Skip to content

fix(ui): back off unavailable session PR polling - #114266

Merged
steipete merged 5 commits into
mainfrom
fix/ui-pr-poller-backoff
Jul 27, 2026
Merged

steipete merged 5 commits into
mainfrom
fix/ui-pr-poller-backoff

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

A connected Control UI client hammers the gateway with controlUi.sessionPullRequests at ~11–14 calls per second, sustained for minutes, every reply failing. Production journal on team.openclaw.ai (2026-07-27 03:05 UTC, one connection, back-to-back):

[ws] ⇄ res ✗ controlUi.sessionPullRequests 68ms errorCode=UNAVAILABLE errorMessage=session pull requests unavailable conn=ced84e56…77d2
[ws] ⇄ res ✗ controlUi.sessionPullRequests 69ms errorCode=UNAVAILABLE ... (×10+ per second)

Mechanism: the sidebar PR indicators iterate worktree session rows sequentially, and every caller gates only on isGatewayMethodAdvertised(...). The method is advertised while its runtime dependency is down (src/gateway/server-methods/control-ui.ts:68 answers UNAVAILABLE), so each ~68ms failure immediately advances to the next row — an unbounded poll loop the advertised-method gate can never stop.

Why This Change Was Made

Availability is a property of the connection, not of each call site, so the gate lives in GatewayBrowserClient.requestSessionPullRequests() and every caller (sidebar indicators via session-menu-work.ts, chat suggestions) routes through it:

  • A non-retryable UNAVAILABLE latches the surface off until the next socket hello.
  • Retryable failures back off 30s doubling to a 5min cap, honoring longer server retryAfterMs hints.
  • A generation counter prevents concurrent in-flight rows from multiplying one outage wave's backoff; connection open/hello resets the state.
  • Suppressed requests resolve null; consumers already handle the absent-summary case.

One shared helper instead of per-callsite patches, matching how other optional gateway surfaces are consumed.

User Impact

No more request-spam floods against gateways whose session-PR provider is unavailable (each flood burned ~70ms of gateway work per call, 14×/s, per client). Indicators quietly resume when the surface recovers or the client reconnects.

Evidence

  • Journal evidence above; loop mechanism verified in app-sidebar-session-pr-indicators.ts (sequential row iteration) and chat-pane-suggestions.ts.
  • New ui/src/api/gateway.node.test.ts (257 lines): permanent-unavailable latch, retryable backoff with server hint, concurrent-row generation guard, reconnect reset, response ordering.
  • Updated caller tests: session-menu-work.test.ts, app-sidebar-session-pr-indicators.test.ts, chat-pane-pull-requests.test.ts, chat-pane.test.ts — all green (focused rerun after squash: 1 shard, passed).
  • Worker's broader runs: 49 gateway + 8 sidebar/menu + 45 chat-pane tests green; oxfmt/oxlint/git diff --check clean.
  • Autoreview (Codex gpt-5.6-sol, xhigh): clean, "patch is correct (0.91)".

@steipete
steipete marked this pull request as ready for review July 27, 2026 03:38
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Jul 27, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 2:36 AM ET / 06:36 UTC.

ClawSweeper review

What this changes

This PR makes the Control UI browser gateway client suppress or back off session pull-request RPC calls after the gateway reports that the session-PR surface is unavailable, and routes sidebar and chat callers through that shared method.

Merge readiness

⛔ Blocked until real behavior proof is added - 3 items remain

Keep this PR open for human merge review. The shared browser-client gate is a coherent fix for an availability failure that current main does not yet contain, and the related gateway cache PR addresses a separate server-cost concern; however, this PR still has no after-fix connected-gateway evidence showing that request volume is bounded and that the UI recovers as intended. The protected maintainer label also requires explicit maintainer handling.

Likely related people: steipete is the strongest routing candidate (medium confidence) through the merged session-PR gateway work and this proposed shared-client change.

Priority: P1
Reviewed head: 044e395a48e8be011bea0afb384350efcbc8db67

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and has strong targeted test coverage, but missing after-fix real behavior proof remains a merge gate.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR contains pre-fix journal evidence and focused test/CI claims, but no after-fix connected-gateway evidence showing bounded polling and the intended recovery behavior. Add redacted terminal output, gateway logs, live output, or a recording; redact private endpoints, IP addresses, and tokens. Updating the PR body should trigger a fresh review, or a maintainer can request one with @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR contains pre-fix journal evidence and focused test/CI claims, but no after-fix connected-gateway evidence showing bounded polling and the intended recovery behavior. Add redacted terminal output, gateway logs, live output, or a recording; redact private endpoints, IP addresses, and tokens. Updating the PR body should trigger a fresh review, or a maintainer can request one with @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Shared client boundary: The branch adds connection-scoped unavailable and retry state plus requestSessionPullRequests() to the browser gateway client, placing the suppression policy before individual UI callers.
Caller coverage: The sidebar/session-menu path and chat suggestions now call the shared client method and explicitly tolerate a null result, covering the two request sources described in the report.
Focused branch coverage: The branch adds gateway-client cases for permanent unavailability, retryable backoff, concurrent requests, reconnect reset, and response ordering, with related caller-test updates.
Findings None None.
Security None None.

How this fits together

The Control UI fetches per-session pull-request summaries from a gateway RPC for sidebar indicators and chat suggestions. The browser gateway client is the shared boundary between those UI refreshes and the server-side session-PR provider, so it can prevent each caller from independently retrying an unavailable service.

flowchart LR
  Sidebar[Sidebar PR indicators] --> Client[Browser gateway client]
  Chat[Chat PR suggestions] --> Client
  Client --> Gate{Availability and retry gate}
  Gate --> RPC[Session PR gateway RPC]
  RPC --> Provider[Session PR provider]
  Gate --> UI[Null summary or PR summary]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR contains pre-fix journal evidence and focused test/CI claims, but no after-fix connected-gateway evidence showing bounded polling and the intended recovery behavior. Add redacted terminal output, gateway logs, live output, or a recording; redact private endpoints, IP addresses, and tokens. Updating the PR body should trigger a fresh review, or a maintainer can request one with @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P0) - A non-retryable unavailable response intentionally suppresses session-PR summaries until a new socket hello; without live outage-and-recovery evidence, maintainers cannot yet verify that this reduces request floods without leaving a recovered surface unavailable longer than intended.
  • Complete next step (P2) - The protected maintainer label and missing contributor-side real behavior proof require a human merge decision; there is no narrow code defect for the repair lane to make on the contributor's behalf.
Agent review details

Security

None.

PR surface

Source +75, Tests +319. Total +394 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 93 18 +75
Tests 6 338 19 +319
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 431 37 +394

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: ui/src/api/gateway.node.test.ts, serialized state: ui/src/components/session-menu-work.test.ts, serialized state: ui/src/components/session-menu-work.ts, serialized state: ui/src/test-helpers/app-sidebar-cases/sessions.ts, unknown-data-model-change: ui/src/components/session-menu-work.test.ts, unknown-data-model-change: ui/src/components/session-menu-work.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Add live outage-and-recovery proof (recommended)
    Capture a redacted connected-gateway run showing the unavailable response, bounded follow-up requests, and the intended recovery path before merge.
  2. Accept the unproven retry policy
    A maintainer may merge based on the focused tests and CI, accepting that the real unavailable-provider and recovery behavior has not been demonstrated.
  3. Pause the availability policy
    Pause this PR if a realistic connected-gateway setup cannot demonstrate that the chosen latch and backoff semantics are safe for Control UI users.

Technical review

Best possible solution:

Retain the shared client-side gate, then add redacted connected-gateway proof showing a failed session-PR provider produces one bounded request wave, the expected suppression/backoff behavior, and summary recovery after the intended reset path before a maintainer decides to merge.

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

No high-confidence live reproduction was established in this read-only review. The source and report describe a credible loop through the advertised RPC callers, but the available evidence is pre-fix journal output rather than a reproducible current connected-gateway scenario.

Is this the best way to solve the issue?

Yes, provisionally: centralizing availability control in the shared browser gateway client is narrower and less drift-prone than separately patching sidebar and chat callers. The remaining requirement is live proof that its latch, retry, and reset semantics match real gateway behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 054495d16dd6.

Labels

