Skip to content

Commit ec71a18

Browse files
committed
Fix chat session processing state init order
Move isProcessingSubmission declaration before createManagedSessionSyncController call so processing state is readable during sync controller startup. Add test verifying declaration ordering.
1 parent 639eed0 commit ec71a18

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/ui/tui/chat-session.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,8 @@ export async function startInteractiveSession(initialUserRequest, options = {})
728728
activeInteractionContainer,
729729
);
730730

731+
let isProcessingSubmission = false;
732+
731733
let tuiRuntimeAdapter = attachTuiRuntimeAdapter({
732734
runtime: sessionRuntime,
733735
sessionId: sessionId,
@@ -1030,8 +1032,6 @@ export async function startInteractiveSession(initialUserRequest, options = {})
10301032
tui.setFocus(editor);
10311033
}
10321034

1033-
let isProcessingSubmission = false;
1034-
10351035
/**
10361036
* Restore a queued item into the editor.
10371037
*

src/ui/tui/chat-session.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ Deno.test("chat session layout keeps transcript, validation panel, spinner, prom
3232
assertEquals(indexes, [...indexes].sort((a, b) => a - b));
3333
});
3434

35+
Deno.test("managed session sync can read processing state before startup awaits", async () => {
36+
const source = await Deno.readTextFile(new URL("./chat-session.js", import.meta.url));
37+
const processingStateIndex = source.indexOf("let isProcessingSubmission = false;");
38+
const syncControllerIndex = source.indexOf("const managedSyncController = createManagedSessionSyncController({");
39+
const modelWelcomeIndex = source.indexOf("const modelWelcomeResult = await maybeShowModelWelcome({");
40+
41+
assertEquals(processingStateIndex >= 0, true);
42+
assertEquals(syncControllerIndex >= 0, true);
43+
assertEquals(modelWelcomeIndex >= 0, true);
44+
assertEquals(processingStateIndex < syncControllerIndex, true);
45+
assertEquals(syncControllerIndex < modelWelcomeIndex, true);
46+
});
47+
3548
Deno.test("footer thinking level is hidden until a model is configured", () => {
3649
assertEquals(shouldShowFooterThinkingLevel("", "medium"), false);
3750
assertEquals(shouldShowFooterThinkingLevel("test/model", "off"), false);

0 commit comments

Comments
 (0)