feat: optionally show the hostname in the desktop tab bar - #2562
Conversation
Add ui.tab_bar_hostname to display the machine's hostname at the right edge of the tab row, like tmux's #h in status-right. The value resolves where the server renders, so remote sessions show the remote host. Off by default.
📝 WalkthroughWalkthroughThe change adds the ChangesHostname tab bar display
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Configuration
participant App
participant Platform
participant AppState
participant TabBar
Configuration->>App: tab_bar_hostname setting
App->>Platform: resolve hostname when enabled
Platform-->>App: optional hostname
App->>AppState: update tab_bar_hostname
AppState->>TabBar: provide hostname and tab-bar bounds
TabBar->>TabBar: reserve hostname area and render tabs
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b89b1741-397b-4e08-af05-3122e5e5f9b6
📒 Files selected for processing (10)
docs/next/CHANGELOG.mddocs/next/website/src/data/config-reference.jsonsrc/app/actions.rssrc/app/mod.rssrc/app/state.rssrc/config/model.rssrc/main.rssrc/platform/mod.rssrc/ui.rssrc/ui/tabs.rs
Greptile SummaryThe PR adds an opt-in hostname label to the desktop tab bar, resolves it at startup and config reload, and reserves tab-layout space for it. The follow-up minimum-width guard still undercounts the controls used by an overflowing mouse-enabled tab bar.
Confidence Score: 4/5The PR is not yet safe to merge because the hostname guard can still shrink an overflowing tab below the usable minimum it is intended to preserve. In the overflow layout, the accepted 14-column content area must hold two three-column scroll controls, a three-column new-tab control, and a tab, leaving only five columns for that tab; the guard must account for the left scroll control before the fix is complete. Files Needing Attention: src/ui/tabs.rs
|
| Filename | Overview |
|---|---|
| src/ui/tabs.rs | Adds hostname rendering and reservation, but the overflow threshold omits the left scroll button and can compress the visible tab below its declared minimum. |
| src/ui.rs | Applies the hostname-adjusted content area consistently when computing desktop tab geometry. |
| src/app/actions.rs | Uses the same adjusted content area when refreshing tab hit regions after mutations. |
| src/app/mod.rs | Resolves and updates the optional hostname during initialization and valid UI config reloads. |
| src/platform/mod.rs | Adds platform-specific hostname resolution for Unix, Windows, and unsupported targets. |
| src/config/model.rs | Adds the opt-in UI configuration field with a false default. |
Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." | Re-trigger Greptile
…ostname # Conflicts: # docs/next/CHANGELOG.md
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bb6cd73e-1f5c-421f-bda0-3dd3600cb150
📒 Files selected for processing (5)
docs/next/CHANGELOG.mddocs/next/website/src/data/config-reference.jsonsrc/config/model.rssrc/main.rssrc/ui/tabs.rs
🚧 Files skipped from review as they are similar to previous changes (4)
- docs/next/website/src/data/config-reference.json
- docs/next/CHANGELOG.md
- src/main.rs
- src/config/model.rs
| // The narrowest tab strip worth keeping interactive: one minimum-width tab | ||
| // plus the trailing controls. Decorations yield below this. | ||
| const MIN_TAB_STRIP_WIDTH: u16 = MIN_TAB_WIDTH + NEW_TAB_WIDTH + TAB_SCROLL_BUTTON_WIDTH; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Reserve both scroll buttons in MIN_TAB_STRIP_WIDTH.
Line 17 includes only one TAB_SCROLL_BUTTON_WIDTH. In overflow mode, compute_tab_bar_view() uses a left scroll button and reserves a right scroll button with the new-tab control. A hostname can therefore remain visible while the tab area becomes narrower than MIN_TAB_WIDTH.
Include both scroll buttons. Add a regression test that forces overflow at this boundary.
Proposed fix
-const MIN_TAB_STRIP_WIDTH: u16 = MIN_TAB_WIDTH + NEW_TAB_WIDTH + TAB_SCROLL_BUTTON_WIDTH;
+const MIN_TAB_STRIP_WIDTH: u16 =
+ MIN_TAB_WIDTH + NEW_TAB_WIDTH + (TAB_SCROLL_BUTTON_WIDTH * 2);| const TAB_SCROLL_BUTTON_WIDTH: u16 = 3; | ||
| // The narrowest tab strip worth keeping interactive: one minimum-width tab | ||
| // plus the trailing controls. Decorations yield below this. | ||
| const MIN_TAB_STRIP_WIDTH: u16 = MIN_TAB_WIDTH + NEW_TAB_WIDTH + TAB_SCROLL_BUTTON_WIDTH; |
There was a problem hiding this comment.
Hostname undercounts overflow controls
When mouse capture is enabled and tabs overflow with 14–16 columns remaining after hostname reservation, the threshold omits the left scroll button, causing the visible tab to shrink to 5–7 columns instead of preserving its eight-column minimum.
| const MIN_TAB_STRIP_WIDTH: u16 = MIN_TAB_WIDTH + NEW_TAB_WIDTH + TAB_SCROLL_BUTTON_WIDTH; | |
| const MIN_TAB_STRIP_WIDTH: u16 = | |
| MIN_TAB_WIDTH + NEW_TAB_WIDTH + TAB_SCROLL_BUTTON_WIDTH + TAB_SCROLL_BUTTON_WIDTH; |
|
superseded by #2586 with the new |
Summary
ui.tab_bar_hostname(defaultfalse) that shows the machine hostname at the right edge of the desktop tab bar, in the inactive-tab text color — tmux's#hin status-rightherdr --remote user@hostshows the remote machine's name, which is the identity that matters when you're juggling local and remote sessionscompute_tab_bar_view's callers, so tabs, trailing controls, and the overflow ellipsis never render underneath the labellibc::gethostnameon unix (libc is already a direct dependency),COMPUTERNAMEon Windows,Noneon other targets, following thesrc/platform/house patternConfiguration
Testing
cargo fmt --check, fullcargo testsuite, andscripts/config_reference_check.pypass locally