Skip to content

feat: include projectPath (workdir) in session reports for all agents - #1618

Closed
caius-kong wants to merge 1 commit into
ccusage:mainfrom
caius-kong:feat/session-project-path
Closed

feat: include projectPath (workdir) in session reports for all agents#1618
caius-kong wants to merge 1 commit into
ccusage:mainfrom
caius-kong:feat/session-project-path

Conversation

@caius-kong

@caius-kong caius-kong commented Aug 20, 2026

Copy link
Copy Markdown

Summary

Only the pi adapter was emitting projectPath (the workdir) in session reports, because the generic / claude / qwen loaders passed include_project_path = false to summary_rows().

This PR flips those session-report call sites to true, so all agents get metadata.projectPath in ccusage session --json.

Why

Tools built on top of ccusage (like dashboards) want to group sessions by working directory. Today that data only exists for pi — claude / openclaw / codex / qwen sessions are just opaque IDs.

Safety

summary_metadata() already gates the field on summary.session_id.is_some():

if summary.session_id.is_some() {
    ...
    if include_project_path && let Some(project_path) = summary.project_path.as_ref() {
        metadata.insert("projectPath".to_string(), json!(project_path));
    }
}

So daily / weekly / monthly aggregate rows (no session_id) are unchanged. Only session reports gain the field.

Verified

  • cargo check -p ccusage-adapter-all passes
  • cargo test -p ccusage-adapter-all --no-run compiles
  • Diff is 6 insertions / 3 deletions across a single file

Summary by cubic

Include metadata.projectPath (workdir) in session reports for all agents; previously only pi emitted it. Aggregated daily/weekly/monthly reports remain unchanged because the field only appears when a session_id is present.

  • Affects ccusage session --json only; aggregated reports are unaffected.
  • Changes are limited to rust/crates/ccusage-adapter-all/src/loader.rs, flipping include_project_path to true in three call sites.
  • Dashboards can now group all agents’ sessions by working directory; no migration required.

Written for commit 3905098. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Enhancements
    • Session usage records now include project path metadata for improved context.
    • Applies to generic summaries, Claude, and Qwen session records.
    • Aggregate usage records remain unchanged.

Only the pi adapter was emitting projectPath because the generic/claude/qwen
loaders passed include_project_path=false to summary_rows(). summary_metadata()
already gates the field on session_id being present, so enabling it only affects
session reports (daily/weekly/monthly aggregate rows have no session_id and are
unchanged). Displaying the workdir for every agent's sessions is useful for
dashboards built on top of ccusage (e.g. session grouped by directory).
@github-actions

Copy link
Copy Markdown
Contributor

This PR was auto-closed. Only contributors approved with lgtm can open PRs. Open an issue first.

Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.

If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

See CONTRIBUTING.md.

@github-actions github-actions Bot closed this Aug 20, 2026
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d7ce2f4-37ee-4c2c-ad31-96f45b1f1dac

📥 Commits

Reviewing files that changed from the base of the PR and between 07e86d5 and 3905098.

📒 Files selected for processing (1)
  • rust/crates/ccusage-adapter-all/src/loader.rs

📝 Walkthrough

Walkthrough

The unified loader now includes projectPath metadata in session rows from generic summary agents, Claude, and Qwen. Daily, weekly, and monthly aggregate rows remain unchanged.

Changes

Session project path metadata

Layer / File(s) Summary
Add project path to session rows
rust/crates/ccusage-adapter-all/src/loader.rs
Generic summary-agent, Claude, and Qwen session rows now include projectPath. Aggregate rows remain unchanged.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: ryoppippi

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Clippy (1.97.1)

Clippy execution failed


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Unified Codex session rows still do not expose metadata.projectPath, so the all-agent behavior described by this PR is incomplete.

Reviewed changes

This review covers the single commit that enables existing project-path metadata for the generic, Claude, and Qwen unified session-report paths.

  • Generic session rows — passes include_project_path = true through the shared summary-row helper.
  • Claude and Qwen sessions — enables the same metadata for their dedicated session loaders.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔Fix 👍s ➔View workflow run | Using GPT Luna (free via Pullfrog for OSS) | 𝕏

// Include projectPath (workdir) in session reports for every agent.
// summary_metadata() only emits it when a session_id is present, so
// daily/weekly/monthly aggregate rows are unaffected.
rows: summary_rows(agent, summaries, true),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag only affects the shared summary_rows path, while unified Codex sessions bypass it through load_codex_rows and codex_group_row. As a result, ccusage session --json still has no metadata.projectPath for Codex rows, despite the PR's all-agent claim; please cover that path or narrow the stated scope.

Technical details
# Cover the Codex session path

## Affected sites
- `rust/crates/ccusage-adapter-all/src/loader.rs:628-657``load_codex_rows` constructs Codex rows directly.
- `rust/crates/ccusage-adapter-all/src/loader.rs:830-833``codex_group_row` emits session metadata without `projectPath`.

## Required outcome
- Unified Codex session JSON includes `metadata.projectPath` as promised, or the PR description explicitly narrows the feature to adapters backed by `summary_rows`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants