Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

Show Claude Code sessions from terminals (Warp, Terminal, iTerm…)

santiagoOrozco-encoraa5e52d7f8b8c
diff --git a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
index fcd1ac75..2017fb10 100644
--- a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
+++ b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
@@ -123,6 +123,7 @@
875FB3F71BD34B53B0524063 /* CoucouWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6723392BE01AF210E484316 /* CoucouWidgets.swift */; };
878924960FC0F2B3524D48AC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192844E7299DEED5C2372067 /* AppDelegate.swift */; };
8881BC510155DEC038F3B552 /* ServiceSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84ECC59BE7CDDEE348FC7096 /* ServiceSnapshot.swift */; };
+ 88A88E8704759E7F1F9D52BA /* ClaudeHost.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F0D0F67E7C56B9E37E7648 /* ClaudeHost.swift */; };
8A6B3688D6B3BF728D106D8B /* UserIdentity.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A13AEE6E06F46CEC9D908C /* UserIdentity.swift */; };
8AC19BAF88822CB31519D447 /* CoucouIntents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 708E1FD9894461B4AD727DB1 /* CoucouIntents.swift */; };
8C32A0C3EAF536D3836F61D5 /* GreetingCanvasView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C581F7B1A9F14B281B60063E /* GreetingCanvasView.swift */; };
@@ -232,6 +233,7 @@
F28275101D83F121E582B1B1 /* LiveActivityRelay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 136626568FF0C3EAB1D08067 /* LiveActivityRelay.swift */; };
F5D6F8E2CA65AB16B487DDD0 /* IslandScreenGeometry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9466FDE02C9B3FB4EF01DFF8 /* IslandScreenGeometry.swift */; };
F6CA56F362902839EF9A3E2E /* PhoneAssets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 60401D1023D17C3FD30D7113 /* PhoneAssets.xcassets */; };
+ F6D57EEBD7E937EFD2B715CF /* ClaudeHost.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F0D0F67E7C56B9E37E7648 /* ClaudeHost.swift */; };
F9445A71BBF9E4D20224238E /* QuestionPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C6993B34A0FFF8E3D454ADC /* QuestionPayload.swift */; };
FAD78D74C6906D4EC8AA4101 /* UploadSequenceEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FD65943C32E150F1CD65C31 /* UploadSequenceEngine.swift */; };
FB063FE6B8A4BB8FBAAF56CB /* LiveActivityLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FA2D136C81C6D930C5357BD /* LiveActivityLink.swift */; };
@@ -365,6 +367,7 @@
C2DFAEAF1DD1CBF03D3C314E /* TurnRecorder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnRecorder.swift; sourceTree = "<group>"; };
C2E4F18AA940EFF7E047B9F7 /* AppState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppState.swift; sourceTree = "<group>"; };
C581F7B1A9F14B281B60063E /* GreetingCanvasView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GreetingCanvasView.swift; sourceTree = "<group>"; };
+ D0F0D0F67E7C56B9E37E7648 /* ClaudeHost.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClaudeHost.swift; sourceTree = "<group>"; };
D1D96E57E8DADE6B82628E3E /* OpenLeadMochiIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenLeadMochiIntent.swift; sourceTree = "<group>"; };
D6DF93125491729E14636AD8 /* CoucouNotificationContent.appex */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "wrapper.app-extension"; path = CoucouNotificationContent.appex; sourceTree = BUILT_PRODUCTS_DIR; };
D710BD7834228045869D0184 /* IslandWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IslandWindowController.swift; sourceTree = "<group>"; };
@@ -415,6 +418,7 @@
3104222B3F17BA5E8DEA5277 /* CalcomPoller.swift */,
D797CC384B5BC70D34F121BC /* ChatMarkdown.swift */,
BFE88A53AEAA637F866D479D /* ChatMarkdownView.swift */,
+ D0F0D0F67E7C56B9E37E7648 /* ClaudeHost.swift */,
F4263B550838CC5614569D13 /* ClaudePlanCardView.swift */,
8BF22817EC70748F2D1FB2E7 /* ClaudePlanGauge.swift */,
A83D5410BD030B243ADDCFF4 /* ClaudeService.swift */,
@@ -789,6 +793,7 @@
4F1E0B3C838DA3CD6F864BC0 /* CalcomPoller.swift in Sources */,
8FC5907E9506DC79EB1DDC3C /* ChatMarkdown.swift in Sources */,
4976F8BF814D6F817370F1D8 /* ChatMarkdownView.swift in Sources */,
+ 88A88E8704759E7F1F9D52BA /* ClaudeHost.swift in Sources */,
94E0849D13762C6EC8548FEF /* ClaudePlanCardView.swift in Sources */,
D861479F6E7EAD07A6AC2105 /* ClaudePlanGauge.swift in Sources */,
2DEB459FBD0BA3CEAAA5FDE9 /* ClaudeService.swift in Sources */,
@@ -939,6 +944,7 @@
1969590AFEE6CB21404346F1 /* CalcomPoller.swift in Sources */,
B2D86BE268D6F4C86BD0C446 /* ChatMarkdown.swift in Sources */,
733FCC6A45DE963EF2024B4E /* ChatMarkdownView.swift in Sources */,
+ F6D57EEBD7E937EFD2B715CF /* ClaudeHost.swift in Sources */,
18D47AE663EB96BE5638D5F7 /* ClaudePlanCardView.swift in Sources */,
E9C21D11BCB72C392436D19E /* ClaudePlanGauge.swift in Sources */,
0329E76BA4A8FEEA8A6D76E7 /* ClaudeService.swift in Sources */,
diff --git a/NotchBuddy/Sources/App/ClaudeHost.swift b/NotchBuddy/Sources/App/ClaudeHost.swift
new file mode 100644
index 00000000..7d846d79
--- /dev/null
+++ b/NotchBuddy/Sources/App/ClaudeHost.swift
@@ -0,0 +1,75 @@
+import AppKit
+
+// MARK: - ClaudeHost
+//
+// The app a Claude Code session runs in, from the hook payload's term_program /
+// bundle_id. VS Code sessions keep the original "VS Code" pill; sessions from a
+// terminal also route to integration_claude and the pill says "Claude Code".
+
+struct ClaudeHost: Equatable {
+ let bundleId: String
+ let name: String
+
+ /// UserDefaults key: show terminal sessions' questions and permission requests in the
+ /// notch (they then wait for the notch). Off by default: the terminal asks itself.
+ static let terminalCardsKey = "terminalCardsEnabled"
+ static var terminalCardsEnabled: Bool { UserDefaults.standard.bool(forKey: terminalCardsKey) }
+
+ /// Terminals accepted for Claude Code sessions. Keyed by bundle id; the second
+ /// table maps TERM_PROGRAM for hooks that run without __CFBundleIdentifier.
+ private static let terminals: [String: String] = [
+ "dev.warp.Warp-Stable": "Warp",
+ "dev.warp.Warp-Preview": "Warp",
+ "com.apple.Terminal": "Terminal",
+ "com.googlecode.iterm2": "iTerm",
+ "com.mitchellh.ghostty": "Ghostty",
+ "net.kovidgoyal.kitty": "kitty",
+ "org.alacritty": "Alacritty",
+ "com.github.wez.wezterm": "WezTerm",
+ "co.zeit.hyper": "Hyper",
+ "dev.zed.Zed": "Zed",
+ ]
+ private static let termPrograms: [String: String] = [
+ "warpterminal": "dev.warp.Warp-Stable",
+ "apple_terminal": "com.apple.Terminal",
+ "iterm.app": "com.googlecode.iterm2",
+ "ghostty": "com.mitchellh.ghostty",
+ "kitty": "net.kovidgoyal.kitty",
+ "alacritty": "org.alacritty",
+ "wezterm": "com.github.wez.wezterm",
+ "hyper": "co.zeit.hyper",
+ "zed": "dev.zed.Zed",
+ ]
+
+ /// The terminal a session runs in, or nil when it isn't a known terminal.
+ static func terminal(termProgram: String, bundleId: String) -> ClaudeHost? {
+ if let name = terminals[bundleId] { return ClaudeHost(bundleId: bundleId, name: name) }
+ if let id = termPrograms[termProgram.lowercased()], let name = terminals[id] {
+ return ClaudeHost(bundleId: id, name: name)
+ }
+ return nil
+ }
+
+ /// The app name for a task's host; nil host means VS Code (the original routing).
+ static func name(for hostBundleId: String?) -> String {
+ guard let id = hostBundleId, let name = terminals[id] else { return "VS Code" }
+ return name
+ }
+
+ /// Pill label for integration_claude: "VS Code" for editor sessions, "Claude Code" otherwise.
+ static func pillName(hostApp: String?) -> String {
+ hostApp == nil ? "VS Code" : "Claude Code"
+ }
+
+ /// Brings the session's terminal forward (launching it if needed). false when not a terminal host.
+ @discardableResult
+ static func activate(_ hostBundleId: String?) -> Bool {
+ guard let id = hostBundleId, terminals[id] != nil else { return false }
+ if let running = NSWorkspace.shared.runningApplications.first(where: { $0.bundleIdentifier == id }) {
+ running.activate()
+ } else if let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: id) {
+ NSWorkspace.shared.openApplication(at: url, configuration: .init(), completionHandler: nil)
+ }
+ return true
+ }
+}
diff --git a/NotchBuddy/Sources/App/HookServer.swift b/NotchBuddy/Sources/App/HookServer.swift
index 5084320c..e3bd619d 100644
--- a/NotchBuddy/Sources/App/HookServer.swift
+++ b/NotchBuddy/Sources/App/HookServer.swift
@@ -368,6 +368,7 @@ final class HookServer: @unchecked Sendable {
// • other valid coucou_agent → external pill (fire-and-forget, no approval card)
// • Cursor bundle ID → agent_cursor
// • VS Code → integration_claude
+ // • a known terminal (Warp, Terminal, iTerm…) → integration_claude, host recorded on the task
#if !APPSTORE
let isCodexEvent = rawAgent == "codex"
#else
@@ -375,6 +376,7 @@ final class HookServer: @unchecked Sendable {
#endif
let agentId: String
let isExternalAgent: Bool
+ var hostApp: String? = nil
if isCodexEvent {
agentId = "agent_codex"
isExternalAgent = false
@@ -387,6 +389,10 @@ final class HookServer: @unchecked Sendable {
} else if isVSCodeEditor {
agentId = "integration_claude"
isExternalAgent = false
+ } else if let host = ClaudeHost.terminal(termProgram: termProgram, bundleId: bundleId) {
+ agentId = "integration_claude"
+ isExternalAgent = false
+ hostApp = host.bundleId
} else {
nbLog("Ignored \(name) from \(termProgram.isEmpty ? bundleId : termProgram) (\(projectName))")
return
@@ -414,7 +420,7 @@ final class HookServer: @unchecked Sendable {
case "agent_codex": handledNote = "Handled in Codex."
case "agent_copilot": handledNote = "Handled in Copilot CLI."
case "agent_muse": handledNote = "Handled in Muse Code."
- default: handledNote = "Handled in VS Code."
+ default: handledNote = "Handled in \(claudeHostName)."
}
var resolved = false
switch name {
@@ -443,7 +449,7 @@ final class HookServer: @unchecked Sendable {
case "SessionStart":
activeSessionId = sessionId
- if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd) }
+ if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd, hostApp: hostApp) }
if let idx = state.tasks.firstIndex(where: { $0.id == agentId }) { state.tasks[idx].finalLine = nil }
nbLog("SessionStart \(isExternalAgent ? agentId : projectName) (\(sessionId.prefix(8)))")
NotificationCenter.default.post(name: .checkMondayRecap, object: nil)
@@ -452,7 +458,7 @@ final class HookServer: @unchecked Sendable {
case "UserPromptSubmit":
activeSessionId = sessionId
- if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd) }
+ if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd, hostApp: hostApp) }
if let idx = state.tasks.firstIndex(where: { $0.id == agentId }) { state.tasks[idx].finalLine = nil }
state.updateTask(id: agentId, state: .thinking)
if let prompt = payload["prompt"] as? String, !prompt.isEmpty {
@@ -470,7 +476,7 @@ final class HookServer: @unchecked Sendable {
// AskUserQuestion is handled via the dedicated --ask hook.
// Skip state/step update here to avoid flickering over the question card.
guard tool != "AskUserQuestion" else { break }
- if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd) }
+ if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd, hostApp: hostApp) }
state.updateTask(id: agentId, state: .working)
let input = payload["tool_input"] as? [String: Any] ?? [:]
let step = localizedStep(tool: tool, input: input)
@@ -690,7 +696,11 @@ final class HookServer: @unchecked Sendable {
} else {
pillId = "integration_claude"
}
- guard isCodexRequest || isCopilotRequest || isMuseRequest || isCursorEditor || isVSCodeEditor else {
+ // Terminal sessions: only when turned on in Settings, else the terminal asks itself.
+ let terminalHost = isCursorEditor || isVSCodeEditor ? nil
+ : ClaudeHost.terminal(termProgram: termProgram, bundleId: bundleId)
+ let isTerminal = terminalHost != nil && ClaudeHost.terminalCardsEnabled
+ guard isCodexRequest || isCopilotRequest || isMuseRequest || isCursorEditor || isVSCodeEditor || isTerminal else {
Task.detached { [weak self] in
self?.sendLine(fd: fd, text: #"{"permissionDecision":"ask"}"#)
close(fd)
@@ -731,7 +741,7 @@ final class HookServer: @unchecked Sendable {
pendingApprovalFD = fd
activeSessionId = sessionId
- upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd)
+ upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd, hostApp: terminalHost?.bundleId)
state.updateTask(id: pillId, state: .approval)
state.pendingApproval = ApprovalInfo(sessionId: sessionId, tool: tool,
command: command, inputKey: inputKey, pillId: pillId)
@@ -756,7 +766,7 @@ final class HookServer: @unchecked Sendable {
case "agent_codex": note = "Handled in Codex."
case "agent_copilot": note = "Handled in Copilot CLI."
case "agent_muse": note = "Handled in Muse Code."
- default: note = "Handled in VS Code."
+ default: note = "Handled in \(self.claudeHostName)."
}
self.dismissApprovalCard(note: note)
}
@@ -777,7 +787,7 @@ final class HookServer: @unchecked Sendable {
case "agent_codex": note = "Still waiting in Codex."
case "agent_copilot": note = "Still waiting in Copilot CLI."
case "agent_muse": note = "Still waiting in Muse Code."
- default: note = "Still waiting in VS Code."
+ default: note = "Still waiting in \(self.claudeHostName)."
}
self.dismissApprovalCard(note: note)
}
@@ -871,7 +881,11 @@ final class HookServer: @unchecked Sendable {
} else {
pillId = "integration_claude"
}
- guard isCodexRequest || isCursorEditor || isVSCodeEditor else {
+ // Terminal sessions: only when turned on in Settings, else the terminal asks itself.
+ let terminalHost = isCursorEditor || isVSCodeEditor ? nil
+ : ClaudeHost.terminal(termProgram: termProgram, bundleId: bundleId)
+ let isTerminal = terminalHost != nil && ClaudeHost.terminalCardsEnabled
+ guard isCodexRequest || isCursorEditor || isVSCodeEditor || isTerminal else {
Task.detached { [weak self] in
self?.sendLine(fd: fd, text: #"{"permissionDecision":"ask"}"#)
close(fd)
@@ -896,7 +910,7 @@ final class HookServer: @unchecked Sendable {
? "\(pillId)+\(cwd)"
: sessionId
- upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd)
+ upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd, hostApp: terminalHost?.bundleId)
state.updateTask(id: pillId, state: .question)
state.pendingQuestion = parsed
state.isPinned = true
@@ -931,23 +945,31 @@ final class HookServer: @unchecked Sendable {
}
}
+ /// "VS Code", "Warp"… — where the Claude Code pill's current session runs.
+ @MainActor
+ private var claudeHostName: String {
+ ClaudeHost.name(for: AppState.shared.tasks.first { $0.id == "integration_claude" }?.hostApp)
+ }
+
/// Updates or transiently creates a workspace pill (VS Code or Cursor) task.
/// If the task already exists (persistent), just updates name/cwd.
/// If missing (transient), creates it and inserts after the main pill.
@MainActor
- private func upsertWorkspaceTask(id: String, projectName: String, cwd: String = "") {
+ private func upsertWorkspaceTask(id: String, projectName: String, cwd: String = "", hostApp: String? = nil) {
let state = AppState.shared
if let idx = state.tasks.firstIndex(where: { $0.id == id }) {
state.tasks[idx].name = projectName
if !cwd.isEmpty { state.tasks[idx].sessionCwd = cwd }
+ if id == "integration_claude" { state.tasks[idx].hostApp = hostApp }
return
}
// Transient: create and insert after the main pill
let def = PillCatalog.definition(for: id)
let color = def?.color ?? "#C0C4CC"
let source = def?.source ?? .agent
- let task = AgentTask(id: id, name: projectName, color: color,
+ var task = AgentTask(id: id, name: projectName, color: color,
state: .idle, steps: [], source: source, isIntegration: true)
+ if id == "integration_claude" { task.hostApp = hostApp }
if let mainIdx = state.tasks.firstIndex(where: { $0.id == state.mainPillId }) {
state.tasks.insert(task, at: mainIdx + 1)
} else {
diff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swift
index fe623cfa..ce9a995d 100644
--- a/NotchBuddy/Sources/App/IslandViewContent.swift
+++ b/NotchBuddy/Sources/App/IslandViewContent.swift
@@ -182,6 +182,7 @@ struct OverviewView: View {
guard let task else { return }
switch task.id {
case "integration_claude":
+ if ClaudeHost.activate(task.hostApp) { return }
let vscodeBundleId = "com.microsoft.VSCode"
if let app = NSWorkspace.shared.runningApplications.first(where: { $0.bundleIdentifier == vscodeBundleId }) {
app.activate(options: .activateIgnoringOtherApps)
@@ -1897,7 +1898,8 @@ struct IntegrationCardView: View {
Circle()
.fill(Color(hex: task.color))
.frame(width: 7, height: 7)
- Text(PillCatalog.definition(for: task.id)?.name ?? task.name)
+ Text(task.id == "integration_claude" ? ClaudeHost.pillName(hostApp: task.hostApp)
+ : PillCatalog.definition(for: task.id)?.name ?? task.name)
.font(.system(size: 12, weight: .semibold))
.foregroundColor(Color(hex: "#F5F6F8"))
Text(PillCatalog.definition(for: task.id)?.subtitle ?? "Integration")
@@ -1919,7 +1921,12 @@ struct IntegrationCardView: View {
.padding(.top, 2)
HStack(spacing: 8) {
- if task.id == "integration_claude" {
+ if task.id == "integration_claude", task.hostApp != nil {
+ Button("Open \(ClaudeHost.name(for: task.hostApp))") { ClaudeHost.activate(task.hostApp) }
+ .font(.system(size: 11, weight: .medium))
+ .foregroundColor(Color(hex: task.color).opacity(0.7))
+ .buttonStyle(.plain)
+ } else if task.id == "integration_claude" {
Button("Open Visual Studio Code") { openVSCode() }
.font(.system(size: 11, weight: .medium))
.foregroundColor(Color(hex: task.color).opacity(0.7))
@@ -3736,9 +3743,9 @@ struct AgentPill: View {
private var effectiveColor: String { task.color }
- // VS Code pill always shows "VS Code" label regardless of active project name
+ // The Claude pill shows "VS Code" (or "Claude Code" for a terminal session) regardless of project name
private var displayName: String {
- task.id == "integration_claude" ? "VS Code" : task.name
+ task.id == "integration_claude" ? ClaudeHost.pillName(hostApp: task.hostApp) : task.name
}
var body: some View {
diff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swift
index 5fea56ff..56fc8834 100644
--- a/NotchBuddy/Sources/App/SettingsView.swift
+++ b/NotchBuddy/Sources/App/SettingsView.swift
@@ -121,6 +121,7 @@ struct SettingsView: View {
@AppStorage("iPhoneLiveActivityEnabled") private var iPhoneLiveActivityEnabled = false
@AppStorage("iPhoneInstructionsEnabled") private var iPhoneInstructionsEnabled = false
#endif
+ @AppStorage(ClaudeHost.terminalCardsKey) private var terminalCardsEnabled = false
private var appVersion: String {
Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
@@ -502,6 +503,11 @@ struct SettingsView: View {
.buttonStyle(.bordered)
}
#endif
+ Toggle("Answer questions and permissions from terminal sessions in the notch", isOn: $terminalCardsEnabled)
+ Text("Off: sessions in Warp, Terminal, iTerm… show in the notch, but their questions and permission requests are asked in the terminal. On: the notch shows them first, and the terminal waits until you answer there or close the island (up to 2 min).")
+ .font(.system(size: 11))
+ .foregroundColor(.secondary)
+ .fixedSize(horizontal: false, vertical: true)
#if !APPSTORE
if showDiff {
diff --git a/NotchBuddy/Sources/CoucouKit/IslandTypes.swift b/NotchBuddy/Sources/CoucouKit/IslandTypes.swift
index 0c435d0a..b384c20c 100644
--- a/NotchBuddy/Sources/CoucouKit/IslandTypes.swift
+++ b/NotchBuddy/Sources/CoucouKit/IslandTypes.swift
@@ -60,6 +60,7 @@ struct AgentTask: Identifiable, Equatable {
var pillBadge: PillBadge? = nil // alert badge shown on pill when not focused
var sessionCwd: String? = nil // last known working directory (Claude Code sessions)
var finalLine: String? = nil // last assistant message shown as static text after Stop
+ var hostApp: String? = nil // bundle id of the terminal running a Claude Code session; nil = VS Code
}
enum AgentSource: Equatable {
diff --git a/scripts/test-claude-host.sh b/scripts/test-claude-host.sh
new file mode 100755
index 00000000..a51a8e8b
--- /dev/null
+++ b/scripts/test-claude-host.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+set -euo pipefail
+cd "$(dirname "$0")/.."
+TEST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/coucou-claude-host.XXXXXX")"
+trap 'rm -rf "$TEST_DIR"' EXIT
+swiftc NotchBuddy/Sources/App/ClaudeHost.swift \
+ tests/ClaudeHostTests.swift -o "$TEST_DIR/claude-host-tests"
+"$TEST_DIR/claude-host-tests"
diff --git a/tests/ClaudeHostTests.swift b/tests/ClaudeHostTests.swift
new file mode 100644
index 00000000..5c11b3d7
--- /dev/null
+++ b/tests/ClaudeHostTests.swift
@@ -0,0 +1,40 @@
+import Foundation
+
+@main
+enum ClaudeHostTests {
+ static var failures = 0
+
+ static func check(_ label: String, _ got: Bool) {
+ if got { print(" ✓ \(label)") }
+ else { print(" ✗ \(label)"); failures += 1 }
+ }
+
+ static func main() {
+ print("ClaudeHost.terminal")
+ check("Warp by bundle id", ClaudeHost.terminal(termProgram: "", bundleId: "dev.warp.Warp-Stable")?.name == "Warp")
+ check("Warp by TERM_PROGRAM", ClaudeHost.terminal(termProgram: "WarpTerminal", bundleId: "")?.bundleId == "dev.warp.Warp-Stable")
+ check("Terminal.app", ClaudeHost.terminal(termProgram: "Apple_Terminal", bundleId: "")?.name == "Terminal")
+ check("iTerm", ClaudeHost.terminal(termProgram: "iTerm.app", bundleId: "")?.name == "iTerm")
+ check("tmux inside Ghostty: bundle id wins",
+ ClaudeHost.terminal(termProgram: "tmux", bundleId: "com.mitchellh.ghostty")?.name == "Ghostty")
+ check("VS Code → nil", ClaudeHost.terminal(termProgram: "vscode", bundleId: "com.microsoft.VSCode") == nil)
+ check("Cursor → nil", ClaudeHost.terminal(termProgram: "vscode", bundleId: "com.todesktop.230313mzl4w4u92") == nil)
+ check("unknown → nil", ClaudeHost.terminal(termProgram: "", bundleId: "com.example.app") == nil)
+
+ print("ClaudeHost.name / pillName")
+ check("nil host = VS Code", ClaudeHost.name(for: nil) == "VS Code")
+ check("Warp host", ClaudeHost.name(for: "dev.warp.Warp-Stable") == "Warp")
+ check("unknown host = VS Code", ClaudeHost.name(for: "com.example.app") == "VS Code")
+ check("editor session → VS Code", ClaudeHost.pillName(hostApp: nil) == "VS Code")
+ check("terminal session → Claude Code", ClaudeHost.pillName(hostApp: "dev.warp.Warp-Stable") == "Claude Code")
+
+ print("ClaudeHost.terminalCardsEnabled")
+ UserDefaults.standard.removeObject(forKey: ClaudeHost.terminalCardsKey)
+ check("off by default", ClaudeHost.terminalCardsEnabled == false)
+
+ if failures > 0 {
+ print("\n\(failures) test(s) failed."); exit(1)
+ }
+ print("\nAll tests passed.")
+ }
+}