From f2e364d55d79dec40545c7c0b70620b030e050eb Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sun, 8 Nov 2026 00:34:52 -0800 Subject: [PATCH] Fix telemetry and abortable transport checks --- src/main/telemetry/client.ts | 6 +++--- .../images/rich-markdown-blob-image-paste.test.ts | 11 ++++++++++- tests/e2e/claude-agent-row-view.unit.test.ts | 13 ++++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/telemetry/client.ts b/src/main/telemetry/client.ts index e21b63a7e20..dc1ccccc7f0 100644 --- a/src/main/telemetry/client.ts +++ b/src/main/telemetry/client.ts @@ -180,8 +180,7 @@ export function track(name: N, props: EventProps): boole // Read persisted consent live to respect current preferences/env precedence. const settings = storeRef.getSettings() - const consent = resolveConsent(settings) - if (consent.effective !== 'enabled') { + if (resolveConsent(settings).effective !== 'enabled') { return false } @@ -215,8 +214,9 @@ export function track(name: N, props: EventProps): boole ? { sample_rate: sampleRate } : {} + const switchCohort = settings.telemetry?.chatUiSwitchNoteCohort enqueueCapture(name, { - chat_ui_switch_note_v1: settings.telemetry?.chatUiSwitchNoteCohort, + ...(switchCohort && { chat_ui_switch_note_v1: switchCohort }), ...result.props, ...mainOwnedProps }) diff --git a/src/renderer/src/components/editor/rich-markdown/images/rich-markdown-blob-image-paste.test.ts b/src/renderer/src/components/editor/rich-markdown/images/rich-markdown-blob-image-paste.test.ts index a70b54dbd8a..73473c7f9a4 100644 --- a/src/renderer/src/components/editor/rich-markdown/images/rich-markdown-blob-image-paste.test.ts +++ b/src/renderer/src/components/editor/rich-markdown/images/rich-markdown-blob-image-paste.test.ts @@ -87,7 +87,16 @@ beforeEach(() => { })) Object.defineProperty(window, 'api', { configurable: true, - value: { runtime: { call: saves }, fs: { importExternalPaths: imports } } + value: { + runtime: { + call: saves, + subscribe: async (args: unknown, onResponse: (response: unknown) => void) => { + void saves(args).then(onResponse) + return { unsubscribe: () => {} } + } + }, + fs: { importExternalPaths: imports } + } }) vi.stubGlobal( 'fetch', diff --git a/tests/e2e/claude-agent-row-view.unit.test.ts b/tests/e2e/claude-agent-row-view.unit.test.ts index 4479c706c6c..e223bfb2ad1 100644 --- a/tests/e2e/claude-agent-row-view.unit.test.ts +++ b/tests/e2e/claude-agent-row-view.unit.test.ts @@ -335,7 +335,18 @@ beforeEach(async () => { runtime: { call: ({ method, params }: { method: string; params: unknown }) => mocks.transport(method, params), - subscribe: (_args: unknown, onResponse: (response: unknown) => void) => { + subscribe: async ( + args: { method: string; params: unknown }, + onResponse: (response: unknown) => void + ) => { + if (['status.get', 'terminal.list', 'terminal.viewClaudeAgent'].includes(args.method)) { + void mocks + .transport(args.method, args.params) + .then(onResponse, (error: Error) => + onResponse({ ok: false, error: { code: 'INTERNAL', message: error.message } }) + ) + return { unsubscribe: () => {} } + } listeners++ const stop = bridge.subscribe((snapshot) => onResponse({ ok: true, result: snapshot })) return {