Label justifications:

  • P1: The proposed fix addresses sustained failed gateway polling from active Control UI clients, an urgent workflow availability regression with real-user gateway load.
  • merge-risk: 🚨 availability: The PR changes when the Control UI suppresses and resumes a gateway-backed summary request, so an incorrect retry or reset policy can make PR indicators unavailable.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR contains pre-fix journal evidence and focused test/CI claims, but no after-fix connected-gateway evidence showing bounded polling and the intended recovery behavior. Add redacted terminal output, gateway logs, live output, or a recording; redact private endpoints, IP addresses, and tokens. Updating the PR body should trigger a fresh review, or a maintainer can request one with @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Shared client boundary: The branch adds connection-scoped unavailable and retry state plus requestSessionPullRequests() to the browser gateway client, placing the suppression policy before individual UI callers. (ui/src/api/gateway.ts:310, 044e395a48e8)
  • Caller coverage: The sidebar/session-menu path and chat suggestions now call the shared client method and explicitly tolerate a null result, covering the two request sources described in the report. (ui/src/components/session-menu-work.ts:62, 044e395a48e8)
  • Focused branch coverage: The branch adds gateway-client cases for permanent unavailability, retryable backoff, concurrent requests, reconnect reset, and response ordering, with related caller-test updates. (ui/src/api/gateway.node.test.ts:608, 044e395a48e8)
  • Current-main separation: The PR remains open at head 044e395a48e8be011bea0afb384350efcbc8db67; the supplied current-main SHA is 054495d16dd6c161a3afc1429d299b060dc1676d, so this client-side availability guard is not implemented on current main. (ui/src/api/gateway.ts:310, 054495d16dd6)
  • Adjacent merged work: Merged PR perf(gateway): cache session-PR local git facts #114311 added server-side caching for local git facts behind the same RPC. Its stated composition with this PR supports treating it as an adjacent performance fix rather than a replacement for client request suppression. (src/gateway/server-methods/control-ui.ts:68, 885121b1f325)
  • Proof gate remains unmet: The current PR body provides pre-fix production journal excerpts and test/CI claims, but no post-fix connected-gateway log, terminal output, recording, or other live evidence that failed calls are bounded and recovery behavior works. The latest completed ClawSweeper review also requested this proof. (044e395a48e8)

Likely related people:

  • steipete: This person authored the current shared-client proposal and the merged adjacent session-PR gateway caching work, providing concrete feature-history context beyond this PR alone. (role: recent area contributor; confidence: medium; commits: 885121b1f325, 237c31229690; files: ui/src/api/gateway.ts, src/gateway/server-methods/control-ui.ts)

Rank-up moves

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

  • Add redacted connected-gateway evidence that proves failed polling is bounded and demonstrates the intended recovery/reset path.

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 (3 earlier review cycles)
  • reviewed 2026-07-27T03:43:12.480Z sha fd724aeb388184941624a976d98f0366fc6c456f :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T03:51:13.564Z sha 992ff2540782a0eff4156a8612153d718a8d814d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T05:57:50.233Z sha 43a3212 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 27, 2026
steipete added 3 commits July 27, 2026 01:45
The sidebar PR indicators iterated worktree rows sequentially; each ~68ms
UNAVAILABLE reply immediately advanced to the next row, hammering
controlUi.sessionPullRequests at ~14 calls/second forever (the method is
advertised while its runtime dependency is down, so the advertised-method
gate never stopped it).

Route all callers through GatewayBrowserClient.requestSessionPullRequests:
a non-retryable UNAVAILABLE latches until the next socket hello; retryable
failures back off 30s doubling to 5min, honoring longer server retry hints.
A generation counter keeps concurrent rows from multiplying one outage wave.
Type the PR-indicator request mocks with real signatures instead of bare
vi.fn shells, and keep GatewaySessionPullRequestsParams module-local until a
second consumer exists.
@steipete
steipete force-pushed the fix/ui-pr-poller-backoff branch from 992ff25 to 0ace42f Compare July 27, 2026 05:46
@steipete
steipete merged commit 9a0fa8f into main Jul 27, 2026
91 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the fix/ui-pr-poller-backoff branch July 27, 2026 06:49
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 27, 2026
* fix(ui): back off unavailable session PR polling

The sidebar PR indicators iterated worktree rows sequentially; each ~68ms
UNAVAILABLE reply immediately advanced to the next row, hammering
controlUi.sessionPullRequests at ~14 calls/second forever (the method is
advertised while its runtime dependency is down, so the advertised-method
gate never stopped it).

Route all callers through GatewayBrowserClient.requestSessionPullRequests:
a non-retryable UNAVAILABLE latches until the next socket hello; retryable
failures back off 30s doubling to 5min, honoring longer server retry hints.
A generation counter keeps concurrent rows from multiplying one outage wave.

* fix(ui): satisfy test-types and knip lanes

Type the PR-indicator request mocks with real signatures instead of bare
vi.fn shells, and keep GatewaySessionPullRequestsParams module-local until a
second consumer exists.

* test(ui): route hydration stubs through the PR latch wrapper

* chore(ui): drop unused ControlUiSessionPullRequests re-export

* test(ui): stub the PR latch wrapper in sidebar and clobber fixtures
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 maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant