Skip to content

fix: refresh pending approvals when reopening chat - #139457

Merged
steipete merged 1 commit into
mainfrom
codex/qa30-03-approval-replay-20260905
Sep 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa30-03-approval-replay-20260905

Conversation

@steipete

@steipete steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users reopening a chat, or opening the same session in another pane, could see resolved approvals again and miss new pending approvals while the sidebar or another pane kept the session subscribed.

Why This Change Was Made

The shared connection coordinator now deduplicates in-flight replay requests and fetches the current pending set for each later approval viewer. Removing the lifetime replay cache also consolidates canonical response handling. Timeout recovery preserves the approval capability held by existing leases; server authorization and approval storage remain the authorities.

User Impact

Newly opened chat panes show the current approvals. A failed refresh does not interrupt approval updates in an already-open pane.

Evidence

  • node scripts/run-vitest.mjs packages/gateway-client/src/session-subscriptions.test.ts: 32 passed, covering replay freshness, concurrent ownership, rejection, timeout compensation, release, and connection retirement. Three freshness cases failed on the baseline before the repair.
  • node scripts/check-changed.mjs -- packages/gateway-client/src/session-subscriptions.ts packages/gateway-client/src/session-subscriptions.test.ts: passed.
  • Real Chromium with the source Control UI and canonical mock Gateway: sidebar clicks through four sessions evict the original chat pane while retaining its sidebar subscription. After approvals change, the baseline reopens the resolved approval; the repair fetches and displays the current pending approval. Both runs keep one connection and send no session unsubscribe before reopening. The before/after screenshots were inspected and contain only synthetic data.
  • Fresh managed Codex autoreview: scoped-clean through P2, no accepted/actionable findings.
  • Production +27/−32 (net −5); tests +96.

Before: reopening shows the old approval after the pending set changed.

Before: stale pending approval after reopening chat

After: reopening fetches and displays the current pending approval.

After: current pending approval after reopening chat

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 5, 2026
@steipete
steipete marked this pull request as ready for review September 5, 2026 22:23
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 6:29 PM ET / 22:29 UTC.

ClawSweeper review

What this changes

Refresh pending approvals whenever another chat pane subscribes, while sharing concurrent requests and preserving existing subscriptions after a timeout.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary: fetched main and v2026.9.2 retain stale approval replays. The patch addresses the shared subscription owner, and no blocking correctness defect was found.

Priority: P2
Reviewed head: f020d1e172194c8bf35137a12067ad0e0d1aea66

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with useful lifecycle coverage and no supported blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER classification exempts this PR from the ordinary contributor proof gate, and no material authorization change triggers additional proof. The body reports Chromium exercising the changed coordinator through chat reopening; linked screenshots were unavailable for independent inspection.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER classification exempts this PR from the ordinary contributor proof gate, and no material authorization change triggers additional proof. The body reports Chromium exercising the changed coordinator through chat reopening; linked screenshots were unavailable for independent inspection.
Evidence reviewed 10 items Current main still caches replay: The fetched main implementation returns entry.approvalResponse for later approval acquisitions, preserving a snapshot after the pending set changes.
Released behavior: v2026.9.2 contains the same lifetime replay cache; comparing this module between that tag and fetched main produced no differences.
Owner-boundary repair: Read the complete coordinator. Approval requests are shared only while pending; later acquisitions request fresh replay. Timeout compensation derives the retained mode from acquired handles, while release and connection retirement retain their existing ownership checks.
Findings None None.
Security None None.

How this fits together

Chat panes and sidebar observers share session subscriptions on one Gateway connection. The coordinator obtains pending approval snapshots from the Gateway and supplies them to newly opened panes.

flowchart LR
  A[Chat pane opens] --> C[Shared subscription coordinator]
  B[Existing sidebar and panes] --> C
  C --> D{Replay request pending?}
  D -->|Yes| E[Share pending request]
  D -->|No| F[Gateway checks access and reads pending approvals]
  E --> G[Populate chat approval queue]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -5, Tests +96. Total +91 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 27 32 -5
Tests 1 96 0 +96
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 123 32 +91

Review metrics

Metric Value Why it matters
Production versus tests Production net −5; tests net +96 The repair removes lifetime cache state and consolidates response handling while adding focused lifecycle regressions.

Technical review

Best possible solution:

Keep replay freshness in the shared coordinator, with in-flight deduplication and Gateway-authorized recovery, without adding pane-specific caches or configuration.

Do we have a high-confidence way to reproduce the issue?

Yes: retain a sidebar subscription, change the pending approvals, then reopen the chat pane; current main returns the cached replay. Source proves this path, and the PR reports before/after browser reproduction; this review did not execute it.

Is this the best way to solve the issue?

Yes: removing the lifetime snapshot cache at the shared owner fixes all later approval acquisitions; forcing pane-level unsubscribe would interfere with other observers and duplicate lifecycle policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 40ebdadcafa6.

Labels

Label changes:

  • add P2: Stale approval snapshots affect reopened or additional chat panes while another observer retains the session.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER classification exempts this PR from the ordinary contributor proof gate, and no material authorization change triggers additional proof. The body reports Chromium exercising the changed coordinator through chat reopening; linked screenshots were unavailable for independent inspection.

Label justifications:

  • P2: Stale approval snapshots affect reopened or additional chat panes while another observer retains the session.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER classification exempts this PR from the ordinary contributor proof gate, and no material authorization change triggers additional proof. The body reports Chromium exercising the changed coordinator through chat reopening; linked screenshots were unavailable for independent inspection.

Evidence

What I checked:

  • Current main still caches replay: The fetched main implementation returns entry.approvalResponse for later approval acquisitions, preserving a snapshot after the pending set changes. (packages/gateway-client/src/session-subscriptions.ts:301, 40ebdadcafa6)
  • Released behavior: v2026.9.2 contains the same lifetime replay cache; comparing this module between that tag and fetched main produced no differences. (packages/gateway-client/src/session-subscriptions.ts:301, 3928bad9badf)
  • Owner-boundary repair: Read the complete coordinator. Approval requests are shared only while pending; later acquisitions request fresh replay. Timeout compensation derives the retained mode from acquired handles, while release and connection retirement retain their existing ownership checks. (packages/gateway-client/src/session-subscriptions.ts:300, f020d1e17219)
  • Chat caller and visible result: The chat subscription flow requests approvals only when operator access permits it, rejects obsolete pane generations, and populates the approval queue from the acquired replay. Session-scoped operations share the coordinator and reconnect after failed timeout compensation. (ui/src/pages/chat/chat-history-subscription.ts:279, f020d1e17219)
  • Gateway contract and authorization: Every approval subscription checks operator access before subscribing or reading replay. The existing protocol documents approval opt-in as non-sticky, explaining why timeout recovery must explicitly preserve an older approval pane's mode. These are OpenClaw-owned contracts; the changed path does not depend on the Codex runtime or protocol. (src/gateway/server-methods/sessions-subscriptions.ts:116, f020d1e17219)
  • Final delivery remains authorized: Approval events filter invalidated connections and recheck each record's reviewer binding before broadcast. Replay filters the pending store by session audience and reviewer access; the patch changes neither that authorization nor persisted approval state. (src/gateway/operator-approval-session-events.ts:57, f020d1e17219)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Ready for native merge at f020d1e172194c8bf35137a12067ad0e0d1aea66. node scripts/run-vitest.mjs packages/gateway-client/src/session-subscriptions.test.ts passed all 32 tests; node scripts/check-changed.mjs -- packages/gateway-client/src/session-subscriptions.ts packages/gateway-client/src/session-subscriptions.test.ts passed the full changed gate. Managed review is scoped-clean through P2. Exact-head CI run 33995789391 completed successfully, and native artifact validation plus OPENCLAW_TESTBOX=1 scripts/pr prepare-run 139457 passed with the same head.

The before/after PNGs in the PR were personally inspected. They show the actual source Control UI in Chromium using the canonical mock Gateway: the sidebar retains the subscription while the chat pane is evicted, and reopening changes from the stale approval to the current pending set. This is client/browser proof, not a full Gateway-server run. The unchanged server authorization and replay owners were inspected. The latest ClawSweeper review has no actionable findings. Production is net −5 lines; tests +96.

@steipete
steipete merged commit 1b9849b into main Sep 5, 2026
182 checks passed
@steipete
steipete deleted the codex/qa30-03-approval-replay-20260905 branch September 5, 2026 23:04
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 5, 2026
* origin/main: (95 commits)
  perf(build): avoid unrelated gateway artifact scans (#127757)
  fix(update): deliver terminal progress after long updates (#139289)
  fix(ui): show session hover cards for local chat URLs (#139384)
  perf(ui): reuse unchanged transcript key snapshots (#139400)
  fix(ui): make subagent sessions view-only (#139381)
  fix: open agent state on SQLite builds without extensions (#139487)
  perf(skills): detach cached metadata from source strings (#139478)
  fix(ui): show primary user in multi-agent profile hero (#136736)
  perf(sessions): stop decoding the session row four times per SQLite entry patch (#136361)
  refactor(exec): share package-manager option scans (#139482)
  fix(ci): authorize frozen mobile release candidates (#139441)
  fix: avoid session deletion slowdown in large session stores (#139467)
  perf(gateway): reuse node invocation idle timers (#139354)
  fix(auth): preserve selected profiles across plugin scopes (#139413)
  fix(discord): retain voice input until transcription completes (#139484)
  fix(agents): name Gateway storage failures in run-failure copy (#139409)
  fix: keep subagent checks responsive in large session stores (#139450)
  fix(memory): index notes when optional embeddings cannot start (#139463)
  fix: refresh pending approvals when reopening chat (#139457)
  fix(tooling): preserve Git hook choices during install (#139461)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant