Skip to content

feat(tui): make the sidebar width configurable - #46117

Open
iceteaSA wants to merge 1 commit into
anomalyco:devfrom
iceteaSA:sidebar-width
Open

feat(tui): make the sidebar width configurable#46117
iceteaSA wants to merge 1 commit into
anomalyco:devfrom
iceteaSA:sidebar-width

Conversation

@iceteaSA

Copy link
Copy Markdown

Issue for this PR

Closes #35513

Type of change

  • New feature

What does this PR do?

Adds a sidebar_width key to the TUI config. 42 stays the default, so nothing changes unless you set it.

The width was hardcoded in two places that had to agree: <box width={42}> in the sidebar component, and the session route's content math (dimensions().width - (sidebarVisible() ? 42 : 0) - 4). Both now read one sidebarWidth() memo. Collapsing that duplication is half the value here — two literals that must stay in sync is where the next layout bug was going to come from.

The resolved width is clamped to max(20, min(configured, terminalWidth - 40, 100)):

  • 20 floor — below this the sidebar content stops being legible
  • terminalWidth - 40 — the main pane keeps at least 40 columns
  • 100 cap

The clamp runs on read rather than only at config load, so shrinking the terminal degrades the sidebar instead of squeezing the main pane. The outer max(20, …) matters on small terminals where the bounds invert (at 55 columns, terminalWidth - 40 is 15, under the floor) — the minimum wins there and the function stays total. That case is unreachable today since terminals at or below 120 columns render the sidebar as an overlay, but the function shouldn't depend on that.

sidebar_width is Schema.Int.check(Schema.isGreaterThan(0)), matching leader_timeout and the prompt size fields, so a fractional or negative value is a config error rather than a fractional column count.

This is deliberately just the config key. A follow-up adds a drag rail, a collapse state, and runtime persistence — kept separate so this part is reviewable on its own.

How did you verify your code works?

  • packages/tui: 199 pass / 0 fail; 6 focused tests on the clamp covering the floor, the terminal-content cap, the hard cap, the inverted-bounds case, and the default
  • bun typecheck clean in packages/tui and packages/opencode
  • Mutation check: making clampSidebarWidth return the raw configured value fails 4 of the 6 focused tests

Screenshots / recordings

No visual change at the default width.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The sidebar width was hardcoded to 42 in two independent places. It is now a single clamped source fed by the sidebar_width config key. The clamp enforces a minimum of 20 for legibility, a terminal-width-derived maximum of terminal width minus 40 to preserve main content, and a hard cap of 100.
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.

feat(tui): add sidebar width configuration option

1 participant