Repository navigation
fix(session-ipc): refuse to delete a session with a running turn - #2292
Conversation
There was a problem hiding this comment.
AIUO CodePilot · Preliminary review
Diff-only preliminary review. The change adds a running-turn guard plus session-operation serialization to `sessionDelete` and also refactors `agentCompact` to hold a session operation. The claimed window-closing effect depends on `acquireSessionOperation` and `activeTurns` correctly sharing state with the turn-start path; the diff does not include that definition, so I could not verify the invariant. No concrete evidenced defect found in the added lines themselves.
No evidenced findings in the supplied diff.
Head: 80f8730
Base: 7b0294d
CI: pending; mergeable: true.
Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.
There was a problem hiding this comment.
AIUO CodePilot · Preliminary review
Diff-only preliminary review of the session-delete running-guard and session-operation changes. The patch synchronizes `session.delete` with active-turn bookkeeping and serializes it against other session operations; the compact handler is also refactored onto the same lock. No concrete, quote-supported defects are evident in the added code. Verification limits: I could not run the app, tests, type checks, or inspect surrounding lock/turn-lifecycle code, so lock ordering, exception-translation behavior to the renderer, and cross-path interactions remain unverified.
No evidenced findings in the supplied diff.
Head: c328cab
Base: 7b0294d
CI: pending; mergeable: true.
Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.
vastsa
left a comment
There was a problem hiding this comment.
The original deletion defect is real, but the queued-start case remains reproducible on this head. I loaded the production registerSessionIpc and createSessionCoordination in an isolated worktree integrated with main 7841a98 (only external boundaries stubbed): acquire the session operation on behalf of prompt setup; invoke sessionDelete while activeTurns is empty; set activeTurns to the newly durable turn before releasing the prompt operation. The queued delete then calls host session.delete while that turn remains active. The same diagnostic reproduces on main; adding a guard inside the acquired lock prevents the host delete (control passed).
Please check activeTurns after await acquireSessionOperation(id), inside the try/finally, before session.delete. The existing pre-lock check may remain as a fast refusal, but cannot be the authoritative check. Add behavioral regressions for a queued prompt that creates a turn before releasing the lock, an already-running turn, idle deletion, and lock release on refusal/error. The current head adds no tests for the delete change. This is the core race the PR claims to close, so I have not approved or merged it. Validation here was the production-handler/production-lock diagnostic, not full Host/Electron E2E.
|
The defect is real, but before landing:
|
sessionDelete now mirrors session.moveProject's contract: acquire the session operation, then check activeTurns, then cascade. The check-after-acquire ordering closes the queued-start window — a prompt holding the operation registers its turn and releases it, and the delete still refuses that turn (issue vastsa#2291). The sidebar's row menu and batch delete pre-check running sessions and surface a translated notice (nav.deleteRunningSessionBlocked, all locales), and project-slice's deleteSession renders the main-side AGENT_BUSY backstop through the same message instead of the raw IPC error. Branch rebuilt from latest main so it carries only the delete fix; the agentCompact rework lives on fix/compact-session-operation (vastsa#2290). Regression tests execute the production handler: busy refusal before any host cascade, the prompt-held-operation repro, operation held for the delete's duration, and a clean idle delete.
c328cab to
f75d2c2
Compare
|
All four points addressed — head
Desktop |
Fixes #2291.
What
sessionDeletehad no running guard and held no session operation, so deleting a live session cascaded away the rows its turn was still streaming into: every later outbox append failed its foreign key, terminal events landed on deleted rows, and the renderer kept receiving events for a session that no longer existed.The change
activeTurns.has(id)now refuses withAGENT_BUSY, matchingsession.fork's existing guard for the same situation.acquireSessionOperation, closing the check-to-host-call window for a turn that starts in between.Behavior is unchanged for idle sessions.