mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix(vscode): persist notification dismissals so they don't reappear
Add optimistic dismiss in the webview so the notification hides immediately when the user clicks X, and update the cached message in KiloProvider so the dismiss survives API failures and offline fallback paths. Previously a dismissed notification could reappear when the webview re-mounted or the CLI backend was temporarily unavailable because the cached payload still contained the old dismissedIds list.
This commit is contained in:
committed by
Mark IJbema
parent
82d6b73c91
commit
0c28c7c0f2
@@ -1404,6 +1404,18 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper
|
||||
private async fetchAndSendNotifications(): Promise<void> {
|
||||
if (!this.client) {
|
||||
if (this.cachedNotificationsMessage) {
|
||||
// Merge the latest dismissed IDs from globalState into the cached
|
||||
// message so that dismissals persisted while offline are honoured.
|
||||
const persisted = this.extensionContext?.globalState.get<string[]>("kilo.dismissedNotificationIds", []) ?? []
|
||||
if (persisted.length > 0) {
|
||||
const cached = this.cachedNotificationsMessage as {
|
||||
type: string
|
||||
notifications: unknown[]
|
||||
dismissedIds: string[]
|
||||
}
|
||||
const merged = Array.from(new Set([...cached.dismissedIds, ...persisted]))
|
||||
this.cachedNotificationsMessage = { ...cached, dismissedIds: merged }
|
||||
}
|
||||
this.postMessage(this.cachedNotificationsMessage)
|
||||
}
|
||||
return
|
||||
@@ -1624,6 +1636,21 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper
|
||||
if (!existing.includes(notificationId)) {
|
||||
await this.extensionContext.globalState.update("kilo.dismissedNotificationIds", [...existing, notificationId])
|
||||
}
|
||||
// Update the cached message so the dismiss persists even if
|
||||
// fetchAndSendNotifications() fails (e.g. no client / API error).
|
||||
if (this.cachedNotificationsMessage) {
|
||||
const cached = this.cachedNotificationsMessage as {
|
||||
type: string
|
||||
notifications: unknown[]
|
||||
dismissedIds: string[]
|
||||
}
|
||||
if (!cached.dismissedIds.includes(notificationId)) {
|
||||
this.cachedNotificationsMessage = {
|
||||
...cached,
|
||||
dismissedIds: [...cached.dismissedIds, notificationId],
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.fetchAndSendNotifications()
|
||||
this.connectionService.notifyNotificationDismissed(notificationId)
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ export const NotificationsProvider: ParentComponent = (props) => {
|
||||
})
|
||||
|
||||
const dismiss = (id: string) => {
|
||||
setDismissedIds((prev) => (prev.includes(id) ? prev : [...prev, id]))
|
||||
vscode.postMessage({ type: "dismissNotification", notificationId: id })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user