Skip to content

fix(ui): stop retrying rejected unread patches - #149359

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-ui-unread-patch-rejections-20260915
Sep 16, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-ui-unread-patch-rejections-20260915

Conversation

@steipete

@steipete steipete commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes repeated rejected read acknowledgements while a Control UI viewer watches a shared session. On team.openclaw.ai on September 15, one hour contained 3,077 sessions.patch calls, 3,021 rejected with INVALID_REQUEST / session is shared for this connection; 2,943 came from one Control UI connection (about one every 1.2 seconds), adding request-handler work to a saturated Gateway main thread.

User Impact

Opening a session as a viewer no longer sends an automatic read patch. Other permanent read-patch rejections appear once per unread episode instead of triggering another request on every active-session snapshot. Temporary failures and unsent requests remain retryable.

No visual change; screenshots are intentionally omitted for this behavior-only work order. No server semantics, sharing permissions, configuration, or storage changes.

Why This Change Was Made

The Gateway composes this rejection in authorizeSessionSharingTarget: shared viewers are denied when their operator role caps participation at viewing or suggesting. The general method-access check does not include that session policy. Chat already receives caller-specific sharingRole, so its automatic read path skips viewers without changing the composer participation tracker.

SessionUnreadPatchGuard now retains its episode latch for the gateway client's canonical INVALID_REQUEST, FORBIDDEN, and APPROVAL_NOT_FOUND codes. Session-not-found responses already use INVALID_REQUEST; there is no generic NOT_FOUND in this protocol. The existing session capability remains the error publisher. Confirmed read/new-activity episodes and navigation reset the existing guard; manual unread reminders keep their existing behavior.

Tradeoff: ordinary Chat rows omit the full role cap. Uncapped shared viewers can be writable on the server, but also skip automatic acknowledgements. Authorized explicit read actions remain available. The more precise activitySummary.canEnsure permission is only projected for Activity requests; this change does not add summary work to Chat roster reads.

Evidence

Regression-first proof, with production files unchanged: 8 failed, 28 passed. Shared viewer cases sent a patch instead of zero; permanent rejection cases expected one request but received two; the guard retried the same rejected episode.

After the fix: 52 passed across 4 files, including permanent rejection/error-publication cases, UNAVAILABLE, client timeouts, null/unsent results, shared viewers, owner/member/admin acknowledgements, optimistic rollback, manual reminders, and retained-pane activation.

node scripts/run-vitest.mjs run --config ui/vitest.config.ts ui/src/lib/sessions/unread.test.ts ui/src/pages/chat/chat-pane.read-marker.test.ts ui/src/lib/sessions/session-unread-mutations.test.ts ui/src/pages/chat/chat-pane-state.test.ts
node scripts/check-changed.mjs
git diff --check

Key regressions: handles INVALID_REQUEST read failures across active snapshots, does not mutate unread state with shared viewer participation, and latches a INVALID_REQUEST rejection until a new unread episode or activation. The request/error test uses the real session capability and a synthetic Gateway client.

The browser participation regression also passes all 7 cases. It now checks that shared viewers keep their unread marker across session updates without disabling their composer, while shared members still acknowledge reads:

node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-management.unread.e2e.test.ts
node scripts/check-changed.mjs -- ui/src/e2e/session-management.unread.e2e.test.ts

Validation status: 52 unit/integration tests, 7 browser E2E cases, and all 92 native wrapper tests passed on the rebased tree. Changed-file checks and git diff --check passed; fresh independent Codex review is clean through P2. Current head: 749812bf3389bb1ca10ae1fe7a0e1eb8da034a60, rebased onto main including the unrelated validation fixes in #149349, #149423, and #149477. Exact-head CI is pending.

Docs: updated Sessions and sidebar automatic-read behavior. Known gaps: no production Gateway was changed or used for validation; this PR does not claim a measured post-deployment CPU reduction. The coordinator owns landing.

@clawsweeper

clawsweeper Bot commented Sep 15, 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.

@steipete
steipete marked this pull request as ready for review September 15, 2026 19:21
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Sep 15, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 15, 2026, 10:15 PM ET / September 16, 2026, 02:15 UTC (Revision 6).

ClawSweeper review

What this changes

The Control UI skips automatic read acknowledgements for viewers and stops retrying permanent Gateway rejections, with updated tests and documentation.

Merge readiness

⛔ Blocked before merge - 2 items remain

This fix remains necessary on current main, and the earlier browser-test finding is resolved. No blocking code defect was found, but the visible unread-badge change still requires the repository’s before/after screenshot evidence.

Priority: P2
Reviewed head: 749812bf3389bb1ca10ae1fe7a0e1eb8da034a60

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation and regression coverage are sound, with readiness limited by the applicable visible-proof gate.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 8 items Introduced scope verified: The merge-base-to-head comparison contains exactly the six supplied UI, test, and documentation paths; diff whitespace validation passed. The checkout remained clean.
Current main still retries permanent failures: Current main’s patchFailed unconditionally clears the request latch; its chat caller does not pass the rejection or exclude shared viewers. The requested repair remains absent.
Latest release also retains the old guard: The v2026.9.4 version of the unread guard likewise unlatches every failed patch; this release does not contain the proposed rejection classification.
Findings None None.
Security None None.

How this fits together

The Control UI consumes Gateway session updates and acknowledges unread activity when a conversation is opened. Its unread guard controls repeat requests, while the session capability publishes errors and reconciles sidebar badges.

flowchart TD
  A[Gateway session updates] --> B[Active chat pane]
  B --> C{Viewer or restricted access?}
  C -->|Yes| D[Keep unread badge]
  C -->|No| E[Unread episode guard]
  E --> F[Gateway read acknowledgement]
  F -->|Permanent rejection| G[Publish error and retain latch]
  F -->|Temporary failure| E
  F -->|Success| H[Reconcile read state]
Loading

Before merge

  • Resolve merge risk (P1) - Existing uncapped shared viewers lose automatic read acknowledgement and retain unread badges until an authorized explicit read action; the intended tradeoff is documented, but visible before/after evidence remains outstanding.
  • Complete next step (P2) - Supply inspected, sanitized before/after unread-badge screenshots rendered in both the originating chat and PR, or an explicit user waiver covering both destinations.
Agent review details

Security

None.

PR surface

Source +9, Tests +86, Docs 0. Total +95 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 16 7 +9
Tests 3 110 24 +86
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 127 32 +95

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Validate the documented viewer tradeoff (recommended)
    Provide the required before/after badge evidence, including the retained explicit-read recovery, before accepting the narrower automatic acknowledgement policy.

Technical review

Best possible solution:

Retain the bounded rejection latch and documented viewer policy, with visible proof of badge retention and authorized read recovery before landing.

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

Yes, from source: a rejected automatic read patch on current main clears the latch, allowing the next active-session update to retry. The PR reports regression-first failures; this review did not execute tests.

Is this the best way to solve the issue?

Yes, within the explicitly documented viewer tradeoff: the change extends the existing guard and error owner without adding server permissions, storage, or competing mutation paths.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 589268ffdbac.

Labels

Label justifications:

  • P2: This is a focused Control UI reliability repair for repeated rejected read acknowledgements.
  • merge-risk: 🚨 compatibility: The introduced viewer check also disables automatic acknowledgements for existing shared viewers whom the Gateway permits to write.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

  • Introduced scope verified: The merge-base-to-head comparison contains exactly the six supplied UI, test, and documentation paths; diff whitespace validation passed. The checkout remained clean. (749812bf3389)
  • Current main still retries permanent failures: Current main’s patchFailed unconditionally clears the request latch; its chat caller does not pass the rejection or exclude shared viewers. The requested repair remains absent. (ui/src/lib/sessions/unread.ts:57, 589268ffdbac)
  • Latest release also retains the old guard: The v2026.9.4 version of the unread guard likewise unlatches every failed patch; this release does not contain the proposed rejection classification. (ui/src/lib/sessions/unread.ts:57, 3a9d69db306c)
  • Existing owner and error contract preserved: The chat pane forwards the original rejection to the guard. The existing session mutation owner rolls back optimistic state, publishes the error, and rethrows it; the local gateway-client error exposes gatewayCode. These are OpenClaw-owned contracts and establish no Codex dependency. (ui/src/pages/chat/chat-pane-session.ts:322, 749812bf3389)
  • Viewer compatibility tradeoff is real and disclosed: Gateway authorization permits an uncapped viewer to mutate a shared session, whereas the introduced UI check skips every viewer. The PR body explicitly acknowledges this narrower automatic-read behavior and retains authorized explicit read actions. (src/gateway/session-sharing-policy.ts:343, 749812bf3389)
  • Prior browser finding resolved: The browser matrix now independently checks composer restrictions and automatic acknowledgements: shared viewers keep their badge with an enabled composer, while shared members acknowledge reads. Permanent-error, temporary-error, unsent-request, manual-reminder, and activation cases are covered in the inspected tests. Reported executions were not rerun during this read-only review. (ui/src/e2e/session-management.unread.e2e.test.ts:22, 749812bf3389)

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach inspected before/after unread-badge screenshots in the originating chat and PR and verify both render, or record an explicit user waiver covering both destinations. Redact private details; updating the PR body should trigger re-review, otherwise ask a maintainer to comment @clawsweeper re-review.

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.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-15T19:27:26.003Z sha 901a661 :: blocked before merge. :: none
  • reviewed 2026-09-15T20:04:32.522Z sha 901a661 :: blocked before merge. :: none
  • reviewed 2026-09-15T20:41:22.969Z sha b477e7d :: blocked before merge. :: [P2] Update the shared-viewer browser case for the new acknowledgement policy
  • reviewed 2026-09-15T21:55:46.861Z sha eef07b0 :: blocked before merge. :: none
  • reviewed 2026-09-15T23:00:14.986Z sha 0185ccdd92e96b57946b8ea91ef3e43de15b3bfd :: blocked before merge. :: none

@steipete
steipete force-pushed the steipete/perf-ui-unread-patch-rejections-20260915 branch from 901a661 to b477e7d Compare September 15, 2026 20:26
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 15, 2026
@steipete
steipete force-pushed the steipete/perf-ui-unread-patch-rejections-20260915 branch from eef07b0 to 0185ccd Compare September 15, 2026 22:13
Skip automatic read acknowledgements for session viewers. Keep permanent Gateway rejections latched for the current unread episode while preserving transient retries and the existing session capability error path.
Expect shared viewers to keep unread state across session updates while their composer remains enabled. Retain automatic acknowledgement coverage for shared members.
@steipete
steipete force-pushed the steipete/perf-ui-unread-patch-rejections-20260915 branch from 0185ccd to 749812b Compare September 16, 2026 02:06
@steipete
steipete merged commit 2031d48 into main Sep 16, 2026
133 checks passed
@steipete
steipete deleted the steipete/perf-ui-unread-patch-rejections-20260915 branch September 16, 2026 03:31
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
* fix(ui): stop retrying rejected unread patches

Skip automatic read acknowledgements for session viewers. Keep permanent Gateway rejections latched for the current unread episode while preserving transient retries and the existing session capability error path.

* test(ui): cover shared viewer read acknowledgements

Expect shared viewers to keep unread state across session updates while their composer remains enabled. Retain automatic acknowledgement coverage for shared members.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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