Repository navigation
fix(renderer): size bars for the mode each line renders in - #52
Draft
eric-engberg wants to merge 42 commits into
Draft
eric-engberg wants to merge 42 commits into
eric-engberg wants to merge 42 commits into
Conversation
Powerline was all or nothing. Now each line can be Powerline or plain: press p in Edit Lines to switch the highlighted line, and the list shows each line's mode once any line is Powerline. Powerline Setup's switch stays the default for lines that haven't been switched, stored as powerline.lineEnabled (true, false, or null to follow the default), so existing configs are unchanged. - A plain line keeps its manual separators and draws its widgets in their own text colors, without the Powerline backgrounds. In plain mode, backgrounds set by hand still show. - Align Widgets, Continue Theme and the start/end caps run across the Powerline lines only. The CLI and the TUI preview advance their separator, theme and cap counters through one helper, which skips plain lines. - The line editor and Edit Colors see the selected line's own mode: a plain line under Powerline has no separator warning and no exclude align key, and a Powerline theme no longer blocks a plain line's colors. - Global Overrides keeps the separator and background options while any line is plain, and turning Powerline on removes manual separators only from the lines it applies to. - A line's mode moves and is deleted with it in the line selector.
Moving a line up or down was two copies of the same swap; one moveSelectedLine(direction) now does both, wrapping past either end, and carries the line's Powerline mode with it. The help text and the row labels are built by small functions instead of nested conditionals in the JSX.
Customize copied the theme's colors into every line, plain ones included. A plain line draws no theme colors, so this changed its text colors (and stored Powerline backgrounds it doesn't draw). It now keeps its own.
…olors - Powerline Setup greyed out separators, caps, themes, Align Widgets and Continue Theme while the global switch was off, even with a line switched to Powerline in Edit Lines. They're now offered while any line is Powerline. - Edit Colors offered and showed backgrounds on a line set to plain while Powerline is on, which doesn't draw them. It now leaves backgrounds out there and says why.
The line selector's settings were optional, and without them a line edit reported only the lines, which App stores with no per-line modes: every line's Powerline/plain switch was wiped. App always passes settings, so it never happened, but nothing enforced it. Settings are now required and every edit reports the modes along with the lines.
…e import A merge import overlays the imported top-level settings on the current ones, but powerline.lineEnabled is indexed by line, so it went with the powerline section rather than with the lines it was set for: - A file with lines but no powerline section kept the current modes, so the imported lines took over the old lines' Powerline/plain switches: a line set to plain in the current config made the imported line in its place plain too. - A file with a powerline section but no lines kept the current lines but replaced their modes: with the file's lineEnabled, set for its own lines, or with none, which wiped every line's switch. The modes now follow whichever side the lines come from. Kept lines keep their modes while the rest of the imported Powerline settings apply, and imported lines bring the file's modes or, without them, follow the Powerline switch. Replace All takes everything from the import and is unchanged. The import preview is built from the same merge, so it shows the result.
…x/bar-width-per-line # Conflicts: # src/tui/components/ColorMenu.tsx # src/tui/components/LineSelector.tsx # src/tui/components/PowerlineSetup.tsx # src/tui/components/PowerlineThemeSelector.tsx # src/tui/components/__tests__/ColorMenu.test.tsx
With per-line Powerline, a fill or percentage bar was sized for the wrong
line. Sizing measured every line with the global Powerline switch and the
line's widgets as configured, and took auto-align column widths from all
lines. The line then rendered in its own mode, with auto-align columns
taken from Powerline lines only. On a 100-column terminal:
- With Powerline on and the bar's line set to plain, the bar was sized
for Powerline's 1-column separators and the line drew " | " ones, so it
overflowed and was truncated ("... (2%) | ta...").
- With Powerline off and the bar's line set to Powerline, the line ended
4 columns short.
- Under auto-align, a plain line's wide first widget padded the bar's
column in the measurement but not in the render, so a fill bar stopped
at 67 of 94 columns.
The TUI preview sizes bars with the same code and showed the same lines.
Each line is now measured as it renders: with its own settings and
widgets, with auto-align columns from Powerline lines only, and from where
it starts in the separator and start cap cycles, which a plain line
doesn't advance. Those cycles can mix widths, so a line that starts at a
different place measures differently. A plain line's bar gets no
auto-align padding. Lines all in one mode size as before.
…here Move mode swapped the highlighted line with its neighbour, and past either end with the line at the other end, so a wrap moved a second line the user never touched: moving line 1 up put line 3 first. The line now moves past its neighbour, and past either end it goes to the other end while the rest keep their order. Each line's Powerline mode moves with it the same way.
…x/bar-width-per-line
…e carries it on The renderer gives a plain line no theme colors and doesn't count it when the theme continues across lines, so the copy mustn't either.
# Conflicts: # src/tui/components/LineSelector.tsx # src/tui/components/PowerlineThemeSelector.tsx # src/tui/components/__tests__/ColorMenu.test.tsx # src/tui/components/__tests__/LineSelector.test.ts # src/tui/components/__tests__/PowerlineThemeSelector.test.ts
# Conflicts: # src/tui/components/__tests__/ColorMenu.test.tsx
# Conflicts: # src/tui/components/StatusLinePreview.tsx
…th-per-line # Conflicts: # src/tui/components/StatusLinePreview.tsx
…x/bar-width-per-line
…lear A line set to plain while Powerline is on doesn't draw its widgets' backgrounds, and Edit Colors hides them there and blocks (f): they are the Powerline colors the line gets back when it is Powerline again. But (r)eset and (c)lear all still deleted them along with the foreground, bold and dim the menu does show. Nothing on screen changed, and the segments came back without their backgrounds once the line went back to Powerline. Reset and clear all now keep backgrounds on a line that doesn't show them, and still clear them everywhere else.
…ee the line Edit Colors blocks a Powerline line under a Powerline theme, and its warning always suggested disabling Powerline mode. A line set to Powerline with (p) in Edit Lines stays Powerline whatever that switch says, so for such a line the advice was a dead end: with Powerline mode already off there was nothing to disable, and pressing (t) there turned every other line Powerline too. The warning now suggests disabling Powerline mode only where that frees the line picked (or, with every line Powerline, some line), and otherwise suggests setting the line to plain with (p) in Edit Lines.
… Powerline Turning Powerline on in Powerline Setup sets one space of padding, and the default theme when none was picked. Switching a line to Powerline with (p) in Edit Lines only stored the line's mode, so on a config that never had Powerline on the line had neither: its segments had no backgrounds, its arrows were drawn in the terminal's default colors, and its text ran straight into them, in the preview and the saved status line alike. When a line switched in Edit Lines brings Powerline into use, it now gets the padding that switch sets, and the default theme the switch picks if no theme was ever picked. A theme the user picked, Custom included, stays. The padding is global, so plain lines are padded too, as they already are after turning Powerline on and off again.
# Conflicts: # src/utils/__tests__/renderer-bar-width.test.ts # src/utils/renderer.ts
# Conflicts: # src/ccstatusline.ts # src/tui/__tests__/App.test.ts # src/utils/powerline-settings.ts
…eps them Turning Powerline on no longer removes manual separators from any line (main's sirmalloc#713), so the per-line exception for plain lines has nothing left to do. Remove its test, which called the old two-argument buildEnabledPowerlineSettings, and the docs line saying Powerline removes separators from the lines it applies to. A plain line shows its separators; a Powerline line keeps them but doesn't draw them.
# Conflicts: # src/ccstatusline.ts # src/tui/__tests__/App.test.ts # src/utils/powerline-settings.ts
eric-engberg
added a commit
that referenced
this pull request
Oct 30, 2026
Brings in upstream main through #129. Files where main met the #49 and #52 code this branch holds take the resolutions those branches made. Turning Powerline on no longer removes manual separators (main's sirmalloc#713), so buildEnabledPowerlineSettings takes only the settings again: this branch's padding tests call it that way, and the per-line separator removal test goes, as it did on #49. # Conflicts: # docs/USAGE.md # src/ccstatusline.ts # src/tui/App.tsx # src/tui/__tests__/App-dev-reload.test.ts # src/tui/__tests__/App.test.ts # src/tui/components/ItemsEditor.tsx # src/tui/components/__tests__/ItemsEditor.test.ts # src/utils/__tests__/powerline-settings.test.ts # src/utils/powerline-settings.ts # src/utils/renderer.ts # src/widgets/SessionUsage.ts # src/widgets/__tests__/ThinkingEffort.test.ts # src/widgets/shared/usage-display.ts # src/widgets/shared/usage-percent-widget.ts
# Conflicts: # src/tui/components/ColorMenu.tsx # src/tui/components/__tests__/PowerlineSetup.test.ts
# Conflicts: # src/tui/components/__tests__/PowerlineSetup.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 #14 (
feat/bar-width) and merges #49 (feat/powerline-per-line). The fix is the last commit; everything before it is those two PRs. Whichever of #14 and #49 goes upstream second carries it.What
A Context Bar (or any bar) set to fill or a percentage width now fills its line correctly when that line's Powerline mode differs from the global setting:
…(2%) | ta...… | tail-textThe TUI preview showed the same wrong widths, and now matches too.
Why
#14 sizes bars before the final render by measuring each line. It measured with the global settings, every line's widgets, and auto-align columns taken from all lines. With #49, each line renders in its own mode: a plain line has 3-cell
|separators where Powerline has 1-cell arrows, and auto-align only lines up Powerline lines. So on a mixed config the measurement and the render disagreed.How
sizeBarsToLinesmeasures each line withgetLineSettingsandgetLineRenderItems, the same calls the piped render and the preview use, and takes auto-align column widths fromgetAutoAlignLines.getBarColumnPadding) comes from the line's own mode, so a plain line gets none.Demo
Fix: bars sized for each line's mode
Piped at
CCSTATUSLINE_WIDTH=100, where flex mode full leaves a 94-column line (the dim ruler). Each still has two lines with the same widgets: line 1, with a fill Context Bar, is set to the other mode from the global setting, and line 2 follows the global setting as a control. Since the point is mixed lines, the two stills are global Powerline on and off rather than the usual Powerline and plain. The payload is sample data.Powerline on, line 1 set to plain
Before: line 1 is sized for Powerline's 1-column separators, so it overflows and is cut off with
....After: line 1 fills the 94 columns.
Powerline off, line 1 set to Powerline
Before: line 1 ends 4 columns short, at 90.
After: line 1 fills the 94 columns.
Testing
renderer-bar-width.test.ts: Powerline on with a plain line; Powerline off with a Powerline line; auto-align with a plain line below; separator and start-cap cycles past a plain line with mixed-width glyphs; and an all-plain / all-Powerline control. The first four failed before the fix; the control passed before and after.CCSTATUSLINE_WIDTH=100) give the table above; the preview, rendered through Ink, gives the same widths.bun run lintclean,bun test3209 pass, 0 fail.renderer-bar-width.test.tsand 18 related files pass under Node 26 vitest; the builtdist/gives 94 in every scenario under Node 26 and Bun.