Skip to content

feat(tui): collapse the sidebar from its version row - #481

Merged
dimetron merged 3 commits into
mainfrom
feat/sidebar-toggle
Nov 17, 2026
Merged

dimetron merged 3 commits into
mainfrom
feat/sidebar-toggle

Conversation

@dimetron

Copy link
Copy Markdown
Owner

What

The sidebar's version row gets a collapse control: click » and the 28-column
panel becomes a one-column strip carrying ‹; click the strip and it comes back.
The chat takes the columns immediately, with the transcript re-wrapped for the
new width rather than waiting for the next resize.

Also widens the sidebar 23 → 28, and bundles a rex-hunk-diff skill.

Why the width change is in the same PR

At 23 columns the branch row read ⎇ feat/sidebar-… — cut exactly where it says
which work is in progress. 28 leaves a 19-character branch name whole, which
covers this repo's feat/<topic> and fix/<topic> names. It costs the chat 5
of 160 columns.

Both changes are about the same trade: what the sidebar's columns are worth. A
collapse control is the answer when the user wants all of them back; a wider
panel is the answer when they want the labels legible.

Design notes

sidebarCollapsed is a preference, not a layout fact. sidebarWidth()
returns SidebarWidth expanded, SidebarStripWidth collapsed, and 0 when the
frame is too narrow to hold either. So restoring the preference on a 70-column
terminal does not force a sidebar into a frame that cannot take one, and a
collapse request there leaves the layout alone. mainWidth derives from
sidebarWidth, so there is one place the frame's widths come from.

The glyphs are width-safe. » and ‹ are Neutral in every width table and
one cell wide. An ambiguous-width glyph would be drawn two cells wide by a
terminal configured that way, shifting the rail and the chat a column left at the
exact moment the panel was collapsed.

The version keeps its whole string. The first attempt placed the glyph within
innerW and truncated pi-go 1.4.2+a1b2c3d to pi-go 1.4.2+a1b2c… — spending
the diagnostic the row is topmost to show on a button. The glyph now sits in the
panel's own right-hand padding, outside innerW.

Hit targets are whole rows. The expanded target is the version row, not the
glyph cell; the collapsed target is the strip's full height. Neither can overlap
the chat: both require a column at or past the chat panel's right edge.

The skill

internal/extension/bundled_skills/rex-hunk-diff documents opening a live Hunk
diff in a pane beside the agent. Two things it records because the first attempt
failed on them:

  • rex split --split=left is relative to the anchor block's position, so it
    lands on the wrong side as readily as the right one. Placement is
    rex move BLOCK DIRECTION ANCHOR.
  • com.superlogical.terminal.resize takes one JSON object, not
    block_id=… args=….

It is bundled rather than added to .claude/skills/ because **/.claude/ is
gitignored in this environment — a skill written there dies with the worktree.

Verification

Check Result
go build ./... ✅
go test ./internal/tui ./internal/extension ✅
make lint ✅ 0 issues
make vet ✅ clean

Guards were seen red before green:

  • disabling hitSidebarToggle in the click dispatcher → the click test fails
  • making mainWidth ignore the collapsed width → the width and frame-integrity tests fail
  • removing the bundled skill → TestBundledSkillsRegistered fails
  • a 5-character description → TestBundledSkillsCarryADescription fails

Not verified visually: the » in a live 81+ column terminal. The rex window
used for testing caps panes at ~80 columns and pi needs >80 for the sidebar, so
the glyph and the untruncated branch were confirmed through RenderSidebar and
a test frame, against the real binary but not a real wide terminal.

The sidebar is a fixed 28 columns of short labels. On a narrow terminal
those columns are worth more to the chat, so the version row now carries a
collapse glyph on its right edge, and the collapsed panel leaves a
one-column strip with a restore glyph.

The two glyphs are » and ‹: both Neutral in every width table and one cell
wide, so a terminal that resolves ambiguous width as wide cannot re-measure
them and shift the rail out of its column.

sidebarCollapsed is a preference, not a layout fact. sidebarWidth still
returns 0 on a frame too narrow to hold the panel, so restoring the
preference does not force a sidebar into a frame that cannot take one, and
a collapse request there leaves the layout as it was.

The version row keeps its whole string: the glyph goes in the panel's own
right-hand padding rather than out of the label's budget. Aiming it at
innerW truncated pi-go 1.4.2+a1b2c3d to pi-go 1.4.2+a1b2c… — losing exactly
the diagnostic that row is topmost to show.

