Merge main; use the shared chatShutdownDetacher for OpenCode and Codex

OpenCode and Codex chats implement Detach (called by chatManager.Close)
instead of a parallel DetachSessions interface. Docs follow the Claude Code
host and the systemd KillMode=process unit. The opt-in live restart check
copies only the stage provider's login row into its scratch OpenCode
database, builds the CLI for skill install and removes its scratch tree.
This commit is contained in:
2026-11-04 16:24:17 +00:00
26 changed files with 2463 additions and 101 deletions
+14
View File
@@ -0,0 +1,14 @@
// Command pipelines-claude-host keeps one Claude Code CLI process alive across
// Pipelines server restarts. The server starts it; it is not run by hand. See
// internal/claudehost and docs/chat-backends.md.
package main
import (
"os"
"git.a-wan.net/alan/pipelines/internal/claudehost"
)
func main() {
os.Exit(claudehost.Main(os.Args[1:]))
}
+7 -5
View File
@@ -13,6 +13,7 @@ import (
"time"
"git.a-wan.net/alan/pipelines/internal/buildinfo"
"git.a-wan.net/alan/pipelines/internal/claude"
"git.a-wan.net/alan/pipelines/internal/discovery"
"git.a-wan.net/alan/pipelines/internal/opencode"
"git.a-wan.net/alan/pipelines/internal/paths"
@@ -148,14 +149,15 @@ func main() {
options.OpenCodeStatus = openCodeStatus
// One manager routes each chat to its owning harness. OpenCode remains the
// default; Codex is attached when its app-server control socket is present.
// Claude Code chats run in detachable hosts scoped to this database, so a
// restart does not end them (internal/claudehost).
claude.ConfigureHosts(claude.DefaultHostDir(*db))
chats := server.NewChatManager(ctx, options.Chat, store)
if len(chats.Backends()) > 0 {
options.Chat = chats
if detach {
defer chats.DetachSessions()
} else {
defer chats.Close()
}
// Close detaches a backend whose sessions survive a restart
// (chatShutdownDetacher) instead of stopping it.
defer chats.Close()
}
srv := &http.Server{Addr: *addr, Handler: server.HandlerWithOptions(ctx, options, store), ReadHeaderTimeout: 5 * time.Second}
// Deferred before WaitRuns so it runs after the runs settle: the owned stage