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/Linux: Mochi-to-desktop shortcut and the island's list and diff keys
Claude322e2ab02235
diff --git a/windows/README.md b/windows/README.mdindex cf48b882..85a39b0a 100644--- a/windows/README.md+++ b/windows/README.md@@ -67,8 +67,11 @@ You can also [build it yourself](#build-it-yourself).| `Ctrl+Alt+→` / `Ctrl+Alt+←` | Next / previous pill || `Ctrl+Alt+S` | Mutes or unmutes Mochi || `Ctrl+Alt+G` | Opens the wardrobe |+| `Ctrl+Alt+D` | Sends Mochi to the desktop, or brings him home || `Ctrl+Alt+N` | Opens and closes the island (off until you turn it on) || In the open island: `Ctrl+→` `Ctrl+←`, `Ctrl+1`–`Ctrl+9` | Switch pills |+| In the open island: `Ctrl+↓` `Ctrl+↑`, `Ctrl+O` | Walk the open GitHub list, open the highlighted row |+| In the open island: `Ctrl+E` | Opens the latest edit's diff, or closes the diff || In the open island: `Ctrl+Enter`, `Ctrl+K` | Send, start a new chat || In the open island: `Ctrl+,`, `Ctrl+P` | Settings, keep the island open |@@ -92,7 +95,9 @@ for one, puts `ą` on `AltGr+A` and `ś` on `AltGr+S`. The recorder refuses sucha combination too.Older Intel graphics drivers rotate the screen on `Ctrl+Alt+←` / `→`; if yours-still does, those two show up as *In use*.+still does, those two show up as *In use*. On Linux, Xfce and MATE keep+`Ctrl+Alt+D` to show the desktop, so there **Send Mochi to the desktop** shows+up as *In use* until you give it other keys.Everything else happens on its own: a Claude Code permission request opens theisland with **Deny / Allow**, a question from Claude Code shows its options to@@ -427,19 +432,21 @@ own window.never the file itself. Counts and diffs come from Claude Code's Edit,MultiEdit and Write, on whichever pill its session is on (VS Code, Cursor,Claude Desktop); other agents' edits show as plain steps.-- The GitHub lists are clicked, not walked with the arrow keys, and there is no- iPhone to keep fetching them while the pill is off.+- There is no iPhone to keep fetching the GitHub lists while the pill is off.- Keyboard shortcuts use `Ctrl+Alt` where the Mac uses `⌃⌥`, with differentkeys (see [Keyboard shortcuts](#keyboard-shortcuts)), and `Ctrl` where theMac uses `⌘` inside the island. "Bring the terminal forward" is "Open- terminal" here. Not in this version: sending Mochi to the desktop from the- keyboard (drag him out instead) and attaching the front window (their ids are- kept for later), moving through a card's- list (`⌘↑` `⌘↓` `⌘O`) and the diff (`⌘E`). The island only reads its own- shortcuts while it has the keyboard: in the chat, or after a global shortcut- opened it. **Go to alert** brings up any agent's waiting card on its own pill;- **Toggle the island** folds a waiting card rather than dropping it, like `Esc`- in the island.+ terminal" here. Not in this version: attaching the front window (its id is+ kept for later). The island only reads its own shortcuts while it has the+ keyboard: in the chat, or after a global shortcut opened it. `Ctrl+↓`+ `Ctrl+↑` `Ctrl+O` walk the GitHub lists, as on the Mac, and the highlighted+ row scrolls into view where the Mac's three-row list doesn't follow it; in the+ chat field `Ctrl+↑` `Ctrl+↓` keep moving the cursor. **Go to alert** brings+ up any agent's waiting card on its own pill; **Toggle the island** folds a+ waiting card rather than dropping it, like `Esc` in the island. **Send Mochi+ to the desktop** (`Ctrl+Alt+D`, the Mac's `⌃⌥D`)+ flies him to his spot, or to the bottom-right corner when that spot was on a+ display that is gone; pressed again, he flies home.- Weekly recap:- Sharing happens inside the island instead of a separate panel, and Savewrites straight into Pictures (or Downloads) instead of asking where. There@@ -463,8 +470,7 @@ own window.the island's text right to left but not its layout: Mochi and the pills keeptheir sides.- Mochi on the desktop doesn't dance: there is no music integration to dance- to. Dropping him on a window doesn't attach it to the chat, and the Mac's- ⌃⌥D shortcut isn't there — drag him out, double-click him home. While he+ to, and dropping him on a window doesn't attach it to the chat. While hesleeps, the transparent square around him (120 px) takes the first mousemove, which wakes him and gives the rest back to the desktop.@@ -514,7 +520,8 @@ What changes on Linux:(KDE Plasma, COSMIC, Hyprland, Sway…), placed with margins and dragged withinthat display; on X11 it is an ordinary always-on-top window that goesanywhere. **GNOME on Wayland** has no layer-shell and lets no app place its- own window, so there Mochi can't leave the island: dragging him does nothing.+ own window, so there Mochi can't leave the island: dragging him does nothing,+ and the desktop shortcut only makes him grumble.- **Claude Code hooks** go through `~/.local/share/coucou/bin/coucou-hook` and aUnix socket at `$XDG_RUNTIME_DIR/coucou.sock`. Both ends check that the otherruns as the same user. Every other agent uses the same relay, single-quoted@@ -530,8 +537,8 @@ What changes on Linux:desktop's own keyboard settings instead:`coucou --shortcut openChat` (or the AppImage's path) runs the action in theCoucou that is already open. The ids are `toggleIsland`, `openChat`,- `goToAlert`, `jumpToTerminal`, `nextPill`, `prevPill`, `muteToggle` and- `wardrobeToggle`.+ `goToAlert`, `jumpToTerminal`, `nextPill`, `prevPill`, `muteToggle`,+ `desktopToggle` and `wardrobeToggle`.- **Keys** live in the Secret Service (GNOME Keyring, KWallet).- **Plan usage**: the status line relay is `~/.local/share/coucou/bin/coucou-hook--statusline` and runs your previous status line with `/bin/sh -c`, like Claudediff --git a/windows/src-tauri/src/desktop.rs b/windows/src-tauri/src/desktop.rsindex 5b7e6509..5b57f21c 100644--- a/windows/src-tauri/src/desktop.rs+++ b/windows/src-tauri/src/desktop.rs@@ -569,21 +569,24 @@ fn remember_spot(app: &AppHandle, d: &Desktop, pos: (f64, f64), on_desktop: bool}/// Where he lands when he flies out, or `None` when his spot is on a display-/// that is no longer connected.-fn target_spot(app: &AppHandle, d: &Desktop) -> Option<(f64, f64)> {+/// that is no longer connected — unless `anywhere`, the user sending him out+/// with the desktop shortcut: then the first-visit corner.+fn target_spot(app: &AppHandle, d: &Desktop, anywhere: bool) -> Option<(f64, f64)> {let all = displays(app, d);let saved = app.try_state::<crate::Shared>().and_then(|s| s.settings.lock().unwrap().desktop_mochi.spot.clone());+ // A fresh start in the corner of the island's display.+ let corner = || {+ let (cx, top, _) = island_anchor(app, d)?;+ let home = logic::display_near((cx, top + 1.0), &all)?;+ Some(logic::default_spot(&home, SIZE, MARGIN))+ };match saved {Some(spot) if spot.space == d.mode.space() => {- logic::restore_spot((spot.x, spot.y), &all, SIZE, MARGIN)- }- // Never placed, or placed under another kind of session: a fresh start- // in the corner of the island's display.- _ => {- let (cx, top, _) = island_anchor(app, d)?;- let home = logic::display_near((cx, top + 1.0), &all)?;- Some(logic::default_spot(&home, SIZE, MARGIN))+ let restored = logic::restore_spot((spot.x, spot.y), &all, SIZE, MARGIN);+ if anywhere { restored.or_else(corner) } else { restored }}+ // Never placed, or placed under another kind of session.+ _ => corner(),}}@@ -804,15 +807,16 @@ pub async fn desktop_mochi_drag_end(app: AppHandle, x: f64, y: f64) {/// Launch or the end of an alert: from the island to his spot. False when the/// spot is on a display that is gone — he then stays home, and is forgotten-/// there so the next launch doesn't try again.+/// there so the next launch doesn't try again. `anywhere` (the desktop+/// shortcut) lands him in the first-visit corner instead.#[tauri::command]-pub async fn desktop_mochi_fly_out(app: AppHandle) -> bool {+pub async fn desktop_mochi_fly_out(app: AppHandle, anywhere: Option<bool>) -> bool {let d = app.state::<Arc<Desktop>>().inner().clone();if d.mode == DesktopMode::Off || window(&app).is_none() {return false;}refresh_layer_display(&app, &d);- let Some(target) = target_spot(&app, &d) else {+ let Some(target) = target_spot(&app, &d, anywhere.unwrap_or(false)) else {crate::log::line("desktop Mochi: his spot is on a display that is gone — he stays home");remember(&app, |p| p.on_desktop = false);return false;diff --git a/windows/src-tauri/src/shortcuts.rs b/windows/src-tauri/src/shortcuts.rsindex a47c7c4e..d67a580f 100644--- a/windows/src-tauri/src/shortcuts.rs+++ b/windows/src-tauri/src/shortcuts.rs@@ -16,6 +16,7 @@// Ctrl+Alt+Space open the chat Ctrl+Alt+→ / ← next / previous pill// Ctrl+Alt+A waiting permission Ctrl+Alt+S mute Mochi// Ctrl+Alt+T open the terminal Ctrl+Alt+G wardrobe+// Ctrl+Alt+D Mochi to the desktop, or home again (the Mac's ⌃⌥D)// Ctrl+Alt+N open / close the island (off by default, as on the Mac)//// ⌃⌥[ and ⌃⌥] became the arrows (brackets are AltGr characters almost@@ -63,8 +64,7 @@ pub const ACTIONS: &[ActionDef] = &[action("nextPill", "Ctrl+Alt+Right", true, true),action("prevPill", "Ctrl+Alt+Left", true, true),action("muteToggle", "Ctrl+Alt+S", true, true),- // Mochi on the desktop is not in this version.- action("desktopToggle", "Ctrl+Alt+D", true, false),+ action("desktopToggle", "Ctrl+Alt+D", true, true),action("wardrobeToggle", "Ctrl+Alt+G", true, true),];@@ -423,10 +423,10 @@ mod tests {}#[test]- fn the_actions_not_ported_yet_are_reserved_not_registered() {+ fn the_action_not_ported_yet_is_reserved_not_registered() {let plan = plan(&Bindings::new(), never);for (def, outcome) in plan {- let reserved = matches!(def.id, "attachFrontWindow" | "desktopToggle");+ let reserved = def.id == "attachFrontWindow";assert_eq!(def.ported, !reserved);match outcome {Ok(_) => assert!(def.ported && def.enabled_by_default, "{}", def.id),@@ -545,7 +545,8 @@ mod tests {assert_eq!(from_args(&args(&["coucou", "--shortcut", "wardrobeToggle"])), Some("wardrobeToggle"));assert_eq!(from_args(&args(&["coucou", "--shortcut"])), None);assert_eq!(from_args(&args(&["coucou", "--shortcut", "rm -rf"])), None);- assert_eq!(from_args(&args(&["coucou", "--shortcut", "desktopToggle"])), None);+ assert_eq!(from_args(&args(&["coucou", "--shortcut", "desktopToggle"])), Some("desktopToggle"));+ assert_eq!(from_args(&args(&["coucou", "--shortcut", "attachFrontWindow"])), None);assert_eq!(from_args(&args(&["coucou"])), None);}}diff --git a/windows/src/core/bridge.ts b/windows/src/core/bridge.tsindex 1bbf25fc..475492ce 100644--- a/windows/src/core/bridge.ts+++ b/windows/src/core/bridge.ts@@ -194,8 +194,9 @@ export const Bridge = {/** X11: top-left corner, physical pixels. */desktopDragMove: (x: number, y: number) => call<void>("desktop_mochi_drag_move", { x, y }),desktopDragEnd: (x: number, y: number) => call<void>("desktop_mochi_drag_end", { x, y }),- /** From the island to his spot. False: no spot on any connected display. */- desktopFlyOut: () => call<boolean>("desktop_mochi_fly_out"),+ /** From the island to his spot. False: no spot on any connected display.+ * `anywhere`: the first-visit corner then, rather than staying home. */+ desktopFlyOut: (anywhere = false) => call<boolean>("desktop_mochi_fly_out", { anywhere }),/** To the island, then hidden. `forget`: he lives in the island again. */desktopFlyHome: (forget: boolean) => call<boolean>("desktop_mochi_fly_home", { forget }),/** Asleep, the cursor poll stops. */diff --git a/windows/src/core/shortcuts.ts b/windows/src/core/shortcuts.tsindex 545d8000..3855ebfa 100644--- a/windows/src/core/shortcuts.ts+++ b/windows/src/core/shortcuts.ts@@ -32,6 +32,9 @@ export const SHORTCUT_TEXT = {island: {nextPrev: N_("Next or previous pill"),byNumber: N_("Go to pill 1 to 9"),+ navItems: N_("Navigate list items"),+ open: N_("Open selected item"),+ diff: N_("Open / close current diff"),send: N_("Send the message"),newChat: N_("Start a new chat"),settings: N_("Open Settings"),@@ -76,7 +79,7 @@ export const SHORTCUTS: readonly ShortcutDef[] = [def("nextPill", "Ctrl+Alt+Right", true, true),def("prevPill", "Ctrl+Alt+Left", true, true),def("muteToggle", "Ctrl+Alt+S", true, true),- def("desktopToggle", "Ctrl+Alt+D", true, false),+ def("desktopToggle", "Ctrl+Alt+D", true, true),def("wardrobeToggle", "Ctrl+Alt+G", true, true),];@@ -349,11 +352,13 @@ export function pillByNumber(ids: readonly string[], n: number): string | null {return n >= 1 && n <= ids.length ? ids[n - 1] : null;}-/** Shown read-only in Settings, like ShortcutLogic.islandShortcuts. The Mac's- * ⌘↑ ⌘↓ ⌘O (card lists) and ⌘E (diff) have no counterpart here yet. */+/** Shown read-only in Settings, like ShortcutLogic.islandShortcuts, in its order. */export const ISLAND_SHORTCUTS: readonly { keys: string; description: string }[] = [{ keys: "Ctrl+→ / Ctrl+←", description: SHORTCUT_TEXT.island.nextPrev },{ keys: "Ctrl+1 – Ctrl+9", description: SHORTCUT_TEXT.island.byNumber },+ { keys: "Ctrl+↓ / Ctrl+↑", description: SHORTCUT_TEXT.island.navItems },+ { keys: "Ctrl+O", description: SHORTCUT_TEXT.island.open },+ { keys: "Ctrl+E", description: SHORTCUT_TEXT.island.diff },{ keys: "Ctrl+Enter", description: SHORTCUT_TEXT.island.send },{ keys: "Ctrl+K", description: SHORTCUT_TEXT.island.newChat },{ keys: "Ctrl+,", description: SHORTCUT_TEXT.island.settings },@@ -364,6 +369,12 @@ export const ISLAND_SHORTCUTS: readonly { keys: string; description: string }[]export type IslandKeyAction =| { kind: "cycle"; delta: 1 | -1 }| { kind: "pill"; number: number }+ /** Ctrl+↓ / Ctrl+↑: the highlight through the card's list (⌘↓ ⌘↑). */+ | { kind: "list"; delta: 1 | -1 }+ /** Ctrl+O: opens the highlighted item (⌘O). */+ | { kind: "openSelection" }+ /** Ctrl+E: the latest edit's diff, or closes the one open (⌘E). */+ | { kind: "diff" }| { kind: "newChat" }| { kind: "settings" }| { kind: "pin" };@@ -371,7 +382,7 @@ export type IslandKeyAction =/*** A key pressed while the island has the keyboard → what it does, or null to* leave it alone. Ctrl stands in for ⌘. In a text field Ctrl+← and Ctrl+→- * keep moving by word.+ * keep moving by word, and Ctrl+↑ and Ctrl+↓ by paragraph.*/export function islandKeyAction(e: KeyPress,@@ -382,11 +393,18 @@ export function islandKeyAction(if (ctx.inTextField) return null;return { kind: "cycle", delta: e.key === "ArrowRight" ? 1 : -1 };}+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {+ if (ctx.inTextField) return null;+ return { kind: "list", delta: e.key === "ArrowDown" ? 1 : -1 };+ }const digit = /^Digit([1-9])$/.exec(e.code);if (digit) return { kind: "pill", number: Number(digit[1]) };const letter = /^[a-z]$/i.test(e.key) ? e.key.toLowerCase() : /^Key([A-Z])$/.exec(e.code)?.[1].toLowerCase();if (letter === "k") return ctx.view === "prompt" ? { kind: "newChat" } : null;if (letter === "p") return { kind: "pin" };+ if (letter === "o") return { kind: "openSelection" };+ // The diff lives in the overview's left card: ⌘E means something only there.+ if (letter === "e") return ctx.view === "overview" ? { kind: "diff" } : null;if (e.key === "," || e.code === "Comma") return { kind: "settings" };return null;}diff --git a/windows/src/core/state.ts b/windows/src/core/state.tsindex b395a4e3..a74a72ec 100644--- a/windows/src/core/state.ts+++ b/windows/src/core/state.ts@@ -229,6 +229,10 @@ class AppState {private sessionDiffTimers = new Map<string, number>();/** Never reset, so an id can never point at a newer diff than the one tapped. */private nextDiffId = 0;+ /** Ctrl+↑ / Ctrl+↓: the highlighted row of the card's list (AppState.cardSelection). */+ cardSelection: number | null = null;+ /** Rows in the list on screen, 0 when there is none (AppState.cardItemCount). */+ cardItemCount = 0;/*** Mochi is out of the island — on the desktop, flying, or being dragged* there — so the island's own Mochi is hidden (AppState.mochiOnDesktop).diff --git a/windows/src/island/desktop.ts b/windows/src/island/desktop.tsindex eac54d24..538164a3 100644--- a/windows/src/island/desktop.ts+++ b/windows/src/island/desktop.ts@@ -41,7 +41,7 @@ export class DesktopLink {constructor(host: DesktopHost) {this.host = host;this.controller = new DesktopMochiController({- flyOut: async () => (await Bridge.desktopFlyOut()) ?? false,+ flyOut: async (anywhere) => (await Bridge.desktopFlyOut(anywhere)) ?? false,flyHome: async (forget) => (await Bridge.desktopFlyHome(forget)) ?? true,setAway: (away) => {State.mochiOnDesktop = away;@@ -90,6 +90,15 @@ export class DesktopLink {if (this.supported) void this.controller.launchFlyIfNeeded();}+ /**+ * The desktop shortcut: out to his spot, or home. Not in the middle of a+ * drag out of the island — the drop decides that one.+ */+ flyOutOrHome() {+ if (!this.supported || this.carrying) return;+ void this.controller.flyOutOrHome();+ }+// ── Drag out of the island ──────────────────────────────────────────────────/** Whether Mochi can be picked up from the island right now. */diff --git a/windows/src/island/island.ts b/windows/src/island/island.tsindex 43279c29..f3b466d7 100644--- a/windows/src/island/island.ts+++ b/windows/src/island/island.ts@@ -24,6 +24,7 @@ import { h } from "../views/dom";import { IslandStateMachine } from "./fsm";import { refreshHookPills } from "./integrations";import { DesktopLink } from "./desktop";+import type { ViewCommand } from "./shortcuts";import { DRAG_THRESHOLD } from "../mochi/desktop-logic";const BOT_OVERHANG = 40;@@ -490,6 +491,25 @@ export class Island {void Bridge.focusWindow(true);}+ /** The desktop shortcut needs a desktop Mochi: none on GNOME's Wayland. */+ canLeaveIsland(): boolean {+ return this.desktop.supported;+ }++ /** The desktop shortcut (macOS DesktopMochiController.flyOutOrHome). */+ flyOutOrHome() {+ // The greeting and the drop sequence draw a Mochi of their own: he stays+ // for them, as he does for a drag (canDragOut).+ const busy = State.mode === "expanded" && (State.view === "greeting" || this.uploadActive);+ if (busy && !State.mochiOnDesktop) return;+ this.desktop.flyOutOrHome();+ }++ /** Ctrl+O / Ctrl+E go to the view on screen. */+ viewCommand(command: ViewCommand) {+ this.views.get(State.view)?.command?.(command);+ }+// ── File drop ───────────────────────────────────────────────────────────────private onDragDrop(e: { type: string; paths?: string[] }) {diff --git a/windows/src/island/shortcuts.ts b/windows/src/island/shortcuts.tsindex 6d77a224..f00c1f2a 100644--- a/windows/src/island/shortcuts.ts+++ b/windows/src/island/shortcuts.ts@@ -9,7 +9,7 @@import { Bridge, onEvent } from "../core/bridge";import type { BotEmoteName, IslandViewName } from "../core/layout";-import { cyclePill, islandKeyAction, pillByNumber, type IslandKeyAction } from "../core/shortcuts";+import { cyclePill, islandKeyAction, navigate, pillByNumber, type IslandKeyAction } from "../core/shortcuts";import { Sound } from "../core/sound";import { State } from "../core/state";@@ -26,11 +26,21 @@ export interface ShortcutHost {takeKeyboard(): void;/** The wardrobe from any state, or back if it is open (Island.wardrobeAnywhere). */wardrobeAnywhere(): void;+ /** False where Mochi can't leave the island (GNOME on Wayland). */+ canLeaveIsland(): boolean;+ /** Mochi out to the desktop, or home (DesktopMochiController.flyOutOrHome). */+ flyOutOrHome(): void;+ /** Hands Ctrl+O / Ctrl+E to the view on screen (the Mac posts notifications). */+ viewCommand(command: ViewCommand): void;}+/** What the open view is asked to do: open the highlighted item, toggle the diff. */+export type ViewCommand = "openSelection" | "toggleDiff";+function focusPill(host: ShortcutHost, id: string | null, open: boolean) {if (!id) return;State.setFocus(id);+ State.cardSelection = null;Sound.play("blip");if (open) host.alert("overview");else host.setView("overview");@@ -110,8 +120,20 @@ export function runGlobalShortcut(host: ShortcutHost, action: string, resume: ()break;}+ // The Mac's ⌃⌥D. Sending him out lifts Pause, as the other shortcuts do;+ // where he can't leave the island, Mochi says so.+ case "desktopToggle":+ if (!host.canLeaveIsland()) {+ host.emote("annoyed");+ Sound.play("error");+ break;+ }+ if (!State.mochiOnDesktop) resume();+ host.flyOutOrHome();+ break;+// wardrobeToggle never comes this way (Rust sends `open-wardrobe`), and- // attachFrontWindow / desktopToggle aren't in this version.+ // attachFrontWindow isn't in this version.default:break;}@@ -127,6 +149,19 @@ export function runIslandKey(host: ShortcutHost, action: IslandKeyAction) {case "pill":focusPill(host, pillByNumber(ids, action.number), false);break;+ case "list":+ // Only a card with a list counts its items: the GitHub lists, as on the Mac.+ if (State.view !== "overview" || State.cardItemCount <= 0) return;+ State.cardSelection = navigate(State.cardSelection, action.delta, State.cardItemCount);+ State.notify();+ break;+ case "openSelection":+ if (State.cardSelection == null) return;+ host.viewCommand("openSelection");+ break;+ case "diff":+ host.viewCommand("toggleDiff");+ break;case "newChat":// Not while an answer is on its way: it would land in the new chat.if (State.stateOverride === "thinking") return;diff --git a/windows/src/mochi/desktop-logic.ts b/windows/src/mochi/desktop-logic.tsindex 0bd6c91a..c6cd6e3f 100644--- a/windows/src/mochi/desktop-logic.ts+++ b/windows/src/mochi/desktop-logic.ts@@ -179,8 +179,12 @@ export type DesktopPhase =/** Everything the life cycle does to the world, injected so it can be tested. */export interface DesktopPorts {- /** Shows the window at the island and flies it to his spot. False: no spot. */- flyOut(): Promise<boolean>;+ /**+ * Shows the window at the island and flies it to his spot. False: no spot.+ * `anywhere`: a spot on a display that is gone gives way to the first-visit+ * corner instead of keeping him home (the user asked him out).+ */+ flyOut(anywhere: boolean): Promise<boolean>;/** Flies the window to the island and hides it. `forget`: he lives there again. */flyHome(forget: boolean): Promise<boolean>;/** The island's own Mochi hides while he is out. */@@ -207,7 +211,7 @@ export class DesktopMochiController {}/** Launch, and back from an alert: fly out to his spot if he lives there. */- async launchFlyIfNeeded(): Promise<void> {+ async launchFlyIfNeeded(anywhere = false): Promise<void> {if (!this.enabled || this.phase !== "home") return;// An alert is up: wait in the island, the alert's end flies him out.if (this.port.alertActive()) {@@ -216,7 +220,7 @@ export class DesktopMochiController {}this.phase = "flyingOut";this.port.setAway(true);- const ok = await this.port.flyOut();+ const ok = await this.port.flyOut(anywhere);if (this.phase !== "flyingOut") return;if (!ok) {// His spot is on a display that is gone: he stays home.@@ -251,6 +255,20 @@ export class DesktopMochiController {this.port.setAway(false);}+ /**+ * The desktop shortcut (DesktopMochiController.flyOutOrHome, ⌃⌥D on the+ * Mac): out to his spot from the island, home from the desktop. In flight,+ * or away for an alert, nothing.+ */+ async flyOutOrHome(): Promise<void> {+ if (this.phase === "home") {+ this.enabled = true;+ await this.launchFlyIfNeeded(true);+ } else if (this.phase === "onDesktop") {+ await this.flyHome();+ }+ }+/** Call whenever the alert condition may have changed; only edges count. */private alertWas = false;updateAlert(active: boolean) {diff --git a/windows/src/style.css b/windows/src/style.cssindex da456b00..ddc25624 100644--- a/windows/src/style.css+++ b/windows/src/style.css@@ -2101,6 +2101,11 @@ input[type="range"]::-webkit-slider-thumb {background: rgba(255, 255, 255, 0.05);}+/* Ctrl+↓ / Ctrl+↑: the highlighted row (GitHubPRRowView's `selected`, white 12 %). */+.gh-row.selected {+ background: rgba(255, 255, 255, 0.12);+}+.gh-gap {width: 5px;flex: 0 0 5px;diff --git a/windows/src/views/github.ts b/windows/src/views/github.tsindex 1aa71c77..86fba2f2 100644--- a/windows/src/views/github.ts+++ b/windows/src/views/github.ts@@ -108,10 +108,18 @@ function ciDot(ci: GitHubPR["ci"]): HTMLElement {return el;}+/** What each list row opens: its click, and Ctrl+O when it is highlighted. */+const rowOpens = new WeakMap<Element, () => void>();++function row(onOpen: () => void, ...children: (HTMLElement | null)[]): HTMLElement {+ const el = h("button", { class: "gh-row", onclick: onOpen }, ...children);+ rowOpens.set(el, onOpen);+ return el;+}+function prRow(pr: GitHubPR, showCI: boolean): HTMLElement {- return h(- "button",- { class: "gh-row", onclick: () => open(pr.url) },+ return row(+ () => open(pr.url),showCI ? ciDot(pr.ci) : h("i", { class: "gh-gap" }),h("span", { class: "gh-ref", text: `${shortRepo(pr.repo)}#${pr.number}` }),h("span", { class: "gh-title", text: pr.title }),@@ -121,9 +129,8 @@ function prRow(pr: GitHubPR, showCI: boolean): HTMLElement {function repoRow(repo: GitHubRepoCI): HTMLElement {const word = ciWord(repo.ci);- return h(- "button",- { class: "gh-row", onclick: () => open(actionsUrl(repo.url)) },+ return row(+ () => open(actionsUrl(repo.url)),ciDot(repo.ci),h("span", { class: "gh-ref", text: shortRepo(repo.repo) }),h("span", { class: "gh-title", text: repo.branch }),@@ -131,12 +138,34 @@ function repoRow(repo: GitHubRepoCI): HTMLElement {);}+// ── Keyboard: Ctrl+↓ Ctrl+↑ Ctrl+O (the Mac's cardSelection) ──────────────────++/** The rows of the GitHub list shown in `root`, top to bottom; none without one. */+export function listRows(root: HTMLElement): HTMLElement[] {+ const list = root.querySelector(".gh-list");+ return list ? (Array.from(list.children) as HTMLElement[]) : [];+}++/**+ * Highlights row `selection` and no other (GitHubPRRowView's `selected`).+ * `reveal`: the highlight just moved, so its row scrolls into the three the+ * list shows.+ */+export function highlightRow(rows: readonly HTMLElement[], selection: number | null, reveal: boolean) {+ rows.forEach((el, i) => el.classList.toggle("selected", i === selection));+ if (reveal && selection != null) rows[selection]?.scrollIntoView({ block: "nearest" });+}++/** Ctrl+O: does what a click on the row does. */+export function openRow(el: HTMLElement | undefined) {+ if (el) rowOpens.get(el)?.();+}+function listDetail(section: Exclude<GitHubSection, "activity">, pulse: GitHubPulse, onBack: () => void): HTMLElement {const rows: HTMLElement[] =section === "mainCI"? pulse.mainCI.map(repoRow): (section === "myPRs" ? pulse.myPRs : pulse.toReview).map((pr) => prRow(pr, section === "myPRs"));-const body =rows.length === 0? h("div", { class: "gh-empty", text: GH_STRINGS.nothingHere })diff --git a/windows/src/views/views.ts b/windows/src/views/views.tsindex 7570c546..da34eca7 100644--- a/windows/src/views/views.ts+++ b/windows/src/views/views.ts@@ -11,6 +11,7 @@ import { createMiniBot, pruneMiniBots } from "../mochi/minibots";import { buildPrompt } from "./chat";import { buildChoose, buildUpload, buildUploading } from "./upload";import { renderIntegrationCard, type IntegrationCardHooks } from "./integrations";+import { highlightRow, listRows, openRow } from "./github";import { pillDefinition, sessionSubtitle } from "../core/pills";import {PlanCard, buildPlanPill, claudePillVisible, codexPillVisible, planCardOpen, refreshCodexPlanUsage,@@ -22,6 +23,7 @@ import { buildRecap } from "./recap";import { buildWardrobe } from "./wardrobe";import type { Outfit, OutfitSelection } from "../mochi/wardrobe";import { language, t, tl, type Msg } from "../i18n/i18n";+import type { ViewCommand } from "../island/shortcuts";export interface ViewActions {setView(v: IslandViewName): void;@@ -58,6 +60,8 @@ export interface ViewHost {focus?(): void;/** Called every frame while the view is on screen. True = needs another frame. */tick?(nowMs: number): boolean | void;+ /** Ctrl+O / Ctrl+E while the view is on screen (island/shortcuts.ts). */+ command?(command: ViewCommand): void;}// ── Shared pieces ─────────────────────────────────────────────────────────────@@ -200,6 +204,8 @@ function buildOverview(actions: ViewActions): ViewHost {let lastFocus: string | null = null;let mode: "ticker" | "card" | "plan" | "diff" | null = null;let cardKey = "";+ /** The list row highlighted at the last sync, to scroll only when it moves. */+ let shownSelection: number | null = null;// Leaving the overview or folding the island closes the diff, as on macOS.State.subscribe(() => {@@ -256,6 +262,26 @@ function buildOverview(actions: ViewActions): ViewHost {ticker.tick(nowMs);return ticker.animating;},+ command(command) {+ if (command === "openSelection") {+ // Ctrl+O: what a click on the highlighted row does.+ if (mode !== "card" || State.cardSelection == null) return;+ openRow(listRows(leftBody)[State.cardSelection]);+ return;+ }+ // Ctrl+E (⌘E, islandToggleDiff): closes the diff that is open, else+ // opens the focused pill's latest edit.+ if (activeDiffId != null) {+ closeDiff();+ return;+ }+ const task = State.focusTask;+ const diffs = task ? State.sessionDiffs.get(task.id) : undefined;+ const last = diffs?.[diffs.length - 1];+ if (last?.id == null) return;+ activeDiffId = last.id;+ State.notify();+ },sync() {const task = State.focusTask;if (task?.id !== lastFocus) {@@ -341,6 +367,13 @@ function buildOverview(actions: ViewActions): ViewHost {jump.style.display = detailOpen || mode === "plan" || mode === "diff" ? "none" : "";+ // Ctrl+↓ Ctrl+↑ walk the open GitHub list (cardItemCount / cardSelection).+ const rows = mode === "card" ? listRows(leftBody) : [];+ State.cardItemCount = rows.length;+ if (State.cardSelection != null && State.cardSelection >= rows.length) State.cardSelection = null;+ highlightRow(rows, State.cardSelection, State.cardSelection !== shownSelection);+ shownSelection = State.cardSelection;+const others = State.otherTasks.slice(0, 4);const pillKey = others.map((t) => `${t.id}:${t.color}:${t.pillBadge ?? ""}`).join("|");if (pillKey !== pillIds) {diff --git a/windows/tests/desktop.test.mjs b/windows/tests/desktop.test.mjsindex e093d52c..7cfddcc5 100644--- a/windows/tests/desktop.test.mjs+++ b/windows/tests/desktop.test.mjs@@ -159,7 +159,10 @@ function world({ alert = false, flyOutOk = true } = {}) {await new Promise((r) => setImmediate(r));},port: {- flyOut: () => new Promise((resolve) => flights.push({ kind: "out", resolve, defaultResult: flyOutOk })),+ flyOut: (anywhere) => {+ log.push(anywhere ? "out-anywhere" : "out-spot");+ return new Promise((resolve) => flights.push({ kind: "out", resolve, defaultResult: flyOutOk }));+ },flyHome: (forget) => {log.push(forget ? "home-forget" : "home-keep");return new Promise((resolve) => flights.push({ kind: "home", resolve, defaultResult: true }));@@ -343,6 +346,50 @@ test("sent home in the instant before an alert takes him: home wins", async () =assert.deepEqual(w.flying, [], "and he doesn't come back out");});+// ── The desktop shortcut (flyOutOrHome, ⌃⌥D on the Mac) ───────────────────────++test("the desktop shortcut: out from the island, home from the desktop", async () => {+ const w = world();+ void w.c.flyOutOrHome();+ assert.equal(w.c.enabled, true, "he lives on the desktop now");+ assert.equal(w.c.phase, "flyingOut");+ assert.ok(w.log.includes("out-anywhere"), "a spot on a display that is gone gives way to the corner");+ // Pressed again mid-flight: nothing.+ void w.c.flyOutOrHome();+ assert.deepEqual(w.flying, ["out"]);+ await w.land();+ assert.equal(w.c.phase, "onDesktop");++ void w.c.flyOutOrHome();+ assert.equal(w.c.phase, "home");+ assert.equal(w.c.enabled, false);+ assert.ok(w.log.includes("home-forget"), "home for good, like a double click");+ await w.land();+ assert.equal(w.away, false);+});++test("the desktop shortcut during an alert: he waits in the island, then goes", async () => {+ const w = world({ alert: true });+ w.c.updateAlert(true);+ await w.c.flyOutOrHome();+ assert.equal(w.c.phase, "atNotchForAlert");+ assert.deepEqual(w.flying, []);+ // Away for the alert: the shortcut leaves him be.+ await w.c.flyOutOrHome();+ assert.equal(w.c.phase, "atNotchForAlert");+ w.alert = false;+ w.c.updateAlert(false);+ await w.tick(RETURN_DELAY_MS);+ assert.deepEqual(w.flying, ["out"]);+});++test("the launch keeps him home when his spot's display is gone", async () => {+ const w = world();+ w.c.enabled = true;+ void w.c.launchFlyIfNeeded();+ assert.deepEqual(w.log, ["out-spot"]);+});+test("a finished task gets a happy jump, only on the desktop", () => {const w = world();w.c.updateState("working");diff --git a/windows/tests/github.test.mjs b/windows/tests/github.test.mjsindex 71ee32c9..e7cffee4 100644--- a/windows/tests/github.test.mjs+++ b/windows/tests/github.test.mjs@@ -210,3 +210,40 @@ test("showing the GitHub card asks Rust for a refresh, once per showing", () =>State.setFocus(GITHUB);assert.deepEqual(sent("github_refresh"), [{ section: "pulse" }, { section: "pulse" }]);});++// ── The lists from the keyboard (GitHubDetailView: ⌘↓ ⌘↑ ⌘O) ──────────────────++test("Ctrl+↓ ↑ highlight a list row, Ctrl+O does what its click does", async () => {+ const { installFakeDom } = await import("./fakedom.mjs");+ installFakeDom();+ const { githubDetail, githubPulseCard, highlightRow, listRows, openRow } = await import("../src/views/github.ts");+ const pr = (n, url) => ({+ id: `me/app#${n}`, title: `PR ${n}`, url, repo: "me/app", number: n, isDraft: false,+ ci: "success", review: "none", headSha: null,+ });+ const pulse = {+ login: "me", fetchedAt: 1, toReview: [], mainCI: [],+ myPRs: [+ pr(1, "https://github.com/me/app/pull/1"),+ pr(2, "https://evil.example/2"),+ pr(3, "https://github.com/me/app/pull/3"),+ ],+ };+ // The summary card has no list to walk.+ assert.deepEqual(listRows(githubPulseCard(pulse, null, null, () => {})), []);++ const rows = listRows(githubDetail(pulse, null, null, () => {}));+ assert.equal(rows.length, 3);+ highlightRow(rows, 1, true);+ assert.deepEqual(rows.map((r) => r.classList.contains("selected")), [false, true, false]);+ highlightRow(rows, null, false);+ assert.ok(rows.every((r) => !r.classList.contains("selected")));++ calls.length = 0;+ openRow(rows[0]);+ assert.deepEqual(sent("open_url"), [{ url: "https://github.com/me/app/pull/1" }]);+ // The same check as a click: only github.com opens.+ openRow(rows[1]);+ openRow(undefined);+ assert.equal(sent("open_url").length, 1);+});diff --git a/windows/tests/shortcuts.test.mjs b/windows/tests/shortcuts.test.mjsindex e76e5348..c929e4a6 100644--- a/windows/tests/shortcuts.test.mjs+++ b/windows/tests/shortcuts.test.mjs@@ -65,14 +65,17 @@ test("the defaults are the same on both sides of the bridge", () => {});// testEnabledByDefault-test("only the island toggle is off by default; the two not ported yet are reserved", () => {+test("only the island toggle is off by default; the one not ported yet is reserved", () => {for (const d of SHORTCUTS) {assert.equal(d.enabledByDefault, d.id !== "toggleIsland", d.id);- assert.equal(d.ported, !["attachFrontWindow", "desktopToggle"].includes(d.id), d.id);+ assert.equal(d.ported, d.id !== "attachFrontWindow", d.id);}assert.deepEqual(activeKeys({}).map(([id]) => id), [- "openChat", "goToAlert", "jumpToTerminal", "nextPill", "prevPill", "muteToggle", "wardrobeToggle",+ "openChat", "goToAlert", "jumpToTerminal", "nextPill", "prevPill", "muteToggle", "desktopToggle",+ "wardrobeToggle",]);+ // The Mac's ⌃⌥D, on the same letter.+ assert.equal(SHORTCUTS.find((d) => d.id === "desktopToggle").defaultKeys, "Ctrl+Alt+D");});// ── Parsing and formatting (testCarbonModifiers, testDisplayString, testKeyCodeToString) ──@@ -237,6 +240,29 @@ test("Ctrl stands in for ⌘ inside the island", () => {assert.ok(ISLAND_SHORTCUTS.length >= 6);});+test("Ctrl+↓ ↑ walk a card's list, Ctrl+O opens, Ctrl+E is the overview's diff", () => {+ const ctx = { view: "overview", inTextField: false };+ const ctrl = (key, code = "") => press({ key, code, ctrlKey: true });+ assert.deepEqual(islandKeyAction(ctrl("ArrowDown", "ArrowDown"), ctx), { kind: "list", delta: 1 });+ assert.deepEqual(islandKeyAction(ctrl("ArrowUp", "ArrowUp"), ctx), { kind: "list", delta: -1 });+ assert.deepEqual(islandKeyAction(ctrl("o", "KeyO"), ctx), { kind: "openSelection" });+ assert.deepEqual(islandKeyAction(ctrl("e", "KeyE"), ctx), { kind: "diff" });+ // The key labelled E on any layout, and Ctrl+Shift+E is something else.+ assert.deepEqual(islandKeyAction(ctrl("E", "KeyE"), ctx), { kind: "diff" });+ assert.equal(islandKeyAction(press({ key: "E", code: "KeyE", ctrlKey: true, shiftKey: true }), ctx), null);+ // ⌘E only means something in the overview, where the diff opens.+ assert.equal(islandKeyAction(ctrl("e", "KeyE"), { view: "prompt", inTextField: true }), null);+ // In the chat field Ctrl+↑ ↓ keep moving by paragraph.+ assert.equal(islandKeyAction(ctrl("ArrowDown", "ArrowDown"), { view: "prompt", inTextField: true }), null);+ // Settings lists them in the Mac's order (ShortcutLogic.islandShortcuts).+ assert.deepEqual(ISLAND_SHORTCUTS.map((s) => s.keys).slice(0, 5), [+ "Ctrl+→ / Ctrl+←", "Ctrl+1 – Ctrl+9", "Ctrl+↓ / Ctrl+↑", "Ctrl+O", "Ctrl+E",+ ]);+ assert.equal(SHORTCUT_TEXT.island.navItems, "Navigate list items");+ assert.equal(SHORTCUT_TEXT.island.open, "Open selected item");+ assert.equal(SHORTCUT_TEXT.island.diff, "Open / close current diff");+});+// ── What the island does ──────────────────────────────────────────────────────let did;@@ -248,7 +274,11 @@ const host = {setPinned: (on) => did.push(`pin:${on}`),takeKeyboard: () => did.push("keyboard"),wardrobeAnywhere: () => did.push("wardrobe"),+ canLeaveIsland: () => desktopSupported,+ flyOutOrHome: () => did.push("desktop"),+ viewCommand: (c) => did.push(`view:${c}`),};+let desktopSupported = true;const resume = () => did.push("resume");// The island listens on `window`, which here is the bare global object.const listeners = [];@@ -267,6 +297,10 @@ beforeEach(() => {State.stateOverride = null;State.chatHistory = [];State.settings = { ...DEFAULT_SETTINGS };+ State.mochiOnDesktop = false;+ State.cardSelection = null;+ State.cardItemCount = 0;+ desktopSupported = true;State.loadIntegrationTasks();});@@ -403,8 +437,32 @@ test("mute flips the sound, saves it, and Mochi reacts", () => {assert.deepEqual(did, ["emote:annoyed", "emote:happy"]);});+test("the desktop shortcut sends Mochi out, lifting Pause, and brings him home", () => {+ runGlobalShortcut(host, "desktopToggle", resume);+ assert.deepEqual(did, ["resume", "desktop"]);+ // Out there already: home, and Pause stays as it is.+ did = [];+ State.mochiOnDesktop = true;+ runGlobalShortcut(host, "desktopToggle", resume);+ assert.deepEqual(did, ["desktop"]);+ assert.deepEqual(calls, []);+});++test("where Mochi can't leave the island (GNOME on Wayland), he says so", () => {+ desktopSupported = false;+ runGlobalShortcut(host, "desktopToggle", resume);+ assert.deepEqual(did, ["emote:annoyed"]);+});++test("the desktop shortcut arrives like the others, and runs from the command line", () => {+ emit("shortcut", "desktopToggle");+ assert.deepEqual(did, ["resume", "desktop"]);+ const rust = readFileSync(new URL("../src-tauri/src/shortcuts.rs", import.meta.url), "utf8");+ assert.match(rust, /from_args\(&args\(&\["coucou", "--shortcut", "desktopToggle"\]\)\), Some\("desktopToggle"\)/);+});+test("actions that aren't the island's do nothing here", () => {- for (const id of ["wardrobeToggle", "attachFrontWindow", "desktopToggle", "nonsense"]) {+ for (const id of ["wardrobeToggle", "attachFrontWindow", "nonsense"]) {runGlobalShortcut(host, id, resume);}assert.deepEqual(did, []);@@ -437,3 +495,41 @@ test("island keys: pills by number, new chat, settings, pin", () => {runIslandKey(host, { kind: "pin" });assert.deepEqual(did, ["setView:overview", "setView:overview", "setView:prompt", "pin:true"]);});++test("island keys: the highlight walks the list on screen, Ctrl+O opens it, Ctrl+E the diff", () => {+ // No list on screen: nothing to walk, nothing to open.+ runIslandKey(host, { kind: "list", delta: 1 });+ assert.equal(State.cardSelection, null);+ runIslandKey(host, { kind: "openSelection" });+ assert.deepEqual(did, []);++ // A GitHub list of three: from the top, clamped at the bottom (ShortcutLogic.navigate).+ State.cardItemCount = 3;+ runIslandKey(host, { kind: "list", delta: 1 });+ assert.equal(State.cardSelection, 0);+ for (let i = 0; i < 4; i++) runIslandKey(host, { kind: "list", delta: 1 });+ assert.equal(State.cardSelection, 2);+ runIslandKey(host, { kind: "list", delta: -1 });+ assert.equal(State.cardSelection, 1);+ runIslandKey(host, { kind: "openSelection" });+ assert.deepEqual(did, ["view:openSelection"]);++ // Starting from nothing, ↑ picks the last row.+ State.cardSelection = null;+ runIslandKey(host, { kind: "list", delta: -1 });+ assert.equal(State.cardSelection, 2);++ // Another view is on screen: the overview's list isn't walked.+ State.view = "prompt";+ runIslandKey(host, { kind: "list", delta: -1 });+ assert.equal(State.cardSelection, 2);+ State.view = "overview";++ // Another pill drops the highlight, as cyclePill / switchToPill do.+ runIslandKey(host, { kind: "pill", number: 1 });+ assert.equal(State.cardSelection, null);++ did = [];+ runIslandKey(host, { kind: "diff" });+ assert.deepEqual(did, ["view:toggleDiff"]);+});