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 to understand the codebase and locate relevant files. Let's first check the current directory and list files.
- Assistant
Let me explore the repository to understand the structure and find relevant files.
- Assistant
The file mentioned in the issue doesn't exist yet. I need to create it:
src/renderer/src/lib/agent-status-terminal-title.tsLet me understand the existing codebase better.
- Assistant
Let me look at the existing agent-status related files to understand the patterns and types.
- Assistant
Let me look at the agent-status-types and the agent-status IPC store to understand the payload types.
- Assistant
Let me read the rest of the file and look at the existing IPC integration that handles agent status updates.
- Assistant
Let me look at more of this file and understand the IPC payload and how terminal titles are used.
- Assistant
Now I understand the key types. Let me look at the store slice to understand how agent status is stored and how terminalTitle is used.
- Assistant
Let me look at the existing agent-status-identity and terminal-title related files to understand the patterns.
- Assistant
Let me look at the terminal title related files and the IPC status integration to understand how terminal titles are currently managed.
- Assistant
Let me search for how terminal titles are managed in the context of agent status.
- Assistant
Let me look at the existing agent detection code and understand what synthetic titles exist for different agents:
- Assistant
Let me search for synthetic title files and understand the cursor agent's title patterns.
- Assistant
Let me look at the synthetic title files to understand how they work and what patterns exist.
- Assistant
Let me look at these synthetic title files to understand the patterns.
- Assistant
Let me look at the agent-detection shared module and the IPC status integration.
- Assistant
Let me look at the IPC status integration to understand how terminal titles are stored and where the resolver should be called.
- Assistant
Let me search for cursor-specific detection patterns in the agent-detection file:
- Assistant
Let me look at more context around the cursor detection and see what the current behavior is for cursor titles.
- Assistant
Let me look at the agent-status store's setAgentStatus method to see how terminalTitle is handled:
- Assistant
Let me continue reading the setAgentStatus implementation:
- Assistant
Now let me look at where the IPC status integration stores the title. Let me find where agent-status IPC events are handled.
- Assistant
Let me look at how the IPC integration is called. Let me find where the agentStatus:set IPC listener is in the renderer.
- Assistant
Let me look at pty-connection.ts to understand how the IPC integration stores the title:
- Assistant
Let me find where the IPC agent status is received in the renderer:
- Assistant
Let me look at where agentStatus:set is called in the main process:
- Assistant
Let me look at the context around line 609 in the main/index.ts to understand how agentStatus:set is called and where the terminal title comes from.
- Assistant
Now I can see the important code! There's a
SYNTHETIC_TITLE_PROFILESthat drives synthetic titles from hooks. Let me look at this to understand the synthetic title profiles and how they work. - Assistant
Let me look at the synthetic title profiles and the
driveSyntheticTitleFromHookfunction. - Assistant
Now let me look at the
driveSyntheticTitleFromHookfunction to understand how synthetic titles are driven. - Assistant
Let me look at the
driveSyntheticTitleFromHookfunction. - Assistant
Now I understand the full picture. Let me look at how the IPC payload is received in the renderer side. Let me search for where agentStatus:set is received in the renderer:
- Assistant
Let me look for where the IPC listener is set up in the renderer.
- Assistant
Now let me look at the pty-connection.ts file to see the onAgentStatus handler and how titles flow through:
- Assistant
Let me look at that handler and the surrounding code to understand how terminalTitle is used.
- Assistant
Now let me look at the agent-status test file for clues about what the function should do:
- Assistant
Let me search for any test files related to
agent-status-terminal-title: - Assistant
So there's no existing
agent-status-terminal-title.tsfile yet. Let me look at the synthetic title profiles more carefully to understand what the function needs to do: - Assistant
Now let me look at all places where
setAgentStatusis called with aterminalTitle: - Assistant
Let me look at lines 760-840 to understand the other setAgentStatus calls:
- Assistant
Let me now look at where the title is used when storing the entry:
- Assistant
Now let me look at how terminal title is detected for cursor and understand the flow. Let me check if there are existing tests for the agent-status-terminal-title:
- Assistant
Let me now look at the
detectAgentStatusFromTitlefunction to understand how different titles are classified: - Assistant
Now let me look at the existing agent-status test to understand the testing patterns:
- Assistant
Let me search for cursor-specific test patterns in the existing test file:
- Assistant
Now I have a thorough understanding of the codebase. Let me also check if there's a shared synthetic-title profile definition:
- Assistant
Let me look at all places where
setAgentStatusis called to understand the integration points: - Assistant
Let me look at the
useIpcEvents.tsfile where the IPC status is received and stored: - Assistant
Let me see the broader context of where the title is resolved before calling setAgentStatus:
- Assistant
Let me see where
titleandidentityTitleare defined in this handler: - Assistant
Let me look at the
resolvePaneKeyfunction to understand how titles are resolved: - Assistant
Let me look at how resolvePaneKey gets the title:
- Assistant
Let me continue reading to see how the title is determined.
- Assistant
Now I have a thorough understanding. Let me create the implementation. First, let me check what the synthetic-title profiles look like and what functions from agent-detection I'll need:
- Assistant
Now I have a thorough understanding of the codebase. Let me create the implementation. First, let me understand the full picture by looking at how terminal title is used when
setAgentStatusis called from useIpcEvents: - Assistant
Now I have a thorough understanding. Let me create the implementation plan:
- Create
src/renderer/src/lib/agent-status-terminal-title.tswith theresolveAgentStatusTerminalTitlefunction - Integrate it into the IPC status handling in
useIpcEvents.tsbefore storing agent status snapshot titles
Let me first create the new file:
- Create
- Assistant
Now let me copy it to the correct location:
- Assistant
Let me verify the file:
- Assistant
Good. Now I need to integrate this resolver into the IPC status flow. The evaluation contract says "The IPC status integration must call this resolver before storing the title." Let me integrate it into the main IPC handler in
useIpcEvents.ts: - Assistant
Let me first check the imports at the top of useIpcEvents.ts:
- Assistant
Now let me add the import for
resolveAgentStatusTerminalTitleand apply it before storing the title. Let me first add the import: - Assistant
Let me add the import after the agent-status-identity import line.
- Assistant
Now let me add the import for
resolveAgentStatusTerminalTitle. I'll add it after the agent-status-identity import: - Assistant
Let me use the correct format for the edit command:
- Assistant
Good. Now let me find the exact location where the title is passed to
setAgentStatusand apply the resolver. Let me find the current line numbers: - Assistant
Let me see the context around line 2295:
- Assistant
Now I need to apply the resolver before the
setAgentStatuscall. Let me replacetitlewith the resolved title: - Assistant
Good. Now I need to also integrate the resolver into
pty-connection.tswhere agent statuses are set. Let me check the relevant locations: - Assistant
Let me look at each of these calls to understand which ones pass a terminalTitle and need the resolver:
- Assistant
This one always sets state 'working', so the resolver won't change the title (it only acts on done/waiting/blocked states). Let me check the others:
- Assistant
This is also always 'working' state, so the resolver won't change the title. Let me check the done state one:
- Assistant
This one sets state 'done' with agentType 'command-code'. Since 'command-code' is not in the synthetic title profiles, the resolver won't change anything for it. Let me check the main onAgentStatus handler:
- Assistant
This is the main onAgentStatus handler. I should integrate the resolver here too. Let me first add the import to pty-connection.ts:
- Assistant
Let me add the import after the agent-status-types import:
- Assistant
Let me add the import for resolveAgentStatusTerminalTitle.
- Assistant
Good. Now let me apply the resolver in the onAgentStatus handler. Let me find the updated line number:
- Assistant
Let me see the context around line 1155:
- Assistant
Now let me replace the
setAgentStatuscall to add the resolver: - Assistant
Now let me run the existing tests to make sure nothing is broken. First, let me check if there's a test runner available:
- Assistant
Let me check the package.json for test scripts:
- Assistant
Let me run the typecheck to verify my changes compile correctly:
- Assistant
The typecheck timed out. Let me try running just the relevant tests:
- Assistant
Good, the agent-status tests pass. Let me also run the agent-status store tests:
- Assistant
Good. Let me also run the pty-connection tests:
- Assistant
I see the issue - the import path for agent-detection is wrong. Let me fix it:
- Assistant
Let me check the correct import path by looking at how other files in the same directory import from shared:
- Assistant
I see the issue - the import path should be
../../../shared/, not../../../../shared/. Let me fix both imports: - Assistant
Now let me run the pty-connection tests again:
- Assistant
All 110 tests pass. Now let me also run the useIpcEvents-related tests:
- Assistant
All tests pass. Let me also run the shared agent-detection test:
- Assistant
All existing tests pass. Let me now run a broader set of tests to make sure nothing else is broken. Let me also run the agent-status count test:
- Assistant
Let me verify the final state of all my changes by looking at the git diff:
- Assistant
Let me check if the new file is tracked:
- Assistant
Good. Let me see the full diff to verify all changes:
- Assistant
Let me verify the new file contents:
- Assistant
Now let me run a broader set of agent-status related tests to make sure everything is working:
- Assistant
All 292 tests pass across 7 test files. Let me now create a quick test script to verify the behavior manually:
- Assistant
The TypeScript file can't be run directly with node. Let me verify the logic is correct by testing through the test framework. Let me create a temporary test file:
- Assistant
Let me run this temporary test file:
- Assistant
The test file needs to be in the src directory. Let me create a temporary test in the right place:
- Assistant
Now let me run the test:
- Assistant
All 15 tests pass. Now I need to remove the test file since the instructions say I should not modify or add tests to the repository:
- Assistant
Let me now verify the final state of all changes:
- Assistant
Let me run all the relevant tests one more time to make sure everything is working:
- Assistant
All 276 tests pass. Let me now do a final review of all changes before submitting:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.