Skip to content

Harden Ghostty AppleScript integration#29

Merged
umputun merged 1 commit intoumputun:masterfrom
tkukushkin:fix/ghostty-improvements
Apr 5, 2026
Merged

Harden Ghostty AppleScript integration#29
umputun merged 1 commit intoumputun:masterfrom
tkukushkin:fix/ghostty-improvements

Conversation

@tkukushkin
Copy link
Copy Markdown
Contributor

@tkukushkin tkukushkin commented Apr 5, 2026

Summary

Follow-up to #28. Addresses Copilot review feedback and testing findings:

  • AppleScript injection fix: Pass shell variables via osascript argv (on run argv) instead of interpolating into AppleScript string literals — prevents breakage with paths containing double quotes or backslashes
  • Detection fix: Replace get version probe with command -v osascript — the probe succeeds even with macos-applescript = false, so it wasn't actually testing AppleScript availability
  • Temp file cleanup: Add EXIT trap for LAUNCH_SCRIPT and SENTINEL so they're cleaned up on signal interruption (Ctrl-C during sentinel polling)

Test plan

  • Run launch-revdiff.sh HEAD~1 from Ghostty — split, zoom, close on exit
  • Run with macos-applescript = false — osascript fails with descriptive error
  • Verify tmux/kitty/wezterm still work (no regressions)

🤖 Generated with Claude Code

@tkukushkin tkukushkin requested a review from umputun as a code owner April 5, 2026 22:49
Copy link
Copy Markdown
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

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

the AppleScript argv fix looks correct — proper use of on run argv + quoted heredoc to avoid injection.

two things from the PR description that aren't in the diff though:

  1. detection line is unchanged — still uses osascript -e 'tell application "Ghostty" to get version' which you noted succeeds even with macos-applescript = false. the command -v osascript replacement mentioned in the description isn't here.
  2. EXIT trap for temp files (SENTINEL + LAUNCH_SCRIPT) isn't in the diff either.

are those planned for a follow-up, or were they accidentally left out?

- Pass shell variables via osascript argv instead of interpolating into
  AppleScript strings, preventing injection with special path characters
- Replace unreliable get-version probe with command -v osascript check
  (get version succeeds even with macos-applescript=false)
- Add EXIT trap for LAUNCH_SCRIPT and SENTINEL cleanup on interruption
- Add explicit cleanup on success path for consistency with other backends

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tkukushkin tkukushkin force-pushed the fix/ghostty-improvements branch from 360e553 to 2a46a23 Compare April 5, 2026 23:05
@tkukushkin
Copy link
Copy Markdown
Contributor Author

Good catch — the detection fix and EXIT trap were accidentally left out during rebasing. Fixed in the force-pushed update: both command -v osascript guard and trap 'rm -f ... ' EXIT are now in the diff.

Copy link
Copy Markdown
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

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

both fixes confirmed — detection guard and EXIT trap are in. lgtm, thx

@umputun umputun merged commit 59e9e70 into umputun:master Apr 5, 2026
1 check passed
@tkukushkin tkukushkin deleted the fix/ghostty-improvements branch April 5, 2026 23:13
@umputun umputun mentioned this pull request Apr 6, 2026
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