Add semantic status updates for Codex and OpenCode#1340
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds semantic status tracking for Codex and OpenCode providers by wiring them into the shared Key changes:
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| src/renderer/lib/agentStatusStore.ts | Removes the pendingSubmitPtyIds set and the handlePtyData method entirely; markUserInputSubmitted now immediately sets status to working rather than waiting for PTY-output confirmation. Clean simplification with no issues. |
| src/renderer/lib/providerStatusAdapters.ts | Extends provider allow-lists to include codex and opencode in both mapAgentEventToStatus and mapUserInputToStatus. Straightforward, correct change. |
| src/renderer/terminal/TerminalSessionManager.ts | Introduces consumeSubmittedInput to track typed characters and determine whether an Enter-press carries real content, replacing the prior PTY-output-based confirmation. Contains a logic bug at line 612 where whitespace-only submittedText suppresses a valid pendingText-based markUserInputSubmitted call. Additionally, history-recall via arrow keys is not reflected in currentSubmittedInput (a known design limitation of input-side tracking). |
| src/renderer/hooks/useInitialPromptInjection.ts | Adds agentStatusStore.markUserInputSubmitted call immediately before the PTY input write; status is optimistically set to working before confirmation. The ordering is safe because a failed ptyInput call leaves sent=false, allowing retry, and PTY exit will eventually reset status to idle. |
| src/renderer/hooks/usePendingInjection.ts | Adds a text.trim() guard around markUserInputSubmitted so that submitting empty/whitespace text does not incorrectly transition the agent to working. Correct defensive fix. |
| src/test/renderer/agentStatusStore.test.ts | Updates and extends test coverage for the new immediate working-on-submit behavior for Claude, Codex, and OpenCode; adds notification-mapping tests for all three providers. Removed tests that relied on the now-deleted PTY-data confirmation path. Good coverage. |
Sequence Diagram
sequenceDiagram
participant User
participant TerminalSessionManager
participant usePendingInjection
participant useInitialPromptInjection
participant agentStatusStore
participant AgentEventService
Note over User,AgentEventService: Path A — Direct keyboard input (new consumeSubmittedInput logic)
User->>TerminalSessionManager: keypress (chars + Enter)
TerminalSessionManager->>TerminalSessionManager: consumeSubmittedInput() → submittedText
alt submittedText is non-empty
TerminalSessionManager->>agentStatusStore: markUserInputSubmitted({ ptyId })
agentStatusStore-->>agentStatusStore: status → working
end
TerminalSessionManager->>ElectronAPI: ptyInput(data)
Note over User,AgentEventService: Path B — Pending injection (usePendingInjection.sendNow)
User->>usePendingInjection: sendNow(ptyId, text)
alt text.trim() non-empty
usePendingInjection->>agentStatusStore: markUserInputSubmitted({ ptyId })
agentStatusStore-->>agentStatusStore: status → working
end
usePendingInjection->>ElectronAPI: ptyInput(text + "\r")
Note over User,AgentEventService: Path C — Initial prompt injection
useInitialPromptInjection->>agentStatusStore: markUserInputSubmitted({ ptyId })
agentStatusStore-->>agentStatusStore: status → working
useInitialPromptInjection->>ElectronAPI: ptyInput(prompt + "\n")
Note over User,AgentEventService: Semantic event updates (Codex / OpenCode / Claude)
AgentEventService->>agentStatusStore: handleAgentEvent({ type: "notification", notificationType: "idle_prompt" | "permission_prompt" })
agentStatusStore-->>agentStatusStore: status → waiting (+ unread flag)
AgentEventService->>agentStatusStore: handleAgentEvent({ type: "stop" })
agentStatusStore-->>agentStatusStore: status → complete (+ unread flag)
AgentEventService->>agentStatusStore: handleAgentEvent({ type: "error" })
agentStatusStore-->>agentStatusStore: status → error (+ unread flag)
Last reviewed commit: 673118a
| if ((submittedText || pendingText).trim()) { | ||
| agentStatusStore.markUserInputSubmitted({ ptyId: this.id }); | ||
| } |
There was a problem hiding this comment.
Incorrect short-circuit || may suppress markUserInputSubmitted call
(submittedText || pendingText).trim() uses JavaScript's short-circuit ||, which returns submittedText when it is truthy — even if it is whitespace-only (e.g. " "). In that case .trim() yields "" (falsy) and markUserInputSubmitted is never called, even though pendingText is guaranteed truthy and non-empty at this point in the code (the outer if (pendingText && ...) already confirmed it).
Concrete scenario: user presses the spacebar once before an Enter key, triggering the pending-injection path. submittedText would be " " (truthy but whitespace), so " ".trim() is "", the condition is false, and the agent status stays at unknown / its prior state instead of flipping to working.
| if ((submittedText || pendingText).trim()) { | |
| agentStatusStore.markUserInputSubmitted({ ptyId: this.id }); | |
| } | |
| if (submittedText?.trim() || pendingText.trim()) { |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Summary
Testing
Note
Medium Risk
Changes how agent status transitions to
workingby driving it from captured submitted input (and extends event mapping) for multiple providers, which can affect sidebar/unread indicators and perceived agent activity. Risk is limited to renderer status/terminal input handling with added unit coverage.Overview
Adds semantic agent status support for Codex and OpenCode, extending provider adapters so their agent events can drive
waiting/complete/errorand user submits can setworking.Refactors
AgentStatusStoreto markworkingimmediately on submit (removing PTY-output-based confirmation), and updates terminal/injection paths to only callmarkUserInputSubmittedwhen a real non-empty submit is detected via newsubmitCapturetracking. Extracts ANSI stripping into sharedstripAnsiand adds unit tests for the new status mappings and submit-capture logic.Written by Cursor Bugbot for commit d673462. This will update automatically on new commits. Configure here.