Skip to content

fix: stop Codex loader when turn completes#2073

Merged
arnestrickmann merged 2 commits into
generalaction:mainfrom
mezotv:emdash/funky-loops-itch-ev7f8
May 25, 2026
Merged

fix: stop Codex loader when turn completes#2073
arnestrickmann merged 2 commits into
generalaction:mainfrom
mezotv:emdash/funky-loops-itch-ev7f8

Conversation

@mezotv

@mezotv mezotv commented May 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • clear the Codex conversation loader when Codex reports an idle prompt after working
  • keep the terminal classifier active for Codex as a fallback when hooks are skipped

@mezotv mezotv changed the title Fix Codex loader completion state fix: stop Codex loader when turn completes May 17, 2026
@greptile-apps

greptile-apps Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes Codex loader completion state by (1) forcing the terminal classifier to remain active for Codex even when hooks are available, and (2) treating an idle_prompt notification from Codex as a completion signal rather than an attention request.

  • local-conversation.ts: Adds conversation.providerId !== 'codex' to the useHooksOnly guard so the output classifier always runs alongside Codex hooks, providing a completion fallback when hooks are skipped.
  • conversation-manager.ts: Intercepts idle_prompt events from Codex while the conversation is in 'working' state and transitions to 'completed' (with task-complete sound) instead of falling through to setAwaitingInput.

Confidence Score: 3/5

The Codex-specific idle_prompt handling in conversation-manager has a fallthrough path that can incorrectly flip a just-completed conversation to awaiting-input state.

Because the companion change in local-conversation.ts ensures both hooks and the terminal classifier run simultaneously for Codex, two idle_prompt events can arrive in rapid succession. The first correctly marks the conversation as completed; the second misses the status guard and falls through to setAwaitingInput, potentially leaving the UI in a false needs-attention state.

conversation-manager.ts — specifically the new Codex idle_prompt guard and its fallthrough into setAwaitingInput.

Important Files Changed

Filename Overview
src/renderer/features/tasks/conversations/conversation-manager.ts Adds Codex-specific handling for idle_prompt to mark conversations as completed; the status === 'working' guard creates a fallthrough path where a duplicate event (from both hook and classifier being active) can incorrectly set the conversation to awaiting-input.
src/main/core/conversations/impl/local-conversation.ts Excludes Codex from useHooksOnly so the terminal classifier always runs alongside hooks; logic is straightforward and well-commented.

Sequence Diagram

sequenceDiagram
    participant Codex as Codex CLI
    participant Hook as Agent Hook
    participant Classifier as Terminal Classifier
    participant CM as ConversationManager
    participant Store as ConversationStore

    Note over Hook,Classifier: Both active for Codex (new behaviour)

    Codex->>Hook: idle signal (sometimes skipped)
    Codex->>Classifier: terminal output (idle pattern)

    alt Hook fires first
        Hook->>CM: "agentEvent { type: notification, nt: idle_prompt }"
        CM->>Store: setStatus completed [status was working]
        Note over CM: returns early
        Classifier->>CM: "agentEvent { type: notification, nt: idle_prompt }"
        CM-->>Store: status not working, falls through to setAwaitingInput
    else Hook skipped, Classifier fires
        Classifier->>CM: "agentEvent { type: notification, nt: idle_prompt }"
        CM->>Store: setStatus completed [status was working]
        Note over CM: returns early
    end
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/renderer/features/tasks/conversations/conversation-manager.ts:109-117
When both the hook **and** the terminal classifier are active for Codex (exactly what the companion change to `local-conversation.ts` causes), the hook fires `idle_prompt` first and sets the conversation to `'completed'`. If the classifier also emits `idle_prompt` before the 10-second cooldown expires this guard doesn't fire (status is no longer `'working'`), so execution falls through to `setAwaitingInput` and plays the `needs_attention` sound — flipping a just-completed Codex task into an "awaiting input" state. Dropping the `status === 'working'` check from the early-return condition (and still returning early) prevents the fallthrough in all cases.

```suggestion
        if (event.providerId === 'codex' && nt === 'idle_prompt') {
          if (conversationStore.status === 'working') {
            conversationStore.setStatus('completed');
            soundPlayer.play('task_complete', appFocused);
          }
          return;
        }
```

Reviews (1): Last reviewed commit: "Fix Codex loader completion state" | Re-trigger Greptile

Comment thread src/renderer/features/tasks/conversations/conversation-manager.ts Outdated
@mezotv mezotv force-pushed the emdash/funky-loops-itch-ev7f8 branch from d4ad821 to e572525 Compare May 17, 2026 21:02
@mezotv mezotv force-pushed the emdash/funky-loops-itch-ev7f8 branch from e572525 to f865f1c Compare May 19, 2026 18:17
@janburzinski

Copy link
Copy Markdown
Collaborator

thanks for the update, this then lgtm! :D

@mezotv mezotv force-pushed the emdash/funky-loops-itch-ev7f8 branch from e4a8dd1 to 319f425 Compare May 21, 2026 18:40
@arnestrickmann arnestrickmann merged commit bf34af6 into generalaction:main May 25, 2026
1 check passed
@mezotv mezotv deleted the emdash/funky-loops-itch-ev7f8 branch May 25, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants