Skip to content

perf(website): keep the session list mounted while the sidebar is closed - #37116

Merged
bolichen97 merged 1 commit into
mainfrom
crew/kiro-crew-rust/sidebar-keep-mounted
Nov 14, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
crew/kiro-crew-rust/sidebar-keep-mounted

Conversation

@buluoray

@buluoray buluoray commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Reopening the sessions sidebar on desktop, or the sessions drawer on a phone, no longer freezes the page while the session list is built again.

Every reopen mounted the whole session list again (rows, menus, drag-and-drop) in one main-thread task. With a long list the page stops responding for about 100 ms at normal CPU speed, and for 400-900 ms on a slow CPU, while the drawer slides in.

Why it matters

Opening and closing the sessions list is one of the most common actions on the chat page, on desktop and on a phone. Clicks, typing and streaming output stall for as long as the reopen blocks.

Not a goal

  • The first open after a page load: that one still mounts the list.
  • Closing: its cost is unchanged.
  • The right side panel and the detail panel: they had no long task on open or close (measured, below).
  • Making the list itself cheaper to mount.

What changed (motivation → approach → change)

Cause: OverlayDrawer unmounts its children while closed, so every reopen mounted ChatSidebar again. A trace of one desktop reopen shows one React render of 100+ ms; layout is 13-22 ms of it.

Approach: keep the list mounted and move it instead of rebuilding it. SessionsSidebarChrome renders ChatSidebar through a portal into a host element it owns. While the sidebar or drawer is open, the drawer adopts that host; when it closes, it lets go of it. Reopening puts the same list back on screen. The list mounts on the first open and is kept from then on; a phone/desktop switch mounts it afresh, as before. Closed, it takes the same store updates it takes while open.

Four things depended on the list being unmounted while closed:

  • Scroll position. Leaving the document drops an element's scroll offset, so useLaneScrollMemory restores the recorded top row again when the lane comes back on screen, not only on mount.
  • Reveal requests. A folder or session picked in the command bar while the list is closed used to wait in the store until the list mounted. chat-sidebar/reveal.ts now leaves the request pending while the list is out of the document and runs it when the list comes back.
  • Open menus and floating layers. A row menu, or a layer such as the needs-me card or a folder dialog, left open when the sidebar closed by shortcut or Back used to go away with the list. The kept list now renders inside OffScreenOverlayScope (components/overlayRoot.tsx): its menus, context menus and selects close, as on a switch to another Crew; useLocalCrewHidden reads true inside it, so a modal there ignores Escape; and every other layer it opened sits in the scope's own overlay container, which leaves the document while closed, so a dialog in it does not claim the composer's Escape, and comes back on reopen. The menus learn about the close through a subscription, not a changed context value, so closing re-renders only the layers that read it; a context value made every menu in the list re-render and added about 40 ms per close on a phone at CPU 4x.
  • The drawer's own slot. A phone/desktop switch while the drawer is open swaps the drawer's slot; the new slot adopts the list before the old one unmounts, so the old one lets go only if it still holds it.

The lane scroll memory spec in docs/system-specs/modules/learn-cron-dashboard.md describes the kept list.

Fixture: 222 sessions, 100-row transcript, headless Chromium, builds alternated in one script with a main-vs-main (A/A) pair in every round.

Longest task per reopen main this PR
Desktop 1440x900, CPU 1x (8 reopens on this PR, 16 on main, load 6.2-8.5) 91-157 ms 0
Desktop, CPU 4x (8 reopens on this PR, 16 on main, load 4.6-8.5) 359-526 ms 114-153 ms
Phone 412x915 touch, CPU 1x (6 reopens on this PR, 12 on main, load 5.8-8.1) 98-139 ms 0-58 ms (5 of 6 had none)
Phone, CPU 4x (9 reopens on this PR, 18 on main, load 3.7-7.4) 398-486 ms 153-193 ms
Other readings main this PR
Phone, tap to first visible row, CPU 1x 97-122 ms 37-62 ms
Desktop, toggle to first visible row with 6 chats streaming 101-175 ms 32-61 ms
Desktop JS heap / DOM nodes while closed 43.8 MB / 1,624 48.4 MB / 3,499
Phone JS heap / DOM nodes while the drawer is closed (3 rounds each, load 6.8) 41.4-41.7 MB / 1,363 46.8-46.9 MB / 2,962
Longest task per close, CPU 4x (desktop / phone) 61-186 / 53-162 ms 66-140 / 57-174 ms

