Skip to content
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
25030ee
feat: suppress ignored Claude notifications
austinywang May 12, 2026
17f1477
Merge remote-tracking branch 'origin/main' into issue-3602-suppress-i…
austinywang May 12, 2026
636c344
fix: tighten Claude notification type filtering
austinywang May 12, 2026
bee9922
refactor: share Claude notification type normalization
austinywang May 12, 2026
0cf31e7
Merge remote-tracking branch 'origin/main' into issue-3602-suppress-i…
austinywang May 12, 2026
5adc3d5
fix: extract ignored Claude types from raw hook input
austinywang May 12, 2026
0a9029e
refactor: share Claude notification filter keys
austinywang May 12, 2026
d9091ba
Merge remote-tracking branch 'origin/main' into issue-3602-suppress-i…
austinywang May 13, 2026
eb366d3
merge: resolve conflicts with main
austinywang May 14, 2026
48ea5c2
Merge remote-tracking branch 'origin/main' into issue-3602-suppress-i…
austinywang May 17, 2026
a22d3b6
fix: sanitize suppressed notification telemetry
austinywang May 18, 2026
1a010d2
fix: parse fallback Claude notification types
austinywang May 18, 2026
183a71a
fix: scope Claude notification type extraction
austinywang May 18, 2026
9a613da
Merge remote-tracking branch 'origin/main' into issue-3602-suppress-i…
austinywang May 18, 2026
dcddc10
merge: sync with origin main
austinywang May 19, 2026
57574ad
fix: read live Claude notification settings
austinywang May 19, 2026
23613f8
fix: skip invalid Claude notification configs
austinywang May 19, 2026
0d442bc
fix: honor live Claude notification config precedence
austinywang May 19, 2026
270a7c7
fix: reject invalid Claude notification config values
austinywang May 19, 2026
76ee9f0
fix: treat malformed notifications config as invalid
austinywang May 19, 2026
4c7ba93
refactor: isolate Claude notification domain
austinywang May 19, 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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ jobs:
CMUX_CLI_BIN="$CLI_BIN" python3 tests/test_cli_socket_operation_deadline.py
CMUX_CLI_BIN="$CLI_BIN" python3 tests/test_cli_socket_autodiscovery.py
CMUX_CLI_BIN="$CLI_BIN" python3 tests/test_claude_hook_clear_running_status.py
CMUX_CLI_BIN="$CLI_BIN" python3 tests/test_claude_hook_ignored_notification_types.py
- save-swift-package-cache:
prefix: unit
- save-zig-cache
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ jobs:
python3 tests/test_claude_wrapper_hooks.py
CMUX_CLI_BIN="$CLI_BIN" python3 tests/test_claude_hook_stop_last_assistant.py
CMUX_CLI_BIN="$CLI_BIN" python3 tests/test_claude_hook_clear_running_status.py
CMUX_CLI_BIN="$CLI_BIN" python3 tests/test_claude_hook_ignored_notification_types.py
CMUX_CLI_BIN="$CLI_BIN" python3 tests/test_pi_extension_install.py

