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.
Assistant
Let me analyze the issue:
- The bug is about a Cursor CLI agent staying in a loading state after completing its task in the Orca UI.
- The solution involves implementing a
resolveAgentStatusTerminalTitlefunction insrc/renderer/src/lib/agent-status-terminal-title.ts. - For Cursor agents, when the state is "done", it should map stale spinner/working/bare native/permission titles to "Cursor ready".
- When state is "waiting" or "blocked", it should map to "Cursor - action required".
- Descriptive completed titles and agents without a synthetic profile should be preserved.
Let me first explore the repository structure to understand the codebase.
Assistant
Let me look at the actual source files, not node_modules.
Assistant
Let me look at the specific file mentioned in the issue and the agent-status related files.
Assistant
Let me check if the file mentioned in the issue already exists or needs to be created:
Assistant
The file doesn't exist yet. Let me explore the existing agent-status related files to understand the patterns:
Assistant
Let me look at the agent-status files and related types to understand the structure and patterns.
Assistant
Let me look at the shared agent-status-types to understand the types:
<tool_call> <function=bash_terminal> <parameter=command> cat /orca/src/shared/agent-status-types.ts </tool_call>
Assistant
Let me run the command properly.
Assistant
Let me also look at the agent-status store and IPC integration to understand where the terminal title should be resolved:
Assistant
Now let me look at the IPC integration to see where the terminal title is processed:
<tool_call> <function=bash_terminal> <parameter=command> cat /orca/src/main/pi/agent-status-extension-source.ts </tool_call>
Assistant
Let me run the command properly.
Assistant
Let me look at the test files and find where the terminal title is being set/received via IPC:
Assistant
Let me search for where the terminal title is set and where agent-status IPC events are handled to understand the flow.
Assistant
Let me look at the IPC events handler to understand how terminalTitle flows through.
Assistant
Let me search for where the agent status IPC event is processed:
Assistant
Let me look at the IPC handler around line 2371 where
agentStatus.onSetis handled.Assistant
Let me see the applyAgentStatus function:
Assistant
Let me look at the full applyAgentStatus function:
Assistant
Let me look at the existing test files and understand the pattern better:
Assistant
Let me look at how the agent-detection module works and what patterns exist for title normalization:
Assistant
Let me look at the test files and the main process IPC handler:
Assistant
Let me look at how the store-cascades test file works to understand the testing patterns:
Assistant
Now I understand the architecture. Let me search for more context about how terminal titles flow through the IPC and where the resolution should happen:
Assistant
Now I understand the context better. Let me look at the pty-transport.ts to understand how Cursor titles flow through, and the main process code to understand the idle label:
Assistant
Let me look at the synthetic title profile for Cursor:
Assistant
Now I have a clear understanding. Let me look at more test files to understand expected behavior:
Assistant
Now I have a good understanding of the codebase. Let me look at how existing tests are structured and find any related test patterns:
Assistant
Let me look at how the store receives and processes terminalTitle to understand where to call the resolver:
Assistant
Let me check where the terminal title gets stored and how the store's setAgentStatus works more closely:
Assistant
Now I understand the full picture. Let me:
- Create the
resolveAgentStatusTerminalTitlefunction in the specified path - Modify the IPC handler in
useIpcEvents.tsto call this resolver before storing the title
Let me first check the full flow one more time in the IPC handler to know exactly where to apply the fix:
- Create the
Assistant
Now I have a comprehensive understanding of the issue and codebase. Let me implement the solution:
- Create the
resolveAgentStatusTerminalTitlefunction in the specified path - Call it in the IPC handler before storing the terminal title
Let me first check if there are existing patterns for how agent types are identified:
- Create the
Assistant
Now I have a comprehensive understanding of the issue and codebase. Let me implement the solution.
The issue is: When a Cursor CLI agent finishes its task (state='done'), the terminal title may still show a spinner/working title like "⠋ Cursor Agent" or the bare "Cursor Agent" native title. The fix requires a
resolveAgentStatusTerminalTitlefunction that reconciles the hook-reported state with synthetic terminal-title profiles, then calling it from the IPC integration before storing the title.Let me create the resolver function:
Assistant
Good, the file was created. Now let me verify it and then modify the IPC handler to call the resolver before storing the title.
Assistant
Now I need to modify the IPC handler in
useIpcEvents.tsto callresolveAgentStatusTerminalTitlebefore storing the terminal title. Let me modify theapplyAgentStatusfunction:Assistant
Now I need to find the exact line where the title is stored and add the resolver call. Let me look at the specific line numbers in useIpcEvents.ts to understand where to add the import and modify the code.
Assistant
Now I need to:
- Add an import for
resolveAgentStatusTerminalTitlein useIpcEvents.ts - Modify the
applyAgentStatusfunction to call the resolver before passing the title tosetAgentStatus
Let me first find the exact line where
store.setAgentStatusis called in useIpcEvents.ts to understand what needs to be changed.- Add an import for
Assistant
<tool_call> <function=edit> <parameter=--file> /orca/src/renderer/src/hooks/useIpcEvents.ts <parameter=--file> /orca/src/renderer/src/hooks/useIpcEvents.ts <parameter=1:60 <parameter=--file> /orca/src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me add the import first, then modify the setAgentStatus call.
Assistant
Let me find where the import section is and add my new import, then find where the title is passed and add the resolver call.
Assistant
Now I need to:
- Add an import for
resolveAgentStatusTerminalTitlefrom the new file - Modify the
applyAgentStatusfunction to use the resolver before passing the title tosetAgentStatus
Let me add the import first. I'll add it near the other
@/libimports.- Add an import for
Assistant
Good, now let me verify the import was added correctly:
Assistant
Now I need to find the exact line where the title is passed to
setAgentStatusand add the resolver call. Let me check the current line number:Assistant
Good, the line shifted by 1 due to the added import. Let me look at the context around line 2295 to understand what to modify:
Assistant
Now I need to modify the code to call the resolver before passing the title to
setAgentStatus:<tool_call> <function=edit> <parameter=--file> /orca/src/renderer/src/hooks/useIpcEvents.ts <parameter=1:1 <parameter=REPLACEMENT_TEXT> const resolvedTitle = resolveAgentStatusTerminalTitle( { agentType: statusPayload.agentType, state: statusPayload.state }, title ) store.setAgentStatus(data.paneKey, statusPayload, resolvedTitle, { updatedAt: data.receivedAt, stateStartedAt: data.stateStartedAt }) </tool_call>
Assistant
I need to properly use the edit command with the correct syntax.
Assistant
I need to use the edit command correctly. The syntax is
edit --file PATH LINE_RANGE REPLACEMENT_TEXT. Let me use the replace command instead which is better for replacing text.Assistant
Let me use the bash_terminal command with sed to make the change.
Assistant
Let me check the result of this sed command.
Assistant
The changes look correct. Now let me create a test file for the new resolver function:
Assistant
Let me verify the test file was created properly:
Assistant
Now let me run the tests to verify everything works:
Assistant
Let me try to bypass the interactive prompt:
Assistant
Let me check if node_modules exists and if I can run the tests directly with npx or vitest.
Assistant
Let me run the tests directly with vitest.
Assistant
All 18 tests passed. Now let me verify that existing tests still pass by running the related test files:
Assistant
This test failure is unrelated to my changes - it's a missing package issue. Let me run the agent-status slice tests which are more relevant:
Assistant
The test failures are pre-existing issues with missing packages, unrelated to my changes. Let me run the lib-level tests instead:
Assistant
These test failures are pre-existing issues with missing package imports in the codebase, not related to my changes. Let me verify my code compiles correctly by checking TypeScript:
Assistant
There's an error with the regex flag
u- it needs to be supported at ES6+. Let me check the project's tsconfig to understand the target, or just use a different approach that avoids the issue.Assistant
The issue is with the regex flag
uwhich requires ES6+ target. Let me check the tsconfig.web.json to see what target is being used and then fix the regex accordingly.Assistant
Let me check the base tsconfig and fix the regex flag issue:
Assistant
The TypeScript error is from running tsc on a single file without the project context. Let me verify the actual file is correct by checking the TypeScript compilation within the project:
Assistant
Let me fix the unused variable warning in my code and verify everything is working properly.
Assistant
I need to remove the unused variable
normalizedLower. Let me use bash to do this:Assistant
Let me verify the fix and then check the full content of the file. I also need to check if
normalizedLoweris used anywhere else in the file since I removed it.Assistant
Good, the unused variable has been removed. Now let me verify the tests still pass and check for any compilation issues:
Assistant
All tests pass. Let me now verify all my changes look correct by reviewing the git diff:
Assistant
The diff shows the changes I've made to the useIpcEvents.ts file. Now let me also verify the new files were created correctly.
Assistant
Let me verify the full implementation by checking the new files and running a quick TypeScript check on my new files:
Assistant
The changes I've made address the issue where the Cursor CLI agent stays in a loading state after task completion. Let me provide a summary of what was implemented:
Summary of Changes
1. Created
src/renderer/src/lib/agent-status-terminal-title.tsA new resolver function that reconciles hook-reported agent state with synthetic terminal-title profiles:
For Cursor agents:
donestate: Replaces stale spinner/working/bare native/permission titles with "Cursor ready"waiting/blockedstate: Replaces titles with "Cursor - action required"workingstate: No override (existing spinner title is correct)- Descriptive completed titles: Preserved (e.g., "Cursor finished the task")
- Agents without a profile: Left unchanged (undefined returned)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.