Repository navigation
Gate closed secondary-panel diff queries and keep the compact terminal mounted (G1, G4) - #1881
Merged
SawyerHood merged 2 commits intoAug 19, 2026
Conversation
SawyerHood
marked this pull request as ready for review
August 19, 2026 08:04
SawyerHood
force-pushed
the
bb/mobile-perf/secondary-panel-gating
branch
from
August 19, 2026 15:59
b76971e to
10cacf5
Compare
The secondary panel keeps its content mounted while closed (compact drawers retain the panel off-screen; desktop keeps the subtree) so the next open is instant. But the diff tab's TOC query, per-file patch requests, the diff toolbar's shared TOC observer, and every file-preview query stayed live behind a closed panel. Each workspace write emits `work-status-changed`, which invalidates the diff TOC and file previews and evicts the patch cache, so a hidden panel refetched the TOC, re-requested visible patches, and remounted the highlighted preview on every fs event. Terminals were already gated on the panel being open. Gate the data, keep the DOM: - ThreadSecondaryPanel derives `isDiffPanelLive = isDiffPanelActive && isLayoutOpen` and uses it for the toolbar TOC observer and the work-status query behind the diff target selection. - GitDiffTabContent takes `isPanelOpen`; its TOC query is enabled only while the panel is open. DiffFilesPanel takes `isPanelOpen` and skips `requestPaths` while closed; reopening re-runs the effect and re-requests the current visible set, which dedupes against the cache. - The workspace / project / host / thread-storage preview tab bodies take `isPanelOpen` and pass `enabled` to their preview queries. Both views pass `isSecondaryPanelOpen`. A closed panel keeps its cached data; an invalidated query refetches once when the panel reopens, not per event while hidden. Co-Authored-By: Claude <[email protected]>
On compact viewports, closing the secondary drawer leaves the panel persisted-open but hidden. ThreadTerminalContent unmounted the terminal view whenever `isPanelOpen` was false, so every drawer close disposed xterm and its WebSocket, and every reopen re-created xterm/WebGL and replayed the scrollback. Add `shouldMountTerminalView` to the terminal controller: true while the panel is open, and, once this client has shown the panel, while it stays persisted-open but hidden. A persisted-open terminal tab synced from another device does not mount xterm on a phone that never opened the drawer, and closing the persisted panel still releases the view. On desktop `isPanelOpen === isPanelPersistedOpen`, so behavior is unchanged. The retained-view effect follows the same flag so a hidden terminal survives a transient disconnect the way an open one does. Co-Authored-By: Claude <[email protected]>
SawyerHood
force-pushed
the
bb/mobile-perf/secondary-panel-gating
branch
from
August 19, 2026 16:13
10cacf5 to
e1e88b3
Compare
SawyerHood
added a commit
that referenced
this pull request
Aug 19, 2026
…, C10, F2, E2) (#1880) ## What was wrong Seven paint/layout costs hit iOS Safari during a streaming turn (audit findings C2, C10, D7, D9, E2, F1, F2): - The timeline's `AutoHeightContainer` eased its whole height 180 ms for every streaming delta. Deltas arrive every ~250 ms, so the tween ran continuously. Each eased frame re-laid out the timeline; on WebKit (no CSS scroll anchoring) the JS scrollTop restore followed every frame. `AnimatedExpandablePanelContent` restarted its own 200 ms height tween on content growth of open bodies without registering with `layoutAnimationInFlightCountAtom`. - Every collapsed `ExpandablePanel` body pinned a compositing layer with `will-change-transform`. - The follow-up composer tweened its height 240 ms in the sticky footer as the soft keyboard and shell resize landed. - `.scroll-bottom-anchor-content *` toggled with `isAtBottom` and restyled every timeline node; WebKit ignores `overflow-anchor` so the toggle was pure cost there. - The shimmer sweep repainted its scroller tile every frame, also inside inert/aria-hidden hosts. - `body[data-sidebar-dragging] *` set a cursor on every element at drag start/end, including on touch drags. - `backdrop-blur` sat on the page header, the scroll-to-bottom button, and the retained overlay backdrops, where nothing needs blurring. ## What changed - `AutoHeightContainer` uses duration 0 on a coarse pointer, under reduced motion, or when `CSS.supports("overflow-anchor: none")` is false (`lib/scroll-anchoring-support.ts`). `AnimatedExpandablePanelContent` eases only expand/collapse toggles; growth inside an open body snaps. - Removed `will-change-transform` from collapsed panel bodies. - `PromptBoxInternal` skips the layout height tween on coarse pointer + compact viewport. - The scroll-anchor exclusion class goes on the content wrapper alone; the sentinel is a sibling; the class is never applied where scroll anchoring is unsupported. The universal descendant rule is gone. - `.animate-shine`/`.animate-shine-icon` promote to their own layer while present and pause under `[inert]`/`[aria-hidden="true"]`. - The drag cursor rule is scoped to `[data-sidebar="panel"]` inside `@media (pointer: fine)`. - Dropped `backdrop-blur` from the header surface, the scroll-to-bottom button (opaque `bg-background`), and the shared dialog/drawer/persistent-drawer backdrops. ## How you verified - New tests (fail before, pass after): `height-transition.test.tsx` (coarse/reduced-motion/no-anchoring => `height 0ms`, fine pointer => `180ms`), `disclosure.test.tsx` (mount and content growth snap; toggle eases), `bottom-anchored-scroll-body.anchor-class.test.tsx` (class on wrapper only, sentinel outside, no class when unsupported), `theme.test.ts` (shimmer will-change and pause rule; no `.scroll-bottom-anchor-content *`), `app.css.test.ts` (cursor rule scope), `scroll-to-bottom-button.test.tsx` + `responsive-overlay.test.tsx` (no `backdrop-blur`), `PromptBoxInternal.test.tsx` (coarse+compact snaps the tween). - `pnpm exec turbo run typecheck --filter=@bb/app --filter=@bb/shared-ui`: pass. - `pnpm exec turbo run lint --filter=@bb/app`: 0 errors (147 pre-existing warnings, none new). - Targeted vitest runs: 8 + 2 + 25 files, 434 tests, all pass. ## Update (2026-08-19) D7 (skip the follow-up composer height tween on phones) was removed after an iPhone test of this layer alone showed the caret rendered one line above the editor after the first tap: WebKit computes the native caret rect at focus time and, without the per-frame layouts of the tween, never refreshed it. The 240 ms tween is back on phones; the timeline-side snaps (C2) and the rest of this PR are unchanged. Fixes: part of the mobile / iOS Safari performance program (verified sweep report in the bb thread; no single issue). ## Stack context Layer 1 of 22 in the `bb/mobile-perf/*` stack (bottom → top: quick wins first, big rocks last). - Prerequisite: none (bottom of the stack, targets `main`). - Next layer: `bb/mobile-perf/secondary-panel-gating` (#1881). - Audit findings addressed: see title IDs. Review: approved-with-fixes; 1 review fix commit(s). - Deliberately not done here: D7: reverted; snapping the composer expansion leaves a stale iOS caret rect - Reviewer notes / follow-ups: D9 (unverified on WebKit): `will-change: transform` on `.animate-shine` (background-clip: text) and `.animate-shine-icon` (mask-image) renders correctly in Chromium (verified via a | E2 (cosmetic, desktop only): with the cursor rule scoped to `[data-sidebar="panel"]`, dragging a sidebar row while the mouse strays over the main content now shows the underlying e | C2 optional burst gate (snap when the previous growth was <250 ms ago) was intentionally not implemented; desktop Chromium/Firefox with a fine pointer still eases every streaming d - Wire/contract: None. No server/daemon wire, route, command, CLI, config knob, or plugin API change. HOST_DAEMON_PROTOCOL_VERSION unchanged. > AGENT GENERATED: by Claude Code (claude-mangosteen-eap) --------- Co-authored-by: Claude <[email protected]>
SawyerHood
added a commit
that referenced
this pull request
Aug 19, 2026
…t, send path, search, archived (B8, K5, B14, B15, B17, B18, B24) (#1882) ## What was wrong Realtime and query policies on the client did more network and git work than the UI needed, which is expensive on phones and through bb connect: - `work-status-changed` fired on every file-change burst. It refetched (and aborted) the in-flight `git status` probe every flush and also refetched the pull request, which a local edit cannot change. The PR query itself refetched on every focus (`"always"`) and polled every 5 s while checks were pending; each lookup spawns `gh pr view`. - The root-compose branch list (a daemon git RPC) went stale after 5 s and refetched on every foreground. - After a send succeeded, the client prepended the prompt-history entry locally and then invalidated the same query; it also refetched default execution options that consumers read only as initial values, and a queued send refetched thread detail although `queue-changed` arrives over realtime. - Every `events-appended` flush from any thread invalidated (cancelling) the open thread search and ran the timeline pacing machinery for threads nobody was viewing. - Every status/title/environment change refetched every open archived settings page (100-row un-windowed pages). ## What changed - PR query: `refetchOnWindowFocus: true`, 30 s pending-check poll, PR key dropped from the work-status handler. `turn/completed` and the poll keep it current. - Branch list: `REALTIME_OWNED_NO_FOCUS_QUERY_POLICY` + 30 s stale; picker open still refetches. Removed the now-unused `FAST_FOCUS_OWNED_LIVE_QUERY_POLICY`. - Work status: marked stale immediately, active observers refetched at most once per second per environment with `cancelRefetch: false`; changes inside the interval coalesce into one trailing refetch; timers cleared on dispose. - Send success: prompt history is prepended locally on both paths, default-exec marked stale with `refetchType: "none"`, queued sends refetch only the queue list while realtime is connected. History rewrites still refetch prompt history explicitly. - Search: goes stale only when a batch contains `turn/completed`, once per flush (`flushOnce` on `ThreadRealtimeDirtyContext`), with `cancelRefetch: false`. - Timelines without an active observer are only marked stale (`refetchType: "none"`). - Archived list keys are marked stale, not refetched, by status/title/environment handlers (`dirtyActiveThreadListQueries`); `archived-changed` still refetches. Archived page size 100 -> 50. ## How you verified - `pnpm exec turbo run typecheck --filter=@bb/app` and `pnpm exec turbo run lint --filter=@bb/app` pass (lint: 0 errors, pre-existing warnings only). - New tests fail on `origin/main` and pass on this branch (verified by stashing the source changes): - `apps/app/src/hooks/realtime-cache-effects.test.ts`: search invalidated only on turn/completed; once per flush without aborting the in-flight search; unviewed timeline marked stale with `refetchType: "none"` while the viewed one refetches; archived lists not refetched on status/title but refetched on archived-changed; PR not refetched on work-status-changed; work-status refetch paced to one per second without aborting the probe. - `apps/app/src/hooks/cache-owners/thread-runtime-cache-owner.test.ts`: accepted send keeps prompt history local and only marks default-exec stale; queued send refetches only the queue list. - `apps/app/src/hooks/queries/project-queries.test.tsx`: branch list has no focus refetch and 30 s stale. - `apps/app/src/hooks/queries/environment-queries.test.tsx`: updated for `refetchOnWindowFocus: true` and 30 s poll. - `pnpm exec turbo run test --filter=@bb/app -- src/hooks src/components/settings src/views/thread-detail src/components/thread/timeline src/components/promptbox src/lib/query-client`: 134 files, 1018 tests pass. Fixes: part of the mobile / iOS Safari performance program (verified sweep report in the bb thread; no single issue). ## Stack context Layer 3 of 22 in the `bb/mobile-perf/*` stack (bottom → top: quick wins first, big rocks last). - Prerequisite (layer below): `bb/mobile-perf/secondary-panel-gating` (#1881). - Next layer: `bb/mobile-perf/ws-liveness-and-resume` (#1883). - Audit findings addressed: see title IDs. Review: approved-with-fixes; 1 review fix commit(s). - Reviewer notes / follow-ups: Client-side only: the PR query is no longer refreshed by any realtime signal other than turn/completed (git-refs-changed does not touch it, and it never did). A PR created/pushed f | Archived settings pages go stale (not refetched) on status/title/environment changes until the settings route remounts or a focus refetch; archived-changed still refetches. Accepte | K5 is a leading-edge throttle with a coalesced trailing refetch (first change after a quiet period refetches immediately) rather than a pure 1 s debounce; the trailing refetch sche - Wire/contract: None. All changes are client-side (apps/app) query policy and cache-invalidation behavior; no server routes, host daemon RPCs, WebSocket messages, or session payloads changed, so HOST_DAEMON_PROTOCOL_VERSION is unchanged. > AGENT GENERATED: by Claude Code (claude-mangosteen-eap) --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
The secondary panel keeps its content mounted while closed so the next open is instant (compact drawers retain the panel off-screen; desktop keeps the subtree). But its data stayed live: the diff tab TOC query, the toolbar's shared TOC observer, visible-row patch requests, and every file-preview query kept running behind a closed panel. Each workspace write emits
work-status-changed, which invalidates the diff TOC and previews and evicts the patch cache, so a hidden panel refetched the TOC, re-requested patches, and remounted the highlighted preview on every fs event (audit G1). Terminals were gated onisPanelOpen, but on compact that meant every drawer close disposed xterm and its socket, and every reopen re-created xterm/WebGL and replayed up to the full scrollback (audit G4).What changed
ThreadSecondaryPanelderivesisDiffPanelLive = isDiffPanelActive && isLayoutOpenand uses it for the toolbar TOC observer and the diff-target work-status query.GitDiffTabContentandDiffFilesPaneltakeisPanelOpen. The TOC query is enabled only while the panel is open.requestPathsis skipped while closed and re-fires for the current visible set on reopen (dedupes against the cache).isPanelOpenand passenabledto their preview queries.ThreadDetailViewandRootComposeViewpassisSecondaryPanelOpen. The DOM stays mounted; an invalidated query refetches once on reopen.shouldMountTerminalView = isPanelOpen || (isPanelPersistedOpen && hasPanelOpened).ThreadTerminalContentmounts on it. A compact drawer close keeps an already-mounted terminal alive; a persisted-open tab synced from another device does not start xterm on a phone that never opened the drawer; closing the persisted panel releases the view. Desktop is unchanged (isPanelOpen === isPanelPersistedOpen).How you verified
ThreadSecondaryPanelTabContent.panelGate.test.tsx: with the real query hooks and a mocked sdk, the diff TOC and workspace preview do not fetch whileisPanelOpenis false, do not refetch afterinvalidateQuerieswhile closed, and refetch exactly once on reopen. Fails before, passes after.useThreadTerminalController.mount.test.tsxand extendedThreadTerminalContent.test.tsx: view is retained (same DOM node) across a hidden-but-persisted panel, unmounts when persisted state closes, and never mounts for a persisted-open panel this client has not shown. Fail before, pass after.pnpm exec turbo run typecheck --filter=@bb/app,pnpm exec turbo run lint --filter=@bb/app(147 warnings, same as baseline, 0 errors), targeted vitest forsrc/components/secondary-panel,src/components/thread/terminal,src/views/thread-detail,src/views/RootComposeView(50 files, 408 tests pass).Fixes: part of the mobile / iOS Safari performance program (verified sweep report in the bb thread; no single issue).
Stack context
Layer 2 of 22 in the
bb/mobile-perf/*stack (bottom → top: quick wins first, big rocks last).bb/mobile-perf/css-paint-ios(Snap timeline height tweens and trim paint work on phones (C2, F1, D9, C10, F2, E2) #1880).bb/mobile-perf/invalidation-tuning(Tune realtime invalidations: PR key, work-status debounce, branch list, send path, search, archived (B8, K5, B14, B15, B17, B18, B24) #1882).requestPathsearly-return whileisPanelOpen === falseand its re-fire on reopen is untested; no existing jsdom harness renders D | Trade-off to be aware of (by design, per G4): on compact a hidden-but-persisted terminal keeps its WebSocket and xterm/WebGL context alive off-screen while the drawer is closed; xt