Repository navigation
feat(folders): position sidebar folders with fractional rank keys - #15041
Pearcekieser wants to merge 1 commit into
Conversation
|
Intent: A sidebar folder move writes only the moved folder, because its position is a rank string the gateway generates between the two neighbours, so drags and |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: fractional ranks remove sibling renumbering at its source, the spread and the move happen in one locked mutate, and the retired endpoint is listed as Breaking. Notes
[DESIGN-REVIEWED] ebf7e14 Description read[DESCRIPTION-READ] a0580bd1b0768ceffc90da64e85b46dd9095da0be377a66d37360ed87208f686 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 |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Rank keys address the cause (dense integer Notes
What this change shipsInventory (10 items) — 7 justifiedIntent: let a person's drag and an agent's
[FIRST-PRINCIPLES-REVIEWED] ebf7e14 Description read[DESCRIPTION-READ] acf84b58ed4ff50a0976f21063689af4832e276e581727bb0565fb22ab41f3f9 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS The attached and committed screenshots show every control this diff adds: the Undo "went back… at the end" status line (nested and top level, both themes) and the folder-error notices with the action moved below. No first-time reader has looked at them, because this fork lane has no blind read. Pushing the branch to this repository adds that read. Notes
[UX-REVIEWED] ebf7e14 Description read[DESCRIPTION-READ] a2d8ad83f0d39f403655934f85d656432f733774426ce9e60ca2295368bd18dd That sha256 names everything this verdict read: the PR description, plus the 13 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 |
Opus 5.5 Review (fork) — 🔴 changes requested (blocking)Reviewed One folder writer still adds unranked rows: install-archive import. After an import, an app can't place a folder between two siblings until the person drags a folder by hand. This PR fixes and tests that same outcome for every other folder writer. BLOCKING — src/kiro_crew/dashboard/folder_portability.py:261 |
6693e55 to
8e3a35f
Compare
|
span=44792a8fa23a
|
|
span=65f81eb341a2
|
|
span=340683d4ba46
|
|
span=96abd459e241
|
|
span=b7d7ccc155aa
|
|
span=b093ded56bb2
|
|
span=472852ca8399
|
7208c92 to
d3b842b
Compare
|
span=14713081046c
|
|
span=2d121c59e4ca
|
|
span=7f50c78d70d4
|
|
chore (non-blocking): rebased on main, no behaviour change Head 2410fba, a clean rebase of c109358 with no conflicts. Main now includes #26180, which fixes the boot-smoke failure ( |
|
span=be85a2d5c148
|
|
chore (non-blocking): rebased on main, no behaviour change Head 6919493. The only conflict was the lucide-react import line in |
|
chore (non-blocking): rebased on main, no behaviour change Head d1fe31e, a clean rebase of 6919493 with no conflicts. Backend Lint & Type Check failed on 6919493 with flake8 F401 on an unused |
|
chore (non-blocking): rebased on main Head 3814c81. Main had moved four days since d1fe31e, and the rebase conflicted in nine files. Most were import or doc lines where both sides are kept. Two changes go beyond a plain merge, both caused by main's mate home folders (#25994):
The arrival and channel folder writers use main's Locally, flake8, mypy on the touched modules, 746 folder, mate and error-code tests with 4 workers, 1,782 sidebar and folder vitest tests, tsc, the full frontend lint and the pre-push gate (24 of 24) pass. Local GPT and Opus reviews found nothing. |
|
note (non-blocking): Internal Content Scan on 3814c81 needs a re-run (run 41763408225); its runner could not reach github.com:443 during "Checkout base (trusted)", so it scanned nothing and reports no verdict. |
|
note (non-blocking): 289aac6 is the same tree as 3814c81, re-run for Internal Content Scan (run 41763408225, no verdict after a runner network failure) and Backend Tests (3.12, 5) (job 126358548050, two |
|
note (non-blocking): Security Scope Review (fork lane) on 289aac6 needs a re-run (check run 126415705934); it reports |
|
chore (non-blocking): rebased on main, no behaviour change Head 5f1ccd2. Main's #27427 added the folder icon preview ( Locally, flake8, mypy on the touched modules, 765 folder, mate, icon and error-code tests with 4 workers, 3,072 sidebar, folder and API client vitest tests, tsc, the full frontend lint and the pre-push gate (24 of 24) pass. This push also gives Security Scope Review, which never finished on 289aac6, a fresh run. |
|
chore (non-blocking): rebased on main, no behaviour change Head 2f29255. The only conflict was |
|
Re-run with no code change: 35c8834 has the same tree as f32d788. On f32d788, nine lanes failed between 19:01Z and 19:08Z on the CI app's API rate limit before they judged anything: Fork PR Description, PR Policy, Publish readiness signal, Sensitive Change Review, Dependency License Gate, Internal Content Scan, GPT 6.1 Review, Opus 5.5 Review and Security Scope Review. Frontend Tests (2) job 127469072592 timed out at 15 s in |
|
self-added: yes
GPT 6.1 blocked e2d9e86 at i18n runs with The names now render as React text through a small The new test in |
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes at e9115df for one point. CI is green.
website/src/utils/folderRank.ts adds a regex in product code. This repository asks new code not to use one:
out.push(digits.replace(/0+$/, ''))
It strips trailing 0 characters from the rank digits. The same thing needs no regex: walk back from the end while the character is '0', then slice. For example:
let end = digits.length
while (end > 0 && digits[end - 1] === '0') end--
out.push(digits.slice(0, end))A test with no trailing zeros, some, and all zeros would pin it.
Separately, this PR retires POST /api/chat/folders/reorder to a 410 tombstone and changes how apps may position folders. iamwhatever's open review also asks for a maintainer on that, so it is not settled by this review.
|
@bolichen97 issue: the regex in
The same push rebases the PR onto current main, so CI runs fresh on this head. I agree the 410 for |
|
Thanks. My point from e9115df is fixed at 751091b. I'm not approving yet. Retiring |
|
@iamwhatever @bolichen97 question (blocking): this PR now waits on two maintainer calls, and both of your reviews point at them.
If either call should go the other way, say which one and I will change the PR to match. |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 22% chance that this change introduces a defect, above the 12% limit for approving on its own. Approve. Folder positions move from dense integer 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 |
A sidebar folder's place among its siblings is now a short rank string that
the gateway picks between the two neighbours, so a move writes the moved
folder only. PATCH /api/chat/folders/{id} takes before/after naming a sibling;
the sidebar drag and chat_folder_move both send that anchor, and the atomic
multi-row reorder endpoint they used to renumber siblings through is removed.
Folders written before ranks sort after ranked siblings by their legacy order,
so nothing changes on disk until someone moves a folder. The first move in such
a section spreads fresh ranks over it in its current order; since that changes
no other folder's position, an app may position its own folder among the
person's without owning them.
|
span=6662a031f2c4 fixed in ebf7e14
|
Problem / Motivation
Goal: moving a sidebar folder writes only that folder, so a drag and an agent's
chat_folder_movenever renumber siblings.A folder's place among its siblings is a dense integer
order. Every move that has no free integer slot renumbers the siblings. That forced a batch reorder endpoint (POST /api/chat/folders/reorder) with its own entry and byte caps, and it madechat_folder_moverefuse an app agent or crew member any position that would renumber a folder the person owns, which in a hand-arranged sidebar is most positions.Why it matters
An app or crew member that creates a folder cannot put it where it belongs in the person's sidebar; the tool refuses and asks the person to do it. Every sidebar drag also sends a batch of rows computed against a cached tree, so a concurrent move from another tab or an agent can land against a tree that has shifted.
Not a goal
ordervalues stay on disk as they are.What changed (motivation → approach → change)
order, siblings renumberedrankstring, generated between the two neighbours[{id, order}, ...]to/api/chat/folders/reorderchat_folder_movesendbefore/afteronPATCH /api/chat/folders/{id}A rank is a short base-62 string compared lexicographically, the standard fractional-indexing technique.
src/kiro_crew/dashboard/folder_rank.pyholds the key generator, the sibling comparator and the placement plan. The PATCH handler resolves the anchor under the folder-store lock and writes the moved folder's rank, so the position is decided against the tree as it is at the write; an anchor that moved to another section is a 409.Stored folders are not migrated. A folder without a valid rank sorts after its ranked siblings by legacy
order, then name, as every earlier build drew it. The first move in a section holding such a folder, a corrupt rank or tied ranks gives every sibling a fresh, evenly spaced rank in its drawn order, then places the moved folder; no other folder's drawn position changes. Only the person's move may spread a section holding folders someone else owns: an app or crew member gets 409folder_section_unrankedthere, unless the spread rewrites only its own folders. An app can still place its own folder first or last in such a section without that drag: ranked folders always sort before unranked ones, so first takes a rank and last stays unranked with anorderone past the largest (folder_rank.edge_position), and no other row is written. Only a slot between two of the person's unranked folders is refused. A new folder (person,arrival_folders.pyimport,channel_folders.py, Code Review Sageroutes.py) takes a trailing rank when the section is fully ranked. A reparent without an anchor is placed last through the same plan; where an app would need a spread over the person's folders, only the moved folder is written, unranked.A mate's home folder (#25994) still takes only layout writes from anyone. The layout fields are now
collapsed,before,afterandexpected_parent, so a person can still drag a mate's home among the top-level folders;orderstays in the list so an old tab getsorder_retiredthere too.ensure_mate_homegives a new home a trailing rank like the other folder writers.The sidebar comparator (
utils/folderTree.ts) sorts by rank the same way; the crew group that mirrors a connected crew's folders keeps each folder's validranktoo (peerFoldersOfinhooks/useInstanceSessions.ts), so a drag on that crew moves its folders on the hub as well;ChatFoldergains optionalrank(types/index.chat.ts);reorderChatFoldersis removed fromapi/client/chatOrganization.ts;utils/folderRank.tsmirrors the key generator for the optimistic draw, andtest/fixtures/chat_folder_rank.jsonpins the keys and sort cases both suites must produce. Undo after a drag-reparent sends the original neighbours asbefore/afterand falls back to the parent alone if they moved. The folder PATCH reads its body throughread_bounded_json(1 MiB cap;error-code-baseline.jsonupdated).chat_folder_suggestlists folders in sidebar tree order throughfolder_rank.tree_order, the same iterative walkchat_folder_treeuses, and the failed-import rollback inarrival_folders.pytreatsranklikeorder.docs/architecture/mcp.md, the feature map and the dashboard module spec describe the rank model.This is a possible shared helper for the pinned-session order in #14233, which stores a dense list today; not changed here.
Backwards compatibility
Breaking:
POST /api/chat/folders/reorderis retired to a 410reorder_retiredtombstone that tells an old tab to reload. Itsexpected_parentprecondition, which #15846 added, moves to the folder PATCH: an optional string naming the container the caller saw the folder in (""is the root lane, and a parent that no longer exists counts as the root)._applycompares it with the folder's container under the store lock and answers a mismatch with 409folder_parent_changedand no write; a non-string is 400expected_parent_invalid. Anchors alone cannot stand in for it: when a parent is deleted mid-drag, the dragged folder and its anchor are both promoted to the root and are still siblings there. The sidebar drag sends it on every sibling move,chat_folder_movesends it on every anchored move whose parent its listing shows, and a PATCH without it behaves as before.PATCH /api/chat/folders/{id}answers anorderfield with 400order_retired. Writer sweep on origin/main @ 98b7375: the only callers were the sidebar drag (chat-sidebar/dnd/useSidebarDrag.tsviareorderChatFolders, split out ofChatSidebar.tsxby #15094) andchat_folder_moveinmcp_dashboard.py; both now sendbefore/after. The one other caller,website/scripts/capture-nested-folder-reorder.mjs(a manual capture harness, not in CI), now stubs and asserts the anchor PATCH. No app manifest writes folderorderthrough the API. A browser tab still running an older build is told to reload on its next folder drag. The member gate does not admit the retired POST: crew members are agent principals with no dashboard bundle to reload, so a member caller on the old contract gets the owner-only refusal rather than the reload hint. When an Undo's original neighbour has moved, the folder lands last in its old section and a status line names it, reveals the folder and clears on the next move; the line shows in Custom folder order only (folder_undo_anchor_gone, added to every file inwebsite/src/i18n/locales/). Downgrading to a build before this one keeps the legacyordervalues, which this build reads but no longer writes, so folder positions set since the upgrade are lost.Readers of the removed
api_chat_folder_reorderandPOST /api/chat/folders/reorderon origin/main:api_chat_folder_reorder_retiredtombstone; test_chat_folder_rank.py tombstone testapi_chat_folder_reorder_retiredbefore/afteron the folder PATCH; ChatSidebar.folderMoveUndo.test.tsxbefore/afteron the PATCH instead of renumbering; test_mcp_dashboard_folders.pyOther compatible changes:
Deleting a folder still moves its children to the top level; they now land after the top level's ranked folders in their old order (
chat_folders.py_remove), instead of keeping a rank from their old section that could collide with a root folder's. In a top level with unranked folders they droprankand takeordervalues after the root's.The folder PATCH also accepts
beforeandaftertogether, meaning "between these two adjacent siblings"; a pair that is no longer adjacent is 409folder_anchor_not_sibling, which Undo uses so a neighbour that moved inside the section cannot drag the folder to a new spot.The empty-folder cleanup preview (
chat_folder_cleanup.py) lists folders in the sidebar's rank order.Main has since moved
chat_folder_moveandchat_folder_treeintomcp_dashboard_folder_runs.pyandmcp_dashboard_folder_tree.py; the integer-slot code this PR removes is there now.chat_folder_suggest.pyand its test are black-clean after this change, so.github/black-baseline.txtdrops both.Tests
test/test_chat_folder_rank.py: key generation (random insert property check, cap refusal, determinism), comparator (ranked before unranked, UTF-16 id tie-break, corrupt rank), placement plan, and the real PATCH handler through the real folder repository: first move spreads then later moves write one row, corrupt rank falls back to the spread, an app is refused (409, no write) where the spread would touch the person's folders and allowed once the section is ranked or the spread touches only its own, an app reparent into a legacy section writes only the moved folder, a duplicate or unranked row anywhere in the section forces a spread, app refused on the person's folder and on a folder holding the person's, anchor in another section is 409, reparent plus position in one write, reparent without anchor lands at the end of ranked and legacy sections, concurrent moves both land, malformed bodies are 400 with no write, create in a ranked section gets a trailing rank, deleting a folder appends its children after the root's ranked rows in their old order (in a legacy root, unranked withordervalues after the root's), a spread whose store write fails restores every rank.website/src/test/folderRank.test.tsandreorderFolders.test.ts: shared fixture parity, drag direction to anchor, optimistic ranks match the gateway's plan, cross-container drop moves nothing.website/src/test/crewSpaces.test.ts: a connected crew's valid rank is kept and a malformed one dropped; its folders draw in rank order over a conflicting legacyorder; an older crew's unranked folders still sort byorder.website/src/test/ChatSidebar.folderMoveUndo.test.tsx: Undo of a folder drag-reparent sends the original neighbour as the anchor, and a failed parent-only fallback restores the cached parent and rank.test_chat_folder_suggest.py: a ranked nested section stays under its parent in the suggestion list instead of pushing top-level folders past the cap; orphans andparent_idloops are listed once.test_mcp_dashboard_folders.py: the tool sends one PATCH with the anchor and surfaces endpoint refusals.test_chat_folder_reorder_atomic.pyis deleted with its endpoint.Manual verification
N/A: the endpoint tests drive the real handler and repository transaction, and the sidebar path is covered by the drag tests; the drawn order for an existing store is unchanged by construction (unranked rows keep the legacy comparator).
Screenshots / video
A drag lands where it did before; the new surface is the Undo fallback status line (
folder-undo-anchor-gone). Captured from this revision's built SPA bywebsite/scripts/capture-folder-undo-anchor-gone.mjs(real pointer drag, then Undo against a stubbed 409folder_anchor_not_sibling; 28/28 assertions pass), committed undertemp-screenshots/15041-folder-undo-anchor-gone/:nested-dark.png,nested-light.png: a folder with a long name goes back under Archive; the line wraps at sidebar width above the tree and the folder is revealed and outlined below it.top-dark.png,top-light.png: a root folder goes back to the top level.The line uses the neutral status surface with a dismiss ✕, not the red "Folder update failed" notice, which is absent in every capture.
The three folder-move refusals reach the existing "Folder update failed" line through
errMessage(e). That notice now setsactionPlacement="below", as the sidebar's other notices do. Since #37263 a block notice always draws Ask the agent in its action row under the copy, and a test pins that layout for this notice. These six captures come from the built SPA on25d95bcb9b: a real pointer drag of Inbox above Archive, with the folder PATCH stubbed to answer the gateway's exact body. All 6 checks that the line shows the server text pass, and each of the 6 image URLs answers 200.409
folder_parent_changed, the folder's parent was deleted or it was moved by another tab during the drag:409
folder_anchor_not_sibling, the neighbour the drag named moved or was deleted before the write:410
reorder_retired(and the 400order_retiredPATCH, which carries the same text), a tab still on an older build:Related Issues
Supersedes the renumber race fixed in #12278, since there is no batch renumber left to race.
Fixes #15040
Checklist
Follow-ups
Deferred review items, one issue each: