fix(cline): scan all VS Code variants for task storage - #882
Merged
iamtoruk merged 1 commit intoAug 3, 2026
Merged
Conversation
Cline discovery only looked at the stable VS Code globalStorage root, so tasks created in VS Code Insiders or VSCodium were never found. The singular getVSCodeGlobalStoragePath helper returns paths[0], and because the provider always passed a concrete overrideDir, the 3-variant fallback inside discoverClineTasks was never reached - unlike the Roo Code and KiloCode siblings, which pass overrideDir straight through. Build the default roots from getVSCodeGlobalStoragePaths (stable, Insiders, VSCodium) plus the ~/.cline/data root and hand them to discoverClineTasks in one call. The existing dedupe by task id still collapses a task id seen in more than one root, so totals cannot inflate. The configuredDirs override used by tests and createClineProvider(dirs) is unchanged.
iamtoruk
approved these changes
Aug 3, 2026
iamtoruk
left a comment
Member
There was a problem hiding this comment.
Reviewed in depth on the merged tree (current main). Refs #874 secondary finding only; correctly does not close the headline CLI-layout defect.
- The cline provider used the singular getVSCodeGlobalStoragePath (stable VS Code only) while its roo-code/kilo-code siblings scan all variants; this switches to the plural helper so Insiders and VSCodium globalStorage are covered too. Real undercount fix for users on those variants.
- Full data-flow trace confirms discoverClineTasks(array) routes through discoverClineTasksInBaseDirs, which scans every root and dedups by path; behaviorally equivalent to the old map+flat, just adding two roots. vscode-cline-parser.ts is untouched, so the siblings are unaffected.
- No double-count: dedupeTaskSources keys by task id (basename) and keeps the newest ui_messages.json by mtime, collapsing cross-variant duplicates. Mutation-checked: reverting to the stable-only helper fails both the variant-coverage and cross-variant-dedup tests.
- tsc clean; cline + 3 sibling suites 29/29; full suite green apart from the two standing parser.test.ts failures and a known parallel-load flake that passes in isolation.
Good to merge.
7 tasks
ozymandiashh
pushed a commit
to therickfactr/codeburn
that referenced
this pull request
Aug 3, 2026
The Cline CLI (npm `cline`, 3.x) stores sessions as <sessions>/<id>/<id>.json + <id>.messages.json. The existing `cline` provider only discovers tasks/<id>/ui_messages.json, so every CLI session was silently reported as $0.00 — no warning, not even under --verbose. Adds `cline-cli` as its own provider rather than a third root on `cline`, leaving the shared Cline-family parser (Roo Code, KiloCode, IBM Bob) untouched. It mirrors the CLI's own root resolution (CLINE_SESSION_DATA_DIR -> CLINE_DATA_DIR -> CLINE_DIR -> ~/.cline), implements probeRoots() so `doctor` can tell "not installed" from "wrong override", emits one call per assistant message's `metrics` block, and falls back to the session rollup when a session carries none. The fallback reads `usage`, not `aggregateUsage`, which folds in spawned subagents that are themselves separate session directories. Two supporting changes, both required for CLI costs to report correctly: - parser.ts re-priced cline-cli calls from tokens because the provider was not on the reported-cost allowlist, inflating a real 12-session local sample from $1.11 to $3.92. - session-cache.ts gains the matching PROVIDER_ENV_VARS entry (so a changed override invalidates) and a `reported-cost-v1` parse version (so sessions cached before the allowlist fix re-parse once instead of being re-priced forever). Cost is treated as metered only when actually present and non-negative, so a metered $0 stays reported while a missing or negative cost falls back to token pricing — applied identically on the per-message and rollup paths. Timestamps promote a seconds-resolution value rather than silently landing in 1970, matching the guard kiro.ts uses. CLINE_DIR / CLINE_DATA_DIR / CLINE_SESSION_DATA_DIR are added to the test env-isolation list so a developer's real sessions cannot bleed into fixtures. The VS Code variant discovery bug reported alongside this in getagentseal#874 is deliberately NOT fixed here — it shipped in getagentseal#882. Verified against 18 real local sessions: 142 calls, 4,934,762 input / 224,561 output tokens, and a cost matching the CLI's own metered total to the cent. `codeburn doctor` reports "Cline CLI OK". Refs: getagentseal#874
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.
Refs #874 — secondary finding only. This does not fix #874 and must not close it.
Scope, stated up front
Issue #874 reports two distinct defects. Its headline defect is that the Cline CLI writes
~/.cline/data/sessions/<sessionId>/and nothing in codeburn reads it, so those sessions report $0.00. That one is not touched here — the issue's author uses the CLI daily, has real sessions to test against, and asked which shape you'd prefer before implementing. It's theirs.This PR takes only the issue's secondary finding, which is a self-contained pre-existing bug independent of the CLI layout and shouldn't wait on that design discussion.
The bug
cline.tscalls the singular helper and then always passes a concreteoverrideDir:Because
overrideDiris neverundefined,discoverClineTasks' own 3-variant fallback (vscode-cline-parser.ts:48, which calls the pluralgetVSCodeGlobalStoragePaths) is unreachable for Cline. Its siblingsroo-code.ts:20andkilo-code.ts:38passoverrideDirstraight through, so they do reach it and scan VS Code, VS Code Insiders and VSCodium.Cline is the lone outlier. Users on Insiders or VSCodium get no globalStorage coverage at all. #230 asked for VSCodium support and
getVSCodeGlobalStoragePathsduly covers it — Cline is just the one provider routing around it.The fix
Spread the plural helper's roots so
cline.tsbecomes symmetric with its siblings, and handdiscoverClineTasksthe whole array in one call (it already acceptsstring | string[]):vscode-cline-parser.tsis untouched —docs/providers/cline.mdasks that the shared Cline-family parser not be destabilized, and Roo Code and KiloCode must keep passing.No double-counting.
dedupeTaskSourcesalready keys by task id (basename) and keeps the newestui_messages.jsonby mtime. Absorbing cross-root duplicates is precisely what it exists for, and there is already a test for it across two roots; the new test extends that to three variants.Tests
npx vitest run tests/providers/cline.test.ts tests/providers/roo-code.test.ts tests/providers/kilo-code.test.ts tests/providers/vscode-cline-parser.test.ts— all pass, siblings unaffected. New cases cover: all three variants discovered,~/.cline/datastill scanned, and cross-variant dedup by task id holding (no inflation).npx tsc --noEmitclean.Docs
README.md's provider table explicitly said Insiders/VSCodium coverage was a Roo Code and KiloCode property, which was accurate before this change and wrong after it — corrected.CHANGELOG.mdgets an entry underFixed, worded to describe only the variant scan, since users on those variants will see their totals jump after upgrading.Credit
The diagnosis, the three call-site citations and the discovery probe are all from the #874 reporter. I only confirmed and applied them.