mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-05 08:15:41 -08:00
Forget the old console on a project switch, so its end never covers what shows next
AI Assisted
This commit is contained in:
1 parent
59d226c2a6
commit
8b5932c351
2 files changed
+56
-2
No files matched your search
@@ -540,6 +540,31 @@ test("app.js refills the reconnect budget on a new page and brings the page back
|
||||
assert.match(app.slice(app.indexOf("async function showLoopEnd"), app.indexOf("function applyLoopState")), /reconnectConsole\(\)/);
|
||||
});
|
||||
|
||||
test("app.js forgets the old project's console on a project switch, so no check of it covers the new agent's start or the launch card", () => {
|
||||
const app = fs.readFileSync(path.join(HERE, "..", "plan2code-app", "ui", "app.js"), "utf8");
|
||||
const at = app.indexOf("function forgetConsole");
|
||||
assert.ok(at > 0, "left known, the old console's poll put \"The console stopped\" over the new agent's start, or the launch card, five seconds after a switch");
|
||||
const forget = app.slice(at, app.indexOf("\n}\n", at));
|
||||
assert.match(forget, /consoleKnown = false/, "nothing is known again until the new agent opens a page");
|
||||
assert.match(forget, /clearInterval\(pollTimer\);\s*pollTimer = null/, "the poll stops, and showAnnounced can start it again");
|
||||
assert.match(forget, /clearTimeout\(helloTimer\)/, "a hello still awaited from the old page is not waited for");
|
||||
assert.match(forget, /markConsoleAlive\(\)/, "the bar drops a Console stopped it was showing");
|
||||
assert.match(forget, /frame\.src = 'about:blank'/, "the stopped console's page leaves the frame, or its Lost contact shows around the launch card");
|
||||
assert.match(forget, /clearAttention\(\);\s*setGameFull\(false\)/, "and takes its taskbar dot and its full-screen game with it, as loadFrame does");
|
||||
assert.match(forget, /consoleEpoch \+= 1/, "a check already under way can tell the project moved on");
|
||||
const change = app.slice(app.indexOf("async function doChangeProject"), app.indexOf("function changeProject"));
|
||||
assert.match(change, /forgetConsole\(\);[^}]*if \(prior\) await startPriorAgent\(prior\);\s*else afterProjectKnown\(\)/s, "forgotten before the new agent starts or the launch card shows");
|
||||
// Each check that waits on the app answers for the console it asked about.
|
||||
for (const name of ["onNoHello", "reconnectConsole", "pollConsole"]) {
|
||||
const from = app.indexOf(`async function ${name}`);
|
||||
const body = app.slice(from, app.indexOf("\n}\n", from));
|
||||
assert.match(body, /const epoch = consoleEpoch;/, `${name} notes which console it asks about`);
|
||||
const awaits = body.split("await invoke(").length - 1;
|
||||
const guards = body.split("if (epoch !== consoleEpoch) return;").length - 1;
|
||||
assert.ok(guards >= awaits, `${name} drops an answer that comes back after a switch (${guards} checks for ${awaits} waits)`);
|
||||
}
|
||||
});
|
||||
|
||||
test("the window title says a loop is running, and when it needs the person", () => {
|
||||
assert.equal(loopWindowTitle("C:/git/lunch", { phase: 2, phases: 7, step: "Build" }), "Loop: Phase 2 of 7 - lunch");
|
||||
assert.equal(loopWindowTitle("C:/git/lunch", { phase: 2, phases: 7, step: "Waiting on you" }), "Loop needs you: Phase 2 - lunch");
|
||||
|
||||
Reference in new issue
Block a user