Skip to content

feat(sessions): add manual idle session removal - #385

Merged
wxtsky merged 4 commits into
wxtsky:mainfrom
alvinli1991:codex/remove-idle-sessions
Oct 28, 2026
Merged

wxtsky merged 4 commits into
wxtsky:mainfrom
alvinli1991:codex/remove-idle-sessions

Conversation

@alvinli1991

Copy link
Copy Markdown
Contributor

Summary

Add a manual action for removing currently idle session cards from the expanded session list.

This is a UI-level cleanup only. It does not delete the underlying conversation or session history, and a removed session can reappear when real activity resumes.

Screenshot 2026-10-25 at 12 06 13

Behavior

  • Adds a Remove idle sessions action to the expanded panel header.
  • Shows a compact confirmation banner without replacing the session list.
  • Removes only sessions that are currently idle.
  • Keeps sessions that have:
    • active work;
    • pending permission or question requests;
    • live embedded subagents.
  • Treats connected parent/child sessions as one atomic group:
    • the whole group is removed together; or
    • the whole group is retained.
  • Revalidates the original selection before removal:
    • a new child or status change retains the affected group;
    • unrelated sessions that become idle while confirmation is open are not added automatically.
  • An in-progress checklist item alone does not make an otherwise idle session active.

Session reappearance

Manual removal creates a bounded, run-local tombstone for each removed session.

Passive inputs such as discovery scans, hydration snapshots, completion metadata, or delayed callbacks do not immediately restore removed cards. Actual runtime work or a blocking user request restores the affected parent/child group.

Restarting CodeIsland clears these in-memory tombstones.

UI and accessibility

  • Adds localized strings for the removal action and confirmation banner.
  • Keeps the removal action visible but disabled when no sessions are eligible.
  • Provides an explicit accessibility label for the icon-only removal button.

Tests

Added coverage for:

  • idle-only removal;
  • atomic parent/child removal;
  • active children and embedded subagents;
  • pending permission requests;
  • stale in-progress checklist items;
  • status and hierarchy changes during confirmation;
  • cycle-safe parent relationships;
  • suppression of passive rediscovery;
  • revival on real activity;
  • atomic group revival;
  • AiWork hydration and stream activity.

Commands run:

  • swift test --filter AppStateIdleSessionRemovalTests
  • swift test --filter PanelChromeTests.testQuitPillFitsBesideTheNotchInEveryLanguage

The feature tests pass with 13/13 tests, and the header layout test passes.

The full suite has one known unrelated failure in
testCodexDesktopDoesNotRetainSharedHelperPidButOtherSessionsDo.

alvinli1991 and others added 4 commits October 25, 2026 11:59
…then hears its own hooks

An AskUserQuestion reaches handleAskUserQuestion, which had no tombstone
check: it rebuilt the card but left the tombstone, so the rest of that
turn (PostToolUse, Stop) was dropped as passive input about a removed
card and the card hung on its question. A card that comes back by any
way other than an admitted input (a Cursor fold creating its parent, a
path that never asked) now makes its tombstone moot, so its later hooks
always reach it. Requests no longer go through a guard whose `else` would
leak the hook's continuation: they revive the card unconditionally.

A terminal permission prompt (Notification(permission_prompt)) blocks
the agent on the user like a queued request does, so it now brings the
card back, as does a compaction starting (PreCompact). The idle_prompt
reminder, Stop, SessionEnd and the like still trail the finished turn.
The hook classification lives next to the evidence enum.

A discovery scan that read the store before the click (its modifiedAt
no later than the removal) cannot revive a card, whatever status it
read. The tombstone's date was recorded but never used.

Every removal now forgets the card's AiWork hydrate, as the AiWork
sweeps already did. A manually removed AiWork card that came back was
never hydrated again, so it lost its title, folder and client.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r keeps the list's footer in the window

The trash button sat greyed out on every approval, question and
completion card's header, where it can never act; a done card's own
completion card showed it disabled. It now shows only on the session
list, and only while there is an idle card to remove, as the grouping
tabs show only with more than one session. It leads the row, so coming
and going moves no other button. While the banner is up it is tinted
like the banner, and a second click puts the banner away.

