Skip to content

Fix Ghostty session restore launch path#1976

Open
Suda202 wants to merge 1 commit intofarion1231:mainfrom
Suda202:fix/ghostty-shell-launch
Open

Fix Ghostty session restore launch path#1976
Suda202 wants to merge 1 commit intofarion1231:mainfrom
Suda202:fix/ghostty-shell-launch

Conversation

@Suda202
Copy link
Copy Markdown

@Suda202 Suda202 commented Apr 9, 2026

Summary

  • launch Ghostty sessions through the user's shell instead of injecting raw terminal input
  • reuse the existing shell command builder so cwd handling matches other terminal integrations
  • remove the Ghostty raw-input helpers and replace the tests with shell-command assertions

Test plan

  • Set preferred terminal to Ghostty in cc-switch
  • Open a Claude session terminal from the session manager
  • Verify Ghostty opens directly into the resumed Claude Code session
  • Confirm Terminal.app behavior is unchanged

Closes #1975

🤖 Generated with Claude Code

Use Ghostty's shell execution path instead of injecting raw terminal input so Claude resume commands run reliably when opening a session terminal.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yovinchen
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a179c60ca7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


fn launch_ghostty(command: &str, cwd: Option<&str>) -> Result<(), String> {
let args = build_ghostty_args(command, cwd);
let full_command = build_shell_command(command, cwd);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid shell-expanding cwd in Ghostty launch

launch_ghostty now feeds cwd through build_shell_command and runs it via -c, which turns the path into shell-parsed text (cd "..." && ...). This regresses the previous --working-directory=<dir> behavior by allowing expansions/substitutions in directory names (for example $VAR or $(...)), so a crafted or unusual project path can execute unintended commands or resolve to the wrong directory when resuming a session. Pass the working directory as a dedicated Ghostty argument (or apply shell-safe literal escaping) instead of embedding it in a shell command string.

Useful? React with 👍 / 👎.

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.

Ghostty opens blank terminal instead of launching Claude Code

2 participants