The four rows above are from this head on the current main, with main's own pair (A/A) in every round, each round's runs within 2 of each other in load; one desktop CPU 4x round whose load moved more than that is left out. Closing at CPU 4x: main 0-77 ms on a phone and 54-202 ms on desktop, this PR 0-59 and 58-95 ms, so closing is no slower. The heap and node cost while closed is the same list that is there while open. The streaming and memory rows were measured on an earlier version of this change with the same desktop path.

Backwards compatibility

Compatible: the sidebar and drawer show the same list, keep their scroll position and still run a reveal requested while closed; only when the list mounts changes.

Removes nothing: no path, key, record or function is removed.

Tests

  • ChatPage.sidebarKeepMounted.test.tsx: closing the desktop sidebar, and the phone drawer, takes the list off screen without unmounting it, and reopening shows the same instance. Both fail on main. Two more cases close the sidebar with a real shared menu and a hand-rolled dialog layer open inside the list: the menu closes, and the layer leaves the document (so anotherEscapeOwnerIsOpen() is false) and the same one comes back on reopen. Each fails without OffScreenOverlayScope; the dialog case also fails on the previous head, where the container was only undisplayed.
  • overlayRoot.test.tsx: inside an off-screen scope useLocalCrewHidden reads true, and a Modal open there ignores Escape. Both fail on the previous head.
  • AdoptPaneHost.test.tsx: when a newer slot adopts the host before the older slot unmounts, the host stays in the newer slot. Fails without the ownership check.
  • useLaneScrollMemory.reattach.test.tsx: after the lane leaves the document and comes back with its offset reset, the recorded row is scrolled back to the top. Fails on main.
  • ChatSidebar.folderSearch.test.tsx: a folder reveal, and a session reveal, requested while the sidebar is out of the document stay pending and run once it is back. Both fail without the reveal.ts change.
  • The new tests plus the reveal, lane scroll, overlay root and drawer suites, 3 shuffled runs: all passed. All ChatPage, ChatSidebar, chat page, chat-sidebar, drawer, overlay root, shared ui, Modal and chat input suites: 403 files, 5,193 of 5,196 tests passed; the 3 that fail are in ChatInput.approval.test.tsx and fail the same way on unmodified main (6a61c8465f3).

Proof: not provable -- frontend test (prove.py runs Python only)

Manual verification

Against the built SPA with the stubbed dashboard API in headless Chromium: scrolled the desktop lane to perf-s088, closed and reopened. Main and this PR both come back with perf-s088 at the top; without the scroll-memory change the lane came back at the top. The phone drawer renders the same as on main (screenshots compared frame by frame in the recording).

Not checked: Safari, Firefox, a real gateway and a real phone.

Screenshots / video

Same fixture, CPU slowed 4x, the two takes recorded one after the other. The overlay is the longest task each reopen produced. On main the list area stays empty or frozen while the list mounts; here it opens with its rows.

Phone drawer reopen, main vs this PR

Desktop sidebar reopen, main vs this PR

Related Issues

None filed. Found while measuring frontend render cost for the frame-time goal.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 14, 2026 06:38
@buluoray

Copy link
Copy Markdown
Contributor Author

Sidebar reopen, main (left) vs this PR (right). Same 222-session fixture, CPU slowed 4x, the two takes recorded one after the other on the same host. The overlay is the longest main-thread task each reopen produced (main: 474 / 521 ms; this PR: 209 / 155 ms in this take).

Sidebar reopen, main vs this PR

Recorded from 65c701a against the built SPA with the stubbed dashboard API (synthetic sessions, no real data).

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 36be2c9b5d6bf2d08afe7ae75e8a9d4c2b1705da — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks: every item serves the measured reopen freeze, and each rider fixes a behaviour that keeping the list mounted would otherwise break.

