From cf5162ff4a63f192ac49493b12cae9f2e20cd18d Mon Sep 17 00:00:00 2001 From: Grimmer Kang Date: Fri, 20 Mar 2026 04:01:58 +0800 Subject: [PATCH 1/2] fix: enable AppleScript by always returning true for isAppleScriptEnabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The underlying Ghostty fork does not include the `macos-applescript` config key (added in upstream ghostty commit 25fa58143, 2026-03-06). As a result, `appleScriptAutomationEnabled()` always returns false, causing `scriptWindows` to return an empty array. This makes `count windows`, `every window`, `front window`, and all AppleScript window/tab/terminal access silently return empty results. Fix: always return true from `isAppleScriptEnabled` until the fork is updated with the upstream config key. Test results (before fix): osascript -e 'tell application "cmux" to count windows' → 0 osascript -e 'tell application "cmux" to get version' → 0.62.2 Test results (after fix): osascript -e 'tell application "cmux DEV ..." to count windows' → 1 osascript -e 'tell application "cmux DEV ..." to count terminals of tab 1 of window 1' → works osascript -e 'tell application "cmux DEV ..." to input text "..." to terminal 1 of ...' → works Co-Authored-By: Claude Opus 4.6 (1M context) --- Sources/AppleScriptSupport.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/AppleScriptSupport.swift b/Sources/AppleScriptSupport.swift index 640750d5..2ede72cb 100644 --- a/Sources/AppleScriptSupport.swift +++ b/Sources/AppleScriptSupport.swift @@ -81,7 +81,13 @@ private extension Workspace { @MainActor extension NSApplication { var isAppleScriptEnabled: Bool { - GhosttyApp.shared.appleScriptAutomationEnabled() + // cmux always enables AppleScript — the underlying Ghostty fork + // doesn't have the macos-applescript config key yet (added in + // upstream ghostty commit 25fa58143, 2026-03-06), so + // appleScriptAutomationEnabled() always returns false. + // Once the fork is updated, this can revert to: + // GhosttyApp.shared.appleScriptAutomationEnabled() + return true } @discardableResult From 4b0ae5180dbdfcf7259174cb598fcf5d7819094b Mon Sep 17 00:00:00 2001 From: Grimmer Kang Date: Fri, 20 Mar 2026 04:15:44 +0800 Subject: [PATCH 2/2] fix: read working directory from panelDirectories instead of TerminalPanel TerminalPanel.directory is never updated (updateDirectory() is never called anywhere). Workspace.panelDirectories is kept up to date via updatePanelDirectory() from OSC 7 / shell integration. Before: working directory always returns "" After: working directory returns correct cwd (e.g. "/Users/grimmer") Co-Authored-By: Claude Opus 4.6 (1M context) --- Sources/AppleScriptSupport.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/AppleScriptSupport.swift b/Sources/AppleScriptSupport.swift index 2ede72cb..b90db00a 100644 --- a/Sources/AppleScriptSupport.swift +++ b/Sources/AppleScriptSupport.swift @@ -538,7 +538,10 @@ final class ScriptTerminal: NSObject { @objc(workingDirectory) var workingDirectory: String { guard NSApp.isAppleScriptEnabled else { return "" } - return terminal?.directory ?? "" + // TerminalPanel.directory is never updated (updateDirectory is never called). + // Read from Workspace.panelDirectories instead, which is kept up to date + // via updatePanelDirectory() from OSC 7 / shell integration. + return workspace?.panelDirectories[terminalId] ?? terminal?.directory ?? "" } func input(text: String) -> Bool {