Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cf23557
test: cover plain terminal typing shortcut fast path
austinywang May 24, 2026
e61ca3d
fix: reduce terminal input and title hot-path work
austinywang May 24, 2026
8f4a9a5
test: avoid title dispatcher observer capture
austinywang May 24, 2026
6b02e56
fix: address notification hot-path review feedback
austinywang May 24, 2026
e09221d
fix: address terminal notification review followups
austinywang May 24, 2026
f8485f6
test: cover empty terminal interaction fast path
austinywang May 24, 2026
9482022
fix: repair notification fast-path CI failures
austinywang May 24, 2026
7ee4f38
fix: compile key timing path in release
austinywang May 24, 2026
da676a9
fix: avoid mutable notification route snapshots
austinywang May 24, 2026
4cacb69
Merge remote-tracking branch 'origin/main' into issue-4681-ssh-tmux-t…
austinywang May 25, 2026
9b405cb
fix: start automation socket before window construction
austinywang May 25, 2026
e2ee07a
fix: recheck app notification suppression before delivery
austinywang May 25, 2026
78c885a
Merge remote-tracking branch 'origin/main' into issue-4681-ssh-tmux-t…
austinywang May 26, 2026
3740827
fix: resolve app notification route at delivery
austinywang May 26, 2026
43da013
Merge remote-tracking branch 'origin/main' into issue-4681-ssh-tmux-t…
austinywang May 26, 2026
309570a
Merge remote-tracking branch 'origin/main' into issue-4681-ssh-tmux-t…
austinywang Jun 16, 2026
c27700f
fix: address merge fallout review findings
austinywang Jun 16, 2026
e509914
Merge branch 'main' of https://github.com/manaflow-ai/cmux into issue…
austinywang Jun 16, 2026
b71158f
fix: address ssh tmux review regressions
austinywang Jun 17, 2026
59b4c9f
Merge remote-tracking branch 'origin/main' into issue-4681-ssh-tmux-t…
austinywang Jun 17, 2026
4288ec3
Merge remote-tracking branch 'origin/main' into issue-4681-ssh-tmux-t…
austinywang Jun 17, 2026
a069879
fix: keep desktop notification route decisions coherent
austinywang Jun 17, 2026
6c25b1e
fix: repair notification suppression invalidation
austinywang Jun 17, 2026
1e8d4a0
fix: remove stale desktop notification route cache
austinywang Jun 17, 2026
914782c
fix: preserve desktop notification fallback routing
austinywang Jun 17, 2026
647fea2
merge: sync issue-4681 with main
austinywang Jun 17, 2026
340786e
merge: sync issue-4681 with main
austinywang Jul 3, 2026
abb4657
test: cover notification hook paths with trailing spaces
austinywang Jul 3, 2026
fead39e
fix: make terminal notification delivery synchronous
austinywang Jul 3, 2026
222c3cc
merge: sync issue-4681 with main
austinywang Jul 3, 2026
fc0a14b
fix: preserve dock terminal notifications
austinywang Jul 3, 2026
3f0c946
test: cover title dedupe after surface replacement
austinywang Jul 3, 2026
8e4fdbf
fix: scope title dedupe to surface lifetime
austinywang Jul 3, 2026
49d8502
fix: remove bogus copied localizations
austinywang Jul 3, 2026
7186e29
test: cover notification hook dot-dot lookup
austinywang Jul 3, 2026
14e1cff
fix: normalize notification hook lookup paths
austinywang Jul 3, 2026
6a959cc
fix: fall through unresolved surface notifications
austinywang Jul 3, 2026
1c59c03
fix: cache right-sidebar mode shortcuts
austinywang Jul 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions Sources/CmuxConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,8 @@ final class CmuxConfigStore: ObservableObject {
private var resolvedNewWorkspaceCommandCache: CmuxResolvedCommand?
private var resolvedNewWorkspaceActionCache: CmuxResolvedConfigAction?
private var parsedConfigCache: [String: ParsedConfigCacheEntry] = [:]
private var notificationHooksByDirectoryCache: [String: [CmuxResolvedNotificationHook]] = [:]
private var notificationHooksWithoutDirectoryCache: [CmuxResolvedNotificationHook]?
private var lifetimeCancellables = Set<AnyCancellable>()
private var trackingCancellables = Set<AnyCancellable>()
private var localFileWatchSource: DispatchSourceFileSystemObject?
Expand Down Expand Up @@ -1937,6 +1939,13 @@ final class CmuxConfigStore: ObservableObject {
URL(fileURLWithPath: path).resolvingSymlinksInPath().standardizedFileURL.path
}

private static func notificationHookCacheKey(for directory: String?) -> String? {
guard let directory else { return nil }
let trimmed = directory.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else { return nil }
return (trimmed as NSString).standardizingPath
}

init(
globalConfigPath: String = CmuxConfigStore.defaultGlobalConfigPath(),
localConfigPath: String? = nil,
Expand Down Expand Up @@ -2003,19 +2012,33 @@ final class CmuxConfigStore: ObservableObject {
}

func notificationHooks(startingFrom directory: String?) -> [CmuxResolvedNotificationHook] {
let cacheKey = Self.notificationHookCacheKey(for: directory)
if let cacheKey, let cached = notificationHooksByDirectoryCache[cacheKey] {
return cached
}
if cacheKey == nil, let cached = notificationHooksWithoutDirectoryCache {
return cached
}

let globalConfig = parseConfig(at: globalConfigPath).config
let localConfigs: [(path: String, config: CmuxConfigFile)]
if let directory, !directory.isEmpty {
localConfigs = findCmuxConfigHierarchy(startingFrom: directory).compactMap { path in
if let cacheKey {
localConfigs = findCmuxConfigHierarchy(startingFrom: cacheKey).compactMap { path in
parseConfig(at: path).config.map { (path: path, config: $0) }
}
} else {
localConfigs = []
}
return resolveNotificationHooks(
let hooks = resolveNotificationHooks(
globalConfig: globalConfig,
localConfigs: localConfigs
)
if let cacheKey {
notificationHooksByDirectoryCache[cacheKey] = hooks
} else {
notificationHooksWithoutDirectoryCache = hooks
}
return hooks
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}

private func updateLocalConfigPath(_ directory: String?) {
Expand Down Expand Up @@ -2251,6 +2274,8 @@ final class CmuxConfigStore: ObservableObject {
surfaceTabBarWorkspaceCommands = resolvedWorkspaceButtons.workspaceCommands
surfaceTabBarButtons = resolvedWorkspaceButtons.buttons
notificationHooks = resolvedNotificationHooks
notificationHooksByDirectoryCache.removeAll(keepingCapacity: true)
notificationHooksWithoutDirectoryCache = nil
resolvedNewWorkspaceActionCache = resolvedNewWorkspaceAction.action
resolvedNewWorkspaceCommandCache = resolvedNewWorkspaceAction.command
if let issue = resolvedNewWorkspaceAction.issue {
Expand Down
156 changes: 139 additions & 17 deletions Sources/GhosttyTerminalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,56 @@ private final class GhosttySurfaceCallbackContext {
}
}

final class GhosttyTitleNotificationDispatcher {
private struct SurfaceKey: Hashable {
let tabId: UUID
let surfaceId: UUID
}

private let lock = NSLock()
private var lastPostedTitleBySurface: [SurfaceKey: String] = [:]

@discardableResult
func postTitleIfChanged(
tabId: UUID,
surfaceId: UUID,
title: String,
object: Any?,
center: NotificationCenter = .default,
deliver: (@escaping () -> Void) -> Void = { block in
DispatchQueue.main.async {
block()
}
}
) -> Bool {
guard reserveTitleIfChanged(tabId: tabId, surfaceId: surfaceId, title: title) else {
return false
}

deliver {
center.post(
name: .ghosttyDidSetTitle,
object: object,
userInfo: [
GhosttyNotificationKey.tabId: tabId,
GhosttyNotificationKey.surfaceId: surfaceId,
GhosttyNotificationKey.title: title,
]
)
}
return true
}

private func reserveTitleIfChanged(tabId: UUID, surfaceId: UUID, title: String) -> Bool {
let key = SurfaceKey(tabId: tabId, surfaceId: surfaceId)
lock.lock()
defer { lock.unlock() }
guard lastPostedTitleBySurface[key] != title else { return false }
lastPostedTitleBySurface[key] = title
return true
}
}

// Minimal Ghostty wrapper for terminal rendering
// This uses libghostty (GhosttyKit.xcframework) for actual terminal emulation

Comment thread
austinywang marked this conversation as resolved.
Resolved
Expand Down Expand Up @@ -1899,6 +1949,7 @@ class GhosttyApp {
private var backgroundLogSequence: UInt64 = 0
private var appObservers: [NSObjectProtocol] = []
private var bellAudioSound: NSSound?
private let titleNotificationDispatcher = GhosttyTitleNotificationDispatcher()
private var backgroundEventCounter: UInt64 = 0
private var defaultBackgroundUpdateScope: GhosttyDefaultBackgroundUpdateScope = .unscoped
private var defaultBackgroundScopeSource: String = "initialize"
Expand Down Expand Up @@ -4267,16 +4318,16 @@ class GhosttyApp {
.flatMap { String(cString: $0) } ?? ""
let actionBody = action.action.desktop_notification.body
.flatMap { String(cString: $0) } ?? ""
return performOnMain {
Task { @MainActor [actionTitle, actionBody] in
guard let tabManager = AppDelegate.shared?.tabManager,
let tabId = tabManager.selectedTabId else {
return false
return
}
let owningManager = AppDelegate.shared?.tabManagerFor(tabId: tabId) ?? tabManager
let surfaceId = tabManager.focusedSurfaceId(for: tabId)
if let workspace = owningManager.tabs.first(where: { $0.id == tabId }),
workspace.suppressesRawTerminalNotification(panelId: surfaceId) {
return true
return
}
let tabTitle = owningManager.titleForTab(tabId) ?? "Terminal"
let command = actionTitle.isEmpty ? tabTitle : actionTitle
Expand All @@ -4288,8 +4339,8 @@ class GhosttyApp {
subtitle: "",
body: body
)
return true
}
return true
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}

if action.tag == GHOSTTY_ACTION_RING_BELL {
Expand Down Expand Up @@ -4512,17 +4563,12 @@ class GhosttyApp {
.flatMap { String(cString: $0) } ?? ""
if let tabId = surfaceView.tabId,
let surfaceId = surfaceView.terminalSurface?.id {
DispatchQueue.main.async {
NotificationCenter.default.post(
name: .ghosttyDidSetTitle,
object: surfaceView,
userInfo: [
GhosttyNotificationKey.tabId: tabId,
GhosttyNotificationKey.surfaceId: surfaceId,
GhosttyNotificationKey.title: title,
]
)
}
titleNotificationDispatcher.postTitleIfChanged(
tabId: tabId,
surfaceId: surfaceId,
title: title,
object: surfaceView
)
}
return true
case GHOSTTY_ACTION_PWD:
Expand All @@ -4544,7 +4590,7 @@ class GhosttyApp {
.flatMap { String(cString: $0) } ?? ""
let actionBody = action.action.desktop_notification.body
.flatMap { String(cString: $0) } ?? ""
performOnMain {
Task { @MainActor [tabId, surfaceId, actionTitle, actionBody] in
let owningManager = AppDelegate.shared?.tabManagerFor(tabId: tabId) ?? AppDelegate.shared?.tabManager
if let workspace = owningManager?.tabs.first(where: { $0.id == tabId }),
workspace.suppressesRawTerminalNotification(panelId: surfaceId) {
Expand Down Expand Up @@ -4928,6 +4974,11 @@ private enum GhosttyRenderedFrameNotificationDemand {
}

static var isActive: Bool {
#if DEBUG
if CmuxTypingTiming.isEnabled {
return true
}
#endif
lock.lock()
defer { lock.unlock() }
return count > 0
Expand Down Expand Up @@ -7261,6 +7312,21 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {
private let _scrollbarLock = NSLock()
private var _renderedFrameFlushScheduled = false
private let _renderedFrameLock = NSLock()
#if DEBUG
private struct PendingInputRenderTiming {
let sequence: UInt64
let sentAt: TimeInterval
let eventTimestamp: TimeInterval?
let keyCode: UInt16?
let modifierFlagsRawValue: UInt
let isRepeat: Bool
let sourcePath: String
}

private let _inputRenderTimingLock = NSLock()
private var _inputRenderTimingSequence: UInt64 = 0
private var _pendingInputRenderTiming: PendingInputRenderTiming?
#endif
var cellSize: CGSize = .zero
private var lastKnownMousePointInView: NSPoint?

Expand Down Expand Up @@ -7326,12 +7392,59 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {
_renderedFrameLock.unlock()

guard GhosttyRenderedFrameNotificationDemand.isActive else { return }
#if DEBUG
logPendingInputRenderTimingIfNeeded()
#endif
NotificationCenter.default.post(
name: .ghosttyDidRenderFrame,
object: self
)
}

#if DEBUG
private func recordInputDispatchForRenderTiming(path: String, event: NSEvent?) {
guard CmuxTypingTiming.isEnabled else { return }
_inputRenderTimingLock.lock()
_inputRenderTimingSequence &+= 1
_pendingInputRenderTiming = PendingInputRenderTiming(
sequence: _inputRenderTimingSequence,
sentAt: ProcessInfo.processInfo.systemUptime,
eventTimestamp: event?.timestamp,
keyCode: event?.keyCode,
modifierFlagsRawValue: event?.modifierFlags.rawValue ?? 0,
isRepeat: event?.isARepeat ?? false,
sourcePath: path
)
_inputRenderTimingLock.unlock()
}

private func logPendingInputRenderTimingIfNeeded() {
guard CmuxTypingTiming.isEnabled else { return }
_inputRenderTimingLock.lock()
let pending = _pendingInputRenderTiming
_pendingInputRenderTiming = nil
_inputRenderTimingLock.unlock()
guard let pending else { return }

let now = ProcessInfo.processInfo.systemUptime
let renderAfterSendMs = max(0, (now - pending.sentAt) * 1000.0)
var line = "typing.render path=terminal.render.afterInput"
line += " renderAfterSendMs=\(String(format: "%.2f", renderAfterSendMs))"
if let eventTimestamp = pending.eventTimestamp, eventTimestamp > 0 {
let eventToRenderMs = max(0, (now - eventTimestamp) * 1000.0)
line += " eventToRenderMs=\(String(format: "%.2f", eventToRenderMs))"
}
line += " sourcePath=\(pending.sourcePath)"
line += " sequence=\(pending.sequence)"
if let keyCode = pending.keyCode {
line += " keyCode=\(keyCode)"
}
line += " mods=\(pending.modifierFlagsRawValue)"
line += " repeat=\(pending.isRepeat ? 1 : 0)"
cmuxDebugLog(line)
}
#endif

var desiredFocus: Bool = false
var suppressingReparentFocus: Bool = false
var tabId: UUID?
Expand Down Expand Up @@ -8829,7 +8942,13 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {
#endif
handled = text.withCString { ptr in
keyEvent.text = ptr
return ghostty_surface_key(surface, keyEvent)
return sendTimedGhosttyKey(
surface,
keyEvent,
path: "terminal.keyDown.ctrlGhosttySend",
event: event,
extra: "textBytes=\(text.utf8.count)"
)
}
#if DEBUG
ghosttySendMs = (ProcessInfo.processInfo.systemUptime - ghosttySendStart) * 1000.0
Expand Down Expand Up @@ -9164,6 +9283,9 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {
) -> Bool {
let timingStart = CmuxTypingTiming.start()
let handled = sendGhosttyKey(surface, keyEvent)
if handled {
recordInputDispatchForRenderTiming(path: path, event: event)
}
let baseExtra = "handled=\(handled ? 1 : 0)"
let mergedExtra: String
if let extra, !extra.isEmpty {
Expand Down
14 changes: 13 additions & 1 deletion Sources/RightSidebarPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,20 @@ extension RightSidebarMode {
}

extension RightSidebarMode {
private static let shortcutRelevantModifiers: NSEvent.ModifierFlags = [
.command,
.control,
.option,
]

static func shouldCheckModeShortcut(for event: NSEvent) -> Bool {
guard event.type == .keyDown else { return false }
let flags = ShortcutStroke.normalizedModifierFlags(from: event.modifierFlags)
return !flags.intersection(shortcutRelevantModifiers).isEmpty
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

static func modeShortcut(for event: NSEvent) -> RightSidebarMode? {
guard event.type == .keyDown else { return nil }
guard shouldCheckModeShortcut(for: event) else { return nil }
if KeyboardShortcutSettings.shortcut(for: .switchRightSidebarToFiles).matches(event: event) {
return .files
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6793,6 +6793,7 @@ class TabManager: ObservableObject {
guard AppFocusState.isAppActive() else { return false }
}
guard let notificationStore = AppDelegate.shared?.notificationStore else { return false }
guard notificationStore.hasDismissibleActivity(forTabId: tabId) else { return false }
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
let workspace = tabs.first(where: { $0.id == tabId })
let targetPanelId = surfaceId.flatMap { surfaceOrPanelId in
workspace.flatMap { panelId(forSurfaceOrPanelId: surfaceOrPanelId, in: $0) }
Expand Down
8 changes: 8 additions & 0 deletions Sources/TerminalNotificationStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,14 @@ final class TerminalNotificationStore: ObservableObject {
focusedReadIndicatorByTabId[tabId] == surfaceId
}

func hasDismissibleActivity(forTabId tabId: UUID) -> Bool {
(indexes.unreadCountByTabId[tabId] ?? 0) > 0 ||
focusedReadIndicatorByTabId[tabId] != nil ||
manualUnreadWorkspaceIds.contains(tabId) ||
panelDerivedUnreadWorkspaceIds.contains(tabId) ||
restoredUnreadWorkspaceIds.contains(tabId)
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

func latestNotification(forTabId tabId: UUID) -> TerminalNotification? {
indexes.latestByTabId[tabId]
}
Expand Down
25 changes: 25 additions & 0 deletions cmuxTests/ShortcutAndCommandPaletteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,9 @@ final class RightSidebarModeShortcutHintTests: XCTestCase {
}

override func tearDownWithError() throws {
#if DEBUG
KeyboardShortcutSettings.shortcutLookupObserver = nil
#endif
for action in touchedShortcutActions {
if case let .some(.some(data)) = savedShortcutData[action] {
UserDefaults.standard.set(data, forKey: action.defaultsKey)
Expand Down Expand Up @@ -1155,6 +1158,28 @@ final class RightSidebarModeShortcutHintTests: XCTestCase {
)
}

func testPlainTypingDoesNotLookUpModeShortcutBindings() {
#if DEBUG
var observedActions: [KeyboardShortcutSettings.Action] = []
KeyboardShortcutSettings.shortcutLookupObserver = { action in
observedActions.append(action)
}

XCTAssertNil(
RightSidebarMode.modeShortcut(for: makeKeyDownEvent(key: "a", modifiers: [], keyCode: 0))
)
XCTAssertNil(
RightSidebarMode.modeShortcut(for: makeKeyDownEvent(key: "A", modifiers: [.shift], keyCode: 0))
)
XCTAssertTrue(
observedActions.isEmpty,
"Plain terminal typing must return before resolving right-sidebar shortcut bindings"
)
#else
XCTFail("shortcutLookupObserver is only available in DEBUG")
#endif
Comment thread
austinywang marked this conversation as resolved.
Resolved
}

func testModeShortcutUsesConfiguredBindings() {
let customFilesShortcut = StoredShortcut(
key: "4",
Expand Down
Loading
Loading