Repository navigation
Add Spend by branch & worktree lens (project x branch attribution) - #1297
Closed
ozymandiashh wants to merge 4 commits into
Closed
ozymandiashh wants to merge 4 commits into
ozymandiashh wants to merge 4 commits into
Conversation
Spend per canonical project x branch, keyed by the project identity the spend-flow and By project views already use, so identical branch names in different projects never merge. Reuses the aggregateByBranch rules: last-seen branch carried forward across turns (the parser resolves the carry across a range boundary from pre-range evidence), only ever-branched sessions participate, and turns before a session's first branch stay an explicit Unknown row. Rows carry cost, behavioral calls, token components, distinct sessions (identity-based, rows overlap), activity window, per-session contributions, recorded worktree evidence (historical working directory, never today's checkout), and a coverage split: known / Unknown / no-branch-data sources. Same --period/--provider/--from/--to/--project/--exclude semantics as spend --format flow-json. docs/by-branch.md documents the lens.
New getBranchSpend bridge channel (codeburn:getBranchSpend) spawning 'spend --format branch-json' with the same period/provider/range flags and validation as the other first-click reports, plus background-priority prefetch handling. The renderer keeps the typed contract in lib/types.ts. BranchBreakdown panel: project picker (auto top project, explicit All projects view labeled project/branch), expandable branch rows with token components, worktree evidence and per-session contributions, a real session inspect detail, and the coverage note (known / Unknown / no-branch-data, identity-based distinct sessions). Reuses ListRow/Panel/Dropdown/stale-safe usePolled memo keys; selection is derived so a refresh or a vanished project falls back instead of mixing data.
The default 5173 collides with parallel CodeBurn worktree sessions sharing one machine. strictPort stays on so a busy port fails loudly instead of silently drifting; VITE_DEV_SERVER_URL follows the same port in the dev script. Note the port does NOT isolate the Electron userData profile — parallel sessions must still run the app one at a time.
Member
|
Landed as #1319 (003854c) with your commits and authorship intact, rebased onto current main, plus one fix: getBranchSpend was the only main-process fetch without the Projects-pane filter, so a hidden project still showed its branches; now carries projectArgs() like every sibling, with the scoping test extended. Verified on a frozen range: 1,927 projects and 1,746 branch rows sum exactly to report totals, and every (project, branch) key matches the drill-through contributions to the cent. Branch-switching sessions are attributed per turn. flow-json byte-identical. One pre-existing leak it surfaced is tracked in #1321. Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Spend → By branch: select a project and inspect its AI spend per branch, then expand recorded worktrees and session contributions. Branch identity combines the canonical project id and branch name, so equal branch names in separate projects remain distinct. Worktree evidence comes from recorded historical working directories.
The CLI exposes
branches --format jsonthrough the typed Electron bridge. Attribution carries the last observed branch across turns and preserves unknown metadata explicitly. The existing menubar branch contract remains intact. Desktop development uses the standard port 5173 in both Vite and the Electron launch command.Validation: full root suite compared with upstream/main
a1805393(3,938 passed; the same four Node 26 DEP0205 stderr failures as main); full app suite (888 passed, four skipped); root/app typechecks and CLI/Electron/renderer builds. Branch fixtures cover equal branch names across projects, branch switches, pre-range carry, worktree evidence, missing metadata and token components. The main project-filter suite passes all nine tests on Node 24.Branch metadata coverage follows what providers record. The feature does not infer branch value, merge state or branch-to-PR links. Details:
docs/by-branch.md.