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
Let me analyze the issue and understand what needs to be done:
- The issue is about a Cursor CLI agent that stays in a loading state after task completes
- The evaluation contract describes a function
resolveAgentStatusTerminalTitlethat needs to be created - The function should reconcile terminal titles based on agent state
Let me start by exploring the repository structure to understand the codebase.
- Assistant
Let me explore the repository structure more and look for the relevant files.
- Assistant
Good, I found some relevant files. Let me look for the specific file mentioned in the issue:
src/renderer/src/lib/agent-status-terminal-title.ts. - Assistant
Let me explore the existing agent-status related files to understand the structure:
- Assistant
Now let me look at the agent-status.ts file in the renderer to understand the structure and find the IPC integration:
- Assistant
Now let me look at the agent status store slice and the IPC integration:
- Assistant
Let me look at the IPC integration where terminal titles are stored:
- Assistant
Let me look at the IPC agent-hooks file:
- Assistant
Let me look at the agent-hooks server.ts file to understand how agent status is being processed:
- Assistant
Let me look at the agent-status-osc.ts file to understand how terminal titles are handled:
- Assistant
Let me search for where terminalTitle is being set in the agent status:
- Assistant
Let me look at the use-terminal-pane-lifecycle.ts file to understand how terminalTitle is being set:
- Assistant
Now let me look at the pty-connection.ts file to understand how terminalTitle is being handled:
- Assistant
Let me look at this file to understand how terminal titles are being handled in the PTY connection:
- Assistant
Let me search for where terminalTitle is being set in the agent status:
- Assistant
Let me look at how setAgentStatus is called in pty-connection.ts to understand how terminalTitle is being set:
- Assistant
Now let me check if there's already a file for agent-status-terminal-title:
- Assistant
Let me check if the file exists:
- Assistant
Let me look at the agent-detection module to understand synthetic titles:
- Assistant
Let me look at the agent-detection.ts file to understand synthetic titles: responsibility.
- Assistant
Let me continue reading the file to understand how the agent status is detected:
- Assistant
Let me continue reading the agent-detection.ts file to understand how Cursor titles are handled:
- Assistant
Now let me look for where the IPC status integration stores the title. Let me search for where agentStatus is being set in the store:
- Assistant
Let me look at the main process to understand how the IPC status integration works. Let me search for where the status is being set via IPC:
- Assistant
Let me search for where the IPC sends the status to the renderer:
- Assistant
Let me look at the main/index.ts to understand how the status is being sent via IPC:
- Assistant
Now let me look for where the terminalTitle is being set when the IPC sends the status. Let me search for where the terminalTitle is being set:
- Assistant
Let me look at how the renderer side stores terminalTitle when receiving the IPC:
- Assistant
Let me search for the renderer-side listener for agentStatus:set.
- Assistant
Let me look for where the IPC listener is set up and where terminalTitle is stored:
- Assistant
Let me look at the setAgentStatus implementation in the store slice:
- Assistant
Now let me look at the IPC status integration to understand where the resolver needs to be called:
- Assistant
Now I see there's already a
SYNTHETIC_TITLE_PROFILESanddriveSyntheticTitleFromHookfunction. Let me find these: - Assistant
Let me look at the synthetic title profiles and driveSyntheticTitleFromHook function:
- Assistant
Now let me look at the
driveSyntheticTitleFromHookfunction: - Assistant
Let me search for where the IPC listener is registered:
- Assistant
Now I need to understand the full flow and where the terminal title resolution happens. Let me search for the renderer-side agent status store subscription and where it listens for
agentStatus:setIPC events. - Assistant
Now let me look at the useIpcEvents.ts to see how the agent status is being handled:
- Assistant
Let me find the
applyAgentStatusfunction: - Assistant
Let me search for
applyAgentStatusin the codebase. - Assistant
Let me look at the applyAgentStatus function in useIpcEvents.ts to see where it's implemented.
- Assistant
Let me continue reading the applyAgentStatus function:
- Assistant
Let me look at the test file for agent status to understand the expected behavior:
- Assistant
Now let me search for where we need to call this resolver. I need to find where agent-status terminal titles are stored. Let me check if there are existing tests that reference this:
- Assistant
Let me look more closely at the setAgentStatus function in the store:
- Assistant
Now let me understand what synthetic title profiles exist. Let me check:
- Assistant
Let me check if there are any existing tests that might be related:
- Assistant
Let me also look at how
resolvePaneKeyworks to understand how titles come in: - Assistant
Let me check what resolvePaneKey does:
- Assistant
Let me continue reading to understand what title is returned:
- Assistant
Now I understand the full picture. Let me look at the synthetic-title-visibility test file to understand more:
- Assistant
Now I understand the full picture. Let me also look at how the synthetic title spinner works:
- Assistant
Now I have enough understanding of the codebase. Let me create the
resolveAgentStatusTerminalTitlefunction. The key issue is that when a Cursor agent finishes, the terminal title might still be in a working state (like "⠋ Cursor Agent") and needs to be reconciled with the actual agent state. - Assistant
Now let me understand the flow in
useIpcEvents.tsto integrate the resolver. The key is theapplyAgentStatusfunction that callssetAgentStatus: - Assistant
Now let me look at the setAgentStatus implementation in the store to understand where the title is stored:
- Assistant
Let me look at the lines around where effectiveTitle is computed:
- Assistant
Now I understand the flow. I need to:
- Create
agent-status-terminal-title.tswith the resolver function - Apply the resolver in the
setAgentStatusfunction whereeffectiveTitleis computed
Let me create the resolver file first:
- Create
- Assistant
Now I need to integrate this resolver into the agent-status store slice. Let me modify the
setAgentStatusfunction to use the resolver: - Assistant
Now I need to add the import for
resolveAgentStatusTerminalTitleand modify thesetAgentStatusfunction to use it. Let me make the edit: - Assistant
Now let me add the import and modify the setAgentStatus function to use the resolver.
- Assistant
Now let me find the exact location where the title is stored in the entry:
- Assistant
Let me look at the area around where effectiveTitle is computed:
- Assistant
Now I need to apply the resolver to the
effectiveTitlebefore it's stored in the entry. Let me modify the code: - Assistant
Now I need to change the entry to use
resolvedTitleinstead ofeffectiveTitle: - Assistant
Now let me run the existing tests to make sure the changes don't break anything:
- Assistant
Let me try running vitest directly:
- Assistant
The import path is wrong. Let me check what the correct path should be by looking at existing imports:
- Assistant
I see - the import path should be
../../../shared/agent-detectionnot../../../../shared/agent-detection. Let me fix it: - Assistant
I also need to fix the import for agent-status-types. Let me check the correct path:
- Assistant
Now let me run the tests again:
- Assistant
All 24 tests passed! Let me also run the agent-status.test.ts tests in the lib folder:
- Assistant
Let me also run the agent-status-count.test.ts tests:
- Assistant
Let me also run the agent-status-types.test.ts tests:
- Assistant
Let me also run some additional tests to make sure I haven't broken anything:
- Assistant
Let me also run some more related tests:
- Assistant
Let me run the synthetic-title-visibility test and the agent-detection tests:
- Assistant
Let me run more tests to make sure everything is passing. Let me check if there are any tests related to agent detection:
- Assistant
Let me check for test files related to agent detection:
- Assistant
Let me now create a test file for the new function:
- Assistant
Now let me run the test file to make sure all tests pass:
- Assistant
All 18 tests passed! Now let me run a broader set of tests to make sure nothing else is broken:
- Assistant
All tests pass. Let me verify the changes I made:
- Assistant
Let me check git status to see what changes are tracked:
- Assistant
Let me check the diff to make sure the changes look correct:
- Assistant
Let me verify the new file contents:
- Assistant
Let me verify the test file:
- Assistant
Let me run all the tests one more time to make sure everything is working correctly:
- Assistant
All 180 tests passed! Let me now run some broader tests to make sure nothing else is broken:
- Assistant
All tests pass. Let me now check the checklist from the issue:
Checklist
-
If an error was reported in the issue description, I have successfully reproduced it.
- The issue reports that Cursor CLI agent stays in loading state after task completes. This is because the terminal title is not reconciled with the agent state. I've created a resolver function that addresses this.
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- The fix creates a resolver function that:
- For
donestate: replaces spinner/working titles, bare native titles, and stale permission titles with the idle label - For
waiting/blocked: uses the permission label - Preserves descriptive completed titles
- Does not rewrite agents without a synthetic-title profile
- For
- The fix creates a resolver function that:
-
I have thought about edge cases and made sure my fix handles them as well.
-
- Assistant
Now let me verify the final state of the changes:
- Assistant
Let me run the tests one more time to make sure everything still passes:
- Assistant
All 162 tests passed. Let me also run a broader test suite to make sure nothing else is broken:
- Assistant
All tests pass. Let me verify the final implementation once more:
- Assistant
Let me also verify the changes in the agent-status.ts file:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.