Repository navigation
fix(powerline): put back the default padding when (p) takes the last line off Powerline - #130
Draft
eric-engberg wants to merge 241 commits into
Draft
eric-engberg wants to merge 241 commits into
eric-engberg wants to merge 241 commits into
Conversation
Letter shortcuts compared the typed character without checking modifiers, so ctrl+letter and alt+letter ran the plain-letter action: ctrl+r toggled raw value, ctrl+d deleted a widget, and on macOS alt+arrow (sent as ESC + letter) fired whatever letter followed. A few handlers patched ctrl+s one key at a time with `&& !key.ctrl`; widget keybinds checked ctrl but not alt. Shortcuts now compare against getPlainInput(), which is empty while ctrl or alt/option is held, across the line editor, widget keybinds, Edit Colors, Global Overrides, Powerline setup/themes/separators, the line selector and the hide-state checklist. Arrows, Enter, ESC, shift and text entry are unchanged, and modifier combos are free for bindings of their own.
Picking up a code change meant quitting the TUI and redoing any unsaved setup and navigation by hand. With CCSTATUSLINE_DEV_RELOAD=1 the interactive TUI runs under a small supervisor process. ctrl+r writes a snapshot (unsaved and original settings, current screen, selected line, menu positions, line editor cursor) and exits with code 75; the supervisor starts a fresh process on the latest code, which resumes from the snapshot. Screens that carry their own flow state (confirm dialogs, install/update, import/export) resume on the main menu. If the new code fails to start, the supervisor keeps the snapshot and offers Enter to retry once it's fixed, or q to quit. Without the variable nothing changes: no supervisor, no key, and the module is only loaded through a dynamic import in the interactive branch, so the status line render path is unaffected.
The shortcut tests sent keys and checked the result after a fixed 25 ms. On a busy machine Ink can take longer, so the bare-key cases could fail even though the shortcut works. They now wait until the shortcut's effect shows (up to 3 s), and a follow-up key waits for the previous key's redraw. Checks that a modified key does nothing give it 150 ms to act. After each wait the test also gives React two setImmediate turns: React draws a frame, then attaches the new input listener in a scheduled effect, so a key sent the moment the frame shows could reach no listener.
Seeing what a widget looks like used to mean adding it, looking, and removing it again. While the add/insert/change picker highlights a widget, the status line preview now shows the line exactly as Enter would leave it; ESC or browsing categories restores the line. The new widget's id and powerline background are fixed when the picker opens, so the preview doesn't change color on every keypress and Enter adds exactly what was shown. Preview and apply share one placement helper.
The picker rendered every entry, so the All category (~90 widgets) or a broad search ran past the bottom of the terminal and scrolled the status line preview off the top, which made the live preview useless there. Picker lists now show only the entries around the selection, sized to the terminal height and the number of status lines, with "↑ N more" / "↓ N more" markers. Entry numbers stay absolute so position in the full list is still visible.
The dev reload cursor test checked the first frame and the cursor callback after fixed 25 ms delays, which a busy machine can outrun. It now retries the assertions until they pass (up to 3 s) with a waitFor helper. Once they pass, waitFor gives React two setImmediate turns: React draws a frame, then attaches the new input listener in a scheduled effect, so a key sent the moment the frame shows could reach no listener.
The widget picker tests typed into the picker 25 ms after the key that opened it. On a busy machine the picker might not be drawn and listening yet, so the typed text reached the line editor instead, where several letters are shortcuts. Each step now waits for its visible result before the next key: the picker's title, the preview, onUpdate, or the redrawn list window.
Showing the effort next to the model, e.g. "Opus 5.5(xhigh)" with the
level color-coded, took four merged widgets and still couldn't color by
level.
Thinking Effort gains two options, both off by default so existing
setups render exactly as before:
- (b)rackets cycles off, (), [], {}, <> and wraps the widget's output
- (l)evel colors opens an editor that colors the value by level
(low gray, medium green, high yellow, xhigh orange, max red by
default), with brackets matching the level or the widget color,
named/hex/ansi256 colors, and a sample that follows the cursor
The label, unknown levels and widget-colored brackets keep the color
from Edit Colors, which now notes that the widget sets some colors
itself. With level colors on the widget preserves its own foreground,
like Claude Status; color level 0 and global foreground overrides still
win. The default orange falls back to bright magenta on 16-color
terminals.
ctrl+d reset the level colors and alt+x opened the custom color prompt, because the editor compared the typed letter without checking modifiers. On macOS alt+arrow arrives as ESC + letter, so this also fired while navigating. The editor now uses getPlainInput() like the rest of the TUI.
The default xhigh orange showed as its raw value, ansi256:208. It now shows as Orange. Other custom colors are labeled the way Edit Colors labels them, ANSI n and #RRGGBB, instead of the stored ansi256:n and hex:rrggbb.
(a) in Edit Colors used to ask for a palette number from 0 to 255, so you had to know the number of the color you wanted. It now opens the whole palette as a grid: the 16 basic colors, the 6x6x6 color cube as six 6x6 blocks, and the 24 grays. The arrow keys move the cursor and the status line preview follows it; Enter keeps the color and ESC restores the previous one. Typing a number still works and jumps straight to that color. The grid works for foreground and background, and is offered at truecolor as well as 256 colors. Basic colors are saved by name, the same values the arrow keys cycle through; the rest are saved as ansi256:N, as before. A hex color starts the cursor on the nearest palette color.
…ests The editor tests sent each key 25 ms after the previous one. On a busy machine a key could arrive before the previous one was drawn, acting on the old state. Every key in these tests redraws the editor or ends it, so each now waits for that (up to 3 s) and fails loudly if it never comes. Keys that should do nothing (ctrl and alt combos) get 150 ms to act instead.
The grid tests sent each key 25 ms after the previous one, so on a busy machine a key could arrive before the grid was drawn and listening. Every key in these tests redraws the screen, so each now waits for that (up to 3 s) and fails loudly if it never comes. The 16-color case, where (a) must do nothing, gives the key 150 ms to act instead.
Block Timer, Block Reset Timer, Weekly Reset Timer, Extra Usage Utilization and the usage-percent widgets each built their bars with the same two blocks (the bracketed bar plus percentage, and the short bar with or without it), Extra Usage twice and Block Timer three times. formatUsageBar in usage-display builds them in one place and returns null outside the bar modes, so each widget only adds its label. The time cursor is resolved only in bar modes, as before. No behavior change: the existing tests pass unchanged.
Session, Weekly, Weekly Sonnet, Weekly Opus and Fable Weekly Usage were five identical classes apart from the kind each passed to the shared usage-percent functions. UsagePercentWidget holds that class once; each widget now just names its kind. No behavior change: the existing tests pass unchanged.
Context % and Context % (usable) were the same class apart from their name, color, description, label prefix, preview sample and how they measure the used share of the window. ContextPercentageWidgetBase holds the shared editor display, actions, keys and rendering; each widget supplies only what differs. No behavior change: the existing tests pass unchanged.
(g)radient in the line editor colors the Context Bar's filled cells by where they sit in the bar, from green through yellow to red, so a fuller bar reaches further into the red. Empty cells turn dark gray. Off by default. Truecolor terminals get exact RGB values, 256-color terminals the nearest palette colors, and 16-color terminals three bands (green, yellow, red). With colors off or a global foreground override, the bar stays plain. It works in all three bar styles and in the TUI preview. The widget colors only the bar and ends the colored run with the default-foreground code. The renderer now turns that code back into the widget's own foreground, in plain mode and in Powerline segments, so the label and numbers after the bar keep their usual color (the theme's, in Powerline) instead of dropping to the terminal default. No existing widget embeds that code inside a colored segment, so nothing else changes.
(g) now cycles through six presets instead of toggling one gradient: off, traffic (green to red), thermal (blue to red), viridis, cividis, blue-orange and mono, then off again. Every preset runs from calm to urgent. Traffic and thermal depend on telling red from green or blue from red. The other four stay readable with red-green color blindness: viridis and cividis are the standard colorblind-safe colormaps, blue-orange uses Okabe-Ito colors, and mono changes brightness only. Viridis, cividis and mono get steadily brighter, so they also read in grayscale. Viridis and cividis start a little in from their dark ends so the first cells show on dark backgrounds. Each preset has its own three bands for 16-color terminals. The line editor shows the current preset, e.g. "gradient: thermal". A gradient saved as "true" by the previous version reads as traffic. docs/USAGE.md lists the Context Bar's (g) key with the presets.
The preview sample was 50k/200k (25%), which fills only a quarter of the bar. While cycling gradient presets in the line editor, that shows just their calm end, so they're hard to tell apart. The sample is now 180k/200k (90%), which shows nearly each preset's whole range. Only the TUI preview changes; real renders still use the session's data. This is separate from the gradient itself and can be dropped on its own.
The 256-color palette is too coarse for these gradients: neighbouring cells snap to washed-out or off-hue palette colors, so most presets came out as a patchwork instead of a ramp. Hand-picked 256-color ramps were cleaner but still visibly stepped. Gradients now render only at the Truecolor color level. As Edit Colors does with (h)ex, (a)nsi256 and (g)radient, (g) is offered only where it can show. A gradient saved earlier (from a truecolor session, or an imported config) is kept, renders plain at lower levels, and the line editor labels it "gradient: thermal, needs truecolor" so the plain bar is explained. Widget.getEditorDisplay and getCustomKeybinds take an optional settings argument for this; the line editor passes its settings. Widgets that ignore it are unaffected.
The Context Bar's gradient presets now work on every widget that draws a bar: Context % and Context % (usable) in slider modes; Session, Weekly, Weekly Sonnet, Weekly Opus and Fable Weekly Usage; Extra Usage Utilization; and the Block, Block Reset and Weekly Reset timers in their bar modes. formatUsageBar paints the usage-style bars and the Context % base class paints its slider, so each bar is painted in one place. Widgets offer (g) while they show a bar and name their preset; the line editor hides (g) below truecolor and adds "needs truecolor" to the label, in one place, so widgets don't need the settings for it. When a bar fills with what's left (inverted fill, or remaining instead of used), the gradient runs from the urgent end, so the color where the fill ends still shows how urgent things are. The usage widgets' time cursor takes a cell's place in the gradient but keeps the widget color. docs/USAGE.md describes bar gradients once and points each widget's keys to it. The usage widgets' expected key lists in the tests now include (g) in bar modes.
Most bar widgets' TUI previews sampled low values (Session 20%, Weekly 12%, the Sonnet, Opus and Fable weeklies 4-8%, Extra Usage 2.6%, Context % 9.3%, the reset timers 10% elapsed), so a gradient showed only its first color or two while choosing a preset. The samples are now 60-90%: Session 90%, Weekly 80%, Weekly Sonnet 70%, Weekly Opus and Fable 60%, Extra Usage 85%, Context % and Context % (usable) 90%, and Block Reset Timer 85% elapsed, with its preview time changed to match (45m left). Weekly Reset Timer's bar now samples 78.3% elapsed, matching its existing preview time of 36.5h left in the week. Block Timer already sampled 73.9%. Only TUI previews change. Like the Context Bar's sample, this is its own commit and can be dropped without affecting the rest.
Every progress bar (Context Bar, Context %, the usage widgets, Extra Usage Utilization and the timers) can now set its width with (b) in its bar modes: default keeps the display mode's own size, 10% to 100% asks for that share of the line, and fill takes all the room the rest of the line leaves. The width editor steps with the arrow keys and previews each width as it goes. Sized bars never push the line past the terminal. The renderer pre-renders them at 5 cells, measures each line with flex separators at their narrowest, then grows them into the room left: percentage bars first, shrunk in proportion when they don't all fit, then fill bars sharing the rest evenly. Auto-align uses the minimum width, so a grown bar doesn't widen the same column on other lines. With no terminal width detected, sized bars keep their display mode's size, and bars without a width setting are unchanged.
Pre-rendering one widget moves into preRenderWidget, and the line editor's shared editors (hide states, bar width) and its choice of what to preview move into small helpers, so preRenderAllWidgets and ItemsEditor don't grow more branches. Behavior is unchanged.
With a bar width, the display modes overlapped: the long and medium bars drew the same once (b) sized them, (p) still stepped through both, and only the short bar could drop the numbers after it. Each bar now has three settings of its own: - (p) picks the style: text, a block bar or a slider bar. It keeps the bar's size, and the text mode remembers it for when the bar comes back. - (b) picks the size: short, medium or long (10, 16 or 32 cells), a share of the line, or fill. - (n) hides or shows the numbers after any bar. Saved settings render as before: the old modes are stored the same way, so a long block bar is still `progress`, a medium one `progress-short`, and `slider-only` reads as a short slider with its numbers hidden. Other sizes go in `barWidth`, and hidden numbers in `barOnly`.
Spreading undefined adds nothing, so the fallbacks were noise.
…arately The Context Bar follows its bar with two numbers, the token counts and the percent, and (n) could only hide both. It now cycles: both, the percent only, the counts only, none. Bars with only a percent after them keep the on/off toggle. The setting becomes `barNumbers` (`percent`, `counts` or `none`; absent shows everything). `barOnly`, its name until now, still reads as none.
The label editor opened with b (la(b)el…). Custom Text, Custom Command, Custom Symbol and Link already open their text editors with e, so the line editor's "edit this widget's text" key differed by widget. Labels now use e too, shown as (e)dit label…, which also reads more plainly. None of the widgets that bind e has a label, so e is free wherever the label editor appears; the existing check that labeled widgets leave the label key unbound now runs against e.
…ew test This branch samples Context % (usable)'s preview at 90% so a gradient bar shows its range. sirmalloc#407's test that the preview ignores compaction settings still expected the old 11.6% sample.
…olors test The line and color editor tests no longer sleep a fixed 25ms after each render and key. They wait for the key's visible effect, and the sleep helper flushInk is gone. The color menu test that checks the note for a widget that sets some of its own colors still called flushInk after the first render, so it no longer compiled. It now waits until the frame shows the Thinking Effort row, then reads that frame as before.
…uplication # Conflicts: # src/widgets/BlockResetTimer.ts # src/widgets/BlockTimer.ts # src/widgets/ExtraUsageUtilization.ts # src/widgets/WeeklyResetTimer.ts # src/widgets/shared/usage-display.ts # src/widgets/shared/usage-percent-widget.ts
…gradient # Conflicts: # docs/USAGE.md # src/widgets/ContextBar.ts # src/widgets/shared/context-slider.ts # src/widgets/shared/usage-display.ts
The thin line display mode draws its bar as ━ and ─, which the gradient painter didn't count as cells, so a line bar with a preset stayed plain. The filled line cells now take the gradient and the empty ones the dark gray, as the block cells do.
The line display mode from main becomes a third bar style next to block and slider: (p) steps text, block, slider, line on the usage widgets and timers (text, block, line without a slider), text, slider, line on Context %, and block, slider, line on the Context Bar. A line keeps the size and numbers the bar had, like a slider does, is medium (16 cells) when it has none of its own, and is stored as display 'line'. Its editor row reads "line bar" with the size, as the other styles do.
# Conflicts: # src/tui/components/ColorMenu.tsx # src/tui/components/__tests__/PowerlineSetup.test.ts
# Conflicts: # src/tui/components/__tests__/PowerlineSetup.test.ts
# Conflicts: # src/utils/__tests__/powerline-settings.test.ts # src/utils/powerline-settings.ts
# Conflicts: # src/widgets/shared/__tests__/usage-bar.test.ts
# Conflicts: # src/utils/renderer.ts # src/widgets/shared/__tests__/usage-bar.test.ts
# Conflicts: # src/tui/components/__tests__/ColorMenu.test.tsx
# Conflicts: # src/tui/components/__tests__/ColorMenu.test.tsx
…helper #96 gives renderColorMenu a settings parameter for its paste tests. With the settings first here too, the two helpers meet in next as one signature that both branches' calls fit.
|
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.



Builds on #129 (
fix/powerline-setup) and merges #49 (feat/powerline-per-line) and #52 (fix/bar-width-per-line). Fork-only meet branch fornext; not for upstream.What
Switching a line to Powerline with
pin Edit Lines and back to plain now puts back the Default Padding from before, as turning Powerline on and off in Powerline Setup does onfix/powerline-setup. Before, the plain line came back asModel | Ctxwhatever the padding had been, including none on a fresh install.The same holds when the two ways are mixed. A line put on Powerline with
p, then Powerline turned on and off with (t), then the line set back to plain gets its padding back too. So does a line put on Powerline withpafter (t) turned Powerline on while every line was set to plain. A padding changed while a line is Powerline is the user's own and stays, across (t) too.Why
fix/powerline-setupremembers the padding that turning Powerline on replaces (powerline.paddingToRestore) and puts it back when Powerline is turned off. #49'sbuildLinesUpdateSettingsalso sets the padding to' 'whenpbrings Powerline into use, but it records nothing and never puts anything back.On the merged branches before the fix, with two lines and Powerline mode off, through
buildLinesUpdateSettings,buildEnabledPowerlineSettingsandbuildDisabledPowerlineSettings:pon,poffpon, (t) on, (t) off,poff" "" """" "" "" "" "" "In the third column, (t) on also remembered the
" "thatphad set, not the padding from before.How
buildLinesUpdateSettingsremembers the padding it replaces when a line brings Powerline into use, and puts it back once no line is Powerline. That coversp, deleting the last Powerline line, and every other line update from the line selector. A padding changed in the meantime is the user's own and stays, as with (t)." "Powerline set. So (t) on with a line already on Powerline keeps what that line remembered instead of recording its" ", andpafter (t) on with every line plain keeps what (t) remembered. A padding changed since is the user's own and is remembered instead. One helper,getPaddingToRestore, decides this for both (t) on andp, andwithPaddingRestoreduses the same check.pstays Powerline when Powerline mode turns off, and without the padding its text would run into its arrows. The remembered padding is kept and comes back when that line goes plain.buildDisabledPowerlineSettingsmoved into a sharedwithPaddingRestored, used by both paths.ptoo.PowerlineSetup.tsximportsisAnyLinePowerlinenext toFontInstallResultandbuildDisabledPowerlineSettings, and keepsgetFontInstallMessageColornext to feat(tui): switch Powerline on or off for each status line #49'sbuildPowerlineSetupMenuItemschange.powerline-settings.tskeepsbuildDisabledPowerlineSettingsandbuildLinesUpdateSettings. fix(renderer): size bars for the mode each line renders in #52 merged without conflicts.Left as is:
pbrings Powerline into use. With Powerline mode on and empty lines that follow it, setting every line that has widgets to plain still leaves a Powerline line, so the padding comes back only when (t) turns Powerline off.ppicks when it brings Powerline into use stays after the last line goes plain, as turning Powerline off keeps the theme.pbefore this change have nothing remembered, so the padding stays" ", as before.Demo
Before is the two merges without the fix, after is this branch. Each recording ends in Global Overrides, where the preview shows the line and the Default Padding row shows the padding.
Powerline. One line, Powerline mode on with Nord Aurora, turned on from a plain line with no padding and a
|separator, so the settings remember no padding.psets the line to plain. Before:Model | Ctx ...and Default Padding" ". After:Model | Ctx ...and(none).Before:
After:
Plain. The plain line with no padding, as on a fresh install, and Powerline mode off.
pputs line 1 on Powerline,pputs it back. Before:Model | Ctx ...and Default Padding" ". After:Model | Ctx ...and(none).Before:
After:
Testing
bun test: 3634 pass, 0 fail (199 files), against 3626 pass, 0 fail on the merges before the fix. 8 new tests, all failing before the fix: 7 inpowerline-settings.test.ts(remembering the padding when the first line turns Powerline, putting it back when the last one turns plain, keeping a changed padding, (t) on and off with a line set to Powerline, a padding changed while that line was Powerline coming back after (t) on and off, andpafter (t) on with every line plain keeping what (t) remembered) and 1 inApp.test.ts(ptwice, then Ctrl+S savesdefaultPadding: ""and nopaddingToRestore). The existing test "stores the lines and their Powerline modes" compares the whole Powerline config, so it now expectspaddingToRestore: ''too.bun run lintis clean.powerline-settings.test.tsandApp.test.ts: 50 passed (42 before the fix).runtime-check.sh: plain and Powerline renders agree under Bun 1.4.2 and Node 26.10.0 and matchmain. The TUI opens and exits cleanly under both.