Skip to content

fix: align session status tags in their own column - #332

Merged
kbwo merged 1 commit into
mainfrom
fix/align-status-display
Sep 2, 2026
Merged

fix: align session status tags in their own column#332
kbwo merged 1 commit into
mainfrom
fix/align-status-display

Conversation

@kbwo

@kbwo kbwo commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Problem

The session state tag ([○ Idle], [● Busy], …) was appended directly to the branch name, so it started at a different horizontal position on every row. Scanning the list for a session's state meant reading each row's tag at wherever the branch name happened to end.

Approach

Give the state tag its own column, placed directly left of the last-commit date (1d ago), so every row's tag starts at the same position.

The extra column widens each row, and narrow terminals cannot always afford it. So the layout is chosen per list: the caller passes the number of columns a row label may occupy, and when the aligned layout does not fit, the layout falls back to the previous behavior of appending the tag to the name.

Aligned (wide enough):

❯ main (main)                             +12 -3    ↑2    origin/main    [○ Idle]     1d ago
❯ fix/align-status-display                +1 -1                          [● Busy]     2h ago
❯ feature/a-much-longer-branch-name: lab            ↓4    main           [◐ Waiting]  3w ago

Fallback (too narrow for the column):

❯ main (main) [○ Idle]                                +12 -3    ↑2    origin/main    1d ago
❯ fix/align-status-display [● Busy]                   +1 -1                          2h ago

The tag is left-aligned within its column so the state icons (○ ● ◐) line up vertically, which is what the eye scans for.

Changes

  • src/utils/worktreeUtils.ts: SessionItem carries the state tag in a new status field instead of inside baseLabel; calculateColumnPositions gained the status column, an optional available-width argument, and an alignStatus flag reporting which layout it picked; assembleSessionLabel renders accordingly. Rows showing a git error keep the tag next to the name, since those rows have no columns at all.
  • src/hooks/useAvailableLabelWidth.ts (new): terminal width minus the per-row prefix (the SelectInput indicator plus the number prefix), used as that available-width argument.
  • src/components/Menu.tsx, src/components/Dashboard.tsx: supply the width from the new hook. Dashboard builds SessionItem values by hand as well, so it was updated to the same convention rather than leaving two meanings for one type.

Verification

  • bun run lint, bun run typecheck: clean.
  • bun run test: 1861 passed. The 6 failing files are the pre-existing submodule suites, which fail in beforeAll on git config --global protocol.file.allow always (could not lock config file /Users/…/.gitconfig: Operation not permitted) in this sandboxed environment — unrelated to this change.
  • New tests in src/utils/worktreeUtils.test.ts cover the aligned column position, the narrow-terminal fallback, and the git-error row.

🤖 Generated with Claude Code

The session state tag (e.g. "[○ Idle]") was appended to the branch name,
so it started at a different horizontal position on every row and was
hard to scan. Give it its own column, placed directly left of the last
commit date, so every row's tag starts at the same position.

Because the extra column widens each row, calculateColumnPositions now
takes the number of columns the label may occupy and falls back to the
previous name-appended layout when the aligned one would not fit. Menu
and Dashboard supply that width from the terminal size via the new
useAvailableLabelWidth hook.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jf1jf3ZqsXZtMAwwkTkPEc
@kbwo
kbwo merged commit 082fe2e into main Sep 2, 2026
1 check passed
@kbwo
kbwo deleted the fix/align-status-display branch September 2, 2026 14:06
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