From 4ee382832a230dcbe9a1084f0eff31823d52992b Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Thu, 8 Oct 2026 20:46:23 +0200 Subject: [PATCH] fix(tabs): keep the active tab in view when it changes state band on a phone On phones and 600-767px tablets the header strip stays one horizontally scrolling row. #538 (Tab Layout, default "by state") orders that row in one flex `order` band per state, so when the ACTIVE session changes state (a prompt sent: idle to working; a permission prompt: needs you) its chip moves to another band while scrollLeft stays put, and the tab in use left the screen (measured at 390px: x 165 to -870). #257's reveal rules only covered a CHANGED active tab: _updateActiveTabImmediate reveals on a switch, and _fullRenderSessionTabs restores scrollLeft and re-reveals only when _lastRenderedActiveTabId changed, while a state change is an incremental pass that never reveals at all. _noteActiveTabBand() records the active tab's band (read off the element, so it is what is on screen) and reports when it moved while the tab stayed active. Both render paths reveal on that, in the single scrolling row only (_isScrollingTabRow: not wrapping, not a vertical list). It is keyed on the band, not the raw order value, because another tab entering or leaving the active tab's band shifts that value by one and another tab's move must not yank a strip the user is browsing. _updateActiveTabImmediate records too, so the pass right after a switch still counts (viewing a waiting tab spends its alert and drops it into the idle row). The incremental path reveals after updateTabOverflowMode(), and only from the branch that reached _syncTabTriageChrome(), so a pass that falls through to a full rebuild mid-loop leaves the record for the rebuild to compare. Tests in test/tab-triage.test.ts pin the reveal on both paths and after a switch, and that another tab's band change, a wrapping strip, a vertical list and an active web tab never scroll. Co-Authored-By: Claude Opus 5.5 (1M context) --- CLAUDE.md | 2 +- docs/architecture-invariants.md | 2 + src/web/public/app.js | 63 ++++++++++++++++++++- test/tab-triage.test.ts | 99 +++++++++++++++++++++++++++++++++ 4 files changed, 163 insertions(+), 3 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index ee2b083f..763bcd08 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -331,7 +331,7 @@ Frontend JS modules have `@fileoverview` with `@dependency`/`@loadorder` tags. L **Entrance animations** (`entrance-animations.js`, all OFF by default): opt-in animations for tabs, terminal, windows and connection lines, chosen via `data-tab-anim` / `data-term-anim` / `data-win-anim` / `data-line-anim` on ``; the default `legacy` theme short-circuits every hook. ⚠️ Tabs and lines are destroyed mid-animation on re-render, so re-apply to the fresh element by id with a negative `animation-delay` (resume, never restart). ⚠️ Terminal-pane styles may animate only transform / opacity / clip-path (anything else resizes the PTY via FitAddon); `blur` is the ONE sanctioned `filter` exception, do not generalise it. ⚠️ Line glow lives in `--line-glow` so blur keyframes interpolate. Persisted per-device in `codeman:*Anim` localStorage keys, never in `SettingsUpdateSchema`; lab at `?animlab=1`. Test: `test/entrance-animations.test.ts`. → [architecture-invariants#entrance-animations](docs/architecture-invariants.md#entrance-animations) -**Mobile tab strip scrolling** (issue #257): under 768px the tab strip scrolls horizontally, so the active tab must be kept reachable. `_updateActiveTabImmediate()` reveals it via `computeTabScrollLeft()` (constants.js, rect math on the strip's own `scrollLeft`, never `scrollIntoView()`, which scrolls the document under the fixed header); `_fullRenderSessionTabs()` must restore `scrollLeft` across rebuilds and re-reveal only when the active tab changed (`_lastRenderedActiveTabId`). ⚠️ The phone-block `min-width` on `.session-tab.active .tab-name` keeps the tab's centre off the gear/close icons, sized for numberless tabs 10+ (floor 40px); do not shrink it. ⚠️ Never reintroduce hoisting the active session to the front of the strip. Test: `test/mobile-tab-tap-zones.test.ts`. → [architecture-invariants#mobile-tab-strip-scrolling](docs/architecture-invariants.md#mobile-tab-strip-scrolling) +**Mobile tab strip scrolling** (issue #257): under 768px the tab strip scrolls horizontally, so the active tab must be kept reachable. `_updateActiveTabImmediate()` reveals it via `computeTabScrollLeft()` (constants.js, rect math on the strip's own `scrollLeft`, never `scrollIntoView()`, which scrolls the document under the fixed header); `_fullRenderSessionTabs()` must restore `scrollLeft` across rebuilds and re-reveal only when the active tab changed (`_lastRenderedActiveTabId`) or, grouped by state, the ACTIVE tab moved to another state band (`_noteActiveTabBand()`, both render paths, scrolling row only; another tab's move never scrolls). ⚠️ The phone-block `min-width` on `.session-tab.active .tab-name` keeps the tab's centre off the gear/close icons, sized for numberless tabs 10+ (floor 40px); do not shrink it. ⚠️ Never reintroduce hoisting the active session to the front of the strip. Tests: `test/mobile-tab-tap-zones.test.ts`, `test/tab-triage.test.ts`. → [architecture-invariants#mobile-tab-strip-scrolling](docs/architecture-invariants.md#mobile-tab-strip-scrolling) **Session list layout: header strip or left sidebar** (`sessionListLayout`, default `header`; per-device via `displayKeys`, also in `SettingsUpdateSchema`): the list can move into a collapsible `