tests-build-and-lag:
Expand Down
253 changes: 252 additions & 1 deletion CLI/cmux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ private struct ClaudeHookParsedInput {
let rawObject: [String: Any]?
let object: [String: Any]?
let rawFallback: String?
let rawFallbackNotificationTypeValues: [String]
let sessionId: String?
let turnId: String?
let cwd: String?
Expand Down Expand Up @@ -16696,6 +16697,16 @@ struct CMUXCLI {

case "notification", "notify":
telemetry.breadcrumb("claude-hook.notification")
let notificationTypes = Self.claudeNotificationTypes(parsedInput: parsedInput)
let suppressedNotificationTypes = Self.suppressedClaudeNotificationTypes(for: notificationTypes)
if !suppressedNotificationTypes.isEmpty {
telemetry.breadcrumb(
"claude-hook.notification.suppressed",
data: ["types": suppressedNotificationTypes.sorted().joined(separator: ",")]
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
print("OK")
return
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved
}
var summary = summarizeClaudeHookNotification(parsedInput: parsedInput)

let mappedSession = parsedInput.sessionId.flatMap { try? sessionStore.lookup(sessionId: $0) }
Expand Down Expand Up @@ -17312,7 +17323,7 @@ struct CMUXCLI {
guard !trimmed.isEmpty,
let data = trimmed.data(using: .utf8),
let json = try? JSONSerialization.jsonObject(with: data, options: []),
let object = json as? [String: Any] else {
let object = Self.claudeHookObject(fromJSONValue: json) else {
let fallback = trimmed.isEmpty ? nil : truncate(
normalizedSingleLine(redactClaudeSensitiveSpans(trimmed)),
maxLength: 180
Expand All @@ -17321,6 +17332,7 @@ struct CMUXCLI {
rawObject: nil,
object: nil,
rawFallback: fallback,
rawFallbackNotificationTypeValues: Self.claudeNotificationTypeValues(inRawFallback: trimmed),
sessionId: nil,
turnId: nil,
cwd: nil,
Expand All @@ -17337,13 +17349,27 @@ struct CMUXCLI {
rawObject: object,
object: compactObject,
rawFallback: nil,
rawFallbackNotificationTypeValues: [],
sessionId: sessionId,
turnId: turnId,
cwd: cwd,
transcriptPath: transcriptPath
)
}

private static func claudeHookObject(fromJSONValue value: Any) -> [String: Any]? {
if let object = value as? [String: Any] {
return object
}
guard let string = value as? String,
let data = string.trimmingCharacters(in: .whitespacesAndNewlines).data(using: .utf8),
let nested = try? JSONSerialization.jsonObject(with: data, options: []),
let object = nested as? [String: Any] else {
return nil
}
return object
}

private func compactClaudeHookObject(_ object: [String: Any]) -> [String: Any] {
var compact: [String: Any] = [:]

Expand Down Expand Up @@ -18722,6 +18748,231 @@ struct CMUXCLI {
return ("Attention", "Claude needs your attention")
}

private static let claudeIgnoredNotificationTypesDefaultsKey =
ClaudeNotificationTypeNormalization.ignoredTypesDefaultsKey
private static let claudeIgnoredNotificationTypesEnvKey =
ClaudeNotificationTypeNormalization.ignoredTypesEnvironmentKey

private static func suppressedClaudeNotificationTypes(for types: Set<String>) -> Set<String> {
let ignoredTypes = ignoredClaudeNotificationTypes()
guard !ignoredTypes.isEmpty, !types.isEmpty else {
return []
}
return ignoredTypes.intersection(types)
}

private static func ignoredClaudeNotificationTypes() -> Set<String> {
// Hook subprocess environments are immutable after terminal launch; read cmux.json first
// so existing terminals follow live settings changes.
if let settingsTypes = ignoredClaudeNotificationTypesFromSettingsFiles() {
return settingsTypes
}

if let env = ProcessInfo.processInfo.environment[claudeIgnoredNotificationTypesEnvKey] {
return normalizedClaudeNotificationTypes(
env.components(separatedBy: CharacterSet(charactersIn: ", \n\t"))
)
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

if let stored = UserDefaults.standard.array(forKey: claudeIgnoredNotificationTypesDefaultsKey) as? [String] {
return normalizedClaudeNotificationTypes(stored)
}
if let stored = UserDefaults.standard.string(forKey: claudeIgnoredNotificationTypesDefaultsKey) {
return normalizedClaudeNotificationTypes(
stored.components(separatedBy: CharacterSet(charactersIn: ", \n\t"))
)
}
return []
}

private enum ClaudeIgnoredNotificationTypesFileLoadResult {
case missing
case invalid
case parsed([String]?)
}

private static func ignoredClaudeNotificationTypesFromSettingsFiles(
fileManager: FileManager = .default,
environment: [String: String] = ProcessInfo.processInfo.environment
) -> Set<String>? {
let paths = claudeIgnoredNotificationTypesSettingsPaths(
fileManager: fileManager,
environment: environment
)

for path in paths {
switch loadIgnoredClaudeNotificationTypes(at: path, fileManager: fileManager) {
case .missing:
continue
case .invalid:
continue
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
case .parsed(let values):
if let values {
return normalizedClaudeNotificationTypes(values)
}
return []
}
}

return nil
}

private static func claudeIgnoredNotificationTypesSettingsPaths(
fileManager: FileManager,
environment: [String: String]
) -> [String] {
var paths: [String] = []
var seen = Set<String>()

func append(_ path: String) {
let standardized = URL(fileURLWithPath: path).standardizedFileURL.path
if seen.insert(standardized).inserted {
paths.append(standardized)
}
}

append(expandedSettingsPath(
primarySettingsDisplayPath,
fileManager: fileManager,
environment: environment
))
append(expandedSettingsPath(
legacySettingsDisplayPath,
fileManager: fileManager,
environment: environment
))

for appSupportURL in CmuxApplicationSupportDirectories.userDirectories(
environment: environment,
fileManager: fileManager
) {
append(
appSupportURL
.appendingPathComponent("com.cmuxterm.app", isDirectory: true)
.appendingPathComponent("settings.json", isDirectory: false)
.path
)
}

return paths
}

private static func expandedSettingsPath(
_ rawPath: String,
fileManager: FileManager,
environment: [String: String]
) -> String {
let homePath = environment["HOME"] ?? fileManager.homeDirectoryForCurrentUser.path
let expanded: String
if rawPath == "~" {
expanded = homePath
} else if rawPath.hasPrefix("~/") {
expanded = (homePath as NSString).appendingPathComponent(String(rawPath.dropFirst(2)))
} else {
expanded = rawPath
}
return URL(fileURLWithPath: expanded).standardizedFileURL.path
}

private static func loadIgnoredClaudeNotificationTypes(
at path: String,
fileManager: FileManager
) -> ClaudeIgnoredNotificationTypesFileLoadResult {
var isDirectory = ObjCBool(false)
guard fileManager.fileExists(atPath: path, isDirectory: &isDirectory) else {
return .missing
}
guard !isDirectory.boolValue,
let data = fileManager.contents(atPath: path),
!data.isEmpty,
let sanitized = try? JSONCParser.preprocess(data: data),
let rootObject = try? JSONSerialization.jsonObject(with: sanitized, options: []),
let root = rootObject as? [String: Any] else {
return .invalid
}

guard let notifications = root["notifications"] as? [String: Any],
let rawValues = notifications["ignoredClaudeNotificationTypes"] else {
return .parsed(nil)
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}
guard let values = rawValues as? [String] else {
return .parsed(nil)
}
return .parsed(values)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 When notifications.ignoredClaudeNotificationTypes is present in the settings file but its value is not a [String] (e.g., the user wrote "idle_prompt" instead of ["idle_prompt"]), .parsed(nil) is returned. In ignoredClaudeNotificationTypesFromSettingsFiles, .parsed(nil) resolves to return [], which makes the settings file "win" with an empty ignore list — silently bypassing the env var the app already set from the still-valid UserDefaults value. The app correctly leaves UserDefaults untouched (logInvalid is called, nothing is written) and sets CMUX_CLAUDE_IGNORED_NOTIFICATION_TYPES from the preserved UserDefaults value, but the CLI never sees it because the settings-file lookup short-circuits. Returning .invalid here instead lets the loop fall through to the env var (and UserDefaults), which matches the app's intent for an invalid-type value.

Suggested change
guard let values = rawValues as? [String] else {
return .parsed(nil)
}
return .parsed(values)
guard let values = rawValues as? [String] else {
return .invalid
}
return .parsed(values)

}

private static func claudeNotificationTypes(parsedInput: ClaudeHookParsedInput) -> Set<String> {
var rawValues: [String] = []
if let object = parsedInput.rawObject ?? parsedInput.object {
rawValues.append(contentsOf: claudeNotificationTypeValues(inJSONValue: object))
}
rawValues.append(contentsOf: parsedInput.rawFallbackNotificationTypeValues)
return normalizedClaudeNotificationTypes(rawValues)
}

private enum ClaudeNotificationTypeExtractionScope {
case root
case notificationPayload
}

private static func claudeNotificationTypeValues(
inRawFallback fallback: String,
scope: ClaudeNotificationTypeExtractionScope = .root
) -> [String] {
let trimmed = fallback.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty,
let data = trimmed.data(using: .utf8),
let json = try? JSONSerialization.jsonObject(with: data, options: []) else {
return []
}
return claudeNotificationTypeValues(inJSONValue: json, scope: scope)
}

private static func claudeNotificationTypeValues(
inJSONValue value: Any,
scope: ClaudeNotificationTypeExtractionScope = .root
) -> [String] {
if let object = value as? [String: Any] {
var values = claudeNotificationTypeValues(in: object, scope: scope)
for key in ["notification", "data"] {
if let nested = object[key] {
values.append(contentsOf: claudeNotificationTypeValues(
inJSONValue: nested,
scope: .notificationPayload
))
}
}
return values
}
if let values = value as? [Any] {
return values.flatMap { claudeNotificationTypeValues(inJSONValue: $0, scope: scope) }
}
if let string = value as? String {
return claudeNotificationTypeValues(inRawFallback: string, scope: scope)
}
return []
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

private static func claudeNotificationTypeValues(
in object: [String: Any],
scope: ClaudeNotificationTypeExtractionScope
) -> [String] {
let keys: [String]
switch scope {
case .root:
keys = ["notification_type", "matcher", "reason"]
case .notificationPayload:
keys = ["notification_type", "matcher", "reason", "type", "kind"]
}
return keys.compactMap { key in
object[key] as? String
}
}

private static func normalizedClaudeNotificationTypes(_ values: [String]) -> Set<String> {
ClaudeNotificationTypeNormalization.normalizedSet(values)
}

private func firstString(in object: [String: Any], keys: [String]) -> String? {
for key in keys {
guard let value = object[key] else { continue }
Expand Down
34 changes: 34 additions & 0 deletions Sources/ClaudeNotificationTypeNormalization.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Foundation

enum ClaudeNotificationTypeNormalization {
static let ignoredTypesDefaultsKey = "claudeCodeIgnoredNotificationTypes"
static let ignoredTypesEnvironmentKey = "CMUX_CLAUDE_IGNORED_NOTIFICATION_TYPES"
static let defaultIgnoredTypes: [String] = []

static func normalized(_ raw: String) -> String? {
let collapsedWhitespace = raw
.trimmingCharacters(in: .whitespacesAndNewlines)
.components(separatedBy: .whitespacesAndNewlines)
.filter { !$0.isEmpty }
.joined(separator: "_")
let normalized = collapsedWhitespace
.replacingOccurrences(of: "-", with: "_")
.lowercased()
return normalized.isEmpty ? nil : normalized
}

static func normalizedSet(_ values: [String]) -> Set<String> {
Set(values.compactMap(normalized))
}

static func normalizedUniqueList(_ values: [String]) -> [String] {
var seen = Set<String>()
return values.compactMap { raw in
guard let normalized = normalized(raw),
seen.insert(normalized).inserted else {
return nil
}
return normalized
}
}
}
1 change: 1 addition & 0 deletions Sources/CmuxSettingsJSONPathSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ extension CmuxSettingsFileStore {
"notifications.sound",
"notifications.customSoundFilePath",
"notifications.command",
"notifications.ignoredClaudeNotificationTypes",
"notifications.hooks",
"notifications.hooksMode",
"sidebar.hideAllDetails",
Expand Down
4 changes: 4 additions & 0 deletions Sources/GhosttyTerminalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5515,6 +5515,10 @@ final class TerminalSurface: Identifiable, ObservableObject {
if !claudeHooksEnabled {
setManagedEnvironmentValue("CMUX_CLAUDE_HOOKS_DISABLED", "1")
}
setManagedEnvironmentValue(
ClaudeNotificationTypeNormalization.ignoredTypesEnvironmentKey,
ClaudeCodeIntegrationSettings.ignoredNotificationTypes().joined(separator: ",")
)
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved
if let customClaudePath = ClaudeCodeIntegrationSettings.customClaudePath() {
setManagedEnvironmentValue("CMUX_CUSTOM_CLAUDE_PATH", customClaudePath)
}
Expand Down
1 change: 1 addition & 0 deletions Sources/KeyboardShortcutSettingsFileStore+Template.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ extension CmuxSettingsFileStore {
"sound": NotificationSoundSettings.defaultValue,
"customSoundFilePath": NotificationSoundSettings.defaultCustomFilePath,
"command": NotificationSoundSettings.defaultCustomCommand,
"ignoredClaudeNotificationTypes": ClaudeCodeIntegrationSettings.defaultIgnoredNotificationTypes,
"hooksMode": "append",
"hooks": [],
],
Expand Down
7 changes: 7 additions & 0 deletions Sources/KeyboardShortcutSettingsFileStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ final class CmuxSettingsFileStore {
if let raw = jsonString(section["command"]) {
snapshot.managedUserDefaults[NotificationSoundSettings.customCommandKey] = .string(raw)
}
if let values = jsonStringArray(section["ignoredClaudeNotificationTypes"]) {
snapshot.managedUserDefaults[ClaudeCodeIntegrationSettings.ignoredNotificationTypesKey] = .stringArray(
ClaudeCodeIntegrationSettings.normalizedIgnoredNotificationTypes(values)
)
} else if section.keys.contains("ignoredClaudeNotificationTypes") {
logInvalid("notifications.ignoredClaudeNotificationTypes", sourcePath: sourcePath)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

App merge ignores hook precedence

Medium Severity

When a valid primary cmux.json exists but omits notifications.ignoredClaudeNotificationTypes, the Claude hook treats the ignore list as empty and still renders matching notifications. The settings file store can still merge ignored types from legacy or App Support configs into UserDefaults and terminal env, so suppression looks enabled while hooks do not suppress.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4c7ba93. Configure here.

}

private func parseTerminalSection(
Expand Down
Loading
Loading