fix: track agent turns from real user messages#2109
Conversation
jschwxrz
commented
May 19, 2026
- capture turns instead of pty spawns and exits
Greptile SummaryThis PR shifts
Confidence Score: 5/5Safe to merge — the change is a straightforward relocation of a telemetry call from PTY lifecycle hooks in the main process to user-turn input callbacks in the renderer, with no impact on conversation functionality. All four changed files make clean, targeted deletions from the main-process providers and a focused addition in the renderer. The new captureTelemetry call is gated by isRealTaskInput in use-pty.ts before onEnterPress is ever invoked, the extra envelope fields are valid under TelemetryEnvelope, and the widened onEnterPress condition matches the intent of tracking turns rather than sessions. No application logic paths are affected. No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/features/tasks/conversations/conversations-panel.tsx | Moves telemetry capture into onEnterPress (now active for all conversations including SSH); logic is correct and already gated by isRealTaskInput in use-pty.ts. |
| src/main/core/conversations/impl/local-conversation.ts | Removes PTY-spawn and PTY-exit telemetry calls; telemetryService import cleanly removed. |
| src/main/core/conversations/impl/ssh-conversation.ts | Same removal as local-conversation.ts; SSH turns are now tracked in the renderer via onEnterPress instead. |
| src/shared/telemetry.ts | Removes agent_run_finished event type; agent_run_started retained with its existing shape (provider only), while project_id/task_id/conversation_id are valid via TelemetryEnvelope at the call site. |
Sequence Diagram
sequenceDiagram
participant User
participant PtyPane
participant usePty
participant ConversationsPanel
participant TelemetryClient
Note over usePty,ConversationsPanel: Before (PTY-spawn tracking — removed)
Note over usePty: LocalConversationProvider spawns PTY<br/>→ telemetryService.capture('agent_run_started')
Note over usePty: PTY exits<br/>→ telemetryService.capture('agent_run_finished')
Note over User,TelemetryClient: After (turn tracking — this PR)
User->>PtyPane: Keystroke + Enter
PtyPane->>usePty: sendInput(data)
usePty->>usePty: SubmittedInputBuffer.feed(data)
usePty->>usePty: isRealTaskInput(message)?
alt message passes isRealTaskInput
usePty->>ConversationsPanel: onEnterPress(message)
ConversationsPanel->>TelemetryClient: "captureTelemetry('agent_run_started', {provider, project_id, ...})"
opt shouldSetWorkingOnEnter (local only)
ConversationsPanel->>ConversationsPanel: activeConversation.setWorking()
end
else shell command / short input
usePty-->>usePty: no-op (telemetry not fired)
end
Reviews (2): Last reviewed commit: "fix: track agent runs from real user mes..." | Re-trigger Greptile