Repository navigation
feat(sidebar): percent-only usage, opt-in local cost, /cmd-settings - #19
Merged
Merged
Conversation
The per-model cost row summed json_extract over session_message on every 5 second poll: a main-thread scan with a disk-spilling sort, which is what made typing lag. Cost now defaults to off and, when enabled, answers from a memo for costMs instead of rescanning per tick. Poll cadence, colour, plan and the cost mode are editable from /cmd-settings, which follows the wallpaper plugin's dialog pattern.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
JeffreyJYZ
approved these changes
Nov 14, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes the Command Code sidebar percentage-only by default and moves the local cost figure behind an opt-in setting, then adds
/cmd-settingsto change these from inside opencode.Why
The per-model cost row ran a
json_extract(data, '$.cost') ... GROUP BYoversession_messageon every five-second poll. On a 1.3 GiB store that is a full scan with a disk-spilling sort, and it ran on the TUI's own main thread: measured 6 database opens in 25 seconds at 0.5 to 1.2 seconds each, with the main thread 49.8 percent busy. Keystrokes queue behind that thread.With the plugin disabled the same measurement showed zero database reads and 21.5 percent busy, which is what confirmed the cause.
Changes
src/sidebar/local-cost.ts(new): every local cost read is memoised per key forcostMsand returns before opening a database whencostisoff.src/sidebar/useRows.ts: no longer importsusageDb; the poll cadence comes fromprefs.pollMs; cost rows are omitted unless the user enables them.src/sidebar/prefs.ts:PrefsgainspollMs,costandcostMs, with strict validation, plussavePrefswriting the shared config file atomically and preserving unknown keys.src/sidebar/settings.tsx,src/sidebar/settings-rows.ts(new): the/cmd-settingsdialog, built the same way the wallpaper plugin builds its picker.src/tui-commands.tsx(new): command registration moved out oftui.tsx, which drops from 214 to 114 lines.Behaviour
Defaults are
cost: off,pollMs: 5000,costMs: 60000, so an existing install keeps its account percentages and stops reading the store at all.cost: sessionadds the indexed session reads,cost: windowadds the account-wide window scans.Verification
bun checkclean,bun test263 pass,bun run buildclean, anddist/tui.jscontains the settings command.