Skip to content

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.

Measure what people do, not what the apps poll (#1313)

0xken1577ac7c64e705
diff --git a/backend/src/analytics/dailyProductReview.test.ts b/backend/src/analytics/dailyProductReview.test.ts
index 7ca6b14a3..ea79270dc 100644
--- a/backend/src/analytics/dailyProductReview.test.ts
+++ b/backend/src/analytics/dailyProductReview.test.ts
@@ -71,3 +71,14 @@ it('does not turn old collector work into zero D28 retention during rollout', ()
expect(cohort([...rows, row('2026-09-14', 'measurement_v2_installation_days', 10)]))
.toMatchObject({ measurementAvailable: true, returned: 0, percent: 0 })
})
+
+it('reports a read the apps make on their own as reliability only, even from clients that still send its reach', () => {
+ const r = dailyProductReview([
+ row('2026-10-12', 'history_requests', 41179), row('2026-10-12', 'history_installation_days', 72),
+ row('2026-10-12', 'history_first_installations', 72), row('2026-10-12', 'search_requests', 86),
+ row('2026-10-12', 'search_installation_days', 19),
+ ], new Date('2026-10-13'))
+ expect(r.features.find(f => f.action === 'history')).toMatchObject({ requests: 41179, automatic: true,
+ installationDays: null, firstMeasuredInstallations: null, repeatInstallationDays: null })
+ expect(r.features.find(f => f.action === 'search')).toMatchObject({ automatic: false, installationDays: 19 })
+})
diff --git a/backend/src/analytics/dailyProductReview.ts b/backend/src/analytics/dailyProductReview.ts
index ee37f5145..155a7d914 100644
--- a/backend/src/analytics/dailyProductReview.ts
+++ b/backend/src/analytics/dailyProductReview.ts
@@ -1,4 +1,4 @@
-import { PRODUCT_FEEDBACK, PRODUCT_FEEDBACK_REASONS, PRODUCT_FEEDBACK_OUTCOMES, PRODUCT_USAGE_ACTIONS, PRODUCT_USAGE_FLOWS, PRODUCT_USAGE_SURFACES } from '../types/productUsage.js'
+import { PRODUCT_FEEDBACK, PRODUCT_FEEDBACK_REASONS, PRODUCT_FEEDBACK_OUTCOMES, PRODUCT_USAGE_ACTIONS, PRODUCT_USAGE_AUTOMATIC_ACTIONS, PRODUCT_USAGE_FLOWS, PRODUCT_USAGE_SURFACES } from '../types/productUsage.js'
import { DAILY_PRODUCT_METRICS } from './dailyProductUsage.js'
type Row = { dayUtc: Date; metric: string; value: number }
@@ -124,12 +124,19 @@ export function dailyProductReview(rows: Row[], now: Date) {
launchAttempts: c.launch_started ?? null, observedLaunchesCreated: c.launch_created ?? null,
interpretation: 'Post-sign-in first-use signals; these stage counts are not one signup cohort or a signup conversion rate. Already installed clients enter measurement when updated.' },
feedback: Object.fromEntries(PRODUCT_FEEDBACK.map(answer => [answer, c[`feedback_${answer}`] ?? 0])),
- features: PRODUCT_USAGE_ACTIONS.map(action => ({ action, requests: c[`${action}_requests`] ?? 0,
- installationDays: c[`${action}_installation_days`] ?? null,
- firstMeasuredInstallations: c[`${action}_first_installations`] ?? null,
- repeatInstallationDays: c[`${action}_repeat_installation_days`] ?? null,
- interpretation: 'An operation was requested, possibly automatically. Reach is installation-days, not unique people, UI clicks or successful feature use.',
- })),
+ features: PRODUCT_USAGE_ACTIONS.map(action => {
+ // The apps make these reads on their own; clients before the split still send their reach.
+ const automatic = PRODUCT_USAGE_AUTOMATIC_ACTIONS.includes(action)
+ const reach = (measure: string) => automatic ? null : c[`${action}_${measure}`] ?? null
+ return { action, automatic, requests: c[`${action}_requests`] ?? 0,
+ installationDays: reach('installation_days'),
+ firstMeasuredInstallations: reach('first_installations'),
+ repeatInstallationDays: reach('repeat_installation_days'),
+ interpretation: automatic
+ ? 'Requested by the apps on their own (after updates, on connect, for previews): reliability and latency only, not feature use.'
+ : 'An operation was requested, possibly automatically. Reach is installation-days, not unique people, UI clicks or successful feature use.',
+ }
+ }),
measurementHealth: { updatedInstallationDays: c.measurement_v2_installation_days ?? null,
queuePruning: c.measurement_queue_pruned ?? 0, turnObservationOverflow: c.turn_observation_overflow ?? 0,
interpretation: 'Loss signals establish incomplete coverage; no loss signal does not prove complete collection.',
diff --git a/backend/src/types/productUsage.ts b/backend/src/types/productUsage.ts
index b520dd9da..0fb3daa26 100644
--- a/backend/src/types/productUsage.ts
+++ b/backend/src/types/productUsage.ts
@@ -8,6 +8,9 @@ export const PRODUCT_FEEDBACK = [...PRODUCT_FEEDBACK_REASONS, ...PRODUCT_FEEDBAC
export const PRODUCT_USAGE_ACTIONS = ['create', 'resume', 'restart', 'model_change', 'history',
'fork', 'close', 'delete', 'search', 'history_page', 'store_list', 'store_install', 'store_update', 'store_remove',
'model_list', 'model_download', 'model_start', 'model_stop', 'browser_open'] as const
+/** Reads the apps make on their own (an agent's recent turns after each update, the Store and model
+ * lists on connect, picker previews): measured for reliability, never as a feature someone used. */
+export const PRODUCT_USAGE_AUTOMATIC_ACTIONS: readonly typeof PRODUCT_USAGE_ACTIONS[number][] = ['history', 'history_page', 'store_list', 'model_list']
export const PRODUCT_USAGE_FEATURE_MEASURES = ['installation_days', 'first_installations', 'repeat_installation_days'] as const
export const PRODUCT_USAGE_SURFACES = ['desktop', 'phone', 'web'] as const
export const PRODUCT_USAGE_FLOWS = ['setup', 'setup_harness', 'setup_tmux', 'setup_clipboard', 'sign_in',
diff --git a/cli/src/backendSocket.spec.ts b/cli/src/backendSocket.spec.ts
index 40797c45c..5ead8e01d 100644
--- a/cli/src/backendSocket.spec.ts
+++ b/cli/src/backendSocket.spec.ts
@@ -2439,18 +2439,19 @@ describe('BackendSocket outbound queue', () => {
vi.advanceTimersByTime(15_000)
expect(kinds(ws)).toEqual(['open', 'ping'])
- // A second window is a session in its own right — up at once, floor or not.
+ // A second connection while one is attached is the same app session: the desktop holds one per
+ // machine and redials on every reconnect, so it opens nothing new.
expect(socket.registerLocalClient('local:2', sink)).toBe(true)
- expect(kinds(ws)).toEqual(['open', 'ping', 'open'])
+ expect(kinds(ws)).toEqual(['open', 'ping'])
// Registering the same window twice is refused, and says nothing.
expect(socket.registerLocalClient('local:2', sink)).toBe(false)
- expect(kinds(ws)).toHaveLength(3)
+ expect(kinds(ws)).toHaveLength(2)
// Every window gone: the tick falls silent.
await socket.unregisterLocalClient('local:1')
await socket.unregisterLocalClient('local:2')
vi.advanceTimersByTime(120_000)
- expect(kinds(ws)).toHaveLength(3)
+ expect(kinds(ws)).toHaveLength(2)
// A window that came and went while the link was down was never a session the backend can hear
// about — the next link is told nothing. Both remaining windows gone first, so the count is clean.
@@ -4112,3 +4113,28 @@ describe('relay down-frames are default-deny: sealed, or the backend\'s own', ()
expect(onMessage).toHaveBeenLastCalledWith('a1', 'task in A')
})
})
+
+describe('opening the app', () => {
+ // The desktop app holds one local connection per machine it shows, and dials again on every
+ // reconnect and every five-second link retry: counted per connection, prod's first day read 5,675
+ // desktop opens across 68 active installations.
+ it('counts a surface opening once, however many connections its windows hold', async () => {
+ const socket = new BackendSocket('fixture')
+ const opened: string[] = []
+ socket.useGateway({ holdRequests: () => {}, serveThisComputerOnly: () => {}, localClients: () => {},
+ windowOpened: (surface: string) => { opened.push(surface) } } as never)
+ const sink = { sendFrame: () => true, sendBinary: () => true }
+ for (const id of ['local:a', 'local:b', 'local:c']) socket.registerLocalClient(id, sink)
+ socket.registerLocalClient('local:tui', sink, { surface: 'tui' })
+ socket.registerLocalClient('local:tool', sink, { tool: true })
+ expect(opened).toEqual(['desktop', 'tui'])
+
+ await socket.unregisterLocalClient('local:b')
+ socket.registerLocalClient('local:b2', sink)
+ expect(opened).toEqual(['desktop', 'tui'])
+
+ for (const id of ['local:a', 'local:b2', 'local:c']) await socket.unregisterLocalClient(id)
+ socket.registerLocalClient('local:again', sink)
+ expect(opened).toEqual(['desktop', 'tui', 'desktop'])
+ })
+})
diff --git a/cli/src/backendSocket.ts b/cli/src/backendSocket.ts
index 4c1b64e90..6d3083000 100644
--- a/cli/src/backendSocket.ts
+++ b/cli/src/backendSocket.ts
@@ -617,13 +617,18 @@ export class BackendSocket {
/** Attach one authenticated loopback desktop client to the same RPC and event plane as cloud web. */
registerLocalClient(connId: string, sink: LocalClientSink, opts: { tool?: boolean; surface?: WindowSurface } = {}): boolean {
if (!isLocalClientId(connId) || this.localClients.has(connId)) return false
+ const surface = opts.surface ?? 'desktop'
+ // The app holds a connection per machine and dials again on every reconnect and link retry:
+ // an open is its surface going from no window to one, not each connection (5,675 "desktop opens"
+ // across 68 active installations on the first measured day).
+ const firstOfSurface = !opts.tool && this.localWindows()[surface] === 0
this.localClients.set(connId, sink)
if (opts.tool) this.toolClients.add(connId)
else if (opts.surface === 'tui') this.tuiClients.add(connId)
this.gatewayPort?.localClients(this.localWindows())
if (opts.tool) return true
// The window is the person's session: the backend counts it, now or when the link next comes up.
- this.gatewayPort?.windowOpened(opts.surface ?? 'desktop')
+ if (firstOfSurface) this.gatewayPort?.windowOpened(surface)
this.onLocalClient?.(connId, true)
return true
}
diff --git a/cli/src/gateway/productUsage.spec.ts b/cli/src/gateway/productUsage.spec.ts
index 610704b47..84c2d8e90 100644
--- a/cli/src/gateway/productUsage.spec.ts
+++ b/cli/src/gateway/productUsage.spec.ts
@@ -181,6 +181,21 @@ it('accepts only known scalar counters and stops diagnostics with the privacy ch
expect(totals()).toEqual({ create_requests: 1, create_installation_days: 1, create_first_installations: 1, measurement_v2_installation_days: 1 })
})
+it('counts a read the apps make on their own for reliability only, never as a feature someone used', async () => {
+ // agent_recent after every agent update, dsh_list on every connect, the pickers' model lists and
+ // session previews: prod's first day read 41,179 "history" requests across 72 "history"
+ // installation-days, almost every active one, without anyone opening a history.
+ await usage.sync()
+ for (const metric of ['history_requests', 'history_ok', 'history_under_1s', 'history_page_requests',
+ 'store_list_requests', 'model_list_requests', 'model_list_failed'] as const) usage.counter(metric)
+ usage.counter('search_requests')
+ await usage.sync()
+ expect(totals()).toEqual({ measurement_v2_installation_days: 1,
+ history_requests: 1, history_ok: 1, history_under_1s: 1, history_page_requests: 1,
+ store_list_requests: 1, model_list_requests: 1, model_list_failed: 1,
+ search_requests: 1, search_installation_days: 1, search_first_installations: 1 })
+})
+
it('tracks a durable launch through polls without persisting its receipt or counting polls as attempts', async () => {
await usage.sync()
const id = 'PRIVATE_CREATION_CANARY'
diff --git a/cli/src/gateway/productUsage.ts b/cli/src/gateway/productUsage.ts
index ccb61adf6..b2388c0e5 100644
--- a/cli/src/gateway/productUsage.ts
+++ b/cli/src/gateway/productUsage.ts
@@ -3,7 +3,7 @@ import { mkdir, rename, writeFile } from 'node:fs/promises'
import { dirname } from 'node:path'
import { randomUUID } from 'node:crypto'
import type { ProductUsageLaunchSignal } from '../lib/productUsageSignals.js'
-import { PRODUCT_USAGE_ACTIONS, PRODUCT_USAGE_DAYS, PRODUCT_USAGE_MAX_COUNT, PRODUCT_USAGE_METRICS,
+import { PRODUCT_USAGE_ACTIONS, PRODUCT_USAGE_AUTOMATIC_ACTIONS, PRODUCT_USAGE_DAYS, PRODUCT_USAGE_MAX_COUNT, PRODUCT_USAGE_METRICS,
type ProductUsageChoice, type ProductUsageMetric, type ProductUsageReport } from '../lib/productUsageContract.js'
const DAY = 86_400_000
@@ -11,7 +11,9 @@ const MAX_QUEUE_BYTES = 256 * 1024
// A report stays below the server's 8 KiB body bound even with the complete vocabulary.
const MAX_REPORT_METRICS = 64
const metricSet = new Set<string>(PRODUCT_USAGE_METRICS)
-const requestActions = new Map(PRODUCT_USAGE_ACTIONS.map(action => [`${action}_requests`, action]))
+// Feature reach is a person's use; the reads the apps make on their own count only their reliability.
+const requestActions = new Map(PRODUCT_USAGE_ACTIONS.filter(action => !PRODUCT_USAGE_AUTOMATIC_ACTIONS.includes(action))
+ .map(action => [`${action}_requests`, action]))
const key = (now: number) => new Date(now).toISOString().slice(0, 10)
const week = (now: number) => { const d = new Date(now); return key(now - ((d.getUTCDay() + 6) % 7) * DAY) }
type Counters = Partial<Record<ProductUsageMetric, number>>
diff --git a/cli/src/lib/productUsageContract.ts b/cli/src/lib/productUsageContract.ts
index b520dd9da..0fb3daa26 100644
--- a/cli/src/lib/productUsageContract.ts
+++ b/cli/src/lib/productUsageContract.ts
@@ -8,6 +8,9 @@ export const PRODUCT_FEEDBACK = [...PRODUCT_FEEDBACK_REASONS, ...PRODUCT_FEEDBAC
export const PRODUCT_USAGE_ACTIONS = ['create', 'resume', 'restart', 'model_change', 'history',
'fork', 'close', 'delete', 'search', 'history_page', 'store_list', 'store_install', 'store_update', 'store_remove',
'model_list', 'model_download', 'model_start', 'model_stop', 'browser_open'] as const
+/** Reads the apps make on their own (an agent's recent turns after each update, the Store and model
+ * lists on connect, picker previews): measured for reliability, never as a feature someone used. */
+export const PRODUCT_USAGE_AUTOMATIC_ACTIONS: readonly typeof PRODUCT_USAGE_ACTIONS[number][] = ['history', 'history_page', 'store_list', 'model_list']
export const PRODUCT_USAGE_FEATURE_MEASURES = ['installation_days', 'first_installations', 'repeat_installation_days'] as const
export const PRODUCT_USAGE_SURFACES = ['desktop', 'phone', 'web'] as const
export const PRODUCT_USAGE_FLOWS = ['setup', 'setup_harness', 'setup_tmux', 'setup_clipboard', 'sign_in',
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index b5d4d7156..7a7c7cf38 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -6813,62 +6813,79 @@ class AppNotifier extends ChangeNotifier {
onAuthFailure: _signedOutAtRuntime,
onLocalFailure: _onLocalFailure,
onEvent: _handleEvent,
- onStatus: (machineId, nextStatus) {
- final machine = machineStates[machineId];
- if (machine == null) return;
- // A refusal being settled against the device log ([_settleTrust]) is still connecting.
- final settling =
- nextStatus == ConnectionStatus.disconnected &&
- _trustSettling.contains(machineId);
- _measureConnection(
- machineId,
- settling ? ConnectionStatus.connecting : nextStatus,
- machine.isLocalMachine
- ? ProductFlow.workspaceConnect
- : ProductFlow.remoteConnect,
- );
- machine.connectionStatus = settling
- ? ConnectionStatus.connecting
- : nextStatus;
- if (nextStatus == ConnectionStatus.connected) {
- _onMachineConnected(machineId, machine);
- _refreshDeviceLogAfterReconnect();
- } else if (nextStatus == ConnectionStatus.reconnecting ||
- nextStatus == ConnectionStatus.disconnected) {
- _stopAgentSyncTimer(machineId);
- _clearMachineActivity(machine);
- if (machine.isLocalMachine) {
- machine.transportMode = MachineTransportMode.localOffline;
- dial.disconnect();
- }
- // Same reasoning as above, mirrored: capture pendingOfflineAgentId from the currently-open
- // terminal (if any) so the connected branch above can reattach it, for every machine — this
- // used to be local-only, which is why a remote machine's terminal never came back on its own
- // after `harness start` on that machine, even though the guide screen promised it would.
- //
- // NOT while the machine is unlinked. NO_PEER_LINK is the local CLI failing a lookup in its
- // own peer table (remoteRelay.ts `dial`) before anything is dialled, so neither that close
- // nor the one `_startLinkRetry`'s `closeMachine` fires every few seconds says anything about
- // whether the OTHER computer is up — our socket never reaches it. Forcing nodeOnline false
- // here overwrote the REST `/api/machines` status, the one signal that does, and painted
- // every unlinked machine as off. Keyed on the sticky flag rather than the 4404 close on
- // purpose: the retry loop's own close() lands as a plain `disconnected` too. needsLink is
- // set by onLocalFailure, which runs before this branch for 4404 (see WsConn._onDone).
- if (!machine.needsLink && !settling) {
- unawaited(
- _applyNodeStatus(
- machine,
- false,
- why: 'socket ${nextStatus.name}',
- ),
- );
- }
- }
- notifyListeners();
- },
+ onStatus: _onConnectionStatus,
);
}
+ void _onConnectionStatus(String machineId, ConnectionStatus nextStatus) {
+ final machine = machineStates[machineId];
+ if (machine == null) return;
+ // A refusal being settled against the device log ([_settleTrust]) is still connecting.
+ final settling =
+ nextStatus == ConnectionStatus.disconnected &&
+ _trustSettling.contains(machineId);
+ // An unlinked machine is redialled every 5 s by the link retry and refused at once each time
+ // (4404 NO_PEER_LINK): measured per dial, one such machine read as ~720 failed connects an hour,
+ // and prod's first day showed 1,197 of 1,233 remote connects "failed", nearly all under a second.
+ // The dial that found it unlinked is already open and still ends as one failure; the retry's
+ // dials are not new attempts. A dial after linking (needsLink cleared first) is measured again.
+ final retryingLink =
+ machine.needsLink &&
+ (nextStatus == ConnectionStatus.connecting ||
+ nextStatus == ConnectionStatus.reconnecting);
+ if (!retryingLink) {
+ _measureConnection(
+ machineId,
+ settling ? ConnectionStatus.connecting : nextStatus,
+ machine.isLocalMachine
+ ? ProductFlow.workspaceConnect
+ : ProductFlow.remoteConnect,
+ );
+ }
+ machine.connectionStatus = settling
+ ? ConnectionStatus.connecting
+ : nextStatus;
+ if (nextStatus == ConnectionStatus.connected) {
+ _onMachineConnected(machineId, machine);
+ _refreshDeviceLogAfterReconnect();
+ } else if (nextStatus == ConnectionStatus.reconnecting ||
+ nextStatus == ConnectionStatus.disconnected) {
+ _stopAgentSyncTimer(machineId);
+ _clearMachineActivity(machine);
+ if (machine.isLocalMachine) {
+ machine.transportMode = MachineTransportMode.localOffline;
+ dial.disconnect();
+ }
+ // Same reasoning as above, mirrored: capture pendingOfflineAgentId from the currently-open
+ // terminal (if any) so the connected branch above can reattach it, for every machine — this
+ // used to be local-only, which is why a remote machine's terminal never came back on its own
+ // after `harness start` on that machine, even though the guide screen promised it would.
+ //
+ // NOT while the machine is unlinked. NO_PEER_LINK is the local CLI failing a lookup in its
+ // own peer table (remoteRelay.ts `dial`) before anything is dialled, so neither that close
+ // nor the one `_startLinkRetry`'s `closeMachine` fires every few seconds says anything about
+ // whether the OTHER computer is up — our socket never reaches it. Forcing nodeOnline false
+ // here overwrote the REST `/api/machines` status, the one signal that does, and painted
+ // every unlinked machine as off. Keyed on the sticky flag rather than the 4404 close on
+ // purpose: the retry loop's own close() lands as a plain `disconnected` too. needsLink is
+ // set by onLocalFailure, which runs before this branch for 4404 (see WsConn._onDone).
+ if (!machine.needsLink && !settling) {
+ unawaited(
+ _applyNodeStatus(
+ machine,
+ false,
+ why: 'socket ${nextStatus.name}',
+ ),
+ );
+ }
+ }
+ notifyListeners();
+ }
+
+ @visibleForTesting
+ void connectionStatusForTest(String machineId, ConnectionStatus status) =>
+ _onConnectionStatus(machineId, status);
+
/// The machine list is being fetched and there is nothing to show meanwhile.
///
/// Only the FIRST fetch sets it: a refresh over a list already on screen
diff --git a/desktop/test/remote_connect_measurement_test.dart b/desktop/test/remote_connect_measurement_test.dart
new file mode 100644
index 000000000..271814946
--- /dev/null
+++ b/desktop/test/remote_connect_measurement_test.dart
@@ -0,0 +1,107 @@
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/auth/auth_session.dart';
+import 'package:harness/core/config.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/measurement/product_measurement.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/ws/ws_conn.dart';
+
+/// Records each measured connection and how it ended, instead of reporting it.
+class _Recorder extends ProductMeasurement {
+ _Recorder() : super(surface: 'desktop', automatic: false, sendSetup: (_) async => {});
+
+ final ended = <String>[];
+
+ @override
+ void Function(ProductOutcome) begin(ProductFlow flow) =>
+ (outcome) => ended.add('${flow.name}:${outcome.name}');
+}
+
+/// A daemon that answers every request with nothing: connecting loads the machine's data.
+class _Daemon extends WsConn {
+ _Daemon()
+ : super(
+ wsBaseUrl: 'ws://fixture.invalid',
+ autonomousEnv: 'test',
+ machineId: 'remote',
+ accessTokenProvider: (_, _) async => '',
+ onAuthFailure: (_) {},
+ onEvent: (_) {},
+ onStatus: (_) {},
+ );
+
+ @override
+ Future<Map<String, dynamic>> request(
+ String type, {
+ Map<String, dynamic> payload = const {},
+ Duration timeout = const Duration(seconds: 20),
+ }) async => const {};
+}
+
+/// A remote machine that is not linked is redialled every five seconds by the
+/// link retry, and its daemon refuses each dial at once (4404 NO_PEER_LINK).
+/// Measured per tick, that read as ~720 failed connections an hour per unlinked
+/// machine: prod's first day showed 1,197 of 1,233 remote connects "failed",
+/// almost all under a second. One refusal is one failed connection.
+void main() {
+ late AppNotifier app;
+ late _Recorder usage;
+ const mid = 'remote';
+
+ setUp(() {
+ usage = _Recorder();
+ app = AppNotifier(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ productMeasurement: usage,
+ connectionForTest: (_) => _Daemon(),
+ );
+ const machine = Machine(
+ machineId: mid,
+ name: 'Box',
+ authMode: MachineAuthMode.remote,
+ );
+ app.machines.add(machine);
+ app.machineStates[mid] = MachineState(machine)..nodeOnline = true;
+ // Connections are measured only for a signed-in account.
+ app
+ ..status = AppStatus.authenticated
+ ..currentUser = const CurrentUserProfile(id: 'u1', email: '[email protected]');
+ });
+
+ tearDown(() => app.dispose());
+
+ test('a machine refused for want of a link counts one failure, not one per retry', () {
+ app.connectionStatusForTest(mid, ConnectionStatus.connecting);
+ // WsConn reports the refusal before the close (WsConn._onDone).
+ app.localFailureForTest(mid, 4404, 'NO_PEER_LINK');
+ app.connectionStatusForTest(mid, ConnectionStatus.disconnected);
+ expect(usage.ended, ['remoteConnect:failed']);
+
+ // Three link-retry ticks: closeMachine, then a dial refused again.
+ for (var tick = 0; tick < 3; tick++) {
+ app.connectionStatusForTest(mid, ConnectionStatus.disconnected);
+ app.connectionStatusForTest(mid, ConnectionStatus.connecting);
+ app.localFailureForTest(mid, 4404, 'NO_PEER_LINK');
+ app.connectionStatusForTest(mid, ConnectionStatus.disconnected);
+ }
+ expect(usage.ended, ['remoteConnect:failed']);
+
+ // Linked: the next dial is measured again, and succeeds.
+ app.stateOf(mid)!.needsLink = false;
+ app.connectionStatusForTest(mid, ConnectionStatus.connecting);
+ app.connectionStatusForTest(mid, ConnectionStatus.connected);
+ expect(usage.ended, ['remoteConnect:failed', 'remoteConnect:ok']);
+ });
+
+ test('an ordinary offline machine still counts each dial that ends', () {
+ app.connectionStatusForTest(mid, ConnectionStatus.connecting);
+ app.connectionStatusForTest(mid, ConnectionStatus.reconnecting);
+ app.connectionStatusForTest(mid, ConnectionStatus.reconnecting);
+ app.connectionStatusForTest(mid, ConnectionStatus.disconnected);
+ app.connectionStatusForTest(mid, ConnectionStatus.connecting);
+ app.connectionStatusForTest(mid, ConnectionStatus.connected);
+ expect(usage.ended, ['remoteConnect:failed', 'remoteConnect:ok']);
+ });
+}
diff --git a/docs/product-measurement.md b/docs/product-measurement.md
index 3530352f4..0fac55b9e 100644
--- a/docs/product-measurement.md
+++ b/docs/product-measurement.md
@@ -14,9 +14,9 @@ automatically proven improvement. Changes still need review, tests and a deliber
| Does work get a response promptly? | First text response buckets; over-one-minute waits; error events; matched ends without text; interruptions | Includes automation. Tool-only turns, interruptions and missing lifecycle events can explain missing text. No message is inspected. |
| Do installations return to work? | D1/D7/D28 working-day cohorts, consecutive complete-week and calendar-month returns, return after a seven-day gap | Any working day can be a cohort; not new-signup retention. Local date flags produce unlinked totals. Opt-outs, reinstallations, resets and missing uploads affect results. |
| Was the task useful? | Optional Completed / Partly completed / Not completed plus five fixed reason choices, reachable from Rate task outcome and Privacy | Voluntary and self-selected; not representative success or satisfaction. There is no free-text input. |
-| Is there usage at all? | Active and working computer counts; app opens; older-client relay totals | Background windows can count as active. Relay events are not distinct people; the populations must not be added together. |
+| Is there usage at all? | Active and working computer counts; app opens; older-client relay totals | Background windows can count as active. An open is a surface going from no attached window to one, not each connection (the desktop holds one per machine and redials). Relay events are not distinct people; the populations must not be added together. |
-| Which features get tried and used again? | First measured installations and daily first/repeat feature reach | Locally deduplicated installation-days, not unique accounts. Some operations are automatic. |
+| Which features get tried and used again? | First measured installations and daily first/repeat feature reach | Locally deduplicated installation-days, not unique accounts. Reads the apps make on their own (history, history paging, Store list, model list; `PRODUCT_USAGE_AUTOMATIC_ACTIONS`) count reliability only and have no reach. |
| Where do app flows break? | Setup, Harness/tmux/clipboard steps, sign-in, workspace/remote connections, computer linking, viewer-pane opening and manual update checking/staging | Fixed started/ok/failed/cancelled/unknown counts and coarse duration buckets. Opening a viewer pane is not rendering its content; staging an update is not a successful relaunch. |
| Is measurement losing coverage? | Updated collector installation-days, pruned queues, full observation maps, unmatched app starts | Loss signals warrant caution. No signal does not prove complete collection. |