Control UI: reconnect on seq gaps

This commit is contained in:
Gustavo Madeira Santana
2026-03-29 19:31:01 -04:00
parent 15c3aa82bf
commit 1600c1726e
3 changed files with 11 additions and 4 deletions

View File

@@ -131,12 +131,17 @@ function createHost() {
assistantAgentId: null,
serverVersion: null,
sessionKey: "main",
basePath: "",
chatMessage: "",
chatMessages: [],
chatAttachments: [],
chatQueue: [],
chatToolMessages: [],
chatStreamSegments: [],
chatStream: null,
chatStreamStartedAt: null,
chatRunId: null,
chatSending: false,
toolStreamById: new Map(),
toolStreamOrder: [],
toolStreamSyncTimer: null,
@@ -195,9 +200,9 @@ describe("connectGateway", () => {
expect(host.lastError).toBeNull();
secondClient.emitGap(20, 24);
expect(host.lastError).toBe(
"event gap detected (expected seq 20, got 24); refresh recommended",
);
expect(gatewayClientInstances).toHaveLength(3);
expect(secondClient.stop).toHaveBeenCalledTimes(1);
expect(host.lastError).toBeNull();
});
it("ignores stale client onEvent callbacks after reconnect", () => {

View File

@@ -264,8 +264,9 @@ export function connectGateway(host: GatewayHost) {
if (host.client !== client) {
return;
}
host.lastError = `event gap detected (expected seq ${expected}, got ${received}); refresh recommended`;
host.lastError = `event gap detected (expected seq ${expected}, got ${received}); reconnecting`;
host.lastErrorCode = null;
connectGateway(host);
},
});
host.client = client;