Skip to content

feat: support Cursor agent in history with resume and workspace recovery#263

Merged
wesm merged 3 commits intowesm:mainfrom
cbb330:fix/cursor-session-paths-20260401
Apr 6, 2026
Merged

feat: support Cursor agent in history with resume and workspace recovery#263
wesm merged 3 commits intowesm:mainfrom
cbb330:fix/cursor-session-paths-20260401

Conversation

@cbb330
Copy link
Copy Markdown
Contributor

@cbb330 cbb330 commented Apr 2, 2026

Summary

  • add Cursor agent resume support end-to-end, including frontend command generation, server-side resume handling, and macOS terminal launch behavior for Ghostty and other openers
  • support Cursor agent's nested transcript layout during discovery/sync and recover workspace roots plus terminal cwd from Cursor transcript metadata, with lazy ambiguity handling so --workspace only needs transcript scanning when multiple filesystem matches exist
  • add regression coverage for nested transcripts, workspace path ambiguity, symlink normalization, command_only resume output, and Ghostty AppleScript launch behavior

Test plan

  • CGO_ENABLED=1 go test -tags fts5 ./internal/server/...
  • go vet ./...
  • make build
  • Manual: resume a Cursor agent session from the UI and verify terminal cwd plus --workspace
  • Manual: verify Ghostty opens a fresh terminal and does not restore stale saved tabs

Made with Cursor

@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Apr 2, 2026

roborev: Combined Review (dd0aa8b)

Verdict: 2 medium-severity issues should be addressed before merge.

Medium

  • internal/server/resume.go (handleResumeSession, command_only response path)
    Cursor resumes depend on launchDir to preserve the prior shell working directory, but the command_only response returns only cursor agent --resume ... --workspace ... and leaves the directory in a separate cwd field. Any caller that executes or copies only command can resume from the wrong directory.
    Suggested fix: make the returned command self-contained, for example by prepending cd <launchDir> && ... when launchDir is known, or guarantee that clipboard/command-only consumers also apply cwd.

  • internal/server/resume.go (resumeLaunchCwd, used from handleResumeSession)
    On macOS, resumeLaunchCwd clears the launch directory for Cursor when using auto, iTerm2, Terminal, or Ghostty. If workspace resolution fails but launchDir is still available from the transcript, the launch loses the only known directory context and starts from the terminal’s default directory instead.
    Suggested fix: preserve launchDir unless there is a confirmed equivalent cwd mechanism, or prepend cd <launchDir> && to the launched Cursor command.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@cbb330 cbb330 changed the title fix: support Cursor session resume and workspace recovery fix: support Cursor agent resume and workspace recovery Apr 2, 2026
@cbb330 cbb330 changed the title fix: support Cursor agent resume and workspace recovery feat: support Cursor agent in history with resume and workspace recovery Apr 2, 2026
@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Apr 2, 2026

roborev: Combined Review (525a200)

Verdict: No medium-or-higher issues found in the reviewed changes.

All review outputs that reported findings agreed the change is clean. The security review found no issues, and the general review found no medium, high, or critical concerns.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Apr 3, 2026

roborev: Combined Review (3c51a3f)

Verdict: One medium-severity regression needs to be addressed; no high or critical issues were identified.

Medium

  • internal/server/resume.go (handleResumeSession, resumeLaunchCwd): Cursor resumes launched on macOS via auto, iTerm2, Terminal.app, or Ghostty drop launchDir because resumeLaunchCwd() returns "" for those launchers. As a result, the AppleScript path runs cursor agent --resume ... --workspace <workspace> without restoring the last working directory, while the clipboard fallback still uses cd <last-working-dir> && .... This causes resumed sessions to reopen from the workspace root instead of the recorded shell directory, which can break relative-path behavior and undercuts the resume-path restoration added by this patch.
    Suggested fix: Preserve launchDir for Cursor macOS launches, or inject cd <launchDir> && into the AppleScript command while keeping --workspace <workspace> for workspace selection.

Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Apr 5, 2026

roborev: Combined Review (f5781c4)

Verdict: Changes are mostly sound, but there is one medium-severity issue that should be addressed before merge.

Medium

  • Race-prone command injection via macOS UI automation
    Files: internal/server/openers.go:304, internal/server/openers.go:348, internal/server/resume.go:808
    The new macOS Ghostty flow sends executable shell commands via synthetic System Events keystrokes after fixed delay 0.2 sleeps, without verifying that Ghostty is frontmost and ready. If activation/window creation is slow, denied, or focus changes between delays, the resume command can be typed into whichever app or terminal currently has focus, creating a realistic local command-injection-by-race condition.
    Suggested remediation: avoid UI keystroke injection for command delivery. Prefer a direct launch mechanism bound to the intended Ghostty process/window. If UI automation is unavoidable, explicitly target the created window/tab, poll for readiness instead of fixed sleeps, and abort unless target/focus verification succeeds immediately before typing.

Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Apr 5, 2026

roborev: Combined Review (ea7078a)

Verdict: No medium, high, or critical findings identified across the reviewed changes.

The combined reviews did not surface any actionable issues at Medium severity or above. Security review also reported no issues found.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@wesm wesm force-pushed the fix/cursor-session-paths-20260401 branch from ea7078a to f02e0c8 Compare April 5, 2026 22:58
@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Apr 5, 2026

roborev: Combined Review (f02e0c8)

Verdict: No medium-or-higher issues found in the reviewed diff.

The reviewed changes look clean. Multiple review passes found no Medium, High, or Critical findings to report.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

- fix: disambiguate cursor workspace paths
- fix: cache cursor resume path resolution
- fix: disambiguate cursor workspace lookup lazily
- refactor: share cursor resume path resolution
- fix: preserve Cursor resume cwd in fallbacks
- test: make resume tests portable on Windows
- fix: preserve Cursor macOS resume cwd
- fix: revert Ghostty to direct CLI, skip guess on ambiguous Cursor paths
- fix: prefer Ghostty CLI over app bundle, reject stale hints
- fix: normalize paths before hint validation in Cursor resolver
@wesm wesm force-pushed the fix/cursor-session-paths-20260401 branch from f02e0c8 to 261b8a5 Compare April 6, 2026 01:42
@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Apr 6, 2026

roborev: Combined Review (261b8a5)

No medium-or-higher issues found in the reviewed diff.

All reviewed findings were below the reporting threshold for this PR comment, so there are no Medium, High, or Critical issues to report.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

wesm and others added 2 commits April 5, 2026 20:45
buildResumeCommand now returns null for Cursor since the resume
command requires server-resolved --workspace and cwd parameters.
Without those, the copied fallback command points to the wrong
workspace. The server API path (formatResumeResponseCommand)
still builds the full command.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Guard the scroll assertion on the container being scrollable and
increase the poll timeout from 3s to 5s for slower webkit rendering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Apr 6, 2026

roborev: Combined Review (2381a42)

LGTM: no Medium, High, or Critical findings identified across the reviewed outputs.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@wesm wesm merged commit 72a21d3 into wesm:main Apr 6, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants