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 start by exploring the repository structure to understand the codebase and find the relevant files mentioned in the issue.
Assistant
Let me find the file mentioned in the interface section:
src/renderer/src/lib/agent-status-terminal-title.ts<tool_call> <function=bash_terminal> <parameter=command> find /orca -name "agent-status-terminal-title.ts" 2>/dev/null </tool_call>
Assistant
Let me run the find command properly.
Assistant
The file doesn't exist yet. Let me explore the directory structure more to understand where the file should be created.
Assistant
The file
agent-status-terminal-title.tsdoes not exist in the directory. Let me search for any related files or see if there are similar patterns that might be relevant.<tool_call> <function=bash_terminal> <parameter=command> grep -r "agent-status" /orca/src/renderer/src/lib/ --include="*.ts" 2>/dev/null | head -30 </tool_call>
Assistant
Let me search for agent-status files properly.
Assistant
Now I can see there's an
agent-status.tsfile. Let me read it and the related types file to understand the structure better.Assistant
Now let me look at the shared/agent-status-types file to understand the types better:
<tool_call> <function=bash_terminal> <parameter=command> cat /orca/src/shared/agent-status-types.ts </tool_call>
Assistant
I need to actually use the command properly. Let me run the cat command again.
Assistant
Now I understand the structure. Let me look at the shared/agent-detection.ts file to see if there's an existing function that might be related:
<tool_call> <function=bash_terminal> <parameter=command> cat /orca/src/shared/agent-detection.ts </tool_call>
Assistant
The command didn't run. Let me try again.
Assistant
Now I have a good understanding of the codebase. Let me understand the issue better:
- The issue is that Cursor CLI agent sessions stay in loading state after the task completes
- The issue mentions an "Evaluation contract" that describes how to resolve terminal titles for Cursor agents
- There's an interface description that asks for a new function
resolveAgentStatusTerminalTitleto be created
Looking at the interface description:
- 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."
Assistant
Let me run the search properly.
Assistant
Now let me look at the agent-status-related files and understand how the status is handled. Let me check for how the agent status is updated through IPC:
<tool_call> <function=bash_terminal> <parameter=command> cat /orca/src/renderer/src/store/slices/agent-status-drop-ipc.test.ts </tool_call>
Assistant
Let me run the cat command properly.
Assistant
Let me look at how the agent status slice is implemented:
<tool_call> <function=bash_terminal> <parameter=command> cat /orca/src/renderer/src/store/slices/agent-status.ts </tool_call>
Assistant
Let me run the cat command properly.
Assistant
Now I understand how the agent status works. Let me also look at how the terminal title is handled when setting agent status, to understand where I need to insert the title resolution logic:
<tool_call> <function=bash_terminal> <parameter=command> grep -r "terminalTitle" /orca/src/renderer/src/store/slices/agent-status.ts | head -30 </tool_call>
Assistant
I need to properly run the grep command. Let me do that.
Assistant
Now let me look at where the agent-status slice is created and called, particularly around the IPC integration to understand where the resolver should be called. Let me look for the IPC handlers for agent status:
<tool_call> <function=bash_terminal> <parameter=command> find /orca/src -name "agent-status" -type f | head -30 </tool_call>
Assistant
Let me run the find command properly.
Assistant
Assistant
The heredoc syntax might have an issue. Let me try a different approach to create the file.
Assistant
Now let me verify the file was created correctly:
Assistant
Now let me look for where the agent-status IPC integration happens to understand where the resolver should be called:
Assistant
Let me look at the main IPC agent-hooks file to understand how agent status is received:
Assistant
Now let me look at the agent hooks server to find where status is sent to the renderer:
Assistant
I need to see where the IPC status is sent to the renderer. Let me search for where the agentStatus event is sent:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "agentStatus:set" /orca/src/main/agent-hooks/server.ts | head -10 </tool_call>
Assistant
Let me run the grep command properly.
Assistant
The grep didn't find any results, meaning the pattern might be different. Let me search for where the IPC event is sent to the renderer.
Assistant
Let me look at how the IPC handler is registered and where the IPC call to renderer happens. The agent-status slice has
setAgentStatusmethod. I need to find where that's called from.<tool_call> <function=bash_terminal> <parameter=command> grep -rn "setAgentStatus" /orca/src/main --include="*.ts" | head -20 </tool_call>
Assistant
Let me search for where the IPC event is sent to renderer.
Assistant
Let me search for IPC event names related to agent status:
Assistant
Let me look at the renderer's store hooks to see how the agent status is set:
Assistant
Let me look at the useIpcEvents.ts file to understand how agent status is received:
Assistant
Let me look at the IPC handler registration to understand the flow better:
Assistant
Let me look at the code around line 2371 where onSet is called:
Assistant
Let me see the applyAgentStatus function to understand how it processes the data:
Assistant
Let me see the applyAgentStatus function definition:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '2180,2280p' /orca/src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
I need to run the sed command properly. Let me try again.
Assistant
Let me continue to see more of the applyAgentStatus function and find where setAgentStatus is called:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '2280,2360p' /orca/src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me try the sed command again.
Assistant
Now I understand the flow. The
applyAgentStatusfunction receives data from IPC and callsstore.setAgentStatus(data.paneKey, statusPayload, title, ...). Thetitleparameter is the terminal title.I need to:
- Apply the
resolveAgentStatusTerminalTitleresolver before callingsetAgentStatus - Pass the resolved title to
setAgentStatus
Let me also check how the main process sends the title. I need to find where the title is obtained in the main process and sent to the renderer:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "title" /orca/src/main/agent-hooks/server.ts | head -30 </tool_call>
- Apply the
Assistant
The grep command is having issues. Let me try a different approach to search for where the title is used in the server.
Assistant
The file doesn't seem to have "title" in it. Let me look at the shared agent-status-identity file that's imported:
Assistant
I need to understand where the terminal title is obtained. Let me look at the PTY code to see where the title is read and sent:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "terminalTitle|terminal.*title" /orca/src/main/ipc/pty.ts | head -30 </tool_call>
Assistant
Let me try running the grep command again properly.
Assistant
The search didn't find anything. Let me look at how the agent hooks server is sending data to the renderer. I should check if there's a preload file that defines the IPC handlers:
Assistant
Let me run the find command properly.
<tool_call> <function=bash_terminal> <parameter=command> find /orca/src -name "preload" -type f </tool_call>
Assistant
The find command is having issues. Let me try a different approach to find the preload file.
Assistant
Let me look at the preload API types to see how the agentStatus IPC is defined:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "agentStatus" /orca/src/preload/api-types.ts | head -30 </tool_call>
Assistant
Let me try a different approach to search for agentStatus in the api-types file.
Assistant
Now let me see more context around that line:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '2250,2350p' /orca/src/preload/api-types.ts </tool_call>
Assistant
Let me try again to see the content around that line.
Assistant
Now I understand the structure. The
onSetcallback receivesAgentStatusIpcPayload. I need to modify theapplyAgentStatusfunction in the renderer to call theresolveAgentStatusTerminalTitlefunction and update the title based on the agent state.Looking at the issue description again, the problem is that the Cursor CLI agent stays in loading state after the task completes. The evaluation contract says:
For Cursor,
donereplaces spinner/working titles, the bareCursor Agenttitle, and stale permission titles withCursor ready;waitingorblockeduses .Assistant
Let me find where the imports are at the top of the useIpcEvents.ts file to see how to add the import for the new function.
Assistant
Now I can see the imports. I need to add an import for
resolveAgentStatusTerminalTitlefrom the new file I created. Let me also look at the applyAgentStatus function more closely to understand where to apply the resolver.Looking at line 2295-2300 in the previous output, I can see:
store.setAgentStatus(data.paneKey, statusPayload, title, { updatedAt: data.receivedAt, stateStartedAt: data.stateStartedAt })The
titleparameter is the terminal title that was resolved from the pane key. I need to callresolveAgentStatusTerminalTitlehere to get a resolved title based on the agent type and state.Let me first update the imports and then modify the applyAgentStatus function:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '75,85p' /orca/src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me try running the sed command again to see the imports section.
Assistant
Let me add the import for
resolveAgentStatusTerminalTitleafter the other agent-status related imports:<tool_call> <function=bash_terminal> <parameter=command> sed -n '60,72p' /orca/src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me try to see the imports section around line 60-72.
Assistant
Let me find where the agent-status identity imports are so I can add the new import nearby.
Assistant
Now I'll add the import for the
resolveAgentStatusTerminalTitlefunction after the agent-status-identity import. Let me use the sed command to add the import.Assistant
Now let me verify the import was added:
Assistant
Now I need to modify the
applyAgentStatusfunction to callresolveAgentStatusTerminalTitleand use the resolved title. Let me find the exact line wheresetAgentStatusis called:Assistant
Now I need to modify the code to apply the title resolver. Let me replace the
setAgentStatuscall to use the resolved title:Assistant
I need to:
- Create a resolved title by calling
resolveAgentStatusTerminalTitle - Use the resolved title (or fall back to the existing title)
Let me update the setAgentStatus call to use the resolved title:
- Create a resolved title by calling
Assistant
Let me verify the changes:
Assistant
Let me also check if the main process needs to apply the title resolver. Let me search for where the agentStatus IPC payload is created in the main process:
Assistant
I need to look at the main process IPC code to see where the terminal title is included in the payload. Let me check if the main process sends the terminal title.
Let me look at the agent hook listener to see where the payload is created.
Assistant
The main process IPC payload doesn't include the terminal title - the title is obtained from the renderer's pane state. The renderer's
applyAgentStatusfunction resolves the title fromresolvePaneKey, and I've already added the resolver there.Now let me verify the existing tests pass and create a test for the new functionality. First, let me check if there are any tests for the agent-status-terminal-title file:
Assistant
Now let me create a test file for the new function:
Assistant
Now let me run the tests to verify everything works:
Assistant
Let me check the package.json to see how to run tests:
Assistant
Let me try running the test with a more specific path:
Assistant
Let me check if there's a way to just verify TypeScript compilation:
Assistant
Let me verify the code syntax is correct by looking at the files:
Assistant
Let me verify the test file:
<tool_call> <function=bash_terminal> <parameter=command> cat /orca/src/renderer/src/lib/agent-status-terminal-title.test.ts </tool_call>
Assistant
The cat command didn't work properly. Let me try again with proper escaping.
Assistant
Now let me also verify the changes to useIpcEvents.ts:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '54,62p' /orca/src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
I need to run the command to verify the changes. Let me try with a fresh command.
Assistant
Now let me verify the change where the resolver is called in the applyAgentStatus function:
Assistant
Now let me check if there are any other places where the title resolution should be applied. Let me look for other places where
setAgentStatusis called in the codebase:<tool_call> <function=bash_terminal> <parameter=command> grep -n "setAgentStatus" /orca/src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
The grep command didn't produce any output. Let me try again to search for setAgentStatus calls.
Assistant
There's only one place where
setAgentStatusis called in the IPC events file. Now let me also check if the title resolver should be called when the status is replayed (snapshot):Assistant
The snapshot replay also goes through
applyAgentStatus, so the title resolver will be applied there too.Now let me check if there are any other places where agent status is set that might need the resolver. Let me search for other files that might set agent status:
Assistant
Now I see there are multiple places where
setAgentStatusis called. Let me look at each of them to understand if they need the title resolver too.Let me check the PTY connection file:
Assistant
Let me also check the automation-session-observer file and the launch-agent-background-session file:
Assistant
Let me also check the launch-agent-background-session file:
Assistant
Assistant
Let me get the content around that line to understand how the title is obtained.
Assistant
Let me find where
titleis defined in the applyAgentStatus function.Assistant
Let me search for where the title variable is defined in the applyAgentStatus function.
Assistant
Let me search for the
titlevariable in the applyAgentStatus function.<tool_call> <function=bash_terminal> <parameter=command> sed -n '2200,2225p' /orca/src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
I need to get the content around line 2200 to understand how the title is obtained. Let me try again with the sed command.
Assistant
Now I understand. The
titlevariable is obtained fromresolvePaneKey(store, data.paneKey). This is the current terminal title of the pane. My fix applies the resolver to this title based on the agent type and state.Now let me verify my implementation by looking at the full picture:
- The IPC handler receives agent status updates
- It calls
resolvePaneKeyto get the current terminal title - My fix calls
resolveAgentStatusTerminalTitleto get a resolved title based on the agent state - The resolved title is passed to
setAgentStatus
This should fix the issue where the UI shows loading after the Cursor CLI agent completes.
Let me also make sure the file is properly exported from the lib index if there is one:
<tool_call> <function=bash_terminal> <parameter=command> ls /orca/src/renderer/src/lib/index.ts 2>/dev/null || echo "No index.ts found" </tool_call>
Assistant
I need to check if there's an index file that exports the functions from the lib directory. Let me try again with a simpler command.
Assistant
There's no index file in the lib directory, so the import I added directly to useIpcEvents.ts is correct.
Now let me verify that the changes I made don't break any existing functionality by checking if there are any TypeScript errors in the modified file. Let me also double-check the interface description requirements:
- ✅ Path:
src/renderer/src/lib/agent-status-terminal-title.ts- created - ✅ Input:
payload: Pick<ParsedAgentStatusPayload, 'agentType' | 'state'>, currentTitle: string | undefined- correct - ✅ Output:
string | undefined- correct - ✅ 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." - implemented
The implementation looks correct. Let me now verify the test file exists and run a quick sanity check:
<tool_call> <function=bash_terminal> <parameter=command> ls -la /orca/src/renderer/src/lib/agent-status-terminal-title* </tool_call>
- ✅ Path:
Assistant
Let me run the ls command to check the files.
Assistant
Both files exist. Now let me also verify the changes made to useIpcEvents.ts by checking the git diff:
<tool_call> <function=bash_terminal> <parameter=command> cd /orca && git diff --stat </tool_call>
Assistant
I need to run git diff to see what changes were made.
Assistant
Let me see the full diff to verify the changes are correct:
<tool_call> <function=bash_terminal> <parameter=command> cd /orca && git diff </tool_call>
Assistant
I need to run git diff to see the changes made. Let me try again.
Assistant
The changes look correct. Now let me also check if there are any untracked files that need to be included:
<tool_call> <function=bash_terminal> <parameter=command> cd /orca && git status </tool_call>
Assistant
I need to run git status to see the current state of the repository.
Assistant
Assistant
The command didn't work properly. Let me try a different approach to update the file.
Assistant
Let me verify the updated file and check the git status again:
<tool_call> <function=bash_terminal> <parameter=command> cat /orca/src/renderer/src/lib/agent-status-terminal-title.ts </tool_call>
Assistant
I need to run the cat command to verify the file contents.
Assistant
The file now correctly imports
ParsedAgentStatusPayloadand uses the correct type. Let me check the git status to see the final changes:<tool_call> <function=bash_terminal> <parameter=command> cd /orca && git status </tool_call>
Assistant
Let me run the git status command again to check the final state.
Assistant
Let me also verify the full diff to make sure everything is correct:
<tool_call> <function=bash_terminal> <parameter=command> cd /orca && git diff </tool_call>
Assistant
The git diff command didn't produce output. Let me try again to see the changes.
Assistant
The changes look correct. Now let me summarize what I've done:
Summary of Changes
1. Created
/orca/src/renderer/src/lib/agent-status-terminal-title.tsThis file implements the
resolveAgentStatusTerminalTitlefunction that:- Takes a payload with
agentTypeandstate, and acurrentTitle - Returns the resolved terminal title or
undefinedto preserve the current title - For Cursor agents in
donestate: replaces stale spinner/working/permission titles with "Cursor ready" - For Cursor agents in or state: replaces with "Cursor - action required"
- Takes a payload with
Assistant
Let me check the git status to confirm the changes:
Assistant
The changes are complete. Let me submit the solution.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.