Claude Code chats survive server restarts in a detachable host
A pipelines-claude-host process owns each claude -p CLI and its pipes, spools its stream-json output with offsets and serves a private Unix socket. The server detaches on shutdown and reattaches on start, replaying the spool to rebuild turns, approvals, questions, background tasks and the live model. Explicit close, idle release and CLI exit stop the host; a crashed host falls back to --resume with a notice.
This commit is contained in:
@@ -325,6 +325,7 @@ func (s *session) ensureProcess(ctx context.Context) (*process, error) {
|
||||
p := s.proc
|
||||
s.lastUsed = time.Now()
|
||||
s.mu.Unlock()
|
||||
s.awaitReady(ctx)
|
||||
return p, nil
|
||||
}
|
||||
if s.starting != nil {
|
||||
@@ -408,6 +409,7 @@ func (c *Chat) Interrupt(ctx context.Context, id string) error {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
s.awaitReady(ctx)
|
||||
s.mu.Lock()
|
||||
proc := s.proc
|
||||
running := s.running
|
||||
@@ -489,6 +491,7 @@ func (c *Chat) Permissions(ctx context.Context, id string) ([]protocol.ChatPermi
|
||||
if s == nil {
|
||||
return []protocol.ChatPermissionFrame{}, nil
|
||||
}
|
||||
s.awaitReady(ctx)
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
frames := make([]protocol.ChatPermissionFrame, 0, len(s.approvals))
|
||||
@@ -505,6 +508,7 @@ func (c *Chat) Forms(ctx context.Context, id string) ([]protocol.ChatForm, error
|
||||
if s == nil {
|
||||
return []protocol.ChatForm{}, nil
|
||||
}
|
||||
s.awaitReady(ctx)
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
forms := make([]protocol.ChatForm, 0, len(s.forms))
|
||||
@@ -629,6 +633,7 @@ func (c *Chat) Shells(ctx context.Context, id string) ([]protocol.ChatShell, err
|
||||
if s == nil {
|
||||
return []protocol.ChatShell{}, nil
|
||||
}
|
||||
s.awaitReady(ctx)
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
result := []protocol.ChatShell{}
|
||||
|
||||
Reference in New Issue
Block a user