From 21b0ef28410230b10e7c88e3bc5dbe224c9babf1 Mon Sep 17 00:00:00 2001 From: StuBehan Date: Wed, 25 Nov 2026 07:38:03 +0000 Subject: [PATCH 1/2] fix(mcp): speak a client's nudge, and name Claude Desktop A notify nudge carried no phrase or sound, so with banners off it arrived as a silent row in Events. It's spoken as ": ", with the user's done or permission sound for when voice is off. Claude Desktop names itself local-agent-mode-<server>, which now reads as Claude. --- .../MCPServerTests.swift | 16 ++++++++++++++++ panel/MCPAppContext.swift | 5 ++++- panel/MCPNudge.swift | 7 +++++-- panel/MCPProtocol.swift | 2 ++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Tests/StackNudgePanelCoreTests/MCPServerTests.swift b/Tests/StackNudgePanelCoreTests/MCPServerTests.swift index 6acb24a..a5787c9 100644 --- a/Tests/StackNudgePanelCoreTests/MCPServerTests.swift +++ b/Tests/StackNudgePanelCoreTests/MCPServerTests.swift @@ -501,6 +501,22 @@ final class MCPNudgeTests: XCTestCase { XCTAssertNil(MCPNudge.liveSession(for: fromDesktop, in: [session(pid: 10, claude: "s-10")])) } + // A client asked for the user's attention, so the nudge is spoken, or + // makes the user's own sound, even with banners off. + func testTheNudgeIsSpokenAsTheClient() { + let request = try! MCPNudge.request(from: ["title": "Migration finished"]).get() + let event = MCPNudge.event(request, caller: MCPCaller(clientName: "local-agent-mode-stack-nudge"), + session: nil, sound: "Glass") + XCTAssertEqual(event.agent, "Claude") + XCTAssertEqual(event.voiceMessage, "Claude: Migration finished") + XCTAssertEqual(event.soundName, "Glass") + } + + func testClaudeDesktopIsNamedClaude() { + XCTAssertEqual(MCPCaller.friendlyName("local-agent-mode-stack-nudge"), "Claude") + XCTAssertEqual(MCPCaller.friendlyName("my-own-client"), "my-own-client") + } + // The hook socket may not claim to be MCP: an MCP nudge can take you to a // terminal or app, so only the server makes them. func testAScriptCantClaimToBeMCP() { diff --git a/panel/MCPAppContext.swift b/panel/MCPAppContext.swift index 65582a6..e7f81f8 100644 --- a/panel/MCPAppContext.swift +++ b/panel/MCPAppContext.swift @@ -58,7 +58,10 @@ final class MCPAppContext: MCPContext { func raiseNudge(_ request: MCPNudge.Request, caller: MCPCaller) { onMain { let session = MCPNudge.session(for: caller, in: sessionStore?.sessions ?? []) - store?.append(MCPNudge.event(request, caller: caller, session: session)) + // The sound an agent's own would make: waiting is a prompt's, the + // rest a finished turn's. + let sound = request.kind == .waiting ? nav?.soundPermission : nav?.soundStop + store?.append(MCPNudge.event(request, caller: caller, session: session, sound: sound)) } } diff --git a/panel/MCPNudge.swift b/panel/MCPNudge.swift index dd8095f..9d04cf3 100644 --- a/panel/MCPNudge.swift +++ b/panel/MCPNudge.swift @@ -85,13 +85,16 @@ enum MCPNudge { // The feed event: source mcp, so it can never be a permission prompt and // has its own cap in the queue. It carries what acting on it needs to take // you back: the session's pid and Claude session id, or the launching - // app's bundle id. - static func event(_ request: Request, caller: MCPCaller, session: Session?) -> NudgeEvent { + // app's bundle id. And what to say, since a client asked for the user's + // attention: with banners off, voice may be the only way they hear it. + // `sound` is the user's own, for when voice is off. + static func event(_ request: Request, caller: MCPCaller, session: Session?, sound: String? = nil) -> NudgeEvent { NudgeEvent(agent: caller.displayName, kind: .other, title: request.title, message: request.message, projectPath: session?.projectPath, bundleID: session == nil ? caller.parentBundleID : nil, agentPID: session?.pid, terminalApp: session?.terminalApp, + voiceMessage: "\(caller.displayName): \(request.title)", soundName: sound, claudeSessionID: session?.claudeSessionID ?? caller.claudeSessionID, source: .mcp, tag: request.tag ?? "mcp", severity: request.kind.severity, url: request.url) diff --git a/panel/MCPProtocol.swift b/panel/MCPProtocol.swift index 04c67fb..17d0951 100644 --- a/panel/MCPProtocol.swift +++ b/panel/MCPProtocol.swift @@ -132,6 +132,8 @@ struct MCPCaller: Equatable { // Clients name themselves in code form ("claude-code"); a row reads better // with the product name. static func friendlyName(_ raw: String) -> String { + // Claude Desktop names itself after the server it's talking to. + if raw.lowercased().hasPrefix("local-agent-mode-") { return "Claude" } switch raw.lowercased() { case "claude-code", "claude code": return "Claude Code" case "claude-ai", "claude", "claude-desktop": return "Claude" From 1c9fa76affa14cc775392a226f55c5faebddb35e Mon Sep 17 00:00:00 2001 From: StuBehan <stuart.bainesdinning@gmail.com> Date: Wed, 25 Nov 2026 08:00:47 +0000 Subject: [PATCH 2/2] fix(mcp): a settings change leaves one line in Events The title says what changed and the MCP chip says how, so "Changed over MCP. Settings has the switch for this." under every change was only ever read again. --- Tests/StackNudgePanelCoreTests/MCPServerTests.swift | 8 ++++++++ panel/MCPNudge.swift | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Tests/StackNudgePanelCoreTests/MCPServerTests.swift b/Tests/StackNudgePanelCoreTests/MCPServerTests.swift index a5787c9..de7dcba 100644 --- a/Tests/StackNudgePanelCoreTests/MCPServerTests.swift +++ b/Tests/StackNudgePanelCoreTests/MCPServerTests.swift @@ -512,6 +512,14 @@ final class MCPNudgeTests: XCTestCase { XCTAssertEqual(event.soundName, "Glass") } + func testASettingsChangeLeavesOneLine() { + let setting = SettingSnapshot(key: "STACKNUDGE_THEME", label: "Accent color", category: "appearance", + value: .string("mint"), kindJSON: ["type": "string"], readOnlyReason: nil) + let row = MCPNudge.auditEvent(caller: MCPCaller(clientName: "claude-ai"), setting: setting) + XCTAssertEqual(row.title, "Claude set Accent color to mint") + XCTAssertEqual(row.message, "") + } + func testClaudeDesktopIsNamedClaude() { XCTAssertEqual(MCPCaller.friendlyName("local-agent-mode-stack-nudge"), "Claude") XCTAssertEqual(MCPCaller.friendlyName("my-own-client"), "my-own-client") diff --git a/panel/MCPNudge.swift b/panel/MCPNudge.swift index 9d04cf3..82467fd 100644 --- a/panel/MCPNudge.swift +++ b/panel/MCPNudge.swift @@ -112,10 +112,12 @@ enum MCPNudge { return nil } - // The audit line a settings change leaves in Events. + // The audit line a settings change leaves in Events: one line, since the + // title says what changed and the row's MCP chip says how. Every change + // leaves one, so anything more is read over and over. static func auditEvent(caller: MCPCaller, setting: SettingSnapshot) -> NudgeEvent { NudgeEvent.feed(source: .mcp, tag: "settings", severity: .info, title: "\(caller.displayName) set \(setting.label) to \(SettingsRegistry.describe(setting.value))", - message: "Changed over MCP. Settings has the switch for this.") + message: "") } }