状态(2026-07-15):已实施,本文保留为历史实施计划。当前事件字段和归因口径以
docs/monitoring/performance-telemetry-catalog.md、docs/monitoring/business-monitoring.md与packages/ui/src/lib/uiPerfArmsTelemetry.ts为准。For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Strengthen UI-side Agent/RUM telemetry so 3.1.5 performance issues can be attributed to turn completion, stream stalls, and model network status without adding high-frequency runtime overhead.
Architecture: Reuse the existing uiPerfArmsTelemetry.ts and planUsageArmsTelemetry.ts wrappers. Add one low-frequency turn breakdown event emitted once per prompt completion, enrich stream stall with chunk type, and mirror existing model network statuses into plan_request with sanitized properties.
Tech Stack: TypeScript, Vitest, existing IPlatformService.reportArmsCustomEvent, ARMS custom event payloads.
Files:
docs/superpowers/specs/2026-06-16-ui-perf-arms-telemetry-design.mdCreate: docs/superpowers/plans/2026-06-25-ui-perf-telemetry-attribution.md
[x] Step 1: Update the existing spec
Document the attribution gap, low-overhead rules, new event names, and runtime-only future fields.
Save this file under docs/superpowers/plans/.
Files:
Modify: packages/ui/test/uiPerfArmsTelemetry.test.ts
[x] Step 1: Add tests before production code
Add tests for:
reportUiTurnBreakdown({
durationMs: 9000,
result: "success",
model: "glm-4",
talkId: "task-1",
messageId: "message-1",
ttftMs: 1200,
waitingMs: 300,
toolCallTotal: 2,
toolCallFailed: 1,
agentStepCount: 4,
retryCount: 1,
fileChangeCount: 3,
generatedCodeLines: 20,
});
Expected payload: name=perf_ui_turn_breakdown, group=ui_perf, value=9000, with numeric properties rounded and string ids preserved.
Add a stream stall test with chunkType: "thought" and expect properties.chunk_type = "thought".
Run:
pnpm vitest run packages/ui/test/uiPerfArmsTelemetry.test.ts
Expected: fail because reportUiTurnBreakdown and chunkType support do not exist yet.
Files:
packages/ui/src/lib/uiPerfArmsTelemetry.tspackages/ui/src/hooks/taskStreamEventHandlers.tsModify: packages/ui/src/hooks/useZCodeChat.ts
[x] Step 1: Add UI_PERF_EVENT_TURN_BREAKDOWN and reportUiTurnBreakdown
Implementation must:
emit() helper.Keep absent optional values undefined.
[x] Step 2: Add chunkType to stream stall
Extend recordStreamChunkArrival() options with chunkType?: "message" | "thought" | "unknown" and add chunk_type to properties.
Pass chunkType: "message" for agent_message_chunk and chunkType: "thought" for agent_thought_chunk.
Parse existing completionTelemetry.eventExtraDetail values in useZCodeChat.ts and call reportUiTurnBreakdown() once alongside reportUiMessageComplete().
Files:
packages/ui/test/planUsageArmsTelemetry.test.ts or create if missing.Modify: packages/ui/src/lib/planUsageArmsTelemetry.ts
[x] Step 1: Add tests before production code
Test that model_request_completed, model_request_failed, model_retry_scheduled, and model_stream_stalled are mirrored to plan_request with sanitized duration/status/retry fields.
Run:
pnpm vitest run packages/ui/test/planUsageArmsTelemetry.test.ts
Expected: fail because only model_request_started is currently mirrored.
Files:
Modify: packages/ui/src/lib/planUsageArmsTelemetry.ts
[x] Step 1: Rename the helper internally or extend it in place
Keep the existing exported reportPlanUsageModelRequestStartedToArms() name for call-site compatibility, but allow all task_network_debug_status model status types through.
Include duration_ms, status_code, delay_ms, idle_ms, timeout_ms, retryable, reason, transport, provider_kind, next_attempt when present. Do not include headers or raw messages.
Files:
All modified files.
[x] Step 1: Run targeted tests
pnpm vitest run packages/ui/test/uiPerfArmsTelemetry.test.ts packages/ui/test/planUsageArmsTelemetry.test.ts
[x] Step 2: Run required checks
pnpm typecheck
pnpm lint
[x] Step 3: Commit
git add docs/superpowers/specs/2026-06-16-ui-perf-arms-telemetry-design.md docs/superpowers/plans/2026-06-25-ui-perf-telemetry-attribution.md packages/ui/src/lib/uiPerfArmsTelemetry.ts packages/ui/src/lib/planUsageArmsTelemetry.ts packages/ui/src/hooks/taskStreamEventHandlers.ts packages/ui/src/hooks/useZCodeChat.ts packages/ui/test/uiPerfArmsTelemetry.test.ts packages/ui/test/planUsageArmsTelemetry.test.ts
git commit -m "feat: enrich ui perf telemetry attribution"