Repository navigation
feat(mcp-dashboard): chat_folder_delete removes an empty sidebar folder - #15753
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that every browser path that puts a session in a folder clears Suggestions
[DESIGN-REVIEWED] d5a669e Description read[DESCRIPTION-READ] 51720aaf3f07523646cb2701e1a4b991f48cc77c930edf71af31c759b54f4d81 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 |
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: |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Before merge, a human should accept the residue the PR records: a session filed and closed during the archive scan keeps a dangling folder id. What this change shipsInventory (8 items) — 7 justifiedIntent: an agent can clean up an empty sidebar folder it created itself, and never one the person made or uses. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] d5a669e Description read[DESCRIPTION-READ] 869a10b0263a4be6c9a084daa2620cdfeb172cfd41d03999f32343831e6f9d0b That sha256 names the PR description this verdict read. Recompute it with |
82ca546 to
7330a7c
Compare
|
Rebased onto main to pick up the vector_memory row-stem helper fix that was failing Windows shard 6 (test_vector_memory_composition_contract). No change to this PR's diff. New head 7330a7c. The previous head's review-lane reds were GitHub API rate-limit failures, not verdicts. |
7330a7c to
70df1ec
Compare
70df1ec to
7577478
Compare
|
|
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsFINDING: the new empty-only delete skips the cron-job and channel references that the bulk cleanup checks. FINDING — src/kiro_crew/dashboard/chat_folders.py:2276 — the empty-only delete can remove an agent-created folder that a person's saved cron job still names. In [OPUS-REVIEWED] d5a669e Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
5d50388 to
badd74f
Compare
|
/ai-review override gpt badd74f: The residue is one session closed during the archive scan whose transcript keeps a deleted folder id and renders as unfiled, with no transcript loss and the same state the sidebar delete already leaves archived sessions in, documented under Known residue. |
Human judgment recorded@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
Read-only review note, leaving approval to a maintainer because it deletes a folder row and there is no 'only folders you created' rule: any person-scoped session can delete any empty folder, including an app-owned one (apps themselves are refused at :2098 and :2135). Under the lock _remove_if_empty re-checks existence, no child and no live slot, so no live session is unfiled and no subfolder lifted. The archived-session count (:2165) is a disk scan before the lock, so a session filed and closed during the scan ends up unfiled (disclosed). Gaps: no if_empty route test for an app or member caller (the MCP test mocks the refusal), and the crew-member refusal was not confirmable from the diff alone. |
The dashboard MCP server could create, move and file into sidebar folders but had no way to remove one, so an agent that organized sessions left every emptied folder behind for the person to delete by hand. chat_folder_delete deletes a folder only when it holds no subfolder, no live session and no archived session, so it never unfiles or relocates anything. The endpoint still refuses every app and crew-member caller.
badd74f to
0e05e31
Compare
…untouched folder An agent create now stamps the creating session's key on the new folder row as created_by_session. A browser write that renames, moves, restyles or hides the folder, files a session into it, opens a chat in it, or nests a folder under it removes the field for good; collapsing it or reordering its siblings does not. The empty-only delete refuses with 403 folder_not_agent_owned unless the row still carries the caller's own key, decided under the folder-store lock with the occupancy checks, so a folder the person created or reused is never removed by an agent. Emptiness is decided under the same lock: subfolders and live slots are re-checked in the locked step that removes the row.
0e05e31 to
d5a669e
Compare
|
@chenmingwei23 — handing this back to you. The rebase-onto- First Principles objection (design): the new delete-empty-folder path ( Fenced GPT security block ( Maintainer direction: track folder creation through a NEW crew-log event, so Keeping this PR open for you to pick up. |
bolichen97
left a comment
There was a problem hiding this comment.
LGTM. Delete is empty-only and owner-gated: the created_by_session mark is re-checked with subfolders and live slots under the folder-store lock, and any person edit clears the mark. Archived count sits outside the lock, which the comment names as accepted residue. Tool stays withheld from conductor specs until a skill needs it — good.
Problem / Motivation
Goal: An agent that organizes sidebar sessions can delete a folder it created and has emptied, and never a folder the person made or uses.
The
kirocrew-dashboardMCP server can read the folder tree, create folders, move folders and file sessions into them, but it has no delete verb. When an agent moves every session out of a folder, the empty folder stays in the sidebar and the person has to delete it by hand. An agent asked "delete these empty folders" can only answer that it has no tool for it.Why it matters
Session control creates folders as a side effect (
session_createwithfolder=,chat_folder_file_self, mkdir -p inchat_folder_create). Every workstream an agent stands up leaves folders behind, and the only cleanup path is clicking each one in the sidebar.Not a goal
DELETE /api/chat/folders/{id}keeps refusing both.What changed (motivation -> approach -> change)
Goal: remove a folder with nothing in it, without giving the MCP set any way to unfile or relocate a session.
Approach: the tool calls the existing
DELETE /api/chat/folders/{id}route with a new?if_empty=truemode. The emptiness check has to live in the endpoint: a check in the tool reads the tree, then deletes, and a session filed in between would be unfiled by the full delete (review caught this on the first head). Empty-only keeps this server's posture: nothing it does can unfile a session, lift a subfolder or leave an archived session pointing at a gone folder.Change:
chat_folders.py: an agent create (internal secret plus a liveX-Session-Key) stampscreated_by_sessionon the NEW row; a same-name reuse returns the existing row unmarked. A browser write removes the field for good when it renames, moves, restyles, hides or regenerates the icon of the folder, or moves another folder into it (api_chat_folder_update;collapsedandorderalone do not count), files a session into it (api_chat_slot_folder), opens a chat in it (api_chat_slot_create), or nests a folder under it (create_folder_record). Each removal runs in the same locked folder-store step as its write. Theif_emptydelete refuses with 403folder_not_agent_ownedunless the row still carries the caller's own key, checked again under the lock. A row from before this field has none, so every existing folder reads as the person's. The field is on the row infolders.json, so it survives a restart.mcp_dashboard.py: newchat_folder_delete(folder). It passes the same_refuse_tree_shaping_if_unverifiablegate as create/move, resolves the folder by id or path, refusesroot, and sendsDELETE ...?if_empty=truewith the verified caller key. Afolder_not_emptyrefusal is returned with a hint to empty the folder first. Module docstring updated.chat_folders.py(api_chat_folder_delete): newif_emptymode. It counts archived sessions first (a disk scan, off the loop), then re-checks subfolders and live slots inside themutate_folderscallback that removes the row. A slot PATCH setsfolder_idbefore it re-checks the folder under that same lock, and a child create checks its parent there too, so neither can land between the check and the removal. The mode never unfiles a slot or lifts a subfolder; refusals are 409folder_not_emptyand carry no count or name. The plain DELETE the sidebar sends is unchanged.mcp_core._delete: takessession_key=like_patch/_put, so a strictly-verified key is what reaches the endpoint.validation.py:CHAT_FOLDER_DELETE_SCHEMA, registered inMCP_DASHBOARD_SCHEMAS.agent.py: conductor grant audit records the verb as WITHHELD.docs/architecture/mcp.md(the app-delete section now names this tool and its one residue),session-control.md(tool table, count 28 to 29, note on the empty-only rule),docs/index.mdcount,docs/architecture/mcp.mdtool list,mcp_tool_titles.jsontitle.Known residue
One seam stays open, by choice. A session that is filed into the folder and then closed while the archive scan runs is in neither store when the locked check runs: closing pops it from the live slot table before its archival save lands. The delete then proceeds, and that archived transcript keeps the gone folder's id. Nothing in the transcript is lost: every reader renders a session whose folder is gone as unfiled, which is the state the person's full sidebar delete already leaves on every archived session in the folder it removes. It needs the person to file and close a session into the very folder their own session is deleting, inside one disk scan; apps are refused before any of this runs. Closing it would mean registering every in-flight close across all of the slot-removal paths (about twenty pop sites), which this verb does not justify.
docs/architecture/mcp.mdrecords the same.Backwards compatibility
Compatible: one new tool, one optional keyword argument on
_delete, and one optional query flag on the delete route. Without the flag the route behaves exactly as before.Tests
test/test_chat_folder_delete_if_empty.py(new, real route), creator rules: a folder the person created is kept; another session's folder is kept; reusing the person's same-name folder does not mark it; a browser call carrying a session key is not an agent; a person's rename, colour, hide, move or icon regenerate claims it; a person moving a folder in and back out claims the parent; a collapse or reorder does not; an agent's own rename keeps the mark; a session the person filed then removed, or a subfolder the person made then deleted, leaves the folder claimed; the mark and a claim both survive a reload offolders.json.test/test_mcp_dashboard_folders.py::TestFolderDelete: sends?if_empty=truewith the verified key; does no tree pre-check of its own; surfaces afolder_not_emptyrefusal without naming a session; refusesrootand an unknown folder without writing; surfaces the endpoint's app refusal verbatim; refuses an unverifiable caller; requiresfolder.test/test_mcp_dashboard_registration.pyandTestAdvertisedSet: the ratcheted tool set includeschat_folder_delete.test/test_session_control_doc.pypasses against the updated page and count.Ran locally: the files above plus the conductor, session-control, member-gate, caller-identity and call-site-auth suites (about 2,300 tests), all green. After adding the creator rules: every test file that touches the folder routes (64 files, 5,387 tests) passes; black, isort, flake8 and mypy are clean on the changed files.
Manual verification
N/A: the tool is a proxy over an existing route whose person / app / member behavior is already covered by the route tests; the new logic is the empty-only gate, which the unit cases exercise.
Related Issues
no linked issue: new tool request from the dashboard owner
Checklist