fix(web): require post-acceptance state

This commit is contained in:
Miguel Palhas
2026-09-05 08:22:26 +01:00
parent 8bd943a8ca
commit b52a9085e9
2 changed files with 31 additions and 8 deletions
+10 -3
View File
@@ -429,7 +429,7 @@ describe("structured connection: reconnection/error/loading", () => {
conn.dispose();
});
it("releases an accepted submission from an idle snapshot after reconnect", async () => {
it("releases an accepted submission from a post-acceptance idle snapshot", async () => {
vi.mocked(sendStructuredPrompt).mockResolvedValueOnce(undefined);
const first = new FakeSocket();
const second = new FakeSocket();
@@ -452,14 +452,15 @@ describe("structured connection: reconnection/error/loading", () => {
conn.dispose();
});
it("releases when reconnect idle arrives before submission acceptance", async () => {
it("does not release from reconnect idle cached before submission acceptance", async () => {
let accept!: () => void;
vi.mocked(sendStructuredPrompt).mockImplementationOnce(
() => new Promise((resolve) => { accept = resolve; }),
);
const first = new FakeSocket();
const second = new FakeSocket();
const conn = mount({ sockets: [first, second], shouldReconnect: () => true });
const third = new FakeSocket();
const conn = mount({ sockets: [first, second, third], shouldReconnect: () => true });
first.open();
first.emit({ type: "transcript_snapshot", snapshot: { cursor: 0, rows: [] } });
first.emit({ type: "reduced_state", state: idleState });
@@ -477,6 +478,12 @@ describe("structured connection: reconnection/error/loading", () => {
accept();
await Promise.resolve().then(() => Promise.resolve());
expect(input.disabled).toBe(true);
expect(second.closed).toBe(true);
third.open();
third.emit({ type: "transcript_snapshot", snapshot: { cursor: 0, rows: [] } });
third.emit({ type: "reduced_state", state: idleState });
expect(input.disabled).toBe(false);
conn.dispose();
});