Repository navigation
perf(gateway): stop polling checkout context for idle sidebar rows - #159390
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 27, 2026, 1:57 AM ET / 05:57 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch makes sidebar pull-request indicators passive, checks Git metadata for viewed checkouts, refreshes active sessions after activity, and updates documentation and tests. Regression provenancePossible 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 Review scores
Verification
How this fits togetherThe 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
Decision needed
Why: The performance goal and existing indicator behavior conflict when no snapshot exists; source inspection cannot choose that user-visible tradeoff. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +165, Tests +148, Docs +2. Total +315 across 18 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2f58eadd0558. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
…penclaw#159390) * perf(gateway): stop polling checkout context for idle sidebar rows * test(ui): seed cached PR summaries in sidebar layout fixtures
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.
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, profileopenclaw-check): baseline leasetbx_01m3g98e3vzz1zsghv0qy53krp; full proof leasetbx_01m3gc050r3c5wz1e5ajdzb41g, run. Candidate source hashes were checked before execution.node scripts/run-vitest.mjson the Git/PR/subscription owners: 138 tests passed, including the temporary 43-checkout measurement; 79.18 s wall.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=1passed all 11 tests (38.34 s runner wall, including cold compilation) on recovery leasetbx_01m3gehpbctrxrqy3maqzj3stz(run). Its complete scopedcheck-changedalso 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
2b4a2749587eand 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-testboxleasetbx_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-changedfor that test file passed ontbx_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.