Skip to content

feat(tab-bar): add fit tab width mode and max tab width setting - #48482

Open
huutrungle2001 wants to merge 1 commit into
stablyai:mainfrom
huutrungle2001:feat/fit-tab-width
Open

huutrungle2001 wants to merge 1 commit into
stablyai:mainfrom
huutrungle2001:feat/fit-tab-width

Conversation

@huutrungle2001

Copy link
Copy Markdown

ELI5

Adds a Tab width setting (Default | Fit) and a Max tab width setting (140–480 px, default 300 px) under Settings → General → Tabs.

  • Default keeps Orca's exact current behavior (zero change for existing users).
  • Fit lets every tab — including terminal and agent tabs — shrink to fit its title instead of reserving 300 px of empty space, while still capping long prompt titles with ... at Max tab width and scrolling horizontally on overflow.

What Changed

Before

  • Terminal and agent tabs were always w-[300px] max-w-[300px] min-w-[80px] flex-auto, leaving large empty gaps on short tab names (hub, api, ui) and condensing inactive tabs into 32 px icon-only slots once width / count < 80px.
  • The 300 px max width was hard-coded across tab width rules and the inline rename slot.

After

  • Persisted settings & normalization (src/shared/workspace-layout/tab-groups/tab-width-settings.ts, composed into GlobalSettingsBase, defaulted in default-global-settings.ts, normalized on profile load in normalize-loaded-global-settings.ts):
    • tabWidthMode: 'default' | 'fit' (defaults to 'default')
    • tabMaxWidth: clamped integer in 140..480 px (defaults to 300)
  • Static CSS-variable width rules (tab-width-rules.ts, use-tab-strip-slot-props.ts):
    • Parameterized max-width through --tab-max-width (defaulting to 300px) for default, fit, condensed active slots, and inline rename (has-[[data-tab-rename-input]]:w-[var(--tab-max-width,300px)]).
    • Added FIT_TAB_CONTAINER_WIDTH_CLASSES (w-max max-w-[var(--tab-max-width,300px)] min-w-[80px] flex-none [&>*]:max-w-[var(--tab-max-width,300px)]), preserving Orca's existing min-w-[80px] floor.
  • Clean horizontal overflow in Fit mode (TabBar.tsx, use-tab-strip-condense.ts):
    • When tabWidthMode === 'fit', useTabStripCondense is disabled so tabs are not crushed into 32 px icons or hidden behind +N; instead the strip uses its existing horizontal scroll container, edge fades, scroll indicator, and left/right scroll chevrons when overflowing.
  • Forked tabs in w-max slots (SortableTab.tsx):
    • @container/tab (container-type: inline-size) collapses an intrinsically sized w-max slot down to min-w-[80px]. In fit (or content) sizing, SortableTab omits @container/tab and passes narrowIcon={false} to ForkMarkedName, so forked tabs fit Fork · <title> cleanly up to --tab-max-width.
  • Settings UI, search & i18n (TabWidthSettings.tsx, GeneralPane.tsx, general-search.ts, en.json):
    • Added Tab width (SettingsSegmentedControl) and Max tab width (NumberField) rows inside General → Tabs, wired into Settings search and en.json.

Why

Terminal and agent tabs frequently carry either very short custom names (hub, api, ui) or long unedited prompt titles. A two-option Default | Fit mode paired with Max tab width directly solves the wasted strip space without introducing four overlapping VS Code sizing modes or a redundant min-width control:

  • Keeping a max-width cap in Fit mode prevents a single long agent prompt tab from monopolizing the entire strip, while TabHoverCard still reveals the full title on hover.
  • Keeping default + 300px as defaults guarantees zero visual or behavioral change unless the user opts in.

Linked Issue

Fixes #33867
Refs #40227

Visual Proof

Verified in both dark and light themes via isolated headless Chromium component fixtures (pnpm fixtures:shot):

ORCA_BACKGROUND_LAUNCH=1 pnpm fixtures:shot \
  tab-bar/TabBarWidthMode \
  tab-bar/terminal-tabs/ForkedChatTab:fitWidth \
  tab-bar/terminal-tabs/ForkedChatTab:defaultWidth \
  tab-bar/terminal-tabs/ForkedChatTab:narrow \
  settings/general/TabWidthSettings:fitSelected \
  --theme both --scale 2

Observed rendered behavior (both light and dark):

  • Before (defaultShortAndLong, 1100 px): hub, api, ui, Codex Chat, and the long prompt tab share equal ~210 px slots with large empty padding on short names.
  • After (fitShortAndLong, 1100 px): hub, api, and ui sit cleanly at 80px (full icon + title + close button), Codex Chat hugs its text, the long prompt truncates cleanly at 300px with ..., and + sits immediately beside the last tab.
  • Custom cap (fitCustomMaxWidth, tabMaxWidth: 200): short tabs stay fitted while the long prompt caps cleanly at 200px.
  • Overflow (fitOverflowing, 420 px with 8 tabs): tabs stay readable at their fitted widths (no condense-plan collapse to 32 px icons) with horizontal scroll chevrons and edge fade masks.
  • Inline rename (fitRenaming): double-clicking hub widens the slot from 80px to 300px (var(--tab-max-width)) for comfortable editing (asserted in fixture interact).
  • Forked tabs (ForkedChatTab:fitWidth): verified DOM widths — hub = 80px, Fork · api > 80px, Fork · Annotate capabilities fits snugly between 150px and 280px (no @container/tab collapse), and a long forked prompt caps at 300px.
  • Settings UI (TabWidthSettings:fitSelected): matches SettingsGroup, SettingsSegmentedControl, and NumberField density and tokens in light and dark modes.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

Commands run (macOS arm64):

  • pnpm test src/shared/workspace-layout/tab-groups/tab-width-settings.test.ts src/renderer/src/components/tab-bar/strip/use-tab-strip-condense.test.tsx --maxWorkers=2 — passed (2 files, 5 tests).
  • ORCA_BACKGROUND_LAUNCH=1 pnpm fixtures:shot ... --theme both --scale 2 — passed (all 18 + 5 shots, 0 page/console errors, including runtime DOM width assertions for rename expansion and forked fit tabs).
  • ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed — 42/42 checks passed in 98.1s (format, oxlint, changed-code quality, all 4 typecheck projects, affected unit tests, compiled :has() restyle scope, localization catalogs/coverage/extraction, dead design-system classes, and all ratchets).

Unit tests are intentionally limited to the pure persisted-setting normalizer (tab-width-settings.test.ts); UI layout and interaction are verified via component fixtures per AGENTS.md.

Performance

None, because tabWidthMode and tabMaxWidth are primitive Zustand selectors (only re-rendering tabs when those two settings change), --tab-max-width is omitted from inline styles at the default 300 px value, and fit mode skips useTabStripCondense DOM measurements and condense-plan work.

Risk

Level: Low

  • Both settings are optional on GlobalSettings and default to 'default' and 300, so existing profiles, older paired clients, and SSH/remote hosts keep identical behavior.
  • The riskiest area is CSS interaction between w-max, @container/tab, and has-[[data-tab-rename-input]], which was explicitly exercised across normal, forked, overflowing, and renaming fixtures.
  • Back-out is a plain git revert; unknown keys in saved settings are harmlessly ignored on older builds.

AI Disclosure

Implemented and verified with assistance from Antigravity / Codex (GPT-5 family) under human direction and review.

Review

  • Cross-platform: Pure CSS/React layout and shared settings normalization; no platform-specific APIs, paths, or keybindings.
  • SSH/remote & older clients: Local presentation preference only (not host-owned); absent/unknown values safely normalize to 'default' and 300.
  • Agent & integration compatibility: Provider-neutral across terminal, native chat, forked chat, editor, browser, and client-hosted browser tabs.
  • Performance: Primitive selectors, static Tailwind classes via CSS variable, zero extra style object allocation at default 300 px, and skipped condense measurements in fit mode.
  • UI quality: Uses SettingsGroup, SettingsRow, SettingsSegmentedControl, NumberField, and en.json tokens; verified in light and dark modes.
  • Security: Clamped numeric CSS pixel value (140..480) and strict union normalizer ('default' | 'fit'); no untrusted string interpolation.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds persisted tab-width settings with default and fit modes and a configurable maximum width. General settings provides controls and search entries for these values. The tab strip applies the selected sizing rules, disables condensation in fit mode, and uses the configured maximum width. Fixtures cover settings controls, tab sizing, overflow, and renaming.

Merge Risk: Minimal · up to 9753b

This adds optional tab width settings, and the default mode preserves existing behavior. No concrete merge-blocking risk was found in the reviewed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(tab-bar): add fit tab width mode and max tab width setting" names the main change. The changeset adds a Tab width setting (Default or Fit) and a Max tab width setting, and wires both i…
Description check Passed The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (Fixes #33867), Visual Proof (fixture commands and observed before/after behavior), Testing with comm…
Linked Issues check Passed Issue #33867 asks for a setting that reduces tab width, such as a compact tab width option. The PR adds two settings under Settings → General → Tabs: tabWidthMode ('default' | 'fit') and tabMaxWidth (…
Out of Scope Changes check Passed All changed areas connect to the tab width objective. The changes cover the settings model and defaults (tab-width-settings.ts, default-global-settings.ts, global-settings-base.ts), load-time normaliz…
Full details: Title check

Explanation

The title "feat(tab-bar): add fit tab width mode and max tab width setting" names the main change. The changeset adds a Tab width setting (Default or Fit) and a Max tab width setting, and wires both into tab sizing, settings UI, and persistence. The title is specific, concise, and follows a conventional commit style.

Full details: Description check

Explanation

The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (Fixes #33867), Visual Proof (fixture commands and observed before/after behavior), Testing with commands run, Performance ("None, because ..." with reasoning), Risk with a level, AI Disclosure, Review, Agent skill boundary, and a completed checklist. The Visual Proof section describes fixture results in text, but it does not attach images or video. The template asks for BEFORE and AFTER attachments that can be switched, so that item is only partly met. The AI Disclosure section is filled in, which is appropriate for an outside contributor.

Full details: Linked Issues check

Explanation

Issue #33867 asks for a setting that reduces tab width, such as a compact tab width option. The PR adds two settings under Settings → General → Tabs: tabWidthMode ('default' | 'fit') and tabMaxWidth (clamped to 140–480 px, default 300). Fit mode sizes each tab to its title with an 80 px floor. Max tab width lowers the width cap, so users can make tabs narrower. The persisted values are normalized in tab-width-settings.ts and normalize-loaded-global-settings.ts. The width rules in tab-width-rules.ts and use-tab-strip-slot-props.ts read --tab-max-width. The settings UI is in TabWidthSettings.tsx and is wired into GeneralPane.tsx. The issue has no other acceptance criteria. The PR does not add a standalone compact preset, but the issue proposes a setting only as an example. The implemented settings satisfy the stated problem. Automated unit tests cover the normalizer (tab-width-settings.test.ts). Layout behavior is covered by component fixtures, not by unit tests. The issue does not require unit tests.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to the tab width objective. The changes cover the settings model and defaults (tab-width-settings.ts, default-global-settings.ts, global-settings-base.ts), load-time normalization, CSS width rules, fit-mode overflow handling (TabBar.tsx, use-tab-strip-condense.ts), forked-tab sizing (SortableTab.tsx), the settings UI and search entries (TabWidthSettings.tsx, GeneralPane.tsx, general-search.ts), and en.json strings for those controls. The fixtures and the normalizer test support verification of these changes. No change was found that is unrelated to tab width sizing.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d2ed3ad9-35fd-491a-aeaa-4cf695578d9c
Commits

Reviewing files that changed from the base of the PR and between 99d6252 and 9753bed.

Files selected for processing: 17

  • src/main/persistence/loading-store/profile-loading/normalize-loaded-global-settings.ts
  • src/renderer/src/components/settings/general/GeneralPane.tsx
  • src/renderer/src/components/settings/general/TabWidthSettings.fixture.tsx
  • src/renderer/src/components/settings/general/TabWidthSettings.tsx
  • src/renderer/src/components/settings/general/general-search.ts
  • src/renderer/src/components/tab-bar/TabBar.tsx
  • src/renderer/src/components/tab-bar/TabBarWidthMode.fixture.tsx
  • src/renderer/src/components/tab-bar/strip/tab-width-rules.ts
  • src/renderer/src/components/tab-bar/strip/use-tab-strip-condense.ts
  • src/renderer/src/components/tab-bar/strip/use-tab-strip-slot-props.ts
  • src/renderer/src/components/tab-bar/terminal-tabs/ForkedChatTab.fixture.tsx
  • src/renderer/src/components/tab-bar/terminal-tabs/SortableTab.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/shared/settings/default-global-settings.ts
  • src/shared/settings/global-settings-base.ts
  • src/shared/workspace-layout/tab-groups/tab-width-settings.test.ts
  • src/shared/workspace-layout/tab-groups/tab-width-settings.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
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.

[Feature]: Setting to make tabs narrower

1 participant