Stop the replaced session on /new for every harness

/new already released the old native session through the chat-close
release path, but two gaps let the replaced session stay alive, and the
client told the operator it could still be resumed in a terminal:

- Claude Code: ReleaseSession only closed a host this server was
  attached to. A host registered for the session but not attached (a
  failed reattach, or one left by an earlier server) kept running. It is
  now asked to close over its socket and killed as a fallback.
- Codex: ReleaseSession only interrupted an active turn. It now also
  sends thread/unsubscribe so the App Server unloads the thread; a later
  prompt reloads it through the existing "thread not found" resume path.
- The /new notice now says the previous session was stopped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 18:10:41 +00:00
parent cfebd3a05b
commit 01040a7b12
8 changed files with 183 additions and 15 deletions
@@ -160,10 +160,11 @@ const String chatRenameUsageReport =
'Usage: /rename <title> — renames this session.';
/// The line the fresh conversation opens on after `/new`: the chat is the
/// same, the agent's context is empty.
/// same, the agent's context is empty, and the server has already stopped the
/// replaced session's agent and background work before it answered.
const String chatNewSessionNotice =
'New session started. The agent no longer sees the earlier conversation; '
'the previous session can still be resumed in a terminal.';
'the previous session was stopped.';
/// The line a conversation opens on when another device started its new
/// session.
@@ -94,4 +94,15 @@ void main() {
'“/close” is not available yet, so nothing was sent to the agent.',
);
});
test('the /new notice says the replaced session was stopped', () {
// The server releases the old harness session before it answers, so the
// notice must not suggest it is still running or resumable.
expect(
chatNewSessionNotice,
'New session started. The agent no longer sees the earlier '
'conversation; the previous session was stopped.',
);
expect(chatNewSessionNotice, isNot(contains('resume')));
});
}