stop the harness before deleting its transcript, and wait for it to actually stop
Deleting a commander removed its transcript and the `claude` CLI wrote it straight back. Verified rather than inferred: the file returned with 22 lines, every one timestamped after the delete, and the deleted commander was sitting in /chat as "(untitled)" — no longer in `command_hq_sessions`, so nothing filtered it out. Delete a commander, get an untitled chat back. Two causes, and the first one hid the second. The kill never happened. `killClaudeSession` was imported straight from `claude-manager` into a route that runs in `officer`, while the session map lives in `officer-claude-code`. It read an empty map in the wrong process and returned false every time. `claude:kill` and `killClaude` already existed for this; the route just wasn't using them. And killing is not being dead. `abort()` returns while the CLI is still unwinding, and officer does not own that file — the CLI does. So a session now carries an `exited` promise resolved by the same exit hook that already reaps it, `claude:kill` replies only once that resolves, and both delete routes await the reply before touching the filesystem. Bounded at 5s and never fatal. A child that will not die delays a delete by seconds instead of hanging it, and a sidecar that is down leaves the caller with exactly the race it already had. `markExited` fires before `dropDeadSession`'s identity guard, deliberately: a waiter has to be released even when a newer session has taken its key, or it blocks for the full timeout on a process that died on schedule. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -294,11 +294,20 @@ async function handleCommand(cmd: SidecarCommand, reply: ReplyFn) {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'claude:kill':
|
||||
claudeManager.killClaudeSession(cmd.sessionKey, cmd.userId);
|
||||
case 'claude:kill': {
|
||||
/*
|
||||
Reply only once the child is actually gone.
|
||||
|
||||
The caller deleting a session's transcript has to know the CLI has stopped writing it, and this
|
||||
reply is the only signal it can get — officer's side of the socket has no view of the process.
|
||||
Bounded inside `killClaudeSessionAndWait`, so a child that will not die delays this by seconds
|
||||
rather than hanging the caller's request.
|
||||
*/
|
||||
await claudeManager.killClaudeSessionAndWait(cmd.sessionKey, cmd.userId);
|
||||
sessionLog.drop(cmd.sessionKey);
|
||||
reply({ type: 'claude:killed', id: cmd.id });
|
||||
break;
|
||||
}
|
||||
|
||||
case 'claude:interrupt':
|
||||
await claudeManager.interruptClaudeSession(cmd.sessionKey, cmd.userId);
|
||||
|
||||
Reference in New Issue
Block a user