Skip to content

fix(sessions): scope Older Sessions Delete all to the rows it lists - #23638

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/13091-older-sessions-delete-all-visible
Oct 24, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/13091-older-sessions-delete-all-visible

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The Older Sessions "Delete all" deletes only the sessions that pane shows, never hidden ones.

Since #13033 the pane lists with user_only=1, which hides machine transcripts (subagent_, wf*, secretary, channel) and never-used sessions. "Delete all" still called DELETE /api/sessions with no filter, so it also deleted every hidden transcript. On one measured host that was 186 extra files the reader never saw.

Why it matters

"Delete all" is permanent. A reader who sees 5 rows and confirms expects 5 rows gone, not 5 plus a hidden remainder of subagent and workflow history.

Not a goal

What changed (motivation → approach → change)

Decision (the issue was crew: needs human; the operator asked for the most conservative fix): option 2 of the issue, made opt-in. "Delete all" now deletes exactly what the pane can show, never more. Rows the pane hides stay on disk.

  • history_reads.py: the user_only row test moves into one shared function, _is_user_listed_row. The listing uses it unchanged.

  • src/kiro_crew/dashboard/handlers/sessions.py: the facade manifest names the three new helpers.

  • delete_routes.py: DELETE /api/sessions and GET /api/sessions/clearable/count accept user_only=1. With it, the shared selector skips any row _is_user_listed_row rejects. Without it, nothing changes.

  • website/src/api/client/sessions.ts: api.clearSessions(userOnly) adds ?user_only=1. website/src/store/chat/lifecycle.ts: the Older Sessions thunk passes true.

  • docs/system-specs/modules/learn-cron-dashboard.md: the Sessions spec now states the flagged Delete all reach and the unflagged full reach.

This keeps the listing and the delete on one predicate, so they cannot drift again.

Backwards compatibility

Compatible: the flag is opt-in, and DELETE /api/sessions without it clears the same set as on main.

Reader: website/src/store/chat/lifecycle.ts:clearHistorySessions -- chat -- now sends user_only=1, deletes only listed rows (test ChatSliceCoverageSecondPass "records nothing when Delete all left nothing behind")
Reader: src/kiro_crew/dashboard/handlers/sessions_parts/delete_routes.py:api_sessions_clear -- app -- app callers are refused by _app_bulk_history_refusal before the flag is read; flagless callers unchanged (test_clear_without_user_only_still_clears_every_closed_session)
Reader: src/kiro_crew/dashboard/handlers/sessions_parts/delete_routes.py:api_sessions_clearable_count -- crew page -- same flag, same selector, so the count matches the delete (test_user_only_clear_deletes_exactly_the_listed_rows)

Tests

  • test_user_only_clear_deletes_exactly_the_listed_rows: real files on disk. The listing, the count and the clear agree; only the listed row is unlinked; subagent_* and secretary_* survive.
  • test_clear_without_user_only_still_clears_every_closed_session: the flagless contract is unchanged.
  • website/src/test/ApiClient.coverage.construction.test.tsx: clearSessions() vs clearSessions(true) URLs.
  • website/src/test/ChatSliceCoverageSecondPass.test.tsx: the thunk calls clearSessions(true).

Proof: PROVEN test/test_dashboard_sessions_clearable_count.py::test_user_only_clear_deletes_exactly_the_listed_rows (head 6989c06)

Run locally: the 4 related backend files (186 passed), the 3 related vitest files (222 passed), mypy/isort/flake8 on the changed Python files, tsc -p tsconfig.app.json (clean). Local gpt and opus reviews: no findings.

Manual verification

N/A — unit coverage sufficient: the backend test drives the real handlers over real files on disk, and the frontend change is one query flag pinned by two tests.

Screenshots / video

Why no screenshot: the pane renders the same; only the request behind "Delete all" gains a query flag.

Related Issues

Closes #13091

Sibling sweep

Swept: git grep -n "user_only" -- src website/src
Sibling: src/kiro_crew/dashboard/handlers/sessions_parts/history_reads.py -- changed here
Sibling: website/src/store/chat/lifecycle.ts -- changed here

Pattern harvest

Rule candidate: review-prompt
Pattern: a bulk action next to a filtered list must apply the same filter predicate as the list.

Checklist

  • At most two commits (one is the norm), 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)
  • No secrets, credentials, or internal references in the diff

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of a1fbb33a6d80ceabee6adb2e69f44006b54669d9 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks: no pixels change, so no screenshot is needed. The only frontend change is the query flag sent behind the existing "Delete all".

Notes

  • The confirm text "Permanently delete all closed sessions?" (en.json:6956) now promises more than the button deletes. Hidden machine transcripts survive. Consider "Permanently delete the closed sessions listed here?" in a follow-up, since this PR rules out copy changes.

[UX-REVIEWED] a1fbb33

Description read

[DESCRIPTION-READ] d485b745a9f14ad901bc609d5e789b6c6e12865bad616380be52d42fd74a34f8

That sha256 names everything this verdict read: the PR description, plus the 3 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 24, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of a1fbb33a6d80ceabee6adb2e69f44006b54669d9 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design-level concerns: the list and the bulk delete now use one predicate, the flag is opt-in, and callers that omit it keep today's behaviour.

[DESIGN-REVIEWED] a1fbb33

Description read

