Skip to content

fix(sidebar): hold a scroll floor when a pinned folder collapses near the end of the list - #18130

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:fix/17529-near-end-scroll-floor-main
Oct 9, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:fix/17529-near-end-scroll-floor-main

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Collapsing a pinned folder near the end of the sessions list leaves the closed folder as the top row, instead of the list sliding down.

#17581 fixed the main jump from #17529, where a folder with more folders below it collapsed and its header vanished off the top. One layout is still open. Collapse a pinned folder that sits near the end of the list, with too little below it to fill the lane. holdPinnedHeaderThroughCollapse scrolls the lane back correctly. Then the body closes, the list becomes shorter than that scroll position, and the browser clamps scrollTop. The whole list slides down. In Chromium on #17581's head the collapsed header goes from 40px to 80px below the top of the lane, and the folder above comes back into view. Steps are in my comment on #17581 (#17581 (comment)), and jeeshofone agreed there that a scroll floor stacked on their hold is the right shape for it.

Why it matters

The last folder in the list is a common one to collapse, and it's the one where the jump still happens. The person loses their place: the folder they just closed moves down a row and a different folder takes its spot.

Not a goal

  • Changing the shared FolderBody close animation, including the blank pane under a tall folder during its close.
  • The board view, whose folder headers aren't sticky.
  • Expanding a folder, which doesn't move the list.

What changed (motivation → approach → change)

website/src/pages/chat-sidebar/collapseFloor.ts (new) holds a scroll floor through the collapse. The tree lane in website/src/pages/ChatSidebar.tsx now starts with a zero-height anchor holding one hidden, absolutely positioned 1px marker. holdPinnedHeaderThroughCollapse in website/src/pages/chat-sidebar/stickyCollapse.ts calls holdScrollFloor just before it scrolls. That places the marker so the lane's scroll height can't drop below the held position while the body closes. The marker is out of flow, so it doesn't change the lane's layout. It only extends the scrollable area. The result is blank room under the list. As the person scrolls up, the floor follows the highest point they reach, and it's removed once the content alone reaches it. With folders below there's nothing to hold, so the floor is released about a second after the collapse (FLOOR_SETTLE_MS). That check compares the lane's scrollHeight with the marker's own bottom edge and never hides the marker, because taking it out of layout lets the browser clamp scrollTop. A child's rect won't work, because the lane's last child is a flex-1 min-h-0 box clamped to the lane height. docs/feature-map/README.md lists the new helper next to stickyCollapse.ts.

Backwards compatibility

Compatible: the floor is a new out-of-flow element inside the tree lane, and holdPinnedHeaderThroughCollapse keeps its signature and still does the plain hold when no anchor is present.

Removes nothing: the change adds a marker element and a scroll adjustment, and takes no path, key or behaviour away.

Tests

  • website/src/test/collapseFloor.test.ts, run through holdPinnedHeaderThroughCollapse, covers three cases. First, the floor is held near the end of the list, lowered on scroll-up, never raised on scroll-down, and removed once the content reaches it. Second, the floor drops once the collapse settles when content below fills the lane. Third, a lane with no anchor still gets the plain hold.
  • website/playwright/sidebar-folder-collapse-floor.spec.ts runs in real Chromium. It collapses a pinned folder from the header toggle with native scroll anchoring on and from the rail with it off, once with a long folder below and once near the end, for 4 cases. Both controls reach the floor through one call site, so crossing every control with every anchoring mode added about a minute to the shared E2E run without covering more of the floor. It checks that the header stays where it was pinned, that the next folder sits directly below it, that the header is still held after the floor's settle check and moves by exactly 20px on a 20px scroll up, that the floor releases on its own when rows fill the lane, and that it's gone after scrolling back up.
  • The existing stickyCollapse.test.ts and all 111 ChatSidebar* test files (1155 tests) pass, and so do tsc -p tsconfig.app.json, eslint and npm run i18n:check.

Manual verification

I ran the Playwright spec in Chromium against a harness gateway serving this branch's build, rebased on main after #17581 merged, and all 4 cases pass in 27 s. On #17581's head alone the near-end cases fail with the header 40px lower. I haven't checked Safari or Firefox.

Screenshots / video

Before, with #17581 alone and the folder near the end: the list slides down and the collapsed folder drops a row.

before, folder near end

After, with the floor: the collapsed folder stays the top row, with blank room below that goes away as you scroll up.

after, folder near end

Related Issues

Refs #17529, the near-end case left after #17581.

Pattern harvest

Not generalizable: the clamp comes from this one lane shrinking under a held scroll position during a collapse animation, and the floor is the fix for that one layout.

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@Pearcekieser
Pearcekieser requested review from a team and KiroCrewCaptain as code owners October 8, 2026 11:05
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Oct 8, 2026
@github-actions github-actions Bot added 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

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 3a44bbb35e23b47c9430a3707a82f4cfb943dde9 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 the near-end collapse in Safari and Firefox. The author tested only Chromium, and the floor relies on how each engine clamps scrollTop while the marker holds the scroll height.

[DESIGN-REVIEWED] 3a44bbb

Description read

[DESCRIPTION-READ] 5eecf017f276668ef2918b5c2d35b8a9f939bb5652f84586a66b8463a8ec20d8

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

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

Premise-level review of 3a44bbb35e23b47c9430a3707a82f4cfb943dde9 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

Check that the blank space left under the list after the collapse is acceptable, and that the floor works in Safari and Firefox. The author tested only Chromium.

What this change ships

Inventory (5 items) — 5 justified

Intent: when someone collapses a pinned folder near the end of the sessions list, the folder stays as the top row instead of the list sliding down. This is a FIX (Refs #17529, the near-end case left open after #17581, with a Playwright reproduction that fails on #17581's head).

  1. Collapsing a pinned folder near the end of the list keeps it as the top row. The list no longer slides down. — justified
  2. After that collapse, blank room shows under the list and shrinks as the person scrolls up. — justified
  3. When folders below fill the lane, the floor goes away on its own about a second after the collapse. — justified
  4. The tree lane has a new hidden, zero-height floor element as its first child. — justified
  5. Before/after GIFs are committed under temp-screenshots/, which .gitignore allows for fork contributors. — justified

[FIRST-PRINCIPLES-REVIEWED] 3a44bbb

Description read

[DESCRIPTION-READ] 5afd71570846448cbe4168d324512865c8277c9c49741e7d769b340958a33807

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 3a44bbb35e23b47c9430a3707a82f4cfb943dde9 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 "after" recording to check that the blank space left under the list after a near-end collapse doesn't look like a broken or half-loaded list.

[UX-REVIEWED] 3a44bbb

Description read

[DESCRIPTION-READ] a571efc112d7a5763f7dc26957dfe8b0b9d498b6d03112908b8c453c0301f99b

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

GPT 6.1 Review (fork) — ✅ no blocking findings

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

Review details

No findings.
[GPT-REVIEWED] 3a44bbb

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 8, 2026
@Pearcekieser
Pearcekieser force-pushed the fix/17529-near-end-scroll-floor-main branch from ff04506 to 601777c Compare October 8, 2026 11:22
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Fixed in 601777c7a5. GPT F1 at website/src/test/collapseFloor.test.ts:55 is upheld: the vitest teardown now clears the DOM with document.body.replaceChildren() instead of the HTML setter, so the frontend-security rule no longer matches and the Automated Rule Check should pass on this head.

The Semgrep test-sleep-as-barrier hit on test/test_favorite_projects.py:121 came from main, not this diff. That file arrived with #16611 after this branch's base. The branch is now rebased onto current main, so the diff-only scan no longer includes it.

Verified locally: the 3 floor tests and the 21 sticky-collapse tests pass, and tsc -p tsconfig.app.json is clean. The behaviour is unchanged, and the rest of the diff is identical to ff04506057ad.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 3a44bbb

@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

@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 targets the near-end case #17581 left open: collapsing a pinned folder near the bottom of the sessions list makes the browser clamp scrollTop, so the list slides down. It adds a zero-height scroll floor so the held position stays reachable. The approach goes at the real cause (scroll height drops below the held offset), and checks are green. But the current-head Opus finding is still unanswered, and I think it is real. In website/src/pages/chat-sidebar/collapseFloor.ts, contentHeight() sets marker.style.display = 'none' and then reads lane.scrollHeight. That forces a layout in which the content is shorter than scrollTop + clientHeight. Chromium and Firefox clamp the scroll offset during that layout, and restoring display does not bring scrollTop back. So the 1000 ms settle timer (releaseIfUnneeded), or any small upward scroll, can bring back the exact slide in the tail case. The Playwright spec's settled() probe finishes before FLOOR_SETTLE_MS, so nothing exercises this. Suggested fix: measure the content's bottom without taking the marker out of layout, for example with a zero-height end-of-content sentinel read through getBoundingClientRect() + scrollTop. Then add a tail-case assertion that waits past FLOOR_SETTLE_MS and checks that the collapsed header is still at its held position. The committed GIFs under temp-screenshots/ are acceptable because this is a fork PR. — crew-pr-reviewer

@Pearcekieser
Pearcekieser force-pushed the fix/17529-near-end-scroll-floor-main branch from 601777c to 3f306c6 Compare October 9, 2026 00:59
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): Fixed in 3f306c6416. The Opus finding on website/src/pages/chat-sidebar/collapseFloor.ts is upheld, and so is the review from @iamwhatever. contentHeight() hid the floor marker to read lane.scrollHeight, which forced a layout shorter than the held offset, so the browser clamped scrollTop and the tail case slid at the 1000 ms settle check or on a small scroll up.

The release check now leaves the marker in layout. It compares lane.scrollHeight with the marker's own bottom edge, so any extra height can only come from content. I did not use an end-of-content sentinel read through getBoundingClientRect(): the rows sit in nested flex-1 min-h-0 boxes clamped to the lane, so a sentinel there reads the clamped bottom, not the content bottom.

The Playwright spec now covers the settle window. The anchor gets data-collapse-floor=settled when the settle check runs, and the spec waits for that attribute instead of a fixed sleep. It then asserts the collapsed header is still at its held position, and that a 20px scroll up moves the header by exactly 20px. With the old measurement restored, the tail case with scroll anchoring off fails, with the header moving from 40px to 80px. With the fix, all 8 Chromium cases pass. A new unit test asserts the marker is never hidden during a read; it fails on the old code and passes now. Sticky-collapse tests, tsc -p tsconfig.app.json and eslint are clean. Still one commit.

@iamwhatever could you re-review when CI is in?

@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: passed Eligible automated validation passed for the current revision readiness: action required A blocking check or review needs attention labels Oct 9, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): The one red check on 3f306c6416 is E2E (stub ACP backend, offline), and it comes from outside this diff. The Playwright suite itself passed 328 of 328. The failure is in the dedicated memory UI evidence run: member-memory.spec.ts:594 was interrupted while openMemory() waited 5 s for "Memory for memory-e2e-bulk-v2-..." on /settings/overview?view=memory. This PR changes only the sessions sidebar collapse path (collapseFloor.ts, stickyCollapse.ts, the tree lane's first child) and never renders on the settings memory page. All other 94 checks pass. A fork cannot rerun a job, so I have queued one same-tree retrigger for the next free CI slot; a maintainer rerun of that one job would also clear it.

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Oct 9, 2026
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Oct 9, 2026
@Pearcekieser
Pearcekieser force-pushed the fix/17529-near-end-scroll-floor-main branch from 3f306c6 to b3fa83d Compare October 9, 2026 03:45
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Same-tree retrigger pushed as b3fa83d8a9. The tree is identical to 3f306c6416, and only the commit date changed. It reruns the E2E (stub ACP backend, offline) job, whose only failure was member-memory.spec.ts:594 in the memory settings page, outside this diff. The evidence is in the earlier comment. A fork cannot rerun a single job, so a new head is the only retrigger available.

@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 Oct 9, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue: E2E (stub ACP backend, offline) failed again on b3fa83d8a9, and this time I traced it to the run's time bound rather than a flake.

Both failing runs stop with Playwright ran 1020s, past the 1020s bound in test/test_playwright_e2e.py. The member-memory test is only the one that happened to be running when the bound hit, which is why a different test failed each time: :594, then :702. The "Run E2E" step took 1089s and 1091s on this PR's last two heads and 1064s on 601777c7a5, which passed just under the bound. Recent main runs take 766 to 844s on the self-hosted runners. This PR's runs land on GitHub-hosted runners, and another fork PR on a GitHub-hosted runner, fix/paste-chip-scroll-desync, took 1069s.

This spec is part of that overrun. The run's report gives sidebar-folder-collapse-floor.spec.ts 62s, the 4th-largest file in the suite. So the next head cuts it in half: 4 cases instead of 8. Each anchoring mode is now paired with one control instead of crossed with both. Both controls reach the floor through the single holdPinnedHeaderThroughCollapse call site, so the dropped combinations covered no extra floor code. The kept cases include the rail with anchoring off near the end, which is the one that failed with the old release check. Locally, against a harness gateway, the 4 cases pass in 27s; the 8-case version took 54s on the same host. The description is updated to match, and it also now describes the current release check, which no longer hides the marker.

The push waits for a CI slot.

@Pearcekieser
Pearcekieser force-pushed the fix/17529-near-end-scroll-floor-main branch from b3fa83d to c2bbc94 Compare October 9, 2026 06:03
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 9, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Replies to the First Principles and UX lanes on c2bbc944f7.

note (non-blocking): span=15cdeeeffdc0, FLOOR_SETTLE_MS = 1000 versus FOLDER_BODY_COLLAPSE_MS. I tried taking the delay from the shared constant, as FOLDER_BODY_COLLAPSE_MS * 2 or 300 ms, rebuilt, and ran the Playwright spec twice against a harness gateway. The second run failed collapse via folder rail (overflow-anchor: none, tail) with the collapsed header 40px below where it was pinned, the same jump this PR fixes. The settle check releases the floor once the content alone reaches it, so a release that lands while the body and the rows below are still settling drops the floor too early, and the lane clamps. The 150 ms transition is not the whole wait. FolderBody's layout-suppression timer fires at the same mark and needs its own render, and on a loaded main thread both start late. 1000 ms passed every run so far. I kept it, and the reason is now measured.

note (non-blocking): span=82a3e303ee3b, data-collapse-floor="settled" has no production reader. That is intended. It lets the spec wait for the settle check by polling an attribute instead of sleeping past FLOOR_SETTLE_MS, and the repo's flake ratchet rejects a sleep used as a barrier. It costs one attribute write per collapse, and release() clears it.

thought (non-blocking): span=11a50a8e746b, the blank room below the list. It is the price of keeping the header where it was pinned when too little content is left below it. It only shows when the collapsed folder is near the end, it shrinks as the person scrolls up, and it goes away once the content reaches the floor. Without it the browser clamps scrollTop and the list slides down by the closed body's height.

note (non-blocking): span=d2ae76f742dc, only Chromium checked. The spec runs with Chromium's scroll anchoring on and off. Turning it off approximates Safari, which has no scroll anchoring. I have not run Safari or Firefox, and the description says so.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 9, 2026
@Pearcekieser
Pearcekieser force-pushed the fix/17529-near-end-scroll-floor-main branch from c2bbc94 to 3a44bbb Compare October 9, 2026 06:45
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Rebased on main as 3a44bbb35e with no behaviour change. The only conflict was the Session folders row in docs/feature-map/README.md, where I kept main's text and re-added the collapseFloor.ts entry.

The E2E (stub ACP backend, offline) run on c2bbc944f7 took 799s, inside the 1020s bound, so the cut to 4 cases did what it was meant to. It failed only on the retry ratchet, because session-tags-e2e.spec.ts case 17b passed on its second attempt. That spec is outside this diff. The Integration failure on that head was the test_owner_only_boot breakage main has since fixed, and this rebase gives CI a fresh merge commit that includes the fix.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 9, 2026

@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 near-end case left open by #17581. Collapsing a pinned folder near the bottom of the sessions list let the browser clamp scrollTop, and the list slid down. The root cause is addressed: a zero-height scroll floor in website/src/pages/chat-sidebar/collapseFloor.ts keeps the held offset reachable until content alone reaches it. iamwhatever's earlier request is addressed. contentPastFloor() now compares lane.scrollHeight against the marker's own bottom edge with the marker left in layout, so the forced-layout clamp is gone. The Playwright spec waits for data-collapse-floor=settled, then asserts the header is still held past FLOOR_SETTLE_MS and moves exactly 20px on a 20px scroll-up. The author reports that this spec fails with the old measurement restored. I read the production diff and the spec on head 3a44bbb (one commit). All checks pass, and every AI lane (Design, First Principles, UX, GPT, Opus) is PASS or clean on this head. The committed GIFs under temp-screenshots/ are acceptable because this is a fork PR. — crew-pr-reviewer

@iamwhatever
iamwhatever enabled auto-merge (squash) October 9, 2026 19:33
@iamwhatever
iamwhatever merged commit 4a39624 into kirodotdev:main Oct 9, 2026
104 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 9, 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

Development

Successfully merging this pull request may close these issues.

2 participants