Skip to content

perf(ui): reuse complete session event descriptors - #178064

Merged
steipete merged 4 commits into
mainfrom
steipete/perf-micro-sessions-describe-rate-20260919
Oct 20, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/perf-micro-sessions-describe-rate-20260919

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Reopening a recently updated session repeats sessions.describe even when the Control UI already received its complete, current details in a session event.

User Impact

Session navigation reuses current details without a redundant request. Incomplete updates, session replacements, explicit refreshes, subscription outages, and reconnects still require authoritative reads.

Why This Change Was Made

The existing connection-owned descriptor cache discarded every matching event. It now advances completed entries from certified, complete same-incarnation events through the existing row reconciler. Pending requests still coalesce, and retention remains bounded. There is no new cache, timer, configuration, or wire contract.

Full events clear omitted previews rather than preserving stale roster enrichment. Runtime samples are retained only while accumulated runtime, status, and run identity agree, so reactivated runs do not count idle time. Production cache code grows by 40 lines (64 added, 24 removed) to preserve completeness, request options, and runtime semantics; incomplete events still require invalidation.

Evidence

Acceptance rule recorded before measurements: concurrent baseline/candidate runs with identical synthetic sessions, separate state/ports, matching start time, and swapped 16-core halves in at least two pairs; target at least 80% fewer activity-window describes, correct Details, and no material responsiveness regression.

Both completed pairs cut describe requests by 96–97%. Each used a real source Gateway, production-minified Control UI, native Chromium 156, 5,000 synthetic sessions, and 30 alternating navigation/label-patch actions over 60 seconds. An exclusive measurement lock covered each concurrent pair. Pair 1 used A on CPUs 96–111 and B on 112–127; pair 2 swapped them. Startup and final controller verification were outside the activity window. Calls/minute were 30.996 → 1.000 and 29.995 → 1.000, respectively.

Metric Pair 1: base → candidate B−A Pair 2: base → candidate B−A
Describe requests 31 → 1 -30 30 → 1 -29
Describe response bytes 79,826 → 2,630 -77,196 77,378 → 2,664 -74,714
All-action median, ms 66 → 65.5 -0.5 64 → 64 +0
All-action p95, ms 89 → 100 +11 109 → 299 +190
Revisit median, ms 65.5 → 65 -0.5 63.5 → 64 +0.5
Revisit p95, ms 72 → 72 +0 75 → 80 +5
Activity long-task blocking, ms 0 → 0 +0 12 → 11 -1
Document + Details ready, ms 4,571.9 → 4,280.7 -291.2 3,427.7 → 3,534.2 +106.5

All four browser runs had zero page errors and passed the final Details input comparison against a fresh server descriptor, rendered-model check inside Details, and rendered-label check in the conversation header. Revisit statistics consistently exclude the first visit to each of the two sessions (28 remaining actions per side).

The full-action p95 increase in pair 2 is retained above. It came from the first visit to session 2, before the changed event-reuse path executed: the action ended at 33,374.8/33,632.3 ms, while the first recorded sessions.changed arrived at 33,394.7/33,686.1 ms. The probe does not record session.message; source and fixture inspection establishes that label patches/navigation do not produce transcript messages, subscription does not replay them, and the isolated fixture has no active runs, plugins, channels, cron, or heartbeat producing messages. Pre-tail descriptor request keys match, and that cold read's RTT was 60.1 → 62.1 ms. Initial cache misses and runtime sampling retain their prior behavior. This excludes event reuse from the cold outlier; it does not fully diagnose the extra 190 ms or claim a cold-latency improvement. Both sides also had an earlier roughly 3.7-second first patch, with roughly 3.5 seconds in the unchanged Gateway commit phase. Warm revisit p95 was 72 → 72 ms and 75 → 80 ms. No material warm-path regression was observed.

CPU busy context, including workload plus outside load, averaged 2.32%/1.95% across the two halves in pair 1 and 3.30%/3.27% in pair 2. Baseline source: b8daeb2a95a8a2bdb07d1bd950568a67b85c745d; candidate: 07db21160806f5ef08073f139edd1a918766a0c0. The relevant Gateway, event projection, descriptor, and consumer paths did not change between the baseline and final rebase parent. Built candidate descriptor SHA-256: dc0346573c015a1f6a390801e90e9cd267fec5956a0884fb861e835f17e27074; committed probe SHA-256: abd929d444d13f607f23b9b29ffce07a8ac4ea584f270d6323b45c53fb79c889.

The committed workload, per isolated side:

node --import ./scripts/tsx.mjs scripts/perf/catalog-polling-measure.ts \
  --url "$url" --load-runs 1 --load-path /chat/main/team-shape-session-1 \
  --expect-session agent:main:team-shape-session-1 --open-details \
  --activity-patch-sessions agent:main:team-shape-session-1,agent:main:team-shape-session-2 \
  --interval-ms 2000 --duration 60 --start-at "$shared_epoch_ms" --output "$report"

Attribution runs found no steady polling in this fixture: a 190-second stationary chat/Details run made three setup reads and none for the remaining approximately 185 seconds; 30 same-session patches over 60 seconds made zero activity-window reads. Source-mapped consumers were sidebar lineage, desktop discovery, and board/swarm parent reads. Avoidable reads followed invalidation plus a later consumer/navigation read. Board startup also showed explicit refreshes after metadata events; those remain necessary for catalog/authentication changes.

Focused proof: the navigation regression fell from 12 RPCs on base to 1 after 11 complete updates/reentries. All 29 descriptor tests passed, including preview-omission and run-reactivation regressions that failed before their fixes; two focused sibling files passed all 23 tests. Changed-file formatting/lint and native pnpm tsgo:ui passed. Independent Codex review and the GitHub review of the final head are clean. Final CI run 39378853938 passed all 38 executed jobs, including UI, UI E2E, production/test types, lint, and the merge gate. An earlier inherited TS2367 failure was resolved by rebasing onto the upstream fix in #178096; no CI rerun was requested. No Testbox/Crabbox lease was used.

Limitations: the workload uses synthetic label updates and navigation, without real provider turns. It does not explain every production descriptor request or verify the eventual production counter reduction. The result establishes request elimination on the measured event/reentry path, not a production-wide 96–97% reduction.

@clawsweeper

clawsweeper Bot commented Oct 20, 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 October 20, 2026 04:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T06:25:58.763737Z 07db211 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui scripts Repository scripts size: M labels Oct 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ab5bdb0d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/perf/catalog-polling-measure.ts Resolved
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR updates cached session descriptors from complete Gateway events instead of requesting the same details again.

Example: Reopen agent:main:describe-test after each of 11 complete session updates.

  • Before: The reported focused regression makes 12 descriptor requests.
  • After: The reported focused regression makes 1 request while receiving updated fields through events.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The ownership and scope are appropriate, but authoritative preview removal is broken and the new presentation probe can report a false success; supplied validation remains harness-only.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Returning to recently updated conversations repeats Gateway requests for details already received.
Reason: The maintainer-authored direction removes redundant work through the established owner without adding settings, storage, or another cache.

Merge readiness

⛔ Needs changes before merge - 2 items remain

This PR is a useful, maintainer-directed optimization, but descriptor reuse can retain a cleared message preview and the browser probe can falsely certify presentation correctness.

Priority: P2
Reviewed head: 5ab5bdb0d8648553c195250c587759ac22e08a37

Before merge

  • Clear omitted previews when advancing a complete descriptor (P2) - With a completed describe({ key, includeLastMessage: true }) containing lastMessagePreview: "Finished", a later complete event for the same session can legitimately omit that preview. The Gateway already tests this after appending a 70 KiB assistant message in session-row-projection.backfill.test.ts. This call passes the previous descriptor into reconcileParsedSessionChangedRow, whose preserveRosterPresentationMetadata restores omitted lastMessagePreview values. The resulting cache therefore keeps "Finished" where a fresh descriptor omits it; subsequent navigation no longer makes the authoritative read that previously corrected it. Preserve the full descriptor's removal semantics when consuming these snapshots and add an omission regression.
  • Verify rendered details on their actual presentation surfaces (P2) - The new verification compares selectedSession input properties, then accepts the first visible matching label anywhere on the page. With the desktop sidebar visible, its label satisfies this check even if the intended presentation is missing or stale, and the report still emits presentedDetailsMatch: true. This confirms the earlier review comment at perf(ui): reuse complete session event descriptors #178064 (comment). Check rendered fields within the visible Details panel and the label within its intended conversation header surface; the current Details component does not itself render a session label. Keep the property comparison separately identified as an input-state check.

Findings

  • [P2] Clear omitted previews when advancing a complete descriptor — ui/src/lib/sessions/session-describe.ts:185-186
  • [P2] Verify rendered details on their actual presentation surfaces — scripts/perf/catalog-polling-measure.ts:499-504

Tests

  • Missing end-to-end proof: Completed real Gateway/browser baseline-versus-candidate navigation measurements must show fewer descriptor requests and correct rendered details; the body currently supplies only the focused in-process result.
Agent review details

How this fits together

The Control UI's connection-scoped descriptor owner receives Gateway responses and session events, then supplies session details to navigation and resource consumers.

flowchart TD
  A[Gateway row presenter] --> B[Descriptor response]
  A --> C[Complete session event]
  B --> D[Connection descriptor owner]
  C --> E[Shared row reconciler]
  E --> D
  D --> F[Session navigation and Details]
Loading

Technical review

Best possible solution:

Keep reuse in the existing descriptor owner, honor authoritative preview removal, and make the browser probe verify the actual rendered surfaces.

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

Current-main source invalidates matching descriptors even after complete events; the PR reports a focused base-versus-head reproduction, which was inspected but not executed during this read-only review.

Is this the best way to solve the issue?

