Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
test(ui): browser checks for the K24 switch situations and the YAML facts
Bernhard Jackiewiczb824b34206dc
diff --git a/graph-ui/tools/handtest-fixes-chat.mjs b/graph-ui/tools/handtest-fixes-chat.mjsindex 387f094be..83e51e3ff 100644--- a/graph-ui/tools/handtest-fixes-chat.mjs+++ b/graph-ui/tools/handtest-fixes-chat.mjs@@ -18,6 +18,8 @@** It starts no server. It needs a running server with the UI and a browser profile in* which the local model is cached for this origin (Cache Storage is per origin).+ * With --with-download the last K24 check deletes that cached model and downloads it again (network+ * access to Hugging Face), to switch the project while the download runs; the cache is full again after it.*/import { chromium } from 'playwright';@@ -37,6 +39,7 @@ const PROFILE = resolve(String(arg('profile', join(OUT, '..', 'profile'))));const PROJECT = String(arg('project', 'django-demo'));const CONTROL = String(arg('control', 'cbm'));const RUNS = Number(arg('runs', 3));+const WITH_DOWNLOAD = arg('with-download', false) === true;const HEADED = arg('headed', false) === true;const ALL = ['K15', 'K16', 'K11', 'K17', 'K14', 'K7', 'K4', 'K1', 'K12', 'K10', 'K24'];const ONLY = String(arg('only', ALL.join(','))).split(',');@@ -57,11 +60,18 @@ function pageProbe() {window.__probeFetches = [];const nativeFetch = window.fetch.bind(window);window.fetch = (input, init) => {+ let entry;try {const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;- window.__probeFetches.push({ t: Math.round(performance.now()), url, body: typeof init?.body === 'string' ? init.body.slice(0, 600) : '', page: location.search });+ // A log post is kept whole enough to read its page and entries (K24).+ const keep = /\/api\/ui-log/.test(url) ? 8000 : 600;+ entry = { t: Math.round(performance.now()), url, body: typeof init?.body === 'string' ? init.body.slice(0, keep) : '', page: location.search };+ window.__probeFetches.push(entry);} catch { /* observation only */ }- return nativeFetch(input, init);+ const answer = nativeFetch(input, init);+ // When it ended and how: a request still open at a switch is either aborted or lands nowhere (K24).+ if (entry) answer.then(() => { entry.done = Math.round(performance.now()); }, (error) => { entry.done = Math.round(performance.now()); entry.failed = String(error?.name ?? error); });+ return answer;};window.__probePage = Math.random().toString(36).slice(2);const NativeWorker = window.Worker;@@ -503,10 +513,13 @@ async function k7(page) {await explanationDone(page);[request] = (await sentSince(page, mark)).filter((entry) => entry.profile === 'automatic-explanation');const openedCard = await explanationText(page);- outputs.push({ selection: 'Architecture overview, django opened, nothing selected', card: openedCard, model: (await answersSince(page, from))[0]?.output, prompt: promptText(request) });+ // The card counts the parts the view counts ("23 parts · 100 connections"): inside the area and outside it.+ const viewParts = /([\d,]+) parts? · [\d,]+ connections?/.exec(await page.locator('.atlas-workspace-stage').innerText().catch(() => ''))?.[1] ?? null;+ const cardParts = /Parts shown \(([\d,]+)/.exec(openedCard)?.[1] ?? null;+ outputs.push({ selection: 'Architecture overview, django opened, nothing selected', card: openedCard, model: (await answersSince(page, from))[0]?.output, prompt: promptText(request), viewParts, cardParts });await shot(page, 'K7', 'architecture-area-opened', 'Overview inside django with nothing selected: the card names the opened area, its lines and languages, the parts shown, its hotspot findings and the connections between its parts.');const openedOk = !request && /Opened source area: django\./.test(openedCard) && /indexed lines in [\d,]+ measured files of [\d,]+; files by language: /.test(openedCard)- && /Parts shown \([\d,]+, largest first\): /.test(openedCard) && /hotspot findings?: /.test(openedCard) && /Connections of its parts: /.test(openedCard) && /not generated by the model/.test(openedCard)+ && /Parts shown \([\d,]+(?:, largest first\)|\): [\d,]+ inside the area, largest first): /.test(openedCard) && viewParts !== null && cardParts === viewParts && /hotspot findings?: /.test(openedCard) && /Connections of its parts: /.test(openedCard) && /not generated by the model/.test(openedCard)&& !/^Opened: /m.test(openedCard);// Architecture, Behavior: main of manage.py-tpl.mark = await markWorker(page); from = await now(page);@@ -520,8 +533,8 @@ async function k7(page) {const behaviorOk = /Starting operation: main/.test(card) && (!request || /def main\(\)/.test(promptText(request))) && !/Finding a|Visible operations/.test(card)&& /line 9 calls os\.environ\.setdefault/.test(card) && /line 18 calls execute_from_command_line/.test(card);await save('K7', 'outputs.json', outputs);- check('K7', 'Automatic explanations rest on listed facts (Galaxy incoming CALLS, Architecture area selected and opened, Behavior)', galaxyOk && areaOk && openedOk && behaviorOk,- { galaxyOk, areaOk, openedOk, behaviorOk, cards: outputs.map((item) => `${item.selection}: ${item.card.replace(/\s+/g, ' ').slice(0, 520)}`) });+ check('K7', 'Automatic explanations rest on listed facts (Galaxy incoming CALLS, Architecture area selected and opened with the parts the view counts, Behavior)', galaxyOk && areaOk && openedOk && behaviorOk,+ { galaxyOk, areaOk, openedOk, behaviorOk, openedParts: { card: cardParts, view: viewParts }, cards: outputs.map((item) => `${item.selection}: ${item.card.replace(/\s+/g, ' ').slice(0, 520)}`) });}async function k4(page) {@@ -648,6 +661,23 @@ async function k12(page) {others.push({ path, card: text.replace(/\s+/g, ' ').slice(0, 300), factsOnly: /Read from the file; not generated by the model\./.test(text), modelCalls: calls });if (others.length <= 3) await shot(page, 'K12', `facts-${path.replace(/[^\w]+/g, '-')}`, `${path}: the automatic card shows only what is read from the file; no model call.`);}+ // A YAML list of mappings is a list: django's pre-commit file holds `repos`, a list of 5 items with repo, rev and hooks,+ // not "10 keys: rev, hooks, rev, ..." (review of the K12 facts). The Read the Docs file is a mapping with a list below `python.install`.+ const yaml = [];+ for (const [path, wanted] of [['.pre-commit-config.yaml', /Top-level keys \(1\): repos \(list of 5; item keys: repo, rev, hooks\)\./],+ ['.readthedocs.yml', /Top-level keys \(5\): version, build \(2 keys: os, tools\), sphinx \(2 keys: configuration, fail_on_warning\), python \(1 key: install\), formats\./]]) {+ mark = await markWorker(page);+ const opened = await openTreeFile(page, path);+ await explanationDone(page);+ const text = await explanationText(page);+ const calls = (await sentSince(page, mark)).filter((entry) => entry.profile === 'automatic-explanation').length;+ await page.locator('.cbm-chat-explanation').screenshot({ path: join(OUT, 'K12', `yaml-${path.replace(/[^\w]+/g, '-')}-card.png`) }).catch(() => {});+ const file = await shot(page, 'K12', `yaml-${path.replace(/[^\w]+/g, '-')}`, `${path}: the automatic card counts what the YAML holds (a list as a list, its items' keys as item keys); crop: yaml-${path.replace(/[^\w]+/g, '-')}-card.png.`);+ yaml.push({ path, opened, file, card: text.replace(/\s+/g, ' ').slice(0, 400), wanted: wanted.test(text.replace(/\s+/g, ' ')),+ repeatedKeys: /keys: (\w+), (\w+), \1, \2/.test(text), factsOnly: /Read from the file; not generated by the model\./.test(text), modelCalls: calls });+ }+ check('K12', 'YAML facts count a list of mappings as a list with item keys (.pre-commit-config.yaml: repos, list of 5) and a mapping by its keys (.readthedocs.yml)',+ yaml.length === 2 && yaml.every((item) => item.opened && item.wanted && !item.repeatedKeys && item.factsOnly && item.modelCalls === 0), { yaml });// Explicit questions about the workflow go to the model, as before (back by its tree row: no reload, the model stays loaded).await openTreeFile(page, '.github/workflows/new_contributor_pr.yml');await explanationDone(page);@@ -763,16 +793,22 @@ async function showView(page, item) {}/** Paths and dotted names a view shows; a stale view shows ones the fresh view of its project does not. */const pathTokens = (text) => new Set(text.match(/[\w.@-]+\/[\w./@-]+/g) ?? []);+/** What the Galaxy draws: its headline names the indexed node count, which differs per project, while the stage text has no paths. */+const galaxyGraph = (page) => page.evaluate(() => ({ headline: globalThis.__atlasGalaxy?.headline ?? '', nodes: globalThis.__atlasGalaxy?.nodes ?? 0, target: globalThis.__atlasGalaxy?.lastTargetQn ?? '' }));async function viewTexts(page, label, shots) {const texts = {};+ let galaxy;for (const item of K24_VIEWS) {await showView(page, item);texts[item.id] = await settledStage(page, item.workspace === 'galaxy' ? 45000 : 30000);+ if (item.workspace === 'galaxy') { await galaxyReady(page); galaxy = await galaxyGraph(page); }if (item.workspace === 'system') texts[item.id] += `\n${await page.locator('select option[value="project"]').first().innerText().catch(() => '')}`;if (shots) await shot(page, 'K24', `${label}-${item.id}`, `${label}: ${item.id} after the switch.`);}- return texts;+ return { texts, galaxy };}+/** The same graph as the fresh Galaxy of the project: headline, node count and no selection carried over. */+const sameGraph = (seen, fresh) => Boolean(seen && fresh) && seen.headline === fresh.headline && seen.nodes === fresh.nodes && seen.target === fresh.target;/** Requests sent once the address named `shown` that name `project` (URL parameter or JSON argument);* the log transport carries entries logged before the switch by design. */async function requestsNaming(page, from, shown, project) {@@ -803,6 +839,166 @@ async function switchTo(page, project) {await page.locator('.atlas-project-picker button', { has: page.locator('.atlas-project-result-name', { hasText: new RegExp(`^${project}`) }) }).first().click();}+const pageState = (page) => page.evaluate(() => ({ id: window.__probePage, origin: performance.timeOrigin, workers: window.__probeModelWorkers }));+const projectShown = (page) => page.evaluate(() => new URLSearchParams(location.search).get('project'));+const chatToggle = (page) => page.locator('.atlas-agent-chat-toggle').first();+/** The ways a switch can meet the page that a plain switch does not: chat closed, an answer running,+ * the old project still loading, and a log line written after it (review of K24). */+async function k24Situations(page, reference) {+ const lampOk = (frames, last = /Agent active/) => frames.every((frame) => /Agent (?:active|working)/.test(frame.label ?? '')) && last.test(frames.at(-1)?.label ?? '');+ // 1. Chat closed: the model stays, the chat stays closed, and nothing is loaded again.+ {+ await tab(page, 'galaxy');+ if ((await chatToggle(page).getAttribute('aria-expanded')) === 'true') { await chatToggle(page).click(); await wait(600); }+ const here = await projectShown(page), other = here === CONTROL ? PROJECT : CONTROL;+ const before = await pageState(page), mark = await markWorker(page), t0 = Date.now();+ await switchTo(page, other);+ const frames = await lampFrames(page, `chat-closed-to-${other}`, t0);+ const after = await pageState(page);+ const chatExpanded = await chatToggle(page).getAttribute('aria-expanded');+ const prepares = (await sentSince(page, mark, 'prepare')).length;+ check('K24', 'A switch with the chat closed keeps the model loaded and the chat closed', after.id === before.id && after.workers === before.workers && prepares === 0+ && lampOk(frames) && chatExpanded === 'false' && (await projectShown(page)) === other,+ { from: here, to: other, samePage: after.id === before.id, modelWorkersCreated: after.workers - before.workers, prepares, chatExpanded, lamp: frames.map(({ at, label }) => ({ at, label })) });+ }+ // 2. An answer running in the old project: the lamp goes from working to active, the old answer never shows,+ // and the handed-over model answers in the new project.+ {+ if ((await projectShown(page)) !== PROJECT) { await switchTo(page, PROJECT); await wait(2500); }+ await tab(page, 'galaxy');+ await galaxyReady(page);+ await openChat(page);+ if ((await chatToggle(page).getAttribute('aria-expanded')) !== 'true') { await chatToggle(page).click(); await wait(800); }+ await select(page, 'JSONBAgg');+ await scopeSettled(page);+ await explanationDone(page);+ const question = 'Beschreibe ausführlich, wofür diese Klasse in Django verwendet wird, mit vielen Details.';+ const prompt = page.locator('#cbm-chat-prompt');+ await prompt.click(); await prompt.fill(question); await prompt.press('Enter');+ const running = await page.waitForFunction(() => Boolean(document.querySelector('.cbm-chat-send[aria-label="Stop"]')), null, { timeout: 30000 }).then(() => true).catch(() => false);+ await wait(600);+ const lampBefore = await agentLabel(page);+ const before = await pageState(page), mark = await markWorker(page), t0 = Date.now();+ await switchTo(page, CONTROL);+ const frames = await lampFrames(page, 'running-answer-to-cbm', t0);+ await page.waitForFunction(() => /Agent active/.test(document.querySelector('.atlas-browser-ai-action')?.getAttribute('aria-label') ?? ''), null, { timeout: 30000 }).catch(() => {});+ const settledLamp = await agentLabel(page);+ const transcript = await page.locator('.cbm-chat-transcript').innerText().catch(() => '');+ await shot(page, 'K24', 'running-answer-cbm-after-switch', 'cbm right after a switch while a django-demo answer was running: the old question and answer are not in cbm\'s chat; the lamp is back on "Agent active".');+ // A question in cbm that the model answers on the handed-over worker, about a file of cbm open in Explore.+ await tab(page, 'explore');+ const fileOpened = await openTreeFile(page, 'src/main.c');+ await explanationDone(page);+ const asked = await markWorker(page);+ const answer = await ask(page, 'Was macht diese Datei?');+ const [chat] = await sentSince(page, asked);+ await shot(page, 'K24', 'running-answer-cbm-model-answer', 'cbm after that switch: the model, handed over from django-demo, answers a question about cbm\'s src/main.c.');+ const after = await pageState(page);+ const prepares = (await sentSince(page, mark, 'prepare')).length;+ const answerText = answer.replace(/^You\s+[^\n]*\n+/, '').trim();+ const lastTurn = page.locator('.cbm-chat-turn').last();+ const failedTurn = (await lastTurn.locator('.cbm-chat-turn-error').count()) + (await lastTurn.getByText(/Stopped before an answer|Stopped · partial answer/).count());+ check('K24', 'A switch during a running answer: the lamp goes from working to active, the old answer never shows, and the handed-over model answers in the new project',+ running && /Agent working/.test(lampBefore ?? '') && frames.every((frame) => /Agent (?:active|working)/.test(frame.label ?? '')) && /Agent active/.test(settledLamp ?? '')+ && !transcript.includes(question) && !/JSONBAgg/.test(transcript) && fileOpened && Boolean(chat) && /src\/main\.c/.test(promptText(chat)) && !/JSONBAgg/.test(promptText(chat)) && answerText.length > 20+ && failedTurn === 0 && after.id === before.id && after.workers === before.workers && prepares === 0,+ { running, lampBefore, lamp: frames.map(({ at, label }) => ({ at, label })), settledLamp, oldQuestionInCbm: transcript.includes(question), fileOpened, modelAsked: Boolean(chat),+ promptNamesOld: /JSONBAgg/.test(promptText(chat)), failedTurn, answer: answerText.replace(/\s+/g, ' ').slice(0, 300), samePage: after.id === before.id, modelWorkersCreated: after.workers - before.workers, prepares });+ }+ // 3. The old project still loading: open django-demo's Galaxy and switch before its graph is there. The server+ // is made slow for that one layout (4 s), so the request is surely still open when the switch happens.+ {+ if ((await projectShown(page)) !== PROJECT) { await switchTo(page, PROJECT); await wait(2500); }+ await tab(page, 'explore');+ const slowLayout = (url) => /\/api\/layout/.test(url.pathname) && url.searchParams.get('project') === PROJECT;+ const delay = async (route) => { await wait(4000); await route.continue().catch(() => {}); };+ await page.route(slowLayout, delay);+ const clicked = await now(page);+ await page.locator('[data-workspace-tab="galaxy"]').first().click();+ await page.waitForFunction((from) => window.__probeFetches.some((entry) => entry.t >= from && /\/api\/layout/.test(entry.url)), clicked, { timeout: 15000 }).catch(() => {});+ await wait(300);+ const t = await now(page);+ const openAtSwitch = (await page.evaluate(() => window.__probeFetches.slice())).filter((entry) => entry.t >= clicked && /\/api\/layout/.test(entry.url) && entry.done === undefined).map((entry) => entry.url.slice(0, 100));+ await switchTo(page, CONTROL);+ await page.waitForFunction((name) => new URLSearchParams(location.search).get('project') === name, CONTROL, { timeout: 30000 }).catch(() => {});+ await galaxyReady(page);+ await settledStage(page, 45000);+ const graph = await galaxyGraph(page);+ await wait(4000);+ await page.unroute(slowLayout, delay);+ const ended = (await page.evaluate(() => window.__probeFetches.slice())).filter((entry) => entry.t >= clicked && entry.t < t && /\/api\/layout/.test(entry.url)).map((entry) => ({ url: entry.url.slice(0, 100), endedAfterSwitchMs: entry.done === undefined ? null : entry.done - t, failed: entry.failed ?? null }));+ const leaks = await requestsNaming(page, t, CONTROL, PROJECT);+ const text = await page.locator('.atlas-workspace-stage').innerText().catch(() => '');+ await shot(page, 'K24', 'switch-while-loading-cbm-galaxy', 'Switched to cbm while django-demo\'s Galaxy was still loading: cbm\'s own graph, nothing of django-demo.');+ check('K24', 'A switch while the old project is still loading shows the new project\'s own Galaxy; no request after the switch names the old project',+ openAtSwitch.length > 0 && sameGraph(graph, reference[CONTROL].galaxy) && leaks.naming.length === 0 && !PROJECT_MARKERS[PROJECT].test(text),+ { openAtSwitch, oldLayoutRequests: ended, graph, fresh: reference[CONTROL].galaxy, requestsAfterSwitch: leaks.total, requestsNamingOldProject: leaks.naming.slice(0, 5), stale: PROJECT_MARKERS[PROJECT].exec(text)?.[0] ?? null });+ }+ // 4. A log line written after a switch is posted under the page it was written on, the new one.+ {+ const here = await projectShown(page), other = here === CONTROL ? PROJECT : CONTROL;+ const t = await now(page);+ await page.evaluate(() => console.warn('k24 log line before the switch'));+ await switchTo(page, other);+ await page.waitForFunction((name) => new URLSearchParams(location.search).get('project') === name, other, { timeout: 30000 }).catch(() => {});+ await page.evaluate(() => console.warn('k24 log line after the switch'));+ await wait(4500);+ const posts = (await page.evaluate(() => window.__probeFetches.slice())).filter((entry) => entry.t >= t && /\/api\/ui-log/.test(entry.url)).map((entry) => {+ try { const body = JSON.parse(entry.body); return { page: body.page, messages: body.entries.map((item) => item.message), projects: [...new Set(body.entries.map((item) => item.project))] }; }+ catch { return { page: /"page"\s*:\s*"([^"]*)"/.exec(entry.body)?.[1], messages: [entry.body.slice(0, 200)], projects: [] }; }+ });+ const pageOf = (marker) => posts.find((post) => post.messages.some((message) => message.includes(marker)))?.page;+ const projectOf = (value) => new URLSearchParams(String(value ?? '').replace(/^[^?]*/, '')).get('project');+ const mixed = posts.filter((post) => post.projects.some((project) => project && project !== projectOf(post.page)));+ check('K24', 'A log line is posted under the page it was written on: before the switch the old one, after it the new one',+ projectOf(pageOf('k24 log line before the switch')) === here && projectOf(pageOf('k24 log line after the switch')) === other && mixed.length === 0,+ { from: here, to: other, before: pageOf('k24 log line before the switch'), after: pageOf('k24 log line after the switch'), posts: posts.map((post) => ({ page: post.page, projects: post.projects, messages: post.messages.slice(0, 4).map((message) => message.slice(0, 80)) })), mixed: mixed.length });+ }+ // 5. Only with --with-download: it deletes the cached model and downloads it again (567 MB from Hugging Face).+ if (!WITH_DOWNLOAD) return;+ // A download still running at the switch: the configuration of the new project shows how far it got and follows it.+ // The cached model of this profile is deleted first and downloaded again; the download ends in the new project.+ {+ const bar = async () => page.locator('.cbm-chat-loading').first().evaluate((element) => ({ value: element.querySelector('progress')?.value ?? null, file: element.querySelector('span')?.textContent ?? '' })).catch(() => null);+ await openConfig(page);+ await page.locator('dialog.cbm-agent-settings').getByRole('button', { name: 'Delete cached model', exact: true }).click();+ await page.waitForFunction(() => /Cached model files deleted/.test(document.querySelector('dialog.cbm-agent-settings')?.textContent ?? ''), null, { timeout: 30000 }).catch(() => {});+ await page.locator('dialog.cbm-agent-settings button').filter({ hasText: /^Download & load$/ }).click();+ const downloading = await page.waitForFunction(() => {+ const element = document.querySelector('.cbm-chat-loading');+ return /onnx/.test(element?.querySelector('span')?.textContent ?? '') && (element?.querySelector('progress')?.value ?? 0) > 2;+ }, null, { timeout: 120000 }).then(() => true).catch(() => false);+ const atSwitch = await bar();+ await page.locator('.cbm-chat-loading').first().scrollIntoViewIfNeeded().catch(() => {});+ await page.locator('.cbm-chat-loading').first().screenshot({ path: join(OUT, 'K24', 'download-before-switch-bar.png') }).catch(() => {});+ await shot(page, 'K24', 'download-before-switch', 'The model downloading in the configuration, just before the switch (crop of the bar: download-before-switch-bar.png).');+ await closeConfig(page);+ const here = await projectShown(page), other = here === CONTROL ? PROJECT : CONTROL;+ const before = await pageState(page), mark = await markWorker(page), t0 = Date.now();+ await switchTo(page, other);+ const lamp = [];+ for (const at of [0, 250, 1000]) { const delay = at - (Date.now() - t0); if (delay > 0) await wait(delay); lamp.push(await agentLabel(page)); }+ await openConfig(page);+ const shown = await bar();+ await page.locator('.cbm-chat-loading').first().scrollIntoViewIfNeeded().catch(() => {});+ await page.locator('.cbm-chat-loading').first().screenshot({ path: join(OUT, 'K24', 'download-after-switch-bar.png') }).catch(() => {});+ await shot(page, 'K24', 'download-after-switch', `The configuration of ${other} right after the switch: the bar shows how far the download of the last project got, with its file (crop: download-after-switch-bar.png).`);+ await wait(2500);+ const later = await bar();+ const active = await agentActive(page, 300000);+ await shot(page, 'K24', 'download-done-in-new-project', `The download ended in ${other}: the model is loaded.`);+ await closeConfig(page);+ const after = await pageState(page);+ const prepares = (await sentSince(page, mark, 'prepare')).length;+ check('K24', 'A download still running at a switch shows its progress in the configuration of the new project and ends there, without a second worker or load',+ // Each file of the model counts from 0 to 100: a later value is compared within the same file.+ downloading && (atSwitch?.value ?? 0) > 2 && (shown?.value ?? 0) > 0 && /onnx/.test(shown?.file ?? '') && (shown?.file !== atSwitch?.file || shown.value >= atSwitch.value)+ && (!later || later.file !== shown?.file || later.value >= shown.value)+ && lamp.every((label) => /Agent loading/.test(label ?? '')) && active && after.workers === before.workers && after.id === before.id && prepares === 0,+ { from: here, to: other, downloading, atSwitch, shownAfterSwitch: shown, twoSecondsLater: later, lamp, active, modelWorkersCreated: after.workers - before.workers, prepares, samePage: after.id === before.id });+ }+}+async function k24(page) {// Fresh page loads of both projects are the reference for what each view shows (no switch involved).const fresh = await page.context().newPage();@@ -811,6 +1007,7 @@ async function k24(page) {await open(fresh, project, 'explore');await wait(4000);reference[project] = await viewTexts(fresh, `fresh-${project}`, false);+ await shot(fresh, 'K24', `fresh-${project}-system-logs`, `Reference: a fresh page load of ${project} (last view of the reference pass).`);}await fresh.close();await save('K24', 'reference.json', reference);@@ -840,12 +1037,13 @@ async function k24(page) {const shown = await page.locator('.atlas-project-switcher summary').first().getAttribute('aria-label').catch(() => '');const workspaceAfter = await activeWorkspace(page);const chat = await page.locator('.cbm-chat-transcript').innerText().catch(() => '');- const texts = how === 'switcher' ? await viewTexts(page, `${how}-to-${to}`, true) : {};+ // Every workspace on every leg, Back and Forward included.+ const { texts, galaxy } = await viewTexts(page, `${how}-to-${to}`, true);const views = Object.entries(texts).map(([id, text]) => {const stale = PROJECT_MARKERS[from].exec(text)?.[0];- const expected = pathTokens(reference[to][id] ?? '');+ const expected = pathTokens(reference[to].texts[id] ?? '');const unexpected = [...pathTokens(text)].filter((token) => !expected.has(token) && PROJECT_MARKERS[from].test(token));- return { id, stale: stale ?? null, unexpected: unexpected.slice(0, 5), chars: text.length, referenceChars: (reference[to][id] ?? '').length, sameAsFresh: sameText(text, reference[to][id] ?? '') };+ 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] ?? '') };});await wait(1500);const leaks = await requestsNaming(page, t, to, from);@@ -854,18 +1052,19 @@ async function k24(page) {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,modelWorkersCreated: state.workers - page0.workers, prepares, lamp: frames.map(({ at, label }) => ({ at, label })),chatHasOldTurn: to === CONTROL ? /Who calls JSONBAgg/.test(chat) : null, chatKeptOwnTurn: to === PROJECT ? /Who calls JSONBAgg/.test(chat) : null,- views, requestsAfterSwitch: leaks.total, requestsNamingOldProject: leaks.naming });+ views, galaxy, galaxyFresh: reference[to].galaxy, galaxySameAsFresh: sameGraph(galaxy, reference[to].galaxy), requestsAfterSwitch: leaks.total, requestsNamingOldProject: leaks.naming });}const downloads = modelRequests.length - requestsBefore;await save('K24', 'legs.json', legs);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 ?? ''))- && new RegExp(leg.to).test(leg.project ?? '') && leg.requestsNamingOldProject.length === 0 && leg.views.every((view) => !view.stale && !view.unexpected.length)+ && new RegExp(leg.to).test(leg.project ?? '') && leg.requestsNamingOldProject.length === 0 && leg.views.length === K24_VIEWS.length && leg.views.every((view) => !view.stale && !view.unexpected.length) && leg.galaxySameAsFresh&& (leg.to !== CONTROL || leg.chatHasOldTurn === false) && (leg.to !== PROJECT || leg.how !== 'switcher' || leg.chatKeptOwnTurn === true);- check('K24', 'A project switch stays in the page: the model stays loaded (no reload, no new worker, lamp active), every workspace shows only the new project, no request names the old one; Back/Forward switch the same way',+ check('K24', 'A project switch stays in the page: the model stays loaded (no reload, no new worker, lamp active), every workspace shows only the new project and the Galaxy its graph, no request names the old one; Back/Forward the same, all views checked',loaded && downloads === 0 && legs.every(legOk),{ modelDownloads: downloads, legs: legs.map((leg) => ({ ...leg, views: leg.views.filter((view) => view.stale || view.unexpected.length), viewsChecked: leg.views.length,viewsSameAsFresh: leg.views.filter((view) => view.sameAsFresh).map((view) => view.id), viewsDifferingFromFresh: leg.views.filter((view) => !view.sameAsFresh).map((view) => view.id),requestsNamingOldProject: leg.requestsNamingOldProject.slice(0, 5) })) });+ await k24Situations(page, reference);// The configuration says what a switch does with the model.await openConfig(page);const tooltip = await page.locator('#cbm-chat-auto-load').locator('xpath=..').getAttribute('title').catch(() => '');