Skip to content

fix(tab-bar): keep the active tab visible when the tab strip scrolls - #24010

Merged
AmethystLiang merged 5 commits into
mainfrom
hard-to-locate-current-tab-in-many-tabs
Sep 30, 2026
Merged

AmethystLiang merged 5 commits into
mainfrom
hard-to-locate-current-tab-in-many-tabs

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​359 $\color{#cf222e}{\Huge{\mathbf{−}}}$​26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​333
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​291 $\color{#cf222e}{\Huge{\mathbf{−}}}$​52 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​239

ELI5

With lots of tabs open, the tab bar scrolls sideways, and the tab you're on can scroll out of sight. Then it's hard to tell which tab you're looking at. Now the current tab sticks to the edge of the tab bar instead of disappearing, and its underline is easier to see.

What Changed

Before: with many tabs, every tab shrinks to 72px and the strip scrolls. The active tab was marked only by a 6% background tint and a 60%-grey underline, which is hard to spot among many similar tabs. Once you scrolled it out of view, nothing pointed back to it. A tab opened in the background could land out of view with no visible change. Closing the active tab could send the strip to a far-away tab and back.

After:

  • The active tab docks to the edge. When it would scroll out of view, it sticks to the edge it went past. It keeps its current width. This is position: sticky on each tab's wrapper in the strip (use-tab-strip-slot-props.ts). Docking turns off during a drag, because drop targets are picked from on-screen positions and a docked tab overlaps its neighbour.
  • Stronger underline. The active tab's underline is full foreground instead of 60%.
  • No fade under the docked tab. The strip's edge fade turns off on the side where a tab is docked. When docked on the right, a thin divider marks the seam.
  • Scrolling uses each tab's real position. A docked tab always looks on screen, so scrollIntoView and the scroll anchor would be fooled. They now use where the tab sits in the tab order, not where it's drawn (tab-strip-slot-geometry.ts).
  • Opening a tab scrolls to it. Foreground opens already did this. A background open that lands out of view now scrolls to the new tab as well:
    • the active tab stays beside it when both fit, and docks otherwise;
    • this is skipped while the pointer is over the strip, so tabs don't slide under the cursor;
    • new tabs are detected by comparing tab ids, not counts, so a tab that replaces another still counts as new.
  • Closing a tab keeps the strip still. Closing the active tab switches to the previously used tab, which can be far away. The strip no longer scrolls after it; that tab docks instead. This also fixes an older flicker: a scroll-to-end queued in the same update would run after a reveal and undo it.

Why

Chrome shrinks tabs down to their icons and never scrolls. That works because every website has its own favicon. Orca's terminals and editor files share icons, so icon-only tabs would all look the same.

VS Code scrolls and reveals the tab you switch to, but loses the active tab as soon as you scroll by hand.

I also prototyped counts on the scroll arrows, a marker on the scroll thumb, and an all-tabs list. Each of those points you toward the tab instead of showing it. Docking keeps the active tab visible in every state with one CSS rule; the rest of this PR keeps scrolling correct around it. I dropped keeping the active tab at full width, because resizing tabs on click moves the other tabs under the cursor.

Linked Issue

No existing issue covers this bug.

Visual Proof

The active tab (bun-notes.md) docked on the right after scrolling the strip back to the start:

active-tab-docked-right.png

A background tab opened far from the active tab. The strip scrolls to the new tab ("New Tab", right edge), and the active tab (orb-notes.md) docks on the left:

background-open-revealed.png

Testing

  • Unit tests in tab-strip-growth-scroll.test.tsx cover:

    • which edge the tab docks to;
    • scrolling to a new tab on foreground and background opens;
    • keeping visible tabs still next to a docked tab;
    • the hover guard;
    • a close leaving the strip still, while a later tab switch still scrolls.

    Each test was checked to fail with its fix removed. tab-strip-scroll-metrics and drop-indicator tests were updated too.

  • Dev build on macOS, a hidden window driven over the DevTools protocol, with 24+ tabs. Checked:

    • docking at both edges;
    • a background open next to the active tab and far from it;
    • a foreground open next to a docked tab;
    • closing the active tab when the next tab is far away and when it's nearby, recording tab positions frame by frame.
  • Checks on this branch: 821 tab-bar/tab-group/floating-terminal tests, pnpm tc:web, oxlint on changed files, and the changed-code quality gate all pass.

  • Not yet tested:

    • dragging the docked tab;
    • light theme;
    • the floating terminal panel;
    • client-hosted browser rows;
    • Linux and Windows (CSS only, no platform-specific code);
    • SSH workspaces.
  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Security: no impact.
  • Cross-platform: CSS and DOM measurement only; nothing branches on platform.
  • Remote SSH: tabs synced from a remote host go through the same reveal logic. A remote snapshot lands in one store update and sets the active tab, so a first load doesn't count as a background open.
  • Mobile: the mobile app has its own tab strip and isn't affected.
  • Backwards compatibility: no stored state or wire format changes.
  • Performance: the extra work is a few position reads per scroll event and a pass over tab ids when the tab list changes. There's no new per-frame rendering.

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)
  • 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)