Updating the existing connection owner is the smallest appropriate approach, provided descriptor completeness does not inherit the roster's intentional preservation of omitted enrichment.

Full review comments:

  • [P2] Clear omitted previews when advancing a complete descriptor — ui/src/lib/sessions/session-describe.ts:185-186
    With a completed describe({ key, includeLastMessage: true }) containing lastMessagePreview: "Finished", a later complete event for the same session can legitimately omit that preview. The Gateway already tests this after appending a 70 KiB assistant message in session-row-projection.backfill.test.ts. This call passes the previous descriptor into reconcileParsedSessionChangedRow, whose preserveRosterPresentationMetadata restores omitted lastMessagePreview values. The resulting cache therefore keeps "Finished" where a fresh descriptor omits it; subsequent navigation no longer makes the authoritative read that previously corrected it. Preserve the full descriptor's removal semantics when consuming these snapshots and add an omission regression.
    Confidence: 0.96
  • [P2] Verify rendered details on their actual presentation surfaces — scripts/perf/catalog-polling-measure.ts:499-504
    The new verification compares selectedSession input properties, then accepts the first visible matching label anywhere on the page. With the desktop sidebar visible, its label satisfies this check even if the intended presentation is missing or stale, and the report still emits presentedDetailsMatch: true. This confirms the earlier review comment at perf(ui): reuse complete session event descriptors #178064 (comment). Check rendered fields within the visible Details panel and the label within its intended conversation header surface; the current Details component does not itself render a session label. Keep the property comparison separately identified as an input-state check.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2d7ba4ef7e39.

Provenance checked

  • Complete-event descriptor invalidation changes intended behavior with a stated reason (4094329: The original shared owner invalidated event-affected reads to protect descriptor completeness, including ancestors outside held rosters; the later ancestor-reference optimization deliberately retained full-snapshot invalidation.)
  • Runtime sampling and request-specific descriptor variants keeps the original intent (4094329: Shared reads preserved their original runtime sample and separated request parameters to avoid changing consumer semantics.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test ui/src/lib/sessions/session-describe.test.ts --maxWorkers=1
  • pnpm tsgo:ui
  • git diff --check
  • Verify the cleared-preview regression fails on the reviewed head and passes after repair.
  • Inspect PR-owner browser measurements for request reduction and rendered-field correctness.

What I checked:

PR surface

Source +30, Tests +56, Docs +7, Other +51. Total +144 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 54 24 +30
Tests 1 59 3 +56
Docs 2 9 2 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 1 52 1 +51
Total 5 174 30 +144

Labels

Label changes:

  • add P2: This reduces redundant session-navigation traffic, with a bounded descriptor correctness defect requiring repair.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This reduces redundant session-navigation traffic, with a bounded descriptor correctness defect requiring repair.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 execution lanes are retired.

Reviewed October 20, 2026, 1:10 AM ET / 05:10 UTC.

@steipete
steipete force-pushed the steipete/perf-micro-sessions-describe-rate-20260919 branch 2 times, most recently from 998d7dc to 6095796 Compare October 20, 2026 05:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60957964b1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ui/src/lib/sessions/session-describe.ts Resolved
Keep completed descriptor reads current from certified session event snapshots instead of discarding details already delivered by the Gateway. Preserve incomplete-event refreshes, connection ownership, previews, and runtime samples. Extend the browser probe to attribute descriptor traffic and compare Details with server state.
@steipete
steipete force-pushed the steipete/perf-micro-sessions-describe-rate-20260919 branch from 6095796 to 07db211 Compare October 20, 2026 06:10
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The complete-event preview omission and rendered-proof findings are fixed. Full events now clear omitted previews, and the probe separately verifies Details input state, the model rendered inside Details, and the label rendered in the conversation header. The later run-reactivation finding is also fixed: equal accumulated runtime only retains its timestamp while run identity and status remain unchanged.

All 29 descriptor tests pass, including regressions that failed before those corrections. Independent review and the GitHub review of 07db21160806f5ef08073f139edd1a918766a0c0 are clean, and final CI run 39378853938 passed all 38 executed jobs. The PR body contains the completed concurrent, swapped-core browser measurements and their limitations.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 20, 2026
@steipete
steipete merged commit 6f1b898 into main Oct 20, 2026
126 checks passed
@steipete
steipete deleted the steipete/perf-micro-sessions-describe-rate-20260919 branch October 20, 2026 07:33
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
* perf(ui): reuse complete session event descriptors

Keep completed descriptor reads current from certified session event snapshots instead of discarding details already delivered by the Gateway. Preserve incomplete-event refreshes, connection ownership, previews, and runtime samples. Extend the browser probe to attribute descriptor traffic and compare Details with server state.

* test(perf): scope descriptor label proof to the conversation header

* fix(ui): clear omitted previews in cached session descriptors

* fix(ui): resample cached runtime when session runs change
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 clawsweeper:intake:feature Preliminary submission classification; full source review pending. docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: M 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