Skip to content

feat: auto-detect terminal for session resume with settings override#26

Merged
graydawnc merged 1 commit intomainfrom
feat/terminal-detection
Mar 31, 2026
Merged

feat: auto-detect terminal for session resume with settings override#26
graydawnc merged 1 commit intomainfrom
feat/terminal-detection

Conversation

@graydawnc
Copy link
Copy Markdown
Collaborator

Summary

Session resume previously always opened macOS Terminal.app. This PR adds:

  • Auto-detection of the user's terminal — checks which third-party terminal is currently running (iTerm2, Warp, Kitty, Alacritty, WezTerm) and uses it for session resume. Falls back to Terminal.app if none are detected.
  • Manual terminal preference in Settings — users can override auto-detection by selecting a specific terminal from a dropdown. If the chosen terminal isn't installed, falls back gracefully to auto-detect.
  • Session cwd support — resume now opens the terminal in the session's original working directory, not the home directory.

How it works

Terminal detection (packages/app/src/main/terminal.ts)

  • New module with per-terminal execution strategies:
    • Terminal.app / iTerm2: AppleScript (official scripting dictionaries)
    • Kitty / Alacritty / WezTerm: CLI arguments (open -a <app> --args)
    • Warp: Launch Configurations — writes a temporary YAML config to ~/.warp/launch_configurations/ and opens it via warp://launch/ URI scheme (Warp's official API, no Accessibility permissions needed)
  • Auto-detection runs osascript -e 'application "X" is running' for each known third-party terminal, cached for the process lifetime
  • Installation check via existsSync on /Applications/<app>.app prevents selecting a terminal that isn't installed

Settings UI (packages/app/src/renderer/components/SettingsPanel.tsx)

  • New "Terminal" section with a dropdown: Auto-detect / Terminal / iTerm2 / Warp / Kitty / Alacritty / WezTerm
  • Persisted in ~/.spool/agents.json as terminal field in AgentsConfig
  • Refactored three duplicate config-save handlers (selectAgent, selectTerminal, selectDefaultSearchSort) into a single updateConfig function

Session cwd (packages/core/src/types.ts, packages/core/src/db/queries.ts)

  • Added cwd field to FragmentResult (from sessions.cwd column, not projects.display_path)
  • Resume now uses the session's actual working directory, fixing cases where the project record has a stale path

Files changed

File Change
packages/app/src/main/terminal.ts New — terminal detection, per-terminal runners, openTerminal()
packages/app/src/main/index.ts Resume handler delegates to openTerminal() with cwd and preference
packages/app/src/main/acp.ts Added terminal to AgentsConfig
packages/app/src/preload/index.ts Added terminal to config, cwd to resumeCLI
packages/app/src/renderer/components/SettingsPanel.tsx Terminal dropdown + refactored config save
packages/app/src/renderer/components/ContinueActions.tsx Pass result.cwd to resumeCLI
packages/core/src/types.ts Added cwd? to FragmentResult
packages/core/src/db/queries.ts Added sess.cwd to search query

Test plan

  • Terminal.app resume works
  • Warp resume works (via Launch Configurations)
  • Settings dropdown persists terminal preference
  • Session opens in correct working directory
  • Selecting an uninstalled terminal falls back to auto-detect
  • iTerm2 / Kitty / Alacritty / WezTerm (not installed locally, uses standard APIs)

🤖 Generated with Claude Code

…ssion resume

Previously, session resume always opened macOS Terminal.app via AppleScript.
This change detects the user's preferred terminal automatically and adds a
manual override in Settings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@graydawnc graydawnc merged commit 0e075a0 into main Mar 31, 2026
3 checks passed
@doodlewind doodlewind deleted the feat/terminal-detection branch April 7, 2026 09:47
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