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 how it's organized and find the relevant files mentioned in the issue.
The issue is about a Cursor CLI agent staying in a loading state after the task completes. The evaluation contract mentions a function
resolveAgentStatusTerminalTitlethat should be implemented insrc/renderer/src/lib/agent-status-terminal-title.ts.Let me first explore the repository structure and then look at the relevant files.
Assistant
Let me explore the
src/renderer/src/libdirectory to find the file mentioned in the issue.<tool_call> <function=bash_terminal> <parameter=command> find src/renderer/src/lib -name "agent-status" -o -name "terminal" 2>/dev/null </tool_call>
Assistant
Let me use bash_terminal to search for the agent-status terminal title file.
Assistant
I can see that the file
agent-status-terminal-title.tswas mentioned in the issue, but I don't see it in the search results. Let me check if there's a file with a similar name or if I need to create it. Let me also look at the agent-status.ts file in the lib directory to understand the context better.<tool_call> <function=bash_terminal> <parameter=command> ls -la src/renderer/src/lib/agent-status* </tool_call>
Assistant
Let me use the bash_terminal function to list the agent-status related files in the lib directory.
Assistant
I see there is
agent-status.tsbut notagent-status-terminal-title.ts. According to the issue, I need to create theresolveAgentStatusTerminalTitlefunction insrc/renderer/src/lib/agent-status-terminal-title.ts. Let me first look at the agent-status.ts file to understand the existing code and the ParsedAgentStatusPayload type.<tool_call> <function=bash_terminal> <parameter=command> cat src/renderer/src/lib/agent-status.ts </tool_call>
Assistant
Let me use the bash_terminal function to view the agent-status.ts file.
Assistant
Let me now look at the agent-status-types.ts file to understand the types involved:
<tool_call> <function=bash_terminal> <parameter=command> cat src/shared/agent-status-types.ts </tool_call>
Assistant
I need to use bash_terminal function to view the agent-status-types.ts file.
Assistant
Now I understand the types better. Let me also look at the agent-detection.ts file which contains
detectAgentStatusFromTitleto understand how terminal titles are parsed for agent status:<tool_call> <function=bash_terminal> <parameter=command> cat src/shared/agent-detection.ts </tool_call>
Assistant
I need to use bash_terminal function to view the agent-detection.ts file.
Assistant
Now I understand the structure better. I need to find where the IPC status integration is happening - this is where the
resolveAgentStatusTerminalTitlefunction needs to be called before storing the title. Let me search for files that handle IPC communication for agent status.<tool_call> <function=bash_terminal> <parameter=command> grep -r "agentStatus" src/renderer --include=".ts" --include=".tsx" | grep -v "test.ts" | head -30 </tool_call>
Assistant
Let me use the bash_terminal function to search for agentStatus IPC integration.
Assistant
Let me search for where the IPC events are processed for agent status, specifically where the terminalTitle might be stored.
Assistant
Let me look at the agent-status slice to see how the terminal title is stored and where I need to integrate the
resolveAgentStatusTerminalTitlefunction.Assistant
Now I understand the agent status slice. Let me search for where this
setAgentStatusis called from to see where I need to integrate theresolveAgentStatusTerminalTitlefunction.<tool_call> <function=bash_terminal> <parameter=command> grep -r "setAgentStatus" src/renderer --include=".ts" --include=".tsx" | grep -v "test.ts" </tool_call>
Assistant
Let me use bash_terminal to search for setAgentStatus calls.
Assistant
Now I can see the IPC event handler in
useIpcEvents.tsthat callssetAgentStatus. Let me look at that file to see how the terminal title is passed.<tool_call> <function=bash_terminal> <parameter=command> cat src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me use bash_terminal to view the useIpcEvents.ts file.
Assistant
Let me see the agent status IPC handler section in useIpcEvents.ts:
Assistant
Let me look at the agent status IPC handler around line 2371:
Assistant
Let me look at the
applyAgentStatusfunction to see how the terminal title is handled:Assistant
Let me view the
applyAgentStatusfunction around line 2186:<tool_call> <function=bash_terminal> <parameter=command> sed -n '2186,2290p' src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
I need to use bash_terminal to view the applyAgentStatus function.
Assistant
Let me continue to see the rest of the
applyAgentStatusfunction wheresetAgentStatusis called:<tool_call> <function=bash_terminal> <parameter=command> sed -n '2290,2380p' src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me continue to view the applyAgentStatus function to see where setAgentStatus is called.
Assistant
I see that
setAgentStatusis called on line 2294 with thetitlefromresolvePaneKey. According to the issue, I need to create aresolveAgentStatusTerminalTitlefunction that reconciles the terminal title with the agent status. When the agent is done, the title should be changed to "Cursor ready" for Cursor agents.Now I understand the issue:
- When a Cursor CLI agent finishes, the
statebecomes 'done' - The terminal title may still be showing a loading/working state
- I need to implement a resolver function that changes the title to appropriate states based on the agent type and state
Let me now:
- Create the
resolveAgentStatusTerminalTitlefunction insrc/renderer/src/lib/agent-status-terminal-title.ts - Call this function before storing the title in the
setAgentStatuscall
Let me first look at what test file might exist for this feature:
<tool_call> <function=bash_terminal> <parameter=command> find . -name "agent-status-terminal-title" 2>/dev/null </tool_call>
- When a Cursor CLI agent finishes, the
Assistant
Let me use bash_terminal to search for the agent-status-terminal-title file.
Assistant
The file doesn't exist yet. Based on the issue description, I need to create the
agent-status-terminal-title.tsfile with theresolveAgentStatusTerminalTitlefunction. Let me create this file:Assistant
Now I need to update the
applyAgentStatusfunction inuseIpcEvents.tsto call theresolveAgentStatusTerminalTitlefunction before storing the title. Let me modify the file to import and use the resolver.First, let me view the current import section to see where to add the import:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '1,100p' src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me view the import section of useIpcEvents.ts to see where to add the import for the resolver function.
Assistant
Now I need to add the import for the resolver function and then modify the
applyAgentStatusfunction to use it. Let me add the import first:<tool_call> <function=bash_terminal> <parameter=command> sed -i '68a import { resolveAgentStatusTerminalTitle } from '''@/lib/agent-status-terminal-title'''' src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me try using bash_terminal function to add the import.
Assistant
The sed command didn't work properly. Let me try a different approach using the edit function to add the import properly.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '65,75p' src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
The sed command might have had issues with escaping. Let me check the current state of the file around line 68 to see if the import was added correctly, and if not, I'll use a different approach.
Assistant
The sed command broke the file. Let me restore it and try a different approach:
Assistant
Let me use the bash terminal's edit command to properly add the import. I'll look at the file structure first to find a good place to add the import:
Assistant
Now I see a good place to add the import. I'll add it after the agent-status-identity import (around line 55). Let me use the bash_terminal command with proper escaping.
Assistant
Let me use the sed command with proper escaping to insert the import after line 55.
Assistant
The import command succeeded but I need to check if it worked properly. Let me view the file to see if the import was added correctly.
Assistant
The import was added correctly. Now I need to modify the
applyAgentStatusfunction to use the resolver. Let me find the line wheresetAgentStatusis called:Assistant
Now let me see the context around line 2295 to understand how to modify it:
Assistant
I need to modify the call to
setAgentStatusto pass the resolved title. Let me look at whattitlevariable is and how to use the resolver.<tool_call> <function=bash_terminal> <parameter=command> sed -n '2210,2230p' src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me view the section of the file where the
titlevariable is assigned to understand its context better.Assistant
Let me look at where
titleis assigned fromresolvePaneKey:<tool_call> <function=bash_terminal> <parameter=command> sed -n '2205,2215p' src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me continue to view the code to find where
titleis assigned.Assistant
Let me see where
statusPayloadis created and use the resolver to get the resolved title.<tool_call> <function=bash_terminal> <parameter=command> sed -n '2250,2295p' src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me continue to view the code to find where statusPayload is created and then I can use the resolver.
Assistant
Now I can see the structure. The
statusPayloadcontains theagentTypeandstate, andtitleis the current title fromresolvePaneKey. I need to:- Create a payload object with
agentTypeandstatefromstatusPayload - Call
resolveAgentStatusTerminalTitlewith this payload and the currenttitle - Use the resolved title in the
setAgentStatuscall
Let me modify the code to use the resolver. I'll add a line to compute the resolved title and then use it in the
setAgentStatuscall.<tool_call> <function=bash_terminal> <parameter=command> sed -i '2294a\ // Apply terminal title resolver for synthetic-title profiles\n const resolvedTitle = resolveAgentStatusTerminalTitle(\n { agentType: statusPayload.agentType, state: statusPayload.state },\n title\n );' src/renderer/src/hooks/useIpcEvents.ts </tool_call>
- Create a payload object with
Assistant
Let me try a different approach - I'll first add the resolved title calculation on one line, then update the setAgentStatus call to use it.
Assistant
Let me try using a Python script to make the edits since sed is being difficult with multi-line edits.
<tool_call> <function=bash_terminal> <parameter=command> python3 << 'PYEOF' import re
with open('src/renderer/src/hooks/useIpcEvents.ts', 'r') as f: content = f.read()
Find and replace the setAgentStatus call to use resolvedTitle
old_code = '''store.setAgentStatus(data.paneKey, statusPayload, title, { updatedAt: data.receivedAt, stateStartedAt: data.stateStartedAt })'''
new_code = ''' // Apply terminal title resolver for synthetic-title profiles const resolvedTitle = resolveAgentStatusTerminalTitle( { agentType: statusPayload.agentType, state: statusPayload.state }, title ) store.setAgentStatus(data.paneKey, statusPayload, resolvedTitle, { updatedAt: data.receivedAt, stateStartedAt: data.stateStartedAt })'''
content = content.replace(old_code, new_code)
with open('src/renderer/src/hooks/useIpcEvents.ts', 'w') as f: f.write(content)
print("Successfully updated setAgentStatus call") PYEOF </tool_call>
Assistant
The Python script approach might work. Let me try running it.
Assistant
Let me try using node instead:
Assistant
The update succeeded. Let me verify the change was made correctly:
Assistant
There's a minor indentation issue (the comment has extra leading spaces). Let me fix that:
<tool_call> <function=bash_terminal> <parameter=command> node << 'NODEEOF' const fs = require('fs');
const filePath = 'src/renderer/src/hooks/useIpcEvents.ts'; let content = fs.readFileSync(filePath, 'utf8');
// Fix the indentation issue - extra spaces before the comment const oldCode =
// Apply terminal title resolver for synthetic-title profiles const resolvedTitle = resolveAgentStatusTerminalTitle(;const newCode =
// Apply terminal title resolver for synthetic-title profiles const resolvedTitle = resolveAgentStatusTerminalTitle(;const updatedContent = content.replace(oldCode, newCode);
fs.writeFileSync(filePath, updatedContent);
console.log("Successfully fixed indentation"); NODEEOF </tool_call>
Assistant
Let me fix the indentation properly:
Assistant
The indentation is slightly off. Let me fix it properly by using sed to change the specific line:
<tool_call> <function=bash_terminal> <parameter=command> sed -i '2295s/ // Apply terminal title resolver/ // Apply terminal title resolver/' src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me try using bash_terminal with a more direct approach:
<tool_call> <function=bash_terminal> <parameter=command> sed -i '2295s/^ // Apply terminal title resolver/ // Apply terminal title resolver/' src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
Let me check the current state of the file and see if the indentation fix worked.
Assistant
The indentation still isn't fixed. Let me try using the bash_terminal with proper escaping to fix the line:
<tool_call> <function=bash_terminal> <parameter=command> sed -i '2295s/^ /\t /' src/renderer/src/hooks/useIpcEvents.ts 2>&1 || true </tool_call>
Assistant
The sed command didn't work because of the escaping issue. Let me use a different approach - I'll recreate the specific section of the file correctly.
Assistant
The indentation is wrong. Let me fix it by using a more direct bash approach to replace the specific line:
<tool_call> <function=bash_terminal> <parameter=command> head -2294 src/renderer/src/hooks/useIpcEvents.ts > /tmp/part1.ts tail -n +2295 src/renderer/src/hooks/useIpcEvents.ts | tail -n +2 > /tmp/part2.ts cat > /tmp/new_line.txt << 'EOF' // Apply terminal title resolver for synthetic-title profiles const resolvedTitle = resolveAgentStatusTerminalTitle( EOF cat /tmp/part1.ts /tmp/new_line.txt /tmp/part2.ts > src/renderer/src/hooks/useIpcEvents.ts </tool_call>
Assistant
The bash command approach is too complex. Let me try a simpler sed command without quotes.
Assistant
Let me verify the fix worked:
Assistant
There's a duplicate line. Let me restore the file and redo this properly:
Assistant
Let me try a more careful approach using node with proper file manipulation:
Assistant
Let me try using a JavaScript file instead of an inline script:
Assistant
Let me verify the changes are correct now:
Assistant
The import was added correctly. Now let me check the setAgentStatus call:
Assistant
The indentation on the comment line is still wrong. Let me fix that:
Assistant
Let me verify the fix:
Assistant
Now let me verify the new file I created:
Assistant
The file looks good. Now let me check if there are any tests that need to pass. Let me first check if there's an existing test file for agent-status:
Assistant
Let me check if there are any test files related to the useIpcEvents.ts file:
Assistant
Now let me run the tests to make sure my changes don't break anything. First, let me check the test file to see if there are any tests related to agent status:
Assistant
Let me check if there's a package.json to see how to run tests:
Assistant
Now let me try to build or at least type-check the code to make sure there are no type errors:
<tool_call> <function=bash_terminal> <parameter=command> npx tsc --noEmit -p tsconfig.json 2>&1 | head -50 </tool_call>
Assistant
Let me try running the type checking with the proper bash_terminal command.
Assistant
The type check didn't report any errors! Let me try a more comprehensive check:
<tool_call> <function=bash_terminal> <parameter=command> npx tsc --noEmit -p tsconfig.json 2>&1 </tool_call>
Assistant
Let me run the tests to make sure everything works:
Assistant
The test took too long. Let me just check if the build works without running the full test suite. Let me also check for any obvious issues in the code.
Assistant
The integration looks correct. Let me also verify the type definitions match what I expect. Let me check the type of the imported function:
Assistant
The code looks good. Now let me create a simple test to verify the functionality. But first, let me verify the changes I made by looking at the git diff:
Assistant
This is correct. Now let me check if there are any test files for the resolver function that I need to update or create:
<tool_call> <function=bash_terminal> <parameter=command> ls -la src/renderer/src/lib/agent-status-terminal-title* 2>/dev/null </tool_call>
Assistant
Let me list the files I created to verify they exist:
Assistant
The file exists. Now let me verify the complete implementation by checking the full diff:
<tool_call> <function=bash_terminal> <parameter=command> git status </tool_call>
Assistant
Let me use the bash_terminal command to check the git status.
Assistant
Perfect. I have made the following changes:
- Created a new file
src/renderer/src/lib/agent-status-terminal-title.tswith theresolveAgentStatusTerminalTitlefunction - Modified
src/renderer/src/hooks/useIpcEvents.tsto import and use the resolver function
Let me verify the implementation is complete by reviewing the changes once more. Let me also check if there might be other places where
setAgentStatusis called that need to be updated:<tool_call> <function=bash_terminal> <parameter=command> grep -r "setAgentStatus" src --include=".ts" --include=".tsx" | grep -v "test.ts" | grep -v "node_modules" </tool_call>
- Created a new file
Assistant
Let me search for other places where setAgentStatus is called to ensure I've covered all the necessary locations.
Assistant
Let me check if there are any TypeScript errors by running a quick type check on the files I modified:
Assistant
No TypeScript errors were reported. Let me also verify the integration by checking if the import path is correct:
Assistant
The import looks correct. The
@/lib/agent-status-terminal-titleis using the@alias which maps tosrc/renderer/src/. Since the file is atsrc/renderer/src/lib/agent-status-terminal-title.ts, the import path@/lib/agent-status-terminal-titleis correct.Now let me verify the complete solution by reviewing the changes once more. I should also check if there are any edge cases I might have missed.
Looking at my implementation in
agent-status-terminal-title.ts, the logic covers:- Non-Cursor agents: Returns the current title unchanged
- Empty/null title: Returns "Cursor ready" for done state, undefined otherwise
- "Cursor Agent" (bare native title): Returns "Cursor ready" for done state
- "Cursor - action required": Returns "Cursor ready" for done state
- Working/spinner titles: Returns "Cursor ready" for done, "Cursor - action required" for waiting/blocked
- Explicit "Cursor ready" or "Cursor - action required" titles: Preserved as-is
- Other Cursor titles in done state: Returns "Cursor ready"
Assistant
Let me verify the implementation is correct by checking the relevant section of the code:
Assistant
The implementation is complete. Let me verify the complete changes one more time:
Assistant
Let me also verify the newly created file exists:
Assistant
Let me verify that the full implementation is correct by reviewing all the changes once more:
Assistant
The implementation looks correct. Let me summarize what I've done:
-
Created
src/renderer/src/lib/agent-status-terminal-title.tswith theresolveAgentStatusTerminalTitlefunction that:- Only applies to Cursor agents (other agents are preserved as-is)
- Maps 'done' state titles to "Cursor ready" for working/permission/bare native titles
- Maps 'waiting' or 'blocked' state titles to "Cursor - action required"
- Detects working titles (braille spinners, "working"/"thinking"/"running"/"processing" keywords)
- Preserves explicit "Cursor ready" or "Cursor - action required" titles
- Has helper functions for detecting spinner characters and working keywords
-
Modified
src/renderer/src/hooks/useIpcEvents.tsto:- Import the
resolveAgentStatusTerminalTitlefunction - Call the resolver before storing the terminal title in
setAgentStatus
- Import the
-
Assistant
I need to use the submit tool to submit my changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.