Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-web-ws-reconnect-toast.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

web: Fix the connection error toast lingering after the WebSocket reconnects when returning from the background.
19 changes: 19 additions & 0 deletions apps/kimi-web/src/composables/useKimiWebClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,12 @@ function connectEventsIfNeeded(): void {
onConnectionChange(connected: boolean) {
rawState.connected = connected;
rawState.connection = connected ? 'connected' : 'disconnected';
// The data channel is healthy again (server_hello received). Clear any
// stale "Realtime connection error" toast instead of relying on its
// auto-dismiss timer: iOS Safari freezes timers while a tab is
// backgrounded, so the toast would otherwise linger until a manual
// refresh even though the reconnect already succeeded.
if (connected) dismissWsError();
},
});
}
Expand Down Expand Up @@ -1095,6 +1101,19 @@ function pushWarning(warning: AppWarning): void {
rawState.warnings = [...rawState.warnings, warning];
}

// Drop every "Realtime connection error" notice pushed by the WS onError
// handler. Matched by severity + the localized wsTitle (the same i18n instance
// used to push it), so other errors are left untouched.
function dismissWsError(): void {
const title = i18n.global.t('warnings.wsTitle');
const next = rawState.warnings.filter(
(w) => !(typeof w === 'object' && w !== null && w.severity === 'error' && w.title === title),
);
if (next.length !== rawState.warnings.length) {
rawState.warnings = next;
}
}

function pushOperationFailure(
operation: string,
err: unknown,
Expand Down
Loading