cmux NEXT: terminal tab titles follow shell cwd after cd

Merged
TE
7d ago
+65-8

Defect

Demo owner's words:

"Two terminal tabs in one workspace are both titled "Terminal" / "~"."

Dry-run runbook:

"Two terminal tabs in one workspace are both titled "Terminal" in the sidebar and "~" in the tab strip, even after cd into the repo."

Root cause

The shell's ~ title is nonempty, so the tab-strip mapper skipped its existing working-directory fallback and displayed ~. The sidebar's existing clean-name rule then intentionally rendered a cwd-derived bare folder title as the localized Terminal fallback.

Fix

Share the existing bare-shell title rule with tab-strip mapping. Bare shell titles, including ~, now use the terminal's reported cwd for the existing tab title source. The sidebar keeps non-home cwd-derived titles visible instead of collapsing them to Terminal, so sibling terminals in different folders remain distinguishable. User tab names and all other program titles keep their existing precedence.

The existing SidebarTabLineMappingTests expectation that /srv/lane should become Terminal encoded the behavior causing this defect, so it now asserts the cwd-derived title remains the row name and differs from the sibling folder.

Risk

Small title-source mapping change for terminal tabs. It only affects bare shell titles and cwd-derived sidebar rows; title-setting defaults and user names are unchanged.

Tests

  • TerminalTitleTabItemTests.aDefaultShellTitleUsesTheReportedFolder uses a nonempty zsh title and therefore fails on the base implementation (which returns zsh) and passes with this fix.
  • TerminalTitleTabItemTests.aBareShellTitleUsesTheReportedFolder covers the ~ defect case.
  • SidebarTabLineTests covers distinct cwd-derived names and the corrected mapping expectation.
  • Fleet Swift suites passed at the prior head: CmuxNextAppTests.TerminalTitleTabItemTests, CmuxNextAppTests.SidebarTabLineTests. This capture-only head changes no Swift sources.

Before / After

Before (2x light): https://raw.githubusercontent.com/manaflow-ai/cmux/pr-media/28059/cdc2-before-light.png
After (2x light): https://raw.githubusercontent.com/manaflow-ai/cmux/pr-media/28059/cdc2-after-light.png
Viewed after image: yes
Visual verdict: The after capture shows the terminal tab titles with their working-directory labels, making the two tabs distinguishable in the sidebar and tab strip.

Capture steps: scripts/cmux-next/media/states/capture-terminal-tab-titles.json create and focus one named workspace, open its second terminal tab, type cd /tmp/cmux-demo-board, press a real enter key, wait two seconds, then record the sidebar rows and tab strip.

Agent session: agent session