Skip to content

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

Open
cbb330 wants to merge 7 commits intowesm:mainfrom
cbb330:fix/cursor-session-paths-20260401
Open

feat: support Cursor agent in history with resume and workspace recovery#263
cbb330 wants to merge 7 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

cbb330 added 5 commits April 1, 2026 17:00
Support Cursor's nested transcript layout and workspace metadata so imported sessions can reopen and resume from the right project state without broken Ghostty launches or stale path aliases.

Made-with: Cursor
Backtrack Cursor's encoded workspace resolution and use the last recorded working directory as a hint so resume chooses the right project when flattened path tokens collide. Also share the JSONL scanning path for cwd extraction to reduce duplication and remove the shadowed loop variable.

Made-with: Cursor
Compute Cursor's last working directory once per resume request and reuse it for both launch cwd and workspace resolution so large transcripts are not scanned repeatedly. Remove the unused Cursor directory wrapper helpers and cover the precomputed resume-path flow with a focused unit test.

Made-with: Cursor
Resolve Cursor workspaces from the encoded transcript path first and only read transcript contents when multiple filesystem matches exist. Keep the existing resume cwd behavior while reducing unnecessary coupling between --workspace recovery and transcript scanning.

Made-with: Cursor
Route resume launch and workspace lookup through the same Cursor path helpers so the lazy ambiguity handling lives in one place. This removes duplicate handler logic and keeps future workspace disambiguation changes confined to a single flow.

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
Format copied Cursor resume commands with the backend cwd so command-only and launch-failure fallbacks stay runnable without changing the API command field. Also fall back --workspace to the last known cwd when Cursor workspace recovery cannot resolve a project root.

Made-with: Cursor
@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)

Normalize expected paths and encode Cursor fixture directories without invalid drive-letter separators so the resume suite passes consistently across macOS and Windows.

Made-with: Cursor
@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)

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.

1 participant