qwen-code/packages/cli/src/config
John London 5037fa7627
Feat/stats model cost estimation rebase (#3780)
* feat(stats): add optional cost estimation to /stats model

Adds optional cost estimation based on user-defined pricing in settings.json.
Users can configure per-model pricing via the new modelPricing setting.
When configured, /stats model shows estimated cost; when not configured,
the behavior is unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(stats): extract raw model name from composite key for cost lookup

flattenModelsBySource creates keys like "model::source", but
modelPricing is keyed by raw model names. Extract the raw
model name by splitting on "::" to fix cost lookup.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: update settings schema after adding modelPricing

Regenerate the VS Code settings schema to include the new
modelPricing field so the lint check passes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* test(ui): add regression tests for cost estimation edge cases

Coverage for the cost display fixes in ModelStatsDisplay:
- Cost section hidden when no pricing + no thoughts
- Cost section shown when pricing is configured (with value check)
- Thoughts tokens included in cost calculation (with larger numbers
  to expose the before/after difference)
- Raw model name used for pricing lookup with subagent attribution
- Cost section shown when thoughts > 0 even without pricing
- Multiple models with different pricing

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(ui): include thoughts tokens in ModelStatsDisplay cost calculation

Address review feedback: the interactive cost estimate was omitting
thoughts/reasoning tokens from the output token count, causing it to
disagree with the non-interactive /stats model path.

Changes:
- hasPricing visibility gate now includes thoughts in outputTokens
- Cost estimate calculation now includes thoughts in outputTokens
- getModelName() already correctly extracts raw model name from
  flattened model::source keys for pricing lookup

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(stats): include thoughts tokens in non-interactive cost calc + update snapshots

- Fix statsCommand.ts non-interactive path to include thoughts tokens in
  outputTokens for cost calculation, aligning with the interactive
  ModelStatsDisplay path.
- Update 4 ModelStatsDisplay snapshots to reflect Cost section appearing
  when thoughts > 0 (even without pricing, showing N/A).

* fix(test): address all CI failures and reviewer feedback on PR #3780

- Add `toModelMetrics` helper to statsCommand.test.ts to properly
  create ModelMetrics with required `bySource` property
- Fix ModelStatsDisplay.test.tsx:
  - Add missing `sessionId` to SessionStatsState mock
  - Add missing `startNewSession` to useSessionStatsMock
  - Add `auto_accept` to all totalDecisions mocks (7 locations)
  - Add `files` to all SessionMetrics objects (6 locations)
  - Remove contradictory test "should show Cost section when thoughts > 0
    even without pricing" per Option A (strict opt-in)
- Revert 4 snapshots that incorrectly showed Cost/N/A lines for models
  without pricing configuration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-03 07:31:08 +08:00
..
migration refactor: remove summarizeToolOutput feature 2026-03-15 13:51:32 +08:00
auth.test.ts feat(auth): discontinue Qwen OAuth free tier (2026-04-15 cutoff) (#3291) 2026-04-15 22:30:20 +08:00
auth.ts feat(auth): discontinue Qwen OAuth free tier (2026-04-15 cutoff) (#3291) 2026-04-15 22:30:20 +08:00
config.integration.test.ts chore: update tests for parseArguments signature change 2026-02-06 13:05:49 +08:00
config.test.ts feat(core): event monitor tool with throttled stdout streaming (Phase C) (#3684) 2026-05-02 20:57:26 +08:00
config.ts feat(core): event monitor tool with throttled stdout streaming (Phase C) (#3684) 2026-05-02 20:57:26 +08:00
keyBindings.test.ts Explict imports & exports with type modifier (#3774) 2025-08-25 22:04:53 +00:00
keyBindings.ts refactor: rename verboseMode to compactMode for better UX clarity (#3075) 2026-04-10 11:55:50 +08:00
modelProvidersScope.test.ts fix: lint & ci issues 2026-01-07 22:58:09 +08:00
modelProvidersScope.ts feat(cli): warn when workspace overrides global modelProviders (#3148) 2026-04-13 10:43:16 +08:00
sandboxConfig.ts feat(cli): support tools.sandboxImage in settings (#3146) 2026-04-13 09:43:34 +08:00
settings.test.ts feat(cli): add slashCommands.disabled setting to gate slash commands (#3445) 2026-04-20 11:06:26 +08:00
settings.ts feat(hooks): Add HTTP Hook, Function Hook and Async Hook support (#2827) 2026-04-16 10:10:33 +08:00
settingsSchema.test.ts fix(cli): honor proxy setting (#3753) 2026-04-30 18:24:59 +08:00
settingsSchema.ts Feat/stats model cost estimation rebase (#3780) 2026-05-03 07:31:08 +08:00
trustedFolders.test.ts refactor: unify sandbox configuration naming and improve telemetry config 2026-02-11 11:08:15 +08:00
trustedFolders.ts refactor: unify sandbox configuration naming and improve telemetry config 2026-02-11 11:08:15 +08:00