Makes the current tab easier to locate in many-tab scenarios. The active tab
now sticks to a viewport edge via sticky positioning when it would scroll out
of view, with a full-foreground indicator bar for better visibility and arrow
animation when a background tab opens off-screen.
When a background tab opens beyond the visible area, automatically scroll
to reveal it (unless hovering the tab strip). This replaces the previous
arrow-nudge animation with direct visibility. revealTabStripElement now
handles keeping the active tab visible alongside the revealed tab when
both fit, or docks the active tab when needed.
Detect opened tabs by comparing tab identities independently of count
changes. Newly opened tabs are now revealed even when the total tab count
stays the same—e.g., when a tab closes as another opens.
Replace count-based tab detection with identity tracking so the strip
correctly reveals tabs when they're added, replaced, or when the active
tab closes and switches to a far-back history tab. Removes the tabCount
parameter and simplifies overflow navigation by using identity sets.
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Refactors tab bar scrolling to keep active tab visible.

The PR appears safe to merge, though deferred hover reveals can cause an unwanted strip scroll after keyboard selection.

Findings

  1. P2 Deferred reveal overrides selection ▶

Summary

The PR docks an active tab at the edge of an overflowing strip and updates tab-reveal, scroll-anchor, fade, and test behavior.

  • The new deferred hover reveal can later override a keyboard-selected tab’s scroll position.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Background tab opens under pointer] --> B[Queue deferred reveal]
  B --> C[User selects another tab]
  C --> D[Pointer leaves strip]
  D --> E[Queued tab scrolls into view]
Loading

Reviews (2) · Last reviewed commit: "fix(tab-bar): defer revealing tabs until..."

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 952fcb01-96d4-4592-a6cd-f41e18a4900b

📥 Commits

Reviewing files that changed from the base of the PR and between bb874f6 and c4fdc57.

📒 Files selected for processing (19)
  • src/renderer/src/assets/main.css
  • src/renderer/src/components/tab-bar/BrowserTab.test.tsx
  • src/renderer/src/components/tab-bar/BrowserTab.tsx
  • src/renderer/src/components/tab-bar/ClientHostedBrowserTab.tsx
  • src/renderer/src/components/tab-bar/EditorFileTab.test.tsx
  • src/renderer/src/components/tab-bar/EditorFileTab.tsx
  • src/renderer/src/components/tab-bar/SortableTab.rename-shortcut.test.tsx
  • src/renderer/src/components/tab-bar/SortableTab.tsx
  • src/renderer/src/components/tab-bar/TabBar.tsx
  • src/renderer/src/components/tab-bar/drop-indicator.test.ts
  • src/renderer/src/components/tab-bar/drop-indicator.ts
  • src/renderer/src/components/tab-bar/tab-bar-surface.tsx
  • src/renderer/src/components/tab-bar/tab-strip-growth-scroll.test.tsx
  • src/renderer/src/components/tab-bar/tab-strip-overflow-navigation.ts
  • src/renderer/src/components/tab-bar/tab-strip-scroll-anchor.ts
  • src/renderer/src/components/tab-bar/tab-strip-scroll-metrics.test.ts
  • src/renderer/src/components/tab-bar/tab-strip-scroll-metrics.ts
  • src/renderer/src/components/tab-bar/tab-strip-slot-geometry.ts
  • src/renderer/src/components/tab-bar/use-tab-strip-slot-props.ts

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


📝 Walkthrough

Walkthrough

Tab components now expose slot identities and apply active-tab docking when no drag is in progress. Overflow navigation tracks slot changes, reports the active dock side, and reveals off-screen tabs using slot geometry. The tab-strip surface adjusts its scroll fades for the docked edge. The active drop marker and the docked-end tab seam also have updated styling.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to c4fdc

