MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / exercise

Function exercise

graph-ui/tools/smoke-w15.mjs:174–222  ·  view source on GitHub ↗
({ area, button, restore, root, built, ai, shot, screenshotTarget, scope = page })

Source from the content-addressed store, hash-verified

172 report.autoRequestReadings.push({ area, requests });
173 };
174 const exercise = async ({ area, button, restore, root, built, ai, shot, screenshotTarget, scope = page }) => {
175 const askButton = scope.locator(button);
176 const rootNode = typeof root === 'string' ? page.locator(root) : root ?? scope;
177 const hasAiButton = await askButton.isVisible();
178 const aiButtonEnabled = hasAiButton && await askButton.isEnabled();
179 report.aiButtons += hasAiButton ? 1 : 0;
180 if (!hasAiButton || !aiButtonEnabled) {
181 const state = area === 'flow' ? await page.evaluate(() => ({
182 llm: globalThis.__atlasLlm?.state ?? '',
183 flowLines: globalThis.__atlasFlow?.subject.length ?? 0,
184 })) : undefined;
185 throw new Error(`${area} AI button is not usable: ${JSON.stringify(state)}`);
186 }
187 const before = tidy(await rootNode.textContent());
188 const builtProvenance = tidy(await scope.locator(built).textContent());
189 const requestsBefore = completionRequests.length;
190 await askButton.click();
191 try {
192 await scope.locator(restore).waitFor({ state: 'visible', timeout: 30000 });
193 } catch (error) {
194 const refusal = tidy(await page.locator(`[data-testid="atlas-${area}-ai-refused"]`).textContent().catch(() => ''));
195 const state = area === 'flow' ? await page.evaluate(() => globalThis.__atlasFlow?.aiState ?? '') : '';
196 throw new Error(`${area} AI did not apply (${state}): ${refusal || String(error)}`);
197 }
198 const restoreButton = scope.locator(restore);
199 const restoreVisible = await restoreButton.isVisible();
200 report.restoreButtons += restoreVisible ? 1 : 0;
201 const aiProvenance = tidy(await scope.locator(ai).textContent());
202 if (area === 'twin') {
203 await page.locator('.atlas-twin-body').evaluate((node) => { node.scrollTop = node.scrollHeight; });
204 await page.mouse.move(8, 8);
205 await page.waitForTimeout(120);
206 }
207 if (screenshotTarget !== undefined) await page.locator(screenshotTarget).scrollIntoViewIfNeeded();
208 await page.screenshot({ path: join(OUT, shot) });
209 const beforeRestore = completionRequests.length;
210 await restoreButton.click();
211 await scope.locator(button).waitFor({ state: 'visible' });
212 const after = tidy(await rootNode.textContent());
213 report.areas[area] = {
214 hasAiButton, aiButtonEnabled, restoredIdentical: before === after,
215 restoreAsksModelAgain: completionRequests.length !== beforeRestore,
216 builtProvenance, aiProvenance, requestsForAi: completionRequests.length - requestsBefore,
217 requestModels: completionRequests.slice(requestsBefore).map((request) => request.model).filter(Boolean),
218 requestModelPresent: completionRequests.slice(requestsBefore).every((request) => typeof request.model === 'string' && request.model.length > 0),
219 provenanceMatchesSelection: aiProvenance.includes(report.selectedRouterModelName),
220 ...(await guard(area)),
221 };
222 };
223
224 // First question uses the normal depth. It opens the chat zone itself.
225 const off = await ask(1, false);

Callers 1

mainFunction · 0.85

Calls 2

guardFunction · 0.85
tidyFunction · 0.70

Tested by

no test coverage detected