Not checked: Safari/Firefox ResizeObserver firing on reattach, which the scroll and reveal re-runs rely on.

What this change ships

Inventory (7 items) — 7 justified

Intent: reopening the sessions sidebar or phone drawer should no longer freeze the page while the list is rebuilt. This is a FIX (perf).

  1. Reopening the sidebar or drawer shows the same session list without building it again, so the 100–500 ms freeze is gone — justified
  2. The session list now mounts on first open and then stays in memory while closed (about +5 MB heap, about 2× DOM nodes) — justified
  3. The lane's scroll position comes back after the list is taken off screen and put back — justified
  4. A folder or session picked in the command bar while the list is closed is revealed once the list reopens — justified
  5. Row menus, context menus and selects left open close when the sidebar closes; other layers leave the page and come back on reopen — justified
  6. A dialog in the closed list ignores Escape and does not claim the composer's Escape — justified
  7. A phone/desktop switch while the drawer is open keeps the list in the new drawer slot — justified

[FIRST-PRINCIPLES-REVIEWED] 36be2c9

Description read

[DESCRIPTION-READ] b467516feed335e06395287280e4745c23c81a34dd422c917aea54a223724eca

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 36be2c9b5d6bf2d08afe7ae75e8a9d4c2b1705da — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check: this is a performance change that adds or changes no user-visible control. The sidebar and drawer look and open the same as before, and recordings of both are attached.

Notes

  • A dialog left open inside the list (for example a folder dialog) used to disappear when the sidebar closed. It now comes back when the sidebar reopens. Confirm that a returning dialog is what users should see, not one closed the way menus are.
  • The heading "longest task -" is blank in both GIFs, so the blind reader saw "no difference". The before/after comparison shows no result. Put the measured value in the overlay, or state the numbers in the caption.

[UX-REVIEWED] 36be2c9

Description read

[DESCRIPTION-READ] c902d0bad014b4af2dc3fc6f92d9b72b1f7a36eac2e12e61e648064584e651b8

That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 36be2c9b5d6bf2d08afe7ae75e8a9d4c2b1705da — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The list is kept mounted and moved between hosts instead of rebuilt, which removes the measured cause. Each consumer that relied on unmount-on-close is handled: scroll position, reveal requests, open menus and layers, and the drawer slot swap. The recordings show this revision.

Notes

  • The kept list now re-renders on every store update while closed, including while chats stream. The streaming and memory rows were measured on an earlier version of this change. Re-measure them on this head, so the cost of keeping the list mounted is backed by the code that ships.
  • Listeners that ChatSidebar's owners attach at document level (rename.ts, scrollPeek.ts, folders.ts) now stay attached while the list is closed. Each one only records state today. Any future listener that acts on a key needs its own off-screen guard, and OffScreenOverlayScope's doc comment should say so.

[DESIGN-REVIEWED] 36be2c9

Description read

[DESCRIPTION-READ] da8655144ea29fed4630842abb537efd6138502b62baac20de1296ea58d27744

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 6.1 flagged blocking issues on 36be2c9b5d6bf2d08afe7ae75e8a9d4c2b1705da; Opus 5.5 adjudication downgraded every one of them. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents.

This comment is updated in place on each push.

Review details

BLOCKING -- website/src/hooks/useLaneScrollMemory.ts:144 -- Reopen restoration overrides a pending folder reveal

if (now && !shown) restore()
Trigger: With reduced motion enabled, scroll the tree lane, close the sidebar, select an already-expanded folder outside the remembered viewport through the command bar, then reopen. Reattachment starts restore() and wakes useSidebarReveal, which consumes the pending request and immediately scrolls to the folder.
Outcome: The remaining restore frames scroll back to the remembered session, undoing the reveal after its request is cleared and leaving the requested folder off screen.
Anchor: defect
Fix: Give explicit reveals priority by suppressing reattachment restoration for a pending reveal and canceling any active restoration before the reveal scrolls.

[BLOCK-MERGE-DOWNGRADED] 36be2c9
[GPT-REVIEWED] 36be2c9

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 is downgraded: blocking on it isn't proportionate. Harm is LOW.

F1: The failure needs all of these: a remembered anchor for the lane (useLaneScrollMemory.ts:128-129), and the reveal arriving while the list is out of the document, so it waits (reveal.ts:233 and :358, woken by shownTick at :108). The target must also be already expanded, so the reveal scrolls synchronously on its first attempt (reveal.ts:211-212). Otherwise the 100 ms retry and folder-open settle delay (:189, :202-205) would likely land after restore's 12-frame window (useLaneScrollMemory.ts:46, :123-124). Reattachment restore (:144) then re-anchors on later frames.
What the user sees: the folder doesn't appear, though its flash still fires. They can recover by issuing the reveal again with the sidebar open, because restore only re-runs on reattach (:144), so the second reveal stays. Nothing is lost or corrupted.
The real fix is a new ordering contract across two hooks in separate modules (useLaneScrollMemory and useSidebarReveal), with shared pending-reveal state, for one rare path. That costs more than a visible, one-off, self-correcting mis-scroll.

[ADJUDICATION] 36be2c9b5d6bf2d08afe7ae75e8a9d4c2b1705da total=1 uphold=0 downgrade=1
DOWNGRADE F1 website/src/hooks/useLaneScrollMemory.ts:144 reason=disproportionate-remedy
[GPT-ADJUDICATED] 36be2c9b5d6bf2d08afe7ae75e8a9d4c2b1705da

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 36be2c9b5d6bf2d08afe7ae75e8a9d4c2b1705da false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 36be2c9b5d6bf2d08afe7ae75e8a9d4c2b1705da — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 36be2c9

Verdict parsed from the review's SHA-scoped output markers for commit 36be2c9b5d6bf2d08afe7ae75e8a9d4c2b1705da.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 36be2c9b5d6bf2d08afe7ae75e8a9d4c2b1705da false-positive: <reason, 20 to 500 characters>

@buluoray
buluoray force-pushed the crew/kiro-crew-rust/sidebar-keep-mounted branch from 65c701a to cbb60c7 Compare November 14, 2026 07:54
@buluoray

Copy link
Copy Markdown
Contributor Author
  • SessionsSidebarChrome.tsx:342 folder reveal consumed while the sidebar is closed

fixed in cbb60c7: both reveal effects in chat-sidebar/reveal.ts return early while the sidebar root is out of the document, so the request stays in the store.
A ResizeObserver on the root, set up only while a request is pending and the root is detached, re-runs the effects when the root is back.
Test: ChatSidebar.folderSearch.test.tsx "keeps the request while the sidebar is out of the document, and reveals once it is back" fails without the change.

@buluoray

buluoray commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=bd6eb1ad5999 SessionsSidebarChrome.tsx:121 closing the sidebar during resizing strands global drag state

Rebutted: the trigger needs the resize handle held down while Ctrl+B closes the sidebar until its exit ends; the result is a resize cursor and disabled text selection that clear on the next press of the handle, with no data written.
Adjudication already downgraded it as disproportionate; ending a drag on detach would add a rule between the drawer close path and the resize hook for this one path.

@buluoray

Copy link
Copy Markdown
Contributor Author

Scope change, asked for by the PR owner: the phone sessions drawer had the same cause (every open mounted the list again, about 460-900 ms at 4x CPU), so it is now covered too. The Goal line, Why it matters and Not a goal were edited for that reason only; "the phone drawer is unchanged" was removed from Not a goal.

@buluoray

Copy link
Copy Markdown
Contributor Author

Recordings for head cbb60c7, main (left) vs this PR (right). Same 222-session fixture, CPU slowed 4x, the two takes recorded one after the other on the same host (load 20-24 during these takes). The overlay is the longest main-thread task each reopen produced.

Phone drawer, 412x915 touch (main: 826 / 793 ms; this PR: 180 / 209 ms in this take):

Phone drawer reopen, main vs this PR

