Fix telemetry and abortable transport checks

This commit is contained in:
Jinjing
2026-11-10 20:41:16 -08:00
parent b1b3f2a1cf
commit f2e364d55d
3 changed files with 25 additions and 5 deletions
+3 -3
View File
@@ -180,8 +180,7 @@ export function track<N extends EventName>(name: N, props: EventProps<N>): 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<N extends EventName>(name: N, props: EventProps<N>): 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
})
@@ -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',
+12 -1
View File
@@ -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 {