Skip to content

fix(sidebar): close a pinned folder in one frame so the lane is never blank - #18057

Merged
iamwhatever merged 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/sticky-collapse-blank-lane
Oct 8, 2026
Merged

iamwhatever merged 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/sticky-collapse-blank-lane

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Collapsing a folder from its pinned header closes it in one frame, so the next folder is under that header at once instead of after a ~250 ms blank lane.

After #17581, collapsing a tall folder from its pinned (sticky) header keeps the header in place, but the lane under it is empty for about 250 ms. In #17581's filmstrip (temp-screenshots/17529-sticky-folder-collapse/5-collapse-with-fix-filmstrip.png), the rows stop painting at about 42 ms and "beta folder" appears at about 297 ms. #17581's UX lane raised it, and #17581 merged without the fix, so the fix is this follow-up.

Why it matters

The person was reading a folder and asked to fold it away. For a quarter of a second they see an empty sidebar, which reads as lost content or a broken render.

Not a goal

What changed (motivation → approach → change)

The symptom was a blank lane under a held header for about 250 ms, and it came from the animated close. The hold scrolls the lane so the header stays still. The 150 ms grid-template-rows track then shrinks under a header that does not move, and with the rows hidden at once (the opacity snap), that shrinking track is empty space. After that, the next folder's rows slid up through Framer layout projection (rowAnimEnabled) from hundreds of px below.

Change: a collapse that starts from a pinned header takes the reduced-motion path for that one commit.

  • useHoldPinnedHeaderOnCollapse (stickyCollapse.ts) decides at the click, from the same header reading the hold uses, whether the header is pinned, and exposes instantCloseId. It is committed before the collapse, so the collapsed commit already carries it.
  • FolderBody takes instantClose: while closed it uses transition: none. Opening always animates. The opacity snap stays.
  • ChatSidebar passes instantClose to the list view's folder body and sets rowAnimEnabled = !reduceMotion && instantCloseId === null. The hook keeps its slot in the facade's pinned owner-hook order (ChatSidebar.ownerComposition.test.ts).
  • instantCloseId is released two requestAnimationFrames after the collapse commit, so later reorders animate again. Releasing cannot animate anything, because the track is already at 0fr. It is also cleared by the next arm, disarm, the folder being seen open from any control, and a dropped arm. A dropped pinned arm is released by its own HOLD_ARM_TTL_MS timer, so projection never waits on a later folders change.

Why not keep the animation and fade the next folder in? The space would still be empty while the track shrinks. Only closing in one frame removes the shrinking track.
Why not drop the opacity snap instead? That changes every animated close for every FolderBody caller, and #17581 chose the snap on purpose. With no transition, the pinned path has no closing frame to paint, so the snap no longer matters there.
Why decide at the click? The collapsed commit is the frame that must already have no transition, so the flag has to exist before it renders.
Why not a new mechanism? Both switches already exist as the reduced-motion path (transition and rowAnimEnabled). This reuses them for one commit.

Design note (R3): instantCloseId has one writer, the hook. The release frame and the TTL timer are cancelled on re-arm, disarm and unmount, and the timer acts only on the arm that set it, so a stale release cannot clear a newer arm. No state crosses processes or awaits.

Backwards compatibility

Compatible: instantClose is optional and defaults to the animated close. Every other FolderBody caller is unchanged. Removes nothing.

Tests

  • ChatSidebar.stickyFolderCollapse.test.tsx:
    • in the collapsed commit itself, the body's transition is none, every session row has layout=false, and projection comes back afterwards;
    • the same none under prefers-reduced-motion;
    • a header at its natural place keeps the 150 ms close, read in the commit that hides the body, before any frame runs, and the animated expand.
  • stickyCollapse.test.ts: instantCloseId is set only for a pinned header; it clears when seen open, on disarm and on a dropped arm; it releases on the second frame, not the first (requestAnimationFrame faked); a pinned arm that never renders collapsed is released at HOLD_ARM_TTL_MS with no folders change, and a later arm outlives an earlier arm's timer.
  • ChatSidebar.collapsedFolderGhostHeight.test.tsx: the existing opacity-snap pin is kept unchanged, plus an instantClose unit test.

The new tests fail on origin/main. Mutation pins: removing transition: none, always taking the instant close, dropping the seen-open clear, releasing after one frame, never releasing, dropping the TTL timer, forcing pinned = true (fails the natural-place integration test), and leaving rows projected each turn a named test red.

Run on this head: npx vitest run over all src/test/ChatSidebar*.test.ts*, src/pages/chat-sidebar/*.test.ts* and every test naming FolderBody, stickyCollapse or rowAnimEnabled (183 files, 2641 tests passed); npx tsc -b; npx eslint on the changed files; scripts/check_comment_history.py and scripts/check_brand_name.py.

Manual verification

Built the SPA and ran website/scripts/capture-sticky-folder-collapse.mjs against vite preview on 127.0.0.1, with motion on and with reduce. The header top is 125.14 before and after in both runs.

Screenshots / video

With motion on, the collapse commits between the 28 ms and 45 ms frames. "beta folder" is under the pinned header from 45 ms, nothing slides afterwards, and its sessions paint at 95 ms (see Not a goal). On #17581's head, "beta folder" first appears at about 297 ms.

collapse from a pinned header with this change, frame by frame

Under prefers-reduced-motion this path is the same as on #17581.

the same collapse under reduced motion

Recordings: temp-screenshots/sticky-collapse-blank-lane/1-collapse-pinned-tall-folder.webm, temp-screenshots/sticky-collapse-blank-lane/2-collapse-pinned-tall-folder-reduced-motion.webm.

Related Issues

Closes #18052. Follow-up to #17581 (closes #17529). Leaves #18121 open.

Pattern harvest

Rule candidate: review-prompt
Pattern: "a size transition under a scroll-held sticky header shrinks space the reader is looking at; close it in one frame on that path rather than restyling the shared animated close"

Checklist

  • At most two commits, with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable): module notes in FolderBody.tsx and stickyCollapse.ts; no feature-map row changes
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

…er its header is never blank

Collapsing a tall folder from its pinned header left the lane under the
header empty for about 250 ms. FolderBody faded the rows out at once
while the 150 ms track kept almost its full height, and the next
folder's rows then slid up through layout projection.

A collapse that starts from a pinned header now takes the
reduced-motion path for that commit: the body closes with no
transition and the session rows are out of layout projection, released
two frames later. A header at its natural place keeps the animated
close. The opacity snap is gone.

Closes kirodotdev#18052
@jeeshofone
jeeshofone requested review from a team and KiroCrewCaptain as code owners October 8, 2026 07:22
@jeeshofone
jeeshofone requested a review from bolichen97 October 8, 2026 07:22
@jeeshofone

Copy link
Copy Markdown
Contributor Author

First-pass check: R1-R8 OK.

  • R0, AUTOSDE rules that match the changed files:
    • frontend-tests-are-deterministic: requestAnimationFrame is faked in the release test, and the sidebar tests wait on DOM state, never a clock.
    • recorded-decisions-are-not-regressions: fix(sidebar): keep a pinned folder header in place when it collapses #17581's hold is unchanged. Only the transition and projection for that one commit change, and the reduced-motion behaviour is kept.
    • a-ratchet-may-only-tighten: no baseline is edited.
    • feature-map-correctness: no page, route or handler is added. stickyCollapse.ts is already mapped and its row still describes it.
    • accessible-interactive-elements, errors-use-error-notice, frontend-security, use-framer-motion, session-row-fixed-height: no new control, request, error path or row geometry. aria-hidden, inert and visibility on the closed body are unchanged.
  • R0.3, mutation pins: putting back the opacity, removing transition: none, always taking the instant close, dropping the seen-open clear, releasing after one frame, never releasing, and leaving rows projected each turn a named test red.
  • R1: every hunk serves the Goal. The change reuses the existing reduced-motion switches (transition, rowAnimEnabled) and adds no parallel mechanism.
  • R2: no sensitive path, nothing under .github/, no credential-shaped literal.
  • R3: instantCloseId has one writer. The release frame is cancelled on re-arm, disarm and unmount. Nothing crosses an await or another process.
  • R6.3: under prefers-reduced-motion the body still closes at once and the rows stay unprojected (test, plus filmstrip 2).
  • R8: the body is 7.9 KB and passes pr-description-check.sh for both callers. Local gates are green on the rebased head. No open main-red tracker touches these files.

@Pearcekieser, this does not touch the scroll position or holdPinnedHeaderThroughCollapse. It changes only how fast the body closes and whether rows animate in that one commit, so your near-end scroll-floor follow-up should stack cleanly on top.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 9ebe28384157971eeb0d796fa9aa956d35634261 via the fork AI-review pipeline — 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/CONCERNS are advisory.

First-Principles-Verdict: PASS

The only check that the rows stop sliding after the two-frame release is #18052's filmstrip. The unit test fakes requestAnimationFrame.

What this change ships

Inventory (6 items) — 6 justified

Intent: when someone collapses a folder from its pinned header, the next folder shows up under that header at once, with no ~250 ms blank lane. This is a FIX (closes #18052).

  1. A collapse from a pinned header closes in one frame instead of the 150 ms animation — justified
  2. For that one commit the next folder's rows appear in place instead of sliding up from below — justified
  3. Row animation returns two frames after the collapse, so later reorders still animate — justified
  4. A pinned click whose collapse never renders releases on the existing HOLD_ARM_TTL_MS clock — justified
  5. A new optional instantClose on FolderBody, used only by the list view's folder body (1 of 4 <FolderBody sites; the hold has 1 caller) — justified
  6. Committed filmstrips and recordings under temp-screenshots/sticky-collapse-blank-lane/ — justified

[FIRST-PRINCIPLES-REVIEWED] 9ebe283

Description read

[DESCRIPTION-READ] 24daf16c5fa9b3ed8d598d12497fd7b5d8e988e4a09d9d507b506f5b5c01b9f2

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 Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of 9ebe28384157971eeb0d796fa9aa956d35634261 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Watch the motion-on recording: frames 45–77 ms of filmstrip 1 still show an empty lane under "beta folder". That gap is left to #18121.

[UX-REVIEWED] 9ebe283

Description read

[DESCRIPTION-READ] c988b5f3a6d7e18033a4770083186121b952bc95fe265b5d4faaccdbfd878f19

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 Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 9ebe28384157971eeb0d796fa9aa956d35634261 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check in a real browser that switching all rows' Framer layout off and back on during an unrelated reorder in that two-frame window causes no visible jump.

[DESIGN-REVIEWED] 9ebe283

Description read

[DESCRIPTION-READ] 6d15117fff57a7b028fb07a395b41b5cd0c5f57b6ac8a39bce3bdb58fb91cd10

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 Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 9ebe28384157971eeb0d796fa9aa956d35634261 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 9ebe283

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 9ebe28384157971eeb0d796fa9aa956d35634261 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 9ebe283

@jeeshofone

Copy link
Copy Markdown
Contributor Author

ai-review-disposition target=first-principles head=9f0a9928ee

Fixed on 9f0a992: the single blocker, item 3.

  • FolderBody.tsx has opacity: open ? 1 : 0 back. Against base 1c5a71d the opacity line is unchanged, so no FolderBody caller's animated close changes (board view, CrewGroups, DesignTweakPage, unpinned list headers).
  • stops the rows painting the moment it closes, with opacity on the box itself in ChatSidebar.collapsedFolderGhostHeight.test.tsx is restored verbatim, and the opacity assertion added to ChatSidebar.stickyFolderCollapse.test.tsx is dropped.
  • The PR now ships items 1, 2 and 4. The description's Not a goal names every animated close as unchanged, and its "Why not drop the opacity snap instead?" line records why.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

ai-review-disposition target=ux head=9f0a9928ee

Evidence gap (unpinned, board and CrewGroups closes): there is no longer a change there to record. On 9f0a992 the opacity removal is reverted, so FolderBody's animated close is byte-identical to base 1c5a71d for every caller. The only behaviour change is transition: none (and rows out of layout projection) for the one commit that collapses from a pinned header. ChatSidebar.stickyFolderCollapse.test.tsx pins that a header at its natural place keeps the 150 ms close and the animated expand.

Watch (rows paint at 95 ms): agreed, the description over-claimed. It now says "beta folder" is under the header from 45 ms and its sessions paint at 95 ms. The same gap shows on main's existing reduced-motion collapse (filmstrip 2: empty lane at 24 ms, rows by 86 ms), and this PR does not change that path, so the gap does not come from the transition. It is filed as #18121 with the likely cause (content-visibility: auto on .session-row, not yet confirmed) and the experiment that settles it, and the description lists it under Not a goal. The ~250 ms blank lane this PR targets is gone.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

ai-review-disposition target=design head=9f0a9928ee

Watch 1 (opacity removal out of scope): cleared by its first condition. The opacity change is dropped on 9f0a992, and FolderBody's animated close matches base for every caller.

Watch 2 (remaining blank under the next folder, frame timings): the description's timings now match the committed filmstrip. The collapse commits between 28 and 45 ms, "beta folder" sits under the header from 45 ms, and the sessions paint at 95 ms. Main's reduced-motion collapse, which this PR leaves alone, shows the same short gap, so it does not come from the transition change. It is tracked in #18121 (likely content-visibility: auto on .session-row, unconfirmed) and listed under Not a goal.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

CI on 38425b4, disposition for head 9f0a992

  • Frontend Tests (1), ours, fixed. The failing test was ChatSidebar.ownerComposition.test.ts > calls every owner hook once, in the pinned order, because 38425b4 moved useHoldPinnedHeaderOnCollapse ahead of useFolderFilterReveal. On 9f0a992 the hook is back in its pinned slot, and rowAnimEnabled is derived right after it. The file passes locally (7/7).
    The No "PinnedPrompt" export is defined on the "../pages/chat" mock line in that log is stderr from ChatPage.steerKeyIdentity.test.tsx, a file that passes. That line prints on bare origin/main 791b10a as well, with the file passing 9/9, and this PR touches neither ChatPage nor pages/chat. Frontend Coverage Merge and Coverage Gate failed closed on this shard.
  • Backend Tests (Windows) (2), not ours. test_native_skill_projection.py::test_prune_scans_the_lease_directory_once_for_many_candidates failed with "unleased candidates are walked and reclaimed". This PR changes only website/ and temp-screenshots/, so the backend code matches base 1c5a71d. Main's push CI passed Windows (2) on that base and on the next two main heads (runs 37742137815, 37743995106, 37747910016), and the test passes 3/3 on Linux on main 791b10a. Filed as test_prune_scans_the_lease_directory_once_for_many_candidates fails intermittently on Windows #18117: the test runs on the prune's real-clock budget.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 8, 2026
FolderBody hides the closing rows with `opacity: 0` again, so every
animated close (unpinned list headers, the board view, CrewGroups,
DesignTweakPage) paints exactly as it does on main. Only a collapse
from a pinned header changes: it closes with no transition, which on
its own leaves no closing frame for the lane to read as blank.

useHoldPinnedHeaderOnCollapse goes back to its place in the facade's
pinned owner-hook order, and rowAnimEnabled is derived right after it.
@jeeshofone
jeeshofone force-pushed the fix/sticky-collapse-blank-lane branch from 9f0a992 to 9ebe283 Compare October 8, 2026 14:26
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 8, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 8, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Disposition for head 9ebe283 (follow-up to the independent review of 9f0a992)

First-pass check: R1-R8 OK.

  • N2, fixed in stickyCollapse.ts. A pinned arm whose collapse never renders collapsed used to leave instantCloseId set, and with it row projection off, until some later folders change after the TTL. Now armHold starts a HOLD_ARM_TTL_MS timer for a pinned arm. When the timer fires it releases the flag and the arm, but only if that arm is still the pending one. The timer is cancelled on re-arm, disarm and unmount, together with the release frame. The release no longer depends on a folders reference change. New fake-timer tests in stickyCollapse.test.ts:
    • "releases a pinned arm whose collapse never renders at the TTL, with no folders change";
    • "a pinned collapse that renders is not cut short by the TTL timer" (an earlier arm's timer cannot clear a later arm).
      Mutation check: with the timer disabled, the first test fails.
  • N3, fixed in ChatSidebar.stickyFolderCollapse.test.tsx. The natural-place test now records the body's transition in the commit that first sets aria-hidden="true", using a MutationObserver, before any frame runs. Mutation check: forcing pinned = true in armHold makes this test fail. It passed under that mutation before.
  • N1: no code change. It is in the body under Not a goal. onMutate awaits cancelQueries before its optimistic write, so instantCloseId commits one render before the collapse. Row projection is off for that commit, but nothing changes layout in it.

Lane notes on 9ebe283, all PASS:

  • First Principles (the filmstrip is the only check that rows stop sliding after the release): yes. jsdom cannot show projection. Filmstrip 1 shows nothing moving after the release frame. The unit test pins the two-frame timing.
  • UX (frames 45-77 ms of filmstrip 1): that gap is Session rows paint a few frames after their folder rises into view on a collapse #18121. It also shows on main's reduced-motion collapse, so this PR does not cause it.
  • Design (projection toggled during an unrelated reorder): the window is two frames after a click, and projection only switches off for a pinned collapse. A reorder landing inside it would snap instead of slide, the same as with reduced motion. No jump is introduced.

Tests run on 9ebe283: npx vitest run over the 183 test files that name ChatSidebar, FolderBody, stickyCollapse or rowAnimEnabled (2641 passed); npx tsc -b; npx eslint on the 6 changed source and test files; the comment-history gate against origin/main; scripts/check_brand_name.py. CI: 91 success, 12 skipped, 0 failed, readiness passed.

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

This PR fixes the ~250 ms blank lane after you collapse a folder from its pinned header, and it fixes the root cause. The animated grid-template-rows close was shrinking an empty track under a header the hold keeps still, and Framer projection then slid the next folder up from far below. For that one collapse commit, the PR reuses the existing reduced-motion path: FolderBody gets transition: none, and rowAnimEnabled is off while instantCloseId is set. Every other caller keeps the animated close and the opacity snap byte-for-byte. I read the full production diff (stickyCollapse.ts, FolderBody.tsx, ChatSidebar.tsx) and traced how instantCloseId is released. It clears after two rAFs once the collapse renders, on re-arm and disarm, when the folder is seen open, when the folder is gone, and through a per-arm TTL timer that only clears its own arm, so projection cannot stay off. The tests pin the pinned path in the collapsed commit, the natural-place 150 ms close (read with a MutationObserver before any frame), and the TTL release, and the author reports mutation checks. All checks on head 9ebe283 are green, and GPT, Opus, Design, UX and First Principles all PASS. Earlier design, UX and first-principles concerns got dispositions, including dropping the out-of-scope opacity change. This is a fork PR, so the committed temp-screenshots evidence is the allowed path. — crew-pr-reviewer

@iamwhatever
iamwhatever enabled auto-merge (squash) October 8, 2026 16:42
@iamwhatever
iamwhatever merged commit b3aaae0 into kirodotdev:main Oct 8, 2026
104 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

2 participants