fix: filter notifications by showIn so CLI-only and extension-only notifications target the right client

Move showIn filtering from the gateway to each client. The gateway now
returns all notifications unfiltered, and the CLI TUI filters for
showIn containing "cli" while the VS Code extension filters for
"extension". Notifications with no showIn field appear in both clients.

This prevents extension-targeted notifications (e.g. "Prefer the
terminal? Install the Kilo CLI") from appearing in the CLI where
they don't make sense.
This commit is contained in:
kiloconnect[bot]
2026-02-27 14:55:25 +00:00
parent 46a88a0fe4
commit 849780995d
3 changed files with 5 additions and 8 deletions
@@ -30,7 +30,7 @@ const NOTIFICATIONS_TIMEOUT_MS = 5000
* Fetch notifications from Kilo API
*
* @param options - Configuration with token and optional organization ID
* @returns Array of notifications filtered for CLI display
* @returns Array of notifications from the Kilo API (clients filter by showIn)
*/
export async function fetchKilocodeNotifications(options: {
kilocodeToken?: string
@@ -57,11 +57,7 @@ export async function fetchKilocodeNotifications(options: {
if (!result.success) return []
// Filter to show notifications meant for CLI (or no specific target)
// Accept "cli", "extension", or no showIn field (matches old Kilo CLI behavior)
return result.data.notifications.filter(
({ showIn }) => !showIn || showIn.includes("cli") || showIn.includes("extension"),
)
return result.data.notifications
} catch {
return []
}
+2 -1
View File
@@ -1041,7 +1041,8 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper
}
try {
const notifications = await this.httpClient.getNotifications()
const all = await this.httpClient.getNotifications()
const notifications = all.filter((n) => !n.showIn || n.showIn.includes("extension"))
const existing = this.extensionContext?.globalState.get<string[]>("kilo.dismissedNotificationIds", []) ?? []
const active = new Set(notifications.map((n) => n.id))
const dismissedIds = existing.filter((id) => active.has(id))
@@ -42,7 +42,7 @@ export function KiloNews() {
if (!isKiloConnected()) return
const result = await sdk.client.kilo.notifications()
const items = result.data
const items = result.data?.filter(({ showIn }) => !showIn || showIn.includes("cli"))
if (items && items.length > 0) {
setNotifications(items)
}