Skip to content

fix(renderer): size bars for the mode each line renders in - #52

Draft
eric-engberg wants to merge 42 commits into
feat/bar-widthfrom
fix/bar-width-per-line
Draft

eric-engberg wants to merge 42 commits into
feat/bar-widthfrom
fix/bar-width-per-line

Conversation

@eric-engberg

@eric-engberg eric-engberg commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

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:

100 columns, fill bar Before After
Powerline on, this line plain sized for Powerline, so the line overflows and is cut: …(2%) | ta... fills to 94: … | tail-text
Powerline off, this line Powerline 4 columns short (90) 94
Auto-align on, a plain line below 67 of 94 94
All Powerline / all plain / auto-align all Powerline 94 / 94 / 94 unchanged

The 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

  • sizeBarsToLines measures each line with getLineSettings and getLineRenderItems, the same calls the piped render and the preview use, and takes auto-align column widths from getAutoAlignLines.
  • A bar's auto-align padding (from feat(widgets): bar style, size and numbers for progress bars #14's getBarColumnPadding) comes from the line's own mode, so a plain line gets none.
  • The measurement advances the separator and start-cap cycles past each line the way the render does, since a cycle can mix one- and two-cell glyphs. This also fixes an all-Powerline multi-line setup with mixed-width separators, which feat(widgets): bar style, size and numbers for progress bars #14 alone could mis-size.

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 ....

Powerline on with line 1 plain, before the fix: line 1 cut off with ...

After: line 1 fills the 94 columns.

Powerline on with line 1 plain, after the fix: line 1 fills the line

Powerline off, line 1 set to Powerline

Before: line 1 ends 4 columns short, at 90.

Powerline off with line 1 Powerline, before the fix: line 1 4 columns short

After: line 1 fills the 94 columns.

Powerline off with line 1 Powerline, after the fix: line 1 fills the line

Testing

  • New tests in 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.
  • Piped renders (CCSTATUSLINE_WIDTH=100) give the table above; the preview, rendered through Ink, gives the same widths.
  • bun run lint clean, bun test 3209 pass, 0 fail. renderer-bar-width.test.ts and 18 related files pass under Node 26 vitest; the built dist/ gives 94 in every scenario under Node 26 and Bun.

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.
…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
…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.
@sonarqubecloud

sonarqubecloud Bot commented Nov 8, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant