Retain Codex interaction callbacks across server restarts
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user