Skip to content

perf(ui): stop idle identity reads and restart probes - #167968

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-control-ui-identity-polling-20260919
Oct 9, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-control-ui-identity-polling-20260919

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Control UI tabs repeatedly read agent identity while the Gateway drains for restart. Ordinary presence updates also refetch unchanged identity after its one-minute cache expiry.

User Impact

Identity refreshes on connection, configuration changes, and agent invalidation. Announced drains pause bootstrap reads and sidebar/Automations refreshes until readiness or reconnect. Direct edits to workspace IDENTITY.md or avatar image files require a tab reload/reconnect because those files do not publish a Gateway identity event.

Why This Change Was Made

The five-to-six-second restart cadence comes from the shared Gateway client's replay probe. Its existing request owner now distinguishes an announced drain from an unannounced refusal. Unannounced restart refusals retain one probe after at least a minute because canceling a restart fence may not publish readiness.

The UI deletes successful-identity expiry and retains its connection/config/agent invalidations. Cron and model catalogs already use events; their remaining automatic refresh paths now honor availability. The availability owner keeps restart evidence while the socket remains connected and retains normal offline expiry after it closes.

Production delta: +18 lines, excluding tests/docs. Expiration machinery and redundant dispatch guards are removed. Growth is needed to distinguish announcement from refusal and preserve recovery at the existing request, availability, and cron/sidebar owners.

Evidence

Headless Chromium, synthetic Gateway data, and virtual time:

Calls per tab Before After
Identity over 10 idle minutes with ordinary presence updates, including connect 11 1
Identity rejects over a 10-minute announced restart with an in-flight read 99 0
Idle cron.list / cron.status / models.list, each including connect 1 1

The final browser proof also confirms zero calls for all four methods during the announced drain, followed by identity recovery on reconnect. Config-change refresh and interrupted identity-edit recovery pass.

Provider: blacksmith-testbox, profile openclaw-check.

  • Primary lease tbx_01m4h53tqvw1h9ssprwst2mzh6 (run): 53 transport tests and 141 UI owner/sibling tests pass. Seven transport and twelve UI regression cases fail unchanged baseline production. Full node scripts/check-changed.mjs --staged passes, including core/UI types, all 27 selected test-type graphs, lint, unused exports, and repository guards. The combined baseline/browser/cron/gate command took 30m19.1s.
  • Independent UI lease tbx_01m4h6cce4n056wzjb79s9mvvy (run): 80 Gateway-store sibling tests pass (6.09s command wall), as do four browser cases (26.38s). The connected-drain regression fails against the original availability helper. node scripts/check-changed.mjs --staged --timed -- ui/src/app/gateway-store.availability.ts ui/src/app/gateway-store.observers.test.ts ui/src/e2e/agent-identity-reconnect.e2e.test.ts passes with the exact twelve-file candidate staged remotely (257.42s).
  • Independent review: clean through P2, including the connected-drain/offline-deadline follow-up.

The browser proof measures RPC counts using virtual time, not production throughput. The new browser case takes about 3.6s and exercises boot, rendering, shared caches, and transport replay together.

Single-worker test costs (pnpm test <file> --maxWorkers=1, all pass):

Test file Command wall time
packages/gateway-client/src/protocol-client.request.test.ts 2.47s
ui/src/lib/agents/identity.test.ts 2.10s
ui/src/components/sidebar-attention-store.test.ts 3.00s
ui/src/pages/cron/cron-page.lifecycle.test.ts 4.46s
ui/src/app/gateway-store.observers.test.ts 1.99s

All twelve changed-file hashes match the tested candidate after rebasing onto current main (ea6022cae60c); the branch contains only this change. Both remote leases are stopped. CI attempt 1 (run 37992454305) has one inherited root failure: build-artifacts fails pnpm plugins:assets:check because extensions/workboard/openclaw.plugin.json is stale. The identical error appears in earlier main run 37987811729, job 114014378480, before this PR. The Workboard browser tree, SDK runtime, build owner, manifest and dependency inputs are unchanged by this diff. Fail-fast canceled 24 jobs; their step metadata contains no separate failures. Security, performance, i18n, docs, boundary guards and two E2E shards passed. The completed E2E shards took 185s and 196s; canceled UI jobs provide no complete per-file CI timing. Remote single-file timings above remain the cost evidence. Landing uses the maintainer-authorized inherited-failure exception; no CI was rerun.

Retain agent identity until connection, config, or agent invalidation.
Hold announced bootstrap drains until readiness or reconnect, while keeping
one slow recovery probe for unannounced restart refusals.

