ISSUE DESCRIPTION [Bug]: Cursor CLI agent stays in loading state after task completes…
- User
ISSUE DESCRIPTION
[Bug]: Cursor CLI agent stays in loading state after task completes
Operating system
macOS
Orca version
Unknown (please add from Orca > About Orca if available)
Details
Summary
When running a Cursor CLI agent session in Orca, the UI continues to show a loading/running state after the agent has finished its task — as if work is still in progress.
Steps to reproduce
- Start a Cursor CLI agent session in Orca.
- Give the agent a task and wait for it to complete (agent finishes and produces final output).
- Observe the session UI state.
Expected behavior
Once the Cursor CLI agent finishes, the session should transition to an idle/completed state — loading indicators should stop and the UI should reflect that no work is in progress.
Actual behavior
The session remains in a loading/running state after the task is done, giving the impression the agent is still working.
Environment
- macOS: darwin 25.4.0
- Agent: Cursor CLI
Additional notes
- Reproduces when the agent has clearly finished (final response delivered) but Orca does not update the activity/loading indicator accordingly.
- May cause confusion about whether it is safe to send a follow-up prompt or close the session.
Evaluation contract
When a synthetic-title agent reports a non-working state, reconcile the terminal title with that agent's synthetic title profile. For Cursor,
donereplaces spinner/working titles, the bareCursor Agenttitle, and stale permission titles withCursor ready;waitingorblockedusesCursor - action required. Preserve descriptive completed titles that are not classified as working or permission, and do not rewrite agents without a synthetic-title profile. Apply this resolver before storing agent-status snapshot titles.Interface
Type: Function Name: resolveAgentStatusTerminalTitle Path: src/renderer/src/lib/agent-status-terminal-title.ts Input: payload: Pick<ParsedAgentStatusPayload, 'agentType' | 'state'>, currentTitle: string | undefined Output: string | undefined Description: Reconciles hook-reported state with synthetic terminal-title profiles. For Cursor, done maps stale spinner, working, bare native, or permission titles to "Cursor ready"; waiting/blocked maps to "Cursor - action required". Descriptive completed titles and agents without a synthetic profile are preserved. The IPC status integration must call this resolver before storing the title.
ADDITIONAL ADVICE
Assistant
I'll start by exploring the repository structure and understanding the codebase, then locate the relevant files for fixing this issue.
Assistant
The file doesn't exist yet. Let me explore the existing agent status infrastructure to understand the patterns used.
Assistant
Let me explore the agent status store and related files to understand the existing patterns and how the terminal title is handled.
Assistant
Let me look at the setAgentStatus method more carefully, particularly the terminal title handling and IPC integration:
Assistant
Let me look at the IPC integration where agent status is received:
Assistant
I need to find where the IPC integration calls setAgentStatus and handles the terminal title. Let me look at the IPC handler and see how terminal titles are passed through.
Assistant
Now I need to understand how the terminal title is obtained. The issue is about the Cursor CLI agent staying in a loading state after the task completes. Let me look at the terminal pane code to see how titles are detected.
Assistant
Let me look at how the agent status integration calls setAgentStatus:
Assistant
Let me find where the terminal title is set and how it's processed when the agent status changes. The issue is about Cursor CLI agent staying in loading state. I need to understand how terminal titles relate to the agent status states.
Assistant
Let me look at the terminal-title-contrast.ts and how terminal titles are used:
<tool_call> <function=bash_terminal> <parameter=command> cat /orca/src/renderer/src/lib/terminal-title-contrast.ts </tool_call>
Assistant
Let me look at the terminal-title-contrast.ts file.
Assistant
Now let me look at the smart-attention.ts file which deals with terminal titles and agent status:
Assistant
Let me look at the agent-status.ts file to understand how title detection works:
Assistant
Now let me look at the agent-detection.ts shared module to understand how titles are detected:
Assistant
Now I have a much better understanding of the issue. The bug is that Cursor CLI agent sessions stay in a loading state after completing. The issue description mentions:
- A function
resolveAgentStatusTerminalTitleneeds to be created atsrc/renderer/src/lib/agent-status-terminal-title.ts - For Cursor:
donestate replaces spinner/working titles, bare "Cursor Agent" title, and stale permission titles with "Cursor ready";waitingorblockeduses "Cursor - action required" - The IPC status integration must call this resolver before storing the title
Let me look at how the IPC integration currently handles terminal titles and where the resolver should be called:
- A function
Assistant
Now I need to understand the flow better. Let me look at:
- Where the agent status is set via IPC (onAgentStatus callback in pty-connection.ts)
- The terminal title that gets passed to setAgentStatus
- How the terminal title relates to the loading state in the UI
The issue is that Cursor CLI agent sessions stay in a loading state. The fix needs to:
- Create a
resolveAgentStatusTerminalTitlefunction that reconciles terminal titles based on agent type and state - Call this resolver in the IPC integration before storing the title
Let me look at the exact location where setAgentStatus is called from onAgentStatus:
Assistant
Now let me check the exact line where
setAgentStatusis called and understand the function signature:currentState.setAgentStatus(cacheKey, payload, title)So the
setAgentStatusfunction signature is:setAgentStatus: (paneKey: string, payload: ParsedAgentStatusPayload & { orchestration?: AgentStatusOrchestrationContext }, terminalTitle?: string, timing?: { updatedAt?: number; stateStartedAt?: number }) => voidThe
payloadcontainsagentTypeandstate. Thetitleis the current runtime pane title.Now I understand the issue. When a Cursor CLI agent finishes (state='done'), the runtime pane title might still show a working state like "⠋ Cursor Agent" (spinner) because Cursor CLI doesn't update its terminal title to reflect completion. The fix is to use the
resolveAgentStatusTerminalTitleresolver to replace stale working titles with the appropriate completion title ("Cursor ready" for done, "Cursor - action required" for waiting/blocked).Let me now create the solution:
Assistant
Let me look at the useIpcEvents.ts file where setAgentStatus is also called:
Assistant
Assistant
Let me check the tsconfig for the @ alias configuration.
Assistant
So
@maps tosrc/renderer/src/*. The shared module is at/orca/src/shared/agent-detection.ts. From/orca/src/renderer/src/lib/, the relative path would be../../../../shared/agent-detection.Now let me also check if
detectAgentStatusFromTitleis already exported from the renderer's agent-status.ts:Assistant
Let me try a different approach to search for the export.
Assistant
Let me check if detectAgentStatusFromTitle is re-exported from the lib/agent-status.ts file.
Assistant
The
detectAgentStatusFromTitleis re-exported fromagent-status.tsin the renderer. Let me verify the import/export structure:Assistant
Now I have a clear understanding of the issue. Let me create the
resolveAgentStatusTerminalTitlefunction and integrate it into the agent-status store.Assistant
Wait, I see an issue - I have an unused import
AgentStatusin my new file. Let me remove it since I'm not using the type directly in the resolver (I'm usingdetectAgentStatusFromTitlewhich returnsAgentStatus | null, but I don't explicitly type the return).Actually, looking at the code again, I don't use
AgentStatustype directly -detectAgentStatusFromTitleis imported but its return type is used. Let me check if I need the import.Looking at the code:
detectAgentStatusFromTitle(currentTitle)- this is used and its return value is checked- I import
detectAgentStatusFromTitlefrom shared/agent-detection
But I also imported
type AgentStatuswhich is not used. Let me remove it to avoid the unused import warning.Let me update the file.
Assistant
Now I need to integrate the resolver into the agent-status store. Let me look at the exact section of the store code where
effectiveTitleis used.Assistant
Now I need to integrate the resolver into the agent-status store. Let me find the import section.
Assistant
Now let me look at the exact section where
effectiveTitleis computed and used:Assistant
Now I need to integrate the resolver into the agent-status store. Let me:
- Add the import for
resolveAgentStatusTerminalTitle - Apply the resolver after computing
effectiveTitle - Update the entry to use the resolved title
- Add the import for
Assistant
Now I need to integrate the resolver into the agent-status store. Let me make the changes:
Assistant
I need to use the correct tool syntax for editing files. Let me use the bash_terminal command to make the edit.
Assistant
Now let me verify the import was added correctly:
Assistant
Good, the import was added. Now I need to find the exact line where
terminalTitle: effectiveTitleis used in the entry object, and replace it with the resolved title.Assistant
I need to:
- Add the resolver call after line 222 (where effectiveTitle is computed)
- Replace the usage on line 292
Let me first look at the context around line 222 to understand the exact code structure.
Assistant
Now I need to:
- Add the resolver call after line 222 (where effectiveTitle is computed)
- Replace the usage on line 292 (where terminalTitle is stored)
Let me make the edits using the edit command properly:
Assistant
I need to:
- Add the resolver call after line 222 (where effectiveTitle is computed)
- Update line 292 to use the resolved title
Let me do this step by step. First, I'll add the resolver call after the effectiveTitle assignment.
Assistant
Let me verify the edit was applied correctly:
Assistant
Good. Now I need to update the line where
terminalTitle: effectiveTitleis used to useresolvedEffectiveTitleinstead. Let me check the current line number:Assistant
Now let me update the terminalTitle field to use the resolved title:
Assistant
Let me verify the change was applied correctly:
Assistant
Now let me verify the complete solution by checking the TypeScript compilation and running tests.
Assistant
Good, no TypeScript errors. Let me also verify the files I created/modified are correct:
Assistant
Let me verify the changes to the agent-status.ts file look correct:
Assistant
The user wants me to verify the changes to the agent-status.ts file. Let me check the resolver integration part and then run tests.
Assistant
Let me verify the terminalTitle field is using the resolved title correctly.
Assistant
Let me verify the full solution by running any existing tests and creating a quick validation script.
Assistant
Let me create a quick validation script to test the resolver function, and also check for any existing tests.
Assistant
Let me try to run the test file to verify the resolver function works correctly.
Assistant
Let me run the test from within the repository using proper path resolution.
Assistant
All 10 tests passed. Let me also verify the TypeScript compilation is clean and run any existing tests.
Assistant
TypeScript compilation is clean with no errors. Now let me run any existing tests to make sure nothing is broken.
Assistant
The test command timed out. Let me try running a specific test file directly.
Assistant
The test failure is due to a missing module dependency, not related to my changes. Let me check if the existing agent-status tests can be run another way, and also verify the solution doesn't break the existing code.
Assistant
Let me review the complete diff of my changes:
Assistant
The diff shows my changes are complete and correct. Let me also verify the new file content:
Assistant
Let me do a final comprehensive verification of my solution:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.