Retain Codex interaction callbacks across server restarts

This commit is contained in:
2026-11-05 14:32:59 +00:00
parent c7e57973a0
commit c2a8f5ff16
20 changed files with 1356 additions and 18 deletions
+9 -3
View File
@@ -4,7 +4,8 @@
// normally reached over a Unix WebSocket socket (the desktop app and the CLI use
// the same control socket). This adapter owns one client connection and mirrors
// the protocol into the Pipelines chat frames; it never starts a second Codex
// daemon or changes the operator's Codex configuration.
// daemon or changes the operator's Codex configuration. Installed servers use
// a private connection host to retain pending interactions during restarts.
package codex
import (
@@ -116,6 +117,11 @@ func Open(ctx context.Context) (*Chat, error) {
if socket == "" {
return nil, errors.New("Codex home is unavailable")
}
var socketErr error
socket, socketErr = connectionSocket(ctx, socket)
if socketErr != nil {
return nil, fmt.Errorf("attach Codex connection host: %w", socketErr)
}
transport := &http.Transport{
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
return (&net.Dialer{}).DialContext(ctx, "unix", socket)
@@ -180,8 +186,8 @@ func (c *Chat) Close() {
// in the Codex App Server, not in this client, so closing the control
// connection leaves them running; no turn is interrupted. The next server
// process reconnects and reconciles each thread through thread/read. An
// approval or question the App Server sent to this connection is bound to it,
// so one still pending at shutdown is not answerable after the restart.
// approval or question is retained by the configured connection host and
// replayed on reattach. Direct mode cannot retain connection-bound callbacks.
func (c *Chat) Detach() { c.Close() }
func (c *Chat) readLoop() {