Pause sidebar and Automations refreshes and preserve restart evidence while
the draining socket stays connected. Direct workspace identity/avatar edits
are picked up on reload or reconnect.

Synthetic browser proof reduces identity calls from 11 to 1 per tab over ten
idle minutes and announced-drain rejects from 99 to zero. Testbox owner and
sibling tests, full changed checks, and independent review pass.
@clawsweeper

clawsweeper Bot commented Oct 9, 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 size: M labels Oct 9, 2026
@steipete
steipete marked this pull request as ready for review October 9, 2026 21:16
@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. 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 Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The Control UI reuses agent names and avatars until invalidated and pauses background reads during announced Gateway restarts.

Example: A user leaves a Control UI chat open through ten idle minutes with presence updates.

  • Before: The supplied browser baseline sends 11 agent identity requests, including the initial load.
  • After: The supplied browser candidate sends one identity request and refreshes again after invalidation or reconnect.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct performance improvement with relevant browser boundary proof and a documented freshness tradeoff.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Reported Chromium runs exercise the actual UI cache, availability, and shared request paths against synthetic Gateway data, showing quiet idle/drain reads and reconnect recovery; scoped repository policy permits this browser boundary proof. Prepared historical screenshots add no coverage for this PR, and virtual-time counts establish request behavior rather than production throughput.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes
User problem: Open Control UI tabs repeatedly read unchanged agent identity and send avoidable reads while the Gateway restarts.
Reason: The measured per-tab request reductions justify the small change to existing owners. The author also appears in the merged history of the changed policy and explicitly records the direct-file freshness tradeoff.

Merge readiness

✅ Ready for maintainer review

This PR remains useful and distinct from the earlier performance fixes. No actionable patch defect was found, and the reported CI failure matches an earlier main failure rather than this diff.

Priority: P2
Reviewed head: b66b7e5934a408289fe33155cfee95ea56ef7bd4

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Control UI reads agent identity and automation information from the Gateway over its shared client. Connection and availability owners control when those reads run and when cached results become obsolete.

flowchart TD
  A[Control UI views] --> B[Shared identity cache]
  C[Configuration and agent changes] --> B
  B --> D[Gateway request owner]
  E[Restart and suspension announcements] --> F[Connection availability]
  F --> D
  F --> G[Sidebar and Automations reads]
  D --> H[Gateway responses]
  H --> A
Loading

Technical review

Best possible solution:

Keep the existing cache and request owners with event-driven refreshes and the documented direct-file reload tradeoff.

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

Yes: current-main source retains the one-minute identity expiry and announced-pause probes, and the supplied before/after browser observations exercise those paths. No target code was executed during this read-only review.

Is this the best way to solve the issue?

Yes: the patch changes the existing cache, request, and availability owners and preserves explicit invalidation, cancellation, deadlines, and unannounced-refusal recovery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1d09a03dc9cd.

