You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d61b552
Browse filesBrowse the repository at this point in the historyBrowse files
fix(chat): recover exact pending outcomes after reconnect
Retain bounded sent and discarded dispositions under the original browser,
device and pane identity. Replay them to a returning connection or an
already attached successor without submitting terminal input again.
Preserve uncertainty when a receipt is missing, expired or only dismissed
by aging out. Keep live connection ownership and remote relay boundaries.
Add ownership, retention, expiry and deferred Enter-reply regressions,
plus before/after browser evidence and pinned OpenClaw ACP research.
Verification: typecheck, 64 scoped unit tests and 3 receipt contracts passed.
The broader 110-case pending suite and fork browser checks also passed;
the final fast suite and final screenshot replay follow this commit.
Refs devswha#2421.
Copy file name to clipboardExpand all lines: docs/codex-unconfirmed/README.md
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,10 +24,54 @@ In `server/core/pending.ts`, a normal client's pending-message removal is sent o
24
24
25
25
The conservative handling avoids resending a delivered message. The unresolved behavior is presentation recovery: the bridge has successfully delivered it, but the returning page cannot recover that exact delivery outcome. Matching transcript text alone would not safely establish message identity. A possible improvement is to retain and resume the exact delivery disposition for the same authenticated browser/device and message ID, without granting permission to send anything.
26
26
27
-
## Validation
27
+
## Original reproduction validation
28
28
29
29
-`bun run build`: passed.
30
30
-`bun run check run bun docs/codex-unconfirmed/reproduce.ts`: passed, including the no-failure control, exact input bytes, reconnect, reload and screenshot.
31
31
- No application implementation was changed. This evidence reproduces one triggering condition; it does not establish why the original browser lost confirmation.
32
32
-`bun run check fast`: failed one unchanged installer test, `scripts/install-node-fallback.test.ts:299`, which expected `[ node]` and received `[]`. Workflow syntax, generated types/themes, typecheck and build passed. No installer change was made as part of this report.
33
33
- Full integration/browser/native Windows suites were not run for this evidence-only branch.
34
+
35
+
## Fork fix
36
+
37
+
The fork now retains ordinary pending-message dispositions using the same browser/device resume
38
+
identity as Pi's existing receipt recovery. It stores at most 1024 sent/discarded outcomes for ten
39
+
minutes and replays the exact ID on reattach. If the committed Enter's reply arrives after a
40
+
successor has already attached, that successor receives the outcome immediately. This does not
41
+
paste or submit anything, resume a queued message,
42
+
or treat matching conversation text as confirmation. Missing receipts remain uncertain.
43
+
44
+
The [OpenClaw research](openclaw-research.md) explains the source-backed comparison: ACPx's
45
+
passive outcome journal and OpenClaw's exact request-ID reconciliation solve a similar separation
46
+
between delivering a prompt and showing its outcome. Ovis keeps its existing terminal send path.
47
+
48
+
The fork was merged with upstream `3c679791` while preserving saved launchers, custom Codex and
49
+
OMP stores, and navigation fixes. To verify the patched behavior with the same fault injection:
50
+
51
+
```sh
52
+
EXPECT_RECEIPT_RECOVERY=1 bun run check run --build bun docs/codex-unconfirmed/reproduce.ts
53
+
```
54
+
55
+
The check verifies one paste and Enter for each message, an exact resumed delivery receipt,
56
+
the completed native-format transcript, no duplicate recovery row, and no further terminal input
57
+
after reconnect and reload. It uses the same stand-in and fictional data as the original evidence.
58
+
59
+
| Before | After receipt recovery |
60
+
| --- | --- |
61
+
|||
62
+
63
+
The fixed run's events and assertions are in [result-fixed.json](result-fixed.json). This covers
64
+
the reproduced receipt-loss case. A bridge restart or a receipt that predates retention cannot
65
+
be reconstructed; an old uncertain copy still needs review and manual dismissal.
66
+
67
+
Receipt resumption keeps Ovis's existing direct-bridge limit: the remote-PC relay strips the
68
+
browser resume ID because its shared bridge token does not identify the originating device.
69
+
Routed remote sessions therefore keep the existing conservative behavior. A stale tab can also
70
+
write an old saved copy after another tab settled it; after a reload and expiry of the server's
71
+
receipt, that copy remains uncertain rather than being guessed delivered.
72
+
73
+
Coverage includes both reconnect orderings, exact message IDs, no extra input, device/browser
74
+
isolation, read-only and revoked clients, retention bounds, and uncertain-row expiry. The existing
75
+
110-case pending contract suite passed before the final ordering adjustment; all three targeted
76
+
receipt contracts and 64 store/history/core tests passed after it. Fork browser checks also passed
77
+
for saved launchers, new-session fields, worktree selection and deep-link navigation.
Research for [Ovis #2421](https://github.com/devswha/ovis/issues/2421), checked 30 October 2026 against primary documentation and source. OpenClaw source: `0f359b36dc48808097dae18767cf9ccb49390ccb`; acpx source: `6ce38c34f4e5aef16bf28ca8b1fb1e6650695c60` (0.21.1), with the watch contract also verified on release 0.21.0 (`c0b9dfdfad12ed4fc000b8ef2efc4b5644f1c3dc`). No live OpenClaw or Codex run was performed.
4
+
5
+
## What OpenClaw owns
6
+
7
+
OpenClaw's current default Codex route is its native Codex app-server integration. Codex through ACP is an explicit alternative using the official `@openclaw/acpx` plugin and `@agentclientprotocol/codex-acp`. The plugin revision inspected pins acpx 0.21.0 and codex-acp 2.2.2. The adapter is a separate Agent Client Protocol project: it starts Codex App Server, translates ACP requests into Codex operations, and translates events back. It is not a way to acknowledge keystrokes sent to an existing Herdr terminal. [OpenClaw routes](https://docs.openclaw.ai/tools/acp-agents), [plugin dependencies](https://github.com/openclaw/openclaw/blob/0f359b36dc48808097dae18767cf9ccb49390ccb/extensions/acpx/package.json), [adapter architecture](https://github.com/agentclientprotocol/codex-acp/blob/ac8d9251de43ab8648a89eb0520e0c606ad78be5/README.md).
8
+
9
+
The ACP stack separates the OpenClaw session identity, backend session identity, request identity and completion. The harness attempt creates a persistent session, obtains an admitted transcript-entry receipt and creates a request ID from that entry plus a UUID. Assistant persistence gets its own idempotency key derived from that request. The runtime exposes `promptStarted`, events and `result` separately. An acknowledgement that transport accepted a prompt does not mean its model turn completed. [Harness admission and request identity](https://github.com/openclaw/openclaw/blob/0f359b36dc48808097dae18767cf9ccb49390ccb/extensions/acpx/src/harness-attempt.ts#L155), [request creation](https://github.com/openclaw/openclaw/blob/0f359b36dc48808097dae18767cf9ccb49390ccb/extensions/acpx/src/harness-attempt.ts#L255), [runtime result surface](https://github.com/openclaw/openclaw/blob/0f359b36dc48808097dae18767cf9ccb49390ccb/extensions/acpx/src/runtime.ts#L1052).
10
+
11
+
## How confirmation survives a disconnected reader
12
+
13
+
ACPx provides passive `sessions watch` for its CLI/shared-session path. Its retained journal associates events with an exact submitting request ID and opaque cursor. A watcher can reconnect from its last cursor and observe `turn_result`, whose status is completed, cancelled or failed. Disconnecting a watcher neither sends the prompt again nor cancels it. `turn_started` means an attempt was selected; `promptStarted` indicates prompt transport acceptance; `turn_result` follows cleanup and checkpoint attempts. If the owner disappeared without recording a result, the observer gets `WATCH_OUTCOME_UNKNOWN`. It must not infer success from partial output. Retention is bounded: expired cursors fail explicitly. Custom in-process stores do not automatically publish this CLI/shared journal. This is an acpx capability; I did not establish that OpenClaw's browser uses this watch API. [Release-pinned watch contract](https://github.com/openclaw/acpx/blob/c0b9dfdfad12ed4fc000b8ef2efc4b5644f1c3dc/docs/session-watch.md), [journal implementation](https://github.com/openclaw/acpx/blob/6ce38c34f4e5aef16bf28ca8b1fb1e6650695c60/src/session/events.ts#L222).
14
+
15
+
OpenClaw's browser has a separate recovery mechanism. Its queued send retains the original request/idempotency key and physical conversation identity through reconnect. Tests explicitly cover reconnecting after a written frame lost its reply. Gateway admission checks the exact previous request and returns cached or in-flight state; the comparison reads the submitted message by its request-derived identity under the session/lifecycle scope and rejects conflicting input. This is stronger than matching a visible string. [Browser reconnect tests](https://github.com/openclaw/openclaw/blob/0f359b36dc48808097dae18767cf9ccb49390ccb/ui/src/pages/chat/chat-outbox-reconnect.test.ts), [written-frame recovery](https://github.com/openclaw/openclaw/blob/0f359b36dc48808097dae18767cf9ccb49390ccb/ui/src/pages/chat/chat-outbox-transient-recovery.test.ts#L170), [cached admission](https://github.com/openclaw/openclaw/blob/0f359b36dc48808097dae18767cf9ccb49390ccb/src/gateway/server-methods/chat-send-pre-admission.ts#L164), [exact request comparison](https://github.com/openclaw/openclaw/blob/0f359b36dc48808097dae18767cf9ccb49390ccb/src/gateway/server-methods/chat-send-retry-comparison.ts#L39).
16
+
17
+
Its pending-input UI queries exact run IDs and reconciles pending/consumed/cancelled custody receipts. A receipt or an explicitly queried absence can retire that specific projection; an unrelated empty history page cannot settle arbitrary saved input. The UI also checks the physical session before removing a browser queue copy. [Pending-input reconciliation](https://github.com/openclaw/openclaw/blob/0f359b36dc48808097dae18767cf9ccb49390ccb/ui/src/pages/chat/chat-pending-inputs.ts#L36), [settling queue copies](https://github.com/openclaw/openclaw/blob/0f359b36dc48808097dae18767cf9ccb49390ccb/ui/src/pages/chat/chat-pending-inputs.ts#L218).
18
+
19
+
Cancellation is explicit. ACPx requests cooperative session cancellation and waits briefly for a cancelled result before forced cleanup. Watching/disconnecting alone is observation. OpenClaw separately stops automatic ingress startup retries once a prepared ACP turn is accepted, so a slow answer is not a reason to dispatch the trigger again. [ACPx cancellation](https://github.com/openclaw/acpx/blob/c0b9dfdfad12ed4fc000b8ef2efc4b5644f1c3dc/docs/sessions.md#cancelling), [OpenClaw delivery rules](https://github.com/openclaw/openclaw/blob/0f359b36dc48808097dae18767cf9ccb49390ccb/docs/tools/acp-agents/delivery.md#delivery-model).
20
+
21
+
## Applying the lesson to Ovis
22
+
23
+
The transferable mechanism is exact, server-owned outcome recovery. ACP itself is not required. Ovis already has a PTY send boundary and a browser/device receipt-resume identity for Pi. Extend the presentation recovery pattern rather than replacing how a terminal receives prompts.
24
+
25
+
Proposed bounded change, inferred from those sources and Ovis's reproduced failure:
26
+
27
+
1. Retain each ordinary pending message's terminal disposition under its exact message ID, pane and authenticated browser/device resume owner. Record it before trying to notify the socket. Retain no execution authority.
28
+
2. On reattach by that same owner, replay successful/withdrawn dispositions through the existing pending-message protocol. Let an exact receipt settle the corresponding recovery copy even though its old connection scope is gone.
29
+
3. Reconnecting performs no paste, Enter or prompt resubmission. Do not copy OpenClaw's automatic `chat.send` retry into Ovis: its send contract differs.
30
+
4. An expired, missing or unprovable receipt leaves the saved row uncertain. Text equality, agent completion and an empty snapshot are not delivery receipts. Preserve Herdr lifetime fencing and owner isolation.
31
+
32
+
Tests should lose the successful removal receipt, reconnect and reload, then prove the exact row disappears and terminal bytes remain a single delivery. Also cover a different resume owner/device, two same-text sends with different IDs, no receipt, retention expiry, live ownership on another connection, a replaced Herdr lifetime, duplicate receipts, and a failure after paste but before committed Enter. A before/after screenshot should use the same fictional transcript and fault boundary.
33
+
34
+
This repairs one proven trigger of #2421. It does not establish why the original browser lost confirmation, provide exactly-once execution across bridge restarts, or prove that a PTY Enter is a native Codex model-acceptance acknowledgement.
constsummary={upstream: Bun.spawnSync(["git","rev-parse","HEAD"]).stdout.toString().trim(),agent: "byte-recording stand-in, fictional Codex-format transcript; no native Codex/model run",control: "one delivery, row removed",receiptLoss: "one delivery; sent receipt lost before browser; reconnect and reload leave uncertain row",nativeTranscript: "completed user and assistant turns visible in Chat",replayed: false, connections,pendingEvents: events};
constsummary={revision: Bun.spawnSync(["git","rev-parse","HEAD"]).stdout.toString().trim(),recovery,agent: "byte-recording stand-in, fictional Codex-format transcript; no native Codex/model run",control: "one delivery, row removed",receiptLoss: recovery ? "one delivery; lost sent receipt replayed after reconnect; no recovery row after reconnect or reload": "one delivery; sent receipt lost before browser; reconnect and reload leave uncertain row",nativeTranscript: "completed user and assistant turns visible in Chat",replayed: false, connections,pendingEvents: events};
0 commit comments