fix(vscode): propagate telemetry opt-in/out to open webviews

VS Code exposes `env.onDidChangeTelemetryEnabled` for runtime changes
to the telemetry consent setting. The extension was only reading
`env.isTelemetryEnabled` once during `syncWebviewState`, so toggling
`telemetry.telemetryLevel` while a Kilo webview was open left the
feedback UI stuck on its previous visibility state until reload.

Add `watchTelemetryState()` next to `pushTelemetryState()` and wire
the disposable in `setupWebviewMessageHandler` alongside the existing
`watchAutocompleteConfig`. Uses the same registration/dispose pattern
as the autocomplete config watcher.

Also bump the ESLint `max-lines` cap on AgentManagerApp.tsx from 3200
to 3210 to accommodate the FeedbackProvider wrapper that sits inside
the provider chain (past precedent: 3100 → 3200 for terminal tabs).

Closes #9872.
This commit is contained in:
Josh Lambert
2026-05-05 01:26:39 -04:00
parent af88cbe203
commit ac4a7ab620
4 changed files with 23 additions and 4 deletions
+4 -1
View File
@@ -49,7 +49,10 @@ export default [
// (canvases must never leave the paint tree — see render.tsx), and
// render-call wiring that must live at the top of
// `AgentManagerContent` alongside the existing selection/session state.
rules: { complexity: ["error", 74], "max-lines": ["error", 3200] },
// Raised from 3200 → 3210 for the per-message feedback `FeedbackProvider`
// wiring, which sits inside the provider chain and cannot be extracted
// without adding an intermediate wrapper component.
rules: { complexity: ["error", 74], "max-lines": ["error", 3210] },
},
{
files: ["src/agent-manager/AgentManagerProvider.ts"],
+5 -1
View File
@@ -16,7 +16,7 @@ import type { EditorContext, IndexingStatus } from "./services/cli-backend/types
import { FileIgnoreController } from "./services/autocomplete/shims/FileIgnoreController"
import { ChatTextAreaAutocomplete } from "./services/autocomplete/chat-autocomplete/ChatTextAreaAutocomplete"
import { buildWebviewHtml, getWebviewFontSize } from "./utils"
import { TelemetryProxy, type TelemetryPropertiesProvider, pushTelemetryState } from "./services/telemetry"
import { TelemetryProxy, type TelemetryPropertiesProvider, pushTelemetryState, watchTelemetryState } from "./services/telemetry" // prettier-ignore
import {
sessionToWebview,
indexProvidersById,
@@ -216,6 +216,7 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper
private initConnectionPromise: Promise<void> | null = null
private webviewMessageDisposable: vscode.Disposable | null = null
private autocompleteConfigDisposable: vscode.Disposable | null = null
private telemetryStateDisposable: vscode.Disposable | null = null
private viewStateDisposable: vscode.Disposable | null = null
private visibilityDisposable: vscode.Disposable | null = null
private autoApproveBridge: ReturnType<typeof createAutoApproveBridge> | null = null
@@ -579,6 +580,8 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper
this.webviewMessageDisposable?.dispose()
this.autocompleteConfigDisposable?.dispose()
this.autocompleteConfigDisposable = watchAutocompleteConfig((msg) => this.postMessage(msg))
this.telemetryStateDisposable?.dispose()
this.telemetryStateDisposable = watchTelemetryState((msg) => this.postMessage(msg))
this.webviewMessageDisposable = webview.onDidReceiveMessage(async (message) => {
const intercepted = await interceptMessage(message, {
workspaceDir: (sid) => this.getWorkspaceDirectory(sid ?? this.currentSession?.id),
@@ -3402,6 +3405,7 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper
this.visibilityDisposable?.dispose()
this.webviewMessageDisposable?.dispose()
this.autocompleteConfigDisposable?.dispose()
this.telemetryStateDisposable?.dispose()
this.autoApproveBridge?.dispose()
this.streams.dispose()
this.isWebviewReady = false
@@ -1,3 +1,3 @@
export { TelemetryEventName, type TelemetryPropertiesProvider } from "./types"
export { TelemetryProxy } from "./telemetry-proxy"
export { pushTelemetryState } from "./webview-state"
export { pushTelemetryState, watchTelemetryState } from "./webview-state"
@@ -1,9 +1,21 @@
import * as vscode from "vscode"
type Post = (msg: { type: "telemetryState"; enabled: boolean }) => void
/**
* Push the current VS Code telemetry-enabled flag to a webview. Called on
* webview ready / re-sync so the webview can gate feedback UI on the flag.
*/
export function pushTelemetryState(post: (msg: { type: "telemetryState"; enabled: boolean }) => void): void {
export function pushTelemetryState(post: Post): void {
post({ type: "telemetryState", enabled: vscode.env.isTelemetryEnabled })
}
/**
* Re-push telemetry state whenever the user toggles the VS Code telemetry
* setting while a webview is open, so feedback UI shows/hides in real time.
*/
export function watchTelemetryState(post: Post): vscode.Disposable {
return vscode.env.onDidChangeTelemetryEnabled((enabled) => {
post({ type: "telemetryState", enabled })
})
}