Skip to content

add reusable TUI tab bar component#13831

Open
harryalbert wants to merge 5 commits into
harry/code-1822-rich-child-message-renderingfrom
harry/code-1822-tui-tab-bar-component
Open

add reusable TUI tab bar component#13831
harryalbert wants to merge 5 commits into
harry/code-1822-rich-child-message-renderingfrom
harry/code-1822-tui-tab-bar-component

Conversation

@harryalbert

@harryalbert harryalbert commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

Adds TuiTabBar, a retained horizontal tab component for the shared TUI element library. Callers own semantic state—the ordered tabs, selected key, focus, and page anchor—while the component owns stable pointer state, display-cell-aware packing, overflow boundaries, and settled keyboard navigation. It supports an optional fixed main tab, pageable secondary tabs, caller-rendered leading elements, focused/unfocused selection styles, grapheme-safe truncation, semantic click events, and built-in tab/arrow hover affordances.

The main implementation is crates/warpui_core/src/elements/tui/tab_bar.rs. The module documentation at the top of that file is the best entry point: it explains ownership, the per-frame layout flow, how leading elements are measured and reused, how pure paging feeds the rendered row, and why only settled navigation is retained after layout.

Shared terminal-string measurement and grapheme-safe ellipsis logic lives in text_helpers.rs and is reused by both the tab bar and existing TUI column formatting. The tests are intentionally scenario-based rather than one test per field/state.

This PR only introduces the reusable primitive. No user-visible surface consumes it yet; the orchestration integration is in the PR above, so screenshots/video are not applicable here.

Linked Issue

CODE-1822 — Orchestration

Review guide

  • crates/warpui_core/src/elements/tui/tab_bar.rs — main component, retained-state boundary, row construction, paging, navigation, pointer interaction, and top-level architecture documentation.
  • crates/warpui_core/src/elements/tui/text_helpers.rs — shared display-cell width and grapheme-safe truncation.

Testing

  • I have manually tested my changes locally with ./script/run-tui
    No visual changes yet, that'll come in the PR above this one in the stack

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

@harryalbert harryalbert changed the base branch from harry/code-1822-rich-child-message-rendering to graphite-base/13831 July 16, 2026 18:55
@harryalbert harryalbert force-pushed the harry/code-1822-tui-tab-bar-component branch from 061490a to c8ca6af Compare July 16, 2026 20:43
@harryalbert harryalbert changed the base branch from graphite-base/13831 to harry/code-1822-rich-child-message-rendering July 16, 2026 20:43
@harryalbert harryalbert changed the title Add reusable TUI tab bar component specs add reusable TUI tab bar component Jul 16, 2026
@harryalbert harryalbert marked this pull request as ready for review July 16, 2026 20:57
@harryalbert harryalbert requested a review from kevinyang372 July 16, 2026 20:57
@oz-for-oss

oz-for-oss Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@harryalbert

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot 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.

Overview

This PR adds a retained, reusable TUI tab bar component plus shared text-width/truncation helpers and scenario-based tests. The implementation generally follows the intended retained-state and paging model, and I did not find security issues in the changed code.

Concerns

  • Keyboard navigation falls through to the off-page fallback even when there is no valid selected key, so callers can unexpectedly select a visible tab from an unselected or stale-selection state.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

};
return navigation.order.get(target_index).cloned();
}
match direction {

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.

⚠️ [IMPORTANT] selected_is_visible == false also covers selected_key == None or a stale key, so this fallback makes keyboard navigation select the first/last visible tab when there is no current selection. Return None unless the selected key exists in the supplied order, then use the off-page fallback.

Suggested change
match direction {
selected_index?;
match direction {

@harryalbert harryalbert force-pushed the harry/code-1822-rich-child-message-rendering branch from 4835202 to fced1e8 Compare July 16, 2026 22:12
@harryalbert harryalbert force-pushed the harry/code-1822-tui-tab-bar-component branch from ce8145f to 14791bf Compare July 16, 2026 22:12
@harryalbert harryalbert mentioned this pull request Jul 16, 2026
4 tasks

@kevinyang372 kevinyang372 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My feedback is instead of building a dedicated tab bar element, we should have a tab bar view that renders with generic elements

This should be do-able given we have sizing-aware conditional elements implemented in GUI -- we could probably reference that and built it for TUI

harryalbert and others added 5 commits July 16, 2026 19:09
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
@harryalbert harryalbert force-pushed the harry/code-1822-rich-child-message-rendering branch from fced1e8 to 87dd32b Compare July 16, 2026 23:09
@harryalbert harryalbert force-pushed the harry/code-1822-tui-tab-bar-component branch from 14791bf to af903e1 Compare July 16, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants