Repository navigation
feat: add a collapse all folders action to the sessions sidebar - #31330
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Issue #11553 is the record for this new menu item. The one-write route is the smallest way to avoid a tree left half closed. One response field has no reader. Notes
What this change shipsInventory (5 items) — 4 justifiedIntent: let a person close every sidebar folder in one click and then reopen only the branch they need. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 2a90c1d Description read[DESCRIPTION-READ] ce6cef5c0b136215709798f2a54727f8537733014ee20fac8ed2b5fc5ee425ef That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change only adds things, does the collapse in one atomic write the same way reorder and cleanup do, and has screenshots for this revision. [DESIGN-REVIEWED] 2a90c1d Description read[DESCRIPTION-READ] b7e32c33764d0f105accc810595128feb82be494985a0ca9ea1603140ef981b6 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 |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. The blind reader read "Collapse all folders" correctly and said they would click it. Both themes are shown, before and after the click and with the item hidden. Notes
[UX-REVIEWED] 2a90c1d Description read[DESCRIPTION-READ] 2b4cfa38edd3d8dfdde9d05815f223417e06f7017b7057a382e5b50d1ae7dcef That sha256 names everything this verdict read: the PR description, plus the 11 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 |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
56bb06b to
8eb5824
Compare
8eb5824 to
7f694f0
Compare
7f694f0 to
736a885
Compare
736a885 to
7d16a42
Compare
086f569 to
bbbb46e
Compare
|
[operator: bolichen97] Rebased: main moved in the line-budget and platform collect-ignore tests (fixed on main by #32252 and #32209) since this head went red (eaf86e9 -> f58c3cf); CI re-running. The patch is unchanged (git range-diff shows the same commit); changed backend and frontend tests, flake8, isort, mypy and tsc pass locally, and local GPT and Opus reviews of bbbb46e passed. AI-assisted, posted on behalf of bolichen97 |
buluoray
left a comment
There was a problem hiding this comment.
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:
APPROVE at bbbb46e.
What it does for users: the sessions sidebar's header ⋮ menu gains "Collapse all folders". It appears in the folder tree view while any folder is open and closes the whole tree in one click. Before this, each folder had to be closed through its own disclosure. Nothing existing changes. The only other collapse-all strings in the catalog belong to a different surface, so this does not duplicate a sidebar control (issue #11553 asks for it).
Evidence:
- Route (chat_folders_routes.py:1194-1242): one mutate_folders pass flips only
collapsedon the folders that are open. It pushes a slots update only when something changed and writes one audit line with the count. Like the reorder route, the literal path is registered before the "{id}" delete (routes/sessions.py:116-117). - Caller fence: the route first runs _refuse_unattributable_caller, then refuses any non-person principal with 403 folder_collapse_all_forbidden. folder_principal (dashboard caller module, lines 960-985) returns a value for both app and crew-member callers, so the docstring's "an app or crew member is refused" is accurate. This matches PATCH, through which an app may collapse only folders it owns.
- Client (folders.ts:506-529): the cached tree closes optimistically, the request goes out once, and a failure shows the error notice and refetches. Offline, the cached tree closes and nothing is sent, the same as the single-folder toggle. The menu item is hidden in the board view, whose per-column collapse overrides this write does not clear (SidebarHeader.tsx:109-115).
- The label is present in all 13 locale catalogs. The dashboard spec row and the feature map name the menu item and the route in the same commit.
Mutation: the principal refusal changed to if False. Result: test_an_app_is_refused_and_nothing_is_written goes red; restored and the tree checked clean.
Tests: test_chat_folder_collapse_all plus test_chat_folder_reorder_atomic gave 24 passed. ChatSidebar.collapseAllFolders.test.tsx plus ApiClient.refactor.surface.test.ts gave 188 passed.
CI at this head: 82 success, 11 skipped, 1 failure. The failure is Sensitive Change Review, which could not read the PR from the API ("API rate limit exceeded for installation"). That is an infrastructure failure, not a finding, and the check needs a re-run. PR Readiness and both CodeBuild statuses are success. The GPT, Opus, Design, UX and First Principles lanes all report PASS or no findings. It merges cleanly with main.
Source-only: the light and dark rendering, judged from the screenshots in the description.
Follow-ups (non-blocking):
- The test refuses only an app caller. A crew-member caller is refused by the same principal check and by the chat gate, but no test pins the member arm of this route.
- The single-folder toggle in the list view keeps a pinned sticky header in place (armHold). Collapse-all does not, so the list may jump when a pinned header's folder closes. This is cosmetic and not a regression.
|
HOLD at bbbb46e. This head conflicts with main. GitHub reports it as CONFLICTING, and a local merge against 0850c67 conflicts in The PR also adds a new route, Non-blocking UX notes: the open chat is hidden once its folder closes, which the description lists as not a goal, and no screenshot shows the menu once every folder is closed. — crew-pr-reviewer (r149) |
[operator: bolichen97] |
A grown folder tree could only be reset one disclosure at a time. The sidebar header menu now offers "Collapse all folders" in the folder tree view while any folder is open. It sends one request to a new POST /api/chat/folders/collapse-all route, which closes every folder in a single folder-store write, so the tree is never left half closed and nothing else on a folder changes. An app is refused, since through PATCH it may collapse only the folders it owns. Closes #11553
bbbb46e to
2a90c1d
Compare
|
Rebased: main moved in [operator: bolichen97] |
|
[operator: bolichen97] Answering the HOLD at
|
|
[operator: bolichen97] On the review's first follow-up (no test pins the crew-member arm of The member arm is not a separate branch. The handler refuses on one condition, |
|
[operator: bolichen97] On the review's second follow-up (collapse-all does not arm the pinned sticky-header hold the single-folder toggle uses): keeping it as is. The hold ( |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving. On this head the review read the full diff and checked four things. The new POST /api/chat/folders/collapse-all route runs as one mutate_folders transaction that changes only collapsed. The store write is confirmed before the slots update is pushed, and nothing is written when no folder is open. The frontend mutation shares CHAT_FOLDERS_WRITE_KEY with the single-folder toggle. The menu row shows only in tree view. The backend test drives the real FolderRepository.mutate and asserts one write with every other field unchanged. The vitest test asserts one bulk request and no per-folder PATCH. Done well: the route reuses the existing folder guards instead of adding new ones, and it is hidden in board view, where per-column collapse state would make a global write wrong.
Security: the route first refuses an unattributable caller. It then refuses any app or crew member principal with a 403 and writes a SEL event for both the allowed and the denied outcome. The person and agent callers it admits could already set collapsed on any folder one at a time through PATCH, because it is a layout-only field. So the route grants no new authority and cannot claim an agent-created folder.
Optional:
- Add a test for the
_refuse_unattributable_callerline (POST withX-Session-Key: dashboard:chat-1-100and empty_slots, expect 403caller_unattributableand no write). Every sibling folder write has this test. - A crew member is refused at the chat gate today only because
collapse-allparses as a folder id that admits PATCH alone. Addingcollapse-allto the reserved-literal tuple in_shared_route_guards.py, or a row intest_member_chat_folders_gate.py, would pin that. countin the response has no reader. Returning{"ok": True}like reorder would keep the contract smaller.
Problem / Motivation
Goal: Let someone close every folder in the sessions sidebar with one click, so a grown folder tree can be reset and only the branch they need reopened.
The sessions sidebar has no single action that collapses every folder. Each folder has to be closed through its own disclosure, so the cost of resetting the tree grows with every folder added, which hits hardest the people who use nested folders the most.
Builds on #16035 by @tim-finnigan.
Why it matters
People who route their work through nested folders end up with a tall sidebar of mostly irrelevant context. Today the reset is manual and gets longer as the tree grows, so the folder tree becomes less useful the more it is used.
Not a goal
What changed (motivation → approach → change)
Folder collapse state is stored on the server, one folder per
PATCH /api/chat/folders/{id}. Done that way, a collapse-all would be one request per open folder, which can fail halfway and leave the tree half closed, and writes one audit line per folder.So the reset is one write. A new route,
POST /api/chat/folders/collapse-all, setscollapsedon every folder in a single pass under the folder-store lock, the same all-or-none shape asPOST /api/chat/folders/reorder. It changes nothing else, andcollapsedstays a layout field, so it never claims a folder an agent created. An app caller is refused (folder_collapse_all_forbidden), because throughPATCHan app may collapse only the folders it owns; a crew member is already refused at the chat gate.In the sidebar, the header ⋮ menu gains Collapse all folders, next to Clean up empty folders. It shows in the folder tree view while at least one folder is open. The click closes the tree at once in the cached list and sends that one request; if the request fails, the error notice says so and the refetch redraws what the server holds. Offline it closes the cached tree and sends nothing, the same as a single folder's toggle. The dashboard spec and feature map name the route and the menu item.
dashboard/chat_folders_routes.py,dashboard/routes/sessions.pyapi/client/chatOrganization.tschat-sidebar/SidebarHeader.tsxchat-sidebar/folders.tsi18n/locales/en.jsonand each other locale (pages.chatSidebar.collapse_all_folders)Backwards compatibility
Compatible: one new route and one new menu item. No existing route, stored field or behaviour changes.
Removes nothing: the diff adds a route, a client method, a menu row and a string, and takes nothing away.
Tests
test/test_chat_folder_collapse_all.py: one request closes every folder in exactly one store write, leaving every other field (order, parent, owner, the agent-created mark) unchanged; an app caller gets 403 and nothing is written.website/src/test/ChatSidebar.collapseAllFolders.test.tsx: the header menu item closes the tree and sends exactly one collapse-all request, never a per-folderPATCH.website/src/test/ApiClient.refactor.surface.test.ts: the new client method takes its place in the method order.Determinism: the backend file passed 20 runs at
-n0, then 10 runs at-n 4 --dist loadgroup --max-worker-restart=2besidetest_chat_folder_reorder_atomic.pyandtest_chat_folder_cleanup.py, and a shuffled order with seed 27021. The vitest file passed 5 runs with--sequence.shuffle, seeds 27022 to 27026, besideChatSidebar.flatFolderFilter.test.tsx.Manual verification
Ran this change at commit
056101c4d4(the same diff as this head, one rebase onto main earlier; main has changed no sidebar file since) as an isolated gateway on loopback, with a throwaway data home seeded from therichfixture plus a few folders, one of them nested, and drove it with scripted Playwright. Opened the header ⋮ menu and picked Collapse all folders. The browser sent exactly onePOST /api/chat/folders/collapse-alland no per-folderPATCH,GET /api/chat/foldersthen reported every folder collapsed, and the menu opened again no longer offered the item. Dark and light themes below.Screenshots / video
All taken from
056101c4d4against that gateway.The header ⋮ menu while a folder is open: Collapse all folders sits between Clean up empty folders… and Switch all to model… (dark, light).
The folder tree before and after the click (dark):
Before and after the click (light)
The same menu once every folder is closed: the item is no longer offered, because there is nothing left to collapse. There is no Expand all (see Not a goal); each folder still opens from its own disclosure (dark, light).
Related Issues
Closes #11553
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.