Skip to content

perf(gateway): stop polling checkout context for idle sidebar rows - #159390

Merged
steipete merged 4 commits into
mainfrom
steipete/perf-micro-checkout-context-poll-idle-zero-20260919
Sep 27, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/perf-micro-checkout-context-poll-idle-zero-20260919

Conversation

@steipete

@steipete steipete commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Related: #159301

What Problem This Solves

An idle Control UI sidebar subscribes every listed checkout to PR refreshes, repeatedly spawning Git even when none of those sessions is open.

User Impact

Sidebar indicators retain their last-known summaries without starting checkout polling. Viewed sessions, PR menus, and activity panels still refresh their facts. Tool completion refreshes unstaged changes; edits made outside OpenClaw have a five-minute fallback while a consumer is present. No new configuration or stored-data migration.

Why This Change Was Made

The existing subscription owner already stops polling an empty watched set. Make sidebar observation passive in the shared UI store, keep active consumers in its bounded subscription set, and coalesce tool/lifecycle completion through the existing refresh mechanism.

The Git read owner validates HEAD, index, refs, packed refs, and checkout metadata in its worker before rerunning Git. It retains context while metadata is unchanged and preserves explicit refresh for unsupported metadata layouts. Branch stats keep the existing diff/landing semantics, including unstaged and untracked changes. Disable Git's automatic index stat refresh for this read-only diff, which otherwise invalidates its own cache revision. Revision reads retire with the existing Gateway/cache lifecycle.

Evidence

Real Git fixture: 40 linked worktrees plus 3 project checkouts, with ten minutes of 60-second polls advanced by a controlled clock. Counts are actual Git commands through the broker; fixture setup is excluded.

Scenario Before, Git spawns/min After, Git spawns/min
Sidebar inventory with no active consumer 64.5 0
One idle active checkout 1.5 0.4
All 43 explicitly active 64.5 17.2

One unstaged edit with an active consumer takes 2 Git spawns. The no-consumer measurement uses the real subscription owner's unsubscribe/poll boundary; the UI regression proves that 40 sidebar rows send an empty subscription set and only a viewed checkout becomes active.

Blacksmith Testbox (blacksmith-testbox, profile openclaw-check): baseline lease tbx_01m3g98e3vzz1zsghv0qy53krp; full proof lease tbx_01m3gc050r3c5wz1e5ajdzb41g, run. Candidate source hashes were checked before execution.

  • node scripts/run-vitest.mjs on the Git/PR/subscription owners: 138 tests passed, including the temporary 43-checkout measurement; 79.18 s wall.
  • Focused Control UI store/sidebar tests: 53 passed, 2.06 s wall.
  • Three UI regressions and the idle-cache regression fail against the original production code for their intended assertions.
  • Independent Codex review through P2: clean after fixing unsupported-layout forced refresh.

Validation follow-up: the full changed-check run passed core/UI types, all 25 selected test type graphs, metadata/ownership guards, formatting, and all three dead-export scans. It then found one shadowed variable in a test callback; that variable was renamed. Final source rerun: 149 tests passed; core types and the changed Gateway/infra test graphs passed; the native changed-check lint plan passed with zero warnings/errors. Previously passed unaffected checks were reused.

Final per-file cost on the proof lease, using pnpm test <file> --maxWorkers=1: branch facts 44.93 s wall (50 existing/extended Git cases, including cold worker compilation; test execution below 30 s), PR loader 21.39 s, retention 12.81 s, Git cache 1.76 s, UI store 1.97 s, sidebar indicators 2.01 s. The new Git regression extends the existing real-checkout suite because mocked Git cannot prove metadata invalidation or index-write behavior.

The existing repository-session retention fixture was updated for the new metadata operation: pnpm test src/gateway/server.sessions.create.repositories.test.ts --maxWorkers=1 passed all 11 tests (38.34 s runner wall, including cold compilation) on recovery lease tbx_01m3gehpbctrxrqy3maqzj3stz (run). Its complete scoped check-changed also passed.

Testbox recovery: several reused-lease checksum syncs timed out before test execution, requiring replacement leases. An initial unpinned changed-check selected unrelated changes from a newer remote main; the full proof pins base 2b4a2749587e and the lane's paths. No live Gateway was restarted or modified. UI changes concern subscription behavior; templates and appearance are unchanged.

