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.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Windows: Open terminal brings the session's own window forward; Claude Desktop opens the app (Mac 0.1.0, #191)
Claudec90d30b536a9
diff --git a/windows/src-tauri/Cargo.toml b/windows/src-tauri/Cargo.tomlindex 3b9bcc91..bf773caa 100644--- a/windows/src-tauri/Cargo.toml+++ b/windows/src-tauri/Cargo.toml@@ -32,7 +32,10 @@ windows = { version = "0.61", features = ["Win32_Foundation","Win32_Security","Win32_Security_Authorization",+ # "Open terminal": the relay's process tree leads to the session's window.+ "Win32_System_Diagnostics_ToolHelp","Win32_System_Ole",+ "Win32_System_Pipes","Win32_System_SystemInformation","Win32_System_Threading","Win32_UI_Input_KeyboardAndMouse",diff --git a/windows/src-tauri/src/lib.rs b/windows/src-tauri/src/lib.rsindex b553ac1e..681113da 100644--- a/windows/src-tauri/src/lib.rs+++ b/windows/src-tauri/src/lib.rs@@ -10,6 +10,7 @@ mod log;mod pipe;mod platform;mod secrets;+mod session_window;mod settings;mod tray;#[cfg(windows)]@@ -175,6 +176,27 @@ fn open_in_vscode(path: Option<String>) -> bool {false}+/// "Open terminal": brings forward the terminal or editor window the session+/// runs in, when it was found (Windows, see session_window.rs); otherwise opens+/// the folder in VS Code, as before.+#[tauri::command]+fn open_session(session_id: Option<String>, path: Option<String>) -> bool {+ if let Some(owner) = session_id.as_deref().and_then(session_window::lookup) {+ let folder = path.as_deref().map(session_window::folder_name).unwrap_or_default();+ if platform::focus_process_window(owner, folder) {+ return true;+ }+ }+ open_in_vscode(path)+}++/// The Claude Desktop pill's target: the Claude app (Windows only — it has no+/// Linux build).+#[tauri::command]+fn open_claude_desktop() -> bool {+ platform::open_claude_desktop()+}+#[tauri::command]fn quit_app(app: AppHandle) {app.exit(0);@@ -412,6 +434,8 @@ pub fn run() {list_monitors,open_url,open_in_vscode,+ open_session,+ open_claude_desktop,quit_app,hooks_status,agent_hooks_status,diff --git a/windows/src-tauri/src/pipe.rs b/windows/src-tauri/src/pipe.rsindex 8d3566b3..da10762b 100644--- a/windows/src-tauri/src/pipe.rs+++ b/windows/src-tauri/src/pipe.rs@@ -34,6 +34,7 @@ use tokio::sync::mpsc;use crate::island::WINDOW_LABEL;use crate::log;+use crate::session_window;/// Slightly under coucou-hook's own 110 s wait, so we always answer first.const DECISION_TIMEOUT: Duration = Duration::from_secs(108);@@ -154,6 +155,10 @@ pub fn start(app: AppHandle) {trait Relay: AsyncRead + AsyncWrite + Unpin {/// Ends the conversation once everything has been written.fn finish(&mut self) {}+ /// The relay process on the other end, where the OS says.+ fn client_pid(&self) -> Option<u32> {+ None+ }}#[cfg(windows)]@@ -161,6 +166,10 @@ impl Relay for NamedPipeServer {fn finish(&mut self) {let _ = self.disconnect();}+ fn client_pid(&self) -> Option<u32> {+ use std::os::windows::io::AsRawHandle;+ crate::platform::pipe_client_pid(self.as_raw_handle())+ }}/// Dropping the stream closes it; the relay reads up to our newline first.@@ -197,6 +206,8 @@ async fn handle(app: AppHandle, mut pipe: impl Relay) {.unwrap_or_default().to_string();+ note_session_window(&pipe, &payload, &event);+if event != "PermissionRequest" {log::line(format!("hook {event}"));let _ = app.emit_to(WINDOW_LABEL, "hook", payload);@@ -226,6 +237,31 @@ async fn handle(app: AppHandle, mut pipe: impl Relay) {pipe.finish();}+/// Finds, once per session, the window it runs in — see session_window.rs.+///+/// Only while the session is unknown, so the process snapshot is not taken on+/// every event. The relay must still be running for its parents to be found:+/// a permission request always is (it waits for us), a quick event may already+/// have exited, and then a later event of the session tries again.+fn note_session_window(pipe: &impl Relay, payload: &Value, event: &str) {+ let Some(session) = payload.get("session_id").and_then(Value::as_str) else { return };+ if event == "SessionEnd" {+ session_window::forget(session);+ return;+ }+ if session_window::known(session) {+ return;+ }+ let Some(relay) = pipe.client_pid() else { return };+ let ancestors = crate::platform::process_ancestors(relay);+ // No ancestors: the relay was already gone, so try again next time. Some,+ // but none with a window (a classic console): settled, VS Code it is.+ if !ancestors.is_empty() {+ let owner = crate::platform::first_with_window(&ancestors);+ session_window::remember(session, owner.unwrap_or(session_window::NO_WINDOW));+ }+}+/// Two waits: a short one for "the card is up", then the long one for a human.async fn wait_for_decision(id: &str, rx: &mut mpsc::Receiver<Reply>) -> Option<String> {match tokio::time::timeout(ACK_TIMEOUT, rx.recv()).await {diff --git a/windows/src-tauri/src/platform/linux.rs b/windows/src-tauri/src/platform/linux.rsindex 8253961d..7333da34 100644--- a/windows/src-tauri/src/platform/linux.rs+++ b/windows/src-tauri/src/platform/linux.rs@@ -208,6 +208,29 @@ pub fn find_on_path(stem: &str) -> Option<PathBuf> {})}+// ── Session windows ("Open terminal") ─────────────────────────────────────────+//+// Wayland lets no app raise another app's window, and X11 would need a window+// manager protocol client this build does not carry, so "Open terminal" opens+// the folder in VS Code here, as before. There is no Claude desktop app for+// Linux either.++pub fn process_ancestors(_pid: u32) -> Vec<u32> {+ Vec::new()+}++pub fn first_with_window(_pids: &[u32]) -> Option<u32> {+ None+}++pub fn focus_process_window(_pid: u32, _folder: &str) -> bool {+ false+}++pub fn open_claude_desktop() -> bool {+ false+}+// ── Cursor ────────────────────────────────────────────────────────────────────/// Nothing polls the cursor here: the page reports it over the island, and thediff --git a/windows/src-tauri/src/platform/windows.rs b/windows/src-tauri/src/platform/windows.rsindex 79bc6a12..b9432ad2 100644--- a/windows/src-tauri/src/platform/windows.rs+++ b/windows/src-tauri/src/platform/windows.rs@@ -1,5 +1,7 @@// Windows: Win32 for the island window and the cursor, %APPDATA% for files.+use std::collections::HashMap;+use std::os::windows::io::RawHandle;use std::os::windows::process::CommandExt;use std::path::PathBuf;use std::process::Command;@@ -10,16 +12,23 @@ use ::windows::core::{BOOL, PWSTR};use ::windows::Win32::Foundation::{CloseHandle, HANDLE, HLOCAL, HWND, LPARAM, LocalFree, POINT};use ::windows::Win32::Security::Authorization::ConvertSidToStringSidW;use ::windows::Win32::Security::{GetTokenInformation, TokenUser, TOKEN_QUERY, TOKEN_USER};+use ::windows::Win32::System::Diagnostics::ToolHelp::{+ CreateToolhelp32Snapshot, Process32FirstW, Process32NextW, PROCESSENTRY32W, TH32CS_SNAPPROCESS,+};use ::windows::Win32::System::Ole::RevokeDragDrop;+use ::windows::Win32::System::Pipes::GetNamedPipeClientProcessId;use ::windows::Win32::System::SystemInformation::GetLocalTime;use ::windows::Win32::System::Threading::{GetCurrentProcess, OpenProcessToken};use ::windows::Win32::UI::Input::KeyboardAndMouse::{GetAsyncKeyState, VK_LBUTTON};use ::windows::Win32::UI::WindowsAndMessaging::{- EnumChildWindows, GetClassNameW, GetCursorPos, GetWindowLongPtrW, SetWindowLongPtrW,- GWL_EXSTYLE, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW,+ EnumChildWindows, EnumWindows, GetClassNameW, GetCursorPos, GetWindow, GetWindowLongPtrW,+ GetWindowTextW, GetWindowThreadProcessId, IsIconic, IsWindowVisible, SetForegroundWindow,+ SetWindowLongPtrW, ShowWindow, GWL_EXSTYLE, GW_OWNER, SW_RESTORE, WS_EX_NOACTIVATE,+ WS_EX_TOOLWINDOW,};use super::LocalTime;+use crate::session_window::{self, Proc};/// File name of the Claude Code relay.pub const HOOK_EXE: &str = "coucou-hook.exe";@@ -236,3 +245,124 @@ pub fn set_pointer_watch(_active: bool) {}/// `set_position` already places a Win32 window on the right display.pub fn pin_to_monitor(_win: &WebviewWindow, _x: i32, _y: i32) {}++// ── Session windows ("Open terminal") ─────────────────────────────────────────+//+// See session_window.rs: the relay's ancestors lead to the terminal or editor+// window a Claude Code session runs in.++/// The process on the other end of a relay connection.+pub fn pipe_client_pid(handle: RawHandle) -> Option<u32> {+ let mut pid = 0u32;+ unsafe { GetNamedPipeClientProcessId(HANDLE(handle), &mut pid).ok()? };+ (pid != 0).then_some(pid)+}++/// Every process, by ID: its parent and its executable's name.+fn process_table() -> HashMap<u32, Proc> {+ let mut out = HashMap::new();+ unsafe {+ let Ok(snapshot) = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) else { return out };+ let mut entry = PROCESSENTRY32W {+ dwSize: std::mem::size_of::<PROCESSENTRY32W>() as u32,+ ..Default::default()+ };+ let mut more = Process32FirstW(snapshot, &mut entry).is_ok();+ while more {+ let len = entry.szExeFile.iter().position(|c| *c == 0).unwrap_or(entry.szExeFile.len());+ out.insert(+ entry.th32ProcessID,+ Proc {+ parent: entry.th32ParentProcessID,+ exe: String::from_utf16_lossy(&entry.szExeFile[..len]),+ },+ );+ more = Process32NextW(snapshot, &mut entry).is_ok();+ }+ let _ = CloseHandle(snapshot);+ }+ out+}++/// The ancestors of a process, nearest first, below the desktop shell.+pub fn process_ancestors(pid: u32) -> Vec<u32> {+ session_window::ancestors(&process_table(), pid)+}++/// Visible top-level windows that are nobody's dialog and have a title:+/// (handle, process ID, title).+fn top_windows() -> Vec<(isize, u32, String)> {+ unsafe extern "system" fn collect(hwnd: HWND, lparam: LPARAM) -> BOOL {+ let list = unsafe { &mut *(lparam.0 as *mut Vec<(isize, u32, String)>) };+ unsafe {+ if !IsWindowVisible(hwnd).as_bool() || GetWindow(hwnd, GW_OWNER).is_ok() {+ return true.into();+ }+ let mut pid = 0u32;+ GetWindowThreadProcessId(hwnd, Some(&mut pid as *mut u32));+ let mut text = [0u16; 512];+ let len = GetWindowTextW(hwnd, &mut text);+ if len > 0 {+ list.push((hwnd.0 as isize, pid, String::from_utf16_lossy(&text[..len as usize])));+ }+ }+ true.into()+ }+ let mut list: Vec<(isize, u32, String)> = Vec::new();+ unsafe {+ let _ = EnumWindows(Some(collect), LPARAM(&mut list as *mut _ as isize));+ }+ list+}++/// The first of `pids` that owns a window.+pub fn first_with_window(pids: &[u32]) -> Option<u32> {+ let windows = top_windows();+ pids.iter().copied().find(|pid| windows.iter().any(|(_, owner, _)| owner == pid))+}++fn bring_forward(raw: isize) -> bool {+ let hwnd = HWND(raw as *mut _);+ unsafe {+ if IsIconic(hwnd).as_bool() {+ let _ = ShowWindow(hwnd, SW_RESTORE);+ }+ // Allowed: the click on the island that asked for this was the last input.+ SetForegroundWindow(hwnd).as_bool()+ }+}++/// Brings `pid`'s window forward — the one titled after `folder` if there are several.+pub fn focus_process_window(pid: u32, folder: &str) -> bool {+ let candidates: Vec<(isize, String)> = top_windows()+ .into_iter()+ .filter(|(_, owner, _)| *owner == pid)+ .map(|(hwnd, _, title)| (hwnd, title))+ .collect();+ session_window::pick_window(&candidates, folder).is_some_and(|hwnd| bring_forward(*hwnd))+}++/// Brings forward the window of a running app, by executable name.+fn focus_app(exe: &str) -> bool {+ let pids: Vec<u32> = process_table()+ .into_iter()+ .filter(|(_, p)| p.exe.eq_ignore_ascii_case(exe))+ .map(|(pid, _)| pid)+ .collect();+ top_windows()+ .into_iter()+ .find(|(_, owner, _)| pids.contains(owner))+ .is_some_and(|(hwnd, _, _)| bring_forward(hwnd))+}++/// The Claude desktop app: brought forward when it runs (Claude Code's own+/// `claude.exe` has no window of its own, so it is never the one picked),+/// started from where its installer puts it otherwise.+pub fn open_claude_desktop() -> bool {+ if focus_app("claude.exe") {+ return true;+ }+ let Some(base) = std::env::var_os("LOCALAPPDATA") else { return false };+ let exe = PathBuf::from(base).join("AnthropicClaude").join("claude.exe");+ exe.is_file() && Command::new(exe).spawn().is_ok()+}diff --git a/windows/src-tauri/src/session_window.rs b/windows/src-tauri/src/session_window.rsnew file mode 100644index 00000000..d1521b2d--- /dev/null+++ b/windows/src-tauri/src/session_window.rs@@ -0,0 +1,230 @@+// "Open terminal" brings the window a Claude Code session runs in to the front,+// instead of opening its folder in VS Code (Mac 0.1.0: jump to the terminal).+//+// The relay is a grandchild of Claude Code, which runs in a shell, which runs+// in the terminal or editor whose window we want. When the relay connects, its+// process is still alive, so walking up from it finds that window's process.+// What is found is kept per session ID, here in memory only, and looked up when+// the button is clicked. Where nothing is found — a classic console, whose+// window belongs to a conhost that is no ancestor, or Linux — the island falls+// back to VS Code as before.+//+// The OS calls live in platform/; this file is the logic, tested on fixtures.++// The process-tree half only runs on Windows; Linux keeps the fallback.+#![cfg_attr(not(windows), allow(dead_code))]++use std::collections::HashMap;+use std::sync::Mutex;++/// One process as a snapshot lists it.+#[derive(Debug, Clone)]+pub struct Proc {+ pub parent: u32,+ /// The executable's file name, as the snapshot gives it (`Code.exe`).+ pub exe: String,+}++/// Never the window of a session: the desktop shell and the services that sit+/// at the top of every process tree. Reaching one of them means the terminal+/// window was not an ancestor (a classic console window belongs to conhost).+const TREE_TOPS: &[&str] = &[+ "explorer.exe", "services.exe", "wininit.exe", "winlogon.exe", "svchost.exe",+ "smss.exe", "csrss.exe", "system", "sihost.exe", "userinit.exe",+];++/// How far up we look. A session sits a handful of levels below its window.+const MAX_DEPTH: usize = 16;++/// The ancestors of `start`, nearest first, stopping before the top of the+/// tree. `start` itself — the relay — is not included. A loop in the parent+/// links (a parent ID reused by a newer process) ends the walk.+pub fn ancestors(procs: &HashMap<u32, Proc>, start: u32) -> Vec<u32> {+ let mut out = Vec::new();+ let mut seen = vec![start];+ let mut current = start;+ while out.len() < MAX_DEPTH {+ let Some(proc) = procs.get(¤t) else { break };+ let parent = proc.parent;+ if parent == 0 || seen.contains(&parent) {+ break;+ }+ let Some(up) = procs.get(&parent) else { break };+ if TREE_TOPS.contains(&up.exe.to_ascii_lowercase().as_str()) {+ break;+ }+ out.push(parent);+ seen.push(parent);+ current = parent;+ }+ out+}++/// The nearest ancestor that owns a window: the terminal or the editor.+pub fn window_owner(procs: &HashMap<u32, Proc>, start: u32, has_window: impl Fn(u32) -> bool) -> Option<u32> {+ ancestors(procs, start).into_iter().find(|pid| has_window(*pid))+}++/// Which of a process's windows to bring forward: the one whose title names+/// the session's folder (an editor with several projects open), else the first.+pub fn pick_window<'a, W>(windows: &'a [(W, String)], folder: &str) -> Option<&'a W> {+ let folder = folder.to_lowercase();+ let named = (!folder.is_empty())+ .then(|| windows.iter().find(|(_, title)| title.to_lowercase().contains(&folder)))+ .flatten();+ named.or_else(|| windows.first()).map(|(w, _)| w)+}++/// The last folder name of a path, either separator.+pub fn folder_name(path: &str) -> &str {+ path.trim_end_matches(['/', '\\']).rsplit(['/', '\\']).next().unwrap_or_default()+}++// ── Sessions seen so far ──────────────────────────────────────────────────────++/// Session ID → the process that owns its window. Small: an old session is+/// dropped once there are more than this many.+const MAX_SESSIONS: usize = 64;++static SESSIONS: Mutex<Vec<(String, u32)>> = Mutex::new(Vec::new());++/// Remembered for a session whose window could not be found, so it is not+/// looked for on every event. No process has this ID.+pub const NO_WINDOW: u32 = 0;++/// A session ID arrives in a hook payload: only what Claude Code sends (a+/// UUID) is kept, at most 128 characters.+fn valid_session(id: &str) -> bool {+ !id.is_empty() && id.len() <= 128 && id.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')+}++pub fn remember(session: &str, owner: u32) {+ if !valid_session(session) {+ return;+ }+ let mut list = SESSIONS.lock().unwrap_or_else(|e| e.into_inner());+ list.retain(|(s, _)| s != session);+ list.push((session.to_string(), owner));+ let excess = list.len().saturating_sub(MAX_SESSIONS);+ list.drain(..excess);+}++/// True once the session has been looked at, window found or not.+pub fn known(session: &str) -> bool {+ let list = SESSIONS.lock().unwrap_or_else(|e| e.into_inner());+ list.iter().any(|(s, _)| s == session)+}++/// The process owning the session's window, if one was found.+pub fn lookup(session: &str) -> Option<u32> {+ let list = SESSIONS.lock().unwrap_or_else(|e| e.into_inner());+ list.iter().find(|(s, _)| s == session).map(|(_, pid)| *pid).filter(|pid| *pid != NO_WINDOW)+}++pub fn forget(session: &str) {+ SESSIONS.lock().unwrap_or_else(|e| e.into_inner()).retain(|(s, _)| s != session);+}++#[cfg(test)]+mod tests {+ use super::*;++ fn tree(entries: &[(u32, u32, &str)]) -> HashMap<u32, Proc> {+ entries+ .iter()+ .map(|(pid, parent, exe)| (*pid, Proc { parent: *parent, exe: exe.to_string() }))+ .collect()+ }++ #[test]+ fn windows_terminal_is_found_above_the_shells() {+ // WindowsTerminal → pwsh → claude (node) → bash → coucou-hook+ let procs = tree(&[+ (4, 0, "System"),+ (100, 4, "explorer.exe"),+ (200, 100, "WindowsTerminal.exe"),+ (300, 200, "pwsh.exe"),+ (400, 300, "node.exe"),+ (500, 400, "bash.exe"),+ (600, 500, "coucou-hook.exe"),+ ]);+ assert_eq!(ancestors(&procs, 600), [500, 400, 300, 200]);+ assert_eq!(window_owner(&procs, 600, |pid| pid == 200 || pid == 100), Some(200));+ }++ #[test]+ fn vs_code_is_found_through_its_pty_host() {+ let procs = tree(&[+ (100, 1, "explorer.exe"),+ (210, 100, "Code.exe"),+ (220, 210, "Code.exe"),+ (300, 220, "powershell.exe"),+ (400, 300, "node.exe"),+ (600, 400, "coucou-hook.exe"),+ ]);+ assert_eq!(window_owner(&procs, 600, |pid| pid == 210), Some(210));+ }++ #[test]+ fn a_classic_console_finds_nothing_rather_than_the_desktop() {+ // cmd.exe's window belongs to conhost, which is not an ancestor; the+ // walk must stop at explorer instead of picking the taskbar.+ let procs = tree(&[+ (100, 1, "explorer.exe"),+ (300, 100, "cmd.exe"),+ (400, 300, "node.exe"),+ (600, 400, "coucou-hook.exe"),+ ]);+ assert_eq!(window_owner(&procs, 600, |pid| pid == 100), None);+ }++ #[test]+ fn a_relay_already_gone_or_a_loop_ends_the_walk() {+ assert!(ancestors(&tree(&[]), 600).is_empty());+ let looped = tree(&[(1, 2, "a.exe"), (2, 1, "b.exe"), (3, 1, "coucou-hook.exe")]);+ assert_eq!(ancestors(&looped, 3), [1, 2]);+ let deep: Vec<(u32, u32, &str)> = (1..100).map(|i| (i, i + 1, "x.exe")).collect();+ assert_eq!(ancestors(&tree(&deep), 1).len(), MAX_DEPTH);+ }++ #[test]+ fn the_window_named_after_the_project_wins() {+ let windows = vec![+ (1, "notes — Visual Studio Code".to_string()),+ (2, "app.ts — coucou — Visual Studio Code".to_string()),+ ];+ assert_eq!(pick_window(&windows, "Coucou"), Some(&2));+ assert_eq!(pick_window(&windows, "other"), Some(&1));+ assert_eq!(pick_window(&windows, ""), Some(&1));+ assert_eq!(pick_window::<i32>(&[], "x"), None);+ assert_eq!(folder_name(r"C:\Users\me\coucou\"), "coucou");+ assert_eq!(folder_name("/home/me/proj"), "proj");+ }++ #[test]+ fn sessions_are_remembered_by_id_and_only_plausible_ids_are_kept() {+ remember("s-test-1", 42);+ remember("s-test-1", 43);+ assert_eq!(lookup("s-test-1"), Some(43));+ remember("not a session/../x", 7);+ assert!(!known("not a session/../x"));+ forget("s-test-1");+ assert!(!known("s-test-1"));++ // A session without a window is settled, with nothing to show.+ remember("s-test-2", NO_WINDOW);+ assert!(known("s-test-2"));+ assert_eq!(lookup("s-test-2"), None);+ forget("s-test-2");++ // Only the latest sessions are kept. (One test: the list is shared.)+ for i in 0..(MAX_SESSIONS + 5) {+ remember(&format!("s-cap-{i}"), 1);+ }+ assert!(!known("s-cap-0"));+ assert!(known(&format!("s-cap-{}", MAX_SESSIONS + 4)));+ for i in 0..(MAX_SESSIONS + 5) {+ forget(&format!("s-cap-{i}"));+ }+ }+}diff --git a/windows/src/core/bridge.ts b/windows/src/core/bridge.tsindex 35c50dc8..4eb29d77 100644--- a/windows/src/core/bridge.ts+++ b/windows/src/core/bridge.ts@@ -58,6 +58,16 @@ export const Bridge = {/** "Open terminal" → opens the folder in VS Code when `code` is on PATH. */openInVSCode: (path: string | null) => call<boolean>("open_in_vscode", { path }),+ /**+ * "Open terminal": the window the session runs in when Rust found it+ * (Windows), else the folder in VS Code.+ */+ openSession: (sessionId: string | null, path: string | null) =>+ call<boolean>("open_session", { sessionId, path }),++ /** The Claude desktop app, for the Claude Desktop pill (Windows only). */+ openClaudeDesktop: () => call<boolean>("open_claude_desktop"),+quit: () => call<void>("quit_app"),openSettingsWindow: () => call<void>("open_settings_window"),diff --git a/windows/src/island/island.ts b/windows/src/island/island.tsindex 384cf408..39939e4e 100644--- a/windows/src/island/island.ts+++ b/windows/src/island/island.ts@@ -23,6 +23,7 @@ import { IslandStateMachine } from "./fsm";import { refreshHookPills } from "./integrations";const BOT_OVERHANG = 40;+const CLAUDE_DESKTOP_ID = "agent_claude-desktop";/** Same margin as the Rust hit test (src-tauri/src/island.rs). */const HIT_MARGIN = 14;@@ -134,8 +135,10 @@ export class Island {Sound.play("blip");},openTerminal: () => {- const cwd = State.focusTask?.sessionCwd ?? null;- void Bridge.openInVSCode(cwd);+ const task = State.focusTask;+ // Sessions from the Claude desktop app live there, not in a terminal.+ if (task?.id === CLAUDE_DESKTOP_ID) void Bridge.openClaudeDesktop();+ else void Bridge.openSession(task?.sessionId ?? null, task?.sessionCwd ?? null);},// The ↗ button — same targets as openAgentTarget() on macOS.openTarget: () => {@@ -149,8 +152,10 @@ export class Island {integration_notion: "https://notion.so",integration_calcom: "https://app.cal.com/bookings",};- if (task.id === "integration_claude") void Bridge.openInVSCode(task.sessionCwd ?? null);- else if (task.id === "integration_n8n") void Bridge.openN8n();+ if (task.id === CLAUDE_DESKTOP_ID) void Bridge.openClaudeDesktop();+ else if (task.id === "integration_claude" || task.sessionId) {+ void Bridge.openSession(task.sessionId ?? null, task.sessionCwd ?? null);+ } else if (task.id === "integration_n8n") void Bridge.openN8n();else if (urls[task.id]) void Bridge.openUrl(urls[task.id]);},openUrl: (url) => {diff --git a/windows/src/views/integrations.ts b/windows/src/views/integrations.tsindex cf2564a3..75bc42a6 100644--- a/windows/src/views/integrations.ts+++ b/windows/src/views/integrations.ts@@ -94,6 +94,15 @@ function idleCard(task: AgentTask, openSettings: () => void): HTMLElement {onclick: () => void Bridge.openInVSCode(task.sessionCwd ?? null),}),);+ } else if (task.id === "agent_claude-desktop") {+ actions.append(+ h("button", {+ class: "link-btn",+ style: `color:${task.color}d9`,+ text: "Open Claude",+ onclick: () => void Bridge.openClaudeDesktop(),+ }),+ );} else if (task.id === "integration_n8n") {actions.append(h("button", {diff --git a/windows/src/views/views.ts b/windows/src/views/views.tsindex d7761036..a7bb9f22 100644--- a/windows/src/views/views.ts+++ b/windows/src/views/views.ts@@ -493,8 +493,9 @@ function buildError(actions: ViewActions): ViewHost {function buildFinished(actions: ViewActions): ViewHost {const who = h("div");const title = h("div", { class: "title" });+ const open = btn("Open terminal", "primary", () => actions.openTerminal());const row = h("div", { class: "actions" },- btn("Open terminal", "primary", () => actions.openTerminal()),+ open,btn("OK", "secondary", () => actions.collapse()),);const el = h("div", { class: "view" }, card("green", stack(116, 16, who, title, row)));@@ -504,6 +505,10 @@ function buildFinished(actions: ViewActions): ViewHost {clear(who);who.append(agentWho(State.focusTask, "Claude Code finished"));title.textContent = State.focusTask?.steps.at(-1) ?? "Session finished";+ // Sessions from the Claude desktop app live there, not in a terminal.+ const label = State.focusTask?.id === "agent_claude-desktop" ? "Open Claude" : "Open terminal";+ const span = open.firstElementChild as HTMLElement;+ if (span.textContent !== label) span.textContent = label;},};}