Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

Windows: the island follows the auto-close delay live (Mac #25)

Claude62e43c6d8b0c
diff --git a/windows/src/island/fsm.ts b/windows/src/island/fsm.ts
index 8a24545e..8cd46d11 100644
--- a/windows/src/island/fsm.ts
+++ b/windows/src/island/fsm.ts
@@ -8,8 +8,19 @@ export class IslandStateMachine {
onTransition: ((from: FsmState, to: FsmState) => void) | null = null;
- /** home → petit delay, seconds. */
- homeToPetitDelay = 15;
+ /**
+ * home → petit delay, seconds: the auto-close preference. Changing it while a
+ * countdown runs starts that countdown again with the new delay, so an edit in
+ * Settings applies at once (IslandStateMachine.homeToPetitDelay on macOS).
+ */
+ get homeToPetitDelay(): number {
+ return this.homeDelay;
+ }
+ set homeToPetitDelay(seconds: number) {
+ if (!Number.isFinite(seconds) || seconds < 0 || seconds === this.homeDelay) return;
+ this.homeDelay = seconds;
+ if (this.state === "home" && this.homeCollapse != null) this.scheduleHomeCollapse();
+ }
/** petit → hidden delay, seconds. */
petitToHiddenDelay = 60;
/** coucou → petit once the greeting animation ends (no hover). */
@@ -19,6 +30,14 @@ export class IslandStateMachine {
/** An alert waiting for an answer stays open, even when the mouse leaves. */
pinned = false;
+ /**
+ * When the open island will fold, on the performance.now() clock, while the
+ * mouse-leave countdown runs; null otherwise. The island draws its countdown
+ * bar from it.
+ */
+ homeCollapseDueAt: number | null = null;
+
+ private homeDelay = 15;
private petitHide: number | null = null;
private homeCollapse: number | null = null;
private greetCollapse: number | null = null;
@@ -115,10 +134,14 @@ export class IslandStateMachine {
private scheduleHomeCollapse() {
this.clear("homeCollapse");
if (this.pinned) return;
+ const ms = this.homeDelay * 1000;
+ this.homeCollapseDueAt = performance.now() + ms;
this.homeCollapse = window.setTimeout(() => {
this.homeCollapse = null;
- if (this.state === "home") this.transition("petit");
- }, this.homeToPetitDelay * 1000);
+ this.homeCollapseDueAt = null;
+ // An alert pinned while the countdown ran keeps the island open.
+ if (this.state === "home" && !this.pinned) this.transition("petit");
+ }, ms);
}
private scheduleGreetCollapse(delay: number) {
@@ -133,6 +156,7 @@ export class IslandStateMachine {
const id = this[which];
if (id != null) window.clearTimeout(id);
this[which] = null;
+ if (which === "homeCollapse") this.homeCollapseDueAt = null;
}
cancelTimers() {
diff --git a/windows/src/island/island.ts b/windows/src/island/island.ts
index 54dbf5f0..07bd4183 100644
--- a/windows/src/island/island.ts
+++ b/windows/src/island/island.ts
@@ -73,7 +73,6 @@ export class Island {
private wasInIsland = false;
/** Last shape handed to Rust for the click-through test. */
private pushedRect = { x: -1, y: -1, w: -1, h: -1 };
- private homeCollapseAt: number | null = null;
// Bot hover → love (IslandWindowController.botHoverIn)
private botHovering = false;
@@ -315,7 +314,6 @@ export class Island {
if (State.mode !== "expanded") this.setMode("expanded");
else this.animateGeometry(false);
State.lastActivity = performance.now();
- this.homeCollapseAt = null;
State.notify();
}
@@ -638,13 +636,9 @@ export class Island {
if (inIsland && !this.wasInIsland) {
if (this.fsm.state === "coucou") this.greeting.hover();
this.fsm.mouseEntered();
- this.homeCollapseAt = null;
}
if (!inIsland && this.wasInIsland) {
this.fsm.mouseLeft();
- if (this.fsm.state === "home" && !State.isPinned) {
- this.homeCollapseAt = performance.now() + State.settings.autoCloseInterval * 1000;
- }
}
this.wasInIsland = inIsland;
@@ -870,13 +864,16 @@ export class Island {
}
private updateCountdown(nowMs: number) {
- if (State.mode !== "expanded" || State.isPinned || this.homeCollapseAt == null) {
+ // The state machine's own deadline, so the bar follows an auto-close delay
+ // edited while the countdown runs.
+ const dueAt = this.fsm.homeCollapseDueAt;
+ if (State.mode !== "expanded" || State.isPinned || dueAt == null) {
this.countdown.style.width = "0px";
return;
}
- const autoClose = State.settings.autoCloseInterval;
+ const autoClose = this.fsm.homeToPetitDelay;
const windowS = Math.min(10, autoClose * 0.6);
- const remaining = (this.homeCollapseAt - nowMs) / 1000;
+ const remaining = (dueAt - nowMs) / 1000;
this.countdown.style.width =
remaining < windowS ? `${Math.max(0, clamp(remaining / windowS, 0, 1) * 160)}px` : "0px";
}
diff --git a/windows/tests/fsm.test.mjs b/windows/tests/fsm.test.mjs
index efb50267..06156a9d 100644
--- a/windows/tests/fsm.test.mjs
+++ b/windows/tests/fsm.test.mjs
@@ -162,3 +162,123 @@ test("a transition to the current state is not reported", () => {
fsm.forceHome();
assert.deepEqual(transitions, ["hidden>home"]);
});
+
+// ── Auto-close delay from Settings (IslandAutoCloseTests.swift) ──────────────
+
+/** Opened by a click, the way the Mac tests open theirs. */
+function opened(delay) {
+ fsm.homeToPetitDelay = delay;
+ fsm.mouseEntered();
+ fsm.click();
+ assert.equal(fsm.state, "home");
+}
+
+test("a configured 2-second delay replaces the default 15 seconds", () => {
+ opened(2);
+ fsm.mouseLeft();
+ seconds(1.9);
+ assert.equal(fsm.state, "home");
+ seconds(0.1);
+ assert.equal(fsm.state, "petit");
+});
+
+test("editing the delay during a countdown replaces its timer", () => {
+ opened(15);
+ fsm.mouseLeft();
+ fsm.homeToPetitDelay = 0.05;
+ seconds(0.05);
+ assert.equal(fsm.state, "petit");
+});
+
+test("a longer delay also cancels the shorter timer that was running", () => {
+ opened(0.05);
+ fsm.mouseLeft();
+ fsm.homeToPetitDelay = 0.25;
+ seconds(0.1);
+ assert.equal(fsm.state, "home");
+ seconds(0.15);
+ assert.equal(fsm.state, "petit");
+});
+
+test("coming back cancels the countdown, and leaving again starts it with the delay", () => {
+ opened(0.05);
+ fsm.mouseLeft();
+ fsm.mouseEntered();
+ seconds(0.1);
+ assert.equal(fsm.state, "home");
+ fsm.mouseLeft();
+ seconds(0.05);
+ assert.equal(fsm.state, "petit");
+});
+
+test("a delay edit while the island is hovered starts no countdown", () => {
+ opened(15);
+ fsm.homeToPetitDelay = 0.05;
+ seconds(600);
+ assert.equal(fsm.state, "home");
+ fsm.mouseLeft();
+ seconds(0.05);
+ assert.equal(fsm.state, "petit");
+});
+
+test("the greeting keeps its own timing whatever the auto-close delay", () => {
+ fsm.greetAutoCollapseDelay = 0.15;
+ fsm.launch();
+ fsm.greetComplete();
+ fsm.homeToPetitDelay = 0.01;
+ seconds(0.05);
+ assert.equal(fsm.state, "coucou");
+ seconds(0.1);
+ assert.equal(fsm.state, "petit");
+});
+
+test("an alert waiting for an answer stays open through a delay edit", () => {
+ opened(0.05);
+ fsm.pinned = true;
+ fsm.mouseLeft();
+ fsm.homeToPetitDelay = 0.01;
+ seconds(600);
+ assert.equal(fsm.state, "home");
+ fsm.pinned = false;
+ fsm.mouseLeft();
+ seconds(0.01);
+ assert.equal(fsm.state, "petit");
+});
+
+test("an alert pinned during a countdown blocks the old timer and its replacement", () => {
+ opened(0.2);
+ fsm.mouseLeft();
+ fsm.pinned = true;
+ fsm.homeToPetitDelay = 0.01;
+ seconds(600);
+ assert.equal(fsm.state, "home");
+ fsm.pinned = false;
+ fsm.mouseLeft();
+ seconds(0.01);
+ assert.equal(fsm.state, "petit");
+});
+
+test("a pin that arrives after the timer was armed still holds the island", () => {
+ opened(1);
+ fsm.mouseLeft();
+ fsm.pinned = true;
+ seconds(600);
+ assert.equal(fsm.state, "home");
+});
+
+test("the deadline the countdown bar reads follows the delay and clears with the timer", () => {
+ opened(15);
+ assert.equal(fsm.homeCollapseDueAt, null);
+ fsm.mouseLeft();
+ const first = fsm.homeCollapseDueAt;
+ assert.ok(first != null);
+ fsm.homeToPetitDelay = 5;
+ assert.ok(fsm.homeCollapseDueAt < first);
+ fsm.mouseEntered();
+ assert.equal(fsm.homeCollapseDueAt, null);
+});
+
+test("an unusable delay is ignored", () => {
+ for (const bad of [NaN, -1, Infinity]) fsm.homeToPetitDelay = bad;
+ assert.equal(fsm.homeToPetitDelay, 15);
+});