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 #278: feat(windows): support Gemini CLI hooks and session island view

Claudee190f1f7aa1f
diff --cc windows/hook/src/main.rs
index 4cd62465,ea6de1b5..59099c3f
--- a/windows/hook/src/main.rs
+++ b/windows/hook/src/main.rs
@@@ -44,8 -44,82 +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, question)) = read_event() else { std::process::exit(0) };
- let Some((payload, event, agent)) = read_event() else { std::process::exit(0) };
++ let Some((payload, event, question, 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 };
@@@ -110,41 -165,8 +189,42 @@@ fn decision_json(decision: &str, questi
))
}
-/// Reads stdin and returns the payload to forward plus the event name and agent.
-fn read_event() -> Option<(String, String, String)> {
+/// True when `answers` answers exactly the questions Claude Code asked: one entry
+/// per question, keyed by its text; a single-select answer is one of its option
+/// labels (a string), a multi-select answer a non-empty list of distinct labels
+/// (Claude Code 2.1.136+ takes the list, as the Mac sends it). Same rule as
+/// `QuestionPayload.accepts` on macOS.
+fn answers_fit(question: &serde_json::Value, answers: &serde_json::Map<String, serde_json::Value>) -> bool {
+ let Some(items) = question.get("questions").and_then(|q| q.as_array()) else { return false };
+ if items.is_empty() || items.len() != answers.len() {
+ return false;
+ }
+ items.iter().all(|item| {
+ let Some(text) = item.get("question").and_then(|q| q.as_str()) else { return false };
+ let labels: Vec<&str> = item
+ .get("options")
+ .and_then(|o| o.as_array())
+ .map(|opts| opts.iter().filter_map(|o| o.get("label").and_then(|l| l.as_str())).collect())
+ .unwrap_or_default();
+ let multi = item.get("multiSelect").and_then(|m| m.as_bool()).unwrap_or(false);
+ match answers.get(text) {
+ Some(serde_json::Value::String(pick)) if !multi => labels.contains(&pick.as_str()),
+ Some(serde_json::Value::Array(picks)) if multi => {
+ let picks: Vec<&str> = picks.iter().filter_map(|p| p.as_str()).collect();
+ let mut seen = picks.clone();
+ seen.sort_unstable();
+ seen.dedup();
+ !picks.is_empty() && seen.len() == picks.len() && picks.iter().all(|p| labels.contains(p))
+ }
+ _ => false,
+ }
+ })
+}
+
- /// Reads stdin and returns the payload to forward, the event name, and — for an
- /// AskUserQuestion permission request — the question as Claude Code sent it.
- fn read_event() -> Option<(String, String, Option<serde_json::Value>)> {
++/// Reads stdin and returns the payload to forward, the event name, — for an
++/// AskUserQuestion permission request — the question as Claude Code sent it,
++/// and the agent the hook was installed for.
++fn read_event() -> Option<(String, String, Option<serde_json::Value>, String)> {
let mut raw = Vec::new();
if std::io::stdin().read_to_end(&mut raw).is_err() || raw.is_empty() {
return None;
@@@ -228,7 -262,7 +326,7 @@@
let mut line = payload.to_string();
line.push('\n');
- Some((line, event, question))
- Some((line, event, agent))
++ Some((line, event, question, agent))
}
/// Caps every string in the payload. A single Write can carry a whole file.
diff --cc windows/src-tauri/src/lib.rs
index 264e4c3a,15aa450a..d0fb31bd
--- a/windows/src-tauri/src/lib.rs
+++ b/windows/src-tauri/src/lib.rs
@@@ -409,8 -418,10 +440,11 @@@ pub fn run()
hooks_status,
hooks_preview,
hooks_apply,
+ gemini_hooks_status,
+ gemini_hooks_preview,
+ gemini_hooks_apply,
approval_decision,
+ approval_answer,
approval_ack,
approval_decline,
log_line,
diff --cc windows/src-tauri/src/settings.rs
index 17f63e1c,a90fa85f..3a4e4fe2
--- a/windows/src-tauri/src/settings.rs
+++ b/windows/src-tauri/src/settings.rs
@@@ -21,7 -16,11 +21,9 @@@ 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")]
pub model: String,
}
diff --cc windows/src/core/state.ts
index 4785897a,08588267..e60d5d2b
--- a/windows/src/core/state.ts
+++ b/windows/src/core/state.ts
@@@ -101,10 -87,10 +101,11 @@@ export interface Settings
autoCloseInterval: number;
absenceInterval: number;
activeIntegrations: string[];
- screen: "primary" | "cursor";
+ /** "primary", "cursor", or `at:<x>,<y>` for one display (logical origin). */
+ screen: string;
autostart: boolean;
hooksInstalled: boolean;
+ geminiHooksInstalled: boolean;
/** Claude model used by the chat. */
model: string;
}