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: chat with Claude and file drop
Louis Raillecd50852f21c7
diff --git a/windows/Cargo.lock b/windows/Cargo.lockindex 48ca1f62..726cad74 100644--- a/windows/Cargo.lock+++ b/windows/Cargo.lock@@ -471,6 +471,23 @@ version = "1.0.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"+[[package]]+name = "cfg_aliases"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"++[[package]]+name = "chacha20"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"+dependencies = [+ "cfg-if",+ "cpufeatures 0.3.1",+ "rand_core",+]+[[package]]name = "chrono"version = "0.4.45"@@ -556,6 +573,8 @@ dependencies = [name = "coucou"version = "0.1.0"dependencies = [+ "keyring",+ "reqwest 0.12.28","serde","serde_json","tauri",@@ -582,6 +601,15 @@ dependencies = ["libc",]+[[package]]+name = "cpufeatures"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"+dependencies = [+ "libc",+]+[[package]]name = "crc32fast"version = "1.5.2"@@ -1283,8 +1311,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"dependencies = ["cfg-if",+ "js-sys","libc","wasi",+ "wasm-bindgen",][[package]]@@ -1306,8 +1336,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"dependencies = ["cfg-if",+ "js-sys","libc","r-efi 6.0.0",+ "rand_core",+ "wasm-bindgen",][[package]]@@ -1563,6 +1596,22 @@ dependencies = ["want",]+[[package]]+name = "hyper-rustls"+version = "0.27.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53"+dependencies = [+ "http",+ "hyper",+ "hyper-util",+ "rustls",+ "tokio",+ "tokio-rustls",+ "tower-service",+ "webpki-roots",+]+[[package]]name = "hyper-util"version = "0.1.21"@@ -1939,6 +1988,18 @@ dependencies = ["serde",]+[[package]]+name = "keyring"+version = "3.6.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "eebcc3aff044e5944a8fbaf69eb277d11986064cba30c468730e8b9909fb551c"+dependencies = [+ "byteorder",+ "log",+ "windows-sys 0.60.2",+ "zeroize",+]+[[package]]name = "libappindicator"version = "0.9.0"@@ -2024,6 +2085,12 @@ version = "0.4.34"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"+[[package]]+name = "lru-slab"+version = "0.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f"+[[package]]name = "markup5ever"version = "0.39.0"@@ -2695,6 +2762,62 @@ dependencies = ["memchr",]+[[package]]+name = "quinn"+version = "0.11.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11"+dependencies = [+ "bytes",+ "cfg_aliases",+ "pin-project-lite",+ "quinn-proto",+ "quinn-udp",+ "rustc-hash",+ "rustls",+ "socket2",+ "thiserror 2.0.21",+ "tokio",+ "tracing",+ "web-time",+]++[[package]]+name = "quinn-proto"+version = "0.11.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a9746dbde176634f4f2f1faf2404e30a31b2bc1e9cafb5329c95d8177a18c9fc"+dependencies = [+ "bytes",+ "getrandom 0.4.3",+ "lru-slab",+ "rand",+ "rand_pcg",+ "ring",+ "rustc-hash",+ "rustls",+ "rustls-pki-types",+ "slab",+ "thiserror 2.0.21",+ "tinyvec",+ "tracing",+ "web-time",+]++[[package]]+name = "quinn-udp"+version = "0.5.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "35a133f956daabe89a61a685c2649f13d82d5aa4bd5d12d1277e1072a21c0694"+dependencies = [+ "cfg_aliases",+ "libc",+ "once_cell",+ "socket2",+ "tracing",+ "windows-sys 0.61.2",+]+[[package]]name = "quote"version = "1.0.47"@@ -2716,6 +2839,32 @@ version = "6.0.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"+[[package]]+name = "rand"+version = "0.10.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"+dependencies = [+ "chacha20",+ "getrandom 0.4.3",+ "rand_core",+]++[[package]]+name = "rand_core"+version = "0.10.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"++[[package]]+name = "rand_pcg"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a"+dependencies = [+ "rand_core",+]+[[package]]name = "raw-window-handle"version = "0.6.2"@@ -2801,6 +2950,44 @@ version = "0.8.11"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"+[[package]]+name = "reqwest"+version = "0.12.28"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147"+dependencies = [+ "base64 0.22.1",+ "bytes",+ "futures-core",+ "http",+ "http-body",+ "http-body-util",+ "hyper",+ "hyper-rustls",+ "hyper-util",+ "js-sys",+ "log",+ "percent-encoding",+ "pin-project-lite",+ "quinn",+ "rustls",+ "rustls-pki-types",+ "serde",+ "serde_json",+ "serde_urlencoded",+ "sync_wrapper",+ "tokio",+ "tokio-rustls",+ "tower",+ "tower-http",+ "tower-service",+ "url",+ "wasm-bindgen",+ "wasm-bindgen-futures",+ "web-sys",+ "webpki-roots",+]+[[package]]name = "reqwest"version = "0.13.5"@@ -2835,6 +3022,20 @@ dependencies = ["web-sys",]+[[package]]+name = "ring"+version = "0.17.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"+dependencies = [+ "cc",+ "cfg-if",+ "getrandom 0.2.17",+ "libc",+ "untrusted",+ "windows-sys 0.52.0",+]+[[package]]name = "rustc-hash"version = "2.1.3"@@ -2863,12 +3064,53 @@ dependencies = ["windows-sys 0.61.2",]+[[package]]+name = "rustls"+version = "0.23.45"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634"+dependencies = [+ "once_cell",+ "ring",+ "rustls-pki-types",+ "rustls-webpki",+ "subtle",+ "zeroize",+]++[[package]]+name = "rustls-pki-types"+version = "1.15.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96"+dependencies = [+ "web-time",+ "zeroize",+]++[[package]]+name = "rustls-webpki"+version = "0.103.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2"+dependencies = [+ "ring",+ "rustls-pki-types",+ "untrusted",+]+[[package]]name = "rustversion"version = "1.0.23"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"+[[package]]+name = "ryu"+version = "1.0.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"+[[package]]name = "same-file"version = "1.0.6"@@ -3059,6 +3301,18 @@ dependencies = ["serde_core",]+[[package]]+name = "serde_urlencoded"+version = "0.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"+dependencies = [+ "form_urlencoded",+ "itoa",+ "ryu",+ "serde",+]+[[package]]name = "serde_with"version = "3.24.0"@@ -3130,7 +3384,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"dependencies = ["cfg-if",- "cpufeatures",+ "cpufeatures 0.2.17","digest",]@@ -3268,6 +3522,12 @@ version = "0.11.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"+[[package]]+name = "subtle"+version = "2.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"+[[package]]name = "swift-rs"version = "1.0.8"@@ -3431,7 +3691,7 @@ dependencies = ["percent-encoding","plist","raw-window-handle",- "reqwest",+ "reqwest 0.13.5","serde","serde_json","serde_repr",@@ -3782,6 +4042,16 @@ dependencies = ["windows-sys 0.61.2",]+[[package]]+name = "tokio-rustls"+version = "0.26.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db"+dependencies = [+ "rustls",+ "tokio",+]+[[package]]name = "tokio-util"version = "0.7.19"@@ -4030,6 +4300,12 @@ version = "1.13.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"+[[package]]+name = "untrusted"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"+[[package]]name = "url"version = "2.5.8"@@ -4284,6 +4560,15 @@ dependencies = ["system-deps",]+[[package]]+name = "webpki-roots"+version = "1.0.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a"+dependencies = [+ "rustls-pki-types",+]+[[package]]name = "webview2-com"version = "0.39.1"@@ -4555,6 +4840,15 @@ dependencies = ["windows-targets 0.42.2",]+[[package]]+name = "windows-sys"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"+dependencies = [+ "windows-targets 0.52.6",+]+[[package]]name = "windows-sys"version = "0.59.0"@@ -5023,6 +5317,12 @@ dependencies = ["synstructure",]+[[package]]+name = "zeroize"+version = "1.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e"+[[package]]name = "zerotrie"version = "0.2.5"diff --git a/windows/src-tauri/Cargo.toml b/windows/src-tauri/Cargo.tomlindex 577c5608..ecb314e8 100644--- a/windows/src-tauri/Cargo.toml+++ b/windows/src-tauri/Cargo.toml@@ -20,6 +20,8 @@ tauri-plugin-autostart = "2"serde = { version = "1", features = ["derive"] }serde_json = "1"tokio = { version = "1", features = ["net", "io-util", "sync", "time", "rt"] }+reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }+keyring = { version = "3", features = ["windows-native"] }windows = { version = "0.61", features = ["Win32_Foundation","Win32_System_SystemInformation",diff --git a/windows/src-tauri/src/claude.rs b/windows/src-tauri/src/claude.rsnew file mode 100644index 00000000..93b48f8e--- /dev/null+++ b/windows/src-tauri/src/claude.rs@@ -0,0 +1,258 @@+// Claude API client — the same integration as ClaudeService.swift: multi-turn+// chat with web search, and files sent as document/image/text blocks.+//+// Everything happens here rather than in the island: the API key never leaves+// the Credential Manager, and file bytes never cross the IPC boundary.++use std::sync::Mutex;++use serde::{Deserialize, Serialize};+use serde_json::{json, Value};++use crate::secrets;++const ENDPOINT: &str = "https://api.anthropic.com/v1/messages";+const ANTHROPIC_VERSION: &str = "2023-06-01";+/// Server-side fallback: on a policy decline the API retries the same request on+/// a fallback model inside the same call, so the island never shows a dead end.+const FALLBACK_BETA: &str = "server-side-fallback-2026-07-01";+const MAX_TOKENS: u32 = 4096;+/// Text and code files are inlined; anything larger is skipped, as on macOS.+const MAX_INLINE_TEXT: u64 = 200_000;++pub const DEFAULT_MODEL: &str = "claude-opus-5";++const SYSTEM_PROMPT: &str = "You are Mochi, a personal AI assistant living at the top of the user's screen. \+You have web search access and can help with absolutely anything — research, coding, finding places, recommendations, tasks, questions. \+Respond in the user's language. Be thorough and complete — use as much detail as the task requires. \+No markdown formatting (no **, no ##, no bullet dashes). Use plain text with line breaks.";++#[derive(Default)]+pub struct Chat {+ /// Full multi-turn history, including tool_use / tool_result blocks.+ messages: Mutex<Vec<Value>>,+}++impl Chat {+ pub fn reset(&self) {+ self.messages.lock().unwrap().clear();+ }++ fn is_empty(&self) -> bool {+ self.messages.lock().unwrap().is_empty()+ }++ fn push(&self, message: Value) {+ self.messages.lock().unwrap().push(message);+ }++ fn pop(&self) {+ self.messages.lock().unwrap().pop();+ }++ fn snapshot(&self) -> Vec<Value> {+ self.messages.lock().unwrap().clone()+ }+}++#[derive(Debug, Clone, Deserialize)]+#[serde(tag = "kind", rename_all = "camelCase")]+pub enum ChatContext {+ File { name: String, path: String },+ Window { app_name: String, title: String, url: Option<String> },+}++#[derive(Serialize)]+#[serde(rename_all = "camelCase")]+pub struct ChatReply {+ pub text: String,+}++/// One chat turn. Returns the assistant's text, or a message the island shows+/// in the note view.+pub async fn send(+ chat: &Chat,+ model: &str,+ query: String,+ context: Option<ChatContext>,+) -> Result<ChatReply, String> {+ let key = secrets::get("anthropic-api-key")+ .ok_or_else(|| "API key missing. Open settings.".to_string())?;++ let mut content: Vec<Value> = Vec::new();++ // File / window context rides along with the first message only, exactly+ // like ClaudeService.chat().+ if chat.is_empty() {+ match &context {+ Some(ChatContext::File { name, path }) => {+ if let Some(block) = file_block(path) {+ content.push(block);+ }+ content.push(json!({ "type": "text", "text": format!("File: {name}") }));+ }+ Some(ChatContext::Window { app_name, title, url }) => {+ let mut text = format!("Context — App: {app_name}, Window: {title}");+ if let Some(url) = url {+ text.push_str(&format!(", URL: {url}"));+ }+ content.push(json!({ "type": "text", "text": text }));+ }+ None => {}+ }+ }+ content.push(json!({ "type": "text", "text": query }));++ chat.push(json!({ "role": "user", "content": content }));++ let body = json!({+ "model": model,+ "max_tokens": MAX_TOKENS,+ "system": SYSTEM_PROMPT,+ "tools": [{ "type": "web_search_20260209", "name": "web_search", "max_uses": 5 }],+ "fallbacks": "default",+ "messages": chat.snapshot(),+ });++ let response = match call(&key, &body).await {+ Ok(v) => v,+ Err(err) => {+ chat.pop(); // keep the history consistent with what the model saw+ return Err(err);+ }+ };++ // A policy decline comes back as HTTP 200 with stop_reason "refusal".+ if response.get("stop_reason").and_then(Value::as_str) == Some("refusal") {+ chat.pop();+ let why = response+ .get("stop_details")+ .and_then(|d| d.get("explanation"))+ .and_then(Value::as_str)+ .unwrap_or("Claude declined this one.");+ return Err(why.to_string());+ }++ let Some(blocks) = response.get("content").and_then(Value::as_array).cloned() else {+ chat.pop();+ return Err("Unexpected API response.".into());+ };++ // Store the whole content — tool_use / tool_result blocks included — so the+ // next turn has the right context.+ chat.push(json!({ "role": "assistant", "content": blocks.clone() }));++ let text = blocks+ .iter()+ .filter(|b| b.get("type").and_then(Value::as_str) == Some("text"))+ .filter_map(|b| b.get("text").and_then(Value::as_str))+ .collect::<Vec<_>>()+ .join("\n")+ .trim()+ .to_string();++ if text.is_empty() {+ return Err("No response text.".into());+ }+ Ok(ChatReply { text })+}++async fn call(key: &str, body: &Value) -> Result<Value, String> {+ let client = reqwest::Client::builder()+ .timeout(std::time::Duration::from_secs(90))+ .build()+ .map_err(|e| e.to_string())?;++ let response = client+ .post(ENDPOINT)+ .header("x-api-key", key)+ .header("anthropic-version", ANTHROPIC_VERSION)+ .header("anthropic-beta", FALLBACK_BETA)+ .header("content-type", "application/json")+ .json(body)+ .send()+ .await+ .map_err(|e| format!("Network error: {e}"))?;++ let status = response.status();+ let text = response.text().await.map_err(|e| e.to_string())?;+ if !status.is_success() {+ // Surface the API's own message, which is what makes a bad key obvious.+ let detail = serde_json::from_str::<Value>(&text)+ .ok()+ .and_then(|v| {+ v.get("error")+ .and_then(|e| e.get("message"))+ .and_then(Value::as_str)+ .map(str::to_string)+ })+ .unwrap_or_else(|| text.chars().take(200).collect());+ return Err(format!("Claude API {status}: {detail}"));+ }+ serde_json::from_str(&text).map_err(|e| format!("Bad API response: {e}"))+}++/// PDF → document block, image → image block, text/code → inline text.+/// Mirrors readFileAsBlock() in ClaudeService.swift.+fn file_block(path: &str) -> Option<Value> {+ let ext = std::path::Path::new(path)+ .extension()+ .and_then(|e| e.to_str())+ .unwrap_or("")+ .to_lowercase();++ let media_type = match ext.as_str() {+ "pdf" => Some(("document", "application/pdf")),+ "jpg" | "jpeg" => Some(("image", "image/jpeg")),+ "png" => Some(("image", "image/png")),+ "gif" => Some(("image", "image/gif")),+ "webp" => Some(("image", "image/webp")),+ _ => None,+ };++ if let Some((block_type, media)) = media_type {+ let bytes = std::fs::read(path).ok()?;+ return Some(json!({+ "type": block_type,+ "source": { "type": "base64", "media_type": media, "data": base64(&bytes) },+ }));+ }++ let len = std::fs::metadata(path).ok()?.len();+ if len > MAX_INLINE_TEXT {+ return None;+ }+ let text = std::fs::read_to_string(path).ok()?;+ Some(json!({ "type": "text", "text": format!("File contents:\n{text}") }))+}++/// Small standalone base64 encoder — not worth another dependency.+fn base64(bytes: &[u8]) -> String {+ const TABLE: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";+ let mut out = String::with_capacity(bytes.len().div_ceil(3) * 4);+ for chunk in bytes.chunks(3) {+ let b = [chunk[0], *chunk.get(1).unwrap_or(&0), *chunk.get(2).unwrap_or(&0)];+ let n = ((b[0] as u32) << 16) | ((b[1] as u32) << 8) | b[2] as u32;+ out.push(TABLE[(n >> 18) as usize & 63] as char);+ out.push(TABLE[(n >> 12) as usize & 63] as char);+ out.push(if chunk.len() > 1 { TABLE[(n >> 6) as usize & 63] as char } else { '=' });+ out.push(if chunk.len() > 2 { TABLE[n as usize & 63] as char } else { '=' });+ }+ out+}++#[cfg(test)]+mod tests {+ use super::base64;++ #[test]+ fn base64_matches_rfc4648_vectors() {+ assert_eq!(base64(b""), "");+ assert_eq!(base64(b"f"), "Zg==");+ assert_eq!(base64(b"fo"), "Zm8=");+ assert_eq!(base64(b"foo"), "Zm9v");+ assert_eq!(base64(b"foob"), "Zm9vYg==");+ assert_eq!(base64(b"fooba"), "Zm9vYmE=");+ assert_eq!(base64(b"foobar"), "Zm9vYmFy");+ }+}diff --git a/windows/src-tauri/src/files.rs b/windows/src-tauri/src/files.rsnew file mode 100644index 00000000..7e711344--- /dev/null+++ b/windows/src-tauri/src/files.rs@@ -0,0 +1,105 @@+// Dropped files are copied into %LOCALAPPDATA%\Coucou\inbox so the original is+// never touched and the copy survives the drag source going away.+// The inbox is swept of anything older than a week, as on macOS.++use std::path::{Path, PathBuf};+use std::time::{Duration, SystemTime};++use serde::Serialize;++use crate::settings;++const KEEP_FOR: Duration = Duration::from_secs(7 * 24 * 60 * 60);++#[derive(Serialize, Clone)]+#[serde(rename_all = "camelCase")]+pub struct DroppedFile {+ pub name: String,+ pub path: String,+ pub size: u64,+}++pub fn inbox_dir() -> PathBuf {+ settings::local_dir().join("inbox")+}++pub fn ingest(source: &str) -> Result<DroppedFile, String> {+ let src = Path::new(source);+ let meta = std::fs::metadata(src).map_err(|e| format!("cannot read {source}: {e}"))?;+ if meta.is_dir() {+ return Err("Folders can't be dropped yet.".into());+ }++ let dir = inbox_dir();+ std::fs::create_dir_all(&dir).map_err(|e| e.to_string())?;++ let name = src+ .file_name()+ .map(|n| n.to_string_lossy().to_string())+ .unwrap_or_else(|| "file".into());++ let mut dest = dir.join(&name);+ if dest.exists() {+ let stem = src.file_stem().map(|s| s.to_string_lossy().to_string()).unwrap_or_default();+ let ext = src.extension().map(|s| format!(".{}", s.to_string_lossy())).unwrap_or_default();+ for i in 2..1000 {+ let candidate = dir.join(format!("{stem} ({i}){ext}"));+ if !candidate.exists() {+ dest = candidate;+ break;+ }+ }+ }++ std::fs::copy(src, &dest).map_err(|e| format!("cannot copy: {e}"))?;+ sweep(&dir);++ Ok(DroppedFile {+ name,+ path: dest.to_string_lossy().to_string(),+ size: meta.len(),+ })+}++fn sweep(dir: &Path) {+ let Ok(entries) = std::fs::read_dir(dir) else { return };+ let now = SystemTime::now();+ for entry in entries.flatten() {+ let Ok(meta) = entry.metadata() else { continue };+ let Ok(modified) = meta.modified() else { continue };+ if now.duration_since(modified).map(|age| age > KEEP_FOR).unwrap_or(false) {+ let _ = std::fs::remove_file(entry.path());+ }+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn ingest_copies_and_never_overwrites() {+ let tmp = std::env::temp_dir().join(format!("coucou-test-{}", std::process::id()));+ std::fs::create_dir_all(&tmp).unwrap();+ let source = tmp.join("note.txt");+ std::fs::write(&source, b"hello").unwrap();++ let first = ingest(source.to_str().unwrap()).unwrap();+ assert_eq!(first.name, "note.txt");+ assert_eq!(std::fs::read(&first.path).unwrap(), b"hello");++ // A second drop of the same name must not clobber the first copy.+ std::fs::write(&source, b"second").unwrap();+ let second = ingest(source.to_str().unwrap()).unwrap();+ assert_ne!(first.path, second.path);+ assert_eq!(std::fs::read(&first.path).unwrap(), b"hello");+ assert_eq!(std::fs::read(&second.path).unwrap(), b"second");++ // Folders are refused rather than silently ignored.+ assert!(ingest(tmp.to_str().unwrap()).is_err());++ let _ = std::fs::remove_file(&first.path);+ let _ = std::fs::remove_file(&second.path);+ let _ = std::fs::remove_dir_all(&tmp);+ }+}diff --git a/windows/src-tauri/src/lib.rs b/windows/src-tauri/src/lib.rsindex aba3d047..5112170c 100644--- a/windows/src-tauri/src/lib.rs+++ b/windows/src-tauri/src/lib.rs@@ -1,9 +1,12 @@// Coucou for Windows — app wiring and the commands the island calls.+mod claude;+mod files;mod hooks;mod island;mod log;mod pipe;+mod secrets;mod settings;mod tray;@@ -16,6 +19,8 @@ use serde::Serialize;use tauri::{AppHandle, Emitter, Manager, State, WebviewUrl, WebviewWindowBuilder};use tauri_plugin_autostart::{ManagerExt, MacosLauncher};+use claude::{Chat, ChatContext, ChatReply};+use files::DroppedFile;use hooks::{HookPreview, HookStatus};use island::{PollGate, ScreenInfo};use pipe::Pending;@@ -189,6 +194,47 @@ fn approval_decision(app: AppHandle, request_id: String, decision: String) {pipe::answer(&app, &request_id, &decision);}+// ── Chat, files and secrets ───────────────────────────────────────────────────++/// One chat turn. The API key and any file bytes stay on the Rust side.+#[tauri::command]+async fn chat_send(+ shared: State<'_, Shared>,+ chat: State<'_, Chat>,+ query: String,+ context: Option<ChatContext>,+) -> Result<ChatReply, String> {+ let model = shared.settings.lock().unwrap().model.clone();+ claude::send(&chat, &model, query, context).await+}++#[tauri::command]+fn chat_reset(chat: State<Chat>) {+ chat.reset();+}++/// Copies a dropped file into the inbox and reports its name back.+#[tauri::command]+fn ingest_file(path: String) -> Result<DroppedFile, String> {+ files::ingest(&path)+}++/// The island may only ask whether a key exists — never read it.+#[tauri::command]+fn secret_present(key: String) -> bool {+ secrets::present(&key)+}++#[tauri::command]+fn secret_set(key: String, value: String) -> Result<(), String> {+ secrets::set(&key, &value)+}++#[tauri::command]+fn secret_clear(key: String) -> Result<(), String> {+ secrets::clear(&key)+}+/// Lets the island write to the same log as the Rust side.#[tauri::command]fn log_line(message: String) {@@ -235,6 +281,7 @@ pub fn run() {gate: gate.clone(),}).manage(Pending::default())+ .manage(Chat::default()).invoke_handler(tauri::generate_handler![boot,save_settings,@@ -250,6 +297,12 @@ pub fn run() {hooks_apply,approval_decision,log_line,+ chat_send,+ chat_reset,+ ingest_file,+ secret_present,+ secret_set,+ secret_clear,open_settings_window,]).setup(move |app| {diff --git a/windows/src-tauri/src/secrets.rs b/windows/src-tauri/src/secrets.rsnew file mode 100644index 00000000..06296d1f--- /dev/null+++ b/windows/src-tauri/src/secrets.rs@@ -0,0 +1,51 @@+// API keys live in the Windows Credential Manager, never on disk and never in+// the front end — the island can only ask whether a key is present.++use keyring::Entry;++const SERVICE: &str = "fr.louisraille.coucou";++/// Every key Coucou may store. Anything outside this list is refused.+pub const KNOWN_KEYS: &[&str] = &[+ "anthropic-api-key",+ "n8n-url",+ "n8n-api-key",+ "vercel-token",+ "github-token",+ "stripe-api-key",+ "resend-api-key",+ "notion-api-key",+ "calcom-api-key",+];++fn entry(key: &str) -> Option<Entry> {+ if !KNOWN_KEYS.contains(&key) {+ return None;+ }+ Entry::new(SERVICE, key).ok()+}++pub fn get(key: &str) -> Option<String> {+ entry(key)?.get_password().ok().filter(|v| !v.is_empty())+}++pub fn set(key: &str, value: &str) -> Result<(), String> {+ let entry = entry(key).ok_or_else(|| format!("unknown key {key}"))?;+ if value.is_empty() {+ let _ = entry.delete_credential();+ return Ok(());+ }+ entry.set_password(value).map_err(|e| e.to_string())+}++pub fn clear(key: &str) -> Result<(), String> {+ let entry = entry(key).ok_or_else(|| format!("unknown key {key}"))?;+ match entry.delete_credential() {+ Ok(()) | Err(keyring::Error::NoEntry) => Ok(()),+ Err(e) => Err(e.to_string()),+ }+}++pub fn present(key: &str) -> bool {+ get(key).is_some()+}diff --git a/windows/src-tauri/src/settings.rs b/windows/src-tauri/src/settings.rsindex 683da5da..27071798 100644--- a/windows/src-tauri/src/settings.rs+++ b/windows/src-tauri/src/settings.rs@@ -16,6 +16,14 @@ pub struct Settings {pub screen: String,pub autostart: bool,pub 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,+}++fn default_model() -> String {+ crate::claude::DEFAULT_MODEL.to_string()}impl Default for Settings {@@ -34,6 +42,7 @@ impl Default for Settings {screen: "primary".into(),autostart: false,hooks_installed: false,+ model: default_model(),}}}diff --git a/windows/src/core/bridge.ts b/windows/src/core/bridge.tsindex f7851935..ab990608 100644--- a/windows/src/core/bridge.ts+++ b/windows/src/core/bridge.ts@@ -4,6 +4,7 @@import { invoke } from "@tauri-apps/api/core";import { listen } from "@tauri-apps/api/event";+import { getCurrentWebview } from "@tauri-apps/api/webview";import type { Settings } from "./state";export const IS_TAURI =@@ -68,8 +69,30 @@ export const Bridge = {approvalDecision: (requestId: string, decision: "allow" | "deny" | "always") =>call<void>("approval_decision", { requestId, decision }),++ // ── Chat, files, secrets ──────────────────────────────────────────────────+ /** One chat turn. The API key and any file bytes never leave Rust. */+ chatSend: (query: string, context: ChatContext | null) =>+ callOrThrow<{ text: string }>("chat_send", { query, context }),+ chatReset: () => call<void>("chat_reset"),+ /** Copies a dropped file into the inbox. */+ ingestFile: (path: string) => callOrThrow<DroppedFile>("ingest_file", { path }),+ /** Only ever tells you whether a key exists — never its value. */+ secretPresent: (key: string) => call<boolean>("secret_present", { key }),+ secretSet: (key: string, value: string) => callOrThrow<void>("secret_set", { key, value }),+ secretClear: (key: string) => callOrThrow<void>("secret_clear", { key }),};+export type ChatContext =+ | { kind: "file"; name: string; path: string }+ | { kind: "window"; appName: string; title: string; url?: string };++export interface DroppedFile {+ name: string;+ path: string;+ size: number;+}+export interface HookStatus {installed: boolean;settingsPath: string;@@ -95,6 +118,19 @@ export type BridgeEvent =| { name: "hook"; payload: Record<string, unknown> }| { name: "screen-changed"; payload: null };+export interface DragDropPayload {+ type: "enter" | "over" | "drop" | "leave";+ paths?: string[];+}++/** Files dragged onto the island. Only reaches us when the window takes the mouse. */+export async function onDragDrop(handler: (e: DragDropPayload) => void) {+ if (!IS_TAURI) return () => {};+ return getCurrentWebview().onDragDropEvent((event) => {+ handler(event.payload as DragDropPayload);+ });+}+export async function onEvent<T>(name: string, handler: (payload: T) => void) {if (!IS_TAURI) return () => {};return listen<T>(name, (e) => handler(e.payload));diff --git a/windows/src/core/layout.ts b/windows/src/core/layout.tsindex 2b27e458..f89e02bc 100644--- a/windows/src/core/layout.ts+++ b/windows/src/core/layout.ts@@ -75,7 +75,9 @@ export const VIEW_LAYOUTS: Record<IslandViewName, ViewLayout> = {finished: { height: 160, botX: 62, botY: null, botDiameter: 58, agentMode: "column" },confused: { height: 160, botX: 76, botY: null, botDiameter: 66, agentMode: "column" },upload: { height: 176, botX: 140, botY: 104, botDiameter: 62, agentMode: "column" },- uploading: { height: 176, botX: 46, botY: 118, botDiameter: 20, agentMode: "none" },+ // botY 103 = bar top (42 + 58) + 3, so the dot really rides the bar. The Swift+ // layout says 118 while its own comment says 103; the comment matches the spec.+ uploading: { height: 176, botX: 46, botY: 103, botDiameter: 20, agentMode: "none" },choose: { height: 176, botX: 60, botY: 101, botDiameter: 52, agentMode: "column" },mail: { height: 240, botX: 56, botY: null, botDiameter: 46, agentMode: "column" },prompt: { height: 160, botX: 52, botY: null, botDiameter: 44, agentMode: "column" },diff --git a/windows/src/core/state.ts b/windows/src/core/state.tsindex 61e644a7..32c8c05b 100644--- a/windows/src/core/state.ts+++ b/windows/src/core/state.ts@@ -82,6 +82,8 @@ export interface Settings {screen: "primary" | "cursor";autostart: boolean;hooksInstalled: boolean;+ /** Claude model used by the chat. */+ model: string;}export const DEFAULT_SETTINGS: Settings = {@@ -95,6 +97,7 @@ export const DEFAULT_SETTINGS: Settings = {screen: "primary",autostart: false,hooksInstalled: false,+ model: "claude-opus-5",};type Listener = () => void;diff --git a/windows/src/island/island.ts b/windows/src/island/island.tsindex 785c7982..dbcf0d53 100644--- a/windows/src/island/island.ts+++ b/windows/src/island/island.ts@@ -2,7 +2,7 @@// Mirrors IslandRootView.swift + IslandWindowController.swift.import { Tracked, Spring, clamp } from "../core/anim";-import { Bridge, IS_TAURI } from "../core/bridge";+import { Bridge, IS_TAURI, onDragDrop } from "../core/bridge";import {EXPANDED_CORNER, EXPANDED_W, NOTCH_W, PANEL_H, PANEL_W,ROUNDED_CORNER, VIEW_LAYOUTS, botGlowColor, botGlowOpacity, botPosition, chatPromptHeight,@@ -72,6 +72,8 @@ export class Island {private confusedRecovery: number | null = null;private prevViewBeforeConfused: IslandViewName = "overview";+ private lastSyncedView: IslandViewName | null = null;+ private lastTick = -1;constructor(root: HTMLElement) {this.root = root;@@ -147,7 +149,7 @@ export class Island {this.countdown = h("div", { id: "countdown" });this.header = buildHeader(actions);- this.views = buildViews(actions);+ this.views = buildViews(actions, () => this.animateGeometry(false));this.viewsEl = h("div", { id: "views" });for (const v of this.views.values()) this.viewsEl.append(v.el);this.contentEl = h("div", { id: "content" }, this.header.el, this.viewsEl);@@ -271,6 +273,91 @@ export class Island {this.fsm.pinned = false;}+ // ── File drop ───────────────────────────────────────────────────────────────++ private onDragDrop(e: { type: string; paths?: string[] }) {+ if (State.paused) return;+ switch (e.type) {+ case "enter":+ case "over": {+ if (State.fileDragOver) return;+ State.fileDragOver = true;+ this.engine.animateMorph(1);+ this.alert("upload");+ break;+ }+ case "leave": {+ if (!State.fileDragOver) return;+ State.fileDragOver = false;+ this.engine.animateMorph(0);+ if (State.view === "upload") this.setView(State.defaultView());+ State.notify();+ break;+ }+ case "drop": {+ State.fileDragOver = false;+ const path = e.paths?.[0];+ if (!path) {+ this.engine.animateMorph(0);+ this.setView(State.defaultView());+ return;+ }+ void this.swallow(path);+ break;+ }+ }+ }++ /** Mochi eats the file, then the progress bar runs and `choose` appears. */+ private async swallow(path: string) {+ try {+ const file = await Bridge.ingestFile(path);+ State.droppedFile = { name: file.name, path: file.path };+ State.chatHistory = [];+ void Bridge.chatReset();+ } catch (err) {+ State.noteMessage = String(err).replace(/^Error:\s*/, "");+ this.engine.animateMorph(0);+ this.setView("note");+ Sound.play("error");+ window.setTimeout(() => this.setView(State.defaultView()), 2400);+ return;+ }++ this.engine.gulp();+ Sound.play("gulp");+ this.engine.triggerEmote("happy");+ window.setTimeout(() => this.engine.animateMorph(0), 950);++ State.uploadProgress = 0;+ State.uploadStartMs = performance.now();+ this.lastTick = -1;+ this.setView("uploading");+ this.ensureRunning();+ }++ /** Time-based progress, `tick` every 10 %, then `choose`. */+ private stepUpload(nowMs: number) {+ if (State.uploadStartMs == null) return;+ const t = Math.min(1, (nowMs - State.uploadStartMs) / 1000 / State.uploadDuration);+ State.uploadProgress = t * (2 - t);+ const tick = Math.floor(State.uploadProgress * 10);+ if (tick !== this.lastTick && tick < 10) {+ this.lastTick = tick;+ Sound.play("tick");+ }+ this.views.get("uploading")?.sync();+ if (t >= 1) {+ State.uploadStartMs = null;+ State.uploadProgress = 1;+ this.views.get("uploading")?.sync();+ Sound.play("approve");+ window.setTimeout(() => {+ if (State.view === "uploading") this.setView("choose");+ }, 600);+ }+ }+// ── Geometry ────────────────────────────────────────────────────────────────private targetSize(): { w: number; h: number; r: number } {@@ -372,6 +459,8 @@ export class Island {State.lastActivity = performance.now();});+ void onDragDrop((e) => this.onDragDrop(e));+// Outside Tauri (plain browser) drive the cursor from DOM events so the// island can be inspected with `npm run dev`.if (!IS_TAURI) {@@ -514,12 +603,14 @@ export class Island {}tickMiniBots(dt);+ if (State.view === "uploading") this.stepUpload(nowMs);this.updateCountdown(nowMs);const busy =this.width.animating || this.height.animating || this.radius.animating ||!this.botCx.settled || !this.botCy.settled || !this.botSize.settled ||- greetingActive || this.engine.busy || State.mode !== "hidden";+ greetingActive || this.engine.busy || State.mode !== "hidden" ||+ State.uploadStartMs != null;if (busy) {requestAnimationFrame(this.frame);@@ -631,6 +722,19 @@ export class Island {if (on) view.sync();}+ // The chat is the only view with a text field, so it is the only time the+ // island is allowed to take keyboard focus.+ if (this.lastSyncedView !== State.view) {+ const wasChat = this.lastSyncedView === "prompt";+ this.lastSyncedView = State.view;+ if (State.view === "prompt") {+ void Bridge.focusWindow(true);+ window.setTimeout(() => this.views.get("prompt")?.focus?.(), 120);+ } else if (wasChat) {+ void Bridge.focusWindow(false);+ }+ }+// Compact mini gridconst showGrid = State.mode === "compact";this.miniGrid.style.opacity = showGrid ? "1" : "0";diff --git a/windows/src/settings/main.ts b/windows/src/settings/main.tsindex 23bacb0d..2282b32c 100644--- a/windows/src/settings/main.ts+++ b/windows/src/settings/main.ts@@ -150,6 +150,89 @@ function claudeSection(status: HookStatus): HTMLElement {return section;}+// ── Claude API section ────────────────────────────────────────────────────────++const MODELS: [string, string][] = [+ ["claude-opus-5", "Claude Opus 5"],+ ["claude-sonnet-5", "Claude Sonnet 5"],+ ["claude-haiku-4-5", "Claude Haiku 4.5"],+];++function apiSection(hasKey: boolean): HTMLElement {+ const dot = statusDot(hasKey);+ const state = h("span", { class: "hint", text: hasKey ? "Key saved in the Windows Credential Manager." : "No key yet — the chat needs one." });++ const field = h("input", {+ type: "password",+ placeholder: hasKey ? "•••••••••••• (stored)" : "sk-ant-...",+ style: "flex:1 1 auto;min-width:0",+ autocomplete: "off",+ spellcheck: "false",+ }) as HTMLInputElement;++ const saveBtn = h("button", { class: "primary", text: "Save key" });+ const clearBtn = h("button", { class: "danger", text: "Remove" });+ const feedback = h("div", {});++ async function refresh() {+ const present = (await Bridge.secretPresent("anthropic-api-key")) ?? false;+ dot.style.background = present ? "#22c55e" : "#f4505e";+ state.textContent = present+ ? "Key saved in the Windows Credential Manager."+ : "No key yet — the chat needs one.";+ field.placeholder = present ? "•••••••••••• (stored)" : "sk-ant-...";+ clearBtn.style.display = present ? "" : "none";+ }++ saveBtn.addEventListener("click", async () => {+ const value = field.value.trim();+ if (!value) return;+ clear(feedback);+ try {+ await Bridge.secretSet("anthropic-api-key", value);+ field.value = "";+ feedback.append(h("div", { class: "notice ok", text: "Saved. It never touches disk." }));+ await refresh();+ } catch (err) {+ feedback.append(h("div", { class: "notice err", text: `Could not save: ${String(err)}` }));+ }+ });++ clearBtn.addEventListener("click", async () => {+ clear(feedback);+ try {+ await Bridge.secretClear("anthropic-api-key");+ feedback.append(h("div", { class: "notice ok", text: "Key removed." }));+ await refresh();+ } catch (err) {+ feedback.append(h("div", { class: "notice err", text: `Could not remove: ${String(err)}` }));+ }+ });++ const model = h("select", {}) as HTMLSelectElement;+ for (const [id, label] of MODELS) model.append(h("option", { value: id, text: label }));+ if (!MODELS.some(([id]) => id === settings.model)) {+ model.append(h("option", { value: settings.model, text: settings.model }));+ }+ model.value = settings.model;+ model.addEventListener("change", () => {+ settings.model = model.value;+ void save();+ });++ clearBtn.style.display = hasKey ? "" : "none";++ return h(+ "section",+ {},+ h("h2", {}, dot, h("span", { text: "Claude" })),+ state,+ h("div", { class: "row" }, h("label", { text: "API key" }), field, saveBtn, clearBtn),+ h("div", { class: "row" }, h("label", { text: "Model" }), model),+ feedback,+ );+}+// ── General section ───────────────────────────────────────────────────────────function generalSection(): HTMLElement {@@ -221,10 +304,13 @@ async function main() {installed: false, settingsPath: "", hookPath: "", hookReady: false,};+ const hasKey = (await Bridge.secretPresent("anthropic-api-key")) ?? false;+clear(root);root.append(h("h1", {}, h("span", { text: "Coucou" }), h("span", { class: "version", text: version })),claudeSection(status),+ apiSection(hasKey),generalSection(),h("div", {class: "hint",diff --git a/windows/src/style.css b/windows/src/style.cssindex e75ac212..553df9dc 100644--- a/windows/src/style.css+++ b/windows/src/style.css@@ -691,3 +691,299 @@ input[type="range"]::-webkit-slider-thumb {.nowrap {white-space: nowrap;}++/* ── Chat (prompt view) ─────────────────────────────────────────────────── */++.chat-card {+ overflow: hidden;+}++.chat-body {+ position: relative;+ z-index: 1;+ height: 100%;+ display: flex;+ flex-direction: column;+ gap: 6px;+ padding: 12px 16px 14px 84px;+}++.chip-row:empty {+ display: none;+}++.chip {+ display: inline-flex;+ align-items: center;+ gap: 6px;+ padding: 4px 10px;+ border-radius: 999px;+ background: rgba(255, 255, 255, 0.1);+ font: 400 11.5px var(--font);+ color: var(--ink-2);+ border: 1.5px solid rgba(255, 255, 255, 0.75);+ transform: scale(1.06);+ transition: border-color 0.3s ease-out 0.45s, transform 0.3s ease-out 0.45s;+}++.chip.settled {+ border-color: rgba(255, 255, 255, 0);+ transform: scale(1);+}++.chip-dot {+ width: 7px;+ height: 7px;+ border-radius: 50%;+ background: linear-gradient(135deg, #ff6b5b, #f7b32b, #2dd4a7, #38bdf8, #a78bfa);+}++.chat-log {+ flex: 1 1 auto;+ min-height: 0;+ overflow-y: auto;+ display: flex;+ flex-direction: column;+ gap: 6px;+ padding: 2px 0;+ scrollbar-width: thin;+ scrollbar-color: rgba(255, 255, 255, 0.18) transparent;+}++.chat-row {+ display: flex;+}++.chat-row.user {+ justify-content: flex-end;+ padding-left: 32px;+}++.bubble {+ background: rgba(255, 255, 255, 0.13);+ border-radius: 12px;+ padding: 6px 10px;+ font: 400 12.5px var(--font);+ color: var(--ink-2);+ white-space: pre-wrap;+ user-select: text;+}++.reply {+ font: 400 12.5px var(--font);+ color: #b0b5be;+ white-space: pre-wrap;+ padding-right: 8px;+ user-select: text;+}++.typing {+ display: flex;+ gap: 4px;+ padding: 4px 2px;+}++.typing i {+ width: 5px;+ height: 5px;+ border-radius: 50%;+ background: var(--dim-3);+ animation: typing 0.9s ease-in-out infinite;+}++.typing i:nth-child(2) {+ animation-delay: 0.14s;+}++.typing i:nth-child(3) {+ animation-delay: 0.28s;+}++@keyframes typing {+ 0%, 100% { transform: scale(0.6); }+ 50% { transform: scale(1.2); }+}++.chat-bar {+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 6px 10px;+ background: rgba(255, 255, 255, 0.07);+ border-radius: 12px;+}++.chat-input {+ flex: 1 1 auto;+ min-width: 0;+ border: 0;+ background: transparent;+ color: var(--ink);+ font: 400 13px var(--font);+ outline: none;+ cursor: text;+}++.chat-input::placeholder {+ color: var(--dim-3);+}++.send-btn {+ width: 28px;+ height: 28px;+ flex: 0 0 28px;+ border: 0;+ border-radius: 50%;+ background: var(--ink);+ color: #0b0c0e;+ display: grid;+ place-items: center;+ cursor: default;+ transition: transform 0.08s ease-out;+}++.send-btn:active {+ transform: scale(0.94);+}++/* ── Drop zone ──────────────────────────────────────────────────────────── */++.drop-card {+ background: var(--card-flat);+ border: 0;+}++.drop-frame {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ pointer-events: none;+}++.drop-frame rect {+ stroke: rgba(255, 255, 255, 0.13);+ animation: dash-march 1.1s linear infinite, dash-breathe 7s ease-in-out infinite;+}++.drop-card.over {+ background: radial-gradient(200px 200px at 50% 100%, rgba(34, 197, 94, 0.13), transparent 70%),+ var(--card-flat);+}++.drop-card.over .drop-frame rect {+ stroke: rgba(34, 197, 94, 0.65);+ animation: dash-march 1.1s linear infinite;+}++@keyframes dash-march {+ to { stroke-dashoffset: -11; }+}++@keyframes dash-breathe {+ 0%, 100% { stroke: rgba(255, 255, 255, 0.11); }+ 50% { stroke: rgba(255, 255, 255, 0.15); }+}++.drop-body {+ position: relative;+ z-index: 1;+ height: 100%;+ display: flex;+ flex-direction: column;+ justify-content: center;+ gap: 8px;+ padding-left: 196px;+}++.drop-title {+ font: 500 13px var(--font);+ color: #d5d7db;+ transition: color 0.2s;+}++.drop-card.over .drop-title {+ color: var(--green-2);+}++.drop-tags {+ display: flex;+ gap: 6px;+}++.drop-tags span {+ font: 400 11px var(--font);+ padding: 3px 8px;+ border-radius: 999px;+ background: rgba(255, 255, 255, 0.07);+ color: #b9bdc4;+}++/* ── Uploading ──────────────────────────────────────────────────────────── */++.up-card {+ background: radial-gradient(260px 260px at 50% 140%, rgba(52, 211, 153, 0.14), transparent 70%),+ var(--card);+}++.up-card.done {+ background: radial-gradient(260px 260px at 50% 140%, rgba(52, 211, 153, 0.28), transparent 70%),+ var(--card);+}++.up-row {+ position: absolute;+ left: 26px;+ top: 36px;+ width: 526px;+ display: flex;+ justify-content: space-between;+ gap: 8px;+ font: 400 12.5px var(--font);+ color: #a9adb5;+}++.up-name {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.up-name.done {+ color: var(--green-2);+ font-weight: 600;+}++.up-pct {+ font-variant-numeric: tabular-nums;+ font-weight: 500;+ flex: 0 0 auto;+}++.up-track {+ position: absolute;+ left: 26px;+ top: 58px;+ width: 526px;+ height: 6px;+ border-radius: 3px;+ background: rgba(255, 255, 255, 0.09);+}++.up-fill {+ height: 6px;+ border-radius: 3px;+ background: linear-gradient(90deg, #1fa87a, #34d399);+}++.up-glow {+ position: absolute;+ left: 0;+ top: -3px;+ width: 28px;+ height: 12px;+ border-radius: 50%;+ background: rgba(110, 231, 183, 0.45);+ filter: blur(5px);+ pointer-events: none;+}diff --git a/windows/src/views/chat.ts b/windows/src/views/chat.tsnew file mode 100644index 00000000..2cd253f7--- /dev/null+++ b/windows/src/views/chat.ts@@ -0,0 +1,133 @@+// Chat view — DOM port of PromptView / ChatBubble / TypingDotsView from+// IslandViewContent.swift.++import { h, svg, clear } from "./dom";+import { ICONS } from "./icons";+import { Bridge, type ChatContext } from "../core/bridge";+import { Sound } from "../core/sound";+import { State, type ChatMessage } from "../core/state";+import type { ViewHost } from "./views";++let nextId = 1;++function bubble(message: ChatMessage): HTMLElement {+ if (message.role === "user") {+ return h(+ "div",+ { class: "chat-row user" },+ h("div", { class: "bubble", text: message.content }),+ );+ }+ return h("div", { class: "chat-row" }, h("div", { class: "reply", text: message.content }));+}++function typingDots(): HTMLElement {+ return h(+ "div",+ { class: "chat-row" },+ h("div", { class: "typing" }, h("i"), h("i"), h("i")),+ );+}++/** The coloured chip showing what the question is about (a dropped file). */+function contextChip(label: string): HTMLElement {+ const chip = h("div", { class: "chip" }, h("i", { class: "chip-dot" }), h("span", { text: label }));+ requestAnimationFrame(() => chip.classList.add("settled"));+ return chip;+}++export function buildPrompt(onHeightChange: () => void): ViewHost {+ const chipRow = h("div", { class: "chip-row" });+ const log = h("div", { class: "chat-log" });+ const input = h("input", {+ type: "text",+ class: "chat-input",+ placeholder: "Ask me anything…",+ spellcheck: "false",+ }) as HTMLInputElement;+ const send = h("button", { class: "send-btn", title: "Send" }, svg(ICONS.arrowUp, 11));+ const bar = h("div", { class: "chat-bar" }, input, send);++ const el = h(+ "div",+ { class: "view" },+ h("div", { class: "card wash chat-card" }, h("div", { class: "chat-body" }, chipRow, log, bar)),+ );+ (el.querySelector(".card") as HTMLElement).style.setProperty("--wash", "rgba(99,102,241,0.5)");++ let sending = false;+ let renderedCount = -1;++ async function submit() {+ const query = input.value.trim();+ if (!query || sending) return;+ input.value = "";+ sending = true;+ Sound.play("send");++ State.chatHistory.push({ id: nextId++, role: "user", content: query });+ State.stateOverride = "thinking";+ State.notify();+ onHeightChange();++ const file = State.droppedFile;+ const context: ChatContext | null =+ State.chatHistory.length === 1 && file ? { kind: "file", name: file.name, path: file.path } : null;++ try {+ const reply = await Bridge.chatSend(query, context);+ State.chatHistory.push({ id: nextId++, role: "assistant", content: reply.text });+ State.stateOverride = null;+ Sound.play("finish");+ } catch (err) {+ State.stateOverride = null;+ State.noteMessage = String(err).replace(/^Error:\s*/, "");+ State.view = "note";+ Sound.play("error");+ } finally {+ sending = false;+ State.notify();+ onHeightChange();+ input.focus();+ }+ }++ send.addEventListener("click", () => void submit());+ input.addEventListener("keydown", (e) => {+ if ((e as KeyboardEvent).key === "Enter") {+ e.preventDefault();+ void submit();+ }+ e.stopPropagation(); // Escape closes the island, not the chat+ });++ return {+ el,+ sync() {+ const file = State.droppedFile;+ const wantChip = file?.name ?? "";+ if (chipRow.dataset.label !== wantChip) {+ chipRow.dataset.label = wantChip;+ clear(chipRow);+ if (wantChip) chipRow.append(contextChip(wantChip));+ }++ const thinking = State.stateOverride === "thinking";+ const count = State.chatHistory.length + (thinking ? 0.5 : 0);+ if (count !== renderedCount) {+ renderedCount = count;+ clear(log);+ for (const m of State.chatHistory) log.append(bubble(m));+ if (thinking) log.append(typingDots());+ log.scrollTop = log.scrollHeight;+ }++ input.placeholder = State.chatHistory.length === 0 ? "Ask me anything…" : "Continue…";+ input.disabled = sending;+ },+ focus() {+ input.focus();+ input.select();+ },+ };+}diff --git a/windows/src/views/upload.ts b/windows/src/views/upload.tsnew file mode 100644index 00000000..714060ff--- /dev/null+++ b/windows/src/views/upload.ts@@ -0,0 +1,123 @@+// Drop zone, upload progress and the "what do you want to do with it" card —+// ports of UploadView / UploadingView / ChooseView from IslandViewContent.swift.+//+// Sending a file by email is not in the Windows v1, so `choose` offers the one+// action the spec asks for: ask a question about it.++import { h, clear } from "./dom";+import { State } from "../core/state";+import type { ViewActions, ViewHost } from "./views";++/** Dashed rounded rect drawn as SVG so the dashes can march like on macOS. */+function dashedFrame(): SVGSVGElement {+ const ns = "http://www.w3.org/2000/svg";+ const el = document.createElementNS(ns, "svg");+ el.setAttribute("class", "drop-frame");+ el.setAttribute("preserveAspectRatio", "none");+ const rect = document.createElementNS(ns, "rect");+ rect.setAttribute("x", "0.75");+ rect.setAttribute("y", "0.75");+ rect.setAttribute("width", "calc(100% - 1.5px)");+ rect.setAttribute("height", "calc(100% - 1.5px)");+ rect.setAttribute("rx", "20");+ rect.setAttribute("fill", "none");+ rect.setAttribute("stroke-width", "1.5");+ rect.setAttribute("stroke-dasharray", "6 5");+ el.append(rect);+ return el;+}++export function buildUpload(): ViewHost {+ const frame = dashedFrame();+ const title = h("div", { class: "drop-title", text: "Drop your files here" });+ const tags = h(+ "div",+ { class: "drop-tags" },+ ...["PDF", "Images", "Code", "Docs"].map((t) => h("span", { text: t })),+ );+ const card = h(+ "div",+ { class: "card drop-card" },+ frame,+ h("div", { class: "drop-body" }, title, tags),+ );+ const el = h("div", { class: "view" }, card);++ return {+ el,+ sync() {+ card.classList.toggle("over", State.fileDragOver);+ },+ };+}++export function buildUploading(): ViewHost {+ const label = h("span", { class: "up-name" });+ const percent = h("span", { class: "up-pct" });+ const fill = h("div", { class: "up-fill" });+ const glow = h("div", { class: "up-glow" });+ const card = h(+ "div",+ { class: "card up-card" },+ h("div", { class: "up-row" }, label, percent),+ h("div", { class: "up-track" }, fill, glow),+ );+ const el = h("div", { class: "view" }, card);++ return {+ el,+ sync() {+ const done = State.uploadProgress >= 0.999;+ const pct = Math.round(State.uploadProgress * 100);+ label.textContent = done+ ? `✓ ${State.droppedFile?.name ?? "File"}`+ : `Uploading ${State.droppedFile?.name ?? "file"}`;+ label.classList.toggle("done", done);+ percent.textContent = done ? "" : `${pct} %`;+ const w = State.uploadProgress * 526;+ fill.style.width = `${w}px`;+ glow.style.transform = `translateX(${Math.max(0, w - 14)}px)`;+ glow.style.opacity = State.uploadProgress > 0.01 ? "1" : "0";+ card.classList.toggle("done", done);+ },+ };+}++export function buildChoose(actions: ViewActions): ViewHost {+ const title = h("div", { class: "title" });+ const sub = h("div", { class: "sub", text: "What do you want to do with it?" });+ const row = h(+ "div",+ { class: "actions" },+ h("button", {+ class: "btn primary",+ text: "Ask a question",+ onclick: () => actions.setView("prompt"),+ }),+ h("button", {+ class: "btn secondary",+ text: "Cancel",+ onclick: () => actions.setView(State.defaultView()),+ }),+ );+ const el = h(+ "div",+ { class: "view" },+ h(+ "div",+ { class: "card" },+ h("div", { class: "stack", style: "padding:0 18px 0 98px" }, title, sub, row),+ ),+ );++ return {+ el,+ sync() {+ clear(title);+ title.append(+ h("b", { text: State.droppedFile?.name ?? "file" }),+ document.createTextNode(" is ready."),+ );+ },+ };+}diff --git a/windows/src/views/views.ts b/windows/src/views/views.tsindex 44af2bb3..f2d23b53 100644--- a/windows/src/views/views.ts+++ b/windows/src/views/views.ts@@ -8,6 +8,8 @@ import { Ticker } from "./ticker";import { State, type AgentTask } from "../core/state";import { washRGBA, type IslandViewName, type Wash } from "../core/layout";import { createMiniBot, pruneMiniBots } from "../mochi/minibots";+import { buildPrompt } from "./chat";+import { buildChoose, buildUpload, buildUploading } from "./upload";export interface ViewActions {setView(v: IslandViewName): void;@@ -26,6 +28,8 @@ export interface ViewActions {export interface ViewHost {el: HTMLElement;sync(): void;+ /** Called when the view becomes active, for views with a text field. */+ focus?(): void;}// ── Shared pieces ─────────────────────────────────────────────────────────────@@ -415,7 +419,10 @@ function buildPlaceholder(title: string, sub: string): ViewHost {// ── Registry ──────────────────────────────────────────────────────────────────-export function buildViews(actions: ViewActions): Map<IslandViewName, ViewHost> {+export function buildViews(+ actions: ViewActions,+ onChatHeightChange: () => void,+): Map<IslandViewName, ViewHost> {const map = new Map<IslandViewName, ViewHost>();map.set("overview", buildOverview(actions));map.set("empty", buildEmpty(actions));@@ -426,11 +433,12 @@ export function buildViews(actions: ViewActions): Map<IslandViewName, ViewHost>map.set("confused", buildConfused());map.set("note", buildNote());map.set("settings", buildSettings(actions));- map.set("prompt", buildPlaceholder("Chat is coming next.", "Ask Claude straight from the island."));- map.set("upload", buildPlaceholder("Drop your files here", "PDF · Images · Code · Docs"));- map.set("uploading", buildPlaceholder("Uploading…", ""));- map.set("choose", buildPlaceholder("File is ready.", "What do you want to do with it?"));- map.set("mail", buildPlaceholder("New email", ""));+ map.set("prompt", buildPrompt(onChatHeightChange));+ map.set("upload", buildUpload());+ map.set("uploading", buildUploading());+ map.set("choose", buildChoose(actions));+ // Not in the Windows v1: sending a file by email, window attach + web result.+ map.set("mail", buildPlaceholder("Sending by email isn't in this version.", ""));map.set("searching", buildPlaceholder("Claude is searching…", ""));map.set("result", buildPlaceholder("Result", ""));return map;