Repository navigation
fix: agent switching leaves the session list waiting - #150092
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. |
c7d30ea to
114bfa5
Compare
|
Codex review: blocked before merge. Reviewed September 16, 2026, 7:09 PM ET / 23:09 UTC (Revision 7). ClawSweeper reviewWhat this changesThe PR makes agent switching load sidebar sessions promptly, reuses valid previously loaded lists, and preserves newer session details when delayed chat history arrives. Merge readiness⛔ Blocked before merge - 2 items remain This remains a useful, distinct fix. The new evidence resolves the current-head validation and benchmark-provenance concern, and no actionable code or security findings remain. The explicit visual-delivery hold still applies. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI session roster turns agent selections and Gateway session responses into sidebar rows. Its refresh owner coordinates foreground navigation, background loading, and temporary presentation of previously loaded sessions. flowchart TD
A[Agent selection] --> B{Explicit navigation?}
B -->|Yes| C[Immediate roster request]
B -->|No| D[Background startup queue]
D --> C
C --> E[Gateway session response]
E --> F[Scope and freshness checks]
F --> G[Selected agent sidebar]
H[Valid loaded session list] --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +259, Tests +586. Total +845 across 26 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep foreground selection and temporary loaded-list presentation within the existing roster owner, preserving its scope, invalidation, and stale-response fences. Do we have a high-confidence way to reproduce the issue? Yes: inspected main queues agent-selection refresh behind background admission, and the held-startup/held-list browser scenario directly exercises that boundary. This read-only review did not execute a new reproduction. Is this the best way to solve the issue? Yes: the patch extends the existing roster owner, preserves automatic startup priority, and keeps reusable presentation separate from authoritative state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 307255794c48. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
Agent-switch benchmark: raw samples and reproduction harnessPublication-time PR head: Measurement and controlsSynthetic browser fixture, not production latency: 200 sessions per agent; sessions.list responses scheduled with the same 150 ms delay; first Writer chat.startup held for 600 ms; five fresh browser contexts per stage; Main initially loaded, then Writer cold switch, then Main warm return. Both stages use the same recorded fixture parameters. Harness uses Chromium, 1440×900 viewport, en-US locale and source-mode Control UI. Browser/version and machine-load equality were not recorded in these JSON files and are not claimed here.
Every sample (milliseconds)
Each measured selection recorded exactly one primary list dispatch and response. Rebased cold rows arrive before the 600 ms transcript release; rebased warm rows arrive before the replacement list response. This establishes the synthetic timing behavior, not a real-Gateway acceptance result. ReproductionSave the harness below as PROOF_STAGE=before pnpm exec tsx .artifacts/agent-switch-measure.mts
# In the candidate checkout:
PROOF_STAGE=rebased pnpm exec tsx .artifacts/agent-switch-measure.mtsComplete measurement harnessimport { writeFile } from 'node:fs/promises';
import path from 'node:path';
import { chromium } from 'playwright';
import { startControlUiE2eServer, installMockGateway, resolvePlaywrightChromiumExecutablePath } from '../ui/src/test-helpers/control-ui-e2e.ts';
import { createControlUiE2eArtifactDir } from '../ui/src/test-helpers/control-ui-e2e-artifacts.ts';
import { createControlUiSessionRow } from '../ui/src/test-helpers/control-ui-session-fixtures.ts';
const stage = process.env.PROOF_STAGE || 'before';
const dir = createControlUiE2eArtifactDir(`agent-switch-measure-${stage}`);
const server = await startControlUiE2eServer(undefined, { source: true });
const browser = await chromium.launch({ executablePath: resolvePlaywrightChromiumExecutablePath(chromium.executablePath()) });
const rows = ['main', 'writer'].flatMap(agent => Array.from({ length: 200 }, (_, i) => createControlUiSessionRow(`agent:${agent}:${i === 0 ? 'main' : `dashboard:item-${i}`}`, `${agent === 'main' ? 'Main' : 'Writer'} project ${String(i).padStart(3, '0')}`, 1789540000000 - i * 1000, { agentId: agent })));
const samples: any[] = [];
try {
for (let run = 0; run < 5; run++) {
const context = await browser.newContext({ viewport: { width: 1440, height: 900 }, locale: 'en-US', ...(run === 0 ? { recordVideo: { dir, size: { width: 1440, height: 900 } } } : {}) });
const page = await context.newPage();
page.setDefaultTimeout(20000);
// tsx names serialized fixture callbacks using this compile-time helper.
await page.addInitScript('globalThis.__name = (target) => target;');
try {
await installMockGateway(page, { sessions: rows, historyMessages: [{ role: 'assistant', content: 'Synthetic baseline conversation.' }], methodResponses: { 'agents.list': { defaultId: 'main', mainKey: 'main', scope: 'per-sender', agents: [{ id: 'main', name: 'Main' }, { id: 'writer', name: 'Writer' }] } } });
await page.goto(`${server.baseUrl}chat/main`);
await page.locator('[data-session-key="agent:main:dashboard:item-1"]').first().waitFor();
await page.evaluate((fixtureRows) => {
const w = window as any;
const gateway = w.openclawControlUiE2eGateway;
w.measurements = [];
const observe = () => {
const measurement = w.measurements.at(-1);
if (!measurement || measurement.firstRows !== undefined) return;
const row = document.querySelector(`openclaw-app-sidebar [data-session-key="agent:${measurement.agentId}:dashboard:item-1"]`) as HTMLElement;
if (row?.getClientRects().length) measurement.firstRows = performance.now() - measurement.click;
};
new MutationObserver(observe).observe(document.body, { subtree: true, childList: true, attributes: true });
document.addEventListener('click', event => {
const option = event.composedPath().find((node: any) => node?.matches?.('.sidebar-agent-menu__agent-switch')) as HTMLElement | undefined;
if (!option) return;
const agentId = option.getAttribute('value')?.slice('agent:'.length);
if (!agentId) return;
const measurement: any = { agentId, click: performance.now(), dispatch: [], response: [] };
w.measurements.push(measurement);
// A deterministic server delay for the cold transcript. Warm return retains its real pane.
if (agentId === 'writer' && w.measurements.length === 1) {
gateway.deferNext('chat.startup');
setTimeout(() => { measurement.historyRelease = performance.now() - measurement.click; gateway.resolveDeferred('chat.startup'); }, 600);
}
queueMicrotask(observe);
}, true);
gateway.setRequestHandler('sessions.list', ({ params, respond }: any) => {
const primary = !params.hasBoard && !params.spawnedBy && !params.archived;
const measurement = w.measurements.at(-1);
if (primary && measurement) measurement.dispatch.push({ agentId: params.agentId, ms: performance.now() - measurement.click });
const sessions = primary ? fixtureRows.filter(row => row.agentId === params.agentId) : [];
setTimeout(() => {
if (primary && measurement) measurement.response.push({ agentId: params.agentId, ms: performance.now() - measurement.click });
respond({ ts: Date.now(), count: sessions.length, sessions, defaults: { model: 'gpt-5.5', modelProvider: 'openai', contextTokens: null }, hasMore: false, nextOffset: null });
}, 150);
});
}, rows);
for (const [index, agent] of ['writer', 'main'].entries()) {
const sidebar = page.locator('openclaw-app-sidebar');
await sidebar.getByRole('button', { name: /Switch agent/ }).click();
await sidebar.locator(`wa-dropdown-item[value="agent:${agent}"]`).click();
if (run === 0) await page.screenshot({ path: path.join(dir, `${index * 2 + 1}-${agent}-selected.png`) });
await page.waitForFunction((id) => {
const m = (window as any).measurements.at(-1);
return m?.agentId === id && m.firstRows !== undefined && m.response.length > 0 && (id !== 'writer' || m.historyRelease !== undefined);
}, agent);
await page.locator(`[data-session-key="agent:${agent}:dashboard:item-1"]`).first().waitFor();
if (run === 0) await page.screenshot({ path: path.join(dir, `${index * 2 + 2}-${agent}-loaded.png`) });
}
samples.push({ run, measurements: await page.evaluate(() => (window as any).measurements) });
} catch (error) {
await page.screenshot({ path: path.join(dir, `failure-${run}.png`) }).catch(() => {});
throw error;
} finally { await context.close(); }
}
const summary = Object.fromEntries(['writer', 'main'].map(agentId => {
const values = samples.flatMap(s => s.measurements).filter(m => m.agentId === agentId).map(m => m.firstRows).sort((a, b) => a - b);
return [agentId === 'writer' ? 'coldSwitch' : 'warmReturn', { samples: values.length, medianMs: values[Math.floor(values.length / 2)], p95Ms: values[Math.ceil(values.length * .95) - 1] }];
}));
await writeFile(path.join(dir, 'measurements.json'), JSON.stringify({ stage, fixture: { rowsPerAgent: 200, listDelayMs: 150, coldHistoryDelayMs: 600, repeats: 5 }, summary, samples }, null, 2));
console.log(JSON.stringify({ dir, summary }, null, 2));
} finally { await browser.close(); await server.close(); }Unrounded original measurement JSON{
"before": {
"stage": "before",
"fixture": {
"rowsPerAgent": 200,
"listDelayMs": 150,
"coldHistoryDelayMs": 600,
"repeats": 5
},
"summary": {
"coldSwitch": {
"samples": 5,
"medianMs": 852.4000000953674,
"p95Ms": 899.5
},
"warmReturn": {
"samples": 5,
"medianMs": 287.39999985694885,
"p95Ms": 356.89999985694885
}
},
"samples": [
{
"run": 0,
"measurements": [
{
"agentId": "writer",
"click": 5716.200000047684,
"dispatch": [
{
"agentId": "writer",
"ms": 648.8999998569489
}
],
"response": [
{
"agentId": "writer",
"ms": 801.7999999523163
}
],
"historyRelease": 600.2999999523163,
"firstRows": 899.5
},
{
"agentId": "main",
"click": 7223.5,
"dispatch": [
{
"agentId": "main",
"ms": 94.59999990463257
}
],
"response": [
{
"agentId": "main",
"ms": 278.2000000476837
}
],
"firstRows": 356.89999985694885
}
]
},
{
"run": 1,
"measurements": [
{
"agentId": "writer",
"click": 4104.799999952316,
"dispatch": [
{
"agentId": "writer",
"ms": 641
}
],
"response": [
{
"agentId": "writer",
"ms": 791.1000001430511
}
],
"historyRelease": 600.1000001430511,
"firstRows": 841.1000001430511
},
{
"agentId": "main",
"click": 5201.799999952316,
"dispatch": [
{
"agentId": "main",
"ms": 82.20000004768372
}
],
"response": [
{
"agentId": "main",
"ms": 232.40000009536743
}
],
"firstRows": 270.7000000476837
}
]
},
{
"run": 2,
"measurements": [
{
"agentId": "writer",
"click": 3937.5999999046326,
"dispatch": [
{
"agentId": "writer",
"ms": 649.1000001430511
}
],
"response": [
{
"agentId": "writer",
"ms": 799.4000000953674
}
],
"historyRelease": 600.4000000953674,
"firstRows": 851.9000000953674
},
{
"agentId": "main",
"click": 5133,
"dispatch": [
{
"agentId": "main",
"ms": 112.89999985694885
}
],
"response": [
{
"agentId": "main",
"ms": 263.09999990463257
}
],
"firstRows": 306.2999999523163
}
]
},
{
"run": 3,
"measurements": [
{
"agentId": "writer",
"click": 3767.5,
"dispatch": [
{
"agentId": "writer",
"ms": 635.7999999523163
}
],
"response": [
{
"agentId": "writer",
"ms": 786.1000001430511
}
],
"historyRelease": 600.2999999523163,
"firstRows": 852.4000000953674
},
{
"agentId": "main",
"click": 4907,
"dispatch": [
{
"agentId": "main",
"ms": 69.29999995231628
}
],
"response": [
{
"agentId": "main",
"ms": 219.5
}
],
"firstRows": 257.60000014305115
}
]
},
{
"run": 4,
"measurements": [
{
"agentId": "writer",
"click": 2958.2000000476837,
"dispatch": [
{
"agentId": "writer",
"ms": 656.0999999046326
}
],
"response": [
{
"agentId": "writer",
"ms": 806.2999999523163
}
],
"historyRelease": 600.2999999523163,
"firstRows": 886.5999999046326
},
{
"agentId": "main",
"click": 4170.600000143051,
"dispatch": [
{
"agentId": "main",
"ms": 95.69999980926514
}
],
"response": [
{
"agentId": "main",
"ms": 245.89999985694885
}
],
"firstRows": 287.39999985694885
}
]
}
]
},
"rebased": {
"stage": "rebased",
"fixture": {
"rowsPerAgent": 200,
"listDelayMs": 150,
"coldHistoryDelayMs": 600,
"repeats": 5
},
"summary": {
"coldSwitch": {
"samples": 5,
"medianMs": 309,
"p95Ms": 331.40000009536743
},
"warmReturn": {
"samples": 5,
"medianMs": 36.59999990463257,
"p95Ms": 55.700000047683716
}
},
"samples": [
{
"run": 0,
"measurements": [
{
"agentId": "writer",
"click": 4627.700000047684,
"dispatch": [
{
"agentId": "writer",
"ms": 60.299999952316284
}
],
"response": [
{
"agentId": "writer",
"ms": 217.59999990463257
}
],
"firstRows": 281.2999999523163,
"historyRelease": 600.2000000476837
},
{
"agentId": "main",
"click": 5681.900000095367,
"dispatch": [
{
"agentId": "main",
"ms": 107.09999990463257
}
],
"response": [
{
"agentId": "main",
"ms": 257.2999999523163
}
],
"firstRows": 36.59999990463257
}
]
},
{
"run": 1,
"measurements": [
{
"agentId": "writer",
"click": 2435.9000000953674,
"dispatch": [
{
"agentId": "writer",
"ms": 44.200000047683716
}
],
"response": [
{
"agentId": "writer",
"ms": 234.59999990463257
}
],
"firstRows": 323.7000000476837,
"historyRelease": 600.2000000476837
},
{
"agentId": "main",
"click": 3352.100000143051,
"dispatch": [
{
"agentId": "main",
"ms": 176.89999985694885
}
],
"response": [
{
"agentId": "main",
"ms": 327
}
],
"firstRows": 32.700000047683716
}
]
},
{
"run": 2,
"measurements": [
{
"agentId": "writer",
"click": 2409.4000000953674,
"dispatch": [
{
"agentId": "writer",
"ms": 43.39999985694885
}
],
"response": [
{
"agentId": "writer",
"ms": 212.70000004768372
}
],
"firstRows": 279.39999985694885,
"historyRelease": 600.2000000476837
},
{
"agentId": "main",
"click": 3368,
"dispatch": [
{
"agentId": "main",
"ms": 173.20000004768372
}
],
"response": [
{
"agentId": "main",
"ms": 323.2999999523163
}
],
"firstRows": 31.90000009536743
}
]
},
{
"run": 3,
"measurements": [
{
"agentId": "writer",
"click": 2935.699999809265,
"dispatch": [
{
"agentId": "writer",
"ms": 47.40000009536743
}
],
"response": [
{
"agentId": "writer",
"ms": 245.80000019073486
}
],
"firstRows": 331.40000009536743,
"historyRelease": 600.2000000476837
},
{
"agentId": "main",
"click": 3738.199999809265,
"dispatch": [
{
"agentId": "main",
"ms": 143.40000009536743
}
],
"response": [
{
"agentId": "main",
"ms": 293.5
}
],
"firstRows": 42.30000019073486
}
]
},
{
"run": 4,
"measurements": [
{
"agentId": "writer",
"click": 3166.9000000953674,
"dispatch": [
{
"agentId": "writer",
"ms": 68.69999980926514
}
],
"response": [
{
"agentId": "writer",
"ms": 249.29999995231628
}
],
"firstRows": 309,
"historyRelease": 600.1999998092651
},
{
"agentId": "main",
"click": 3986,
"dispatch": [
{
"agentId": "main",
"ms": 136
}
],
"response": [
{
"agentId": "main",
"ms": 301.59999990463257
}
],
"firstRows": 55.700000047683716
}
]
}
]
}
}Remaining proof gaps
|
Before / after: selected agent's rows while chat startup is heldInspected screenshots contain synthetic conversations and project names, no visible credentials or private conversations. These are different fixture captures demonstrating behavior, not matched-frame timing measurements. Held-request conditions are established by the harness/test, not by the static pixels alone. Before — Writer selected, sidebar empty while startup is heldAfter — Writer rows visible before held startup is releasedCandidate recorded by the retained rebased proof: Five-run synthetic benchmark
200 rows per agent; 150 ms list delay; 600 ms cold startup hold. DOM visibility from picker click, not compositor paint. All samples, raw JSON, controls, limitations and complete reproduction harness. With the linked harness saved in each verified revision checkout: PROOF_STAGE=before pnpm exec tsx .artifacts/agent-switch-measure.mts
PROOF_STAGE=rebased pnpm exec tsx .artifacts/agent-switch-measure.mtsTypecheck/changed-file validation, full CI acceptance, complete provenance and originating-chat image-render confirmation remain open. PR remains draft; no merge authorization. |
|
@clawsweeper re-review Same head |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Matched agent-switch video proof — five repetitions, normal speedThese are actual Chromium recordings, not generated video. There are five paired repetitions, each recorded as its original separate video: cold Main → Writer, then warm Writer → Main. No playback speed changes or injected network/RPC delays. The visible clock resets at the agent-switch click event; it stops at the first animation frame with the target row visible and hit-testable. Boundary: synthetic/mocked Gateway, source-mode UI on the same shared Linux host, 200 sessions per agent, 1440×900 viewport, same fixture and browser. This is not live-Gateway performance or a production-bundle benchmark. Source-module compilation is warmed before each side; each measured repetition starts with a fresh browser context. Run order alternates AB/BA. Readability pauses occur only between actions and after measurement. The players are separate, not frame-synchronized; compare the common click-relative clocks, not player position. Shared-host CPU scheduling is not controlled. Sources: baseline The ten original clips below are ordered before-run-1, after-run-1, then the same pair for runs 2 through 5. Each has BEFORE/AFTER and repetition labels in the recording. All takes are included, without concatenation, cuts, retiming, or re-encoding. Observed click-to-usable-row times (milliseconds)
These samples replace neither production measurements nor the earlier deliberately delayed fixture. Their timing definition differs from the earlier DOM-mutation benchmark. No take was dropped. Complete measurements and capture conditions{
"manifest": {
"baseline": "82d4d1cc175549e222e3cb2605716f277eff6a00",
"candidateHead": "114bfa58bcc28ad1dbbf4f347cf0c0e665dd7aa4",
"candidatePatchSha256": "5003808d356e3257afa55001e47495289f2dd7a85801424d3b648bce5c009159"
},
"conditions": {
"boundary": "mocked Gateway, source-mode UI",
"browser": "153.0.8010.12",
"platform": "linux",
"arch": "x64",
"cpu": "Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz",
"viewport": "1440x900",
"rowsPerAgent": 200,
"repetitions": 5,
"order": "AB, BA, AB, BA, AB",
"rpcDelayMs": 0,
"network": "loopback; no throttling",
"timing": "capture-phase agent-switch click event to first animation frame with visible hit-testable item-1 row",
"betweenActionReadabilityPausesMs": [
1000,
1500
]
},
"summary": {
"before": {
"writer": {
"n": 5,
"min": 404.5,
"median": 526.7999999523163,
"max": 611.5999999046326,
"mean": 512.5999999523162,
"sd": 69.73507007817449,
"samples": [
404.5,
473.89999985694885,
526.7999999523163,
546.2000000476837,
611.5999999046326
]
},
"main": {
"n": 5,
"min": 210.70000004768372,
"median": 245,
"max": 293.2999999523163,
"mean": 247.5199999809265,
"sd": 26.714744969827954,
"samples": [
210.70000004768372,
237.59999990463257,
245,
251,
293.2999999523163
]
}
},
"after": {
"writer": {
"n": 5,
"min": 132.69999980926514,
"median": 144.5,
"max": 252.09999990463257,
"mean": 169.97999992370606,
"sd": 44.40844062192535,
"samples": [
132.69999980926514,
139.20000004768372,
144.5,
181.39999985694885,
252.09999990463257
]
},
"main": {
"n": 5,
"min": 107.29999995231628,
"median": 159.20000004768372,
"max": 194.70000004768372,
"mean": 153.2,
"sd": 28.56053224969894,
"samples": [
107.29999995231628,
142.09999990463257,
159.20000004768372,
162.70000004768372,
194.70000004768372
]
}
}
},
"samples": [
{
"run": 0,
"stage": "before",
"measurements": [
{
"agentId": "writer",
"click": 4496.800000190735,
"dispatch": [
{
"agentId": "writer",
"ms": 391
}
],
"response": [
{
"agentId": "writer",
"ms": 391.5
}
],
"usableMs": 473.89999985694885
},
{
"agentId": "main",
"click": 7748.700000047684,
"dispatch": [
{
"agentId": "main",
"ms": 129
}
],
"response": [
{
"agentId": "main",
"ms": 129.70000004768372
}
],
"usableMs": 293.2999999523163
}
]
},
{
"run": 0,
"stage": "after",
"measurements": [
{
"agentId": "writer",
"click": 3963.2000000476837,
"dispatch": [
{
"agentId": "writer",
"ms": 66.79999995231628
}
],
"response": [
{
"agentId": "writer",
"ms": 67.40000009536743
}
],
"usableMs": 144.5
},
{
"agentId": "main",
"click": 6987,
"dispatch": [
{
"agentId": "main",
"ms": 114.20000004768372
}
],
"response": [
{
"agentId": "main",
"ms": 114.70000004768372
}
],
"usableMs": 107.29999995231628
}
]
},
{
"run": 1,
"stage": "after",
"measurements": [
{
"agentId": "writer",
"click": 3941.5,
"dispatch": [
{
"agentId": "writer",
"ms": 55.69999980926514
}
],
"response": [
{
"agentId": "writer",
"ms": 56
}
],
"usableMs": 132.69999980926514
},
{
"agentId": "main",
"click": 7027.299999952316,
"dispatch": [
{
"agentId": "main",
"ms": 150.5
}
],
"response": [
{
"agentId": "main",
"ms": 151
}
],
"usableMs": 142.09999990463257
}
]
},
{
"run": 1,
"stage": "before",
"measurements": [
{
"agentId": "writer",
"click": 5302.200000047684,
"dispatch": [
{
"agentId": "writer",
"ms": 479.19999980926514
}
],
"response": [
{
"agentId": "writer",
"ms": 479.7999999523163
}
],
"usableMs": 611.5999999046326
},
{
"agentId": "main",
"click": 8783.099999904633,
"dispatch": [
{
"agentId": "main",
"ms": 91.40000009536743
}
],
"response": [
{
"agentId": "main",
"ms": 91.90000009536743
}
],
"usableMs": 210.70000004768372
}
]
},
{
"run": 2,
"stage": "before",
"measurements": [
{
"agentId": "writer",
"click": 4857.899999856949,
"dispatch": [
{
"agentId": "writer",
"ms": 448.5
}
],
"response": [
{
"agentId": "writer",
"ms": 449.2000000476837
}
],
"usableMs": 546.2000000476837
},
{
"agentId": "main",
"click": 8020.200000047684,
"dispatch": [
{
"agentId": "main",
"ms": 116.59999990463257
}
],
"response": [
{
"agentId": "main",
"ms": 117.39999985694885
}
],
"usableMs": 251
}
]
},
{
"run": 2,
"stage": "after",
"measurements": [
{
"agentId": "writer",
"click": 4497.799999952316,
"dispatch": [
{
"agentId": "writer",
"ms": 102.09999990463257
}
],
"response": [
{
"agentId": "writer",
"ms": 102.5
}
],
"usableMs": 252.09999990463257
},
{
"agentId": "main",
"click": 7654.599999904633,
"dispatch": [
{
"agentId": "main",
"ms": 172
}
],
"response": [
{
"agentId": "main",
"ms": 172.79999995231628
}
],
"usableMs": 162.70000004768372
}
]
},
{
"run": 3,
"stage": "after",
"measurements": [
{
"agentId": "writer",
"click": 4085.5,
"dispatch": [
{
"agentId": "writer",
"ms": 58.30000019073486
}
],
"response": [
{
"agentId": "writer",
"ms": 58.700000047683716
}
],
"usableMs": 139.20000004768372
},
{
"agentId": "main",
"click": 7024,
"dispatch": [
{
"agentId": "main",
"ms": 203.20000004768372
}
],
"response": [
{
"agentId": "main",
"ms": 203.70000004768372
}
],
"usableMs": 194.70000004768372
}
]
},
{
"run": 3,
"stage": "before",
"measurements": [
{
"agentId": "writer",
"click": 4170.100000143051,
"dispatch": [
{
"agentId": "writer",
"ms": 402.7999999523163
}
],
"response": [
{
"agentId": "writer",
"ms": 403.2999999523163
}
],
"usableMs": 526.7999999523163
},
{
"agentId": "main",
"click": 7307.799999952316,
"dispatch": [
{
"agentId": "main",
"ms": 112.10000014305115
}
],
"response": [
{
"agentId": "main",
"ms": 112.70000004768372
}
],
"usableMs": 245
}
]
},
{
"run": 4,
"stage": "before",
"measurements": [
{
"agentId": "writer",
"click": 4529.900000095367,
"dispatch": [
{
"agentId": "writer",
"ms": 330.09999990463257
}
],
"response": [
{
"agentId": "writer",
"ms": 330.39999985694885
}
],
"usableMs": 404.5
},
{
"agentId": "main",
"click": 7720.400000095367,
"dispatch": [
{
"agentId": "main",
"ms": 100.20000004768372
}
],
"response": [
{
"agentId": "main",
"ms": 100.79999995231628
}
],
"usableMs": 237.59999990463257
}
]
},
{
"run": 4,
"stage": "after",
"measurements": [
{
"agentId": "writer",
"click": 3978.5,
"dispatch": [
{
"agentId": "writer",
"ms": 85.59999990463257
}
],
"response": [
{
"agentId": "writer",
"ms": 86.20000004768372
}
],
"usableMs": 181.39999985694885
},
{
"agentId": "main",
"click": 7082.099999904633,
"dispatch": [
{
"agentId": "main",
"ms": 170
}
],
"response": [
{
"agentId": "main",
"ms": 170.5
}
],
"usableMs": 159.20000004768372
}
]
}
]
}Reproduction harnessRun import { writeFile, readFile, mkdir } from 'node:fs/promises';
import path from 'node:path';
import os from 'node:os';
import { chromium } from 'playwright';
const root = path.dirname(new URL(import.meta.url).pathname);
const manifest = JSON.parse(await readFile(path.join(root, 'source-manifest.json'), 'utf8'));
const helpers = Object.fromEntries(await Promise.all(['before','after'].map(async stage => [stage, await import(path.join(root,stage,'ui/src/test-helpers/control-ui-e2e.ts'))])));
const { createControlUiSessionRow } = await import(path.join(root,'after/ui/src/test-helpers/control-ui-session-fixtures.ts'));
const rows = ['main','writer'].flatMap(agent => Array.from({length:200},(_,i) => createControlUiSessionRow(`agent:${agent}:${i===0?'main':`dashboard:item-${i}`}`, `${agent==='main'?'Main':'Writer'} project ${String(i).padStart(3,'0')}`,1789540000000-i*1000,{agentId:agent})));
const servers:any = {}; const samples:any[]=[];
const browser = await chromium.launch({executablePath:helpers.after.resolvePlaywrightChromiumExecutablePath(chromium.executablePath())});
async function install(page:any, stage:string) {
await page.addInitScript('globalThis.__name = (target) => target;');
await helpers[stage].installMockGateway(page,{sessions:rows,historyMessages:[{role:'assistant',content:'Synthetic matched browser performance fixture.'}],methodResponses:{'agents.list':{defaultId:'main',mainKey:'main',scope:'per-sender',agents:[{id:'main',name:'Main'},{id:'writer',name:'Writer'}]}}});
await page.goto(`${servers[stage].baseUrl}chat/main`);
await page.locator('openclaw-app-sidebar [data-session-key="agent:main:dashboard:item-1"]').first().waitFor();
}
try {
for(const stage of ['before','after']) {
servers[stage]=await helpers[stage].startControlUiE2eServer(undefined,{source:true});
const context=await browser.newContext({viewport:{width:1440,height:900},locale:'en-US'});
const page=await context.newPage(); await install(page,stage);
// Prime source-module compilation outside the recorded fresh contexts.
const sidebar=page.locator('openclaw-app-sidebar');
await sidebar.getByRole('button',{name:/Switch agent/}).click();
await sidebar.locator('wa-dropdown-item[value="agent:writer"]').click();
await page.locator('openclaw-app-sidebar [data-session-key="agent:writer:dashboard:item-1"]').first().waitFor();
await context.close();
}
for(let run=0;run<5;run++) for(const stage of run%2===0?['before','after']:['after','before']) {
const dir=path.join(root,'clips',stage);await mkdir(dir,{recursive:true});
const context=await browser.newContext({viewport:{width:1440,height:900},locale:'en-US',recordVideo:{dir,size:{width:1440,height:900}}});
const page=await context.newPage();page.setDefaultTimeout(30000);
try {
await install(page,stage);
await page.evaluate(({rows,stage,run,identity}:any)=>{
const w=window as any;const gateway=w.openclawControlUiE2eGateway;w.measurements=[];
const panel=document.createElement('div');panel.id='performance-proof';panel.style.cssText='position:fixed;right:20px;bottom:20px;z-index:2147483647;background:#081526;color:white;border:2px solid #66cfff;border-radius:10px;padding:18px;width:490px;font:18px/1.5 monospace;pointer-events:none';document.body.append(panel);
const title=`${stage.toUpperCase()} | repetition ${run+1}/5 | NORMAL SPEED`;
const render=(m:any)=>{panel.textContent=`${title}\n${identity}\nMOCK GATEWAY · 200 rows/agent · no added delays\n${m?`${m.agentId==='writer'?'COLD: Main → Writer':'WARM: Writer → Main'}\n${m.usableMs===undefined?'Waiting for usable row':'Usable row visible'}: ${(m.usableMs??performance.now()-m.click).toFixed(1)} ms`:'Ready: fresh browser context, Main loaded'}\nClock: click event → first usable-row animation frame`;panel.style.whiteSpace='pre-wrap';};render(null);
document.addEventListener('click',(event)=>{
const option=event.composedPath().find((n:any)=>n?.matches?.('.sidebar-agent-menu__agent-switch')) as HTMLElement|undefined;
const agentId=option?.getAttribute('value')?.slice(6);if(!agentId)return;
const m:any={agentId,click:performance.now(),dispatch:[],response:[]};w.measurements.push(m);
const frame=()=>{
const el=document.querySelector(`openclaw-app-sidebar [data-session-key="agent:${agentId}:dashboard:item-1"]`) as HTMLElement|null;
if(el){const b=el.getBoundingClientRect();const hit=document.elementFromPoint(b.x+b.width/2,b.y+b.height/2);if(b.width>0&&b.height>0&&b.y>=0&&b.bottom<=innerHeight&&hit&&(el===hit||el.contains(hit))&&!el.closest('[inert],[aria-disabled="true"]')) m.usableMs=performance.now()-m.click;}
render(m);if(m.usableMs===undefined)requestAnimationFrame(frame);
};requestAnimationFrame(frame);
},true);
gateway.setRequestHandler('sessions.list',({params,respond}:any)=>{
const primary=!params.hasBoard&&!params.spawnedBy&&!params.archived;
const m=w.measurements.at(-1);if(primary&&m)m.dispatch.push({agentId:params.agentId,ms:performance.now()-m.click});
const sessions=primary?rows.filter((r:any)=>r.agentId===params.agentId):[];
respond({ts:Date.now(),count:sessions.length,sessions,defaults:{model:'gpt-5.5',modelProvider:'openai',contextTokens:null},hasMore:false,nextOffset:null});
if(primary&&m)m.response.push({agentId:params.agentId,ms:performance.now()-m.click});
});
},{rows,stage,run,identity:stage==='before'?`base ${manifest.baseline.slice(0,12)}`:`candidate ${manifest.candidateHead.slice(0,12)} + patch ${manifest.candidatePatchSha256.slice(0,10)}`});
for(const agent of ['writer','main']) {
// Pauses only provide readable context between actions, never delay measured work.
await page.waitForTimeout(1000);
const sidebar=page.locator('openclaw-app-sidebar');
await sidebar.getByRole('button',{name:/Switch agent/}).click();
await sidebar.locator(`wa-dropdown-item[value="agent:${agent}"]`).click();
await page.waitForFunction((id:string)=>{const m=(window as any).measurements.at(-1);return m?.agentId===id&&m.usableMs!==undefined&&m.response.some((r:any)=>r.agentId===id);},agent);
await page.waitForTimeout(1500);
if(run===0)await page.screenshot({path:path.join(root,`${stage}-${agent}.png`)});
}
samples.push({run,stage,measurements:await page.evaluate(()=>(window as any).measurements)});
const video=page.video();await context.close();await video.saveAs(path.join(dir,`run-${run+1}.webm`));
await writeFile(path.join(root,'samples.partial.json'),JSON.stringify(samples,null,2));
} catch(e) {await page.screenshot({path:path.join(root,`failure-${stage}-${run}.png`)}).catch(()=>{});await context.close();throw e;}
}
const summary:any={};
for(const stage of ['before','after']){summary[stage]={};for(const agent of ['writer','main']){const a=samples.filter(s=>s.stage===stage).flatMap(s=>s.measurements).filter(m=>m.agentId===agent).map(m=>m.usableMs).sort((a,b)=>a-b);const mean=a.reduce((a,b)=>a+b,0)/a.length;summary[stage][agent]={n:a.length,min:a[0],median:a[2],max:a.at(-1),mean,sd:Math.sqrt(a.reduce((s,x)=>s+(x-mean)**2,0)/a.length),samples:a};}}
await writeFile(path.join(root,'results.json'),JSON.stringify({manifest:{baseline:manifest.baseline,candidateHead:manifest.candidateHead,candidatePatchSha256:manifest.candidatePatchSha256},conditions:{boundary:'mocked Gateway, source-mode UI',browser:browser.version(),platform:os.platform(),arch:os.arch(),cpu:os.cpus()[0]?.model,viewport:'1440x900',rowsPerAgent:200,repetitions:5,order:'AB, BA, AB, BA, AB',rpcDelayMs:0,network:'loopback; no throttling',timing:'capture-phase agent-switch click event to first animation frame with visible hit-testable item-1 row',betweenActionReadabilityPausesMs:[1000,1500]},summary,samples},null,2));
console.log(JSON.stringify({root,summary}));
}finally{await browser.close();for(const server of Object.values(servers) as any[])await server.close();}before-run-1.webmafter-run-1.webmbefore-run-2.webmafter-run-2.webmbefore-run-3.webmafter-run-3.webmbefore-run-4.webmafter-run-4.webmbefore-run-5.webmafter-run-5.webm |
adb1259 to
9ad4cc5
Compare
Fix exact background-selection assertions and derive the supplemental reconciliation promise type. Refs agent-switch-4b7.
Current-head browser behavior proofVerified The Chromium test exercised the rendered Control UI against a synthetic Gateway with 200 session rows per agent. Writer rows appeared while OPENCLAW_CAPTURE_UI_PROOF=1 node scripts/run-vitest.mjs run \
--config test/vitest/vitest.ui-e2e.config.ts --configLoader runner \
ui/src/e2e/agent-switch-roster.e2e.test.ts \
ui/src/e2e/chat-startup-request-priority.e2e.test.ts \
ui/src/e2e/queue-update-reload.e2e.test.tsOnly Screenshot files were captured, but media inspection and originating-chat render verification are blocked by the available tool policies. They have not been accepted as delivered visual evidence. The earlier published screenshots/videos retain their historical source identities. Current-head five-run benchmark provenance, image delivery, hosted CI/compiler results, and completed current-head ClawSweeper review remain open. No merge-readiness claim or merge authorization. |
Exact-head five-run synthetic benchmarkCandidate: Observed click-to-usable-row times
Boundary and limitations: Chromium/source-mode Control UI against a synthetic Gateway; 200 rows per agent, 1440×900 viewport, no added network or RPC delay. Fresh browser contexts follow source-module warmup, with paired AB/BA order on the same shared host. Timing starts at the captured picker click and ends at the first animation frame where the selected row is visible and hit-testable. Readability pauses occur outside the measured interval. CPU scheduling is uncontrolled. The older baseline versus the integrated candidate does not isolate this PR's contribution and does not establish production latency or a population-tail estimate. The exact-head held-request browser test is published separately. Exact-head CI completed successfully, including production/test typechecks, lint, build artifacts and the Control UI performance gate. This does not change the separate local compiler-boundary result. Ten original normal-speed videos and screenshots were captured locally, but their inspection, upload and originating-chat rendering are not verified. Historical published media retains its stated source identity. Screenshot delivery remains a completion gate; no merge authorization is implied. All raw samples, controls and source verification{
"verification": {
"candidateHead": "d6b040f3e5bd3d574f6d1f15a9d3f1672267b5c8",
"candidateTree": "941389b6412836e096875b434fd65784c6cac56e",
"baseline": "82d4d1cc175549e222e3cb2605716f277eff6a00",
"exit": 0,
"stageRuns": 10,
"measurements": 20,
"normalSpeedOriginalVideos": 10,
"sourceUnchanged": true,
"resultSha256": "0481f344d589d17b4ac10cd3837b481131622386d98424a3ea7c55ac9bfa30b3",
"harnessSha256": "54dfa05c9b110625d3c8475b8f8782d0e71aad2adc46bf036551c8ac61041c97",
"visualInspectionAndDelivery": "not verified; existing tool-policy boundaries remain"
},
"conditions": {
"boundary": "mocked Gateway, source-mode UI",
"browser": "153.0.8010.12",
"platform": "linux",
"arch": "x64",
"cpu": "Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz",
"viewport": "1440x900",
"rowsPerAgent": 200,
"repetitions": 5,
"order": "AB, BA, AB, BA, AB",
"rpcDelayMs": 0,
"network": "loopback; no throttling",
"timing": "capture-phase agent-switch click event to first animation frame with visible hit-testable item-1 row",
"betweenActionReadabilityPausesMs": [
1000,
1500
]
},
"samples": [
{
"run": 0,
"stage": "before",
"measurements": [
{
"agentId": "writer",
"click": 4007.899999856949,
"dispatch": [
{
"agentId": "writer",
"ms": 335.40000009536743
}
],
"response": [
{
"agentId": "writer",
"ms": 335.7999999523163
}
],
"usableMs": 407.10000014305115
},
{
"agentId": "main",
"click": 7129,
"dispatch": [
{
"agentId": "main",
"ms": 62.39999985694885
}
],
"response": [
{
"agentId": "main",
"ms": 62.799999952316284
}
],
"usableMs": 151.19999980926514
}
]
},
{
"run": 0,
"stage": "after",
"measurements": [
{
"agentId": "writer",
"click": 3929.2999999523163,
"dispatch": [
{
"agentId": "writer",
"ms": 54.799999952316284
}
],
"response": [
{
"agentId": "writer",
"ms": 55.200000047683716
}
],
"usableMs": 138.90000009536743
},
{
"agentId": "main",
"click": 7051,
"dispatch": [
{
"agentId": "main",
"ms": 138.79999995231628
}
],
"response": [
{
"agentId": "main",
"ms": 139.29999995231628
}
],
"usableMs": 131.5
}
]
},
{
"run": 1,
"stage": "after",
"measurements": [
{
"agentId": "writer",
"click": 3997.0999999046326,
"dispatch": [
{
"agentId": "writer",
"ms": 90.5
}
],
"response": [
{
"agentId": "writer",
"ms": 91.10000014305115
}
],
"usableMs": 195.60000014305115
},
{
"agentId": "main",
"click": 7100.899999856949,
"dispatch": [
{
"agentId": "main",
"ms": 122.60000014305115
}
],
"response": [
{
"agentId": "main",
"ms": 123
}
],
"usableMs": 115.80000019073486
}
]
},
{
"run": 1,
"stage": "before",
"measurements": [
{
"agentId": "writer",
"click": 3958.0999999046326,
"dispatch": [
{
"agentId": "writer",
"ms": 317.60000014305115
}
],
"response": [
{
"agentId": "writer",
"ms": 318.10000014305115
}
],
"usableMs": 405.90000009536743
},
{
"agentId": "main",
"click": 7085.899999856949,
"dispatch": [
{
"agentId": "main",
"ms": 65.5
}
],
"response": [
{
"agentId": "main",
"ms": 65.90000009536743
}
],
"usableMs": 187
}
]
},
{
"run": 2,
"stage": "before",
"measurements": [
{
"agentId": "writer",
"click": 4015.300000190735,
"dispatch": [
{
"agentId": "writer",
"ms": 291.59999990463257
}
],
"response": [
{
"agentId": "writer",
"ms": 291.7999999523163
}
],
"usableMs": 362.69999980926514
},
{
"agentId": "main",
"click": 6999.800000190735,
"dispatch": [
{
"agentId": "main",
"ms": 57
}
],
"response": [
{
"agentId": "main",
"ms": 57.299999952316284
}
],
"usableMs": 150.39999985694885
}
]
},
{
"run": 2,
"stage": "after",
"measurements": [
{
"agentId": "writer",
"click": 3964.7000000476837,
"dispatch": [
{
"agentId": "writer",
"ms": 68.20000004768372
}
],
"response": [
{
"agentId": "writer",
"ms": 68.70000004768372
}
],
"usableMs": 152.79999995231628
},
{
"agentId": "main",
"click": 6733.299999952316,
"dispatch": [
{
"agentId": "main",
"ms": 120.40000009536743
}
],
"response": [
{
"agentId": "main",
"ms": 120.90000009536743
}
],
"usableMs": 113.70000004768372
}
]
},
{
"run": 3,
"stage": "after",
"measurements": [
{
"agentId": "writer",
"click": 4008.399999856949,
"dispatch": [
{
"agentId": "writer",
"ms": 56.5
}
],
"response": [
{
"agentId": "writer",
"ms": 57.10000014305115
}
],
"usableMs": 149.80000019073486
},
{
"agentId": "main",
"click": 7043.399999856949,
"dispatch": [
{
"agentId": "main",
"ms": 115.60000014305115
}
],
"response": [
{
"agentId": "main",
"ms": 116
}
],
"usableMs": 109.10000014305115
}
]
},
{
"run": 3,
"stage": "before",
"measurements": [
{
"agentId": "writer",
"click": 3817.600000143051,
"dispatch": [
{
"agentId": "writer",
"ms": 318.7000000476837
}
],
"response": [
{
"agentId": "writer",
"ms": 319.09999990463257
}
],
"usableMs": 399.7999999523163
},
{
"agentId": "main",
"click": 6936,
"dispatch": [
{
"agentId": "main",
"ms": 79.30000019073486
}
],
"response": [
{
"agentId": "main",
"ms": 79.70000004768372
}
],
"usableMs": 160.5
}
]
},
{
"run": 4,
"stage": "before",
"measurements": [
{
"agentId": "writer",
"click": 3961.100000143051,
"dispatch": [
{
"agentId": "writer",
"ms": 412.89999985694885
}
],
"response": [
{
"agentId": "writer",
"ms": 413.39999985694885
}
],
"usableMs": 508.89999985694885
},
{
"agentId": "main",
"click": 7068.700000047684,
"dispatch": [
{
"agentId": "main",
"ms": 74.59999990463257
}
],
"response": [
{
"agentId": "main",
"ms": 75.20000004768372
}
],
"usableMs": 202.59999990463257
}
]
},
{
"run": 4,
"stage": "after",
"measurements": [
{
"agentId": "writer",
"click": 3955.699999809265,
"dispatch": [
{
"agentId": "writer",
"ms": 55.5
}
],
"response": [
{
"agentId": "writer",
"ms": 55.700000047683716
}
],
"usableMs": 135.40000009536743
},
{
"agentId": "main",
"click": 7007.5,
"dispatch": [
{
"agentId": "main",
"ms": 106.5
}
],
"response": [
{
"agentId": "main",
"ms": 106.89999985694885
}
],
"usableMs": 100.29999995231628
}
]
}
]
}Reproduction harnessWith the declared baseline snapshot, the clean candidate checkout and their existing approved dependencies, supply import { writeFile, readFile, mkdir } from 'node:fs/promises';
import path from 'node:path';
import os from 'node:os';
import { chromium } from 'playwright';
const root = path.dirname(new URL(import.meta.url).pathname);
const manifest = JSON.parse(await readFile(path.join(root, 'source-manifest.json'), 'utf8'));
const helpers = Object.fromEntries(await Promise.all(['before','after'].map(async stage => [stage, await import(path.join(manifest.roots[stage],'ui/src/test-helpers/control-ui-e2e.ts'))])));
const { createControlUiSessionRow } = await import(path.join(manifest.roots.after,'ui/src/test-helpers/control-ui-session-fixtures.ts'));
const rows = ['main','writer'].flatMap(agent => Array.from({length:200},(_,i) => createControlUiSessionRow(`agent:${agent}:${i===0?'main':`dashboard:item-${i}`}`, `${agent==='main'?'Main':'Writer'} project ${String(i).padStart(3,'0')}`,1789540000000-i*1000,{agentId:agent})));
const servers:any = {}; const samples:any[]=[];
const browser = await chromium.launch({executablePath:helpers.after.resolvePlaywrightChromiumExecutablePath(chromium.executablePath())});
async function install(page:any, stage:string) {
await page.addInitScript('globalThis.__name = (target) => target;');
await helpers[stage].installMockGateway(page,{sessions:rows,historyMessages:[{role:'assistant',content:'Synthetic matched browser performance fixture.'}],methodResponses:{'agents.list':{defaultId:'main',mainKey:'main',scope:'per-sender',agents:[{id:'main',name:'Main'},{id:'writer',name:'Writer'}]}}});
await page.goto(`${servers[stage].baseUrl}chat/main`);
await page.locator('openclaw-app-sidebar [data-session-key="agent:main:dashboard:item-1"]').first().waitFor();
}
try {
for(const stage of ['before','after']) {
servers[stage]=await helpers[stage].startControlUiE2eServer(undefined,{source:true});
const context=await browser.newContext({viewport:{width:1440,height:900},locale:'en-US'});
const page=await context.newPage(); await install(page,stage);
// Prime source-module compilation outside the recorded fresh contexts.
const sidebar=page.locator('openclaw-app-sidebar');
await sidebar.getByRole('button',{name:/Switch agent/}).click();
await sidebar.locator('wa-dropdown-item[value="agent:writer"]').click();
await page.locator('openclaw-app-sidebar [data-session-key="agent:writer:dashboard:item-1"]').first().waitFor();
await context.close();
}
for(let run=0;run<5;run++) for(const stage of run%2===0?['before','after']:['after','before']) {
const dir=path.join(root,'clips',stage);await mkdir(dir,{recursive:true});
const context=await browser.newContext({viewport:{width:1440,height:900},locale:'en-US',recordVideo:{dir,size:{width:1440,height:900}}});
const page=await context.newPage();page.setDefaultTimeout(30000);
try {
await install(page,stage);
await page.evaluate(({rows,stage,run,identity}:any)=>{
const w=window as any;const gateway=w.openclawControlUiE2eGateway;w.measurements=[];
const panel=document.createElement('div');panel.id='performance-proof';panel.style.cssText='position:fixed;right:20px;bottom:20px;z-index:2147483647;background:#081526;color:white;border:2px solid #66cfff;border-radius:10px;padding:18px;width:490px;font:18px/1.5 monospace;pointer-events:none';document.body.append(panel);
const title=`${stage.toUpperCase()} | repetition ${run+1}/5 | NORMAL SPEED`;
const render=(m:any)=>{panel.textContent=`${title}\n${identity}\nMOCK GATEWAY · 200 rows/agent · no added delays\n${m?`${m.agentId==='writer'?'COLD: Main → Writer':'WARM: Writer → Main'}\n${m.usableMs===undefined?'Waiting for usable row':'Usable row visible'}: ${(m.usableMs??performance.now()-m.click).toFixed(1)} ms`:'Ready: fresh browser context, Main loaded'}\nClock: click event → first usable-row animation frame`;panel.style.whiteSpace='pre-wrap';};render(null);
document.addEventListener('click',(event)=>{
const option=event.composedPath().find((n:any)=>n?.matches?.('.sidebar-agent-menu__agent-switch')) as HTMLElement|undefined;
const agentId=option?.getAttribute('value')?.slice(6);if(!agentId)return;
const m:any={agentId,click:performance.now(),dispatch:[],response:[]};w.measurements.push(m);
const frame=()=>{
const el=document.querySelector(`openclaw-app-sidebar [data-session-key="agent:${agentId}:dashboard:item-1"]`) as HTMLElement|null;
if(el){const b=el.getBoundingClientRect();const hit=document.elementFromPoint(b.x+b.width/2,b.y+b.height/2);if(b.width>0&&b.height>0&&b.y>=0&&b.bottom<=innerHeight&&hit&&(el===hit||el.contains(hit))&&!el.closest('[inert],[aria-disabled="true"]')) m.usableMs=performance.now()-m.click;}
render(m);if(m.usableMs===undefined)requestAnimationFrame(frame);
};requestAnimationFrame(frame);
},true);
gateway.setRequestHandler('sessions.list',({params,respond}:any)=>{
const primary=!params.hasBoard&&!params.spawnedBy&&!params.archived;
const m=w.measurements.at(-1);if(primary&&m)m.dispatch.push({agentId:params.agentId,ms:performance.now()-m.click});
const sessions=primary?rows.filter((r:any)=>r.agentId===params.agentId):[];
respond({ts:Date.now(),count:sessions.length,sessions,defaults:{model:'gpt-5.5',modelProvider:'openai',contextTokens:null},hasMore:false,nextOffset:null});
if(primary&&m)m.response.push({agentId:params.agentId,ms:performance.now()-m.click});
});
},{rows,stage,run,identity:stage==='before'?`base ${manifest.baseline.slice(0,12)}`:`exact candidate ${manifest.candidateHead.slice(0,12)}`});
for(const agent of ['writer','main']) {
// Pauses only provide readable context between actions, never delay measured work.
await page.waitForTimeout(1000);
const sidebar=page.locator('openclaw-app-sidebar');
await sidebar.getByRole('button',{name:/Switch agent/}).click();
await sidebar.locator(`wa-dropdown-item[value="agent:${agent}"]`).click();
await page.waitForFunction((id:string)=>{const m=(window as any).measurements.at(-1);return m?.agentId===id&&m.usableMs!==undefined&&m.response.some((r:any)=>r.agentId===id);},agent);
await page.waitForTimeout(1500);
if(run===0)await page.screenshot({path:path.join(root,`${stage}-${agent}.png`)});
}
samples.push({run,stage,measurements:await page.evaluate(()=>(window as any).measurements)});
const video=page.video();await context.close();await video.saveAs(path.join(dir,`run-${run+1}.webm`));
await writeFile(path.join(root,'samples.partial.json'),JSON.stringify(samples,null,2));
} catch(e) {await page.screenshot({path:path.join(root,`failure-${stage}-${run}.png`)}).catch(()=>{});await context.close();throw e;}
}
const summary:any={};
for(const stage of ['before','after']){summary[stage]={};for(const agent of ['writer','main']){const a=samples.filter(s=>s.stage===stage).flatMap(s=>s.measurements).filter(m=>m.agentId===agent).map(m=>m.usableMs).sort((a,b)=>a-b);const mean=a.reduce((a,b)=>a+b,0)/a.length;summary[stage][agent]={n:a.length,min:a[0],median:a[2],max:a.at(-1),mean,sd:Math.sqrt(a.reduce((s,x)=>s+(x-mean)**2,0)/a.length),samples:a};}}
await writeFile(path.join(root,'results.json'),JSON.stringify({manifest:{baseline:manifest.baseline,candidateHead:manifest.candidateHead,candidatePatchSha256:manifest.candidatePatchSha256},conditions:{boundary:'mocked Gateway, source-mode UI',browser:browser.version(),platform:os.platform(),arch:os.arch(),cpu:os.cpus()[0]?.model,viewport:'1440x900',rowsPerAgent:200,repetitions:5,order:'AB, BA, AB, BA, AB',rpcDelayMs:0,network:'loopback; no throttling',timing:'capture-phase agent-switch click event to first animation frame with visible hit-testable item-1 row',betweenActionReadabilityPausesMs:[1000,1500]},summary,samples},null,2));
console.log(JSON.stringify({root,summary}));
}finally{await browser.close();for(const server of Object.values(servers) as any[])await server.close();} |
|
@clawsweeper re-review Same head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
* fix: show selected agent sessions without waiting for chat startup * fix(ui): preserve startup priority and scoped history ordering * test(ui): align selection and reconciliation contracts Fix exact background-selection assertions and derive the supplemental reconciliation promise type. Refs agent-switch-4b7.


What Problem This Solves
Fixes: switching agents leaves the session sidebar waiting for the previous chat's startup work, and returning to a loaded agent waits for another list response.
User Impact
Explicit agent switches can fetch the selected agent's sessions immediately. Returning to a loaded agent can show its matching, still-valid list while a fresh server request runs. Server invalidation, local mutations, observer failure, connection changes, and query changes retire stale presentation.
Why This Change Was Made
Foreground navigation should not queue behind background hydration. Warm presentation reuses the existing roster owner rather than adding independent storage, and remains separate from authoritative state. Request generations fence superseded navigation; server invalidation also fences warm admission for reads already in flight.
Visual delivery and final evidence acceptance are incomplete. Do not merge.
Historical evidence
Rebased candidate:
114bfa58bcc28ad1dbbf4f347cf0c0e665dd7aa4on82d4d1cc175549e222e3cb2605716f277eff6a00. Current-base validation below supersedes earlier candidate measurements.Changes walkthrough
ui/src/lib/sessions/index.tsui/src/lib/sessions/session-agent-selection.tsui/src/lib/sessions/session-list-query.tsui/src/lib/sessions/session-roster-refresh.tsui/src/lib/sessions/session-primary-windows.tsui/src/lib/sessions/session-list-observation.tsui/src/lib/sessions/selection-hydration.test.tsui/src/lib/sessions/agent-selection-priority.test.tsui/src/lib/sessions/warm-selection-presentation.test.tsui/src/e2e/agent-switch-roster.e2e.test.tsView the OpenClaw team session
Repair validation — adb125973be693e24780a9b451a37681d593601d
The repair separates automatic startup binding from deliberate selection, keeps scoped history defaults behind lifecycle checks without authorizing stale descriptor updates, fixes typed RPC mocks, and gives the private agent-switch browser server a serial test owner. The prestarted-history regression failed before the fix; all six scoped-history cases are preserved in a dedicated sibling suite.
03f9392fda9f54487d3d00efe7f4aad609c7e95a.The existing screenshot and video evidence remains historical at its explicitly recorded source identities. The five paired normal-speed recordings and full measurements are attached directly here; they do not claim to measure this latest repair commit. Originating-chat screenshot rendering remains unverified. The PR is currently ready for review; this update preserves that state and does not clear the remaining exact-head CI/review or delivery gates. No merge authorization has been given.
Current-head acceptance:
d6b040f3e5bd3d574f6d1f15a9d3f1672267b5c8