Skip to content

refactor(sidebar): redesign agents panel to uniform two-line entries#3307

Merged
dgageot merged 3 commits into
docker:mainfrom
dgageot:worktree-board-e071af66343030cd
Jun 30, 2026
Merged

refactor(sidebar): redesign agents panel to uniform two-line entries#3307
dgageot merged 3 commits into
docker:mainfrom
dgageot:worktree-board-e071af66343030cd

Conversation

@dgageot

@dgageot dgageot commented Jun 29, 2026

Copy link
Copy Markdown
Member

The agents panel in the TUI sidebar had two distinct rendering modes: a multi-line "focus card" for the current agent and compact "roster rows" for the others. This asymmetry made the layout shift noticeably when switching agents and required maintaining separate layout computation paths.

This change replaces both modes with a single renderAgentLine that produces a consistent two-line entry for every agent. Line 1 shows the agent name in its accent color, a thinking-effort badge right-aligned in a shared column, and a ^N switch shortcut flush against the right edge. Line 2 shows the provider/model string, indented and left-truncated so the informative tail is always visible. The current agent is marked with ▶ (or the spinner while working); other agents pad the marker column so names stay aligned. Agent descriptions are removed from the sidebar — they remain accessible in the agent-details dialog.

Click zones are updated so both rendered lines of an entry are owned by the agent, while the blank separator lines between entries remain unclickable. The ^N shortcut displayed matches the existing ctrl+1..ctrl+9 keyboard handler.

Removed now-unused helpers — renderAgentCard, renderAgentRow, computeRosterLayout, cardThinkingLine, renderTreeNodes, wrapDescription, ellipsizePlain, rowShortcutCell, rightAlign — and the rosterLayout type. Added small padLeft/padRight/badgeColumnWidth helpers and moved badge-column-width computation into agentInfo so it is derived once rather than per render. Layout constants rowShortcutWidth/rowIndentWidth are replaced by agentMarkerWidth/agentShortcutWidth.

One pre-existing edge case (not a regression): below the MinWidth auto-collapse threshold combined with very long agent names, tab.Render may wrap body lines and misalign click zones.

dgageot added 3 commits June 29, 2026 18:45
Avoids redundant per-agent recomputation; removes the now-unused
agentNameWidth helper; updates stale doc comments.

Assisted-By: claude-sonnet-4-5
…in effort_gauge_test

Assisted-By: docker-agent
@dgageot dgageot requested a review from a team as a code owner June 29, 2026 17:03

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

This refactor replaces the two-mode rendering system (renderAgentCard + renderAgentRow) with a unified renderAgentLine that produces consistent two-line entries for all agents. The new implementation is clean and logically sound.

Width/layout calculations — The nameWidth formula is internally consistent with the right-column formula. The - 1 separator correctly accounts for the literal space between badge and shortcut columns; the gap always resolves to exactly minGap=2. No off-by-one errors.

Left-truncation of model stringsTruncateTextLeft(modelText, max(1, contentWidth-agentMarkerWidth)) correctly limits model text to the available space, producing a total line width equal to contentWidth.

Click zone mapping — The agentLineOwners approach is preserved. buildAgentClickZones correctly applies the tabHeaderLines=2 offset and skips blank owner entries. The updated click tests thoroughly verify the new 2-lines-per-agent layout.

Badge column widthbadgeColumnWidth now includes the current agent (unlike the old computeRosterLayout which skipped it), which is correct since the current agent is now rendered as a regular line.

Marker logic — The spinner/ precedence in the switch is correct: working agents (any) show a spinner; the current non-working agent shows ; all others get blank padding.

No actionable bugs were found in the introduced code.

@aheritier aheritier added area/tui For features/issues/fixes related to the TUI kind/refactor PR refactors code without behavior change labels Jun 29, 2026
@dgageot dgageot merged commit cf07963 into docker:main Jun 30, 2026
10 checks passed
@dgageot dgageot deleted the worktree-board-e071af66343030cd branch June 30, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tui For features/issues/fixes related to the TUI kind/refactor PR refactors code without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants