(page)
| 1007 | } |
| 1008 | |
| 1009 | async function k24(page) { |
| 1010 | // Fresh page loads of both projects are the reference for what each view shows (no switch involved). |
| 1011 | const fresh = await page.context().newPage(); |
| 1012 | const reference = {}; |
| 1013 | for (const project of [PROJECT, CONTROL]) { |
| 1014 | await open(fresh, project, 'explore'); |
| 1015 | await wait(4000); |
| 1016 | reference[project] = await viewTexts(fresh, `fresh-${project}`, false); |
| 1017 | await shot(fresh, 'K24', `fresh-${project}-system-logs`, `Reference: a fresh page load of ${project} (last view of the reference pass).`); |
| 1018 | } |
| 1019 | await fresh.close(); |
| 1020 | await save('K24', 'reference.json', reference); |
| 1021 | // The flow of the hand test (18:04): django-demo with the agent active and a selection, then cbm, then back. |
| 1022 | await open(page, PROJECT, 'galaxy'); |
| 1023 | await galaxyReady(page); |
| 1024 | const loaded = await loadModel(page); |
| 1025 | await openChat(page); |
| 1026 | await select(page, 'JSONBAgg'); |
| 1027 | await scopeSettled(page); |
| 1028 | await explanationDone(page); |
| 1029 | await ask(page, 'Who calls JSONBAgg?'); |
| 1030 | await shot(page, 'K24', 'before-switch', `${PROJECT} with the agent active, JSONBAgg selected and a listed answer in the chat.`); |
| 1031 | const page0 = await page.evaluate(() => ({ id: window.__probePage, origin: performance.timeOrigin, workers: window.__probeModelWorkers })); |
| 1032 | const requestsBefore = modelRequests.length; |
| 1033 | const legs = []; |
| 1034 | for (const [from, to, how] of [[PROJECT, CONTROL, 'switcher'], [CONTROL, PROJECT, 'switcher'], [PROJECT, CONTROL, 'back'], [CONTROL, PROJECT, 'forward']]) { |
| 1035 | const mark = await markWorker(page); |
| 1036 | const t = await now(page); |
| 1037 | const workspaceBefore = await activeWorkspace(page); |
| 1038 | const t0 = Date.now(); |
| 1039 | if (how === 'switcher') await switchTo(page, to); |
| 1040 | else if (how === 'back') await page.goBack({ waitUntil: 'commit' }); |
| 1041 | else await page.goForward({ waitUntil: 'commit' }); |
| 1042 | const frames = await lampFrames(page, `${how}-to-${to}`, t0); |
| 1043 | await page.waitForFunction((name) => new URLSearchParams(location.search).get('project') === name, to, { timeout: 30000 }).catch(() => {}); |
| 1044 | const shown = await page.locator('.atlas-project-switcher summary').first().getAttribute('aria-label').catch(() => ''); |
| 1045 | const workspaceAfter = await activeWorkspace(page); |
| 1046 | const chat = await page.locator('.cbm-chat-transcript').innerText().catch(() => ''); |
| 1047 | // Every workspace on every leg, Back and Forward included. |
| 1048 | const { texts, galaxy } = await viewTexts(page, `${how}-to-${to}`, true); |
| 1049 | const views = Object.entries(texts).map(([id, text]) => { |
| 1050 | const stale = PROJECT_MARKERS[from].exec(text)?.[0]; |
| 1051 | const expected = pathTokens(reference[to].texts[id] ?? ''); |
| 1052 | const unexpected = [...pathTokens(text)].filter((token) => !expected.has(token) && PROJECT_MARKERS[from].test(token)); |
| 1053 | return { id, stale: stale ?? null, unexpected: unexpected.slice(0, 5), chars: text.length, referenceChars: (reference[to].texts[id] ?? '').length, sameAsFresh: sameText(text, reference[to].texts[id] ?? '') }; |
| 1054 | }); |
| 1055 | await wait(1500); |
| 1056 | const leaks = await requestsNaming(page, t, to, from); |
| 1057 | const state = await page.evaluate(() => ({ id: window.__probePage, origin: performance.timeOrigin, workers: window.__probeModelWorkers })); |
| 1058 | const prepares = (await workerMessages(page)).slice(mark).filter((entry) => entry.kind === 'prepare').length; |
| 1059 | legs.push({ from, to, how, project: shown, url: await page.evaluate(() => location.search), workspace: { before: workspaceBefore, after: workspaceAfter }, samePage: state.id === page0.id && state.origin === page0.origin, |
| 1060 | modelWorkersCreated: state.workers - page0.workers, prepares, lamp: frames.map(({ at, label }) => ({ at, label })), |
| 1061 | chatHasOldTurn: to === CONTROL ? /Who calls JSONBAgg/.test(chat) : null, chatKeptOwnTurn: to === PROJECT ? /Who calls JSONBAgg/.test(chat) : null, |
| 1062 | views, galaxy, galaxyFresh: reference[to].galaxy, galaxySameAsFresh: sameGraph(galaxy, reference[to].galaxy), requestsAfterSwitch: leaks.total, requestsNamingOldProject: leaks.naming }); |
| 1063 | } |
| 1064 | const downloads = modelRequests.length - requestsBefore; |
| 1065 | await save('K24', 'legs.json', legs); |
| 1066 | const legOk = (leg) => leg.samePage && leg.workspace.before === leg.workspace.after && leg.modelWorkersCreated === 0 && leg.prepares === 0 && leg.lamp.every((frame) => /Agent active/.test(frame.label ?? '')) |
nothing calls this directly
no test coverage detected