Release native chat runtimes on lifecycle changes

Ensure /new and chat close stop native foreground and background work before changing registry state. Preserve transcripts while surfacing release and recovery cleanup failures instead of reporting false success, with focused adapter and server regressions.
This commit is contained in:
2026-11-11 17:11:40 +00:00
parent a5912d9a1e
commit 2307d45417
11 changed files with 197 additions and 14 deletions
+12
View File
@@ -550,6 +550,18 @@ func (c *Chat) Interrupt(ctx context.Context, id string) error {
return err
}
// ReleaseSession stops an active Codex turn while preserving the thread and
// its transcript. Codex has no separate per-thread process to reap.
func (c *Chat) ReleaseSession(ctx context.Context, id string) error {
c.mu.Lock()
turn := c.turns[id]
c.mu.Unlock()
if turn == "" {
return nil
}
return c.Interrupt(ctx, id)
}
// Create starts one Codex thread in directory.
func (c *Chat) Create(ctx context.Context, title, directory string) (protocol.ChatSession, error) {
if strings.TrimSpace(directory) == "" {