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 understanding the issue and exploring the repository structure. The issue is about a Cursor CLI agent staying in a loading state after completing its task. I need to:
- Explore the repository structure
- Find the relevant files, especially
src/renderer/src/lib/agent-status-terminal-title.ts - Understand how the agent status is managed
- Implement the fix according to the evaluation contract
Let me start exploring.
Assistant
The file doesn't exist yet at
src/renderer/src/lib/agent-status-terminal-title.ts. Let me search for it and also explore the relevant files.Assistant
The file
agent-status-terminal-title.tsdoesn't exist yet. Let me explore the existing agent status related files to understand the pattern and then create the resolver function.Assistant
Let me read the agent-status-types.ts to understand the data structures, and then look at the IPC integration to understand where the title is stored.
Assistant
Good, I can see the
AgentStatusStatecan be 'working', 'blocked', 'waiting', or 'done', andAgentTypeincludes 'cursor'. Now let me look at the IPC integration to understand where the terminal title is stored, and also look at the synthetic title profiles.Assistant
Now let me look at where
setAgentStatusis called (IPC integration) and also look at the existing agent status logic:Assistant
Let me look at where
setAgentStatusis called in pty-connection.ts to see where the terminal title is passed:Assistant
Let me look at the pty-connection.ts file more carefully to understand where the terminal title comes from and how it's passed to setAgentStatus.
Assistant
Now let me look at where
setAgentStatusis called with the title at line 1154, and understand how the title flows. Let me also look for the IPC handler that handlesagentStatus:set.Assistant
Now let me look at the agent-status hooks and how terminal titles relate to the agent status. Let me also search for the synthetic-title related files:
Assistant
Now let me look for where the terminal title is managed and where there's a synthetic-title profile for Cursor:
Assistant
Let me look at the Cursor synthetic-title profile and surrounding code more closely:
Assistant
Now let me understand how the terminal title is stored and where the resolver should be applied. Let me look at the agent-status slice's
setAgentStatusmore closely:Assistant
Now I have a good understanding of the system. The issue is that when a Cursor CLI agent reports
donestate, the terminal title still shows a "working" title like "Cursor Agent" instead of "Cursor ready". The resolver functionresolveAgentStatusTerminalTitleshould be applied before storing the terminal title in the agent-status entry.Let me look at how the title flows from the PTY connection to see where to apply the resolver:
Assistant
Let me also look at how the agent status tests are structured to understand the test pattern:
Assistant
Now I have a clear understanding of the issue. Let me trace through the code flow:
- The Cursor CLI agent reports
state: 'done'via OSC 9999 - The
onAgentStatuscallback gets the current runtime pane title (which may still be "Cursor Agent" — the working title) - The entry stores this stale working title even though the state is 'done'
The fix is to create a
resolveAgentStatusTerminalTitleresolver that reconciles the reported state with the terminal title, and call it before storing. Let me first look at existing test files to understand patterns:- The Cursor CLI agent reports
Assistant
Now I have a clear understanding. Let me read the agent-status.ts in the lib to understand the working indicators:
Assistant
Now let me look at how existing tests are structured for this module:
Assistant
Now I have a thorough understanding of the codebase. Let me now create the resolver function and implement the fix. The plan is:
- Create
src/renderer/src/lib/agent-status-terminal-title.tswith theresolveAgentStatusTerminalTitlefunction - Create a test file
src/renderer/src/lib/agent-status-terminal-title.test.ts - Update the pty-connection.ts to call the resolver before storing
- Update the agent-status slice to also apply the resolver
Let me first look at what values the agent detection considers as "working" for cursor:
- Create
Assistant
Now I have a complete understanding. Let me create the resolver function. The key insight is:
- For Cursor agent with
state === 'done': replace spinner/working titles, bare "Cursor Agent", and stale permission titles with "Cursor ready" - For Cursor agent with
state === 'waiting'orstate === 'blocked': use "Cursor - action required" - Preserve descriptive completed titles and titles from agents without a synthetic-title profile
- For Cursor agent with
Assistant
Now let me create a test file for the resolver:
Assistant
Now let me run the tests to make sure they pass:
Assistant
The test failure reveals an important design point. Re-reading the evaluation contract: "
waitingorblockedusesCursor - action required" — this means for waiting/blocked states, the permission label should always be applied (not just when not already set). Let me fix the implementation and the test:Assistant
Now I need to update the test to match the new behavior for waiting/blocked state. According to the evaluation contract, "waiting or blocked uses Cursor - action required" — so for waiting/blocked states, the permission label is always applied (not just when not already set), and descriptive titles are replaced.
Let me fix the test.
Assistant
The test file was updated. Let me run the tests again to verify they all pass.
Assistant
All 30 tests pass. Now I need to integrate the resolver into the pty-connection.ts file, which is the IPC status integration point. Let me look at the exact import path and where to add the resolver call.
Assistant
Now I need to integrate the resolver into the pty-connection.ts file. The key place is the
onAgentStatuscallback where the title is fetched and passed tosetAgentStatus. Let me add the import and modify the code:Assistant
Now let me add the import and modify the
onAgentStatushandler:Assistant
Now I need to add the import for
resolveAgentStatusTerminalTitleand modify theonAgentStatushandler to use it. Let me first find the right place in the imports to add it.Assistant
Let me add the import and modify the
onAgentStatushandler:Assistant
I need to use the edit command with the correct syntax. Let me use the line range to insert the import.
Assistant
I need to use the edit command properly. Let me insert the import line after the terminal-color-scheme-protocol import.
Assistant
Let me use sed to insert the import line:
Assistant
Let me verify the import was added correctly:
Assistant
Good, the import was added. Now I need to modify the
onAgentStatuscallback to use the resolver. Let me find its current location:Assistant
Now I need to modify the onAgentStatus callback to use the resolver. Let me look at the current code and plan the replacement.
Assistant
Now I need to modify the
onAgentStatuscallback to apply the resolver before storing. The key change is:- After getting the current title from the store, apply the resolver to reconcile it with the payload state
- Pass the resolved title to setAgentStatus
Let me use the bash
sedcommand to make this change:Assistant
Let me check if that worked:
Assistant
The sed didn't work due to complex regex. Let me try a different approach - I'll view the exact lines and edit them more precisely.
Assistant
The sed command didn't work. Let me use the
replacetool instead to make the change. I need to replace:const title = currentState.runtimePaneTitlesByTabId?.[deps.tabId]?.[pane.id]with:
const rawTitle = currentState.runtimePaneTitlesByTabId?.[deps.tabId]?.[pane.id] const title = resolveAgentStatusTerminalTitle(payload, rawTitle)Assistant
I need to specify the file path in the replace command. Let me use the --file option.
Assistant
Let me use the heredoc syntax for multi-line replacement.
Assistant
Let me navigate to that line first and then try the replacement again.
Assistant
I can see the code at line 1154. Let me use the bash edit command to replace lines 1153-1155 with the new code.
Assistant
Good, the edit was applied correctly. Now I need to also fix the other call sites in pty-connection.ts that call
setAgentStatuswith a terminal title. Let me check them:Assistant
Let me check the other call sites to ensure they also apply the resolver:
Assistant
The
applyInitialAgentStatusfunction at line 768-777 passes aterminalTitleparameter that was already provided to the function. Since this function is called when a pane starts up, and the title is the raw terminal title, we need to apply the resolver here too.But wait - looking at the function, it's called with state 'working', and our resolver only applies changes for 'done', 'waiting', 'blocked' states (not 'working'). So the title will be preserved as-is for 'working' state.
However, looking more carefully, the function is called when initial agent status is provided. Let me check where this function is called from:
Assistant
Let me re-check my implementation. The resolver function should work correctly:
- For 'working' state, it returns the currentTitle unchanged
- For 'done' state, it replaces spinner/working/permission titles with idleLabel
- For 'waiting'/'blocked' state, it sets permissionLabel
So the
applyInitialAgentStatus(which sets 'working' state) andseedCommandCodeOutputWorkingStatus(also 'working') don't need changes because the resolver preserves the title for 'working' state.The only place where the state might be 'done', 'waiting', or 'blocked' is the
onAgentStatuscallback at line 1156, which I've already modified.But wait, there's also the
scheduleCommandCodeOutputDoneStatusfunction that might set 'done' state. Let me check:Assistant
This is the
scheduleCommandCodeOutputDoneStatusfunction which sets state to 'done' for command-code agent. The resolver will preserve titles for 'command-code' since it has no synthetic-title profile.Let me also check the
applyInitialAgentStatusfunction. It's passed aterminalTitleparameter. Let me see where it's called:Assistant
The
applyInitialAgentStatusfunction is called without a terminalTitle argument. Looking at the function signature:const applyInitialAgentStatus = (terminalTitle?: string): void => {It's called with
applyInitialAgentStatus()(no arguments). So the terminalTitle will be undefined. This is fine because:- The state is 'working', and our resolver preserves titles for 'working' state
- Even without the resolver, the setAgentStatus function preserves the existing terminalTitle when undefined
Let me now run the existing tests to make sure nothing broke.
Assistant
All 30 tests pass. Now let me run the existing agent-status tests to make sure nothing broke:
Assistant
The test failure is a pre-existing infrastructure issue (missing import path for
onboarding-folder-agent-startup), not related to my changes. Let me verify my changes compile correctly by checking TypeScript compilation:Assistant
TypeScript compilation passed with no errors. Let me also check if there are other IPC integration points where the resolver should be applied:
Assistant
Let me check the
useIpcEvents.tsfile, which is another IPC integration point:Assistant
Let me see more context around this IPC integration point:
Assistant
Let me find where the
titlevariable is defined in this context:Assistant
Let me look at the broader context to find where the title is defined for the
setAgentStatuscall around line 2294:Assistant
The current file shown is still pty-connection.ts but I'm trying to look at useIpcEvents.ts. Let me open that file instead.
Assistant
The user seems to have sent an empty response. Let me continue with my work. I was in the middle of finding where the
titlevariable is defined inuseIpcEvents.ts. Let me search for it properly.Assistant
Let me look at the handler context around line 2294 in useIpcEvents.ts:
Assistant
Let me continue looking at the
useIpcEvents.tsfile to find where thetitlevariable comes from:Assistant
I found the second IPC integration point. The
applyAgentStatusfunction inuseIpcEvents.tsalso callsstore.setAgentStatuswith atitlethat comes fromresolvePaneKey. This title needs to be resolved through the resolver before storing.Let me first look at the other
setAgentStatuscall sites:Assistant
This
setAgentStatuscall passesundefinedfor the title, so it will preserve the existing title in the store. The resolver will returnundefinedfor agents without a profile, but for Cursor it would return "Cursor ready" for 'done' state. Since the title is explicitlyundefined, I should also apply the resolver here.Let me also check
launch-agent-background-session.ts:Assistant
Both
automation-session-observer.tsandlaunch-agent-background-session.tscallsetAgentStatuswithundefinedfor the title. When the title isundefined, the resolver should still apply the profile-based default for the current state.Now I need to apply the resolver to all IPC integration points. The evaluation contract says: "The IPC status integration must call this resolver before storing agent-status snapshot titles."
Let me now update the
useIpcEvents.tsIPC integration point:Assistant
Let me continue updating the
useIpcEvents.tsfile to apply the resolver. First, let me find a good place to add the import.Assistant
Let me continue with the integration. I need to update the
useIpcEvents.tsfile to apply the resolver.Assistant
The current file is still pty-connection.ts but I need to edit useIpcEvents.ts. Let me open it first.
Assistant
I need to open the useIpcEvents.ts file first.
Assistant
Now let me understand the issue better. The
resolvePaneKeyfunction inuseIpcEvents.tsreturns atitlethat is used when callingsetAgentStatus. I need to apply the resolver there too.Looking at the code flow:
- In
applyAgentStatus,resolvePaneKeyreturns{ exists, title, identityTitle, ... } - The
titleis then passed tostore.setAgentStatus(data.paneKey, statusPayload, title, ...)
I need to apply
resolveAgentStatusTerminalTitlebetween getting the title and passing it tosetAgentStatus.Let me also handle the other IPC integration points:
automation-session-observer.ts: callssetAgentStatus(paneKey, payload, undefined)launch-agent-background-session.ts: callssetAgentStatus(paneKey, payload, undefined)
For these, the title is
undefined, so the resolver should return the profile-based default (e.g., "Cursor ready" for 'done' state).Let me continue editing the files. </tool_call>
- In
Assistant
Let me continue updating the remaining IPC integration points. I'll start with
useIpcEvents.ts.Assistant
Let me add the import to useIpcEvents.ts and update the setAgentStatus calls.
Assistant
Let me check if the import was added correctly:
Assistant
Good, the import was added. Now I need to update the
setAgentStatuscall inuseIpcEvents.tsto apply the resolver before storing the title. Let me find the exact line:Assistant
Let me view the context around line 2295 to understand how to apply the resolver.
Assistant
Let me continue. I need to update the
setAgentStatuscall inuseIpcEvents.tsto apply the resolver before storing the title. Thetitlevariable comes fromresolvePaneKeyand I need to resolve it through the resolver first.Assistant
Now let me update the
useIpcEvents.tsfile to apply the resolver before storing the title.Assistant
Let me check the result and update the setAgentStatus call to use resolvedTitle.
Assistant
Good, the resolvedTitle line was added. Now I need to update the setAgentStatus call to use resolvedTitle instead of title. Let me use sed to replace the line.
Assistant
Let me check the result.
Assistant
There's a double
{{issue. Let me fix it.Assistant
Let me fix the double brace issue properly.
Assistant
I need to fix the double brace issue on line 2296. Let me use sed to replace it properly.
Assistant
Let me verify the fix:
Assistant
Good, the fix is correct. Now I need to update the remaining IPC integration points. Let me update
automation-session-observer.tsandlaunch-agent-background-session.tsto apply the resolver.Assistant
Let me update
automation-session-observer.tsto apply the resolver:Assistant
I need to update the
automation-session-observer.tsfile to apply the resolver before storing. Let me also check the line number for thesetAgentStatuscall.Assistant
Let me update the automation-session-observer.ts file:
Assistant
Let me update the automation-session-observer.ts to apply the resolver:
Assistant
Let me check the result:
Assistant
Now let me update
launch-agent-background-session.ts:Assistant
Let me add the import and update the setAgentStatus calls in
launch-agent-background-session.ts:Assistant
Let me check the line numbers again since I added an import:
Assistant
The current file is still pty-connection.ts, but I need to edit launch-agent-background-session.ts. Let me verify the changes I'm making are correct by checking the file contents. Let me verify the changes are correct:
Assistant
Now I need to update line 220 in
launch-agent-background-session.ts:Assistant
I need to update the
setAgentStatuscall at line 220 inlaunch-agent-background-session.ts. Let me apply the resolver there. Let me update line 220 inlaunch-agent-background-session.ts:Assistant
Let me verify the changes:
Assistant
Now let me verify TypeScript compilation passes:
Assistant
TypeScript compilation passed. Let me run the tests to make sure everything still works:
Assistant
Let me also check if
launch-agent-in-new-tab.tsneeds updating:Assistant
Let me check the context of this call:
Assistant
This call is setting state to 'working' and doesn't pass a terminalTitle (which means it will preserve the existing title). Since the state is 'working', the resolver would return the title unchanged. So no changes needed here.
Assistant
The test failures are all pre-existing infrastructure issues (missing packages like
@/lib/agent-session-fork-context,@/lib/pane-manager/mint-stable-pane-id, etc.) and not related to my changes. These are pre-existing issues in the test environment.Let me verify that my specific changes work correctly by running only the tests for my new file:
Assistant
Let me verify the complete solution by reviewing all the changes I've made:
Assistant
Let me verify the complete solution by reviewing the git diff:
Assistant
Now let me verify all the changes are complete. Let me review the created files and make sure everything is in order:
Assistant
Let me summarize the solution and verify everything is complete.
Summary of Changes
Issue
Cursor CLI agent session UI stays in loading state after the agent completes its task. The terminal title continues to show a working spinner title like "Cursor Agent" even after the agent reports
donestate.Solution
Created a
resolveAgentStatusTerminalTitleresolver function that reconciles hook-reported state with synthetic terminal-title profiles, and integrated it into all IPC status integration points.Files Created
-
src/renderer/src/lib/agent-status-terminal-title.ts- The resolver function that:- For Cursor (and other agents with synthetic-title profiles): Maps stale/working titles to the correct idle label when state is
done - For / states: Sets the permission label ("Cursor - action required")
- For Cursor (and other agents with synthetic-title profiles): Maps stale/working titles to the correct idle label when state is
-
Assistant
Let me do a final verification of all changes and the TypeScript compilation:
Assistant
I have completed the solution. Let me submit the changes.
Assistant
The submit command was called but it seems there was an issue with the argument parsing. Let me try again with the correct format.
Assistant
The submit command seems to not be working properly with the empty arguments. Let me try a different approach.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.