feat(vscode): add token usage visibility setting - #1100
Conversation
will-lamerton
left a comment
There was a problem hiding this comment.
Approach looks right and the webview-side gating is clean. A few things to fix before merge.
Blocking
-
Unhandled rejection on the update path.
_handleUpdateSettingis nowasyncbutcase 'updateSetting'calls it withoutawait/.catch(), and_updateShowTokenUsagehas notry/catch. Ifconfig.updaterejects, the webview never gets asettingsUpdatedmessage, no error toast fires, and the promise rejects unhandled.SettingsManager.updateSettingalready wraps its body and returns{success: false, error}; mirror that. -
Always writing
ConfigurationTarget.Global. The setting has no declaredscope, so it defaults towindowand can be set in.vscode/settings.json. When a workspace value exists,get()returns it, the panel writes Global, the effective value never changes, and the toggle silently snaps back with no error. Useconfig.inspect()to pick the narrowest scope that already holds a value, falling back to Global. Also worth deciding deliberately: every other toggle in this panel persists per-project, so this one changing behaviour for all workspaces is an inconsistency. -
No
onDidChangeConfigurationlistener. It is a contributed setting now, so users will flip it in the Settings editor, and nothing pushes that to a live webview. It stays stale until reload or until the in-panel settings view is opened.extension.ts:130already has this pattern fornanocoder.codeLens; calling_handleRequestSettings()onaffectsConfiguration('nanocoder.showTokenUsage')closes it.
Non-blocking
-
SettingsManager.readSettingshardcodesshowTokenUsage: falseand the provider immediately overwrites it, so the field onSettingsDatais wrong by construction for any other caller. Prefer leaving it offSettingsDataand typing the webview payload asSettingsData & {showTokenUsage: boolean}. -
The
settings-manager.spec.tsassertion tests that hardcoded constant, so it passes whether or not the feature works. Drop it or move it to whatever owns the real value. Thechat-panel-turn-footer.spec.tstest is good; the missing case is enabled-then-disabled. -
Toggling off leaves already-rendered footers on screen (and toggling on does not back-fill). Since the issue is about visual noise, hiding existing indicators in
renderSettingsDatawould match expectations. -
Changeset is
patchfor a user-facing feature; this repo usesminorfor those (seeanthropic-prompt-caching,calm-work-summaries). -
Minor:
case 'ready'now does a full config-file read plus a wholerenderSettingsDatapass to learn one boolean.
Summary
nanocoder.showTokenUsageVS Code setting, defaulting to falseFixes #1096
Testing