Signed-off-by: pi <dimetron@me.com>
rex owns the terminal layout and hunk draws the diff; neither calls the
other. The skill records the sequence that actually places a pane where it
was asked for: split with --keep-open --focus=false -c $PWD --json, then
rex move BLOCK DIRECTION ANCHOR. --split=left alone is relative to the
anchor block's position, so it lands on the wrong side as readily as the
right one.

Also records the traps: hunk diff is a full-screen TUI and must never run
in the agent's own shell, and an api call takes one JSON object, not
block_id=/args= flags.

The registry test asserts every bundled skill is embedded and carries a
description long enough to be actionable — an empty one registers a skill
nothing will load.

Signed-off-by: pi <dimetron@me.com>
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.50%. Comparing base (8db35a1) to head (780e471).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #481      +/-   ##
==========================================
- Coverage   91.50%   91.50%   -0.01%     
==========================================
  Files         394      394              
  Lines       50610    50649      +39     
==========================================
+ Hits        46313    46345      +32     
- Misses       4291     4298       +7     
  Partials        6        6              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov/patch flagged two lines: the guard against a click above the frame,
and the width floor where collapsing is refused.

The above-the-frame case only proves anything in the collapsed state. The
strip's hit test is `row < topSectionRows`, and a negative row satisfies it,
so without the guard a click in the scrollback just above a collapsed strip
restores the panel. The expanded test is `row == 0`, which rejects -1 by
accident — a first attempt at this test passed with the guard deleted, so
it was asserting nothing.

Signed-off-by: pi <dimetron@me.com>
@dimetron

Copy link
Copy Markdown
Owner Author

govulncheck

Go: go1.27.4 Scanner: govulncheck@v1.9.0 

make vulncheck — gate passes.

9 findings, all in github.com/ollama/ollama, none with a fixed version released:

ID Module
GO-2025-3557 github.com/ollama/ollama
GO-2025-3558 github.com/ollama/ollama
GO-2025-3559 github.com/ollama/ollama
GO-2025-3582 github.com/ollama/ollama
GO-2025-3689 github.com/ollama/ollama
GO-2025-3695 github.com/ollama/ollama
GO-2025-3824 github.com/ollama/ollama
GO-2025-4251 github.com/ollama/ollama
GO-2026-5750 github.com/ollama/ollama

This PR adds no dependencies — it touches internal/tui and adds a bundled
skill markdown file — so none of these originate here. They are reported rather
than failing because there is nothing to upgrade to; the gate is deliberately
narrow so that a red result always means there is something to do.

@dimetron
dimetron merged commit cdb4736 into main Nov 17, 2026
24 of 26 checks passed
dimetron added a commit that referenced this pull request Nov 17, 2026
The sidebar had three ways to disappear after #479 and #481 merged: a frame
at or below 80 columns dropped it outright, a portrait frame dropped it
outright, and the version-row toggle collapsed it to a strip. Two of those
left no control behind, so on exactly the frames that needed the columns
back the sidebar became a one-way trip — no strip, no glyph, nothing to
click.

They are now one rule with one output. sidebarFits answers whether this
frame can afford SidebarWidth columns: too narrow for the chat beside it,
or portrait, and it cannot. sidebarWidth turns that plus the user's toggle
into a width — SidebarWidth or the one-column strip — and never returns 0.
The strip is one column, which every frame that can draw a chat can seat,
so the sidebar is never absent, only wide or narrow, and the control that
undoes a collapse is always on screen.

The rule fires on resize and is a pure function of the frame, not a stored
"already applied" flag. A cached flag would be one edit away from going
stale, and a stale one shows the expanded panel on a phone. sidebarExpanded
carries the one piece of state a render cannot re-derive: the user clicking
the strip on a small frame to expand it, which the rule would otherwise
undo on the very next frame. A resize clears it, which is the moment the
user is asking for the layout to be decided again.

The toggle now flips the visible state rather than the preference flag. On
a small frame the strip is up because the rule collapsed it, with the flag
still false — flipping only the flag there left the strip up and the
control apparently dead.

Five tests encoded the old hide-it contract (mainWidth at 60 columns, the
symmetric-gap row helper, the absent-strip case, and the width floor) and
were updated to the new one.

Signed-off-by: pi <dimetron@me.com>
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