Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Prevent new-chat flash during conversation navigation (#1336)

Eve Bouffard8d9e15da4e37
diff --git a/plugins/web-ui/src/sessions.ts b/plugins/web-ui/src/sessions.ts
index ed1d00328..25d782e79 100644
--- a/plugins/web-ui/src/sessions.ts
+++ b/plugins/web-ui/src/sessions.ts
@@ -1630,9 +1630,7 @@ export async function openSessionInto(
sessionsState.openingKey = opening;
renderList();
}
- const skeletonTimer = window.setTimeout(() => {
- if (isLiveConversation(conv) && (!tracked || sessionsState.openingKey === opening)) conv.mountLoadingPane();
- }, 140);
+ if (isLiveConversation(conv) && (!tracked || sessionsState.openingKey === opening)) conv.mountLoadingPane();
const fetchEntries = (): Promise<TranscriptPage | null> =>
fetchTranscript(s.id, { tailTurns: TAIL_TURNS }).catch(() => null);
@@ -1641,7 +1639,6 @@ export async function openSessionInto(
entriesPrefetch ? entriesPrefetch.then((r) => r ?? fetchEntries()) : fetchEntries(),
continuable ? (approvalsPrefetch ?? fetchSessionApprovals(s.id)) : Promise.resolve(null),
]);
- window.clearTimeout(skeletonTimer);
if (!isLiveConversation(conv)) return;
if (tracked) {
diff --git a/plugins/web-ui/test/loading-pane-centered.test.ts b/plugins/web-ui/test/loading-pane-centered.test.ts
index 5da98ef25..c17b869a2 100644
--- a/plugins/web-ui/test/loading-pane-centered.test.ts
+++ b/plugins/web-ui/test/loading-pane-centered.test.ts
@@ -4,6 +4,7 @@ import test from "node:test";
const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");
const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");
+const sessions = readFileSync(new URL("../src/sessions.ts", import.meta.url), "utf8");
test("the loading pane renders chat-loading as the shell's only child", () => {
const fn = chat.match(/function mountLoadingPane\(\): void \{[\s\S]*?\n {2}\}/)?.[0] ?? "";
@@ -19,3 +20,13 @@ test("chat-loading spans every shell grid row so the spinner centers vertically"
assert.match(block, /align-items: center;/);
assert.match(block, /justify-content: center;/);
});
+
+test("opening a conversation replaces the previous pane before waiting for its transcript", () => {
+ const start = sessions.indexOf("export async function openSessionInto");
+ const body = sessions.slice(start, sessions.indexOf("\nexport ", start + 1));
+ const loading = body.indexOf("conv.mountLoadingPane()");
+ const waiting = body.indexOf("await Promise.all");
+ assert.ok(loading >= 0, "the target conversation must claim the pane with its loading state");
+ assert.ok(loading < waiting, "the previous conversation must disappear before transcript loading can yield");
+ assert.doesNotMatch(body, /setTimeout/, "a delay exposes the previous or new-conversation UI between clicks");
+});