The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
test(control-pane): pin that a late response keeps its hands off newer data
L4XB36460824ee8c
diff --git a/tests/lib/control-pane-ui.test.js b/tests/lib/control-pane-ui.test.jsindex 14809b96b..7e8f73e63 100644--- a/tests/lib/control-pane-ui.test.js+++ b/tests/lib/control-pane-ui.test.js@@ -40,7 +40,7 @@ class PageDate extends Date {// Runs the page script against a stand-in for the few browser APIs it uses:// elements looked up by selector, fetch, a fixed clock, and a setInterval// whose callback the test fires itself. While `hold` is set, a fetch waits in-// `pending` until the test settles it.+// `pending` until the test settles it, with the page's snapshot or another one.function openPage(snapshot) {const elements = new Map();const element = selector => {@@ -67,7 +67,7 @@ function openPage(snapshot) {fetch: () =>new Promise((resolve, reject) => {const reply = {- succeed: () => resolve({ ok: true, status: 200, statusText: 'OK', json: async () => snapshot }),+ succeed: (data = snapshot) => resolve({ ok: true, status: 200, statusText: 'OK', json: async () => data }),fail: () => reject(new TypeError('Failed to fetch'))};if (page.hold) page.pending.push(reply);@@ -200,6 +200,25 @@ async function runTests() {passed++;else failed++;+ if (+ await test('an older response that arrives after a newer one does not replace its data', async () => {+ const page = openPage(snapshot);+ await settle();+ const answer = query => ({ ...snapshot, knowledge: { ...snapshot.knowledge, query } });++ page.hold = true;+ page.refresh();+ page.refresh();+ page.pending[1].succeed(answer('newer'));+ await settle();+ page.pending[0].succeed(answer('older'));+ await settle();+ assert.strictEqual(page.element('#query').value, 'newer');+ })+ )+ passed++;+ else failed++;+console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);process.exit(failed > 0 ? 1 : 0);}