The change keeps active tabs visible and makes overflow navigation slot-aware. No concrete merge-blocking issue is established; it is ready to merge subject to normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 18 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: keeping the active tab visible while the tab strip scrolls.
Description check ✅ Passed The description is mostly complete. It explains the user impact, implementation, rationale, visual behavior, testing, platform considerations, and performance impact. It includes visual proof and upda…
Full details: Docstring Coverage

Explanation

Docstring coverage is 36.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 18 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog 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.

ℹ️ Minor suggestions only.

Reviewed changes

  • Active tab docks to strip edges. New use-tab-strip-slot-props.ts marks each tab's direct strip child with data-tab-strip-slot and tags the active one with data-active-tab-dock plus sticky inset-x-0 z-10, wired into SortableTab, BrowserTab, EditorFileTab, and ClientHostedBrowserTab.
  • New slot-geometry module. tab-strip-slot-geometry.ts reconstructs each slot's natural span, reports the docked edge, finds newly opened offscreen slots, and implements a least-distance revealTabStripSlot.
  • Open/close tracked by identity. tab-strip-overflow-navigation.ts drops tabCount in favor of slot-id sets, suppresses the reveal on a close commit via tabClosedThisCommitRef, skips revealing while the pointer hovers the strip, and exposes activeTabDockSide.
  • Presentation. Active indicator is now full bg-foreground; the edge fade is dropped on the docked side; a ::before seam is added for data-active-tab-docked='end'; the TabBar layout key now includes client-hosted row ids.

ℹ️ The new geometry module and the docking class have no direct tests

tab-strip-slot-geometry.ts and use-tab-strip-slot-props.ts are covered only indirectly. tab-strip-growth-scroll.test.tsx builds its own slots and mocks getBoundingClientRect to clamp a data-active-tab-dock element into the viewport, and the component tests mock useTabStripSlotProps to a stub that drops the sticky inset-x-0 classes. As a result, the actual docking mechanism (the CSS class) and the span/offscreen math against a real layout are unverified — deleting sticky inset-x-0 would leave every test green. I confirmed the sticky + inset-x-0 behavior in Chromium, so the mechanism is sound; the gap is that a future regression would not be caught.

Technical details
# Docking has no regression guard

## Affected sites
- `src/renderer/src/components/tab-bar/tab-strip-slot-geometry.ts` — no dedicated test.
- `src/renderer/src/components/tab-bar/use-tab-strip-slot-props.ts` — the `sticky inset-x-0 z-10` class is not asserted anywhere; `BrowserTab.test.tsx`, `EditorFileTab.test.tsx`, and `SortableTab.rename-shortcut.test.tsx` mock the hook, and `tab-strip-growth-scroll.test.tsx` hand-builds slots.
- `src/renderer/src/assets/main.css` — the end-dock seam and fade suppression are not exercised.

## Required outcome
- At least one guard that fails if the active slot stops carrying the docking class, or an E2E/manual check of both-edge docking, the edge fade, and the seam.

## Suggested approach (optional)
- Assert the `className`/`data-active-tab-dock` output of `useTabStripSlotProps` for active vs inactive vs dragging.
- Consider a small unit test for `getSlotNaturalSpan`/`getSlotOffscreenSide`/`revealTabStripSlot` with real rects.

ℹ️ Nitpicks

  • The PR body is still the empty template: no ELI5, What Changed, Why, Testing, or required before/after visual proof for a UI behavior change.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@AmethystLiang AmethystLiang changed the title Hard to locate current tab in many tabs fix(tab-bar): keep the active tab visible when the tab strip scrolls Sep 30, 2026
When a background tab opens while the pointer hovers the tab strip, defer
its reveal until the pointer leaves. This prevents the active tab from
sliding away mid-interaction. Also support client-hosted rows taking
active state while maintaining tab dock positioning.
@AmethystLiang
AmethystLiang merged commit 9cdbeba into main Sep 30, 2026
1 of 2 checks passed
Comment on lines +178 to +183
const knownIds = new Set([...readTabStripSlotIds(el)].filter((id) => !deferred.has(id)))
const offscreenOpened = findOffscreenOpenedTabStripSlot(el, knownIds)
if (!offscreenOpened) {
return
}
revealTabStripSlot(el, offscreenOpened)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Deferred reveal overrides selection When a background tab opens while the pointer is over the strip, its reveal is queued. If the user then selects another tab with the keyboard, leaving the strip still reveals the earlier background tab. This moves the strip away from the selected tab; the queued reveal should be cleared or reconsidered when selection changes.

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