The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
feat(usage): count the phone's own polls apart from the Desktop's
tony385b5603e16a
diff --git a/backend/src/routes/productUsage.test.ts b/backend/src/routes/productUsage.test.tsindex 844dd4c83..aeee261df 100644--- a/backend/src/routes/productUsage.test.ts+++ b/backend/src/routes/productUsage.test.ts@@ -149,9 +149,10 @@ it('takes how the phone opened Find or Computers, and the phone\'s own requests,const context = { surface: 'phone', release: '1.0.4', platform: 'ios', channel: 'production' }const counters = { ui_phone_screen_find_swipe: 2, ui_phone_screen_find_button: 1, ui_phone_screen_computers_swipe: 1,ui_phone_screen_computers_button: 1, request_phone_create_started: 1, request_phone_resume_error_other: 1,- request_phone_resume_reason_busy: 1 }+ request_phone_resume_reason_busy: 1, request_phone_automatic_history_ok: 1, request_phone_automatic_store_list_error_timeout: 1 }expect((await submit({ ...good, context, counters })).statusCode).toBe(200)- for (const name of ['ui_phone_screen_settings_swipe', 'ui_phone_screen_find_pinch', 'ui_desktop_screen_find_swipe']) {+ for (const name of ['ui_phone_screen_settings_swipe', 'ui_phone_screen_find_pinch', 'ui_desktop_screen_find_swipe',+ 'request_phone_automatic_create_ok', 'request_desktop_automatic_history_ok']) {expect((await submit({ ...good, context, counters: { [name]: 1 } })).statusCode).toBe(400)}})diff --git a/backend/src/types/productHealthContract.ts b/backend/src/types/productHealthContract.tsindex 7fcfced03..7aedd6a7d 100644--- a/backend/src/types/productHealthContract.ts+++ b/backend/src/types/productHealthContract.ts@@ -6,6 +6,9 @@ export const HEALTH_ACTIONS = ['create', 'resume', 'restart', 'model_change', 'h'search', 'history_page', 'store_list', 'store_install', 'store_update', 'store_remove','model_list', 'model_download', 'model_start', 'model_stop', 'browser_open', 'message'] as constexport const HEALTH_RESULTS = ['started', 'ok', 'failed', 'pending', 'cancelled', 'unknown'] as const+/** The fixed polls an app makes on its own, which count under `automatic` whichever app makes them+ * (`PRODUCT_USAGE_AUTOMATIC_ACTIONS`); the phone's are counted again, apart, under `phone_automatic`. */+export const AUTOMATIC_POLL_ACTIONS = ['history', 'history_page', 'store_list', 'model_list'] as constexport const HEALTH_FAILURES = ['setup', 'auth', 'unavailable', 'invalid', 'not_found', 'conflict', 'timeout', 'other'] as constexport const HEALTH_FLOWS = ['app_start', 'workspace_ready', 'viewer_load', 'update_apply', 'update_relaunch','connect_user', 'connect_auto', 'resume_recovery'] as const@@ -50,6 +53,11 @@ export const PRODUCT_HEALTH_METRICS = [...HEALTH_RESULTS.map(result => `request_${source}_${action}_${result}` as const),...HEALTH_FAILURES.map(failure => `request_${source}_${action}_error_${failure}` as const),])),+ // Of `automatic`, the phone's own again: until then the Desktop's and the phone's polls read as one total.+ ...AUTOMATIC_POLL_ACTIONS.flatMap(action => [+ ...HEALTH_RESULTS.map(result => `request_phone_automatic_${action}_${result}` as const),+ ...HEALTH_FAILURES.map(failure => `request_phone_automatic_${action}_error_${failure}` as const),+ ]),] as constexport type ProductHealthMetric = typeof PRODUCT_HEALTH_METRICS[number]export type HealthSource = typeof HEALTH_SOURCES[number]diff --git a/cli/src/lib/productHealthContract.ts b/cli/src/lib/productHealthContract.tsindex 7fcfced03..7aedd6a7d 100644--- a/cli/src/lib/productHealthContract.ts+++ b/cli/src/lib/productHealthContract.ts@@ -6,6 +6,9 @@ export const HEALTH_ACTIONS = ['create', 'resume', 'restart', 'model_change', 'h'search', 'history_page', 'store_list', 'store_install', 'store_update', 'store_remove','model_list', 'model_download', 'model_start', 'model_stop', 'browser_open', 'message'] as constexport const HEALTH_RESULTS = ['started', 'ok', 'failed', 'pending', 'cancelled', 'unknown'] as const+/** The fixed polls an app makes on its own, which count under `automatic` whichever app makes them+ * (`PRODUCT_USAGE_AUTOMATIC_ACTIONS`); the phone's are counted again, apart, under `phone_automatic`. */+export const AUTOMATIC_POLL_ACTIONS = ['history', 'history_page', 'store_list', 'model_list'] as constexport const HEALTH_FAILURES = ['setup', 'auth', 'unavailable', 'invalid', 'not_found', 'conflict', 'timeout', 'other'] as constexport const HEALTH_FLOWS = ['app_start', 'workspace_ready', 'viewer_load', 'update_apply', 'update_relaunch','connect_user', 'connect_auto', 'resume_recovery'] as const@@ -50,6 +53,11 @@ export const PRODUCT_HEALTH_METRICS = [...HEALTH_RESULTS.map(result => `request_${source}_${action}_${result}` as const),...HEALTH_FAILURES.map(failure => `request_${source}_${action}_error_${failure}` as const),])),+ // Of `automatic`, the phone's own again: until then the Desktop's and the phone's polls read as one total.+ ...AUTOMATIC_POLL_ACTIONS.flatMap(action => [+ ...HEALTH_RESULTS.map(result => `request_phone_automatic_${action}_${result}` as const),+ ...HEALTH_FAILURES.map(failure => `request_phone_automatic_${action}_error_${failure}` as const),+ ]),] as constexport type ProductHealthMetric = typeof PRODUCT_HEALTH_METRICS[number]export type HealthSource = typeof HEALTH_SOURCES[number]diff --git a/cli/src/lib/productUsageSignals.spec.ts b/cli/src/lib/productUsageSignals.spec.tsindex a7a32e16f..3962e052e 100644--- a/cli/src/lib/productUsageSignals.spec.ts+++ b/cli/src/lib/productUsageSignals.spec.ts@@ -4,8 +4,8 @@ import { fileURLToPath } from 'node:url'import { expect, it, vi } from 'vitest'import { failureKind, launchErrorCode, messageReceipt, productObservation, productUsageIntent, productUsageLaunch, productUsageRequest, productUsageSource } from './productUsageSignals.js'import type { MessageOutcome } from './sessionInput.js'-import { LAUNCH_ERROR_CODES, PRODUCT_USAGE_FLOWS, PRODUCT_USAGE_METRICS, PRODUCT_USAGE_SETUP_METRICS } from './productUsageContract.js'-import { HEALTH_MEASURES } from './productHealthContract.js'+import { LAUNCH_ERROR_CODES, PRODUCT_USAGE_AUTOMATIC_ACTIONS, PRODUCT_USAGE_FLOWS, PRODUCT_USAGE_METRICS, PRODUCT_USAGE_SETUP_METRICS } from './productUsageContract.js'+import { AUTOMATIC_POLL_ACTIONS, HEALTH_MEASURES } from './productHealthContract.js'it('separates automated polling, tool and app RPCs without inspecting error objects or content', () => {const emit = vi.fn()@@ -40,6 +40,11 @@ it('counts what a person on the phone asked for as the phone\'s, and its polls a'request_phone_resume_error_other', 'request_phone_resume_reason_busy','request_automatic_history_ok', 'request_automatic_model_list_ok']))expect(names).not.toContain('request_phone_history_ok')+ // One list of the fixed polls, as the feature counts name them.+ expect([...AUTOMATIC_POLL_ACTIONS]).toEqual([...PRODUCT_USAGE_AUTOMATIC_ACTIONS])+ // The phone's polls again, apart from every app's `automatic`; nothing else of the phone's.+ expect(names.filter(name => name.startsWith('request_phone_automatic_'))).toEqual(['request_phone_automatic_history_started',+ 'request_phone_automatic_history_ok', 'request_phone_automatic_model_list_started', 'request_phone_automatic_model_list_ok'])for (const name of names) expect(PRODUCT_USAGE_METRICS).toContain(name)const work = vi.fn()productUsageIntent('message', 'interactive', 'agent', 'phone', work)diff --git a/cli/src/lib/productUsageSignals.ts b/cli/src/lib/productUsageSignals.tsindex aed6d11c3..345763923 100644--- a/cli/src/lib/productUsageSignals.ts+++ b/cli/src/lib/productUsageSignals.ts@@ -1,4 +1,4 @@-import { HEALTH_FAILURES, HEALTH_MEASURES, type HealthSource, type ResumeReason } from './productHealthContract.js'+import { AUTOMATIC_POLL_ACTIONS, HEALTH_FAILURES, HEALTH_MEASURES, type HealthSource, type ResumeReason } from './productHealthContract.js'import type { MessageOutcome, MessageReceipt } from './sessionInput.js'import { LAUNCH_ERROR_CODES, PRODUCT_USAGE_FLOWS, PRODUCT_USAGE_LAUNCH_ENGINES, PRODUCT_USAGE_USER_OPENED_ACTIONS,type LaunchErrorCode, type ProductUsageLaunchEngine, type ProductUsageMetric } from './productUsageContract.js'@@ -130,10 +130,16 @@ export function productUsageRequest(type: string, emit: (metric: ProductUsageMetlet answered = false// A fixed poll is `automatic` whichever app makes it, the phone's included: its own source is for what a// person on it asked for.- const origin = (source === 'app' || source === 'phone') && ['history', 'history_page', 'store_list', 'model_list'].includes(action)+ const origin = (source === 'app' || source === 'phone') && (AUTOMATIC_POLL_ACTIONS as readonly string[]).includes(action)? 'automatic' : source+ // `automatic` is every app's polls, the Desktop's and the phone's together: the phone's are counted again, apart.+ const phonePoll = source === 'phone' && origin === 'automatic'const count = (measure: string) => { if (action && action !== 'message') { try { emit(`${action}_${measure}` as ProductUsageMetric) } catch { /* Optional measurement. */ } } }- const detail = (measure: string) => { if (!source) return; try { emit(`request_${origin}_${action}_${measure}` as ProductUsageMetric) } catch { /* Optional measurement. */ } }+ const detail = (measure: string) => {+ if (!source) return+ try { emit(`request_${origin}_${action}_${measure}` as ProductUsageMetric) } catch { /* Optional measurement. */ }+ if (phonePoll) { try { emit(`request_phone_automatic_${action}_${measure}` as ProductUsageMetric) } catch { /* Optional measurement. */ } }+ }count('requests'); detail('started')if (userAction && (PRODUCT_USAGE_USER_OPENED_ACTIONS as readonly string[]).includes(action)) count('user_requests')// [failure]: the kind of a refusal its caller already knows (a message's, [messageReceipt]), not read off a code.diff --git a/docs/product-measurement.md b/docs/product-measurement.mdindex cdec31993..ce38b4a2c 100644--- a/docs/product-measurement.md+++ b/docs/product-measurement.md@@ -69,15 +69,17 @@ it for under names of their own. Nothing else in a report is the phone's:| Where | Names | What they are || --- | --- | --- || The phone's own reports (`context.surface: 'phone'`, `platform: 'ios' \| 'android'`) | `ui_phone_*` signed in, `setup_phone_*` signed out, `health_phone_collector_days`, `health_phone_report_*` | Its flows and marks in the rows above: sign-in by button, the onboarding steps, `first_open`, `app_start` and what it waited on, its dials, `resume_recovery`, the side pages |-| A computer's daemon (that computer's CLI report, `context.surface: 'cli'`) | `request_phone_<action>_<result>`, `request_phone_<action>_error_<kind>`, `phone_delete_error_code_<code>`, `phone_restart_error_code_<code>` | The requests the phone sent that computer (create, resume, restart, delete and the rest, and a typed `message`), which it marks `usageSurface: 'phone'` inside the E2EE payload |+| A computer's daemon (that computer's CLI report, `context.surface: 'cli'`) | `request_phone_<action>_<result>`, `request_phone_<action>_error_<kind>`, `request_phone_automatic_<poll>_<result>`, `phone_delete_error_code_<code>`, `phone_restart_error_code_<code>` | The requests the phone sent that computer (create, resume, restart, delete and the rest, and a typed `message`), and apart its own fixed polls, all of which it marks `usageSurface: 'phone'` inside the E2EE payload || Margins | `breakdown:release:phone:<release>:<metric>`, `breakdown:platform:phone:<ios\|android>:<metric>` | The phone's own counts by its release and OS, shown above 20 collector days |Reading the phone apart:- In a daemon's report `request_app_*` is the Desktop's and the browser's, `request_tool_*` scripts' and- agents', `request_unknown_*` any other session's, and `request_automatic_*` every app's fixed polls: the- phone's own reads of history, history pages and the Store and model lists are counted there, with the- Desktop's, not as `request_phone_*`. The families with no source in their name (`<action>_ok`,+ agents', `request_unknown_*` any other session's, and `request_automatic_*` every app's fixed polls (reads+ of history, history pages and the Store and model lists), the Desktop's and the phone's together. The+ phone's are counted again, apart, as `request_phone_automatic_<action>_<result>`, so the Desktop's and the+ browser's are `request_automatic_*` less those; a CLI before that counts only the total. The families with+ no source in their name (`<action>_ok`,`<action>_failed`, `delete_error_code_*`, `restart_error_code_*`, `create_error_code_*`, `turns_*`,`launch_*`) are every client's together, the phone's included: never add the phone's names to them.- The other apps have their own prefixes: the Desktop `ui_desktop_*`, `setup_desktop_*` and