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
+15
View File
@@ -44,6 +44,8 @@ type fakeChat struct {
promptCalls int
promptFiles []opencode.PromptFile
interrupts int
releases []string
releaseErr error
replies int
replyRequest protocol.ChatReplyRequest
replyErr error
@@ -209,6 +211,19 @@ func (f *fakeChat) Interrupt(context.Context, string) error {
return f.interruptErr
}
func (f *fakeChat) ReleaseSession(_ context.Context, sessionID string) error {
f.mu.Lock()
defer f.mu.Unlock()
f.releases = append(f.releases, sessionID)
return f.releaseErr
}
func (f *fakeChat) releaseQuery() ([]string, error) {
f.mu.Lock()
defer f.mu.Unlock()
return append([]string(nil), f.releases...), f.releaseErr
}
func (f *fakeChat) Messages(_ context.Context, sessionID string, limit int, cursor string) (protocol.ChatHistoryPage, error) {
f.mu.Lock()
defer f.mu.Unlock()