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.

Merge #238 on top of #282: Open terminal brings back the session's own app

Claude18cb7e651be3
diff --cc NotchBuddy/Sources/App/HookServer.swift
index 6d9df4af,69ae96ed..20b3f6d3
--- a/NotchBuddy/Sources/App/HookServer.swift
+++ b/NotchBuddy/Sources/App/HookServer.swift
@@@ -450,21 -418,15 +450,21 @@@ final class HookServer: @unchecked Send
case "SessionStart":
activeSessionId = sessionId
- if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd, hostApp: hostApp) }
- if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd, bundleId: bundleId) }
++ if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd, hostApp: hostApp, bundleId: bundleId) }
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)
if state.isPresent { expandIfNeeded(to: .overview) }
SoundEngine.shared.play("work")
+ if agentId == "agent_hermes", let platform = payload["platform"] as? String,
+ !platform.isEmpty, platform != "cli" {
+ let capitalized = platform.prefix(1).uppercased() + platform.dropFirst()
+ appendStep(id: agentId, step: String(capitalized))
+ }
case "UserPromptSubmit":
activeSessionId = sessionId
- if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd, hostApp: hostApp) }
- if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd, bundleId: bundleId) }
++ if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd, hostApp: hostApp, bundleId: bundleId) }
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 {
@@@ -482,10 -441,10 +482,10 @@@
// 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, hostApp: hostApp) }
- if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd, bundleId: bundleId) }
++ if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd, hostApp: hostApp, bundleId: bundleId) }
state.updateTask(id: agentId, state: .working)
let input = payload["tool_input"] as? [String: Any] ?? [:]
- let step = frenchStep(tool: tool, input: input)
+ let step = localizedStep(tool: tool, input: input)
appendStep(id: agentId, step: step)
nbLog("PreToolUse \(tool)")
@@@ -761,7 -689,7 +761,7 @@@
pendingApprovalFD = fd
activeSessionId = sessionId
- upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd, hostApp: terminalHost?.bundleId)
- upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd, bundleId: bundleId)
++ upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd, hostApp: terminalHost?.bundleId, bundleId: bundleId)
state.updateTask(id: pillId, state: .approval)
state.pendingApproval = ApprovalInfo(sessionId: sessionId, tool: tool,
command: command, inputKey: inputKey, pillId: pillId)
@@@ -928,11 -832,8 +928,11 @@@
pendingQuestionFD = fd
activeSessionId = sessionId
questionPillId = pillId
+ questionSessionId = (sessionId == "unknown" || sessionId.isEmpty)
+ ? "\(pillId)+\(cwd)"
+ : sessionId
- upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd, hostApp: terminalHost?.bundleId)
- upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd, bundleId: bundleId)
++ upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd, hostApp: terminalHost?.bundleId, bundleId: bundleId)
state.updateTask(id: pillId, state: .question)
state.pendingQuestion = parsed
state.isPinned = true
@@@ -977,12 -872,12 +977,13 @@@
/// 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 = "", hostApp: String? = nil) {
- private func upsertWorkspaceTask(id: String, projectName: String, cwd: String = "", bundleId: String = "") {
++ private func upsertWorkspaceTask(id: String, projectName: String, cwd: String = "", hostApp: String? = nil, bundleId: String = "") {
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 }
+ if !bundleId.isEmpty { state.tasks[idx].sessionBundleId = bundleId }
return
}
// Transient: create and insert after the main pill
@@@ -991,7 -886,7 +992,8 @@@
let source = def?.source ?? .agent
var task = AgentTask(id: id, name: projectName, color: color,
state: .idle, steps: [], source: source, isIntegration: true)
+ if id == "integration_claude" { task.hostApp = hostApp }
+ if !bundleId.isEmpty { task.sessionBundleId = bundleId }
if let mainIdx = state.tasks.firstIndex(where: { $0.id == state.mainPillId }) {
state.tasks.insert(task, at: mainIdx + 1)
} else {
diff --cc NotchBuddy/Sources/App/IslandViewContent.swift
index b9aa88fd,d66c82c1..b38593c9
--- a/NotchBuddy/Sources/App/IslandViewContent.swift
+++ b/NotchBuddy/Sources/App/IslandViewContent.swift
@@@ -225,18 -217,9 +225,12 @@@ struct OverviewView: View
NSWorkspace.shared.openApplication(at: url, configuration: .init(), completionHandler: nil)
}
#endif
- case "agent_gemini", "agent_antigravity":
+ case "agent_claude-desktop":
+ openClaudeDesktopApp()
+ case "agent_gemini", "agent_antigravity",
+ "agent_copilot", "agent_muse", "agent_opencode", "agent_amp":
#if !APPSTORE
- let terminalBundleIds = ["com.apple.Terminal", "com.googlecode.iterm2",
- "net.kovidgoyal.kitty", "com.mitchellh.ghostty"]
- if let hit = terminalBundleIds.compactMap({ id in
- NSWorkspace.shared.runningApplications.first { $0.bundleIdentifier == id }
- }).first {
- hit.activate(options: .activateIgnoringOtherApps)
- }
+ TerminalTarget.activate(sessionBundleId: nil)
#endif
case "ai_anthropic":
switchChatProvider(.anthropic)
@@@ -617,31 -546,14 +605,25 @@@ struct FinishedView: View
.lineLimit(1)
.truncationMode(.tail)
HStack(spacing: 8) {
- #if !APPSTORE
- PrimaryButton("Open terminal") {
- if !TerminalTarget.activate(sessionBundleId: state.focusTask?.sessionBundleId) {
- NSWorkspace.shared.open(URL(fileURLWithPath: "/System/Applications/Utilities/Terminal.app"))
+ if state.focusTask?.id == "agent_claude-desktop" {
+ // Sessions from the Claude desktop app live there, not in a terminal.
+ PrimaryButton("Open Claude") {
+ openClaudeDesktopApp()
+ NotificationCenter.default.post(name: .islandCollapse, object: nil)
}
- NotificationCenter.default.post(name: .islandCollapse, object: nil)
+ } else {
+ #if !APPSTORE
+ PrimaryButton("Open terminal") {
- // The terminal the session runs in, when the hooks told us
- if state.focusTask?.id == "integration_claude", ClaudeHost.activate(state.focusTask?.hostApp) {
- NotificationCenter.default.post(name: .islandCollapse, object: nil)
- return
- }
- let terminalBundleIds = ["com.apple.Terminal", "com.googlecode.iterm2", "net.kovidgoyal.kitty", "com.mitchellh.ghostty"]
- let activated = terminalBundleIds.compactMap { id in
- NSWorkspace.shared.runningApplications.first { $0.bundleIdentifier == id }
- }.first.map { $0.activate(options: .activateIgnoringOtherApps) }
- if activated == nil {
++ // The app the session runs in (its terminal, or VS Code), then any known terminal
++ let task = state.focusTask
++ if !(task?.id == "integration_claude" && ClaudeHost.activate(task?.hostApp)),
++ !TerminalTarget.activate(sessionBundleId: task?.sessionBundleId) {
+ NSWorkspace.shared.open(URL(fileURLWithPath: "/System/Applications/Utilities/Terminal.app"))
+ }
+ NotificationCenter.default.post(name: .islandCollapse, object: nil)
+ }
+ #endif
}
- #endif
SecondaryButton("OK") {
NotificationCenter.default.post(name: .islandCollapse, object: nil)
}
diff --cc NotchBuddy/Sources/CoucouKit/IslandTypes.swift
index b384c20c,bf3c2e53..26217856
--- a/NotchBuddy/Sources/CoucouKit/IslandTypes.swift
+++ b/NotchBuddy/Sources/CoucouKit/IslandTypes.swift
@@@ -59,8 -59,8 +59,9 @@@ struct AgentTask: Identifiable, Equatab
var miniEye: EyeShape? = nil
var pillBadge: PillBadge? = nil // alert badge shown on pill when not focused
var sessionCwd: String? = nil // last known working directory (Claude Code sessions)
+ var sessionBundleId: String? = nil // app the session runs in (hook bundle_id), for "Open terminal"
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 {