Skip to content

fix(cline): scan all VS Code variants for task storage - #882

Merged
iamtoruk merged 1 commit into
getagentseal:mainfrom
ozymandiashh:fix/874-cline-vscode-variants
Aug 3, 2026
Merged

fix(cline): scan all VS Code variants for task storage#882
iamtoruk merged 1 commit into
getagentseal:mainfrom
ozymandiashh:fix/874-cline-vscode-variants

Conversation

@ozymandiashh

Copy link
Copy Markdown
Collaborator

Refs #874secondary 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.ts calls the singular helper and then always passes a concrete overrideDir:

const baseDirs = configuredDirs ?? [
  getVSCodeGlobalStoragePath(EXTENSION_ID),   // returns paths[0] — stable VS Code only
  getClineDataPath(),
]
const sources = await Promise.all(
  baseDirs.map(dir => discoverClineTasks(EXTENSION_ID, 'cline', 'Cline', dir)),
)

Because overrideDir is never undefined, discoverClineTasks' own 3-variant fallback (vscode-cline-parser.ts:48, which calls the plural getVSCodeGlobalStoragePaths) is unreachable for Cline. Its siblings roo-code.ts:20 and kilo-code.ts:38 pass overrideDir straight 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 getVSCodeGlobalStoragePaths duly covers it — Cline is just the one provider routing around it.

The fix

Spread the plural helper's roots so cline.ts becomes symmetric with its siblings, and hand discoverClineTasks the whole array in one call (it already accepts string | string[]):

const baseDirs = configuredDirs ?? [
  ...getVSCodeGlobalStoragePaths(EXTENSION_ID),
  getClineDataPath(),
]
return dedupeTaskSources(await discoverClineTasks(EXTENSION_ID, 'cline', 'Cline', baseDirs))

vscode-cline-parser.ts is untouched — docs/providers/cline.md asks that the shared Cline-family parser not be destabilized, and Roo Code and KiloCode must keep passing.

No double-counting. dedupeTaskSources already keys by task id (basename) and keeps the newest ui_messages.json by 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/data still scanned, and cross-variant dedup by task id holding (no inflation).

npx tsc --noEmit clean.

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.md gets an entry under Fixed, 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.

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 iamtoruk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@iamtoruk
iamtoruk merged commit 2c69516 into getagentseal:main Aug 3, 2026
4 checks passed
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
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.

Cline provider misses every Cline CLI session (~/.cline/data/sessions, cline@3.0.49) — silently reported as $0.00

2 participants