The banner sat on top of the list without the list knowing: four cards
that fit the window pushed the footer and the panel's rounded bottom out
of it. The list now gives up the banner's height and scrolls sooner, and
its scroll view follows a changed height cap instead of keeping the one
it was created with.

The confirmation is AppState's (idleSessionRemovalRequest) rather than
the view's: leaving the list drops it, the banner shows only what is
still removable as it was, and a request none of whose cards stayed idle
is dropped instead of coming back when they go idle again. The flow is
unit-tested now. VoiceOver hears the banner's question when it opens.

Strings: "Remove 1 idle card?" in the singular, a hint that does not
assume several cards ("A removed card comes back when its session is
active again."), and the never-read remove_idle_sessions_confirm gone
from all seven languages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Japanese chrome

list/4-remove-idle (one idle card of four: the singular, and the list
giving up the banner's height) and list/8-remove-idle (three of eight,
scrolling) in every language, and list/8-compact-remove-idle in English.
list/1 shows the header with nothing to remove (no trash), list/4 and
list/8 with it.

UI_GALLERY_LANGS now also takes tr and ja, which render the island's own
strings around the English demo sessions: Turkish runs long, Japanese
checks a second CJK script. The default stays en,zh,de.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wxtsky
wxtsky merged commit 2bbdd13 into wxtsky:main Oct 28, 2026
wxtsky added a commit that referenced this pull request Oct 28, 2026
A card removed with "Remove idle cards" (#385) came back for work, and a
compaction starting counted as work, so Claude Code's background
compaction of the finished session (#388) passed the removed-card check
first: it spent the card's tombstone, and only then did the compaction
filter drop the event. The card stayed away, but the next discovery scan
brought it back. The filter now runs before the removed-card check, so
none of the compaction's hooks touch a removed card or its tombstone; a
/compact the user types still brings the card back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
wxtsky added a commit that referenced this pull request Oct 28, 2026
… idle removal and more

Unreleased notes for this round: the island's 20 fps clock (#381, #391),
"Always allow" holding in its session and Codex rules Codex can use
(#380), shortcuts and pinned displays with a second monitor (#384), pi
and Oh My Pi ringing once a task (#386), the Claude Desktop answer and
background compaction fixes (#389, #388), removing idle cards (#385),
the Codex Desktop thread jump (#387), the DeepSeek whale (#390) and the
Grok / DeepSeek Harness sections in Group by CLI.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wxtsky

wxtsky commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Thanks @alvinli1991, this is careful work: the group rule, the re-check when you confirm, and the split between passive input and real activity for the tombstones all held up in review. I pushed three maintainer commits on top of yours (your commit is unchanged):

  • Requests always bring a removed card back (045422b). AskUserQuestion skipped the tombstone check, so the card came back but the rest of its turn was dropped and it hung. A terminal permission prompt and a compaction now count too. A tombstone is dropped once the card is back by any path, a scan older than the removal can't revive the card, and removal forgets an AiWork card's hydrate as the AiWork sweep does.
  • Panel (027ddc5). The trash now shows only on the session list and only when there's something to remove; before, it sat greyed out on approval, question and completion cards. With 4–5 cards the banner pushed the footer out of the window, so the list now makes room for it. The confirmation state moved into AppState with tests, "Remove 1 idle card?" is singular, and the unused remove_idle_sessions_confirm string is gone.
  • Gallery cases for the banner, including Turkish and Japanese (82ff9f2).

One more fix on main for how this meets #388 (Claude Code's background compaction): its hooks no longer use up a removed card's tombstone, so the card stays removed. A /compact you type still brings it back (5367be1).

Possible follow-ups, not blocking: marking which cards the banner will remove, a per-card dismiss on the same path, and letting a finished child go while its parent still works.

@wxtsky

wxtsky commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Follow-up from the list above, now on main: while the banner is up, the cards it would remove are dimmed and outlined in the banner's colour, and VoiceOver reads "Will be removed" on them (0d8995c).

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.

2 participants