Provenance checked

  • ui/src/lib/agents/identity.ts changes intended behavior with a stated reason (fix: speed up chat opening and cache avatars #138635: Share identity reads across views while using a 60-second freshness bound to detect avatar-file replacement.)
  • packages/gateway-client/src/pending-request.ts changes intended behavior with a stated reason (perf(gateway): pause reconnect bootstrap during restart #167407: Pause five bootstrap reads together and retain a bounded recovery probe because a restart fence can roll back without readiness or socket replacement.)
  • ui/src/components/sidebar-attention-store.ts keeps the original intent (perf(ui): reuse automation inventory and host CPU identity #155686: Reuse automation inventory until events or connection changes, with visible failed-read retries and local overdue deadlines.)
  • ui/src/pages/cron/cron-page.ts keeps the original intent (fix(ui): stop automation refreshes in hidden tabs #140097: Prevent hidden-tab automation reads and perform a coalesced catch-up while retaining filters and drafts.)
  • ui/src/app/gateway-store.availability.ts changes intended behavior with a stated reason (b44741c: The existing availability owner expires stale lifecycle evidence into ordinary offline presentation.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned introduced changes: The merge-base-to-head diff changes the existing identity cache, bootstrap request owner, availability indicators, and sidebar/Automations consumers; it adds no competing scheduler or persisted state. (packages/gateway-client/src/pending-request.ts:77, b66b7e5934a4)
  • Still necessary on current main: Fetched main still expires successful identities after 60 seconds and schedules probes for announced pauses; none of the six production/documentation paths changed between the pinned merge base and fetched main. (ui/src/lib/agents/identity.ts:28, 1d09a03dc9cd)
  • Identity freshness provenance and accepted tradeoff: The earlier merged avatar work explicitly used a 60-second freshness bound to detect direct file replacement. This PR deliberately replaces that policy with event invalidation and documents reload/reconnect for direct IDENTITY.md or avatar-file edits at https://docs.openclaw.ai/web/control-ui. (ui/src/lib/agents/identity.ts:26, 712622517abb)
  • Browser runtime proof: The fully inspected PR body reports headless Chromium exercising UI boot, rendering, shared identity caches, and transport replay with synthetic Gateway data and virtual time: idle identity requests fall from 11 to 1, announced-drain identity rejections fall from 99 to 0, all four measured methods remain quiet during the drain, and reconnect displays Cedar. The added browser scenario matches these claims; baseline failures and candidate checks are reported in the linked Testbox runs. (ui/src/e2e/agent-identity-reconnect.e2e.test.ts:17, b66b7e5934a4)
  • Prepared media inspected: Both downloaded screenshots were inspected. They depict the earlier long-chat/avatar comparison and do not demonstrate this PR's idle-read or restart behavior; this review relies on the browser runtime observations instead.
  • Inherited CI failure: GitHub job metadata confirms that the PR run and earlier main job both fail Check bundled plugin generated assets. The author identifies the same stale Workboard manifest in both and records the inherited-failure landing exception. Raw logs could not be independently read because their Azure artifact host is blocked by the review proxy; the Workboard manifest and package inputs are unchanged in the inspected merge comparison.

Likely related people:

  • Peter Steinberger: Raw commit 7126225 adds ui/src/lib/agents/identity.ts:21 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 712622517abb; files: ui/src/lib/agents/identity.ts)
  • Nehanth Narendrula: Raw commit b44741c adds ui/src/app/gateway-store.availability.ts:26 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: b44741cfeaeb; files: ui/src/app/gateway-store.availability.ts)

PR surface

Source +18, Tests +206, Docs +2. Total +226 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 57 39 +18
Tests 6 295 89 +206
Docs 1 4 2 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 356 130 +226

Review metrics

Metric Value Why it matters
Production versus tests Production net +18 LOC; tests net +206 LOC The small production growth records announcement and recovery state in existing owners while removing successful-cache expiration machinery.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This reduces redundant per-tab Gateway work during idle use and restart without evidence of an urgent availability regression.
  • merge-risk: 🚨 compatibility: The explicitly documented freshness tradeoff means direct workspace identity/avatar edits require reload or reconnect instead of automatic expiry.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-09T21:22:39.385Z sha b66b7e5 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T21:29:40.563Z sha b66b7e5 :: needs maintainer review before merge. :: none

Reviewed October 9, 2026, 6:14 PM ET / 22:14 UTC (Revision 3).

@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

The remaining CI red is inherited. build-artifacts in PR run 37992454305 fails pnpm plugins:assets:check on stale extensions/workboard/openclaw.plugin.json. The exact same failure occurred earlier on main in run 37987811729.

I verified the captured CI merge (34f6096a13097b5f3f7ea610f5242b209c0caab5), its main parent, and unchanged Workboard build inputs. This PR's host UI and Gateway client changes are outside the plugin's browser bundle dependency graph. The other 24 canceled jobs were fail-fast collateral with no separately failed steps; security passed. Full Testbox changed gates, owner/sibling tests, headless browser proof, and independent review are green, with evidence and timing in the PR body.

Landing exact head b66b7e5934a408289fe33155cfee95ea56ef7bd4 under the maintainer-authorized inherited-CI exception. No rerun or unrelated generated-asset change is needed.

@steipete
steipete merged commit 00b00e2 into main Oct 9, 2026
151 of 180 checks passed
@steipete
steipete deleted the steipete/perf-micro-control-ui-identity-polling-20260919 branch October 9, 2026 22:24
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
Retain agent identity until connection, config, or agent invalidation.
Hold announced bootstrap drains until readiness or reconnect, while keeping
one slow recovery probe for unannounced restart refusals.

Pause sidebar and Automations refreshes and preserve restart evidence while
the draining socket stays connected. Direct workspace identity/avatar edits
are picked up on reload or reconnect.

Synthetic browser proof reduces identity calls from 11 to 1 per tab over ten
idle minutes and announced-drain rejects from 99 to zero. Testbox owner and
sibling tests, full changed checks, and independent review pass.
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. size: M 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