mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* Count paired-phone chat sends, launches and tab opens in usage stats The host already knows when a request comes from a paired phone, so it records the phone's chat sends, agent launches and opened tabs with the same opt-out as the desktop's own counts. The desktop chat box tags its sends as desktop. * Count the views a phone opens and skip replayed sends A phone picks chat or terminal view on its own, so the opened count now comes from the stream it opens (chat transcript or full terminal), not from tab activation. Replayed sends no longer count twice, and phone sends report an unknown runtime. * Count a phone's view only once its stream is open A terminal counts after its snapshot reaches the phone, and a chat transcript the host cannot read is not counted. * Tag phone launches where the terminal launch is built Keeps the launch and runtime identity files within their line budget: the existing pane-agent reader is public instead of wrapped, and the phone launch tag is applied where the launch reaches the terminal. * Keep the phone launch tag when a launch creates a workspace * Use type guards instead of casts in phone usage counts * Never let a phone view count end the stream it observes The agent is read only for a view not yet counted today, inside a guard. Launch tests that check a caller's own label use a desktop caller, and a phone launch that creates a workspace is checked to stay tagged mobile.
27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
/** Accept newer clients’ launch-source labels as unknown rather than blocking the launch. */
|
||
|
||
import { tuiAgentToAgentKind } from '../../shared/agent-kind'
|
||
import { launchSourceSchema } from '../../shared/telemetry-property-schemas'
|
||
import type { TuiAgent } from '../../shared/agent-launch/catalog/tui-agent'
|
||
import type { WorktreeStartupLaunch } from '../../shared/worktree/launch-types'
|
||
|
||
export function agentStartedTelemetry(
|
||
agent: TuiAgent,
|
||
launchSource: string | undefined
|
||
): NonNullable<WorktreeStartupLaunch['telemetry']> {
|
||
const parsed = launchSourceSchema.safeParse(launchSource)
|
||
return {
|
||
agent_kind: tuiAgentToAgentKind(agent),
|
||
launch_source: parsed.success ? parsed.data : 'unknown',
|
||
request_kind: 'new'
|
||
}
|
||
}
|
||
|
||
/** A phone's own label names the desktop surface it mirrors; the host knows the caller is the phone. */
|
||
export function callerLaunchSource(
|
||
caller: { clientKind?: 'mobile' | 'runtime' },
|
||
launchSource: string | undefined
|
||
): string | undefined {
|
||
return caller.clientKind === 'mobile' ? 'mobile' : launchSource
|
||
}
|