Files
coucou/tests/TerminalTargetTests.swift
Claude a8ba953d5b Claude Code sessions from Conductor show on the Claude Code pill
Conductor (conductor.build) runs Claude Code with
__CFBundleIdentifier=com.conductor.app and no TERM_PROGRAM, so every hook
event was dropped ("Ignored PreToolUse from com.conductor.app"). It is now a
known host, matched on its bundle id like Orca and cmux: its sessions go to
integration_claude, the pill's button reads "Open Conductor", and "Open
terminal" / ⌃⌥T bring Conductor forward. Conductor has no documented deep
link to an existing workspace, so the app is activated, not a workspace.
Questions and permissions follow the existing terminal opt-in.

The ClaudeHost tests cover Conductor and now run in CI.

Closes #793

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LJm3SRL9k3gBPaVtfPhwcT
2026-10-20 01:12:54 +02:00

52 lines
2.6 KiB
Swift

import Foundation
@main
struct TerminalTargetTests {
static func main() {
var failures = 0
func check(_ cond: Bool, _ msg: String) {
if cond { print("✓ \(msg)") } else { print("✗ \(msg)"); failures += 1 }
}
// The session's own app wins over the fixed list
check(TerminalTarget.pick(sessionBundleId: "com.cmuxterm.app",
running: ["com.apple.Terminal", "com.cmuxterm.app"]) == "com.cmuxterm.app",
"session app (cmux) is preferred over a running Terminal")
// Conductor (no TERM_PROGRAM, bundle id only) goes back to Conductor
check(TerminalTarget.pick(sessionBundleId: "com.conductor.app",
running: ["com.apple.Terminal", "com.conductor.app"]) == "com.conductor.app",
"Conductor session goes back to Conductor")
check(!TerminalTarget.knownTerminals.contains("com.conductor.app"),
"Conductor is not a fallback terminal")
// VS Code integrated terminal goes back to VS Code
check(TerminalTarget.pick(sessionBundleId: "com.microsoft.VSCode",
running: ["com.microsoft.VSCode", "com.googlecode.iterm2"]) == "com.microsoft.VSCode",
"VS Code session goes back to VS Code")
// Session app not running → fall back to known terminals, in order
check(TerminalTarget.pick(sessionBundleId: "com.cmuxterm.app",
running: ["com.googlecode.iterm2", "com.mitchellh.ghostty"]) == "com.googlecode.iterm2",
"falls back to the first running known terminal")
// No bundle id → known terminals only, cmux included
check(TerminalTarget.pick(sessionBundleId: nil, running: ["com.cmuxterm.app"]) == "com.cmuxterm.app",
"cmux is in the fallback list")
check(TerminalTarget.pick(sessionBundleId: " ", running: ["dev.warp.Warp-Stable"]) == "dev.warp.Warp-Stable",
"blank bundle id is ignored")
// Nothing running → nil (caller opens Terminal.app as before)
check(TerminalTarget.pick(sessionBundleId: "com.cmuxterm.app", running: []) == nil,
"nothing running returns nil")
// No duplicates when the session app is already a known terminal
let c = TerminalTarget.candidates(sessionBundleId: "com.mitchellh.ghostty")
check(c.first == "com.mitchellh.ghostty" && c.filter { $0 == "com.mitchellh.ghostty" }.count == 1,
"session app is listed once, first")
if failures > 0 { print("\(failures) failure(s)"); exit(1) }
print("All terminal target tests passed")
}
}