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
feat(windows): support Gemini CLI hooks and session island view
Totopo27777d06f91194
diff --git a/windows/hook/src/main.rs b/windows/hook/src/main.rsindex 5bb36378..ea6de1b5 100644--- a/windows/hook/src/main.rs+++ b/windows/hook/src/main.rs@@ -44,8 +44,82 @@ mod unix;#[cfg(target_os = "linux")]use unix::connect;+/// Normalize event names across agents (Claude Code, Gemini CLI, Antigravity)+fn normalize_event(name: &str) -> String {+ match name {+ "BeforeTool" | "BeforeToolSelection" => "PreToolUse".to_string(),+ "AfterTool" | "AfterModel" | "PostInvocation" => "PostToolUse".to_string(),+ "BeforeAgent" | "PreInvocation" => "UserPromptSubmit".to_string(),+ "AfterAgent" => "Stop".to_string(),+ "startup" => "SessionStart".to_string(),+ "exit" => "SessionEnd".to_string(),+ other => other.to_string(),+ }+}++/// Normalize tool fields from Gemini CLI format (`toolCall: {name, args: {...}}`)+/// into canonical `tool_name` and `tool_input`.+fn normalize_tool_fields(map: &mut serde_json::Map<String, serde_json::Value>) {+ if !map.contains_key("tool_name") {+ let (extracted_name, extracted_input) = if let Some(tool) = map.get("toolCall").and_then(|t| t.as_object()) {+ let name = tool.get("name").and_then(|n| n.as_str()).map(|n| n.to_string());+ let input = if let Some(args) = tool.get("args").and_then(|a| a.as_object()) {+ let mut input_map = serde_json::Map::new();+ for (k, v) in args {+ let target_key = match k.as_str() {+ "CommandLine" => "command",+ "FilePath" => "file_path",+ "Path" => "path",+ "Url" => "url",+ "Query" => "query",+ "Pattern" => "pattern",+ other => other,+ };+ input_map.insert(target_key.into(), v.clone());+ }+ Some(input_map)+ } else {+ None+ };+ (name, input)+ } else if let Some(name) = map.get("tool").and_then(|t| t.as_str()) {+ (Some(name.to_string()), None)+ } else {+ (None, None)+ };++ if let Some(name) = extracted_name {+ map.insert("tool_name".into(), serde_json::Value::String(name));+ }+ if let Some(input) = extracted_input {+ if !map.contains_key("tool_input") {+ map.insert("tool_input".into(), serde_json::Value::Object(input));+ }+ }+ }++ if !map.contains_key("session_id") {+ let mut found_sid = None;+ for key in &["conversationId", "conversation_id", "sessionId", "GEMINI_SESSION_ID"] {+ if let Some(val) = map.get(*key).and_then(|v| v.as_str()) {+ if !val.is_empty() {+ found_sid = Some(val.to_string());+ break;+ }+ }+ }+ if let Some(sid) = found_sid {+ map.insert("session_id".into(), serde_json::Value::String(sid));+ } else if let Ok(sid) = std::env::var("GEMINI_SESSION_ID") {+ if !sid.is_empty() {+ map.insert("session_id".into(), serde_json::Value::String(sid));+ }+ }+ }+}+fn main() {- let Some((payload, event)) = read_event() else { std::process::exit(0) };+ let Some((payload, event, agent)) = read_event() else { std::process::exit(0) };let waits_for_answer = event == "PermissionRequest";let budget = if waits_for_answer { DECISION_BUDGET } else { FIRE_AND_FORGET_BUDGET };@@ -65,6 +139,11 @@ fn main() {let _ = writeln!(out, "{json}");let _ = out.flush();}+ } else if !waits_for_answer && (agent == "gemini" || agent == "antigravity") {+ // Gemini CLI and Antigravity expect a JSON response on stdout ({})+ let mut out = std::io::stdout();+ let _ = writeln!(out, "{{}}");+ let _ = out.flush();}// Nothing printed: Claude Code asks in the terminal, as if we were not here.std::process::exit(0);@@ -86,8 +165,8 @@ fn decision_json(decision: &str) -> Option<String> {))}-/// Reads stdin and returns the payload to forward plus the event name.-fn read_event() -> Option<(String, String)> {+/// Reads stdin and returns the payload to forward plus the event name and agent.+fn read_event() -> Option<(String, String, String)> {let mut raw = Vec::new();if std::io::stdin().read_to_end(&mut raw).is_err() || raw.is_empty() {return None;@@ -118,14 +197,18 @@ fn read_event() -> Option<(String, String)> {// Which agent this hook was installed for. Absent means Claude Code,// so existing hook commands keep working unchanged.if !agent.is_empty() {- map.insert("coucou_agent".into(), serde_json::Value::String(agent));+ map.insert("coucou_agent".into(), serde_json::Value::String(agent.clone()));}- let event = map++ normalize_tool_fields(map);++ let raw_event = map.get("hook_event_name").and_then(|v| v.as_str()).map(str::to_string).filter(|s| !s.is_empty()).unwrap_or(arg_event);+ let event = normalize_event(&raw_event);map.insert("hook_event_name".into(), serde_json::Value::String(event.clone()));for field in DROPPED_FIELDS {@@ -138,7 +221,21 @@ fn read_event() -> Option<(String, String)> {.map(str::is_empty).unwrap_or(true);if cwd_missing {- if let Ok(cwd) = std::env::current_dir() {+ // Also check workspacePaths or workspace_roots (Gemini CLI)+ let mut found_path = None;+ for key in &["workspacePaths", "workspace_roots"] {+ if let Some(arr) = map.get(*key).and_then(|v| v.as_array()) {+ if let Some(first) = arr.first().and_then(|v| v.as_str()) {+ if !first.is_empty() {+ found_path = Some(first.to_string());+ break;+ }+ }+ }+ }+ if let Some(p) = found_path {+ map.insert("cwd".into(), serde_json::Value::String(p));+ } else if let Ok(cwd) = std::env::current_dir() {map.insert("cwd".into(),serde_json::Value::String(cwd.to_string_lossy().to_string()),@@ -165,7 +262,7 @@ fn read_event() -> Option<(String, String)> {let mut line = payload.to_string();line.push('\n');- Some((line, event))+ Some((line, event, agent))}/// Caps every string in the payload. A single Write can carry a whole file.@@ -253,4 +350,35 @@ mod tests {assert!(s.len() <= MAX_FIELD_LEN + 4);assert!(s.ends_with('…'));}++ #[test]+ fn normalize_event_maps_gemini_events_to_canonical() {+ assert_eq!(normalize_event("BeforeTool"), "PreToolUse");+ assert_eq!(normalize_event("AfterTool"), "PostToolUse");+ assert_eq!(normalize_event("BeforeAgent"), "UserPromptSubmit");+ assert_eq!(normalize_event("AfterAgent"), "Stop");+ assert_eq!(normalize_event("startup"), "SessionStart");+ assert_eq!(normalize_event("exit"), "SessionEnd");+ assert_eq!(normalize_event("PreToolUse"), "PreToolUse");+ }++ #[test]+ fn normalize_tool_fields_extracts_gemini_tool_call() {+ let mut map = serde_json::Map::new();+ map.insert(+ "toolCall".into(),+ serde_json::json!({+ "name": "Bash",+ "args": {+ "CommandLine": "ls -la"+ }+ }),+ );+ map.insert("conversationId".into(), serde_json::json!("gemini-conv-123"));+ normalize_tool_fields(&mut map);++ assert_eq!(map.get("tool_name").unwrap(), "Bash");+ assert_eq!(map.get("tool_input").unwrap()["command"], "ls -la");+ assert_eq!(map.get("session_id").unwrap(), "gemini-conv-123");+ }}diff --git a/windows/src-tauri/src/hooks.rs b/windows/src-tauri/src/hooks.rsindex 3da1d0e5..03708ed9 100644--- a/windows/src-tauri/src/hooks.rs+++ b/windows/src-tauri/src/hooks.rs@@ -237,6 +237,258 @@ fn current_fingerprint() -> String {// ── Public API ────────────────────────────────────────────────────────────────+pub fn gemini_settings_path() -> PathBuf {+ platform::home_dir().join(".gemini").join("settings.json")+}++const GEMINI_EVENTS: &[(&str, &str, u64)] = &[+ ("SessionStart", "SessionStart", 10000),+ ("SessionEnd", "SessionEnd", 10000),+ ("BeforeTool", "PreToolUse", 5000),+ ("AfterTool", "PostToolUse", 5000),+ ("BeforeAgent", "UserPromptSubmit", 5000),+ ("AfterAgent", "Stop", 5000),+];++#[cfg(windows)]+fn gemini_hook_command(event: &str) -> String {+ let exe = settings::hook_exe_path().to_string_lossy().replace('\\', "/");+ format!("\"{exe}\" --agent gemini {event}")+}++#[cfg(unix)]+fn gemini_hook_command(event: &str) -> String {+ format!(+ "{} --agent gemini {event}",+ sh_quote(&settings::hook_exe_path().to_string_lossy())+ )+}++fn read_gemini_settings() -> Result<Value, String> {+ let path = gemini_settings_path();+ match std::fs::read(&path) {+ Ok(bytes) => parse_settings(&bytes, &path.display().to_string()),+ Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(json!({})),+ Err(err) => Err(format!("Can't read {}: {err}", path.display())),+ }+}++fn read_gemini_settings_lossy() -> Value {+ read_gemini_settings().unwrap_or_else(|_| json!({}))+}++fn gemini_entry_is_ours(entry: &Value) -> bool {+ if let Some(cmd) = entry.get("command").and_then(Value::as_str) {+ if cmd.contains(MARKER) && cmd.contains("--agent gemini") {+ return true;+ }+ }+ if let Some(inner) = entry.get("hooks").and_then(Value::as_array) {+ if inner.iter().any(|h| {+ h.get("command")+ .and_then(Value::as_str)+ .map(|c| c.contains(MARKER) && c.contains("--agent gemini"))+ .unwrap_or(false)+ }) {+ return true;+ }+ }+ false+}++fn remove_gemini_nb_hook_entries(groups: &[Value]) -> Vec<Value> {+ let mut out = Vec::new();+ for group in groups {+ if let Some(cmd) = group.get("command").and_then(Value::as_str) {+ if cmd.contains(MARKER) && cmd.contains("--agent gemini") {+ continue;+ }+ }+ if let Some(inner) = group.get("hooks").and_then(Value::as_array) {+ let filtered: Vec<Value> = inner+ .iter()+ .filter(|h| {+ !h.get("command")+ .and_then(Value::as_str)+ .map(|c| c.contains(MARKER) && c.contains("--agent gemini"))+ .unwrap_or(false)+ })+ .cloned()+ .collect();+ if !filtered.is_empty() {+ let mut updated = group.as_object().cloned().unwrap_or_default();+ updated.insert("hooks".into(), Value::Array(filtered));+ out.push(Value::Object(updated));+ }+ } else {+ out.push(group.clone());+ }+ }+ out+}++fn merged_gemini(existing: &Value) -> Result<Value, String> {+ let mut root = existing.as_object().cloned().unwrap_or_default();+ if let Some(raw) = root.get("hooks") {+ if !raw.is_object() {+ return Err("~/.gemini/settings.json: \"hooks\" has an unexpected type — Coucou won't touch it.".into());+ }+ }+ let mut hooks = root+ .get("hooks")+ .and_then(Value::as_object)+ .cloned()+ .unwrap_or_else(Map::new);++ for (gemini_event, normalized_event, timeout) in GEMINI_EVENTS {+ if let Some(raw) = hooks.get(*gemini_event) {+ if !raw.is_array() {+ return Err(format!(+ "~/.gemini/settings.json: \"hooks\"[\"{gemini_event}\"] has an unexpected type — Coucou won't touch it."+ ));+ }+ }+ let list = hooks+ .get(*gemini_event)+ .and_then(Value::as_array)+ .cloned()+ .unwrap_or_default();+ let mut cleaned = remove_gemini_nb_hook_entries(&list);+ cleaned.push(json!({+ "matcher": "*",+ "hooks": [{+ "type": "command",+ "command": gemini_hook_command(normalized_event),+ "timeout": timeout,+ }]+ }));+ hooks.insert((*gemini_event).to_string(), Value::Array(cleaned));+ }++ root.insert("hooks".into(), Value::Object(hooks));+ Ok(Value::Object(root))+}++fn without_gemini_ours(existing: &Value) -> Result<Value, String> {+ let mut root = existing.as_object().cloned().unwrap_or_default();+ let Some(raw_hooks) = root.get("hooks") else {+ return Ok(Value::Object(root));+ };+ let Some(hooks) = raw_hooks.as_object() else {+ return Err("~/.gemini/settings.json: \"hooks\" has an unexpected type — Coucou won't touch it.".into());+ };+ let mut out = Map::new();+ for (event, value) in hooks {+ match value.as_array() {+ Some(list) => {+ let kept = remove_gemini_nb_hook_entries(list);+ if !kept.is_empty() {+ out.insert(event.clone(), Value::Array(kept));+ }+ }+ None => {+ out.insert(event.clone(), value.clone());+ }+ }+ }+ if out.is_empty() {+ root.remove("hooks");+ } else {+ root.insert("hooks".into(), Value::Object(out));+ }+ Ok(Value::Object(root))+}++fn gemini_backup_path() -> PathBuf {+ let p = gemini_settings_path();+ p.with_file_name(format!("settings.json.bak-{}", stamp()))+}++fn gemini_current_fingerprint() -> String {+ match std::fs::read(gemini_settings_path()) {+ Ok(bytes) => fingerprint(&bytes),+ Err(_) => fingerprint(b""),+ }+}++pub fn gemini_status() -> HookStatus {+ let current = read_gemini_settings_lossy();+ let installed = current+ .get("hooks")+ .and_then(Value::as_object)+ .map(|hooks| {+ hooks+ .values()+ .filter_map(Value::as_array)+ .flatten()+ .any(gemini_entry_is_ours)+ })+ .unwrap_or(false);+ let hook_path = settings::hook_exe_path();+ HookStatus {+ installed,+ settings_path: gemini_settings_path().to_string_lossy().to_string(),+ hook_ready: hook_path.exists(),+ hook_path: hook_path.to_string_lossy().to_string(),+ }+}++pub fn gemini_preview(install: bool) -> Result<HookPreview, String> {+ let current = read_gemini_settings()?;+ let next = if install {+ merged_gemini(¤t)?+ } else {+ without_gemini_ours(¤t)?+ };+ Ok(HookPreview {+ diff: unified_diff(&pretty(¤t), &pretty(&next)),+ backup: gemini_backup_path().to_string_lossy().to_string(),+ settings_path: gemini_settings_path().to_string_lossy().to_string(),+ fingerprint: gemini_current_fingerprint(),+ })+}++pub fn gemini_write(install: bool, fingerprint: &str) -> Result<String, String> {+ let path = gemini_settings_path();+ let dir = path.parent().unwrap_or(Path::new("."));+ std::fs::create_dir_all(dir).map_err(|e| e.to_string())?;++ let current = read_gemini_settings()?;+ if gemini_current_fingerprint() != fingerprint {+ return Err(format!(+ "{} changed since the preview. Nothing was written — review the new diff.",+ path.display()+ ));+ }++ let backup = gemini_backup_path();+ if path.exists() {+ std::fs::copy(&path, &backup).map_err(|e| format!("backup failed: {e}"))?;+ }++ let next = if install {+ merged_gemini(¤t)?+ } else {+ without_gemini_ours(¤t)?+ };+ let mut text = pretty(&next);+ text.push('\n');++ #[cfg(unix)]+ let path = std::fs::canonicalize(&path).unwrap_or(path);++ let temp = path.with_extension(format!("json.coucou-{}", std::process::id()));+ if let Err(err) = write_like(&temp, &path, text.as_bytes()) {+ let _ = std::fs::remove_file(&temp);+ return Err(format!("write failed: {err}"));+ }+ if let Err(err) = std::fs::rename(&temp, &path) {+ let _ = std::fs::remove_file(&temp);+ return Err(format!("write failed: {err}"));+ }+ Ok(backup.to_string_lossy().to_string())+}+pub fn status() -> HookStatus {let current = read_settings_lossy();let installed = current@@ -574,6 +826,28 @@ mod tests {assert_eq!(cleaned, existing);}+ #[test]+ fn merging_gemini_creates_groups_and_preserves_others() {+ let existing = serde_json::json!({+ "theme": "dark",+ "hooks": {+ "BeforeTool": [+ { "matcher": "other", "hooks": [{ "type": "command", "command": "custom.exe" }] }+ ]+ }+ });++ let after = merged_gemini(&existing).unwrap();+ assert_eq!(after["theme"], "dark");+ let before_tool = after["hooks"]["BeforeTool"].as_array().unwrap();+ assert_eq!(before_tool.len(), 2);+ assert!(before_tool[0]["matcher"] == "other");+ assert!(gemini_entry_is_ours(&before_tool[1]));++ let cleaned = without_gemini_ours(&after).unwrap();+ assert_eq!(cleaned, existing);+ }+#[test]fn a_fingerprint_notices_any_change() {assert_eq!(fingerprint(b"{}"), fingerprint(b"{}"));diff --git a/windows/src-tauri/src/lib.rs b/windows/src-tauri/src/lib.rsindex 714103e5..15aa450a 100644--- a/windows/src-tauri/src/lib.rs+++ b/windows/src-tauri/src/lib.rs@@ -47,8 +47,9 @@ pub struct BootInfo {#[tauri::command]fn boot(app: AppHandle, shared: State<Shared>) -> BootInfo {let mut settings = shared.settings.lock().unwrap().clone();- // The real state of ~/.claude/settings.json wins over whatever we stored.+ // The real state of ~/.claude/settings.json and ~/.gemini/settings.json wins over whatever we stored.settings.hooks_installed = hooks::status().installed;+ settings.gemini_hooks_installed = hooks::gemini_status().installed;let screen = island::screen_info(&app, &settings.screen);BootInfo {settings,@@ -211,6 +212,36 @@ fn hooks_apply(Ok(backup)}+// ── Gemini CLI hooks ──────────────────────────────────────────────────────────++#[tauri::command]+fn gemini_hooks_status() -> HookStatus {+ hooks::gemini_status()+}++#[tauri::command]+fn gemini_hooks_preview(install: bool) -> Result<HookPreview, String> {+ hooks::gemini_preview(install)+}++#[tauri::command]+fn gemini_hooks_apply(+ app: AppHandle,+ shared: State<Shared>,+ install: bool,+ fingerprint: String,+) -> Result<String, String> {+ let backup = hooks::gemini_write(install, &fingerprint)?;+ let updated = {+ let mut current = shared.settings.lock().unwrap();+ current.gemini_hooks_installed = install;+ let _ = settings::save(¤t);+ current.clone()+ };+ let _ = app.emit("settings-changed", updated);+ Ok(backup)+}+#[tauri::command]fn approval_decision(app: AppHandle, request_id: String, decision: String) {pipe::answer(&app, &request_id, &decision);@@ -387,6 +418,9 @@ pub fn run() {hooks_status,hooks_preview,hooks_apply,+ gemini_hooks_status,+ gemini_hooks_preview,+ gemini_hooks_apply,approval_decision,approval_ack,approval_decline,diff --git a/windows/src-tauri/src/settings.rs b/windows/src-tauri/src/settings.rsindex 2a8d7d35..a90fa85f 100644--- a/windows/src-tauri/src/settings.rs+++ b/windows/src-tauri/src/settings.rs@@ -16,6 +16,8 @@ pub struct Settings {pub screen: String,pub autostart: bool,pub hooks_installed: bool,+ #[serde(default)]+ pub gemini_hooks_installed: bool,/// Claude model used by the chat. Changeable in the settings window./// Defaulted explicitly so a settings.json written by an older build still loads.#[serde(default = "default_model")]@@ -42,6 +44,7 @@ impl Default for Settings {screen: "primary".into(),autostart: false,hooks_installed: false,+ gemini_hooks_installed: false,model: default_model(),}}diff --git a/windows/src/core/bridge.ts b/windows/src/core/bridge.tsindex 24aaf55f..12cec1a4 100644--- a/windows/src/core/bridge.ts+++ b/windows/src/core/bridge.ts@@ -73,6 +73,13 @@ export const Bridge = {hooksApply: (install: boolean, fingerprint: string) =>callOrThrow<string>("hooks_apply", { install, fingerprint }),+ // ── Gemini CLI hooks ───────────────────────────────────────────────────────+ geminiHooksStatus: () => call<HookStatus>("gemini_hooks_status"),+ geminiHooksPreview: (install: boolean) =>+ callOrThrow<HookPreview>("gemini_hooks_preview", { install }),+ geminiHooksApply: (install: boolean, fingerprint: string) =>+ callOrThrow<string>("gemini_hooks_apply", { install, fingerprint }),+approvalDecision: (requestId: string, decision: "allow" | "deny") =>call<void>("approval_decision", { requestId, decision }),/** "The card is up" — until this lands the relay only waits a moment. */diff --git a/windows/src/core/state.ts b/windows/src/core/state.tsindex 01236b80..08588267 100644--- a/windows/src/core/state.ts+++ b/windows/src/core/state.ts@@ -90,6 +90,7 @@ export interface Settings {screen: "primary" | "cursor";autostart: boolean;hooksInstalled: boolean;+ geminiHooksInstalled: boolean;/** Claude model used by the chat. */model: string;}@@ -105,6 +106,7 @@ export const DEFAULT_SETTINGS: Settings = {screen: "primary",autostart: false,hooksInstalled: false,+ geminiHooksInstalled: false,model: "claude-opus-5",};diff --git a/windows/src/island/hooks.ts b/windows/src/island/hooks.tsindex d90a78f0..f1c57628 100644--- a/windows/src/island/hooks.ts+++ b/windows/src/island/hooks.ts@@ -36,7 +36,24 @@ function validateAgent(raw: string | undefined): string | null {const FALLBACK_COLORS = ["#22C55E", "#EAB308", "#60A5FA", "#E879F9"];+const KNOWN_AGENT_COLORS: Record<string, string> = {+ gemini: "#8AB4F8",+ antigravity: "#E879F9",+ cursor: "#C0C4CC",+ codex: "#2DD4BF",+ opencode: "#38BDF8",+};++const KNOWN_AGENT_NAMES: Record<string, string> = {+ gemini: "Gemini CLI",+ antigravity: "Antigravity",+ cursor: "Cursor",+ codex: "Codex",+ opencode: "OpenCode",+};+function agentColor(name: string): string {+ if (KNOWN_AGENT_COLORS[name]) return KNOWN_AGENT_COLORS[name];let h = 0;for (let i = 0; i < name.length; i++) {h = (Math.imul(31, h) + name.charCodeAt(i)) | 0;@@ -44,6 +61,10 @@ function agentColor(name: string): string {return FALLBACK_COLORS[Math.abs(h) % FALLBACK_COLORS.length];}+function agentDisplayName(name: string): string {+ return KNOWN_AGENT_NAMES[name] ?? name;+}+const PROJECT_ALIASES: Record<string, string> = {"notch-buddy": "Notch Buddy",notchbuddy: "Notch Buddy",@@ -176,7 +197,7 @@ function handleHook(island: Island, payload: HookPayload) {/** Ensure the agent pill exists (no-op for Claude Code). */const ensurePill = () => {if (isExternalAgent) {- State.upsertExternalAgent(agentId, validAgent!, agentColor(validAgent!));+ State.upsertExternalAgent(agentId, agentDisplayName(validAgent!), agentColor(validAgent!));} else {upsert(projectName, cwd);}diff --git a/windows/src/settings/main.ts b/windows/src/settings/main.tsindex 3ab9ab94..354e4ea8 100644--- a/windows/src/settings/main.ts+++ b/windows/src/settings/main.ts@@ -171,6 +171,132 @@ function claudeSection(status: HookStatus): HTMLElement {return section;}+// ── Gemini CLI section ────────────────────────────────────────────────────────++function geminiSection(status: HookStatus): HTMLElement {+ const body = h("div", { style: "display:flex;flex-direction:column;gap:12px" });+ const section = h(+ "section",+ {},+ h("h2", {}, statusDot(status.installed), h("span", { text: "Gemini CLI" })),+ body,+ );++ const rebuild = async () => {+ const fresh = await Bridge.geminiHooksStatus();+ if (fresh) Object.assign(status, fresh);+ clear(body);+ draw();+ const head = section.querySelector("h2")!;+ clear(head);+ head.append(statusDot(status.installed), h("span", { text: "Gemini CLI" }));+ };++ function draw() {+ body.append(+ h("div", {+ class: "hint",+ text: status.installed+ ? "Coucou is hooked into your Gemini CLI sessions (~/.gemini/settings.json). Tool calls and steps show up in the island."+ : "Install the hooks in ~/.gemini/settings.json to see your Gemini CLI sessions and tool calls in the island.",+ }),+ h("div", { class: "row" },+ h("label", { text: "settings.json" }),+ h("span", { class: "path", text: status.settingsPath }),+ ),+ h("div", { class: "row" },+ h("label", { text: "Relay" }),+ h("span", { class: "path", text: status.hookPath }),+ statusDot(status.hookReady),+ ),+ );++ if (!status.hookReady) {+ body.append(h("div", {+ class: "notice warn",+ text: "coucou-hook.exe is not in place yet. Restart Coucou; if it still fails, build it with `cargo build -p coucou-hook`.",+ }));+ }++ const actions = h("div", { class: "row" });+ const install = h("button", {+ class: "primary",+ text: status.installed ? "Reinstall hooks…" : "Install hooks…",+ onclick: () => showPreview(true),+ });+ if (!status.hookReady) {+ install.disabled = true;+ install.title = "The relay isn't installed yet.";+ }+ actions.append(install);+ if (status.installed) {+ actions.append(h("button", {+ class: "danger",+ text: "Uninstall hooks…",+ onclick: () => showPreview(false),+ }));+ }+ body.append(actions);+ }++ async function showPreview(install: boolean) {+ let preview;+ try {+ preview = await Bridge.geminiHooksPreview(install);+ } catch (err) {+ clear(body);+ body.append(+ h("div", { class: "notice err", text: String(err).replace(/^Error:\s*/, "") }),+ h("div", { class: "row" }, h("button", {+ text: "Back",+ onclick: () => { clear(body); draw(); },+ })),+ );+ return;+ }+ if (!preview) return;+ clear(body);+ body.append(+ h("div", {+ class: "hint",+ text: install+ ? "This is exactly what will change in ~/.gemini/settings.json. Your own hooks are left untouched."+ : "This removes Coucou's entries only. Your own hooks are left untouched.",+ }),+ renderDiff(preview.diff),+ h("div", { class: "row" },+ h("span", { class: "path", text: `Backup → ${preview.backup}` }),+ ),+ );+ const confirm = h("button", {+ class: install ? "primary" : "danger",+ text: install ? "Back up and write" : "Back up and remove",+ });+ confirm.addEventListener("click", async () => {+ confirm.disabled = true;+ try {+ const backup = await Bridge.geminiHooksApply(install, preview.fingerprint);+ clear(body);+ body.append(h("div", {+ class: "notice ok",+ text: `Done. Previous settings saved as ${backup}. Open a new Gemini CLI session to pick the hooks up.`,+ }));+ window.setTimeout(() => void rebuild(), 2600);+ } catch (err) {+ confirm.disabled = false;+ body.append(h("div", { class: "notice err", text: `Could not write: ${String(err)}` }));+ }+ });+ body.append(h("div", { class: "row" }, confirm, h("button", {+ text: "Cancel",+ onclick: () => { clear(body); draw(); },+ })));+ }++ draw();+ return section;+}+// ── Claude API section ────────────────────────────────────────────────────────const MODELS: [string, string][] = [@@ -428,6 +554,9 @@ async function main() {const status = (await Bridge.hooksStatus()) ?? {installed: false, settingsPath: "", hookPath: "", hookReady: false,};+ const geminiStatus = (await Bridge.geminiHooksStatus()) ?? {+ installed: false, settingsPath: "", hookPath: "", hookReady: false,+ };const hasKey = (await Bridge.secretPresent("anthropic-api-key")) ?? false;@@ -442,6 +571,7 @@ async function main() {root.append(h("h1", {}, h("span", { text: "Coucou" }), h("span", { class: "version", text: version })),claudeSection(status),+ geminiSection(geminiStatus),apiSection(hasKey),integrationsSection(present),generalSection(),diff --git a/windows/src/views/views.ts b/windows/src/views/views.tsindex ac0ac7b6..16ed8268 100644--- a/windows/src/views/views.ts+++ b/windows/src/views/views.ts@@ -172,10 +172,10 @@ function buildOverview(actions: ViewActions): ViewHost {mode = null;}- // VS Code with a live Claude Code session keeps the ticker; every other- // pill shows its own card, exactly like IntegrationCardView.+ // Tasks with live steps or non-idle state keep the ticker; every other+ // integration pill shows its own card, exactly like IntegrationCardView.const sessionActive =- task?.id === "integration_claude" && (task.state !== "idle" || task.steps.length > 0);+ task && (!task.isIntegration || task.id === "integration_claude") && (task.state !== "idle" || task.steps.length > 0);if (task && sessionActive) {if (mode !== "ticker") {@@ -185,10 +185,11 @@ function buildOverview(actions: ViewActions): ViewHost {cardKey = "";}clear(who);+ const toolLabel = task.source === "claudeCode" ? "Claude Code" : task.source === "agent" ? task.name : "n8n";who.append(dot(task.color, 7),h("span", { class: "name", text: task.name }),- h("span", { class: "tool", text: task.source === "claudeCode" ? "Claude Code" : "n8n" }),+ h("span", { class: "tool", text: toolLabel }),);if (task.steps.length > 1) {who.append(h("span", {@@ -328,9 +329,10 @@ function buildQuestion(): ViewHost {el,sync() {clear(who);- who.append(agentWho(State.focusTask, "Claude Code is asking a question"));+ const name = State.focusTask?.name ?? "Agent";+ who.append(agentWho(State.focusTask, `${name} is asking a question`));const task = State.focusTask;- title.textContent = task?.steps.at(-1) ?? "Claude needs an answer.";+ title.textContent = task?.steps.at(-1) ?? `${name} needs an answer.`;clear(row);row.append(h("div", { class: "sub", text: "Answer in your terminal — Coucou can't reply for you yet." }));},@@ -353,7 +355,8 @@ function buildError(actions: ViewActions): ViewHost {sync() {const task = State.focusTask;clear(who);- who.append(agentWho(task, task?.source === "n8n" ? "n8n" : "Claude Code"));+ const whoLabel = task?.source === "n8n" ? "n8n" : (task?.name ?? "Agent");+ who.append(agentWho(task, whoLabel));title.textContent = task?.source === "n8n" ? "Workflow stopped." : "Session stopped on an error.";detail.textContent = task?.steps.at(-1) ?? "No detail available.";},@@ -374,7 +377,8 @@ function buildFinished(actions: ViewActions): ViewHost {el,sync() {clear(who);- who.append(agentWho(State.focusTask, "Claude Code finished"));+ const name = State.focusTask?.name ?? "Agent";+ who.append(agentWho(State.focusTask, `${name} finished`));title.textContent = State.focusTask?.steps.at(-1) ?? "Session finished";},};