Initial CI found one obsolete sidebar polling expectation, fixed here by seeding the existing last-known-summary owner while preserving the rendering assertions. The other 16 failures came from main's list normalization and are fixed upstream by #159394; this branch consumes that canonical repair. CI's other 124 jobs were cancelled by fail-fast, not independent failures. The inherited failures were reproduced on Testbox during diagnosis; the final diff contains no competing roster-normalization repair.

Final replay with the canonical main repair: blacksmith-testbox lease tbx_01m3gkh19vfasfcskmzvgp01r7 (run). Eight UI files, including every formerly failing file plus the PR store/sidebar owners: 345 passed, 24.78 s Vitest wall. Native changed-check lint, formatting, and i18n verification passed. Final independent P2 review is clean. All leases are stopped.

The next CI run passed all three UI unit shards (336 s / 326 s / 331 s). Two E2E layout fixtures still waited for the retired background subscription; their setup now seeds last-known summaries through the real session store, retaining every geometry, hover, focus, and accessibility assertion. check-changed for that test file passed on tbx_01m3gnxpdjpzz869xb6ysghr6f (run), including E2E types (43.3 s), lint, and all dead-export scans. Independent review is clean. Browser execution is left to the existing CI lane.

Final CI run, head 17a9c1ec5b69: 179 checks passed, no failures or pending checks. The repaired trailing-state layout file passed all six browser tests in 8.368 s; its two affected cases took 1.334 s and 2.031 s. No production rollout or live Gateway measurement was performed.

Production growth is 165 lines: the worker metadata reader, cancellation-aware cache validation, and shared UI consumer/activity lifecycle account for the overage above the 150-line guideline. The large fixture is temporary proof; committed regressions extend the existing owner suites.

@clawsweeper

clawsweeper Bot commented Sep 27, 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 docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: L labels Sep 27, 2026
@steipete
steipete enabled auto-merge (squash) September 27, 2026 03:45
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 27, 2026, 1:57 AM ET / 05:57 UTC (Revision 2).

ClawSweeper review

What this changes

The branch makes sidebar pull-request indicators passive, checks Git metadata for viewed checkouts, refreshes active sessions after activity, and updates documentation and tests.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open. The merged related optimization leaves idle sidebar polling unresolved, so this PR has distinct value. The current head also loses an existing sidebar indicator behavior that needs resolution or an explicit product decision.

Priority: P2
Reviewed head: 17a9c1ec5b69134503fb7e0778c344e069acea94
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The measured production-path performance proof is strong, while the first-load indicator regression limits patch readiness.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The captured Testbox evidence exercises the production subscription owner and real Git broker across 43 checkouts and reports zero idle Git spawns after the change; fresh-load and reconnect badge behavior remains a separate correctness gap. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The captured Testbox evidence exercises the production subscription owner and real Git broker across 43 checkouts and reports zero idle Git spawns after the change; fresh-load and reconnect badge behavior remains a separate correctness gap. No stored-data contract changes.
Evidence reviewed 8 items Introduced passive sidebar watch: The introduced hunk marks every eligible sidebar row as passive, removing those rows from the Gateway's requested key set.
Fresh-load summary gap: Sidebar summaries come from a process-local Map. The Map is cleared on client replacement, and passive rows do not request replacement snapshots.
Current main still requests sidebar rows: The fetched current-main sidebar watch has no passive option. The merged related Git-probe optimization therefore does not implement this PR's central change.
Findings 1 actionable finding [P1] Restore sidebar PR badges after initial load and reconnect
Security None None.

How this fits together

The Control UI stores pull-request snapshots for sessions. Active views subscribe through the Gateway, which reads checkout facts in a Git worker and sends updated snapshots back to the UI.

flowchart LR
A[Sidebar rows] --> B[PR snapshot store]
C[Viewed session and activity] --> B
B --> D[Gateway subscription]
D --> E[Git worker]
E --> F[PR and branch snapshot]
F --> B
Loading

Decision needed

Question Recommendation
Should unopened sidebar sessions still show pull-request badges after a fresh load or Gateway reconnect? Preserve initial badges: Add bounded initial and reconnect hydration, then leave idle sidebar rows unsubscribed.

Why: The performance goal and existing indicator behavior conflict when no snapshot exists; source inspection cannot choose that user-visible tradeoff.

Before merge

  • Restore sidebar PR badges after initial load and reconnect (P1) - Marking every sidebar row passive sends an empty requested set. The only sidebar PR summaries are held in browser memory and are cleared on client replacement, so unopened sessions lose their badges after page load or reconnect until each session is viewed. Preserve a bounded initial snapshot or obtain explicit acceptance of this behavior. This is a late discovery in production code unchanged since the previous reviewed head.
  • Resolve merge risk (P1) - A fresh browser load or Gateway reconnect can leave pull-request badges absent for unopened sidebar sessions indefinitely; no explicit acceptance of that user-visible loss is recorded.
  • Complete next step (P2) - Resolve first-load and reconnect PR badge loss, or obtain explicit owner acceptance of the reduced indicator behavior.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Restore sidebar PR badges after initial load and reconnect — ui/src/components/app-sidebar-session-pr-indicators.ts:197
Agent review details

Security

None.

PR surface

Source +165, Tests +148, Docs +2. Total +315 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 8 194 29 +165
Tests 9 336 188 +148
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 532 217 +315

Review metrics

Metric Value Why it matters
Production versus test growth production +165, tests +148, docs +2 lines The PR body attributes production growth to worker metadata checks and UI lifecycle handling; the added scope deserves review alongside the measured performance gain.

Root-cause cluster

Relationship: canonical
Canonical: #159390
Summary: The merged Git-probe reduction overlaps the performance area but does not remove idle polling; the merged roster repair addresses a separate CI and identity problem.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Hydrate once before going passive (recommended)
    Retain first-load and reconnect PR badges with a bounded snapshot request that does not restart idle polling.
  2. Own the reduced indicator behavior
    Accept and document that unopened sessions will lack PR badges until an active view requests them.

Technical review

Best possible solution:

Keep idle polling at zero while supplying a bounded initial or reconnect snapshot for sidebar indicators, unless the owner explicitly chooses and documents the reduced indicator behavior.

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

Yes, source gives a high-confidence path: load or reconnect a Control UI with an unopened checkout session that has a PR. Its browser summary map starts empty or is cleared, and the passive sidebar watch requests no replacement snapshot; this was not executed in this read-only review.

Is this the best way to solve the issue?

No, not yet. Passive rows address repeated Git work, but the patch needs bounded initial badge hydration or explicit acceptance of the changed indicator behavior.

Full review comments:

  • [P1] Restore sidebar PR badges after initial load and reconnect — ui/src/components/app-sidebar-session-pr-indicators.ts:197
    Marking every sidebar row passive sends an empty requested set. The only sidebar PR summaries are held in browser memory and are cleared on client replacement, so unopened sessions lose their badges after page load or reconnect until each session is viewed. Preserve a bounded initial snapshot or obtain explicit acceptance of this behavior. This is a late discovery in production code unchanged since the previous reviewed head.
    Confidence: 0.9
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2f58eadd0558.

Labels

Label changes:

  • add merge-risk: 🚨 other: Merging can remove PR badges from unopened sidebar sessions after load or reconnect, a UI regression outside the more specific merge-risk classes.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (linked_artifact): The captured Testbox evidence exercises the production subscription owner and real Git broker across 43 checkouts and reports zero idle Git spawns after the change; fresh-load and reconnect badge behavior remains a separate correctness gap. No stored-data contract changes.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: This is a bounded Control UI and Gateway performance improvement with a user-visible indicator tradeoff.
  • merge-risk: 🚨 other: Merging can remove PR badges from unopened sidebar sessions after load or reconnect, a UI regression outside the more specific merge-risk classes.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (linked_artifact): The captured Testbox evidence exercises the production subscription owner and real Git broker across 43 checkouts and reports zero idle Git spawns after the change; fresh-load and reconnect badge behavior remains a separate correctness gap. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Testbox evidence exercises the production subscription owner and real Git broker across 43 checkouts and reports zero idle Git spawns after the change; fresh-load and reconnect badge behavior remains a separate correctness gap. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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.

  • Show that unopened sessions retain their PR badges after load and reconnect, or record the owner's explicit acceptance of the changed behavior.

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 (1 earlier review cycle)
  • reviewed 2026-09-27T05:10:39.598Z sha 2659cfd :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. 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. 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. labels Sep 27, 2026
@steipete
steipete merged commit af4a236 into main Sep 27, 2026
243 checks passed
@steipete
steipete deleted the steipete/perf-micro-checkout-context-poll-idle-zero-20260919 branch September 27, 2026 06:04
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
…penclaw#159390)

* perf(gateway): stop polling checkout context for idle sidebar rows

* test(ui): seed cached PR summaries in sidebar layout 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 docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant