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
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /orca, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure to understand the codebase and locate relevant files.
- Assistant
Let me explore more systematically.
- Assistant
Let me look at the issue description. The key parts are:
- There's a bug where the Cursor CLI agent stays in loading state after task completes.
- The evaluation contract says to create a function
resolveAgentStatusTerminalTitleat pathsrc/renderer/src/lib/agent-status-terminal-title.ts. - For Cursor,
donereplaces spinner/working titles, the bareCursor Agenttitle, and stale permission titles withCursor ready;waitingorblockedusesCursor - action required. - This resolver should be called before storing agent-status snapshot titles.
Let me explore the relevant directories.
- Assistant
Let me explore the renderer directory and the agent-status-related files.
- Assistant
Let me find the specific file mentioned in the issue:
src/renderer/src/lib/agent-status-terminal-title.ts - Assistant
The file
src/renderer/src/lib/agent-status-terminal-title.tsdoesn't exist yet. I need to create it. Let me understand the existing codebase first, particularly around agent status and terminal titles. - Assistant
Let me look at agent status types, the synthetic title profiles, and the IPC status integration to understand how things work.
- Assistant
Let me look at the existing agent status types and the synthetic title files:
- Assistant
Let me explore the relevant parts of the codebase more deeply to understand how agent status is processed in the renderer and how terminal titles are managed.
- Assistant
Let me look at the agent-detection shared module:
- Assistant
Now let me look at the agent-status store slice and IPC integration to understand where titles are stored:
- Assistant
Now let me look at the IPC integration for agent status to understand where terminalTitle gets stored:
- Assistant
Let me look at the IPC event handler where agent status is received, and also the pty-connection.ts where titles are used.
- Assistant
Let me search for the agent status IPC handling code:
- Assistant
Let me look at the context around that line.
- Assistant
Let me find where
titleis defined in this context: - Assistant
Now I understand the basic flow. Let me look at how
resolvePaneKeydetermines the title: - Assistant
Let me look at the resolvePaneKey function:
- Assistant
Let me continue reading the function:
- Assistant
Let me look at the agent-status-osc.ts file to understand how the title is handled:
- Assistant
Now let me look at the synthetic title visibility files:
- Assistant
Let me look at the synthetic title spinner file:
- Assistant
Let me look at the main process side to understand how agent status flows through IPC:
- Assistant
Let me look at the IPC agent-hooks file where agent status events are sent to the renderer:
- Assistant
Let me look at the cursor hook service to understand what titles Cursor uses:
- Assistant
Let me read the cursor hook service:
- Assistant
Let me look at the agent-hooks server.ts to understand how cursor hooks are processed and how the title is handled:
- Assistant
Let me search more broadly:
- Assistant
Let me look at the server.ts to understand the general pattern:
- Assistant
Let me look at more of the server.ts to understand how status entries are set:
- Assistant
Let me look at the area around line 706 where the status is set and the IPC payload is constructed:
- Assistant
Let me look at how
onAgentStatussends the IPC event and how terminalTitle is determined: IPC The listener fires on everyset()call. Let me find how the payload is built and sent. - Assistant
Let me look at the onAgentStatus callback and how titles are handled:
- Assistant
Now let me understand the IPC flow - how does the
onAgentStatuslistener connect to the renderer: - Assistant
Let me look at where the listener is set in the main index.ts:
- Assistant
Let me look at the context around line 593 where setListener is called:
- Assistant
Let me find the synthetic title profiles and the driveSyntheticTitleFromHook function:
- Assistant
Let me look at the synthetic title profiles:
- Assistant
Let me look at the driveSyntheticTitleFromHook function:
- Assistant
Now I understand the flow. Let me check the
setAgentStatusstore method more carefully: - Assistant
Let me look at the setAgentStatus implementation to understand how the terminalTitle is stored:
- Assistant
Now I have a good understanding. Let me look at how the synthetic title profiles on the main process side work:
- Assistant
Now I understand the issue. Let me look at the exact point where the title flows into setAgentStatus:
- Assistant
Now I understand the issue clearly. Let me check for existing tests related to this:
- Assistant
Let me look at the agent-status test to understand the testing patterns:
- Assistant
Let me search for Cursor-related tests:
- Assistant
Now let me look at where the title comes from in the pty-connection.ts for the OSC fallback path:
- Assistant
Now I have a thorough understanding of the issue. Let me look at the lib directory to understand the structure:
- Assistant
Now I have a thorough understanding of the codebase. Let me now create the resolver function. The issue is a race condition where the IPC hook event arrives with
state: donebut the terminal title in the pane hasn't been updated by the synthetic title mechanism yet.Let me create the resolver file:
- Assistant
Now I need to integrate the resolver into the IPC status integration. Let me update
useIpcEvents.ts: - Assistant
Let me add the import for the resolver and use it:
- Assistant
Let me check the imports in useIpcEvents.ts:
- Assistant
Let me look at lines around 50-60:
- Assistant
Now let me add the import and modify the code where title is passed to setAgentStatus:
- Assistant
Let me look at the context around line 2294:
- Assistant
Now I need to add the import and use the resolver. Let me add the import first:
- Assistant
Now let me add the import and modify the setAgentStatus call:
- Assistant
Let me add the import after line 55:
- Assistant
Now let me modify the setAgentStatus call to use the resolver:
- Assistant
Now I need to modify this line to apply the resolver before passing the title. Let me look at the context:
- Assistant
Now I need to add the resolver call before the setAgentStatus. Let me edit:
- Assistant
Now let me also update the pty-connection.ts to apply the resolver for the OSC fallback path:
- Assistant
Let me look at the onAgentStatus callback in pty-connection.ts:
- Assistant
Let me look at the imports in pty-connection.ts:
- Assistant
Let me add the import and resolver call to pty-connection.ts:
- Assistant
Now let me add the import and modify the onAgentStatus callback:
- Assistant
Now let me modify the onAgentStatus callback to use the resolver:
- Assistant
Let me look at the context:
- Assistant
Let me modify the onAgentStatus callback to use the resolver:
- Assistant
I see there's a duplicate line. Let me fix it:
- Assistant
I see the old line is still there. Let me remove it:
- Assistant
I see there's still a duplicate. Let me fix it:
- Assistant
I see the duplicate. Let me fix it:
- Assistant
I see there's still a duplicate. Let me look more carefully:
- Assistant
There's still a duplicate line. Let me fix it properly:
- Assistant
Still a duplicate. Let me fix it:
- Assistant
There's still a duplicate line 1164. Let me fix:
- Assistant
I see a stray
}at line 1165. Let me fix: - Assistant
I see there's still an extra closing brace. Let me remove it:
- Assistant
I see there's still an extra
}at line 1167. Let me fix: - Assistant
There's now a duplicate line 1168. Let me fix:
- Assistant
These incremental edits are making a mess. Let me restore pty-connection.ts to original and redo the edit cleanly:
- Assistant
Good. Now let me verify the original state and make a clean edit:
- Assistant
Good. Now let me use sed to add the import after line 57:
- Assistant
Good. Now let me find the onAgentStatus callback and modify it:
- Assistant
Let me look at the original callback code:
- Assistant
Now I need to replace the line that calls setAgentStatus with the resolver. Let me use a targeted replacement:
- Assistant
Let me verify the edit:
- Assistant
The sed didn't work properly. Let me use the edit command instead:
- Assistant
Now let me use the edit command properly to replace line 1155:
- Assistant
Now let me verify both files look correct:
- Assistant
Good, pty-connection.ts looks correct. Let me verify useIpcEvents.ts:
- Assistant
Now let me check if there are other
setAgentStatuscalls that also pass terminal titles: - Assistant
Let me search more broadly:
- Assistant
Let me check the other setAgentStatus calls to see if they also need the resolver:
- Assistant
Good, these other calls use agentType 'command-code' which doesn't have a synthetic title profile, so the resolver passes through unchanged. Now let me run the existing tests:
- Assistant
The test failure is unrelated to my changes - it's about a missing package import in the test environment. Let me try running tests that are more directly relevant:
- Assistant
Good, those tests pass. Let me run the synthetic title visibility tests:
- Assistant
Let me run the synthetic title spinner tests:
- Assistant
Now let me verify the new file is correct and review all changes:
- Assistant
I notice the
STRONG_IDLE_KEYWORDS_REimport is unused. Let me remove it: - Assistant
I see the edit created a mess. Let me restore and redo properly:
- Assistant
The file isn't tracked by git yet. Let me recreate it properly:
- Assistant
Now let me verify the file is clean:
- Assistant
Let me verify the useIpcEvents.ts import is clean:
- Assistant
Let me verify the pty-connection.ts import:
- Assistant
Let me now check the full diff to see all changes:
- Assistant
The diff doesn't show the new file because it's not tracked by git. Let me also check the untracked files:
- Assistant
Now let me create a quick test script to verify the resolver function works correctly:
- Assistant
All 12 test cases pass. Let me now view the full diff to verify all changes:
- Assistant
I notice the diff removed the
const statusWorktreeId = data.worktreeId ?? owningWorktreeIdline. Let me check if this is a problem: - Assistant
Let me check if
statusWorktreeIdis declared earlier in the function: - Assistant
I see the issue - the
const statusWorktreeId = data.worktreeId ?? owningWorktreeIdline was removed! Let me check the original code: - Assistant
I see the issue - the
const statusWorktreeIdline was accidentally deleted. Let me fix this: - Assistant
I see there's still a mess. Let me fix the whole block properly:
- Assistant
Good, now let me verify the full diff is clean:
- Assistant
The diff is clean now. Let me verify all changes:
- Assistant
Let me also verify the new file:
- Assistant
Let me run the available tests to make sure nothing is broken:
- Assistant
All tests pass. Let me also run the agent-status store tests:
- Assistant
The store tests fail due to missing packages (unrelated to my changes). Let me verify my changes are clean by looking at the complete state:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →