Skip to content

fix(core): re-estimate tokens, fix cache double-counting on provider switch (Fixes #1567)#2145

Open
acoliver wants to merge 5 commits into
mainfrom
issue1567
Open

fix(core): re-estimate tokens, fix cache double-counting on provider switch (Fixes #1567)#2145
acoliver wants to merge 5 commits into
mainfrom
issue1567

Conversation

@acoliver

@acoliver acoliver commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

When switching providers (e.g., Codex → Anthropic via /profile load), the displayed context token count would blow up dramatically (e.g., 96k → 369k), far beyond what tokenizer differences could explain. This caused the compression guard to throw negative numbers and made the UI unusable.

Root cause: Three compounding bugs in the token accounting chain. The user confirmed the chat history SHOULD be reused across provider switches (with counts adjusting for tokenizer differences), but the count was doubling or worse.

Root Cause Analysis

Bug 1: History tokens not re-estimated after provider switch

When the HistoryService was reused across a profile/provider switch, totalTokens retained estimates from the old provider's tokenizer. Switching from GPT (262K context) to Anthropic (200K context) meant the token count was still using GPT estimates — no re-estimation with the Anthropic tokenizer occurred.

Fix: Added resetTokenAccounting() + recalculateTotalTokens(model) calls in ChatSessionFactory when the HistoryService is reused. This re-estimates all conversation history tokens using the new provider's tokenizer.

Bug 2: Stale sync state race condition

syncTotalTokens() queues its operation on the async tokenizerLock chain, while setBaseTokenOffset() runs synchronously. When the HistoryService was reused, a pending syncTotalTokens from the old provider ran AFTER setBaseTokenOffset for the new provider, re-applying the old provider's drift correction to the new count — corrupting it.

Fix: Added a syncGeneration counter to HistoryService. Each resetTokenAccounting() increments the generation; stale queued syncs are now skipped via a generation check inside the async callback.

Bug 3: Cache tokens double-counted in sync formula for OpenAI/Gemini

The sync formula promptTokens + cache_read + cache_creation was correct for Anthropic (where promptTokens = non-cached input only) but double-counted for OpenAI/Gemini (where promptTokens = total input INCLUDING cached tokens).

Fix: Normalized Anthropic's promptTokens to include cache tokens (making it consistent across all providers = total input). Then simplified all sync formulas to use promptTokens directly without adding cache tokens. Updated telemetryEmitter, tokenUsageTracker, and StatsDisplay to treat input_token_count as total-including-cache consistently.

Changes

Core token accounting (packages/core/src/services/history/HistoryService.ts)

  • Added syncGeneration counter and resetTokenAccounting() method (zeroes offset, increments generation, emits event)
  • syncTotalTokens() now captures generation at call time and skips if stale
  • recalculateTotalTokens(modelName?) accepts the actual runtime model instead of hardcoding gpt-4.1

Chat session factory (packages/agents/src/core/ChatSessionFactory.ts)

  • When HistoryService is reused: calls resetTokenAccounting() then await recalculateTotalTokens(model) before applySystemPromptTokenOffset

Sync formulas (packages/agents/src/core/TurnProcessor.ts, streamResponseHelpers.ts)

  • Removed cacheReads + cacheWrites additions from all token sync paths — promptTokens is now used directly

Anthropic provider (packages/providers/src/anthropic/AnthropicResponseParser.ts, AnthropicStreamProcessor.ts)

  • promptTokens and totalTokens now include cacheRead + cacheCreation for consistency with OpenAI/Gemini

Downstream consumers (tokenUsageTracker.ts, telemetryEmitter.ts, StatsDisplay.tsx)

  • tokenUsageTracker: removed cacheTokens from session total accumulation; fixed hit rate formula
  • telemetryEmitter: removed cached_content_token_count from total token sum
  • StatsDisplay: Input Tokens column now subtracts cached tokens (since input includes cache for all providers)

Earlier commits in this PR (still included)

  • tokenLimits.ts: Codex model entries (256K for *-codex, 128K for *-codex-spark)
  • OpenAIProviderContext.tsx: Reset remoteTokenStats on provider identity change
  • useOpenAIProviderInfo.ts: Detect all provider identity changes (not just null transitions)

Testing

  • 7 behavioral tests for HistoryService token reset/generation/invalidation
  • 2 tests for ChatSessionFactory re-estimation on reuse
  • 8 tests for Codex token limits
  • 3 tests for provider stats reset
  • Updated existing token sync, caching-metrics, ProviderManager, and StatsDisplay tests
  • Full verification: typecheck, lint, format, build all pass; smoke test (ollamakimi) passes

Fixes #1567

…on provider switch (Fixes #1567)

The context-window denominator was wrong for Codex models because
tokenLimit() had no Codex entries, causing fallback to the 1M default
when no profile context-limit override was present. Additionally,
remoteTokenStats were only reset when the provider became null rather
than on any provider identity change, carrying stale counts across
provider switches.

Changes:
- tokenLimit(): add Codex model detection (256K default, 128K for
  gpt-5.3-codex-spark). Handles both ID-substring matching
  (gpt-5.x-codex) and provider-prefix matching (codex:gpt-5.5) for
  non-suffixed Codex models. Bare non-suffixed IDs remain ambiguous
  and fall through to the default.
- OpenAIProviderContext: reset remoteTokenStats on provider identity
  change via a ref-tracked previous-value comparison, not just when
  the provider becomes null.
@github-actions github-actions Bot added the maintainer:e2e:ok Trusted contributor; maintainer-approved E2E run label Jun 24, 2026
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • New Features

    • Token usage now stays accurate when switching between providers or models during a session.
    • Existing chat history can be re-evaluated against the current model to keep totals aligned.
  • Bug Fixes

    • Fixed stale token counts carrying over after provider changes.
    • Prevented negative input token values from appearing in displays.
    • Improved cache-aware token totals so session usage and reports are more consistent.

Walkthrough

The PR updates provider-change handling in OpenAIProviderContext, adds Codex-specific tokenLimit resolution for gpt-5.x model IDs, and revises token accounting across providers, history sync, and integration tests to align with the new prompt/input token handling.

Changes

OpenAI provider stats reset

Layer / File(s) Summary
Ref-based provider-change reset and import update
packages/cli/src/ui/contexts/OpenAIProviderContext.tsx
Adds useRef import and replaces the prior reset condition with a previousProviderRef; a useEffect compares the stored provider to the current one and resets remoteTokenStats on any identity change.
Tightened provider-info polling condition
packages/cli/src/ui/hooks/useOpenAIProviderInfo.ts
Removes the separate null/non-null provider comparison from the setProviderInfo guard in the polling interval, relying instead on direct provider inequality plus currentModel and isResponsesAPI comparisons.
Tests for stats reset behavior on provider change
packages/cli/src/ui/contexts/OpenAIProviderContext.test.tsx
New Vitest + RTL test file with provider stubs and a populateStats helper; asserts reset on provider switch, no-reset on same-provider re-render, and reset when provider becomes null.

tokenLimit Codex / gpt-5.x model resolution

Layer / File(s) Summary
Provider-prefix parsing and Codex token-limit rules
packages/core/src/core/tokenLimits.ts
Replaces split(':')[1] with indexOf/slice to extract both providerPrefix and modelWithoutPrefix; adds codex-spark131_072 and general Codex → 262_144 branches before the existing OpenAI prefix checks.
Tests for Codex gpt-5.x model token limits
packages/core/src/core/tokenLimits.test.ts
New describe block covers gpt-5.x IDs with and without codex: prefixes, Spark/max/mini variants, bare ambiguity, and a user-supplied context limit override.

Token accounting and history sync

Layer / File(s) Summary
HistoryService reset and re-estimation
packages/core/src/services/history/HistoryService.ts
Adds generation-gated sync behavior, introduces resetTokenAccounting(), and lets recalculateTotalTokens() accept an optional model name for re-estimation.
HistoryService reset and recalculation tests
packages/core/src/services/history/HistoryService.tokenReset.test.ts
New tests cover resetTokenAccounting(), stale syncTotalTokens() calls around resets, and model-specific recalculateTotalTokens() behavior with a scaling tokenizer helper.
ChatSessionFactory history reuse behavior
packages/agents/src/core/ChatSessionFactory.ts, packages/agents/src/core/ChatSessionFactory.tokenReestimate.test.ts, packages/agents/src/core/ChatSessionFactory.test.ts
When createChatSession reuses a stored HistoryService, it resets token accounting and recalculates totals for the current model before applying the system prompt offset; tests cover the reused and non-reused cases and update the HistoryService mocks.
Prompt-token sync uses API prompt tokens only
packages/agents/src/core/TurnProcessor.ts, packages/agents/src/core/streamResponseHelpers.ts, packages/agents/src/core/chatSession.tokenSync.test.ts
TurnProcessor and streaming helpers now store raw provider prompt tokens, and the Anthropic token-sync test expects the API-reported prompt total rather than the previous cache-adjusted total.
Session totals and cache hit-rate calculations
packages/providers/src/tokenUsageTracker.ts, packages/providers/src/ProviderManager.test.ts, integration-tests/token-tracking.test.ts, integration-tests/token-tracking-integration.test.ts, integration-tests/token-tracking-behavioral.test.ts, integration-tests/token-tracking-provider-behavioral.test.ts, integration-tests/token-tracking-ui-behavioral.test.ts, packages/cli/src/ui/components/StatsDisplay.tsx
Session total aggregation, cache hit-rate calculations, UI display math, and multiple token-tracking tests are updated to match the revised input-token and cache-token handling.
Provider usage and telemetry token counts
packages/providers/src/anthropic/AnthropicResponseParser.ts, packages/providers/src/anthropic/AnthropicStreamProcessor.ts, packages/providers/src/logging/telemetryEmitter.ts, packages/providers/src/anthropic/AnthropicProvider.caching-metrics.test.ts
Anthropic usage parsing and streaming now include cached read and creation tokens in prompt and total counts, telemetry totals exclude cached content from aggregation, and cache-hit tests use prompt-token totals for the hit-rate denominator.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • vybestack/llxprt-code#636: The token-accounting changes here intersect with cache-metric propagation and session token accumulation used by provider tracking and UI stats.
  • vybestack/llxprt-code#754: This PR also changes how cache-related token metrics are extracted and consumed in token tracking.
  • vybestack/llxprt-code#2140: Both PRs modify Anthropic token-accounting logic in response parsing and streaming usage handling.

Poem

A rabbit hops through token streams so bright,
Old counts hop off; the new ones stay in sight.
Ref ears twitch when providers change their name,
Codex gets its limits — just the proper frame. 🐇

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main fix: token re-estimation and cache double-counting on provider switch.
Description check ✅ Passed It includes the problem summary, root-cause analysis, changes, and testing, though it doesn't match the repo's exact template headings.
Linked Issues check ✅ Passed The fixes align with #1567 by recalculating reused history on provider switch and removing stale/cache double-counting paths.
Out of Scope Changes check ✅ Passed The additional Codex/provider UI/test changes still support the same provider-switch token-accounting fix, with no clear unrelated scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue1567

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

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/cli/src/ui/contexts/OpenAIProviderContext.tsx (1)

84-95: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Provider-switch reset can still be skipped due to upstream change detection gap.

Line 85 depends on providerInfo.provider changing, but upstream useOpenAIProviderInfo only updates state when model/Responses-API/nullness changes. A non-null provider swap with unchanged model/flags can leave providerInfo unchanged, so this reset never triggers.

Suggested fix (upstream hook condition)
// packages/cli/src/ui/hooks/useOpenAIProviderInfo.ts
      if (
        newInfo.currentModel !== providerInfo.currentModel ||
        newInfo.isResponsesAPI !== providerInfo.isResponsesAPI ||
+       newInfo.provider !== providerInfo.provider ||
        (newInfo.provider !== null) !== (providerInfo.provider !== null)
      ) {
        setProviderInfo(newInfo);
      }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/ui/contexts/OpenAIProviderContext.tsx` around lines 84 - 95,
The useEffect hook that resets remoteTokenStats depends on providerInfo.provider
changing, but the upstream useOpenAIProviderInfo hook does not include provider
in its change detection logic. This causes the reset to be skipped when a
provider swap occurs with an unchanged model or other flags. Update the
useOpenAIProviderInfo hook to include the provider in its dependency array or
change detection condition so that any provider change triggers state updates
and allows the downstream useEffect in this context to properly reset the token
statistics when needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/cli/src/ui/contexts/OpenAIProviderContext.tsx`:
- Around line 84-95: The useEffect hook that resets remoteTokenStats depends on
providerInfo.provider changing, but the upstream useOpenAIProviderInfo hook does
not include provider in its change detection logic. This causes the reset to be
skipped when a provider swap occurs with an unchanged model or other flags.
Update the useOpenAIProviderInfo hook to include the provider in its dependency
array or change detection condition so that any provider change triggers state
updates and allows the downstream useEffect in this context to properly reset
the token statistics when needed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 82018331-e52b-4550-bbc2-8640ceb9d119

📥 Commits

Reviewing files that changed from the base of the PR and between c15e9b7 and 5a82f1d.

📒 Files selected for processing (4)
  • packages/cli/src/ui/contexts/OpenAIProviderContext.test.tsx
  • packages/cli/src/ui/contexts/OpenAIProviderContext.tsx
  • packages/core/src/core/tokenLimits.test.ts
  • packages/core/src/core/tokenLimits.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: E2E Test (macOS)
  • GitHub Check: E2E Test (Linux) - sandbox:docker
  • GitHub Check: E2E Test (Linux) - sandbox:none
  • GitHub Check: CodeQL
  • GitHub Check: Lint (Javascript)
  • GitHub Check: Interactive UI (tmux)
  • GitHub Check: Run LLxprt review
🧰 Additional context used
🧠 Learnings (9)
📚 Learning: 2026-02-06T15:52:42.315Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1305
File: scripts/generate-keybindings-doc.ts:1-5
Timestamp: 2026-02-06T15:52:42.315Z
Learning: In reviews of vybestack/llxprt-code, do not suggest changing existing copyright headers from 'Google LLC' to 'Vybestack LLC' for files that originated from upstream. Preserve upstream copyrights in files that came from upstream, and only apply 'Vybestack LLC' copyright on newly created, original LLxprt files. If a file is clearly LLxprt-original, it may carry the Vybestack header; if it is upstream-originated, keep the original sponsor header.

Applied to files:

  • packages/core/src/core/tokenLimits.test.ts
  • packages/core/src/core/tokenLimits.ts
📚 Learning: 2026-02-15T21:44:56.598Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1407
File: packages/core/src/core/geminiChatHookTriggers.ts:56-65
Timestamp: 2026-02-15T21:44:56.598Z
Learning: Enforce the canonical speaker-to-role mapping used by GeminiChat hooks: in IContent.speaker, which is strictly typed as 'human | ai | tool' (no 'system'), map 'human' to the 'user' role, 'ai' to the 'model' role, and 'tool' to the 'user' role in all hook payloads. This pattern should be applied across related hook files within packages/core/src/core/ (not just the single file) to ensure consistent role assignment.

Applied to files:

  • packages/core/src/core/tokenLimits.test.ts
  • packages/core/src/core/tokenLimits.ts
📚 Learning: 2026-02-16T19:18:56.265Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1436
File: packages/core/src/core/nonInteractiveToolExecutor.ts:0-0
Timestamp: 2026-02-16T19:18:56.265Z
Learning: Guideline: In the core scheduler architecture, the system runs in a single mode at a time—either interactive or non-interactive, never both on the same scheduler instance. Non-interactive (CLI one-shot) runs without any interactive session; interactive mode subagents run within the parent's interactive context and inherit its mode. When reviewing code, ensure non-interactive tool executions (e.g., in nonInteractiveToolExecutor.ts) create and use a fresh completionResolver per executeToolCall, and that there is no race with interactive sessions since they cannot coexist on the same scheduler instance. This pattern applies across files in packages/core/src/core/. Only apply to relevant files, not globally.

Applied to files:

  • packages/core/src/core/tokenLimits.test.ts
  • packages/core/src/core/tokenLimits.ts
📚 Learning: 2026-03-22T04:06:53.600Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1743
File: packages/core/src/core/TurnProcessor.ts:391-402
Timestamp: 2026-03-22T04:06:53.600Z
Learning: When computing `lastPromptTokenCount` (e.g., in the streaming path like `_convertIContentStream`/equivalent), ensure it includes the full prompt token footprint: `lastPromptTokenCount = promptTokens + cache_read_input_tokens + cache_creation_input_tokens`. Do not use `promptTokens` alone, because cached context would otherwise cause `CompressionHandler.shouldCompress()` to underestimate context usage and may incorrectly suppress needed compression. Keep this combined computation consistent with the non-streaming path (e.g., `TurnProcessor._executeProviderCall`), and do not treat the presence of cache-token additions as redundant—both token types are required for correctness when cached context is active.

Applied to files:

  • packages/core/src/core/tokenLimits.test.ts
  • packages/core/src/core/tokenLimits.ts
📚 Learning: 2026-03-31T02:12:43.093Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1854
File: packages/core/src/core/subagentRuntimeSetup.test.ts:77-84
Timestamp: 2026-03-31T02:12:43.093Z
Learning: In this codebase, tool declarations should follow the single required contract `parametersJsonSchema`; do not ask to preserve or reintroduce the legacy `parameters` fallback field. Reviewers should not flag assertions/checks for missing `parameters` or suggest backward-compatibility behavior for `parameters`. Schema converters/providers are expected to error if `parametersJsonSchema` is absent instead of falling back to `parameters`.

Applied to files:

  • packages/core/src/core/tokenLimits.test.ts
  • packages/core/src/core/tokenLimits.ts
📚 Learning: 2026-06-10T18:18:08.545Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1983
File: packages/policy/src/policy-engine.ts:156-156
Timestamp: 2026-06-10T18:18:08.545Z
Learning: In this repo, ESLint rule `sonarjs/too-many-break-or-continue-in-loop` is set to fail loops that contain more than 1 `break`/`continue` total per loop (or both present). When a loop violates this (e.g., it contains a `break` and a `continue`, or has multiple `break`s/`continue`s), the code will not lint unless the violating line includes `// eslint-disable-next-line sonarjs/too-many-break-or-continue-in-loop`. In code reviews, do not suggest removing these `eslint-disable-next-line` directives (use refactoring only if it eliminates the underlying >1 break/continue pattern).

Applied to files:

  • packages/core/src/core/tokenLimits.test.ts
  • packages/cli/src/ui/contexts/OpenAIProviderContext.test.tsx
  • packages/core/src/core/tokenLimits.ts
  • packages/cli/src/ui/contexts/OpenAIProviderContext.tsx
📚 Learning: 2026-06-10T18:18:09.253Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1983
File: packages/policy/src/policy-engine.ts:263-263
Timestamp: 2026-06-10T18:18:09.253Z
Learning: In this repository, the ESLint rule `sonarjs/too-many-break-or-continue-in-loop` is configured to allow at most 1 `break`/`continue` per loop (it is stricter than the SonarJS default). During code review, treat `// eslint-disable-next-line sonarjs/too-many-break-or-continue-in-loop` on loops with 2+ `break`/`continue` as intentional and do not suggest removing or changing those directives. Only consider a change if the rule is violated without an appropriate intentional disable.

Applied to files:

  • packages/core/src/core/tokenLimits.test.ts
  • packages/cli/src/ui/contexts/OpenAIProviderContext.test.tsx
  • packages/core/src/core/tokenLimits.ts
  • packages/cli/src/ui/contexts/OpenAIProviderContext.tsx
📚 Learning: 2026-06-19T17:16:56.523Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 2108
File: packages/agents/src/api/agentImpl.ts:1047-1079
Timestamp: 2026-06-19T17:16:56.523Z
Learning: When the fake-provider test seam is active in vybestack/llxprt-code, `process.env.LLXPRT_FAKE_RESPONSES` is set to a fixture file path ending in a `.jsonl` (not to the string `'1'` or any other boolean-like value). In code, detect the seam by checking `process.env.LLXPRT_FAKE_RESPONSES !== undefined` (and/or that it is a non-empty string), rather than using `process.env.LLXPRT_FAKE_RESPONSES === '1'`. Update any callers of the env var accordingly (see `packages/providers/src/composition/providerManagerInstance.ts` and harness usages).

Applied to files:

  • packages/core/src/core/tokenLimits.test.ts
  • packages/core/src/core/tokenLimits.ts
📚 Learning: 2026-04-23T23:33:11.797Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1907
File: packages/cli/src/ui/App.test.tsx:1583-1586
Timestamp: 2026-04-23T23:33:11.797Z
Learning: In UI test files under packages/cli/src/ui, prefer test titles/descriptions that state the feature being tested (what behavior the user cares about), even if the assertions specifically exercise a guard/edge path. For example, if the test covers the “empty queue ⇒ no auto-send” branch, a title like “auto-send queued messages” is acceptable; aligning the title perfectly to the exact assertion is optional and not required for lint/enforcement batches.

Applied to files:

  • packages/cli/src/ui/contexts/OpenAIProviderContext.test.tsx
🔇 Additional comments (3)
packages/cli/src/ui/contexts/OpenAIProviderContext.test.tsx (1)

83-163: LGTM!

packages/core/src/core/tokenLimits.ts (1)

90-94: LGTM!

Also applies to: 107-119

packages/core/src/core/tokenLimits.test.ts (1)

88-139: LGTM!

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

LLxprt PR Review – PR #2145

Title: fix(core): re-estimate tokens, fix cache double-counting on provider switch
Author: acoliver | Linked Issue: #1567


Issue Alignment

Evidence: Issue #1567 reported context token count exploding (96k → 369k) when switching providers. The PR correctly identifies and fixes three compounding bugs:

  1. Bug 1 (History tokens not re-estimated): HistoryService retained stale token estimates from the old provider's tokenizer after a switch. Fixed by adding resetTokenAccounting() + recalculateTotalTokens(model) in ChatSessionFactory.ts (lines 348-351), which is called when reused === true.

  2. Bug 2 (Race condition): syncTotalTokens calls queued before a reset could execute after the reset, reapplying stale drift. Fixed via a syncGeneration counter in HistoryService.ts (line 79) — the lock checks generation !== this.syncGeneration before applying drift (lines 239-241).

  3. Bug 3 (Cache double-counting): Cache tokens were being added to both lastPromptTokenCount AND to the base promptTokens from the provider, causing double-counting. Fixed by removing cache token additions from TurnProcessor.ts (lines 616, 830-832), streamResponseHelpers.ts (lines 87-90, 322-323), and tokenUsageTracker.ts (line 102).

The input field now carries a "total-including-cache" invariant — cache tokens are folded into promptTokens at the provider level (AnthropicResponseParser.ts lines 134-137, AnthropicStreamProcessor.ts lines 242-244, 541), not added on top. This is a deliberate design change that ripples through tests and is explicitly documented in comments throughout.


Side Effects

  • tokenUsageTracker.ts line 102: total no longer includes cacheTokens (cache is already inside input). This changes session totals — verified in test updates where total remains consistent but input grows to absorb cache.
  • telemetryEmitter.ts line 83: cached_content_token_count removed from totalTokens (consistent with the new invariant).
  • tokenLimits.ts lines 107-117: Added Codex model limits (256K standard, 128K for "codex-spark" variant) and resolution logic for provider-prefixed vs bare model IDs. This is new behavior not present in the original issue but appears related to the Codex provider context.
  • OpenAIProviderContext.tsx lines 80-88: Stats reset now triggers on provider identity change (using a useRef), not just null-check.

Code Quality

Correctness: The generation-counter pattern for the race fix is sound. The lock closure captures the generation at call time and bails out if it changed. The resetTokenAccounting increment-and-emit pattern is consistent with existing event-driven design.

Error Handling: No new error paths introduced; changes are additive.

Data Validation: None needed — changes are arithmetic/accounting.

Maintainability: The "input includes cache" invariant is well-commented throughout changed files, which will help future maintainers.


Tests and Coverage

Coverage impact: Increase

Two new dedicated test files:

  • HistoryService.tokenReset.test.ts (178 lines): Behavioral tests verifying resetTokenAccounting zeroes offsets, race-condition skipping, and recalculateTotalTokens(model) using the correct tokenizer.
  • ChatSessionFactory.tokenReestimate.test.ts (231 lines): Verifies createChatSession calls both methods when reusing history, and does NOT call them when creating fresh.

Both test files use behavioral assertions (e.g., "does NOT reset token accounting when creating a new HistoryService") rather than mock-theater. The HistoryService.tokenReset.test.ts uses a custom createScalingTokenizerFactory to produce real token count differences, not just verify method calls.

Integration tests across 5 files were updated to reflect the new input invariant (input now = base + cache). Unit tests in tokenLimits.test.ts (53 new lines) cover Codex model limit logic with both prefixed and bare model IDs.


Verdict

Ready

The PR correctly addresses all three root causes of issue #1567 with appropriate behavioral tests. The cache token accounting change is a deliberate, coherent design shift (total-including-cache) that is documented and tested. No blocking issues identified.

…olling

The polling change-detection only compared null/non-null transitions for
the provider, so a swap between two non-null providers with unchanged
model/API flags left providerInfo stale and the downstream
remoteTokenStats reset in OpenAIProviderContext never fired. Replaced
the nullness comparison with a direct identity comparison so any
provider change triggers a state update.
@acoliver

Copy link
Copy Markdown
Collaborator Author

Addressed the CodeRabbit finding (provider-switch reset skipped due to upstream gap): updated the polling change-detection in useOpenAIProviderInfo.ts to use a direct identity comparison (newInfo.provider !== providerInfo.provider) instead of the nullness-only check. This ensures any provider swap — including between two non-null providers with unchanged model/API flags — propagates a state update so the downstream remoteTokenStats reset in OpenAIProviderContext fires correctly. Full CLI suite (4739 tests) passes.

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Summary

Package Lines Statements Functions Branches
CLI 55.98% 55.98% 57.88% 81.91%
Core 76.7% 76.7% 73.36% 83.17%
CLI Package - Full Text Report
-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------|---------|----------|---------|---------|-------------------
All files          |   55.98 |    81.91 |   57.88 |   55.98 |                   
 src               |   70.04 |    65.71 |   89.09 |   70.04 |                   
  cli.tsx          |   56.97 |    59.74 |   78.57 |   56.97 | ...1286,1294-1313 
  ...st-helpers.ts |     100 |       60 |     100 |     100 | 23-34             
  ...ractiveCli.ts |   90.37 |     84.9 |   86.66 |   90.37 | ...04-209,282-284 
  ...liCommands.ts |   97.18 |    63.63 |     100 |   97.18 | 39-40             
  ...CliSupport.ts |   80.04 |    65.04 |      95 |   80.04 | ...76-478,500-501 
  ...ActiveAuth.ts |      60 |    68.42 |     100 |      60 | ...91-106,110-119 
 src/auth          |   98.07 |       80 |     100 |   98.07 |                   
  ...gs-adapter.ts |   98.07 |       80 |     100 |   98.07 | 76                
 src/commands      |   78.35 |      100 |   44.44 |   78.35 |                   
  extensions.tsx   |   55.88 |      100 |       0 |   55.88 | 25-38,42          
  hooks.ts         |   61.53 |      100 |       0 |   61.53 | 14-17,20          
  mcp.ts           |   94.11 |      100 |      50 |   94.11 | 26                
  skills.tsx       |     100 |      100 |     100 |     100 |                   
  utils.ts         |     100 |      100 |     100 |     100 |                   
 ...nds/extensions |    74.1 |    92.93 |   67.18 |    74.1 |                   
  config.ts        |   94.61 |    91.83 |     100 |   94.61 | ...66-167,196-201 
  disable.ts       |     100 |      100 |     100 |     100 |                   
  enable.ts        |     100 |      100 |     100 |     100 |                   
  install.ts       |   80.48 |    76.92 |    87.5 |   80.48 | ...63,199,202-209 
  link.ts          |   64.81 |    83.33 |      25 |   64.81 | 31,54-65,67-72    
  list.ts          |      90 |      100 |   33.33 |      90 | 35-37             
  new.ts           |     100 |      100 |     100 |     100 |                   
  settings.ts      |   72.13 |      100 |      70 |   72.13 | 32-80,218-222,225 
  uninstall.ts     |   78.43 |      100 |   66.66 |   78.43 | 54-59,62-66       
  update.ts        |   10.19 |      100 |       0 |   10.19 | ...71-190,192-197 
  utils.ts         |   13.33 |      100 |       0 |   13.33 | 29-60             
  validate.ts      |   89.36 |     87.5 |      75 |   89.36 | 50-53,60,112-116  
 .../hooks/scripts |       0 |        0 |       0 |       0 |                   
  on-start.js      |       0 |        0 |       0 |       0 | 1-8               
 ...les/mcp-server |       0 |        0 |       0 |       0 |                   
  example.js       |       0 |        0 |       0 |       0 | 1-60              
 ...commands/hooks |    7.59 |      100 |       0 |    7.59 |                   
  migrate.ts       |    7.59 |      100 |       0 |    7.59 | ...90-200,202-204 
 src/commands/mcp  |   96.95 |    86.15 |   94.44 |   96.95 |                   
  add.ts           |   99.56 |    93.33 |     100 |   99.56 | 142               
  list.ts          |   90.51 |    82.14 |      80 |   90.51 | ...13-115,148-150 
  remove.ts        |     100 |    71.42 |     100 |     100 | 21-25             
 ...ommands/skills |   60.98 |     92.3 |   31.25 |   60.98 |                   
  disable.ts       |      54 |      100 |   33.33 |      54 | 40-52,54-63       
  enable.ts        |   72.22 |      100 |   33.33 |   72.22 | 33-37,39-43       
  install.ts       |   42.69 |      100 |      25 |   42.69 | ...71-100,102-109 
  list.ts          |   84.93 |       80 |   33.33 |   84.93 | ...9,92-96,98-100 
  uninstall.ts     |   57.89 |      100 |   33.33 |   57.89 | 47-64,66-71       
 src/config        |   86.45 |    84.98 |   86.94 |   86.45 |                   
  ...deResolver.ts |   94.54 |    95.45 |     100 |   94.54 | 50-52             
  auth.ts          |   84.61 |    82.35 |     100 |   84.61 | 18-19,22-23,53-54 
  cliArgParser.ts  |   92.85 |    89.36 |     100 |   92.85 | ...24,285,287-290 
  config.ts        |     100 |      100 |     100 |     100 |                   
  configBuilder.ts |   95.41 |    95.52 |   66.66 |   95.41 | ...18-219,260-261 
  ...mentLoader.ts |    82.9 |    53.84 |     100 |    82.9 | ...29-131,139-142 
  extension.ts     |   75.07 |    88.23 |   78.04 |   75.07 | ...12-913,916-917 
  ...iveContext.ts |   93.75 |    91.66 |     100 |   93.75 | 79,81,87-92,232   
  ...iateConfig.ts |   96.39 |    97.05 |     100 |   96.39 | 53,150-152        
  keyBindings.ts   |     100 |      100 |     100 |     100 |                   
  ...rverConfig.ts |   83.33 |    94.44 |     100 |   83.33 | 23-39             
  paths.ts         |     100 |      100 |     100 |     100 |                   
  policy.ts        |   80.76 |      100 |      50 |   80.76 | 47-51             
  ...figRuntime.ts |   88.65 |    84.21 |     100 |   88.65 | ...22-429,440-443 
  ...eBootstrap.ts |   91.35 |     87.2 |   97.22 |   91.35 | ...07-809,818-819 
  ...Resolution.ts |   43.51 |    72.41 |    62.5 |   43.51 | ...72-291,303-311 
  ...pplication.ts |   85.03 |       65 |     100 |   85.03 | ...44,146-152,176 
  ...elResolver.ts |   90.38 |    73.68 |     100 |   90.38 | 40,42-43,70,79    
  sandboxConfig.ts |   69.81 |    51.48 |   88.46 |   69.81 | ...80-581,593-594 
  ...oxProfiles.ts |    8.53 |      100 |       0 |    8.53 | 47-48,51-129      
  settingPaths.ts  |     100 |      100 |     100 |     100 |                   
  ...validation.ts |   86.95 |    80.62 |     100 |   86.95 | ...02,404,406,408 
  settings.ts      |   82.92 |    86.27 |   65.21 |   82.92 | ...40-441,496-497 
  ...ingsLegacy.ts |    70.9 |    81.81 |     100 |    70.9 | 48-52,56-67       
  ...ingsLoader.ts |   94.11 |    81.39 |     100 |   94.11 | ...78,108-109,137 
  settingsMerge.ts |   99.51 |    95.65 |     100 |   99.51 | 128-129           
  ...Migrations.ts |   95.67 |    91.66 |     100 |   95.67 | 22-24,48-49,55-56 
  ...ingsSchema.ts |     100 |      100 |     100 |     100 |                   
  ...Governance.ts |   95.83 |    90.62 |     100 |   95.83 | 54,126-129        
  ...tedFolders.ts |   95.58 |       96 |     100 |   95.58 | 93,120-126        
  welcomeConfig.ts |   22.41 |      100 |       0 |   22.41 | ...71,74-79,82-83 
  yargsOptions.ts  |   98.73 |    96.77 |    87.5 |   98.73 | 144,153-156       
 ...fig/extensions |   76.18 |    84.44 |   87.61 |   76.18 |                   
  consent.ts       |   88.03 |    85.71 |     100 |   88.03 | ...77-378,381-382 
  ...ionConsent.ts |   87.38 |    76.66 |     100 |   87.38 | ...,64-67,113-116 
  ...Enablement.ts |    93.9 |       96 |     100 |    93.9 | ...06-212,275-277 
  ...sionLoader.ts |   93.33 |    89.36 |     100 |   93.33 | ...86-187,195-199 
  ...onSettings.ts |     100 |      100 |     100 |     100 |                   
  github.ts        |   62.19 |    81.73 |   70.83 |   62.19 | ...41-642,652-655 
  hookSchema.ts    |     100 |      100 |     100 |     100 |                   
  ...ntegration.ts |   55.31 |    84.78 |      50 |   55.31 | ...61,402,426-427 
  ...ingsPrompt.ts |      73 |    94.73 |      80 |      73 | 92-121            
  ...ngsStorage.ts |   84.77 |    75.92 |     100 |   84.77 | ...90-291,309-312 
  update.ts        |   69.52 |    52.94 |   85.71 |   69.52 | ...73-201,218-226 
  ...ableSchema.ts |     100 |      100 |     100 |     100 |                   
  variables.ts     |   95.55 |       90 |     100 |   95.55 | 33-34             
 ...ettings-schema |   99.78 |       60 |     100 |   99.78 |                   
  schema-core.ts   |     100 |      100 |     100 |     100 |                   
  ...extensions.ts |     100 |      100 |     100 |     100 |                   
  ...a-security.ts |   99.44 |       50 |     100 |   99.44 | 16-17             
  schema-tail.ts   |   99.52 |       50 |     100 |   99.52 | 13-14             
  schema-ui.ts     |     100 |      100 |     100 |     100 |                   
  schema.ts        |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/constants     |     100 |      100 |     100 |     100 |                   
  historyLimits.ts |     100 |      100 |     100 |     100 |                   
 src/extensions    |   66.86 |    61.81 |      75 |   66.86 |                   
  ...utoUpdater.ts |   66.86 |    61.81 |      75 |   66.86 | ...56-457,466,468 
 src/generated     |     100 |      100 |     100 |     100 |                   
  git-commit.ts    |     100 |      100 |     100 |     100 |                   
 ...egration-tests |   71.54 |    83.33 |   85.71 |   71.54 |                   
  ...st-helpers.ts |       0 |        0 |       0 |       0 | 1-79              
  test-utils.ts    |   91.93 |     86.2 |    92.3 |   91.93 | ...45,263-264,274 
 src/patches       |       0 |        0 |       0 |       0 |                   
  is-in-ci.ts      |       0 |        0 |       0 |       0 | 1-17              
 ...viders/logging |   89.31 |    90.24 |   69.23 |   89.31 |                   
  ...rvice-impl.ts |   44.44 |        0 |       0 |   44.44 | 21-22,25-30,36-37 
  git-stats.ts     |   96.46 |     92.5 |     100 |   96.46 | 154-155,195-196   
 src/runtime       |   97.65 |       92 |     100 |   97.65 |                   
  ...imeAdapter.ts |   97.65 |       92 |     100 |   97.65 | ...18-219,308-309 
 src/services      |   86.13 |    86.27 |   95.34 |   86.13 |                   
  ...mandLoader.ts |   79.75 |       75 |   83.33 |   79.75 | ...10-124,168-186 
  ...andService.ts |     100 |      100 |     100 |     100 |                   
  ...mandLoader.ts |   91.77 |    86.53 |     100 |   91.77 | ...10-215,300-307 
  ...omptLoader.ts |    67.5 |    67.85 |     100 |    67.5 | ...75,181-187,202 
  ...tArgParser.ts |   96.49 |    94.91 |     100 |   96.49 | ...,89-90,140-141 
  performResume.ts |   89.11 |    89.18 |     100 |   89.11 | ...61-264,270-271 
  types.ts         |       0 |        0 |       0 |       0 | 1                 
 ...mpt-processors |      98 |    92.85 |     100 |      98 |                   
  ...tProcessor.ts |     100 |      100 |     100 |     100 |                   
  ...lProcessor.ts |   97.88 |    92.45 |     100 |   97.88 | 80-81,265-266     
  types.ts         |     100 |      100 |     100 |     100 |                   
 ...o-continuation |   86.56 |    84.09 |   94.73 |   86.56 |                   
  ...ionService.ts |   86.56 |    84.09 |   94.73 |   86.56 | ...07,574,600-601 
 src/test-utils    |   76.07 |    90.69 |   26.78 |   76.07 |                   
  async.ts         |       0 |        0 |       0 |       0 | 1-34              
  ...eExtension.ts |     100 |      100 |     100 |     100 |                   
  ...omMatchers.ts |    14.7 |      100 |       0 |    14.7 | 13-45             
  ...andContext.ts |     100 |      100 |     100 |     100 |                   
  render.tsx       |   94.84 |    96.55 |      25 |   94.84 | ...51-156,259-260 
  ...e-testing.tsx |       0 |        0 |       0 |       0 | 1-56              
  ...iderConfig.ts |       0 |        0 |       0 |       0 | 1-19              
 src/ui            |   37.77 |    93.44 |   30.48 |   37.77 |                   
  App.tsx          |   37.25 |      100 |       0 |   37.25 | 64-91,97-104      
  AppContainer.tsx |     100 |      100 |     100 |     100 |                   
  ...erRuntime.tsx |   14.28 |      100 |   16.66 |   14.28 | 66-399            
  ...tionNudge.tsx |       8 |      100 |       0 |       8 | 29-104            
  colors.ts        |   37.14 |      100 |   20.33 |   37.14 | ...03-304,306-307 
  constants.ts     |     100 |      100 |     100 |     100 |                   
  debug.ts         |     100 |      100 |     100 |     100 |                   
  ...derOptions.ts |     100 |      100 |     100 |     100 |                   
  keyMatchers.ts   |   88.63 |       84 |     100 |   88.63 | 18,20-21,28-29    
  ...ntsEnabled.ts |     100 |      100 |     100 |     100 |                   
  ...submission.ts |     100 |      100 |     100 |     100 |                   
  ...tic-colors.ts |   78.94 |      100 |      60 |   78.94 | 15-16,24-25       
  textConstants.ts |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/ui/commands   |   71.08 |    76.71 |    76.9 |   71.08 |                   
  aboutCommand.ts  |   82.84 |    51.51 |   91.66 |   82.84 | ...92-193,195-196 
  authCommand.ts   |   49.52 |    77.33 |   58.33 |   49.52 | ...51-654,665-707 
  ...urlCommand.ts |      30 |      100 |       0 |      30 | 20-40             
  bugCommand.ts    |   71.23 |    30.76 |     100 |   71.23 | ...99-110,145-153 
  chatCommand.ts   |   69.72 |    74.62 |   66.66 |   69.72 | ...50-551,599-610 
  clearCommand.ts  |   88.88 |    88.88 |     100 |   88.88 | 96-103            
  ...essCommand.ts |    97.7 |    89.28 |     100 |    97.7 | 41,63-64          
  ...nueCommand.ts |     100 |      100 |     100 |     100 |                   
  copyCommand.ts   |     100 |      100 |     100 |     100 |                   
  debugCommands.ts |   13.29 |      100 |       0 |   13.29 | ...49,456,463,470 
  ...st-helpers.ts |   89.62 |     91.3 |      50 |   89.62 | ...93,95-96,98-99 
  ...icsCommand.ts |   66.28 |    32.83 |   84.61 |   66.28 | ...99-402,417-422 
  ...ticsTokens.ts |   90.96 |    87.17 |     100 |   90.96 | ...,67-72,107-108 
  ...ryCommand.tsx |    89.5 |    84.84 |     100 |    89.5 | ...29-137,204-212 
  docsCommand.ts   |     100 |      100 |     100 |     100 |                   
  ...extCommand.ts |   96.22 |    89.65 |     100 |   96.22 | 216-221           
  editorCommand.ts |     100 |      100 |     100 |     100 |                   
  ...onsCommand.ts |   41.27 |    88.09 |    62.5 |   41.27 | ...24-381,391-539 
  ...ionSection.ts |   83.33 |    93.33 |     100 |   83.33 | 28-34             
  helpCommand.ts   |     100 |      100 |     100 |     100 |                   
  hooksCommand.ts  |   89.62 |    87.27 |     100 |   89.62 | ...54,344-345,459 
  ideCommand.ts    |   69.87 |    73.52 |   69.23 |   69.87 | ...36-237,240-255 
  initCommand.ts   |   80.26 |    71.42 |   66.66 |   80.26 | 36-40,42-89       
  keyCommand.ts    |   89.87 |    80.76 |     100 |   89.87 | ...92,415-416,515 
  ...ileCommand.ts |    10.9 |      100 |       0 |    10.9 | 22-46,53-141      
  ...ingCommand.ts |   10.27 |      100 |       0 |   10.27 | ...19-572,589-601 
  logoutCommand.ts |   15.87 |      100 |       0 |   15.87 | 21-84             
  lspCommand.ts    |    90.9 |    87.17 |     100 |    90.9 | ...18-123,147-149 
  mcpAuth.ts       |   90.59 |    83.33 |   66.66 |   90.59 | 35-44,89-90       
  mcpCommand.ts    |   96.22 |    85.71 |     100 |   96.22 | 93-98             
  mcpDisplay.ts    |   83.25 |     80.8 |   94.11 |   83.25 | ...89-490,517-518 
  memoryCommand.ts |   87.45 |    75.47 |     100 |   87.45 | ...46,234-248,297 
  modelCommand.ts  |   98.92 |    93.02 |     100 |   98.92 | 120               
  mouseCommand.ts  |     100 |      100 |     100 |     100 |                   
  ...onsCommand.ts |    93.9 |    88.88 |     100 |    93.9 | 58-62             
  ...iesCommand.ts |   97.05 |    80.55 |     100 |   97.05 | 27,40-41          
  ...acyCommand.ts |   61.53 |      100 |       0 |   61.53 | 22-26             
  ...ileCommand.ts |   56.52 |    46.42 |   55.55 |   56.52 | ...35-476,497-513 
  profileLoad.ts   |   51.74 |       60 |    87.5 |   51.74 | ...47,174,185-189 
  ...adBalancer.ts |   81.36 |    84.61 |     100 |   81.36 | ...20-321,347-352 
  ...ileSchemas.ts |   67.11 |    81.81 |     100 |   67.11 | ...18-230,262-267 
  ...derCommand.ts |   56.96 |    31.57 |   88.88 |   56.96 | ...89-290,299-304 
  quitCommand.ts   |   36.66 |      100 |       0 |   36.66 | 17-36             
  ...oreCommand.ts |   90.16 |    82.85 |     100 |   90.16 | ...69-174,207-212 
  setCommand.ts    |   86.32 |    84.28 |     100 |   86.32 | ...91-200,217-222 
  ...mandSchema.ts |   71.57 |    81.81 |   84.61 |   71.57 | ...05,232-240,295 
  ...ngsCommand.ts |     100 |      100 |     100 |     100 |                   
  setupCommand.ts  |     100 |      100 |     100 |     100 |                   
  ...hubCommand.ts |   90.47 |    82.85 |     100 |   90.47 | ...13-216,223-227 
  skillsCommand.ts |   82.78 |       75 |     100 |   82.78 | ...91-292,305-306 
  statsCommand.ts  |   57.25 |    86.66 |   58.33 |   57.25 | ...04-216,234-235 
  statsQuota.ts    |   80.16 |     67.1 |   86.66 |   80.16 | ...05-406,439-443 
  ...entCommand.ts |   76.72 |    69.73 |   81.81 |   76.72 | ...09-615,626-632 
  tasksCommand.ts  |   78.53 |    78.78 |     100 |   78.53 | ...78-186,247-254 
  ...tupCommand.ts |     100 |      100 |     100 |     100 |                   
  themeCommand.ts  |     100 |      100 |     100 |     100 |                   
  todoCommand.ts   |   82.24 |    72.28 |     100 |   82.24 | ...48-460,468-472 
  ...Formatters.ts |   48.93 |    71.42 |   33.33 |   48.93 | ...5,70-86,92-113 
  ...Operations.ts |   85.75 |    77.77 |   95.23 |   85.75 | ...63-364,402-416 
  ...matCommand.ts |   26.66 |      100 |       0 |   26.66 | 33-92             
  ...keyCommand.ts |   98.88 |     92.3 |     100 |   98.88 | 34                
  ...ileCommand.ts |    99.1 |    94.11 |     100 |    99.1 | 36                
  toolsCommand.ts  |   86.56 |    76.47 |     100 |   86.56 | ...59,293,324-325 
  types.ts         |     100 |      100 |     100 |     100 |                   
  ...ileCommand.ts |   27.77 |        0 |       0 |   27.77 | 11-23             
  vimCommand.ts    |   44.44 |      100 |       0 |   44.44 | 15-25             
 ...ommands/schema |   96.06 |    92.54 |   94.11 |   96.06 |                   
  index.ts         |   95.84 |    91.58 |     100 |   95.84 | ...07-211,222-223 
  schemaHelpers.ts |   97.02 |    96.22 |     100 |   97.02 | 67-68,115-117     
  types.ts         |       0 |        0 |       0 |       0 | 1                 
 src/ui/components |   11.62 |    39.04 |     7.5 |   11.62 |                   
  AboutBox.tsx     |   12.19 |      100 |       0 |   12.19 | ...,76-98,102-130 
  AnsiOutput.tsx   |    8.33 |      100 |       0 |    8.33 | 25-90             
  AppHeader.tsx    |   21.87 |      100 |       0 |   21.87 | 26-56             
  AsciiArt.ts      |     100 |      100 |     100 |     100 |                   
  AuthDialog.tsx   |    4.36 |      100 |       0 |    4.36 | ...38-263,266-347 
  ...nProgress.tsx |       0 |        0 |       0 |       0 | 1-63              
  ...Indicator.tsx |   15.15 |      100 |       0 |   15.15 | 17-47             
  ...firmation.tsx |   15.38 |      100 |       0 |   15.38 | 59-134,143-208    
  ...tsDisplay.tsx |   10.37 |      100 |       0 |   10.37 | ...70-110,114-168 
  CliSpinner.tsx   |       0 |        0 |       0 |       0 | 1-22              
  Composer.tsx     |    7.14 |      100 |       0 |    7.14 | 16-29,42-97       
  ...entPrompt.tsx |   18.75 |      100 |       0 |   18.75 | 21-51             
  ...ryDisplay.tsx |   21.05 |      100 |       0 |   21.05 | 17-35             
  ...ryDisplay.tsx |    4.65 |      100 |       0 |    4.65 | 29-107,110-174    
  ...geDisplay.tsx |       0 |        0 |       0 |       0 | 1-37              
  ...gProfiler.tsx |   16.86 |      100 |       0 |   16.86 | ...73-118,122-224 
  ...esDisplay.tsx |   10.52 |      100 |       0 |   10.52 | 24-82             
  ...ogManager.tsx |    5.54 |      100 |       0 |    5.54 | 71-782,786-810    
  ...ngsDialog.tsx |   12.56 |      100 |       0 |   12.56 | ...48-172,176-247 
  ...rBoundary.tsx |   10.16 |        0 |       0 |   10.16 | ...19-164,182-195 
  ...ustDialog.tsx |   16.34 |      100 |       0 |   16.34 | ...2,70-81,84-143 
  Footer.tsx       |   11.06 |        0 |       0 |   11.06 | ...24-693,698-715 
  ...ngSpinner.tsx |    40.9 |      100 |       0 |    40.9 | 31-47             
  Header.tsx       |    17.5 |      100 |       0 |    17.5 | 22-62             
  Help.tsx         |    6.84 |      100 |       0 |    6.84 | ...87-190,194-206 
  ...emDisplay.tsx |   12.01 |      100 |       0 |   12.01 | 55-239,242-280    
  ...usDisplay.tsx |       0 |        0 |       0 |       0 | 1-47              
  InputPrompt.tsx  |   53.38 |     42.1 |   67.34 |   53.38 | ...1639-1644,1662 
  ...tsDisplay.tsx |    4.36 |      100 |       0 |    4.36 | ...32-226,229-292 
  ...utManager.tsx |       0 |        0 |       0 |       0 | 1-99              
  ...ileDialog.tsx |    8.33 |      100 |       0 |    8.33 | ...8,72-81,85-152 
  ...Indicator.tsx |   13.84 |      100 |       0 |   13.84 | 20-24,34-96       
  ...ingDialog.tsx |    4.92 |      100 |       0 |    4.92 | ...65-382,386-435 
  ...geDisplay.tsx |       0 |        0 |       0 |       0 | 1-41              
  ModelDialog.tsx  |     3.6 |      100 |       0 |     3.6 | ...66-739,743-829 
  ...tsDisplay.tsx |    3.82 |      100 |       0 |    3.82 | 32-205,208-259    
  ...fications.tsx |   17.32 |      100 |       0 |   17.32 | ...11-142,145-180 
  ...odeDialog.tsx |     7.4 |      100 |       0 |     7.4 | 32-141            
  ...ustDialog.tsx |    5.53 |      100 |       0 |    5.53 | ...36-273,278-313 
  PrepareLabel.tsx |   13.33 |      100 |       0 |   13.33 | 20-48             
  ...ailDialog.tsx |   11.36 |      100 |       0 |   11.36 | ...93-499,503-576 
  ...ineEditor.tsx |    4.15 |      100 |       0 |    4.15 | ...68-554,557-632 
  ...istDialog.tsx |     4.6 |      100 |       0 |     4.6 | ...88-525,528-614 
  ...derDialog.tsx |    2.63 |      100 |       0 |    2.63 | 60-408,411-426    
  ...Indicator.tsx |       0 |        0 |       0 |       0 | 1-21              
  ...eKeyInput.tsx |       0 |        0 |       0 |       0 | 1-149             
  ...serDialog.tsx |    9.56 |      100 |       0 |    9.56 | ...52-603,611-670 
  ...ryDisplay.tsx |      50 |      100 |       0 |      50 | 15-17             
  ...ngsDialog.tsx |    1.03 |      100 |       0 |    1.03 | ...1738,1743-2800 
  ...putPrompt.tsx |   14.28 |      100 |       0 |   14.28 | 19-58             
  ...Indicator.tsx |   44.44 |      100 |       0 |   44.44 | 12-17             
  ...MoreLines.tsx |   30.43 |      100 |       0 |   30.43 | 18-38             
  StatsDisplay.tsx |    8.98 |      100 |       0 |    8.98 | ...40-445,449-500 
  ...usDisplay.tsx |       0 |        0 |       0 |       0 | 1-59              
  StickyHeader.tsx |    7.14 |      100 |       0 |    7.14 | 20-78             
  ...nsDisplay.tsx |    5.83 |      100 |       0 |    5.83 | 39-91,105-181     
  Table.tsx        |    7.54 |      100 |       0 |    7.54 | 27-89             
  ThemeDialog.tsx  |    3.96 |      100 |       0 |    3.96 | 51-441,444-500    
  ...dGradient.tsx |      25 |      100 |       0 |      25 | 27-46             
  Tips.tsx         |      16 |      100 |       0 |      16 | 17-45             
  TodoPanel.tsx    |     5.9 |      100 |       0 |     5.9 | ...87-244,247-296 
  ...tsDisplay.tsx |   10.05 |      100 |       0 |   10.05 | ...88-227,230-259 
  ToolsDialog.tsx  |   10.63 |      100 |       0 |   10.63 | ...5,41-47,50-123 
  ...ification.tsx |   36.36 |      100 |       0 |   36.36 | 15-22             
  ...ionDialog.tsx |    6.08 |      100 |       0 |    6.08 | 18-104,110-161    
  todo-utils.ts    |       0 |        0 |       0 |       0 | 1-7               
 ...leCreateWizard |   18.43 |       50 |       0 |   18.43 |                   
  ...aramsStep.tsx |   11.34 |      100 |       0 |   11.34 | ...34-247,259-343 
  ...ationStep.tsx |    7.12 |      100 |       0 |    7.12 | ...08-544,556-624 
  ...onfigStep.tsx |   12.35 |      100 |       0 |   12.35 | 19-25,36-117      
  ...electStep.tsx |    9.73 |      100 |       0 |    9.73 | ...13-280,296-341 
  ...ationMenu.tsx |       0 |        0 |       0 |       0 | 1-102             
  ...eSaveStep.tsx |    7.45 |      100 |       0 |    7.45 | ...76-305,317-396 
  ...ssSummary.tsx |   12.12 |      100 |       0 |   12.12 | 23-88             
  ...electStep.tsx |   16.92 |      100 |       0 |   16.92 | 28-97             
  TextInput.tsx    |    6.56 |      100 |       0 |    6.56 | ...01-111,119-202 
  constants.ts     |     100 |      100 |     100 |     100 |                   
  index.tsx        |   14.51 |      100 |       0 |   14.51 | ...94-223,232-316 
  types.ts         |     100 |      100 |     100 |     100 |                   
  utils.ts         |    5.15 |      100 |       0 |    5.15 | ...53-356,361-378 
  validation.ts    |   11.23 |      100 |       0 |   11.23 | ...97-104,107-111 
 ...gentManagement |    4.22 |      100 |       0 |    4.22 |                   
  ...entWizard.tsx |    2.91 |      100 |       0 |    2.91 | 30-232,237-312    
  ...ionWizard.tsx |    1.44 |      100 |       0 |    1.44 | 30-592,595-676    
  ...eteDialog.tsx |    5.88 |      100 |       0 |    5.88 | 14-94,104-147     
  ...tEditForm.tsx |    1.77 |      100 |       0 |    1.77 | 30-619,622-640    
  ...tListMenu.tsx |    2.94 |      100 |       0 |    2.94 | 17-266,269-350    
  ...tMainMenu.tsx |   16.66 |      100 |       0 |   16.66 | 22-62             
  ...gerDialog.tsx |    2.39 |      100 |       0 |    2.39 | 29-601,604-680    
  ...tShowView.tsx |    4.76 |      100 |       0 |    4.76 | 25-183,186-243    
  index.ts         |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 ...comeOnboarding |   14.36 |        0 |       0 |   14.36 |                   
  ...ethodStep.tsx |   22.47 |      100 |       0 |   22.47 | 44-129            
  ...ationStep.tsx |    7.35 |      100 |       0 |    7.35 | ...1,59-95,98-177 
  ...etionStep.tsx |    9.84 |      100 |       0 |    9.84 | ...,89-99,103-179 
  ...electStep.tsx |   12.12 |      100 |       0 |   12.12 | ...3,67-75,79-143 
  ...electStep.tsx |   34.48 |      100 |       0 |   34.48 | 51-120            
  SkipExitStep.tsx |    12.5 |      100 |       0 |    12.5 | 18-59             
  ...omeDialog.tsx |   11.76 |      100 |       0 |   11.76 | 51-118,121-166    
  WelcomeStep.tsx  |    10.2 |      100 |       0 |    10.2 | 23-74             
  index.ts         |       0 |        0 |       0 |       0 | 1-13              
 ...nents/messages |   18.01 |    88.63 |   12.67 |   18.01 |                   
  ...onMessage.tsx |   12.28 |      100 |       0 |   12.28 | 24-86             
  DiffRenderer.tsx |    3.02 |      100 |       0 |    3.02 | ...10-441,444-462 
  ErrorMessage.tsx |   22.22 |      100 |       0 |   22.22 | 16-31             
  ...niMessage.tsx |   14.51 |      100 |       0 |   14.51 | 28-95             
  ...geContent.tsx |   20.83 |      100 |       0 |   20.83 | 26-46             
  InfoMessage.tsx  |   19.23 |      100 |       0 |   19.23 | 19-41             
  ...rlMessage.tsx |   11.36 |      100 |       0 |   11.36 | 18-65             
  ...geMessage.tsx |     100 |      100 |     100 |     100 |                   
  ...ckDisplay.tsx |      20 |      100 |       0 |      20 | 43-64             
  ...onMessage.tsx |    3.18 |      100 |       0 |    3.18 | 40-524,537-616    
  ...upMessage.tsx |    6.77 |      100 |       0 |    6.77 | ...03-300,304-379 
  ToolMessage.tsx  |    4.33 |      100 |       0 |    4.33 | 40-342,358-428    
  ...ltDisplay.tsx |   91.53 |    85.71 |     100 |   91.53 | 39-53,222-224     
  ToolShared.tsx   |   64.61 |       90 |   33.33 |   64.61 | 78-99,102-105     
  UserMessage.tsx  |     100 |      100 |     100 |     100 |                   
  ...llMessage.tsx |   36.36 |      100 |       0 |   36.36 | 17-25             
  ...ngMessage.tsx |   26.31 |      100 |       0 |   26.31 | 17-32             
 ...ponents/shared |   41.49 |    64.39 |   40.85 |   41.49 |                   
  ...ctionList.tsx |    4.31 |      100 |       0 |    4.31 | 36-123,128-206    
  MaxSizedBox.tsx  |   49.89 |     58.1 |      75 |   49.89 | ...63-666,670-673 
  ...tonSelect.tsx |   12.76 |      100 |       0 |   12.76 | 66-113            
  ...lableList.tsx |    5.15 |      100 |       0 |    5.15 | 40-267            
  ...ist.hooks.tsx |    3.84 |      100 |       0 |    3.84 | ...68-793,796-833 
  ...lizedList.tsx |   11.11 |      100 |       0 |   11.11 | 28-108            
  ...List.types.ts |     100 |      100 |     100 |     100 |                   
  ...operations.ts |   75.54 |    48.14 |     100 |   75.54 | ...32-233,256-265 
  ...er-reducer.ts |   28.25 |    51.11 |   33.33 |   28.25 | ...30,632,644,687 
  buffer-types.ts  |     100 |      100 |     100 |     100 |                   
  text-buffer.ts   |   71.75 |    89.18 |   27.86 |   71.75 | ...33-635,654-660 
  ...formations.ts |   56.04 |     75.6 |    87.5 |   56.04 | ...74-181,205-251 
  ...n-handlers.ts |   33.99 |    61.53 |   23.25 |   33.99 | ...47-755,758-762 
  ...st-helpers.ts |       0 |        0 |       0 |       0 | 1-33              
  ...er-actions.ts |   93.84 |     87.5 |     100 |   93.84 | 91-93,100         
  visual-layout.ts |    90.2 |    71.73 |     100 |    90.2 | ...48-350,372-373 
  ...navigation.ts |   53.01 |    60.93 |   73.68 |   53.01 | ...39-360,383-405 
 ...mponents/views |    8.89 |      100 |       0 |    8.89 |                   
  ChatList.tsx     |    14.7 |      100 |       0 |    14.7 | 18-52             
  ...sionsList.tsx |    7.59 |      100 |       0 |    7.59 | 19-103            
  HooksList.tsx    |    10.1 |      100 |       0 |    10.1 | ...15-126,129-144 
  SkillsList.tsx   |    5.79 |      100 |       0 |    5.79 | 18-103            
 src/ui/constants  |   55.78 |     90.9 |      50 |   55.78 |                   
  ...ollections.ts |     100 |      100 |     100 |     100 |                   
  tips.ts          |       0 |        0 |       0 |       0 | 1-164             
 src/ui/containers |       0 |        0 |       0 |       0 |                   
  ...ontroller.tsx |       0 |        0 |       0 |       0 | 1-362             
  UIStateShell.tsx |       0 |        0 |       0 |       0 | 1-15              
 ...ainer/builders |   98.38 |      100 |   83.33 |   98.38 |                   
  ...dUIActions.ts |     100 |      100 |     100 |     100 |                   
  buildUIState.ts  |     100 |      100 |     100 |     100 |                   
  ...onsBuilder.ts |   66.66 |      100 |       0 |   66.66 | 21-22             
  ...ateBuilder.ts |   66.66 |      100 |       0 |   66.66 | 21-22             
 ...ontainer/hooks |   55.17 |     87.1 |   56.52 |   55.17 |                   
  ...pBootstrap.ts |   94.71 |    58.33 |     100 |   94.71 | ...20-223,227-229 
  useAppDialogs.ts |   41.37 |      100 |   42.85 |   41.37 | ...63,182-398,418 
  ...ntHandlers.ts |     100 |      100 |     100 |     100 |                   
  useAppInput.ts   |    5.55 |      100 |       0 |    5.55 | 100-521,524-528   
  useAppLayout.ts  |    7.92 |      100 |       0 |    7.92 | 92-299,302-305    
  ...reenAction.ts |   13.63 |      100 |       0 |   13.63 | 23-42             
  ...nSelection.ts |      20 |      100 |       0 |      20 | 27-48             
  ...hestration.ts |     100 |      100 |     100 |     100 |                   
  ...references.ts |      10 |      100 |       0 |      10 | 51-104            
  ...itHandling.ts |   89.79 |      100 |     100 |   89.79 | 131-139,143       
  ...textBridge.ts |   33.33 |      100 |       0 |   33.33 | 23-30             
  ...tartHotkey.ts |   26.66 |      100 |       0 |   26.66 | 23-33             
  ...omptSubmit.ts |     100 |      100 |     100 |     100 |                   
  ...utHandling.ts |   98.37 |     91.3 |     100 |   98.37 | 53,167            
  ...yBootstrap.ts |      30 |      100 |       0 |      30 | 28-34             
  ...eybindings.ts |   86.28 |    78.18 |     100 |   86.28 | ...06-208,252-253 
  ...easurement.ts |   15.38 |      100 |       0 |   15.38 | 45-95             
  ...reshAction.ts |   79.16 |     37.5 |     100 |   79.16 | 51,82-85,87-96    
  ...untimeSync.ts |     100 |      100 |     100 |     100 |                   
  ...elTracking.ts |   26.22 |      100 |      50 |   26.22 | 20-24,60-113      
  ...laceholder.ts |      15 |      100 |       0 |      15 | 13-18,21-34       
  ...rorTimeout.ts |   17.64 |      100 |       0 |   17.64 | 24-39             
  ...astructure.ts |   73.91 |      100 |      20 |   73.91 | 53,57,61,75-83    
  ...ebugLogger.ts |   17.24 |      100 |       0 |   17.24 | 23-51             
  ...ialization.ts |   70.45 |    84.61 |   66.66 |   70.45 | ...,72-94,127-128 
  ...sAutoReset.ts |     100 |       90 |     100 |     100 | 44                
  ...andActions.ts |     100 |      100 |     100 |     100 |                   
  ...eshManager.ts |     100 |      100 |     100 |     100 |                   
  ...uationFlow.ts |    7.93 |      100 |       0 |    7.93 | 54-150            
  ...csTracking.ts |    95.8 |    80.64 |     100 |    95.8 | ...32-133,184-185 
  ...uthBridges.ts |   17.94 |      100 |   33.33 |   17.94 | ...13-138,142-146 
 src/ui/contexts   |   56.12 |    79.18 |   53.33 |   56.12 |                   
  ...chContext.tsx |   88.23 |    66.66 |     100 |   88.23 | 27-28             
  FocusContext.tsx |       0 |        0 |       0 |       0 | 1-11              
  ...ssContext.tsx |   83.75 |     86.7 |    87.5 |   83.75 | ...17-520,573-574 
  MouseContext.tsx |   78.82 |       75 |      80 |   78.82 | ...00-101,111-117 
  ...erContext.tsx |   94.44 |    63.63 |     100 |   94.44 | 127-130           
  ...owContext.tsx |   21.42 |      100 |   33.33 |   21.42 | 34,40-88          
  ...meContext.tsx |   52.34 |       40 |   57.14 |   52.34 | ...95-196,201-202 
  ...lProvider.tsx |   92.05 |    73.84 |     100 |   92.05 | ...85-486,498-499 
  ...onContext.tsx |     4.4 |      100 |       0 |     4.4 | ...40-395,400-407 
  ...teContext.tsx |       0 |        0 |       0 |       0 | 1-57              
  ...gsContext.tsx |      50 |      100 |       0 |      50 | 15-20             
  ...ngContext.tsx |   42.85 |      100 |       0 |   42.85 | 15-22             
  TodoContext.tsx  |   54.54 |      100 |       0 |   54.54 | 28-31,33-36,39-40 
  TodoProvider.tsx |    3.37 |      100 |       0 |    3.37 | 27-167,170-200    
  ...llContext.tsx |     100 |      100 |       0 |     100 |                   
  ...lProvider.tsx |    6.75 |      100 |       0 |    6.75 | 24-118            
  ...nsContext.tsx |      25 |      100 |       0 |      25 | 203-214,217-222   
  ...teContext.tsx |      50 |       50 |      50 |      50 | 251-260,265-266   
  ...deContext.tsx |   11.11 |      100 |       0 |   11.11 | 30-82,85-90       
 src/ui/editors    |   98.18 |     87.5 |     100 |   98.18 |                   
  ...ngsManager.ts |   98.18 |     87.5 |     100 |   98.18 | 59                
 src/ui/hooks      |    68.4 |    85.81 |   72.52 |    68.4 |                   
  ...st-helpers.ts |    95.9 |    90.47 |   56.66 |    95.9 | 67,79-80,98-99    
  ...dProcessor.ts |   87.95 |    87.09 |   88.88 |   87.95 | ...78-180,241-253 
  ...sorHelpers.ts |    78.8 |    78.57 |   88.88 |    78.8 | ...21-822,850-856 
  ...etionUtils.ts |   53.36 |    88.23 |   64.28 |   53.36 | 57-207,335        
  index.ts         |       0 |        0 |       0 |       0 | 1-9               
  keyToAnsi.ts     |    42.5 |      100 |       0 |    42.5 | 27-37,47-61       
  ...etionUtils.ts |     100 |    66.66 |     100 |     100 | 49                
  ...dProcessor.ts |   96.29 |       80 |     100 |   96.29 | ...74-275,407-411 
  ...ndHandlers.ts |    17.6 |    27.27 |   22.22 |    17.6 | ...44-645,650-659 
  ...dPathUtils.ts |    95.7 |    90.52 |     100 |    95.7 | ...25-227,271-272 
  ...dProcessor.ts |     100 |      100 |     100 |     100 |                   
  ...sorSupport.ts |   68.72 |    70.83 |   66.66 |   68.72 | ...82-285,303-310 
  ...tionEffect.ts |   90.76 |    86.56 |   92.85 |   90.76 | ...04-405,418-419 
  ...etionTypes.ts |       0 |        0 |       0 |       0 | 1                 
  toolMapping.ts   |   90.76 |    88.88 |   93.33 |   90.76 | ...95-207,226-228 
  ...nateBuffer.ts |      50 |      100 |       0 |      50 | 16-18             
  ...dScrollbar.ts |   97.82 |      100 |     100 |   97.82 | 153-155           
  ...st-helpers.ts |     100 |      100 |     100 |     100 |                   
  ...Completion.ts |   92.52 |    89.65 |     100 |   92.52 | ...02-603,606-607 
  ...uthCommand.ts |   96.42 |    66.66 |     100 |   96.42 | 21                
  ...tIndicator.ts |     100 |     92.3 |     100 |     100 | 57                
  useBanner.ts     |     100 |    83.33 |     100 |     100 | 22,48             
  ...chedScroll.ts |   16.66 |      100 |       0 |   16.66 | 14-32             
  ...ketedPaste.ts |      20 |      100 |       0 |      20 | 20-38             
  ...ompletion.tsx |   97.24 |    82.75 |    90.9 |   97.24 | ...04-206,209-210 
  useCompletion.ts |    92.4 |     87.5 |     100 |    92.4 | 68-69,93-94,98-99 
  ...leMessages.ts |   96.15 |       90 |     100 |   96.15 | 56-57,63          
  ...ntHandlers.ts |   31.25 |      100 |     100 |   31.25 | 43-70,74-82       
  ...fileDialog.ts |   16.12 |      100 |       0 |   16.12 | 17-47             
  ...orSettings.ts |   11.86 |      100 |       0 |   11.86 | 31-87             
  ...AutoUpdate.ts |    8.33 |      100 |       0 |    8.33 | 18-64             
  ...ionUpdates.ts |   75.17 |    80.64 |   77.77 |   75.17 | ...60-261,289-303 
  ...erDetector.ts |     100 |      100 |     100 |     100 |                   
  useFocus.ts      |     100 |      100 |     100 |     100 |                   
  ...olderTrust.ts |   87.09 |     91.3 |     100 |   87.09 | 50-63,135-136     
  ...BranchName.ts |     100 |    89.47 |     100 |     100 | 60,63             
  ...oryManager.ts |   96.61 |    93.18 |     100 |   96.61 | ...70-171,214-215 
  ...splayState.ts |     100 |      100 |     100 |     100 |                   
  ...stListener.ts |   12.12 |      100 |       0 |   12.12 | 17-50             
  ...ivityTimer.ts |   76.19 |    66.66 |     100 |   76.19 | 30-35             
  ...putHistory.ts |    92.5 |    85.71 |     100 |    92.5 | 62-63,71,93-95    
  ...storyStore.ts |     100 |    94.11 |     100 |     100 | 67                
  useKeypress.ts   |   88.88 |       75 |     100 |   88.88 | 28-29             
  ...rdProtocol.ts |       0 |        0 |       0 |       0 | 1-26              
  ...fileDialog.ts |     5.3 |      100 |       0 |     5.3 | 26-72,75-148      
  ...gIndicator.ts |     100 |      100 |     100 |     100 |                   
  useLogger.ts     |   93.75 |      100 |     100 |   93.75 | 27                
  useMcpStatus.ts  |   90.69 |    66.66 |     100 |   90.69 | 19,33-35          
  ...oryMonitor.ts |     100 |      100 |     100 |     100 |                   
  ...ssageQueue.ts |     100 |      100 |     100 |     100 |                   
  useMouse.ts      |   77.77 |    66.66 |     100 |   77.77 | 31-34             
  useMouseClick.ts |     100 |      100 |     100 |     100 |                   
  ...eSelection.ts |     2.2 |      100 |       0 |     2.2 | 36-367,370-416    
  ...hestration.ts |     100 |      100 |     100 |     100 |                   
  ...oviderInfo.ts |       0 |        0 |       0 |       0 | 1-86              
  ...odifyTrust.ts |    9.09 |      100 |       0 |    9.09 | 43-134            
  ...raseCycler.ts |   79.72 |    73.33 |     100 |   79.72 | ...69,75-76,92-94 
  ...cySettings.ts |   86.72 |    83.33 |     100 |   86.72 | ...,95-99,127-138 
  ...Management.ts |    1.53 |      100 |       0 |    1.53 | 22-568,571-663    
  ...Completion.ts |   43.02 |    55.55 |      50 |   43.02 | ...84-297,328-337 
  ...iderDialog.ts |    5.66 |      100 |       0 |    5.66 | 45-83,86-158      
  ...lScheduler.ts |   75.46 |    83.33 |   73.52 |   75.46 | ...41-657,808,815 
  ...oryCommand.ts |       0 |        0 |       0 |       0 | 1-7               
  useResponsive.ts |     100 |      100 |     100 |     100 |                   
  ...ompletion.tsx |   69.56 |      100 |     100 |   69.56 | 45-47,51-66,78-81 
  useRewind.ts     |     100 |      100 |     100 |     100 |                   
  ...ectionList.ts |   89.78 |    88.88 |     100 |   89.78 | ...19-425,445-449 
  useSession.ts    |       0 |        0 |       0 |       0 | 1-23              
  ...ionBrowser.ts |     100 |      100 |     100 |     100 |                   
  ...serHelpers.ts |   95.79 |    85.21 |   97.36 |   95.79 | ...39-641,764-765 
  ...erKeypress.ts |   89.87 |    97.29 |   94.11 |   89.87 | 101-108,130-145   
  ...ngsCommand.ts |   18.75 |      100 |       0 |   18.75 | 10-25             
  ...ellHistory.ts |   90.75 |       80 |     100 |   90.75 | ...83,131-132,142 
  ...Completion.ts |   97.04 |    81.25 |     100 |   97.04 | 71-73,101-102     
  ...oryCommand.ts |       0 |        0 |       0 |       0 | 1-63              
  ...cessorCore.ts |   73.91 |       60 |     100 |   73.91 | ...18,154,174-201 
  ...ompletion.tsx |   96.73 |    81.39 |     100 |   96.73 | ...,92-93,335-343 
  ...leCallback.ts |     100 |      100 |     100 |     100 |                   
  ...tateAndRef.ts |   59.09 |      100 |     100 |   59.09 | 23-31             
  ...oryRefresh.ts |     100 |      100 |     100 |     100 |                   
  ...rminalSize.ts |   10.34 |      100 |       0 |   10.34 | 15-44,49-85       
  ...emeCommand.ts |    4.29 |      100 |       0 |    4.29 | 25-122,125-199    
  useTimer.ts      |    87.5 |    85.71 |     100 |    87.5 | 44-45,50-52       
  ...ntinuation.ts |   91.28 |    89.74 |     100 |   91.28 | ...25-126,153-163 
  ...ePreserver.ts |   57.14 |      100 |      80 |   57.14 | 58-76             
  ...oolsDialog.ts |    3.44 |      100 |       0 |    3.44 | 23-106,109-193    
  ...Onboarding.ts |    1.92 |      100 |       0 |    1.92 | 77-402,405-486    
  ...eMigration.ts |   11.66 |      100 |       0 |   11.66 | 15-74             
  vim.ts           |   85.73 |    87.17 |    90.9 |   85.73 | ...07-716,832-834 
 ...s/geminiStream |   88.04 |    80.28 |   89.09 |   88.04 |                   
  ...ersistence.ts |   98.29 |    95.12 |     100 |   98.29 | 162-164           
  ...tProcessor.ts |   77.85 |    69.56 |      80 |   77.85 | ...48-159,162-164 
  index.ts         |     100 |      100 |     100 |     100 |                   
  queryPreparer.ts |   63.15 |    18.18 |     100 |   63.15 | ...26-127,130-143 
  ...Dispatcher.ts |   90.14 |    85.45 |   91.66 |   90.14 | ...19,321-325,410 
  streamUtils.ts   |   98.98 |    94.87 |     100 |   98.98 | 349-351           
  thoughtState.ts  |   93.33 |    61.53 |     100 |   93.33 | 71-72,77-78       
  ...ionHandler.ts |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
  ...genticLoop.ts |   97.43 |     87.5 |      60 |   97.43 | 177-178,239,346   
  ...miniStream.ts |   99.33 |    88.23 |   85.71 |   99.33 | 87                
  ...mLifecycle.ts |   84.18 |    58.62 |      80 |   84.18 | ...30-231,260-265 
  ...hestration.ts |    98.8 |    91.66 |   88.88 |    98.8 | 110-111,268       
  ...ntHandlers.ts |   73.63 |    89.28 |     100 |   73.63 | ...30-436,445-454 
  ...treamState.ts |   79.76 |    52.17 |     100 |   79.76 | ...79,200,237-238 
  ...ubmitQuery.ts |      86 |    66.66 |   81.81 |      86 | ...30-432,434-436 
 src/ui/layouts    |   83.46 |    55.17 |   82.75 |   83.46 |                   
  ...AppLayout.tsx |   80.98 |    71.42 |   83.33 |   80.98 | ...88-202,318-356 
  ...utHelpers.tsx |    84.6 |    52.94 |    82.6 |    84.6 | ...02-803,824-852 
 ...noninteractive |      75 |      100 |    6.66 |      75 |                   
  ...eractiveUi.ts |      75 |      100 |    6.66 |      75 | 17-19,23-24,27-28 
 src/ui/privacy    |   19.41 |        0 |       0 |   19.41 |                   
  ...acyNotice.tsx |       0 |        0 |       0 |       0 | 1-139             
  ...acyNotice.tsx |       0 |        0 |       0 |       0 | 1-59              
  ...acyNotice.tsx |   12.19 |      100 |       0 |   12.19 | 16-62             
  ...acyNotice.tsx |   35.42 |      100 |       0 |   35.42 | 77-172,180-235    
  ...acyNotice.tsx |   19.35 |      100 |       0 |   19.35 | 21-52,55-57       
 src/ui/reducers   |    79.5 |    91.66 |      50 |    79.5 |                   
  appReducer.ts    |     100 |      100 |     100 |     100 |                   
  ...ionReducer.ts |       0 |        0 |       0 |       0 | 1-52              
 src/ui/state      |   52.63 |    30.76 |      50 |   52.63 |                   
  extensions.ts    |   52.63 |    30.76 |      50 |   52.63 | ...28,130,134-149 
 src/ui/themes     |      99 |    86.63 |   97.77 |      99 |                   
  ansi-light.ts    |     100 |      100 |     100 |     100 |                   
  ansi.ts          |     100 |      100 |     100 |     100 |                   
  atom-one-dark.ts |     100 |      100 |     100 |     100 |                   
  ayu-light.ts     |     100 |      100 |     100 |     100 |                   
  ayu.ts           |     100 |      100 |     100 |     100 |                   
  color-utils.ts   |   99.38 |    98.63 |     100 |   99.38 | 326-327           
  default-light.ts |     100 |      100 |     100 |     100 |                   
  default.ts       |     100 |      100 |     100 |     100 |                   
  dracula.ts       |     100 |      100 |     100 |     100 |                   
  github-dark.ts   |     100 |      100 |     100 |     100 |                   
  github-light.ts  |     100 |      100 |     100 |     100 |                   
  googlecode.ts    |     100 |      100 |     100 |     100 |                   
  green-screen.ts  |     100 |      100 |     100 |     100 |                   
  no-color.ts      |     100 |      100 |     100 |     100 |                   
  ...c-resolver.ts |     100 |      100 |     100 |     100 |                   
  ...tic-tokens.ts |     100 |      100 |     100 |     100 |                   
  ...-of-purple.ts |     100 |      100 |     100 |     100 |                   
  theme-compat.ts  |     100 |       50 |     100 |     100 | 79                
  theme-manager.ts |   88.55 |    82.81 |     100 |   88.55 | ...03-312,317-318 
  theme.ts         |   99.09 |     81.3 |   94.11 |   99.09 | 282-283,702-703   
  xcode.ts         |     100 |      100 |     100 |     100 |                   
 src/ui/types      |       0 |        0 |       0 |       0 |                   
  ...ngMetadata.ts |       0 |        0 |       0 |       0 |                   
 src/ui/utils      |   55.71 |    86.36 |   67.89 |   55.71 |                   
  ...Colorizer.tsx |    5.64 |      100 |       0 |    5.64 | ...27-168,180-249 
  ...olePatcher.ts |   72.09 |      100 |   83.33 |   72.09 | 51-62             
  ...nRenderer.tsx |   27.87 |    63.26 |      45 |   27.87 | ...09,411,415-416 
  ...wnDisplay.tsx |    3.05 |      100 |       0 |    3.05 | ...89-814,825-829 
  ...eRenderer.tsx |   10.46 |      100 |       0 |   10.46 | ...28-379,386-419 
  ...tGenerator.ts |    76.4 |    53.84 |      60 |    76.4 | ...63,69-72,84-85 
  ...ketedPaste.ts |      60 |      100 |       0 |      60 | 13-14,17-18       
  clipboard.ts     |   97.29 |    84.61 |     100 |   97.29 | 40                
  ...boardUtils.ts |   63.09 |    76.74 |   83.33 |   63.09 | ...52-264,334-336 
  commandUtils.ts  |   93.11 |    95.34 |   95.83 |   93.11 | ...40-244,325-333 
  computeStats.ts  |     100 |      100 |     100 |     100 |                   
  displayUtils.ts  |     100 |      100 |     100 |     100 |                   
  formatters.ts    |   90.47 |    95.23 |     100 |   90.47 | 57-60             
  fuzzyFilter.ts   |     100 |    96.55 |     100 |     100 | 84                
  highlight.ts     |   77.51 |    97.29 |      60 |   77.51 | 144-170,174-179   
  ...xportUtils.ts |   98.03 |    91.66 |     100 |   98.03 | 111-112           
  ...storyItems.ts |   99.04 |    94.44 |     100 |   99.04 | 72                
  input.ts         |   84.28 |    94.44 |   66.66 |   84.28 | 73-80,106-113     
  isNarrowWidth.ts |      50 |      100 |       0 |      50 | 13-14             
  ...nUtilities.ts |   66.66 |    85.71 |     100 |   66.66 | 75-94,103-104     
  mouse.ts         |   83.05 |    72.41 |     100 |   83.05 | ...94,201,214-215 
  ...mConstants.ts |     100 |      100 |     100 |     100 |                   
  ...opDetector.ts |       0 |        0 |       0 |       0 | 1-210             
  responsive.ts    |   73.39 |    76.66 |   83.33 |   73.39 | ...00-108,111-125 
  rewindFileOps.ts |   91.84 |    66.66 |     100 |   91.84 | ...15-218,262-266 
  ...putHandler.ts |   89.89 |    89.91 |     100 |   89.89 | ...80-289,356-357 
  ...ityManager.ts |   94.33 |    85.71 |   93.18 |   94.33 | ...58-459,497,507 
  ...alContract.ts |     100 |      100 |     100 |     100 |                   
  terminalLinks.ts |     100 |      100 |     100 |     100 |                   
  ...colCleanup.ts |   95.45 |       75 |     100 |   95.45 | 39                
  ...lSequences.ts |     100 |      100 |     100 |     100 |                   
  terminalSetup.ts |    3.64 |      100 |       0 |    3.64 | 42-397            
  textUtils.ts     |   95.27 |    92.15 |   88.88 |   95.27 | 20-25             
  ...Formatters.ts |       0 |        0 |       0 |       0 | 1-50              
  ...icsTracker.ts |     100 |    94.44 |     100 |     100 | 38                
  ui-sizing.ts     |      16 |      100 |       0 |      16 | 11-23,26-36       
  updateCheck.ts   |     100 |    94.11 |     100 |     100 | 34,45             
 src/utils         |   61.39 |    88.68 |    74.9 |   61.39 |                   
  ...ionContext.ts |   76.92 |       75 |     100 |   76.92 | 38-41,63-66,81-84 
  ...Formatting.ts |     100 |      100 |     100 |     100 |                   
  bootstrap.ts     |     100 |      100 |     100 |     100 |                   
  checks.ts        |   33.33 |      100 |       0 |   33.33 | 23-28             
  cleanup.ts       |   67.74 |       80 |      60 |   67.74 | ...66-68,71,85-94 
  commands.ts      |   51.78 |    71.42 |     100 |   51.78 | 25-26,57-85       
  commentJson.ts   |    92.3 |     92.5 |     100 |    92.3 | 94-102            
  ...ScopeUtils.ts |   27.58 |      100 |       0 |   27.58 | 24-41,58-86       
  ...icSettings.ts |   92.53 |    91.66 |     100 |   92.53 | 55-56,61-64,67-70 
  ...arResolver.ts |   96.66 |    96.42 |     100 |   96.66 | 115-116           
  errors.ts        |   94.87 |       88 |     100 |   94.87 | 54-55,96-97       
  events.ts        |     100 |      100 |     100 |     100 |                   
  ...lativeTime.ts |     100 |      100 |     100 |     100 |                   
  gitUtils.ts      |   93.54 |       85 |     100 |   93.54 | 63-64,79-82       
  ...AutoUpdate.ts |   69.45 |    78.57 |      80 |   69.45 | ...67-268,282-347 
  ...lationInfo.ts |   99.49 |     98.3 |     100 |   99.49 | 61                
  math.ts          |   66.66 |      100 |       0 |   66.66 | 15                
  ...stentState.ts |   95.31 |    84.21 |     100 |   95.31 | 42,63-64          
  readStdin.ts     |   81.03 |    91.66 |   83.33 |   81.03 | 32-39,51-53       
  relaunch.ts      |     100 |      100 |     100 |     100 |                   
  resolvePath.ts   |   66.66 |       25 |     100 |   66.66 | 12-13,16,18-19    
  ...containers.ts |    4.69 |      100 |       0 |    4.69 | ...35-655,659-685 
  ...entrypoint.ts |    9.87 |      100 |       0 |    9.87 | 19-48,51-100      
  sandbox-env.ts   |   74.65 |    77.14 |   66.66 |   74.65 | ...52-153,161-162 
  sandbox-exec.ts  |     4.6 |      100 |       0 |     4.6 | 51-392            
  sandbox-image.ts |    3.96 |      100 |       0 |    3.96 | 12-128            
  ...box-podman.ts |   74.59 |    94.73 |   77.77 |   74.59 | ...49-259,325-398 
  ...x-seatbelt.ts |     8.2 |      100 |       0 |     8.2 | 34-310            
  sandbox-ssh.ts   |   78.84 |    81.13 |     100 |   78.84 | ...06-307,371-375 
  sandbox.ts       |   13.23 |      100 |       0 |   13.23 | 47-111            
  ...st-helpers.ts |     100 |      100 |     100 |     100 |                   
  ...ionCleanup.ts |   86.64 |       84 |     100 |   86.64 | ...48-249,332-333 
  sessionUtils.ts  |     8.1 |      100 |       0 |     8.1 | 51-118,125-139    
  settingsUtils.ts |   85.67 |    91.34 |   94.28 |   85.67 | ...61-489,528-529 
  ...ttingSaver.ts |    1.92 |      100 |       0 |    1.92 | 11-32,40-85       
  skillSettings.ts |   86.13 |       88 |     100 |   86.13 | 99-107,134-138    
  skillUtils.ts    |   64.51 |    63.33 |   83.33 |   64.51 | ...98-199,206-227 
  spawnWrapper.ts  |     100 |      100 |     100 |     100 |                   
  ...upWarnings.ts |     100 |      100 |     100 |     100 |                   
  stdinSafety.ts   |   91.39 |    86.48 |     100 |   91.39 | ...66-167,170,245 
  terminalTheme.ts |     100 |      100 |     100 |     100 |                   
  ...entEmitter.ts |     100 |      100 |     100 |     100 |                   
  ...upWarnings.ts |     100 |      100 |     100 |     100 |                   
  version.ts       |     100 |      100 |     100 |     100 |                   
  windowTitle.ts   |     100 |      100 |     100 |     100 |                   
 src/utils/privacy |   62.91 |    77.35 |      80 |   62.91 |                   
  ...taRedactor.ts |   78.06 |    78.09 |   82.75 |   78.06 | ...86-588,594-615 
  ...acyManager.ts |       0 |        0 |       0 |       0 | 1-176             
 ...ed-integration |    9.73 |     92.3 |    9.23 |    9.73 |                   
  ...temService.ts |     100 |      100 |     100 |     100 |                   
  ...tent-utils.ts |    6.38 |      100 |       0 |    6.38 | ...9,62-75,78-124 
  zed-helpers.ts   |   20.76 |      100 |      25 |   20.76 | ...79-128,131-148 
  ...h-resolver.ts |     4.7 |      100 |       0 |     4.7 | ...70-502,505-529 
  ...vider-auth.ts |    3.53 |      100 |       0 |    3.53 | ...17-224,227-287 
  ...ol-handler.ts |     5.1 |      100 |       0 |     5.1 | ...85-305,308-361 
  ...ntegration.ts |   11.88 |       80 |       8 |   11.88 | ...43-646,649-655 
-------------------|---------|----------|---------|---------|-------------------
Core Package - Full Text Report
-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------|---------|----------|---------|---------|-------------------
All files          |    76.7 |    83.17 |   73.36 |    76.7 |                   
 src               |     100 |      100 |     100 |     100 |                   
  ...-factories.ts |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
 src/__mocks__/fs  |       0 |        0 |       0 |       0 |                   
  promises.ts      |       0 |        0 |       0 |       0 | 1-48              
 src/adapters      |     100 |      100 |     100 |     100 |                   
  ...eamAdapter.ts |     100 |      100 |     100 |     100 |                   
 src/code_assist   |   69.19 |    80.54 |   77.41 |   69.19 |                   
  codeAssist.ts    |   11.76 |      100 |       0 |   11.76 | 16-62,65-73,81-94 
  converter.ts     |   95.54 |    93.02 |     100 |   95.54 | 186-190,219-220   
  ...al-storage.ts |   97.39 |    76.31 |     100 |   97.39 | 76,103,132        
  oauth2.ts        |    64.9 |       78 |   81.81 |    64.9 | ...88-789,794-795 
  server.ts        |   48.16 |    72.72 |      50 |   48.16 | ...10-251,254-257 
  setup.ts         |   86.09 |    76.92 |     100 |   86.09 | ...60-162,187-193 
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/commands      |     100 |      100 |     100 |     100 |                   
  extensions.ts    |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/config        |   71.18 |    79.44 |   59.82 |   71.18 |                   
  ...tLifecycle.ts |   95.36 |    94.59 |     100 |   95.36 | ...55-156,220-222 
  ...skServices.ts |    9.19 |      100 |       0 |    9.19 | ...5,62-80,89-129 
  config.ts        |   59.84 |    72.83 |   57.14 |   59.84 | ...35-744,769-776 
  configBase.ts    |   68.81 |    72.09 |   72.72 |   68.81 | ...48-255,257-261 
  ...igBaseCore.ts |   70.13 |    94.28 |    45.2 |   70.13 | ...54-755,757-758 
  ...onstructor.ts |   97.14 |    90.14 |     100 |   97.14 | ...16-517,520-521 
  ...estHarness.ts |   93.15 |    95.45 |   83.33 |   93.15 | 229-239,245-248   
  configTypes.ts   |      58 |      100 |      50 |      58 | 196-236           
  constants.ts     |     100 |      100 |     100 |     100 |                   
  endpoints.ts     |     100 |      100 |     100 |     100 |                   
  ...ngsHelpers.ts |   62.16 |       40 |     100 |   62.16 | ...31,35-36,42-43 
  index.ts         |       0 |        0 |       0 |       0 | 1-41              
  ...ntegration.ts |   61.51 |    73.46 |   68.75 |   61.51 | ...82,399,408,417 
  models.ts        |     100 |      100 |     100 |     100 |                   
  ...rSingleton.ts |   76.22 |    70.37 |   56.25 |   76.22 | ...94,397-400,408 
  ...entManager.ts |   50.76 |    68.91 |   65.21 |   50.76 | ...52-653,679-703 
  ...ingsParser.ts |   41.37 |    33.33 |     100 |   41.37 | 31-48             
  ...tryFactory.ts |   82.54 |    75.92 |   69.23 |   82.54 | ...89-505,515-525 
  types.ts         |       0 |        0 |       0 |       0 |                   
 ...nfirmation-bus |   83.33 |       50 |      50 |   83.33 |                   
  index.ts         |       0 |        0 |       0 |       0 | 1-2               
  message-bus.ts   |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/core          |   81.21 |    79.41 |   83.33 |   81.21 |                   
  ...ssionTypes.ts |   68.42 |      100 |      20 |   68.42 | ...05-107,112-113 
  ...ntContract.ts |     100 |      100 |     100 |     100 |                   
  ...tGenerator.ts |     100 |       96 |     100 |     100 | 96                
  ...okTriggers.ts |   43.27 |    55.55 |      60 |   43.27 | ...76-277,301-306 
  geminiRequest.ts |      60 |      100 |       0 |      60 | 18-19             
  ...nAIWrapper.ts |   77.77 |      100 |   66.66 |   77.77 | 58-61,64-67       
  ...okTriggers.ts |   96.21 |     87.5 |     100 |   96.21 | ...19,165,219,268 
  logger.ts        |   81.06 |    81.81 |     100 |   81.06 | ...70-385,432-446 
  prompts.ts       |   82.85 |    56.33 |    91.3 |   82.85 | ...55,558,619-620 
  subagentTypes.ts |     100 |      100 |   83.33 |     100 |                   
  tokenLimits.ts   |     100 |      100 |     100 |     100 |                   
  ...erContract.ts |     100 |      100 |     100 |     100 |                   
  turn.ts          |     100 |      100 |     100 |     100 |                   
 ...re/compression |   33.55 |       50 |   16.66 |   33.55 |                   
  ...nDirective.ts |    6.25 |      100 |       0 |    6.25 | 22-62             
  types.ts         |   41.02 |       50 |      20 |   41.02 | ...43-377,388-389 
 src/debug         |   61.53 |        0 |       0 |   61.53 |                   
  ...ionManager.ts |     100 |      100 |     100 |     100 |                   
  DebugLogger.ts   |     100 |      100 |     100 |     100 |                   
  FileOutput.ts    |     100 |      100 |     100 |     100 |                   
  ...ionManager.ts |       0 |        0 |       0 |       0 | 1-6               
  ...FileOutput.ts |       0 |        0 |       0 |       0 | 1-6               
  index.ts         |     100 |      100 |     100 |     100 |                   
  types.ts         |       0 |        0 |       0 |       0 | 1                 
 src/filters       |   99.19 |     98.8 |     100 |   99.19 |                   
  EmojiFilter.ts   |   99.19 |     98.8 |     100 |   99.19 | 208-209           
 src/hooks         |   82.96 |    84.55 |   80.12 |   82.96 |                   
  errors.ts        |     100 |      100 |     100 |     100 |                   
  ...Aggregator.ts |    90.4 |    81.33 |    87.5 |    90.4 | ...50,369,371,373 
  ...sContracts.ts |       0 |        0 |       0 |       0 | 1                 
  ...entHandler.ts |   91.45 |    84.73 |   93.75 |   91.45 | ...55,795-801,846 
  hookPlanner.ts   |   98.79 |    93.33 |     100 |   98.79 | 103               
  hookRegistry.ts  |   98.25 |    89.23 |     100 |   98.25 | 353,355,357,359   
  hookRunner.ts    |   84.88 |    87.14 |   86.95 |   84.88 | ...37-439,502-505 
  hookSystem.ts    |    64.2 |    88.88 |      65 |    64.2 | ...49-351,364-366 
  ...Translator.ts |   93.96 |    68.08 |     100 |   93.96 | ...06-307,318,367 
  ...Validators.ts |    92.4 |    89.83 |     100 |    92.4 | 57-59,78-80       
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...ssion-hook.ts |   88.88 |    33.33 |     100 |   88.88 | 24,30             
  trustedHooks.ts  |   20.77 |      100 |       0 |   20.77 | ...6,82-90,96-109 
  types.ts         |   52.19 |    87.09 |      50 |   52.19 | ...21-422,433-434 
 ...oks/test-utils |       0 |        0 |       0 |       0 |                   
  ...igWithHook.ts |       0 |        0 |       0 |       0 | 1-137             
 src/interfaces    |       0 |        0 |       0 |       0 |                   
  index.ts         |       0 |        0 |       0 |       0 |                   
  ....interface.ts |       0 |        0 |       0 |       0 |                   
 src/models        |   83.48 |    92.41 |    87.5 |   83.48 |                   
  hydration.ts     |    4.76 |      100 |       0 |    4.76 | 65-131,153-233    
  index.ts         |     100 |      100 |     100 |     100 |                   
  profiles.ts      |     100 |      100 |     100 |     100 |                   
  ...ntegration.ts |   95.34 |    89.74 |     100 |   95.34 | ...36-137,200-201 
  registry.ts      |   90.58 |    88.88 |      92 |   90.58 | ...72-273,393-406 
  schema.ts        |     100 |      100 |     100 |     100 |                   
  transformer.ts   |     100 |      100 |     100 |     100 |                   
 src/parsers       |   71.41 |    73.68 |   88.88 |   71.41 |                   
  ...CallParser.ts |   71.85 |    77.12 |   86.66 |   71.85 | ...6,981,987-1002 
  ...rser-utils.ts |   66.15 |    42.85 |     100 |   66.15 | ...58,66-67,71-76 
 src/policy        |    72.9 |    76.19 |   88.46 |    72.9 |                   
  config.ts        |   68.06 |    77.19 |   86.36 |   68.06 | ...25,381,458-459 
  index.ts         |     100 |      100 |     100 |     100 |                   
  policy-engine.ts |     100 |      100 |     100 |     100 |                   
  ...cy-helpers.ts |   88.88 |    66.66 |     100 |   88.88 | 31-39             
  ...-stringify.ts |     100 |      100 |     100 |     100 |                   
  toml-loader.ts   |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
  utils.ts         |     100 |      100 |     100 |     100 |                   
 src/prompt-config |   82.46 |     87.3 |   82.22 |   82.46 |                   
  ...lateEngine.ts |   93.83 |    87.36 |     100 |   93.83 | ...04-407,418-421 
  index.ts         |       0 |      100 |     100 |       0 | 5-41              
  prompt-cache.ts  |    99.1 |    97.46 |     100 |    99.1 | 227-228           
  ...-installer.ts |   83.82 |    81.87 |    92.3 |   83.82 | ...24-831,863-866 
  prompt-loader.ts |   90.93 |    92.56 |   89.65 |   90.93 | ...15-532,542-543 
  ...t-resolver.ts |   50.38 |       84 |      50 |   50.38 | ...22-423,428-527 
  ...pt-service.ts |   85.28 |    83.18 |   80.95 |   85.28 | ...28,545-552,583 
  ...delegation.ts |   93.54 |     90.9 |     100 |   93.54 | 34-35             
  types.ts         |     100 |      100 |     100 |     100 |                   
 ...onfig/defaults |   56.45 |    45.74 |   85.41 |   56.45 |                   
  core-defaults.ts |      48 |     41.5 |   78.57 |      48 | ...55,365,371-379 
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...est-loader.ts |   81.81 |    79.31 |     100 |   81.81 | ...02-108,116-120 
  ...t-warnings.ts |    92.3 |    33.33 |     100 |    92.3 | 18-19             
  ...r-defaults.ts |   52.51 |    35.29 |   84.61 |   52.51 | ...24,334,340-345 
  ...e-defaults.ts |     100 |      100 |     100 |     100 |                   
  tool-defaults.ts |   56.05 |     42.3 |   84.61 |   56.05 | ...82-283,295-300 
 ...nfig/installer |   92.11 |    87.63 |   97.61 |   92.11 |                   
  ...resolution.ts |   96.63 |    92.45 |     100 |   96.63 | ...70-271,317-318 
  ...tory-utils.ts |   95.42 |    90.38 |     100 |   95.42 | ...14-117,154,175 
  file-writer.ts   |   78.78 |    73.68 |     100 |   78.78 | 31-32,51-52,69-78 
  ...operations.ts |   97.46 |    94.44 |     100 |   97.46 | 48-49             
  ...-expansion.ts |   82.67 |    81.81 |      90 |   82.67 | ...,70-71,165-172 
 ...onfig/resolver |   36.86 |    60.86 |   51.85 |   36.86 |                   
  ...ry-scanner.ts |    4.04 |      100 |       0 |    4.04 | ...98-159,163-207 
  fs-adapter.ts    |   39.06 |    66.66 |      50 |   39.06 | ...37,42-47,51-88 
  name-utils.ts    |   71.69 |       60 |   78.57 |   71.69 | ...03-204,208-218 
 src/prompts       |      30 |      100 |      25 |      30 |                   
  mcp-prompts.ts   |   28.57 |      100 |       0 |   28.57 | 11-15             
  ...t-registry.ts |   30.23 |      100 |   28.57 |   30.23 | ...43,49-56,69-74 
 src/recording     |   90.81 |     85.2 |   97.93 |   90.81 |                   
  ...ntegration.ts |    83.9 |       75 |     100 |    83.9 | ...31-132,143-144 
  ReplayEngine.ts  |    97.1 |     91.2 |     100 |    97.1 | 121-122,473-480   
  ...nDiscovery.ts |   92.12 |    84.53 |     100 |   92.12 | ...35,252-254,304 
  ...ockManager.ts |   89.41 |    81.25 |     100 |   89.41 | ...98,213,240-241 
  ...ingService.ts |   82.97 |    92.45 |   95.65 |   82.97 | ...57,390-391,395 
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...st-helpers.ts |   91.12 |       90 |   92.85 |   91.12 | 190-200,227-230   
  resumeSession.ts |   93.19 |    89.65 |     100 |   93.19 | ...10-215,246-247 
  ...eanupUtils.ts |      90 |    69.23 |     100 |      90 | ...40-241,267,280 
  ...Management.ts |   88.23 |    85.71 |     100 |   88.23 | 94,108-112        
  types.ts         |       0 |        0 |       0 |       0 |                   
 src/resources     |   95.23 |     92.3 |     100 |   95.23 |                   
  ...e-registry.ts |   95.23 |     92.3 |     100 |   95.23 | 34-35             
 src/runtime       |   74.73 |    84.48 |   75.86 |   74.73 |                   
  ...imeContext.ts |     100 |      100 |     100 |     100 |                   
  ...timeLoader.ts |   84.37 |    71.18 |   83.33 |   84.37 | ...43,247,274-277 
  ...ntimeState.ts |   95.63 |    90.54 |     100 |   95.63 | ...01-502,542-543 
  ...ionContext.ts |   83.54 |    93.33 |   71.42 |   83.54 | ...56-157,168-175 
  ...imeContext.ts |   73.96 |    97.61 |   60.71 |   73.96 | ...60-265,267-274 
  index.ts         |       0 |        0 |       0 |       0 | 1-19              
  ...imeContext.ts |      70 |       90 |     100 |      70 | 88-108            
  ...meAdapters.ts |     4.8 |      100 |       0 |     4.8 | ...84-118,124-170 
  ...ateFactory.ts |   90.32 |    71.42 |     100 |   90.32 | ...79,102,112,125 
  ...imeAdapter.ts |   80.55 |    86.66 |   88.88 |   80.55 | 52-59,67-68,71-76 
 ...time/contracts |       0 |        0 |       0 |       0 |                   
  ...lureReason.ts |       0 |        0 |       0 |       0 | 1                 
  ...kContracts.ts |       0 |        0 |       0 |       0 | 1                 
  ...ningOutput.ts |       0 |        0 |       0 |       0 | 1                 
  ...torFactory.ts |       0 |        0 |       0 |       0 | 1                 
  RuntimeModel.ts  |       0 |        0 |       0 |       0 | 1                 
  ...meProvider.ts |       0 |        0 |       0 |       0 | 1                 
  ...oviderChat.ts |       0 |        0 |       0 |       0 | 1                 
  ...derManager.ts |       0 |        0 |       0 |       0 | 1                 
  ...eTokenizer.ts |       0 |        0 |       0 |       0 | 1                 
  ...zerFactory.ts |       0 |        0 |       0 |       0 | 1                 
  ...tryContext.ts |       0 |        0 |       0 |       0 | 1                 
  index.ts         |       0 |        0 |       0 |       0 | 1                 
 ...runtime/errors |   94.87 |    85.71 |   66.66 |   94.87 |                   
  ...viderError.ts |     100 |      100 |     100 |     100 |                   
  index.ts         |       0 |        0 |       0 |       0 | 1-14              
 src/safety        |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  pathValidator.ts |     100 |      100 |     100 |     100 |                   
 src/scheduler     |       0 |        0 |       0 |       0 |                   
  types.ts         |       0 |        0 |       0 |       0 | 1                 
 src/services      |   84.43 |     85.8 |   88.26 |   84.43 |                   
  ...ardService.ts |   94.23 |    93.75 |     100 |   94.23 | 70,74-75          
  ...utoTrigger.ts |   97.33 |    95.83 |     100 |   97.33 | 127-128           
  ...askManager.ts |   95.81 |    93.93 |     100 |   95.81 | 151-157,365-366   
  ...derService.ts |   98.98 |    97.05 |     100 |   98.98 | 173               
  ...y-analyzer.ts |   83.51 |    79.85 |   87.09 |   83.51 | ...13-641,647-648 
  ...extManager.ts |     100 |    96.29 |     100 |     100 | 63                
  ...nitization.ts |   98.62 |    96.66 |     100 |   98.62 | 172-173           
  ...eryService.ts |     100 |      100 |     100 |     100 |                   
  ...temService.ts |     100 |      100 |     100 |     100 |                   
  ...ts-service.ts |      50 |      100 |       0 |      50 | 41-42,48-49       
  gitService.ts    |    86.6 |    86.95 |      80 |    86.6 | ...35-138,142-146 
  index.ts         |       0 |        0 |       0 |       0 | 1-23              
  ...ionService.ts |   96.47 |     94.5 |     100 |   96.47 | ...53-354,364-365 
  ...pExecution.ts |   88.42 |    78.57 |   83.33 |   88.42 | 65-66,92-100      
  ...lCpHelpers.ts |   87.83 |    87.75 |     100 |   87.83 | ...91,194,253-259 
  ...ionService.ts |   71.55 |    85.71 |    62.5 |   71.55 | ...80-303,362-375 
  ...utionTypes.ts |       0 |        0 |       0 |       0 | 1                 
  ...lExitGuard.ts |     100 |      100 |     100 |     100 |                   
  ...utputUtils.ts |   95.65 |    95.23 |     100 |   95.65 | 34-35             
  ...rocessKill.ts |   88.57 |    88.88 |     100 |   88.57 | 38-41             
  ...yExecution.ts |   96.15 |    93.33 |     100 |   96.15 | 110-111,132-134   
  ...PtyHelpers.ts |   87.03 |    76.19 |    87.5 |   87.03 | ...20,151-152,208 
  ...yLifecycle.ts |   86.77 |    78.68 |   88.88 |   86.77 | ...92,297,354-356 
  shellPtyState.ts |       0 |        0 |       0 |       0 | 1                 
  ...xt-tracker.ts |   94.87 |       90 |    87.5 |   94.87 | 54-55             
  ...er-service.ts |       0 |        0 |       0 |       0 | 1-161             
  ...er-service.ts |   68.47 |    48.48 |      80 |   68.47 | ...85-289,311-314 
 ...rvices/history |   82.53 |     84.8 |   87.32 |   82.53 |                   
  ...Converters.ts |   83.29 |    81.96 |   81.81 |   83.29 | ...51-452,558-581 
  HistoryEvents.ts |       0 |        0 |       0 |       0 |                   
  ...oryService.ts |   85.13 |    88.31 |   86.53 |   85.13 | ...95-696,775-776 
  IContent.ts      |    89.7 |       76 |     100 |    89.7 | ...40,250-251,262 
  ...calToolIds.ts |   96.82 |    92.59 |     100 |   96.82 | 36-37             
  ...ebugLogger.ts |   62.41 |       68 |   85.71 |   62.41 | ...33-145,158-162 
  ...Validation.ts |     100 |      100 |     100 |     100 |                   
  ...CloneUtils.ts |   73.07 |    88.46 |   83.33 |   73.07 | ...98-101,106-118 
  ...textWindow.ts |   91.42 |    55.55 |     100 |   91.42 | 59,61-62          
  ...ryCuration.ts |     100 |      100 |     100 |     100 |                   
  ...EventTypes.ts |       0 |        0 |       0 |       0 |                   
  ...erPipeline.ts |     100 |      100 |     100 |     100 |                   
  historyQuery.ts  |   63.63 |       50 |     100 |   63.63 | 27-30             
  ...Estimation.ts |   44.68 |    82.14 |      50 |   44.68 | ...87-196,202-251 
  ...zerAdapter.ts |     100 |     87.5 |     100 |     100 | 73                
  ...malization.ts |    91.7 |    87.12 |     100 |    91.7 | ...26-431,477-485 
  ...oolPairing.ts |   98.59 |     87.5 |     100 |   98.59 | 103               
 src/skills        |   76.77 |     82.9 |   77.41 |   76.77 |                   
  skillLoader.ts   |   63.96 |    79.66 |   83.33 |   63.96 | ...63-299,302-338 
  skillManager.ts  |   91.28 |     86.2 |   73.68 |   91.28 | ...57-358,364-365 
 src/storage       |    98.7 |    96.96 |     100 |    98.7 |                   
  ...FileWriter.ts |     100 |      100 |     100 |     100 |                   
  ...nceService.ts |   98.67 |    96.96 |     100 |   98.67 | 294-295           
  ...ey-storage.ts |     100 |      100 |     100 |     100 |                   
  secure-store.ts  |     100 |      100 |     100 |     100 |                   
  sessionTypes.ts  |     100 |      100 |     100 |     100 |                   
 src/telemetry     |   15.17 |        0 |       0 |   15.17 |                   
  constants.ts     |     100 |      100 |     100 |     100 |                   
  ...-exporters.ts |       0 |        0 |       0 |       0 | 1-6               
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...t.circular.ts |       0 |        0 |       0 |       0 | 1-17              
  ...t.circular.ts |       0 |        0 |       0 |       0 | 1-115             
  loggers.ts       |     100 |      100 |     100 |     100 |                   
  metrics.ts       |     100 |      100 |     100 |     100 |                   
  sdk.ts           |     100 |      100 |     100 |     100 |                   
  ...l-decision.ts |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
  uiTelemetry.ts   |     100 |      100 |     100 |     100 |                   
 src/test-utils    |      50 |       60 |   18.18 |      50 |                   
  config.ts        |   65.38 |      100 |   13.04 |   65.38 | ...,91-96,155-193 
  index.ts         |       0 |        0 |       0 |       0 | 1-9               
  mock-tool.ts     |       0 |        0 |       0 |       0 | 1-158             
  ...aceContext.ts |       0 |        0 |       0 |       0 | 1-32              
  ...allOptions.ts |   81.62 |    51.61 |   54.54 |   81.62 | ...83,196,225-228 
  runtime.ts       |   47.03 |    33.33 |    8.82 |   47.03 | ...13-276,284-347 
  tools.ts         |   43.02 |      100 |   31.25 |   43.02 | ...99-211,214-221 
 src/todo          |   13.04 |      100 |       0 |   13.04 |                   
  todoFormatter.ts |   13.04 |      100 |       0 |   13.04 | ...64,170-211,214 
 src/tools         |   79.33 |    83.33 |   91.66 |   79.33 |                   
  ...ey-storage.ts |   79.33 |    83.33 |   91.66 |   79.33 | ...05-310,319-324 
 ...tools-adapters |    43.8 |    61.68 |   31.57 |    43.8 |                   
  ...iceAdapter.ts |   61.22 |       80 |   57.14 |   61.22 | ...52,55-60,65-68 
  ...iceAdapter.ts |   27.58 |      100 |      25 |   27.58 | 21-26,29-37,40-45 
  ...iceAdapter.ts |   22.58 |      100 |      25 |   22.58 | 18-25,28-43,46-47 
  ...iceAdapter.ts |      30 |      100 |       0 |      30 | 16-18,21-22,25-33 
  ...BusAdapter.ts |   11.76 |      100 |      20 |   11.76 | ...07-120,123-129 
  ...iceAdapter.ts |      60 |      100 |       0 |      60 | ...27,36-37,40-41 
  ...iceAdapter.ts |   53.84 |      100 |      25 |   53.84 | 17-18,21-22,26-27 
  ...ostAdapter.ts |   19.88 |      100 |    4.76 |   19.88 | ...16-222,225-239 
  ...iceAdapter.ts |   15.58 |        0 |       0 |   15.58 | ...9,82-84,87-102 
  ...iceAdapter.ts |   52.94 |      100 |       0 |   52.94 | ...18,21-22,25-26 
  ...iceAdapter.ts |   49.83 |    57.31 |      68 |   49.83 | ...53-796,801-804 
  ...iceAdapter.ts |   68.18 |       50 |      50 |   68.18 | 32-36,39-40       
  ...ostAdapter.ts |    29.9 |      100 |    9.09 |    29.9 | ...48-154,157-158 
  ...ageAdapter.ts |   46.15 |      100 |       0 |   46.15 | ...33,36-37,40-41 
  ...ostAdapter.ts |   67.74 |      100 |      50 |   67.74 | ...57,60-61,64-65 
  ...iceAdapter.ts |      50 |      100 |      50 |      50 | 19-23             
  ...iceHelpers.ts |   63.79 |    59.18 |      75 |   63.79 | ...79-280,284-285 
  index.ts         |     100 |      100 |     100 |     100 |                   
 src/utils         |   82.56 |    86.82 |   82.94 |   82.56 |                   
  LruCache.ts      |    82.6 |      100 |   71.42 |    82.6 | 29-30,33-34       
  ...grep-utils.ts |   98.03 |     87.5 |     100 |   98.03 | 137-138           
  asyncIterator.ts |   73.07 |    84.61 |   66.66 |   73.07 | ...71,75-86,93-94 
  bfsFileSearch.ts |   93.61 |    92.85 |     100 |   93.61 | 36-44             
  browser.ts       |    8.69 |      100 |       0 |    8.69 | 17-53             
  channel.ts       |     100 |      100 |     100 |     100 |                   
  ...pointUtils.ts |   95.58 |    95.23 |     100 |   95.58 | 150-155           
  debugLogger.ts   |     100 |      100 |     100 |     100 |                   
  delay.ts         |     100 |      100 |     100 |     100 |                   
  editor.ts        |   96.46 |    90.38 |    90.9 |   96.46 | ...27-228,230-231 
  ...entContext.ts |     100 |      100 |     100 |     100 |                   
  errorParsing.ts  |   93.23 |    85.14 |   95.23 |   93.23 | ...73,213,297-298 
  ...rReporting.ts |   84.44 |    86.66 |     100 |   84.44 | 47-51,117-125     
  errors.ts        |   74.67 |       95 |   46.66 |   74.67 | ...27-128,189-213 
  events.ts        |   65.74 |      100 |    62.5 |   65.74 | ...04-309,315-318 
  exitCodes.ts     |     100 |      100 |     100 |     100 |                   
  ...sionLoader.ts |   80.98 |    62.85 |    92.3 |   80.98 | ...70-171,224-232 
  fetch.ts         |   24.32 |      100 |       0 |   24.32 | 23-28,32-86,89-90 
  fileDiffUtils.ts |     100 |      100 |     100 |     100 |                   
  fileUtils.ts     |    93.8 |    89.93 |      95 |    93.8 | ...82,452,486-492 
  formatters.ts    |   18.18 |      100 |       0 |   18.18 | 8-16              
  ...eUtilities.ts |   91.25 |       90 |   93.75 |   91.25 | ...95-299,347-357 
  ...rStructure.ts |   96.35 |       95 |     100 |   96.35 | 98-101,387-392    
  getPty.ts        |    12.5 |      100 |       0 |    12.5 | 21-36             
  ...noreParser.ts |   89.28 |    89.58 |      80 |   89.28 | ...30-231,236-250 
  ...ineChanges.ts |       0 |        0 |       0 |       0 | 1-275             
  gitUtils.ts      |   42.55 |    71.42 |      50 |   42.55 | 32-33,40-44,53-80 
  googleErrors.ts  |   77.24 |    72.72 |     100 |   77.24 | ...01,348,354-355 
  ...uotaErrors.ts |    95.5 |    86.59 |     100 |    95.5 | ...69-270,308-309 
  ide-trust.ts     |      60 |      100 |       0 |      60 | 14-15             
  ...rePatterns.ts |     100 |    96.55 |     100 |     100 | 249               
  ...ionManager.ts |     100 |    88.88 |     100 |     100 | 24                
  ...edit-fixer.ts |       0 |        0 |       0 |       0 | 1-156             
  ...yDiscovery.ts |    83.6 |    78.26 |    87.5 |    83.6 | ...60-761,764-765 
  ...tProcessor.ts |   95.79 |    89.41 |   93.75 |   95.79 | ...17-318,413-414 
  ...Inspectors.ts |       0 |        0 |       0 |       0 | 1-23              
  output-format.ts |   36.36 |      100 |       0 |   36.36 | ...53-154,164-185 
  package.ts       |     100 |      100 |     100 |     100 |                   
  ...erCoercion.ts |   86.66 |    82.89 |     100 |   86.66 | ...09-210,272-273 
  partUtils.ts     |   95.31 |    94.59 |     100 |   95.31 | 28,101-102        
  pathReader.ts    |   22.58 |      100 |       0 |   22.58 | ...22,28-29,41-60 
  paths.ts         |    87.5 |    85.18 |   92.85 |    87.5 | ...49-250,265-275 
  ...rDetection.ts |   53.62 |    83.33 |   83.33 |   53.62 | ...01-102,112-113 
  ...archTarget.ts |   89.58 |    69.23 |     100 |   89.58 | 45-47,65-66       
  retry.ts         |   82.61 |    88.01 |   91.66 |   82.61 | ...1007,1012-1013 
  ...thResolver.ts |     100 |      100 |     100 |     100 |                   
  ...nStringify.ts |     100 |      100 |     100 |     100 |                   
  sanitization.ts  |     100 |      100 |     100 |     100 |                   
  ...aValidator.ts |   93.67 |    76.31 |     100 |   93.67 | ...94-295,312-323 
  ...r-launcher.ts |   89.34 |       80 |     100 |   89.34 | ...84-189,194-195 
  session.ts       |     100 |      100 |     100 |     100 |                   
  shell-parser.ts  |   23.82 |    45.45 |   42.85 |   23.82 | ...97-411,436-475 
  shell-utils.ts   |   84.74 |    88.88 |   95.45 |   84.74 | ...47-553,722-731 
  ...Completion.ts |   94.16 |     92.3 |     100 |   94.16 | 69-75             
  stdio.ts         |   84.21 |    59.09 |     100 |   84.21 | ...21-125,134-138 
  ...dleTimeout.ts |   98.57 |    92.59 |     100 |   98.57 | 79                
  summarizer.ts    |     100 |    88.88 |     100 |     100 | 91                
  ...emEncoding.ts |   97.16 |    91.42 |     100 |   97.16 | 115-116,168       
  terminal.ts      |   34.09 |      100 |       0 |   34.09 | ...55,58-59,62-66 
  ...Serializer.ts |   98.16 |    92.18 |     100 |   98.16 | ...,98-99,153-155 
  testUtils.ts     |      50 |      100 |   33.33 |      50 | ...47,53-58,64-66 
  textUtils.ts     |    12.5 |      100 |       0 |    12.5 | 15-34             
  thoughtUtils.ts  |     100 |      100 |     100 |     100 |                   
  tool-utils.ts    |   66.94 |    76.92 |      75 |   66.94 | ...36-137,158-182 
  ...putLimiter.ts |   95.14 |    81.63 |     100 |   95.14 | ...5-66,78-79,113 
  unicodeUtils.ts  |     100 |      100 |     100 |     100 |                   
  ...untManager.ts |   89.83 |    88.57 |     100 |   89.83 | ...0,78-83,99-101 
  version.ts       |     100 |      100 |     100 |     100 |                   
  ...aceContext.ts |   96.85 |    95.23 |    92.3 |   96.85 | 95-96,110-111     
 ...ils/filesearch |   88.24 |    89.93 |   93.54 |   88.24 |                   
  crawlCache.ts    |     100 |      100 |     100 |     100 |                   
  crawler.ts       |   83.15 |     82.6 |      60 |   83.15 | ...,97-99,111-116 
  fileSearch.ts    |   83.05 |    86.51 |     100 |   83.05 | ...06-307,309-310 
  ignore.ts        |     100 |      100 |     100 |     100 |                   
  result-cache.ts  |     100 |      100 |     100 |     100 |                   
-------------------|---------|----------|---------|---------|-------------------

For detailed HTML reports, please see the 'coverage-reports-24.x-ubuntu-latest' artifact from the main CI run.

…n provider switch (Fixes #1567)

Three root causes of context token count blow-up on provider switch:

1. History tokens not re-estimated after provider switch:
   - When HistoryService is reused across a profile switch, totalTokens
     retained estimates from the old provider's tokenizer
   - Added resetTokenAccounting() + recalculateTotalTokens(model) call in
     ChatSessionFactory when HistoryService is reused

2. Stale sync state race condition:
   - syncTotalTokens() queued on async tokenizerLock while setBaseTokenOffset()
     runs synchronously, causing old provider drift to corrupt new count
   - Added syncGeneration counter to HistoryService; stale queued syncs are
     now skipped after resetTokenAccounting() increments the generation

3. Cache tokens double-counted for OpenAI/Gemini providers:
   - Sync formula (promptTokens + cache_read + cache_creation) was correct for
     Anthropic (non-cached input) but double-counted for OpenAI/Gemini
     (total input including cache)
   - Normalized Anthropic promptTokens to include cache, then simplified all
     sync formulas to use promptTokens directly
   - Updated telemetryEmitter, tokenUsageTracker, and StatsDisplay to treat
     input_token_count as total-including-cache consistently
@acoliver

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Combined main's sanitizeTokenCount helper with cache-inclusion fix
(promptTokens = sanitizeTokenCount(input) + cacheRead + cacheCreation).
@acoliver acoliver changed the title fix(core): resolve Codex context window limits and reset token stats on provider switch (Fixes #1567) fix(core): re-estimate tokens, fix cache double-counting on provider switch (Fixes #1567) Jun 24, 2026
…ut invariant

promptTokens now includes cache tokens for all providers (total-including-cache).
The session total formula no longer adds cache separately (it's already in input).
Updated test data so input reflects total-including-cache, keeping total assertions unchanged.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
integration-tests/token-tracking-ui-behavioral.test.ts (1)

319-328: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a regression case for negative derived input.

These updated assertions cover the cache-inclusive happy path, but they still don't exercise the new clamp in packages/cli/src/ui/components/StatsDisplay.tsx when input is missing and cached > prompt. Please add a case that would previously have rendered a negative Input: value so this UI safeguard stays locked in.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@integration-tests/token-tracking-ui-behavioral.test.ts` around lines 319 -
328, Add a regression test that exercises the negative derived input clamp in
formatSessionTokenUsage / StatsDisplay when input is missing and cached exceeds
prompt. Extend the token-tracking UI behavioral test with a case where combined
usage would previously format a negative Input value, and assert the displayed
text is clamped to zero instead of showing a negative number. Use the existing
formatSessionTokenUsage helper and StatsDisplay-related assertions so the
safeguard in packages/cli/src/ui/components/StatsDisplay.tsx stays covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/src/services/history/HistoryService.ts`:
- Around line 261-269: The token-accounting reset logic in HistoryService only
invalidates pending syncs inside resetTokenAccounting(), so a queued
syncTotalTokens() can still apply after clear() or dispose() and restore stale
state. Extract the syncGeneration bump into a shared helper in HistoryService
and call it from every state-reset path that should cancel in-flight syncs,
including resetTokenAccounting(), clear(), and dispose(), so all resets
consistently invalidate pending work.

---

Outside diff comments:
In `@integration-tests/token-tracking-ui-behavioral.test.ts`:
- Around line 319-328: Add a regression test that exercises the negative derived
input clamp in formatSessionTokenUsage / StatsDisplay when input is missing and
cached exceeds prompt. Extend the token-tracking UI behavioral test with a case
where combined usage would previously format a negative Input value, and assert
the displayed text is clamped to zero instead of showing a negative number. Use
the existing formatSessionTokenUsage helper and StatsDisplay-related assertions
so the safeguard in packages/cli/src/ui/components/StatsDisplay.tsx stays
covered.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3c6606aa-06a8-44f6-8160-16dd36d4086e

📥 Commits

Reviewing files that changed from the base of the PR and between 1416cd6 and 59c4f9f.

⛔ Files ignored due to path filters (1)
  • packages/cli/src/ui/components/__snapshots__/StatsDisplay.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (20)
  • integration-tests/token-tracking-behavioral.test.ts
  • integration-tests/token-tracking-integration.test.ts
  • integration-tests/token-tracking-provider-behavioral.test.ts
  • integration-tests/token-tracking-ui-behavioral.test.ts
  • integration-tests/token-tracking.test.ts
  • packages/agents/src/core/ChatSessionFactory.test.ts
  • packages/agents/src/core/ChatSessionFactory.tokenReestimate.test.ts
  • packages/agents/src/core/ChatSessionFactory.ts
  • packages/agents/src/core/TurnProcessor.ts
  • packages/agents/src/core/chatSession.tokenSync.test.ts
  • packages/agents/src/core/streamResponseHelpers.ts
  • packages/cli/src/ui/components/StatsDisplay.tsx
  • packages/core/src/services/history/HistoryService.tokenReset.test.ts
  • packages/core/src/services/history/HistoryService.ts
  • packages/providers/src/ProviderManager.test.ts
  • packages/providers/src/anthropic/AnthropicProvider.caching-metrics.test.ts
  • packages/providers/src/anthropic/AnthropicResponseParser.ts
  • packages/providers/src/anthropic/AnthropicStreamProcessor.ts
  • packages/providers/src/logging/telemetryEmitter.ts
  • packages/providers/src/tokenUsageTracker.ts
💤 Files with no reviewable changes (1)
  • packages/providers/src/logging/telemetryEmitter.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: E2E Test (Linux) - sandbox:none
  • GitHub Check: E2E Test (Linux) - sandbox:docker
  • GitHub Check: E2E Test (macOS)
  • GitHub Check: CodeQL
  • GitHub Check: Lint (Javascript)
  • GitHub Check: Interactive UI (tmux)
  • GitHub Check: Run LLxprt review
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2026-02-06T15:52:42.315Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1305
File: scripts/generate-keybindings-doc.ts:1-5
Timestamp: 2026-02-06T15:52:42.315Z
Learning: In reviews of vybestack/llxprt-code, do not suggest changing existing copyright headers from 'Google LLC' to 'Vybestack LLC' for files that originated from upstream. Preserve upstream copyrights in files that came from upstream, and only apply 'Vybestack LLC' copyright on newly created, original LLxprt files. If a file is clearly LLxprt-original, it may carry the Vybestack header; if it is upstream-originated, keep the original sponsor header.

Applied to files:

  • packages/agents/src/core/chatSession.tokenSync.test.ts
  • packages/providers/src/anthropic/AnthropicResponseParser.ts
  • packages/providers/src/anthropic/AnthropicProvider.caching-metrics.test.ts
  • packages/agents/src/core/ChatSessionFactory.ts
  • packages/providers/src/anthropic/AnthropicStreamProcessor.ts
  • packages/agents/src/core/ChatSessionFactory.tokenReestimate.test.ts
  • packages/providers/src/tokenUsageTracker.ts
  • packages/agents/src/core/ChatSessionFactory.test.ts
  • integration-tests/token-tracking-integration.test.ts
  • packages/providers/src/ProviderManager.test.ts
  • integration-tests/token-tracking-provider-behavioral.test.ts
  • packages/core/src/services/history/HistoryService.tokenReset.test.ts
  • packages/agents/src/core/TurnProcessor.ts
  • integration-tests/token-tracking.test.ts
  • packages/core/src/services/history/HistoryService.ts
  • packages/agents/src/core/streamResponseHelpers.ts
  • integration-tests/token-tracking-ui-behavioral.test.ts
  • integration-tests/token-tracking-behavioral.test.ts
📚 Learning: 2026-03-31T02:12:43.093Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1854
File: packages/core/src/core/subagentRuntimeSetup.test.ts:77-84
Timestamp: 2026-03-31T02:12:43.093Z
Learning: In this codebase, tool declarations should follow the single required contract `parametersJsonSchema`; do not ask to preserve or reintroduce the legacy `parameters` fallback field. Reviewers should not flag assertions/checks for missing `parameters` or suggest backward-compatibility behavior for `parameters`. Schema converters/providers are expected to error if `parametersJsonSchema` is absent instead of falling back to `parameters`.

Applied to files:

  • packages/agents/src/core/chatSession.tokenSync.test.ts
  • packages/providers/src/anthropic/AnthropicResponseParser.ts
  • packages/providers/src/anthropic/AnthropicProvider.caching-metrics.test.ts
  • packages/agents/src/core/ChatSessionFactory.ts
  • packages/providers/src/anthropic/AnthropicStreamProcessor.ts
  • packages/agents/src/core/ChatSessionFactory.tokenReestimate.test.ts
  • packages/providers/src/tokenUsageTracker.ts
  • packages/agents/src/core/ChatSessionFactory.test.ts
  • packages/providers/src/ProviderManager.test.ts
  • packages/core/src/services/history/HistoryService.tokenReset.test.ts
  • packages/agents/src/core/TurnProcessor.ts
  • packages/core/src/services/history/HistoryService.ts
  • packages/agents/src/core/streamResponseHelpers.ts
📚 Learning: 2026-06-10T18:18:08.545Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1983
File: packages/policy/src/policy-engine.ts:156-156
Timestamp: 2026-06-10T18:18:08.545Z
Learning: In this repo, ESLint rule `sonarjs/too-many-break-or-continue-in-loop` is set to fail loops that contain more than 1 `break`/`continue` total per loop (or both present). When a loop violates this (e.g., it contains a `break` and a `continue`, or has multiple `break`s/`continue`s), the code will not lint unless the violating line includes `// eslint-disable-next-line sonarjs/too-many-break-or-continue-in-loop`. In code reviews, do not suggest removing these `eslint-disable-next-line` directives (use refactoring only if it eliminates the underlying >1 break/continue pattern).

Applied to files:

  • packages/agents/src/core/chatSession.tokenSync.test.ts
  • packages/providers/src/anthropic/AnthropicResponseParser.ts
  • packages/providers/src/anthropic/AnthropicProvider.caching-metrics.test.ts
  • packages/agents/src/core/ChatSessionFactory.ts
  • packages/providers/src/anthropic/AnthropicStreamProcessor.ts
  • packages/agents/src/core/ChatSessionFactory.tokenReestimate.test.ts
  • packages/providers/src/tokenUsageTracker.ts
  • packages/agents/src/core/ChatSessionFactory.test.ts
  • integration-tests/token-tracking-integration.test.ts
  • packages/cli/src/ui/components/StatsDisplay.tsx
  • packages/providers/src/ProviderManager.test.ts
  • integration-tests/token-tracking-provider-behavioral.test.ts
  • packages/core/src/services/history/HistoryService.tokenReset.test.ts
  • packages/agents/src/core/TurnProcessor.ts
  • integration-tests/token-tracking.test.ts
  • packages/core/src/services/history/HistoryService.ts
  • packages/agents/src/core/streamResponseHelpers.ts
  • integration-tests/token-tracking-ui-behavioral.test.ts
  • integration-tests/token-tracking-behavioral.test.ts
📚 Learning: 2026-06-10T18:18:09.253Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 1983
File: packages/policy/src/policy-engine.ts:263-263
Timestamp: 2026-06-10T18:18:09.253Z
Learning: In this repository, the ESLint rule `sonarjs/too-many-break-or-continue-in-loop` is configured to allow at most 1 `break`/`continue` per loop (it is stricter than the SonarJS default). During code review, treat `// eslint-disable-next-line sonarjs/too-many-break-or-continue-in-loop` on loops with 2+ `break`/`continue` as intentional and do not suggest removing or changing those directives. Only consider a change if the rule is violated without an appropriate intentional disable.

Applied to files:

  • packages/agents/src/core/chatSession.tokenSync.test.ts
  • packages/providers/src/anthropic/AnthropicResponseParser.ts
  • packages/providers/src/anthropic/AnthropicProvider.caching-metrics.test.ts
  • packages/agents/src/core/ChatSessionFactory.ts
  • packages/providers/src/anthropic/AnthropicStreamProcessor.ts
  • packages/agents/src/core/ChatSessionFactory.tokenReestimate.test.ts
  • packages/providers/src/tokenUsageTracker.ts
  • packages/agents/src/core/ChatSessionFactory.test.ts
  • integration-tests/token-tracking-integration.test.ts
  • packages/cli/src/ui/components/StatsDisplay.tsx
  • packages/providers/src/ProviderManager.test.ts
  • integration-tests/token-tracking-provider-behavioral.test.ts
  • packages/core/src/services/history/HistoryService.tokenReset.test.ts
  • packages/agents/src/core/TurnProcessor.ts
  • integration-tests/token-tracking.test.ts
  • packages/core/src/services/history/HistoryService.ts
  • packages/agents/src/core/streamResponseHelpers.ts
  • integration-tests/token-tracking-ui-behavioral.test.ts
  • integration-tests/token-tracking-behavioral.test.ts
📚 Learning: 2026-06-19T17:16:56.523Z
Learnt from: acoliver
Repo: vybestack/llxprt-code PR: 2108
File: packages/agents/src/api/agentImpl.ts:1047-1079
Timestamp: 2026-06-19T17:16:56.523Z
Learning: When the fake-provider test seam is active in vybestack/llxprt-code, `process.env.LLXPRT_FAKE_RESPONSES` is set to a fixture file path ending in a `.jsonl` (not to the string `'1'` or any other boolean-like value). In code, detect the seam by checking `process.env.LLXPRT_FAKE_RESPONSES !== undefined` (and/or that it is a non-empty string), rather than using `process.env.LLXPRT_FAKE_RESPONSES === '1'`. Update any callers of the env var accordingly (see `packages/providers/src/composition/providerManagerInstance.ts` and harness usages).

Applied to files:

  • packages/agents/src/core/chatSession.tokenSync.test.ts
  • packages/providers/src/anthropic/AnthropicResponseParser.ts
  • packages/providers/src/anthropic/AnthropicProvider.caching-metrics.test.ts
  • packages/agents/src/core/ChatSessionFactory.ts
  • packages/providers/src/anthropic/AnthropicStreamProcessor.ts
  • packages/agents/src/core/ChatSessionFactory.tokenReestimate.test.ts
  • packages/providers/src/tokenUsageTracker.ts
  • packages/agents/src/core/ChatSessionFactory.test.ts
  • packages/providers/src/ProviderManager.test.ts
  • packages/core/src/services/history/HistoryService.tokenReset.test.ts
  • packages/agents/src/core/TurnProcessor.ts
  • packages/core/src/services/history/HistoryService.ts
  • packages/agents/src/core/streamResponseHelpers.ts
🔇 Additional comments (12)
packages/core/src/services/history/HistoryService.ts (1)

230-259: LGTM!

Also applies to: 441-447

packages/core/src/services/history/HistoryService.tokenReset.test.ts (1)

1-178: LGTM!

packages/agents/src/core/ChatSessionFactory.test.ts (1)

58-59: LGTM!

Also applies to: 436-437

packages/agents/src/core/ChatSessionFactory.tokenReestimate.test.ts (1)

1-231: LGTM!

packages/agents/src/core/ChatSessionFactory.ts (1)

348-352: LGTM!

packages/providers/src/anthropic/AnthropicResponseParser.ts (1)

134-137: LGTM!

packages/providers/src/anthropic/AnthropicStreamProcessor.ts (1)

242-248: LGTM!

Also applies to: 365-379, 401-404, 541-543

packages/providers/src/anthropic/AnthropicProvider.caching-metrics.test.ts (1)

315-316: LGTM!

Also applies to: 348-349

packages/providers/src/ProviderManager.test.ts (1)

171-173: LGTM!

Also applies to: 182-191, 200-205, 218-218

integration-tests/token-tracking-integration.test.ts (1)

154-156: LGTM!

Also applies to: 166-167

integration-tests/token-tracking-behavioral.test.ts (1)

108-109: LGTM!

Also applies to: 131-132, 188-189, 209-210, 239-240, 249-250, 260-261, 533-535, 545-546

integration-tests/token-tracking-provider-behavioral.test.ts (1)

467-478: LGTM!

Also applies to: 488-489, 556-558, 569-571, 581-582

Comment on lines +261 to +269
resetTokenAccounting(): void {
this.syncGeneration++;
this.baseTokenOffset = 0;
this.emit('tokensUpdated', {
totalTokens: this.getTotalTokens(),
addedTokens: 0,
contentId: null,
});
}

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Invalidate pending syncs on every token-accounting reset path.

Line 262 only bumps syncGeneration in resetTokenAccounting(). A queued syncTotalTokens() followed by clear() or dispose() can still replay later and restore a non-zero baseTokenOffset onto an emptied service, because those paths never advance the generation. Please extract this invalidation into a shared helper and call it from all state-reset paths, not just provider-switch reset.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/services/history/HistoryService.ts` around lines 261 - 269,
The token-accounting reset logic in HistoryService only invalidates pending
syncs inside resetTokenAccounting(), so a queued syncTotalTokens() can still
apply after clear() or dispose() and restore stale state. Extract the
syncGeneration bump into a shared helper in HistoryService and call it from
every state-reset path that should cancel in-flight syncs, including
resetTokenAccounting(), clear(), and dispose(), so all resets consistently
invalidate pending work.

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

Labels

maintainer:e2e:ok Trusted contributor; maintainer-approved E2E run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When switching from opus to gpt the context is miscalculated

1 participant