Desktop sidebar, 1280x800 (main: 478 / 463 ms; this PR: 157 / 236 ms in this take):

Desktop sidebar reopen, main vs this PR

Built SPA with the stubbed dashboard API: synthetic sessions, no real data. The timing table in the description comes from the interleaved runs at lower load, not from these takes.

@buluoray
buluoray force-pushed the crew/kiro-crew-rust/sidebar-keep-mounted branch from cbb60c7 to 2c4524d Compare November 14, 2026 08:13
@KiroCrewCaptain

KiroCrewCaptain commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own.

Performance fix that keeps ChatSidebar mounted, portalled into a host element the drawer adopts while open and releases when closed. It handles the four things that relied on the list being unmounted: scroll memory restores when the lane comes back, reveals wait while the list is out of the document, menus close through a subscription while off screen, and the scope's overlay container leaves the document so hidden dialogs no longer claim Escape (this fixes the GPT lane's finding on the earlier head). It also handles the drawer swapping its slot. Checked against callers: the width is reported from state, not measured from the DOM; the guide registry ignores elements not in the document; Modal, the focus trap and popover stand down while off screen; the shortcut order still reads the detached DOM. Each behaviour has a test that fails without its change. Most CI and every AI lane on this head were still pending at decision time. No concrete regression path found.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 36be2c9b5d · 668 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@buluoray
buluoray force-pushed the crew/kiro-crew-rust/sidebar-keep-mounted branch from 2c4524d to 54e89c2 Compare November 14, 2026 08:52
@buluoray

Copy link
Copy Markdown
Contributor Author
  • SessionsSidebarChrome.tsx:120 phone-to-desktop switch with the drawer open leaves the desktop sidebar empty

fixed in 54e89c2: AdoptPaneHost lets go of the host only if its own slot still holds it (host.parentNode === slot), so a newer slot that adopted the host first keeps it.
Test: AdoptPaneHost.test.tsx "keeps the host in the newer slot when the older slot unmounts after it" fails without the check.

@buluoray

Copy link
Copy Markdown
Contributor Author
  • SessionsSidebarChrome.tsx:353 needs-me hover card stays floating after a keyboard close

fixed in 54e89c2: the kept list renders inside OffScreenOverlayScope, which marks it hidden while closed; NeedsMeHoverLayer already closes on that signal through useCloseWhenCrewHidden, and the scope's own overlay container is hidden too.
Tests: ChatPage.sidebarKeepMounted.test.tsx menu-close and floating-layer cases fail on cbb60c7.

@buluoray

Copy link
Copy Markdown
Contributor Author
  • SessionsSidebarChrome.tsx:347 board column tag popover stays on screen after the sidebar closes

fixed in 54e89c2: the second option in the finding. OffScreenOverlayScope gives the kept list its own overlay container, set to display:none while the sidebar is closed, so the column popover is hidden with it and returns as it was.
Test: ChatPage.sidebarKeepMounted.test.tsx "hides a floating layer the list opened while the sidebar is closed, and shows it again on reopen" fails on 2c4524d.

@buluoray

buluoray commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=0a051edb7d6a overlayRoot.tsx:130 board filter editor remains visible after the sidebar closes

fixed in 54e89c2: OffScreenOverlayScope owns a dedicated overlay container inside the parent's and sets it to display:none while the sidebar is closed, so the column editor and every other layer the list opened are hidden, and shown again on reopen.
Test: ChatPage.sidebarKeepMounted.test.tsx "hides a floating layer the list opened while the sidebar is closed, and shows it again on reopen" fails on 2c4524d.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 14, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 2) is red on 54e89c2 in test/tracing/test_tracing_otlp.py (assert 5 == 4). That is main's red from #37005, tracked in #37169, with the fix in #37171; this PR changes no backend file. I will rebase onto main once #37171 merges.

@buluoray
buluoray force-pushed the crew/kiro-crew-rust/sidebar-keep-mounted branch from 54e89c2 to 5b70d74 Compare November 14, 2026 10:06
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Nov 14, 2026
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 14, 2026
@buluoray
buluoray force-pushed the crew/kiro-crew-rust/sidebar-keep-mounted branch from 5b70d74 to ce8ecc9 Compare November 14, 2026 11:41
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 14, 2026
Reopening the sessions sidebar on desktop, or the sessions drawer on a
phone, mounted the whole session list again in one main-thread task:
about 90-150 ms on desktop and 100-160 ms on a phone for a long list,
four times that on a slow CPU. The list now renders into a host element
that the drawer adopts while open and lets go of when closed, so
reopening puts the same list back on screen. A phone/desktop switch
still mounts it afresh.

Taking the list out of the document drops the lane's scroll offset, so
the lane scroll memory also restores its anchor row each time the lane
comes back on screen, not only on mount.

A reveal request (a folder or session picked in the command bar) that
arrives while the list is out of the document now waits for it to come
back, as it waited for the mount before.

While closed, the kept list is marked hidden to its overlay layers, so
a menu, context menu or select it had open closes as it does on a
switch to another Crew.
Other layers it opened go with the scope's own overlay
container and come back on reopen, and the drawer slot lets go of the
list only if it still holds it.
The scope's container leaves the document while the sidebar is closed,
so a dialog in it does not claim the composer's Escape, and its layers
learn about the close through a subscription, so closing re-renders
only the layers that read it.
@buluoray
buluoray force-pushed the crew/kiro-crew-rust/sidebar-keep-mounted branch from ce8ecc9 to 36be2c9 Compare November 14, 2026 13:10
@buluoray

buluoray commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=0a051edb7d6a overlayRoot.tsx:169 hidden folder dialogs keep claiming the composer's Escape

fixed in 36be2c9: the scope's overlay container now leaves the document while the sidebar is closed (same element, reattached on reopen), so anotherEscapeOwnerIsOpen() no longer finds a dialog in it; useLocalCrewHidden reads true inside the scope, so a Modal there ignores Escape until it is back on screen.
Tests: ChatPage.sidebarKeepMounted.test.tsx dialog-layer case and overlayRoot.test.tsx off-screen scope cases fail on ce8ecc9.

@buluoray

buluoray commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=db85a8c91a0b useLaneScrollMemory.ts:144 reopen restoration overrides a pending folder reveal

Rebutted as disproportionate, as the adjudication downgraded it: it needs reduced motion, a remembered lane anchor, a reveal requested while the sidebar is closed, and a target folder already expanded so the reveal scrolls inside the 12-frame restore window.
The flash still fires and a second reveal with the sidebar open lands; nothing is lost. Ordering the two hooks would add shared pending-reveal state across modules for this one path.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 14, 2026

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

Reviewed 36be2c9b5d. Approving.

What I checked:

  • AdoptPaneHost only removes the host when it still holds it, so a phone/desktop slot swap that adopts first and unmounts second keeps the list in place.
  • OffScreenOverlayScope takes its own overlay container out of the document while closed, so a dialog left open there no longer answers anotherEscapeOwnerIsOpen. Menus close through the subscription in useCloseWhenCrewHidden, and useLocalCrewHidden reads the same signal through useSyncExternalStore, so a close does not re-render every menu row.
  • useLaneScrollMemory: restore() calls stop() first, which removes the user-intent listeners, so repeated reattaches do not stack listeners. The ResizeObserver restores only on a hidden-to-shown change.
  • reveal.ts: both reveal effects return early while the root is out of the document, and shownTick runs them again on reattach, so a request made while closed still lands, as before.
  • The list is not kept in embed mode (keepPaneMounted = !embedMode), and a form switch still mounts it afresh through the key.

Locally on this head: the 5 changed test files pass (62 tests), and tsc --noEmit is clean. CI is all green, including UX Review and PR Readiness.

@bolichen97
bolichen97 merged commit e51c773 into main Nov 14, 2026
155 of 161 checks passed
@bolichen97
bolichen97 deleted the crew/kiro-crew-rust/sidebar-keep-mounted branch November 14, 2026 14:41
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 14, 2026
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.

3 participants