[DESCRIPTION-READ] ea7c828bd7d31b9ee57c439d57c5aaf50626bc8d5546215287ff5b2fce7305c0

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 24, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of a1fbb33a6d80ceabee6adb2e69f44006b54669d9 — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks. The fix is aimed at the cause: the listing and the bulk delete now share one row filter. Two pieces of new flag surface have no caller that uses them.

Notes

  • Item 3 — zero consumers: GET /api/sessions/clearable/count gains user_only, but no call to that endpoint exists anywhere in website/src (grepped clearable: 0 hits), and the only other mention in src is the route registration. The description says "crew page — same flag", and no such caller exists. Subtraction: drop user_only=_user_only_query(request) from api_sessions_clearable_count; the flag can be added when a caller needs it.
  • Item 4 — one consumer, generalized: clearSessions: (userOnly = false) => … has exactly 1 non-test caller (lifecycle.ts:323), and it always passes true. Subtraction: remove the parameter and have clearSessions always append ?user_only=1.

What this change ships

Inventory (6 items) — 4 justified

Intent: delete only the old sessions the reader can see in Older Sessions, never the hidden ones. This is a FIX (#13091).

  1. Older Sessions "Delete all" no longer removes hidden subagent, workflow, secretary and never-used transcripts — justified
  2. DELETE /api/sessions accepts user_only=1; without it the clear behaves exactly as before — justified
  3. The clearable-count endpoint accepts user_only=1 — zero consumers, no caller sends it
  4. The SPA client's clearSessions gains a userOnly parameter — one consumer, generalized
  5. The listing filter moves into the shared _is_user_listed_row / _has_user_content — justified
  6. The sessions facade manifest names the three new helpers — justified

[FIRST-PRINCIPLES-REVIEWED] a1fbb33

Description read

[DESCRIPTION-READ] a80e869138febaa80bd830be0e0dad327f889b3e34a39ee8fae67000d1917fd4

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 24, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed a1fbb33a6d80ceabee6adb2e69f44006b54669d9 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] a1fbb33

Verdict parsed from the review's SHA-scoped output markers for commit a1fbb33a6d80ceabee6adb2e69f44006b54669d9.

False positive or not applicable? A repository writer can comment:
/ai-review override fable a1fbb33a6d80ceabee6adb2e69f44006b54669d9 false-positive: <reason, 20 to 500 characters>

@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 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of a1fbb33a6d80ceabee6adb2e69f44006b54669d9 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a1fbb33

False positive or not applicable? A repository writer can comment:
/ai-review override gpt a1fbb33a6d80ceabee6adb2e69f44006b54669d9 false-positive: <reason, 20 to 500 characters>

@iamwhatever
iamwhatever force-pushed the fix/13091-older-sessions-delete-all-visible branch from c0f32c1 to 6989c06 Compare October 24, 2026 03:09
@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 24, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: spec still said Delete all reaches hidden machine transcripts (span=e58ee26efa2a)

Fixed in 6989c06: the Sessions entry in docs/system-specs/modules/learn-cron-dashboard.md now says the pane's Delete all sends user_only=1, so the shared selector skips every row _is_user_listed_row rejects and hidden machine transcripts and never-used sessions stay on disk.
It also says GET /api/sessions/clearable/count takes the same flag, and an unflagged DELETE /api/sessions keeps the full reach.

🤖 AI-assisted comment 🤖

@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 24, 2026
@iamwhatever
iamwhatever force-pushed the fix/13091-older-sessions-delete-all-visible branch from 6989c06 to a1fbb33 Compare October 24, 2026 04:00
@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 24, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Review-ready on head a1fbb33.

  • pr_status.py exit 0: PR Readiness SUCCESS, 108 checks, 0 running, 0 failing.
  • Mergeable, base is current (green age +0 commits, no overlap).
  • Design, First Principles and UX: PASS. GPT and Opus lanes ran on this head; the one Opus finding (span=e58ee26efa2a, spec wording) is fixed and answered.
  • Remaining gate: a maintainer review.

🤖 AI-assisted comment 🤖

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

Approving — non-security, clean.

This narrows the Older Sessions Delete all to exactly the rows the user_only=1 listing shows, so machine-namespace transcripts (subagent / secretary / wf / channel …) and never-used sessions now survive the bulk clear. What I verified:

  • One shared predicate. _is_user_listed_row / _has_user_content are extracted and used by the listing, the clearable-count, and the clear, so the confirmation count cannot drift from the set the delete takes.
  • Additive opt-in, no default loosening. The SPA's Delete all sends user_only=1; an unflagged DELETE /api/sessions keeps the full reach (every closed session), so memory consolidation and other callers are unchanged.
  • Tightening only. It deletes fewer rows, never more — I saw no over-deletion path.
  • Tests: 52 pass across the clearable-count / clear / older-exclusion suites on the merge with current main; forcing _is_user_listed_row to list every row turns test_user_only_clear_deletes_exactly_the_listed_rows red, so the scoping is pinned.

Final sign-off is a maintainer's where required.

@chenmingwei23
chenmingwei23 merged commit f11e740 into main Oct 24, 2026
109 of 117 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/13091-older-sessions-delete-all-visible branch October 24, 2026 06:20
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Older Sessions: the visible set and the Delete-all set no longer agree

3 participants