mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-07-09 17:29:12 +00:00
fix(web): dismiss stale connection error toast after ws reconnect (#1474)
This commit is contained in:
parent
2065ae4615
commit
11c6a37ce0
2 changed files with 24 additions and 0 deletions
5
.changeset/fix-web-ws-reconnect-toast.md
Normal file
5
.changeset/fix-web-ws-reconnect-toast.md
Normal file
|
|
@ -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.
|
||||
|
|
@ -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();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue