Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
feat(desktop): redesign the notch island and add usage
leepokaib6094e643d34
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.tsindex 9dd4a25a..f5f7fe32 100644--- a/apps/desktop/src/main/index.ts+++ b/apps/desktop/src/main/index.ts@@ -211,7 +211,7 @@ if (!app.requestSingleInstanceLock()) {// would otherwise show Electron's.if (isMac && !app.isPackaged) app.dock?.setIcon(join(__dirname, '../../resources/icon.png'))applyDockVisibility()- const island = new Island({ url: rendererURL('island'), preload: join(__dirname, '../preload/index.js'), send, changed: () => tray.hostChanged() })+ const island = new Island({ url: rendererURL('island'), preload: join(__dirname, '../preload/index.js'), send, openApp: openChat, changed: () => tray.hostChanged() })const tray = new Tray({ openChat, openPairing, send, host, updates, island })updates.on('change', () => tray.hostChanged())registerIPC(tray)diff --git a/apps/desktop/src/main/island.ts b/apps/desktop/src/main/island.tsindex 8546f05c..50667bcf 100644--- a/apps/desktop/src/main/island.ts+++ b/apps/desktop/src/main/island.ts@@ -1,5 +1,5 @@import { execFile } from 'node:child_process'-import { BrowserWindow, ipcMain, screen } from 'electron'+import { BrowserWindow, globalShortcut, ipcMain, screen } from 'electron'import type { WindowCommand } from '../shared/ipc'import { hitRect, hits, notchOf, PANEL, type IslandRect, type IslandScreen, type IslandSummary, type NotchScreen } from '../shared/island'import { prefs } from './host-controller'@@ -40,10 +40,14 @@ function readScreens(): Promise<NotchScreen[]> {})}+/** Answers the approval on screen from any app while it shows. */+const KEYS = { 'Alt+Y': 'allow', 'Alt+N': 'deny' } as const+interface Deps {url: stringpreload: stringsend: (command: WindowCommand, show?: boolean) => void+ openApp: () => void/** The setting changed (the tray's Settings menu shows it). */changed: () => void}@@ -55,7 +59,7 @@ interface Deps {*/export class Island {private window: BrowserWindow | null = null- private summary: IslandSummary = { bots: [], permissions: [] }+ private summary: IslandSummary = { bots: [], permissions: [], usage: [] }private screen: IslandScreen = { notch: null }private rect: IslandRect = { x: 0, y: 0, width: 0, height: 0 }private inside = false@@ -64,8 +68,9 @@ export class Island {constructor(private deps: Deps) {}+ /** Off until turned on: the island is still experimental. */get enabled() {- return islandSupported && prefs.get('showIsland') !== false+ return islandSupported && prefs.get('showIsland') === true}setEnabled(on: boolean) {@@ -92,6 +97,11 @@ export class Island {this.deps.send({ kind: 'respondPermission', ref, entryId, optionId }, false),)ipcMain.on('island:openBot', (_e, ref: string) => this.deps.send({ kind: 'openBot', ref }))+ ipcMain.on('island:send', (_e, ref: string, text: string) => this.deps.send({ kind: 'sendMessage', ref, text }, false))+ ipcMain.on('island:newBot', () => this.deps.send({ kind: 'newChat' }))+ ipcMain.on('island:openApp', () => this.deps.openApp())+ ipcMain.on('island:focusable', (_e, on: boolean) => this.setFocusable(on))+ ipcMain.on('island:keys', (_e, on: boolean) => this.setKeys(on))screen.on('display-added', () => void this.place())screen.on('display-removed', () => void this.place())screen.on('display-metrics-changed', () => void this.place())@@ -147,12 +157,35 @@ export class Island {}private close() {+ this.setKeys(false)if (this.timer) clearTimeout(this.timer)this.timer = nullthis.window?.destroy()this.window = null}+ /** Only the message field takes the keyboard; a panel takes it without bringing the app forward. */+ private setFocusable(on: boolean) {+ const win = this.window+ if (!win) return+ win.setFocusable(on)+ if (on) win.focus()+ else win.blur()+ }++ private setKeys(on: boolean) {+ for (const [accelerator, answer] of Object.entries(KEYS)) {+ if (!on) {+ globalShortcut.unregister(accelerator)+ continue+ }+ if (globalShortcut.isRegistered(accelerator)) continue+ if (!globalShortcut.register(accelerator, () => this.window?.webContents.send('island:key', answer))) {+ console.error(`island: ${accelerator} is taken by another app`)+ }+ }+ }+/** Top center of the display with the notch, else the main display. */private async place() {if (!this.window) returndiff --git a/apps/desktop/src/preload/index.ts b/apps/desktop/src/preload/index.tsindex 4c4be809..ab7d2fe8 100644--- a/apps/desktop/src/preload/index.ts+++ b/apps/desktop/src/preload/index.ts@@ -73,8 +73,14 @@ const bridge: CodyncBridge = {onScreen: (cb) => listen('island:screen', cb),onHover: (cb) => listen('island:hover', cb),setShape: (rect) => ipcRenderer.send('island:shape', rect),+ setFocusable: (on) => ipcRenderer.send('island:focusable', on),+ setKeys: (on) => ipcRenderer.send('island:keys', on),+ onKey: (cb) => listen('island:key', cb),respond: (ref, entryId, optionId) => ipcRenderer.send('island:respond', ref, entryId, optionId),+ send: (ref, text) => ipcRenderer.send('island:send', ref, text),openBot: (ref) => ipcRenderer.send('island:openBot', ref),+ newBot: () => ipcRenderer.send('island:newBot'),+ openApp: () => ipcRenderer.send('island:openApp'),},cloud: {request: (method, path, body, signed) => ipcRenderer.invoke('cloud:request', method, path, body, signed),diff --git a/apps/desktop/src/renderer/components/icon-fallbacks.ts b/apps/desktop/src/renderer/components/icon-fallbacks.tsindex 089e5df8..4f18e4a1 100644--- a/apps/desktop/src/renderer/components/icon-fallbacks.ts+++ b/apps/desktop/src/renderer/components/icon-fallbacks.ts@@ -40,6 +40,7 @@ const map: Record<string, IconNode> = {'book.closed': L.Book,'book.pages': L.BookOpenText,'bubble.left': L.MessageSquare,+ 'bubble.left.fill': L.MessageSquare,'bubble.left.and.bubble.right': L.MessagesSquare,calendar: L.Calendar,'chart.bar': L.ChartColumn,@@ -90,6 +91,7 @@ const map: Record<string, IconNode> = {'gauge.with.dots.needle.33percent': L.Gauge,gearshape: L.Settings,globe: L.Globe,+ 'house.fill': L.House,hammer: L.Hammer,'hand.point.up.left': L.Pointer,'hand.raised': L.Hand,diff --git a/apps/desktop/src/renderer/components/symbols.json b/apps/desktop/src/renderer/components/symbols.jsonindex 09027879..72ffa83a 100644--- a/apps/desktop/src/renderer/components/symbols.json+++ b/apps/desktop/src/renderer/components/symbols.json@@ -153,5 +153,7 @@"wrench.and.screwdriver","xmark","xmark.circle",-"xmark.circle.fill"-]\ No newline at end of file+"xmark.circle.fill",+"house.fill",+"bubble.left.fill"+]diff --git a/apps/desktop/src/renderer/demo/bridge.ts b/apps/desktop/src/renderer/demo/bridge.tsindex 7dc9b0a5..2d3682b2 100644--- a/apps/desktop/src/renderer/demo/bridge.ts+++ b/apps/desktop/src/renderer/demo/bridge.ts@@ -72,13 +72,19 @@ const bridge: CodyncBridge = {enabled: async () => false,setEnabled: async () => false,setSummary() {},- state: async () => ({ screen: { notch: null }, summary: { bots: [], permissions: [] } }),+ state: async () => ({ screen: { notch: null }, summary: { bots: [], permissions: [], usage: [] } }),onSummary: none,onScreen: none,onHover: none,setShape() {},+ setFocusable() {},+ setKeys() {},+ onKey: none,respond() {},+ send() {},openBot() {},+ newBot() {},+ openApp() {},},cloud: { request: async () => ({ ok: false, error: { status: 503, code: 'demo', message: DEMO_UNAVAILABLE } }) },updates: { state: async () => updates, onChange: none, check() {}, setAutoCheck() {}, setAutoDownload() {} },diff --git a/apps/desktop/src/renderer/views/ChatWindow.tsx b/apps/desktop/src/renderer/views/ChatWindow.tsxindex b9a3a79e..84e99552 100644--- a/apps/desktop/src/renderer/views/ChatWindow.tsx+++ b/apps/desktop/src/renderer/views/ChatWindow.tsx@@ -87,6 +87,11 @@ export function ChatWindow() {if (store && entry) store.respond(entry, c.optionId)return}+ case 'sendMessage': {+ const ref = parseRef(c.ref)+ if (ref) app.store(ref.computerId)?.send(c.text, ref.botId)+ return+ }}}),[app],diff --git a/apps/desktop/src/renderer/views/island-summary.ts b/apps/desktop/src/renderer/views/island-summary.tsindex 57a8757d..70355448 100644--- a/apps/desktop/src/renderer/views/island-summary.ts+++ b/apps/desktop/src/renderer/views/island-summary.ts@@ -1,11 +1,15 @@import { useEffect } from 'react'-import type { IslandPermission, IslandSummary } from '@shared/island'-import { isGroup } from '@shared/models'+import type { IslandBot, IslandPermission, IslandSummary } from '@shared/island'+import { folderName, isGroup, isWorking, type Bot, type Entry } from '@shared/models'import { useModels } from '../lib/observable'import { refKey, type AppModel, type RosterItem } from '../store/app-model'+import type { BotStore } from '../store/bot-store'import { botDetail } from './tray-summary'import { optionLabel, permissionHeadline, sortedOptions } from './thread/PermissionCard'+/** Tool calls in the island's ticker. */+const STEPS = 3+let sent = ''let pending: ReturnType<typeof setTimeout> | null = null@@ -33,18 +37,33 @@ function islandSummary(app: AppModel): IslandSummary {return {bots: app.roster.filter((i) => !isGroup(i.bot))- .map((i) => ({- ref: refKey(i.ref),- name: many ? `${i.bot.name} · ${i.computer.name}` : i.bot.name,- shape: i.bot.avatarShape,- color: i.bot.avatarColor,- status: i.bot.status,- detail: botDetail(i.bot),- })),+ .map((i) => islandBot(i.store, i.bot, refKey(i.ref), many ? `${i.bot.name} · ${i.computer.name}` : i.bot.name)),permissions: app.roster.flatMap(pendingCards),+ usage: app.local?.usage.providers ?? [],+ }+}++function islandBot(store: BotStore, bot: Bot, ref: string, name: string): IslandBot {+ const entries = store.allEntries(bot.id)+ return {+ ref,+ name,+ shape: bot.avatarShape,+ color: bot.avatarColor,+ status: bot.status,+ backend: store.backendName(bot.backend),+ folder: folderName(bot),+ detail: botDetail(bot),+ steps: isWorking(bot)+ ? entries.filter((e) => e.kind === 'tool').slice(-STEPS).map((e) => ({ title: e.data.title || 'Use a tool', kind: e.data.toolKind ?? 'other' }))+ : [],+ error: bot.status === 'error' ? (lastError(entries) ?? null) : null,}}+/** The text of the conversation's last error notice. */+const lastError = (entries: Entry[]) => entries.findLast((e) => e.kind === 'notice' && e.data.style === 'error')?.data.text+/** A conversation's unanswered approval cards; in a group, the member that asks. */function pendingCards({ ref, bot, store }: RosterItem): IslandPermission[] {return store@@ -55,10 +74,10 @@ function pendingCards({ ref, bot, store }: RosterItem): IslandPermission[] {return {ref: refKey(ref),entryId: e.id,- bot: { name: author.name, shape: author.avatarShape, color: author.avatarColor },+ bot: { name: author.name, shape: author.avatarShape, color: author.avatarColor, backend: store.backendName(author.backend) },headline: permissionHeadline(e.data.toolKind),title: e.data.title ?? '',- options: sortedOptions(e.data.options ?? []).map((o) => ({ id: o.optionId, label: optionLabel(o), allow: o.kind.startsWith('allow') })),+ options: sortedOptions(e.data.options ?? []).map((o) => ({ id: o.optionId, label: optionLabel(o), kind: o.kind })),answering: store.answering.get(e.id) ?? null,}})diff --git a/apps/desktop/src/renderer/views/island/IslandUsage.tsx b/apps/desktop/src/renderer/views/island/IslandUsage.tsxnew file mode 100644index 00000000..b86b6316--- /dev/null+++ b/apps/desktop/src/renderer/views/island/IslandUsage.tsx@@ -0,0 +1,83 @@+import type { UsageProvider, UsageWindow } from '@shared/models'+import { prefs, usePref } from '../../lib/prefs'+import { UsageBar } from '../settings/UsageLimits'+import { mascotDataURL } from '../usage/ProviderMascot'+import { providerTintCSS, resetDescription, tightest, windowTitle } from '../usage/usage-model'+import type { IslandModel } from './island-model'++// Codync's own part of the island: the plan limits the menu bar already tracks (local usage+// only), as a meter in the header and a Usage tab.++/** A provider's character for the black island, whatever the system appearance. */+function Mascot({ provider, size }: { provider: UsageProvider; size: number }) {+ const [style] = usePref(prefs.usageIconStyle)+ const src = mascotDataURL(provider, size, style, true)+ return src ? <img src={src} alt="" width={size} height={size} style={{ flex: 'none' }} /> : null+}++/** The limit closest to running out, across providers. */+function tightestOverall(usage: UsageProvider[]): { provider: UsageProvider; window: UsageWindow } | null {+ let best: { provider: UsageProvider; window: UsageWindow } | null = null+ for (const provider of usage) {+ const window = tightest(provider)+ if (window && (!best || window.percent > best.window.percent)) best = { provider, window }+ }+ return best+}++/** Header: the tightest limit as its provider's character, a short bar and the percent; opens Usage. */+export function UsageMeter({ model }: { model: IslandModel }) {+ const top = tightestOverall(model.summary.usage)+ if (!top) return null+ const { provider, window } = top+ const reset = resetDescription(window)+ return (+ <button+ className="island-meter"+ title={`${provider.name} · ${windowTitle(window)} · ${Math.round(window.percent)}%${reset ? ` · ${reset}` : ''}`}+ aria-label={`Usage: ${provider.name} ${windowTitle(window)} ${Math.round(window.percent)} percent`}+ onClick={() => model.setTab('usage')}+ >+ <Mascot provider={provider} size={15} />+ <span className="island-meter-bar">+ <UsageBar percent={window.percent} tint={providerTintCSS(provider.id)} />+ </span>+ <span className="island-meter-value">{`${Math.round(window.percent)}%`}</span>+ </button>+ )+}++/** Every provider's limits side by side, each window a bar with when it resets. */+export function UsageView({ model }: { model: IslandModel }) {+ const usage = model.summary.usage+ if (!usage.length) {+ return (+ <div className="island-card island-empty">+ <span className="island-empty-text">+ <span className="island-title">No usage yet.</span>+ <span className="island-subtitle">Claude Code and Codex limits show up here once a bot has used them.</span>+ </span>+ </div>+ )+ }+ return (+ <div className="island-row-cards">+ {usage.slice(0, 2).map((provider) => (+ <div key={provider.id} className="island-card island-usage">+ <div className="island-agent">+ <Mascot provider={provider} size={20} />+ <span className="island-agent-name">{provider.name}</span>+ </div>+ {provider.windows.slice(0, 3).map((w) => (+ <div key={w.id} className="island-usage-row">+ <span className="island-usage-title">{windowTitle(w)}</span>+ <UsageBar percent={w.percent} tint={providerTintCSS(provider.id)} />+ <span className="island-usage-value">{`${Math.round(w.percent)}%`}</span>+ <span className="island-usage-reset">{resetDescription(w)?.replace('resets ', '') ?? ''}</span>+ </div>+ ))}+ </div>+ ))}+ </div>+ )+}diff --git a/apps/desktop/src/renderer/views/island/IslandViews.tsx b/apps/desktop/src/renderer/views/island/IslandViews.tsxnew file mode 100644index 00000000..5bbec521--- /dev/null+++ b/apps/desktop/src/renderer/views/island/IslandViews.tsx@@ -0,0 +1,210 @@+import { useState } from 'react'+import type { IslandBot, IslandPermission } from '@shared/island'+import { CharacterAvatar } from '../../components/Avatar'+import { Button, Spinner } from '../../components/Controls'+import { Icon } from '../../components/Icon'+import { ThinkingOrb } from '../../components/ThinkingOrb'+import { avatarColor, withAlpha } from '../../lib/theme'+import type { IslandModel } from './island-model'+import { AgentRow, AMBER, badgeOf, BigCharacter, GREEN, KeyHint, MiniColumn, moodOf, RED, StateBadge, StatusDot, stepIcon } from './island-parts'++const veil = (color: string, alpha: number) => `radial-gradient(120% 90% at 50% 130%, ${withAlpha(color, alpha)}, ${withAlpha(color, 0)} 70%)`++/** Closed over the notch: the bot in focus on the left wing; the others (or its state) on the right. */+export function Wings({ model, peek }: { model: IslandModel; peek: boolean }) {+ const focus = model.focus+ const others = model.others(4)+ if (!focus) return null+ return (+ <div className="island-wings">+ <span className="island-wing-left">+ <span className="island-wing-avatar">+ <CharacterAvatar shape={focus.shape} color={focus.color} size={peek ? 18 : 20} mood={moodOf(focus)} dark />+ {peek ? null : <StateBadge badge={badgeOf(focus)} small />}+ </span>+ </span>+ {peek ? null : (+ <span className="island-wing-right">+ {others.length ? (+ <span className="island-cluster">+ {others.map((b) => (+ <span key={b.ref} className="island-cluster-bot">+ <CharacterAvatar shape={b.shape} color={b.color} size={11} mood={moodOf(b)} dark />+ {b.status === 'needsInput' ? <StatusDot bot={b} /> : null}+ </span>+ ))}+ </span>+ ) : focus.status === 'needsInput' ? (+ <span className="island-dot" style={{ background: AMBER }} />+ ) : (+ <ThinkingOrb size={14} color="#F5F6F8" />+ )}+ </span>+ )}+ </div>+ )+}++/** The bot in focus with its latest steps, and the other bots as pills. */+export function Overview({ model }: { model: IslandModel }) {+ const focus = model.focus+ const others = model.others(4)+ if (!focus) return null+ const steps = focus.steps.length ? focus.steps : [{ title: focus.detail, kind: 'other' }]+ return (+ <div className="island-row-cards">+ <button className="island-card island-focus" style={others.length ? { width: 322 } : { flex: 1 }} onClick={() => model.openBot(focus.ref)} title="Open conversation">+ <BigCharacter bot={focus} size={70} mood={moodOf(focus)} badge={badgeOf(focus)} />+ <span className="island-focus-text">+ <AgentRow color={focus.color} name={focus.name} subtitle={focus.backend} />+ {steps.map((step, i) => (+ <span key={`${i}-${step.title}`} className={`island-step ${i === steps.length - 1 ? 'current' : ''}`}>+ <Icon name={stepIcon(step.kind)} size={i === steps.length - 1 ? 13 : 12} scaled={false} />+ <span className="island-ellipsis">{step.title}</span>+ </span>+ ))}+ </span>+ </button>+ {others.length ? (+ <div className="island-card island-pills">+ {others.map((b) => (+ <button+ key={b.ref}+ className="island-pill"+ style={{ background: withAlpha(avatarColor(b.color), 0.16), color: `color-mix(in srgb, ${avatarColor(b.color)} 55%, white)` }}+ onClick={() => model.openBot(b.ref)}+ title={b.detail}+ >+ <span className="island-pill-bot">+ <CharacterAvatar shape={b.shape} color={b.color} size={24} mood={moodOf(b)} dark />+ <StatusDot bot={b} />+ </span>+ <span className="island-ellipsis">{b.name}</span>+ </button>+ ))}+ </div>+ ) : null}+ </div>+ )+}++export function Empty({ model }: { model: IslandModel }) {+ const focus = model.focus+ return (+ <div className="island-card island-empty">+ {focus ? <BigCharacter bot={focus} size={62} mood="idle" badge={null} /> : null}+ <span className="island-empty-text">+ <span className="island-title">Nothing running right now.</span>+ <span className="island-subtitle">{focus ? 'Your bots are idle. Message one from here, or open Codync.' : 'Create a bot in Codync to get started.'}</span>+ </span>+ {focus ? <Button onClick={() => model.setTab('message')}>Message a bot</Button> : <Button onClick={() => model.newBot()}>New bot</Button>}+ </div>+ )+}++/** Deny on the left, the main allow on the right. */+const optionOrder = (kind: string) => ({ reject_always: 0, reject_once: 1, allow_always: 2, allow_once: 3 })[kind] ?? 1.5++export function Approval({ model, card }: { model: IslandModel; card: IslandPermission }) {+ const options = [...card.options].sort((a, b) => optionOrder(a.kind) - optionOrder(b.kind))+ return (+ <div className="island-with-minis">+ <div className="island-card island-alert" style={{ background: `${veil(AMBER, 0.42)}, var(--island-card)` }}>+ <BigCharacter bot={card.bot} size={56} mood="needsInput" badge="needsInput" onOpen={() => model.openBot(card.ref)} />+ <div className="island-alert-text">+ <AgentRow color={card.bot.color} name={card.bot.name} subtitle={`${card.bot.backend} ${card.headline.charAt(0).toLowerCase()}${card.headline.slice(1)}`} />+ {card.title ? <div className="island-code">{card.title}</div> : null}+ <div className="island-buttons">+ {options.map((o) => (+ <Button key={o.id} kind={o.kind === 'allow_once' ? 'primary' : 'secondary'} disabled={card.answering !== null} onClick={() => model.respond(card, o.id)}>+ {card.answering === o.id ? <Spinner size={12} /> : null}+ {o.label}+ {o.kind === 'allow_once' ? <KeyHint keys="⌥Y" /> : o.kind === 'reject_once' ? <KeyHint keys="⌥N" /> : null}+ </Button>+ ))}+ </div>+ </div>+ </div>+ <MiniColumn bots={model.others(3).filter((b) => b.ref !== card.ref)} onOpen={(ref) => model.openBot(ref)} />+ </div>+ )+}++/** A bot that just finished (for a moment) or failed (until dismissed). */+export function Notice({ model, bot, failed }: { model: IslandModel; bot: IslandBot; failed: boolean }) {+ return (+ <div className="island-with-minis">+ <div className="island-card island-alert" style={{ background: `${veil(failed ? RED : GREEN, failed ? 0.5 : 0.42)}, var(--island-card)` }}>+ <BigCharacter bot={bot} size={58} mood="idle" badge={failed ? 'failed' : 'finished'} onOpen={() => model.openBot(bot.ref)} />+ <div className="island-alert-text">+ <AgentRow color={bot.color} name={bot.name} subtitle={failed ? bot.backend : `${bot.backend} is done`} />+ {failed ? (+ <>+ <div className="island-title">{`${bot.name} stopped.`}</div>+ <div className="island-error">{bot.error ?? bot.detail}</div>+ </>+ ) : (+ <div className="island-title island-ellipsis">{bot.detail}</div>+ )}+ <div className="island-buttons start">+ <Button onClick={() => model.openBot(bot.ref)}>Open conversation</Button>+ <Button kind="secondary" onClick={() => model.dismissNotice()}>OK</Button>+ </div>+ </div>+ </div>+ <MiniColumn bots={model.others(3).filter((b) => b.ref !== bot.ref)} onOpen={(ref) => model.openBot(ref)} />+ </div>+ )+}++/** Writes to a bot without opening Codync: the chip picks the bot, Enter sends, Esc closes. */+export function Message({ model }: { model: IslandModel }) {+ const [text, setText] = useState('')+ const bot = model.messageBot+ if (!bot) return null+ return (+ <div className="island-with-minis">+ <div className="island-card island-message">+ <CharacterAvatar shape={bot.shape} color={bot.color} size={44} mood={moodOf(bot)} dark />+ <div className="island-message-body">+ <div className="island-agent">+ <button+ className="island-chip"+ style={{ background: withAlpha(avatarColor(bot.color), 0.16), color: `color-mix(in srgb, ${avatarColor(bot.color)} 55%, white)` }}+ onClick={() => model.nextMessageBot()}+ title="Choose a bot"+ >+ <CharacterAvatar shape={bot.shape} color={bot.color} size={18} mood={moodOf(bot)} dark />+ {bot.name}+ <Icon name="chevron.down" size={8} weight="bold" scaled={false} />+ </button>+ <span className="island-agent-subtitle">{`${bot.backend} · ${bot.folder}`}</span>+ </div>+ <form+ className="island-field"+ onSubmit={(e) => {+ e.preventDefault()+ model.send(text)+ setText('')+ }}+ >+ <input+ autoFocus+ aria-label={`Message ${bot.name}`}+ placeholder={`Message ${bot.name}…`}+ value={text}+ onChange={(e) => setText(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === 'Escape') model.close()+ }}+ />+ <button type="submit" className="island-send" aria-label="Send" title="Send" disabled={!text.trim()}>+ <Icon name="arrow.up" size={12} weight="bold" scaled={false} />+ </button>+ </form>+ </div>+ </div>+ <MiniColumn bots={model.others(3).filter((b) => b.ref !== bot.ref)} onOpen={(ref) => model.openBot(ref)} />+ </div>+ )+}diff --git a/apps/desktop/src/renderer/views/island/IslandWindow.tsx b/apps/desktop/src/renderer/views/island/IslandWindow.tsxindex c318e971..25f627bb 100644--- a/apps/desktop/src/renderer/views/island/IslandWindow.tsx+++ b/apps/desktop/src/renderer/views/island/IslandWindow.tsx@@ -1,31 +1,20 @@-import { useEffect, useRef } from 'react'-import { contentTop, type IslandBot, type IslandPermission } from '@shared/island'-import { CharacterAvatar } from '../../components/Avatar'-import { Button, IconButton, Spinner } from '../../components/Controls'-import { ThinkingOrb } from '../../components/ThinkingOrb'+import { contentTop, isOpenMode, type IslandMode, type IslandTab } from '@shared/island'+import { Icon } from '../../components/Icon'import { useModel } from '../../lib/observable'-import type { IslandModel } from './island-model'+import { PINNED_LEAVE_MS, type IslandModel } from './island-model'+import { Approval, Empty, Message, Notice, Overview, Wings } from './IslandViews'+import { UsageMeter, UsageView } from './IslandUsage'import './island.css'-const INK = '#f2f2f2'--/** The notch island: a black shape at the top of the screen that grows from the notch. */+/** The notch island: a black shape that grows out of the notch. */export function IslandWindow({ model }: { model: IslandModel }) {useModel(model)- const content = useRef<HTMLDivElement>(null)- useEffect(() => {- const el = content.current- if (!el) return- const observer = new ResizeObserver(() => model.setContentHeight(el.offsetHeight))- observer.observe(el)- return () => observer.disconnect()- }, [model])-const { mode, frame } = model- const closed = mode === 'compact' || mode === 'hidden'+ const open = isOpenMode(mode)+ const closed = mode === 'compact' || mode === 'hidden' || mode === 'peek'return (<div- className={`island ${model.growing ? 'growing' : 'shrinking'}`}+ className={`island ${model.growing ? 'growing' : 'shrinking'} ${model.screen.notch ? '' : 'edge'}`}data-mode={mode}style={{ width: frame.width, height: frame.height }}role={closed ? 'button' : undefined}@@ -35,108 +24,70 @@ export function IslandWindow({ model }: { model: IslandModel }) {<span className="island-ear left" /><span className="island-ear right" /><div className="island-body" style={{ borderBottomLeftRadius: frame.radius, borderBottomRightRadius: frame.radius }}>- {mode === 'compact' ? <Compact model={model} height={frame.height} /> : null}- <div className="island-content" ref={content} style={{ top: contentTop(model.screen), width: frame.width }}>- {mode === 'bots' ? <BotList model={model} /> : null}- {mode === 'approval' && model.permission ? <Approval model={model} card={model.permission} /> : null}- {mode === 'finished' && model.finished ? <Finished model={model} bot={model.finished} /> : null}- </div>+ {mode === 'compact' || mode === 'peek' ? <Wings model={model} peek={mode === 'peek'} /> : null}+ {open ? (+ <>+ <Header model={model} mode={mode} />+ <div key={mode} className="island-content" style={{ top: contentTop(model.screen) }}>+ <View model={model} mode={mode} />+ </div>+ </>+ ) : null}+ {open && model.closing ? <span className="island-countdown" style={{ animationDuration: `${PINNED_LEAVE_MS}ms` }} /> : null}</div></div>)}-/** The notch widened: the bot in focus on the left, how many work or that one waits on the right. */-function Compact({ model, height }: { model: IslandModel; height: number }) {- const focus = model.focus- const count = model.activeCount- return (- <div className="island-compact" style={{ height }}>- <span className="island-wing">{focus ? <Avatar bot={focus} size={Math.min(20, height - 10)} /> : null}</span>- <span className="island-wing">- {focus?.status === 'needsInput' ? <span className="island-dot" /> : count > 1 ? <span className="island-count">{count}</span> : <ThinkingOrb size={14} color={INK} />}- </span>- </div>- )+function View({ model, mode }: { model: IslandModel; mode: IslandMode }) {+ switch (mode) {+ case 'overview':+ return <Overview model={model} />+ case 'empty':+ return <Empty model={model} />+ case 'approval':+ return model.permission ? <Approval model={model} card={model.permission} /> : null+ case 'finished':+ case 'failed':+ return model.noticeBot ? <Notice model={model} bot={model.noticeBot} failed={mode === 'failed'} /> : null+ case 'message':+ return <Message model={model} />+ case 'usage':+ return <UsageView model={model} />+ default:+ return null+ }}-function BotList({ model }: { model: IslandModel }) {- const bots = model.bots- if (bots.length === 0) return <div className="island-empty">No bots yet</div>- return (- <div className="island-list">- {bots.map((bot) => (- <button key={bot.ref} className="island-row" onClick={() => model.openBot(bot.ref)} title="Open conversation">- <Avatar bot={bot} size={24} />- <span className="island-text">- <span className="island-name">{bot.name}</span>- <span className="island-detail">{bot.detail}</span>- </span>- <Status bot={bot} />- </button>- ))}- </div>- )-}+const TABS: { tab: IslandTab; icon: string; label: string }[] = [+ { tab: 'bots', icon: 'house.fill', label: 'Bots' },+ { tab: 'message', icon: 'bubble.left.fill', label: 'Message a bot' },+ { tab: 'usage', icon: 'gauge.with.dots.needle.33percent', label: 'Usage' },+]-function Approval({ model, card }: { model: IslandModel; card: IslandPermission }) {- const count = model.summary.permissions.length+/** Tabs on the left of the notch; the working count, the usage meter and Codync on the right. */+function Header({ model, mode }: { model: IslandModel; mode: IslandMode }) {+ const selected = mode === 'message' || mode === 'usage' ? mode : mode === 'overview' || mode === 'empty' ? 'bots' : null+ const count = model.activeCountreturn (- <div className="island-approval">- <div className="island-head">- <CharacterAvatar shape={card.bot.shape} color={card.bot.color} size={22} mood="needsInput" dark />- <span className="island-name">{card.bot.name}</span>- <span className="island-detail">{card.headline}</span>- <span style={{ flex: 1 }} />- {count > 1 ? <span className="island-detail">{`${count} waiting`}</span> : null}- <IconButton icon="arrow.up.right.square" title="Open conversation" size={24} onClick={() => model.openBot(card.ref)} />- <IconButton icon="chevron.up" title="Later" size={24} onClick={() => model.later(card)} />- </div>- {card.title ? <div className="island-command">{card.title}</div> : null}- <div className="island-options">- {card.options.map((o, i) => (- <Button- key={o.id}- kind={i === 0 && o.allow ? 'primary' : 'secondary'}- className={o.allow ? undefined : 'island-deny'}- disabled={card.answering !== null}- onClick={() => model.respond(card, o.id)}- >- {card.answering === o.id ? <Spinner size={12} /> : null}- {o.label}- </Button>+ <div className="island-header">+ <div className="island-tabs">+ {TABS.map((t) => (+ <button key={t.tab} className={`island-tab ${selected === t.tab ? 'selected' : ''}`} title={t.label} aria-label={t.label} onClick={() => model.setTab(t.tab)}>+ <Icon name={t.icon} size={13} scaled={false} />+ </button>))}+ <button className="island-tab" title="New bot" aria-label="New bot" onClick={() => model.newBot()}>+ <Icon name="plus" size={13} weight="semibold" scaled={false} />+ </button>+ </div>+ <div className="island-tabs">+ {count ? <span className="island-count">{`${count} working`}</span> : null}+ <UsageMeter model={model} />+ <button className="island-tab" title="Open Codync" aria-label="Open Codync" onClick={() => model.openApp()}>+ <Icon name="arrow.up.right.square" size={13} scaled={false} />+ </button></div></div>)}--function Finished({ model, bot }: { model: IslandModel; bot: IslandBot }) {- return (- <button className="island-row" onClick={() => model.openBot(bot.ref)} title="Open conversation">- <Avatar bot={bot} size={24} />- <span className="island-text">- <span className="island-name">{bot.status === 'error' ? `${bot.name} failed` : `${bot.name} is done`}</span>- <span className="island-detail">{bot.detail}</span>- </span>- </button>- )-}--function Avatar({ bot, size }: { bot: IslandBot; size: number }) {- const mood = bot.status === 'needsInput' ? 'needsInput' : bot.status === 'working' ? 'working' : 'idle'- return <CharacterAvatar shape={bot.shape} color={bot.color} size={size} mood={mood} dark />-}--function Status({ bot }: { bot: IslandBot }) {- switch (bot.status) {- case 'working':- return <ThinkingOrb size={14} color={INK} />- case 'needsInput':- return <span className="island-dot" />- case 'error':- return <span className="island-dot error" />- default:- return null- }-}diff --git a/apps/desktop/src/renderer/views/island/island-model.ts b/apps/desktop/src/renderer/views/island/island-model.tsindex a869c5ab..70c09631 100644--- a/apps/desktop/src/renderer/views/island/island-model.ts+++ b/apps/desktop/src/renderer/views/island/island-model.ts@@ -1,34 +1,49 @@import {- FINISHED_MS, isActive, islandFrame, islandMode, islandRect, justFinished,- type IslandBot, type IslandPermission, type IslandScreen, type IslandSummary,+ FINISHED_MS, focusOf, isActive, islandFrame, islandMode, islandRect, othersOf, transitions,+ type IslandBot, type IslandNotice, type IslandPermission, type IslandScreen, type IslandSummary, type IslandTab,} from '@shared/island'import { Observable } from '../../lib/observable'-const LIST_LIMIT = 6-/** Opened without the pointer on it (a click through accessibility): folds by itself after this. */-const UNATTENDED_MS = 8000+/** The bare notch peeks at once and opens after a rest; the compact island opens sooner. */+const OPEN_FROM_PEEK_MS = 650+const OPEN_FROM_COMPACT_MS = 200+const UNPEEK_MS = 600+/** Opened by hover, it folds soon after the pointer leaves; opened by a click, after a countdown. */+const LEAVE_MS = 800+export const PINNED_LEAVE_MS = 10_000-/** The island window's state: the chat window's summary, the pointer, and approvals put off. */+/** The island window's state: the chat window's summary, the pointer, the header's tab and what was put off. */export class IslandModel extends Observable {- summary: IslandSummary = { bots: [], permissions: [] }+ summary: IslandSummary = { bots: [], permissions: [], usage: [] }screen: IslandScreen = { notch: null }open = false- finished: IslandBot | null = null+ tab: IslandTab = 'auto'+ notice: IslandNotice | null = null+ /** Counting down to fold after the pointer left a pinned island. */+ closing = false+ /** The bot the message field writes to. */+ messageRef: string | null = null/** The shape grew on its last change: open with a spring, close without one. */growing = true+ private peek = false+ private pinned = falseprivate hovering = falseprivate deferred = new Set<string>()- private content = 0private statuses: Map<string, string> | null = nullprivate hoverTimer: ReturnType<typeof setTimeout> | undefined- private finishTimer: ReturnType<typeof setTimeout> | undefined+ private noticeTimer: ReturnType<typeof setTimeout> | undefinedprivate shape = { width: 0, height: 0 }+ private keys = falsestart() {const island = window.codync.islandisland.onSummary((s) => this.apply(s))island.onScreen((s) => this.update(() => (this.screen = s)))island.onHover((inside) => this.hover(inside))+ island.onKey((answer) => this.answerByKey(answer))+ window.addEventListener('blur', () => {+ if (this.tab === 'message') this.close()+ })// Linux shapes the window to the island (main/island.ts): the pointer entering the window is the hover.if (window.codync.platform === 'linux') {document.documentElement.addEventListener('mouseenter', () => this.hover(true))@@ -41,11 +56,11 @@ export class IslandModel extends Observable {}get mode() {- return islandMode(this.summary, { open: this.open, deferred: this.deferred, finished: this.finished !== null })+ return islandMode(this.summary, { open: this.open, peek: this.peek, tab: this.tab, deferred: this.deferred, notice: this.notice })}get frame() {- return islandFrame(this.mode, this.screen, this.content)+ return islandFrame(this.mode, this.screen)}/** The approval to answer now: the first not put off, else the first. */@@ -54,79 +69,174 @@ export class IslandModel extends Observable {return cards.find((p) => !this.deferred.has(p.entryId)) ?? cards[0] ?? null}- /** The compact island's bot: one that needs you, else one working. */get focus() {- const bots = this.summary.bots- return bots.find((b) => b.status === 'needsInput') ?? bots.find(isActive) ?? null+ return focusOf(this.summary.bots)+ }++ /** The bots beside the big slot: pills (overview), the mini column and the compact cluster. */+ others(limit: number) {+ return othersOf(this.summary.bots, this.focus, limit)}get activeCount() {return this.summary.bots.filter(isActive).length}- /** The open list: bots that work or wait first, then the rest in roster order. */- get bots() {- const bots = this.summary.bots- return [...bots.filter(isActive), ...bots.filter((b) => !isActive(b))].slice(0, LIST_LIMIT)+ bot(ref: string | null) {+ return this.summary.bots.find((b) => b.ref === ref) ?? null}- setContentHeight(height: number) {- if (height !== this.content) this.update(() => (this.content = height))+ get noticeBot(): IslandBot | null {+ return this.bot(this.notice?.ref ?? null)}- /** A click on the closed island opens it at once. */+ get messageBot(): IslandBot | null {+ return this.bot(this.messageRef) ?? this.focus+ }++ /** A click on the closed island opens it and keeps it open. */openNow() {- clearTimeout(this.hoverTimer)- if (!this.hovering) this.hoverTimer = setTimeout(() => this.update(() => (this.open = false)), UNATTENDED_MS)- this.update(() => (this.open = true))+ this.update(() => {+ this.open = true+ this.pinned = true+ this.peek = false+ })+ this.foldWhenAway()}- /** Folds the approval away until the island is opened again or another one arrives. */- later(card: IslandPermission) {+ /** The header's tabs. Bots puts the approvals on screen off until another arrives. */+ setTab(tab: IslandTab) {this.update(() => {- this.deferred.add(card.entryId)- this.open = false+ if (tab === 'bots') for (const p of this.summary.permissions) this.deferred.add(p.entryId)+ if (tab === 'message' && !this.messageRef) this.messageRef = this.focus?.ref ?? null+ this.tab = tab+ this.open = true+ this.pinned = true})+ window.codync.island.setFocusable(tab === 'message')+ this.foldWhenAway()+ }++ /** The message field's bot chip steps through the bots. */+ nextMessageBot() {+ const bots = this.summary.bots+ if (!bots.length) return+ const at = bots.findIndex((b) => b.ref === this.messageBot?.ref)+ this.update(() => (this.messageRef = bots[(at + 1) % bots.length]!.ref))+ }++ send(text: string) {+ const bot = this.messageBot+ if (!bot || !text.trim()) return+ window.codync.island.send(bot.ref, text)+ this.close()}- /** Answers the card and folds the island: the bot carries on. */respond(card: IslandPermission, optionId: string) {window.codync.island.respond(card.ref, card.entryId, optionId)- this.update(() => (this.open = false))+ if (this.open) this.close()}openBot(ref: string) {window.codync.island.openBot(ref)- clearTimeout(this.finishTimer)+ this.dismissNotice()+ this.close()+ }++ newBot() {+ window.codync.island.newBot()+ this.close()+ }++ openApp() {+ window.codync.island.openApp()+ this.close()+ }++ dismissNotice() {+ clearTimeout(this.noticeTimer)+ this.update(() => (this.notice = null))+ }++ close() {+ clearTimeout(this.hoverTimer)this.update(() => {this.open = false- this.finished = null+ this.pinned = false+ this.peek = false+ this.closing = false+ this.tab = 'auto'})+ window.codync.island.setFocusable(false)+ }++ private answerByKey(answer: 'allow' | 'deny') {+ const card = this.mode === 'approval' ? this.permission : null+ const option = card?.options.find((o) => o.kind === (answer === 'allow' ? 'allow_once' : 'reject_once'))+ if (card && option && card.answering === null) this.respond(card, option.id)}private apply(summary: IslandSummary) {- const done = this.statuses ? justFinished(this.statuses, summary.bots) : []+ const changes = this.statuses ? transitions(this.statuses, summary.bots) : []this.statuses = new Map(summary.bots.map((b) => [b.ref, b.status]))this.update(() => {this.summary = summary// Answered and expired cards leave the put-off set.for (const id of this.deferred) if (!summary.permissions.some((p) => p.entryId === id)) this.deferred.delete(id)- if (done[0]) this.showFinished(done[0])+ // A failed bot that works again no longer needs the notice.+ const shown = this.notice ? summary.bots.find((b) => b.ref === this.notice?.ref) : undefined+ if (shown && isActive(shown)) this.notice = null+ const next = changes.at(-1)+ if (next) this.showNotice(next)})}- private showFinished(bot: IslandBot) {- clearTimeout(this.finishTimer)- this.finished = bot- this.finishTimer = setTimeout(() => this.update(() => (this.finished = null)), FINISHED_MS)+ /** Done fades after a moment; failed stays until dismissed. */+ private showNotice(notice: IslandNotice) {+ clearTimeout(this.noticeTimer)+ this.notice = notice+ if (notice.kind === 'finished') this.noticeTimer = setTimeout(() => this.update(() => (this.notice = null)), FINISHED_MS)}- /** Opens after a short rest on the island (longer over the bare notch), folds soon after the pointer leaves. */private hover(inside: boolean) {this.hovering = insideclearTimeout(this.hoverTimer)- const delay = inside ? (this.mode === 'hidden' ? 600 : 250) : 500- this.hoverTimer = setTimeout(() => this.update(() => (this.open = inside)), delay)+ const mode = this.mode+ if (inside) {+ if (this.closing) this.update(() => (this.closing = false))+ if (mode === 'hidden') {+ this.update(() => (this.peek = true))+ this.hoverTimer = setTimeout(() => this.openByHover(), OPEN_FROM_PEEK_MS)+ } else if (mode === 'peek' || mode === 'compact') {+ this.hoverTimer = setTimeout(() => this.openByHover(), OPEN_FROM_COMPACT_MS)+ }+ return+ }+ if (this.open) {+ if (this.pinned) this.foldWhenAway()+ else this.hoverTimer = setTimeout(() => this.close(), LEAVE_MS)+ } else if (this.peek) {+ this.hoverTimer = setTimeout(() => this.update(() => (this.peek = false)), UNPEEK_MS)+ }+ }++ /**+ * Kept open with the pointer elsewhere (it left, or a click came through accessibility): fold+ * after a countdown. The message field stays until it sends, Esc or a click in another app.+ */+ private foldWhenAway() {+ clearTimeout(this.hoverTimer)+ const counting = this.open && !this.hovering && this.tab !== 'message'+ if (counting !== this.closing) this.update(() => (this.closing = counting))+ if (counting) this.hoverTimer = setTimeout(() => this.close(), PINNED_LEAVE_MS)+ }++ private openByHover() {+ if (!this.hovering) return+ this.update(() => {+ this.open = true+ this.peek = false+ })}private update(change: () => void) {@@ -137,6 +247,11 @@ export class IslandModel extends Observable {this.shape = { width: frame.width, height: frame.height }window.codync.island.setShape(islandRect(frame, window.innerWidth))}+ const keys = this.mode === 'approval'+ if (keys !== this.keys) {+ this.keys = keys+ window.codync.island.setKeys(keys)+ }this.changed()}}diff --git a/apps/desktop/src/renderer/views/island/island-parts.tsx b/apps/desktop/src/renderer/views/island/island-parts.tsxnew file mode 100644index 00000000..7dde6aab--- /dev/null+++ b/apps/desktop/src/renderer/views/island/island-parts.tsx@@ -0,0 +1,145 @@+import type { IslandBot } from '@shared/island'+import { CharacterAvatar, type Mood } from '../../components/Avatar'+import { Icon } from '../../components/Icon'+import { ThinkingOrb } from '../../components/ThinkingOrb'+import { avatarColor, withAlpha } from '../../lib/theme'++// Pieces the island's views share: the big character with its glow and+// badge, the agent row, the column of other bots and the key hint on a button.++export type Badge = 'working' | 'needsInput' | 'finished' | 'failed' | null++/** State colors: amber needs you, green done, red failed (Codync's palette has no others). */+export const AMBER = '#F0A030'+export const GREEN = '#34D399'+export const RED = '#F4505E'++export const moodOf = (bot: Pick<IslandBot, 'status'>): Mood =>+ bot.status === 'needsInput' ? 'needsInput' : bot.status === 'working' ? 'working' : 'idle'++export const badgeOf = (bot: Pick<IslandBot, 'status'>): Badge =>+ bot.status === 'needsInput' ? 'needsInput' : bot.status === 'working' ? 'working' : bot.status === 'error' ? 'failed' : null++function glowOf(badge: Badge, color: string) {+ switch (badge) {+ case 'needsInput':+ return AMBER+ case 'finished':+ return GREEN+ case 'failed':+ return RED+ case 'working':+ return avatarColor(color)+ case null:+ return null+ }+}++/** The bot in the big slot: its character, a glow in its state's color and a badge. */+export function BigCharacter({ bot, size, mood, badge, onOpen }: {+ bot: Pick<IslandBot, 'shape' | 'color'>+ size: number+ mood: Mood+ badge: Badge+ onOpen?: () => void+}) {+ const glow = glowOf(badge, bot.color)+ const inner = (+ <>+ {glow ? <span aria-hidden className="island-glow" style={{ background: `radial-gradient(circle, ${withAlpha(glow, 0.36)}, ${withAlpha(glow, 0)} 68%)` }} /> : null}+ <CharacterAvatar shape={bot.shape} color={bot.color} size={size} mood={mood} dark />+ <StateBadge badge={badge} />+ </>+ )+ const style = { width: size, height: size }+ return onOpen ? (+ <button className="island-big" style={style} onClick={onOpen} title="Open conversation" aria-label="Open conversation">+ {inner}+ </button>+ ) : (+ <span className="island-big" style={style}>+ {inner}+ </span>+ )+}++export function StateBadge({ badge, small = false }: { badge: Badge; small?: boolean }) {+ if (!badge) return null+ if (badge === 'working' && !small) {+ return (+ <span className="island-badge orb" aria-label="Working">+ <ThinkingOrb size={14} color="#F5F6F8" />+ </span>+ )+ }+ if (badge === 'working') {+ return (+ <span className={`island-badge dots ${small ? 'small' : ''}`} aria-label="Working">+ <i />+ <i />+ <i />+ </span>+ )+ }+ const color = badge === 'needsInput' ? AMBER : badge === 'finished' ? GREEN : RED+ const label = badge === 'needsInput' ? 'Needs you' : badge === 'finished' ? 'Done' : 'Failed'+ return (+ <span className={`island-badge ${small ? 'small' : ''}`} style={{ background: color }} aria-label={label}>+ <Icon name={badge === 'finished' ? 'checkmark' : 'exclamationmark'} size={small ? 5 : 8} weight="black" scaled={false} />+ </span>+ )+}++/** The bot's color dot, its name and what it's doing. */+export function AgentRow({ color, name, subtitle }: { color: string; name: string; subtitle: string }) {+ return (+ <div className="island-agent">+ <span className="island-dot" style={{ background: avatarColor(color) }} />+ <span className="island-agent-name">{name}</span>+ <span className="island-agent-subtitle">{subtitle}</span>+ </div>+ )+}++/** The other bots down the right edge; each opens its conversation. */+export function MiniColumn({ bots, onOpen }: { bots: IslandBot[]; onOpen: (ref: string) => void }) {+ return (+ <div className="island-minis">+ {bots.map((b) => (+ <button key={b.ref} className="island-mini" title={b.name} aria-label={`Open ${b.name}`} onClick={() => onOpen(b.ref)}>+ <CharacterAvatar shape={b.shape} color={b.color} size={18} mood={moodOf(b)} dark />+ <StatusDot bot={b} />+ </button>+ ))}+ </div>+ )+}++/** A small dot on a mini character: amber needs you, white working, red failed. */+export function StatusDot({ bot }: { bot: Pick<IslandBot, 'status'> }) {+ const color = bot.status === 'needsInput' ? AMBER : bot.status === 'working' ? '#F5F6F8' : bot.status === 'error' ? RED : null+ return color ? <span className="island-status-dot" style={{ background: color }} /> : null+}++/** The shortcut on an approval button. */+export const KeyHint = ({ keys }: { keys: string }) => <span aria-hidden className="island-key">{keys}</span>++/** A ticker row's icon for the tool's kind. */+export function stepIcon(kind: string) {+ switch (kind) {+ case 'execute':+ return 'terminal'+ case 'edit':+ case 'delete':+ case 'move':+ return 'pencil'+ case 'read':+ return 'doc.text'+ case 'search':+ return 'magnifyingglass'+ case 'fetch':+ return 'globe'+ default:+ return 'ellipsis'+ }+}diff --git a/apps/desktop/src/renderer/views/island/island.css b/apps/desktop/src/renderer/views/island/island.cssindex f4ef36c5..178c206a 100644--- a/apps/desktop/src/renderer/views/island/island.css+++ b/apps/desktop/src/renderer/views/island/island.css@@ -7,21 +7,24 @@ html[data-window='island'] #root {/* Always black like the notch, so always the dark palette, at the default text size. */.island {- --text: #fafafa;- --text-rgb: 250, 250, 250;- --secondary: #a0a0a0;- --tertiary: #929292;- --accent-fill: #ffffff;- --on-accent: #000000;- --bubble-user: #2c2c2c;- --danger: #f0a7a7;+ --text: #f5f6f8;+ --text-rgb: 245, 246, 248;+ --secondary: #8e939c;+ --tertiary: #5f646d;+ --accent-fill: #f5f6f8;+ --on-accent: #0b0c0e;+ --bubble-user: rgba(255, 255, 255, 0.09);+ --danger: #ff8d97;+ --island-card: #141518;+ --bubble-agent: rgba(255, 255, 255, 0.12);+ --warning: #f0a030;--scale: 1;position: absolute;top: 0;left: 50%;transform: translateX(-50%);color: var(--text);- font-size: 12px;+ font-size: 13px;/* A spring with a little overshoot to open, none to close. */transition: width 0.52s cubic-bezier(0.32, 1.22, 0.42, 1), height 0.52s cubic-bezier(0.32, 1.22, 0.42, 1), opacity 0.2s var(--ease);}@@ -45,136 +48,574 @@ html[data-window='island'] #root {.island-ear {position: absolute;top: 0;- width: 8px;- height: 8px;+ width: 14px;+ height: 14px;}.island-ear.left {- left: -8px;- background: radial-gradient(circle at 0 100%, transparent 7.5px, #000 8px);+ left: -14px;+ background: radial-gradient(circle at 0 100%, transparent 13.5px, #000 14px);}.island-ear.right {- right: -8px;- background: radial-gradient(circle at 100% 100%, transparent 7.5px, #000 8px);+ right: -14px;+ background: radial-gradient(circle at 100% 100%, transparent 13.5px, #000 14px);+}+.island.edge .island-ear {+ width: 10px;+ height: 10px;+}+.island.edge .island-ear.left {+ left: -10px;+ background: radial-gradient(circle at 0 100%, transparent 9.5px, #000 10px);+}+.island.edge .island-ear.right {+ right: -10px;+ background: radial-gradient(circle at 100% 100%, transparent 9.5px, #000 10px);+}++/* Bare buttons; :where keeps this below each element's own padding. */+:where(.island button) {+ border: 0;+ padding: 0;+ cursor: default;}-.island-compact {+/* Closed: the wings on each side of the notch. */+.island-wings {position: absolute;- inset: 0 0 auto 0;+ inset: 0;display: flex;justify-content: space-between;+ align-items: center;}-.island-wing {- width: 36px;+.island-wing-left,+.island-wing-right {+ position: relative;+ width: 52px;+ height: 100%;display: grid;place-items: center;}-.island-count {- font-weight: 600;- font-variant-numeric: tabular-nums;+.island[data-mode='peek'] .island-wing-left {+ width: 38px;+ justify-items: end;}-.island-dot {- width: 8px;- height: 8px;- border-radius: 50%;- background: var(--warning);- flex: none;+.island-wing-avatar {+ position: relative;+ display: block;+}+.island-cluster {+ display: grid;+ grid-template-columns: repeat(2, 11px);+ gap: 1px;+ justify-items: center;}-.island-dot.error {- background: var(--danger);+.island-cluster-bot {+ position: relative;}-.island-content {+/* Open: the header beside the notch. */+.island-header {position: absolute;- left: 50%;- transform: translateX(-50%);- padding: 6px 14px 0;+ top: 2px;+ left: 14px;+ right: 14px;+ height: 32px;+ display: flex;+ align-items: center;+ justify-content: space-between;+}+.island-tabs {+ display: flex;+ align-items: center;+ gap: 6px;+}+.island-tab {+ width: 30px;+ height: 30px;+ border-radius: 15px;+ display: grid;+ place-items: center;+ background: transparent;+ color: var(--secondary);+ transition: background-color var(--hover), color var(--hover);}-.island-content > * {+.island-tab:hover {+ background: rgba(255, 255, 255, 0.08);+ color: var(--text);+}+.island-tab.selected {+ background: rgba(255, 255, 255, 0.12);+ color: var(--text);+}+.island-count {+ font-size: 12px;+ color: var(--secondary);+ margin-right: 4px;+}++.island-content {+ position: absolute;+ left: 10px;+ right: 10px;+ bottom: 10px;animation: island-in 0.3s 0.16s var(--ease) backwards;}@keyframes island-in {from {opacity: 0;- filter: blur(6px);+ filter: blur(8px);transform: scale(0.97);}}-.island-list {+.island-card {+ position: relative;+ height: 100%;+ box-sizing: border-box;+ border-radius: 20px;+ background: var(--island-card);+ overflow: hidden;+ color: var(--text);+}+.island-row-cards,+.island-with-minis {display: flex;- flex-direction: column;- gap: 2px;+ height: 100%;+ gap: 10px;+}+.island-with-minis {+ gap: 0;+}+.island-with-minis > .island-card {+ flex: 1;+ min-width: 0;+}++/* The big character: glow behind, badge on its top left. */+.island-big {+ position: relative;+ flex: none;+ background: none;+}+.island-big canvas {+ position: relative;}-.island-row {+.island-glow {+ position: absolute;+ inset: -18px;+ border-radius: 50%;+}+.island-badge {+ position: absolute;+ left: -5px;+ top: 3px;+ z-index: 1;+ width: 18px;+ height: 18px;+ border-radius: 50%;+ box-shadow: 0 0 0 2.5px #000;+ display: grid;+ place-items: center;+ color: #0b0c0e;+}+.island-badge.orb {+ left: -7px;+ top: 1px;+ width: 22px;+ height: 22px;+ background: #000;+ box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.14);+}+.island-badge.dots {+ left: -6px;+ top: 4px;+ width: auto;+ height: 16px;+ padding: 0 4px;+ border-radius: 8px;+ background: #f5f6f8;display: flex;align-items: center;- gap: 10px;- width: 100%;- min-height: 40px;- padding: 0 8px;- border-radius: 12px;- text-align: left;- transition: background-color var(--hover);+ gap: 2px;}-.island-row:hover {- background: rgba(255, 255, 255, 0.08);+.island-badge.dots i {+ width: 3px;+ height: 3px;+ border-radius: 50%;+ background: #0b0c0e;+}+.island-badge.small {+ left: -4px;+ top: -3px;+ width: 9px;+ height: 9px;+ box-shadow: 0 0 0 1.5px #000;+}+.island-badge.dots.small {+ width: auto;+ height: 7px;+ padding: 0 2px;+ gap: 1px;+}+.island-badge.dots.small i {+ width: 1.5px;+ height: 1.5px;}-.island-text {++.island-agent {display: flex;- flex-direction: column;+ align-items: center;+ gap: 7px;min-width: 0;- flex: 1;+ height: 26px;}-.island-name {+.island-dot {+ width: 8px;+ height: 8px;+ border-radius: 50%;+ flex: none;+}+.island-agent-name {+ font-size: 14px;font-weight: 600;white-space: nowrap;- overflow: hidden;- text-overflow: ellipsis;}-.island-detail {+.island-agent-subtitle {+ font-size: 13px;color: var(--secondary);white-space: nowrap;overflow: hidden;text-overflow: ellipsis;+ min-width: 0;}-.island-empty {- color: var(--secondary);- text-align: center;- padding: 10px 0;+.island-ellipsis {+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ min-width: 0;}-.island-approval {+/* Overview: the bot in focus and its steps, the others as pills. */+.island-focus {+ display: flex;+ align-items: center;+ gap: 13px;+ padding: 0 14px 0 19px;+ text-align: left;+ font: inherit;+}+.island-focus-text {+ flex: 1;+ min-width: 0;display: flex;flex-direction: column;- gap: 10px;}-.island-head {+.island-step {+ height: 30px;display: flex;align-items: center;+ gap: 9px;+ font-size: 13px;+ color: var(--tertiary);+ min-width: 0;+}+.island-step.current {+ font-size: 15px;+ font-weight: 500;+ color: #e8eaed;+}+.island-pills {+ flex: 1;+ min-width: 0;+ display: grid;+ grid-template-columns: repeat(2, minmax(0, 1fr));gap: 8px;+ align-content: center;+ padding: 0 8px;+}+.island-pill {+ height: 34px;+ border-radius: 17px;+ padding: 0 10px 0 5px;+ display: flex;+ align-items: center;+ gap: 7px;+ font: inherit;+ font-size: 12.5px;+ font-weight: 500;min-width: 0;+ transition: filter var(--hover);}-.island-command {- font-family: var(--mono);- font-size: 11px;- color: var(--secondary);- background: #141414;+.island-pill:hover {+ filter: brightness(1.25);+}+.island-pill-bot,+.island-mini {+ position: relative;+ flex: none;+ background: none;+}+.island-status-dot {+ position: absolute;+ left: -1px;+ top: -1px;+ width: 6px;+ height: 6px;+ border-radius: 50%;+ box-shadow: 0 0 0 1.5px #000;+}+.island-cluster .island-status-dot {+ width: 4px;+ height: 4px;+ left: -2px;+ top: -2px;+}++/* Alerts: approval, done, failed. */+.island-alert {+ display: flex;+ align-items: center;+ gap: 24px;+ padding: 0 20px 0 24px;+}+.island-alert-text {+ flex: 1;+ min-width: 0;+ display: flex;+ flex-direction: column;+ gap: 9px;+}+.island-alert .island-agent-name {+ font-size: 15px;+}+.island-alert .island-agent-subtitle {+ font-size: 14px;+}+.island-code {+ align-self: flex-start;+ max-width: 100%;+ box-sizing: border-box;+ padding: 8px 12px;border-radius: 10px;- padding: 8px 10px;- overflow-wrap: anywhere;+ background: #22242a;+ font-family: var(--mono);+ font-size: 13.5px;+ color: #e8eaed;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}+.island-title {+ font-size: 17px;+ font-weight: 700;+}+.island-error {+ font-size: 13.5px;+ line-height: 1.4;+ color: var(--danger);display: -webkit-box;- -webkit-line-clamp: 3;+ -webkit-line-clamp: 2;-webkit-box-orient: vertical;overflow: hidden;}-.island-options {+.island-buttons {display: flex;+ align-items: center;+ gap: 8px;flex-wrap: wrap;- justify-content: flex-end;+}+.island .styled-button {+ height: 32px;+ border-radius: 16px;+ padding: 0 14px;+ font-size: 13px;+ font-weight: 500;gap: 8px;}-.island-options .island-deny {- color: var(--danger);+.island-key {+ min-width: 16px;+ height: 16px;+ box-sizing: border-box;+ padding: 0 3px;+ border-radius: 5px;+ border: 1.5px solid;+ opacity: 0.55;+ display: grid;+ place-items: center;+ font-size: 10px;+}+.island-minis {+ width: 42px;+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 6px;+ padding-top: 4px;+}++/* Codync's own: the plan limits. */+.island-meter {+ height: 30px;+ padding: 0 6px;+ border-radius: 15px;+ display: flex;+ align-items: center;+ gap: 6px;+ background: transparent;+ color: var(--secondary);+ font-size: 12px;+ font-variant-numeric: tabular-nums;+ transition: background-color var(--hover), color var(--hover);+}+.island-meter:hover {+ background: rgba(255, 255, 255, 0.08);+ color: var(--text);+}+.island-meter-bar {+ width: 28px;+ display: flex;+}+.island-usage {+ flex: 1;+ min-width: 0;+ display: flex;+ flex-direction: column;+ justify-content: center;+ gap: 8px;+ padding: 0 18px;+}+.island-usage-row {+ display: flex;+ align-items: center;+ gap: 10px;+ font-size: 12.5px;+ white-space: nowrap;+}+.island-usage-title {+ width: 56px;+ flex: none;+ overflow: hidden;+ text-overflow: ellipsis;+}+.island-usage-value {+ width: 34px;+ flex: none;+ text-align: right;+ font-variant-numeric: tabular-nums;+}+.island-usage-reset {+ width: 66px;+ flex: none;+ text-align: right;+ color: var(--secondary);+ overflow: hidden;+ text-overflow: ellipsis;+}++/* Nothing running. */+.island-empty {+ display: flex;+ align-items: center;+ gap: 28px;+ padding: 0 22px 0 29px;+}+.island-empty-text {+ flex: 1;+ min-width: 0;+ display: flex;+ flex-direction: column;+ gap: 5px;+}+.island-empty .island-title {+ font-size: 16px;+}+.island-subtitle {+ font-size: 13.5px;+ line-height: 1.35;+ color: var(--secondary);+}++/* Message a bot. */+.island-message {+ display: flex;+ align-items: center;+ gap: 22px;+ padding: 0 18px 0 20px;+}+.island-message-body {+ flex: 1;+ min-width: 0;+ display: flex;+ flex-direction: column;+ gap: 9px;+}+.island-chip {+ height: 26px;+ border-radius: 13px;+ padding: 0 9px 0 4px;+ display: flex;+ align-items: center;+ gap: 6px;+ font: inherit;+ font-size: 12.5px;+ font-weight: 500;+ flex: none;+}+.island-field {+ display: flex;+ align-items: center;+ gap: 8px;+ height: 40px;+ border-radius: 20px;+ background: #22242a;+ padding: 0 5px 0 16px;+ margin: 0;+}+.island-field input {+ flex: 1;+ min-width: 0;+ border: 0;+ outline: none;+ background: transparent;+ color: var(--text);+ font: inherit;+ font-size: 14px;+ user-select: text;+}+.island-field input::placeholder {+ color: #6b7079;+}+.island-send {+ width: 30px;+ height: 30px;+ border-radius: 15px;+ display: grid;+ place-items: center;+ background: #f5f6f8;+ color: #0b0c0e;+}+.island-send:disabled {+ opacity: 0.35;+}++/* Folding soon: a line that runs out. */+.island-countdown {+ position: absolute;+ bottom: 4px;+ left: 50%;+ transform: translateX(-50%);+ height: 2px;+ border-radius: 1px;+ background: rgba(255, 255, 255, 0.35);+ animation: island-countdown linear forwards;+}+@keyframes island-countdown {+ from {+ width: 160px;+ }+ to {+ width: 0;+ }}@media (prefers-reduced-motion: reduce) {@@ -183,7 +624,7 @@ html[data-window='island'] #root {.island-body {transition: none;}- .island-content > * {+ .island-content {animation: none;}}diff --git a/apps/desktop/src/renderer/views/settings/UsageLimits.tsx b/apps/desktop/src/renderer/views/settings/UsageLimits.tsxindex 2e49c4fd..a9c4ed2a 100644--- a/apps/desktop/src/renderer/views/settings/UsageLimits.tsx+++ b/apps/desktop/src/renderer/views/settings/UsageLimits.tsx@@ -30,7 +30,7 @@ export function UsageLimits({ usage }: { usage: Usage }) {}/** A capsule filled to `percent`: the provider's tint below 70%, then amber, red from 90%. */-function UsageBar({ percent, tint }: { percent: number; tint: string }) {+export function UsageBar({ percent, tint }: { percent: number; tint: string }) {const fill = percent >= 90 ? 'var(--danger)' : percent >= 70 ? 'var(--warning)' : tintreturn (<span style={{ flex: 1, minWidth: 0, height: 6, borderRadius: 3, background: 'var(--bubble-agent)', overflow: 'hidden' }}>diff --git a/apps/desktop/src/shared/ipc.ts b/apps/desktop/src/shared/ipc.tsindex 21feb3b3..7a9360e3 100644--- a/apps/desktop/src/shared/ipc.ts+++ b/apps/desktop/src/shared/ipc.ts@@ -67,6 +67,7 @@ export type WindowCommand =| { kind: 'toggleSidebar' }| { kind: 'toggleDetails' }| { kind: 'respondPermission'; ref: string; entryId: string; optionId: string }+ | { kind: 'sendMessage'; ref: string; text: string }/** The app's own updates (electron-updater, release builds only). */export interface UpdateState {@@ -153,8 +154,16 @@ export interface CodyncBridge {/** The pointer reached or left the shape. */onHover(cb: (inside: boolean) => void): () => voidsetShape(rect: IslandRect): void+ /** The message field takes the keyboard (the island never does otherwise). */+ setFocusable(on: boolean): void+ /** ⌥Y / ⌥N answer the approval on screen, from any app, while it shows. */+ setKeys(on: boolean): void+ onKey(cb: (answer: 'allow' | 'deny') => void): () => voidrespond(ref: string, entryId: string, optionId: string): void+ send(ref: string, text: string): voidopenBot(ref: string): void+ newBot(): void+ openApp(): void}/** The Codync cloud's `/v1` API with the signed-in session (and the device key for `signed`). */cloud: {diff --git a/apps/desktop/src/shared/island.test.ts b/apps/desktop/src/shared/island.test.tsindex 549cfdc1..07ad0725 100644--- a/apps/desktop/src/shared/island.test.ts+++ b/apps/desktop/src/shared/island.test.ts@@ -1,36 +1,58 @@import assert from 'node:assert/strict'import { test } from 'node:test'import type { BotStatus } from './models.ts'-import { hitRect, hits, islandFrame, islandMode, islandRect, justFinished, notchOf, type IslandBot, type IslandPermission, type IslandSummary } from './island.ts'+import {+ focusOf, hitRect, hits, islandFrame, islandMode, islandRect, notchOf, othersOf, transitions,+ type IslandBot, type IslandNotice, type IslandPermission, type IslandSummary, type IslandTab,+} from './island.ts'-const bot = (ref: string, status: BotStatus): IslandBot => ({ ref, name: ref, shape: 'circle', color: 'blue', status, detail: '' })+const bot = (ref: string, status: BotStatus): IslandBot => ({+ ref, name: ref, shape: 'blob', color: 'blue', status, backend: 'Claude Code', folder: 'site', detail: '', steps: [], error: null,+})const card = (entryId: string): IslandPermission => ({- ref: 'c/a', entryId, bot: { name: 'a', shape: 'circle', color: 'blue' }, headline: 'Wants to run a command', title: 'ls', options: [], answering: null,+ ref: 'c/a', entryId, bot: { name: 'a', shape: 'blob', color: 'blue', backend: 'Claude Code' }, headline: 'Wants to run a command', title: 'ls', options: [], answering: null,+})+const summary = (bots: IslandBot[], permissions: IslandPermission[] = []): IslandSummary => ({ bots, permissions, usage: [] })+const state = (over: Partial<{ open: boolean; peek: boolean; tab: IslandTab; deferred: ReadonlySet<string>; notice: IslandNotice | null }> = {}) =>+ ({ open: false, peek: false, tab: 'auto' as IslandTab, deferred: new Set<string>(), notice: null, ...over })++test('closed, the island hides, peeks under the pointer and stays thin while bots work', () => {+ assert.equal(islandMode(summary([bot('a', 'idle')]), state()), 'hidden')+ assert.equal(islandMode(summary([bot('a', 'idle')]), state({ peek: true })), 'peek')+ assert.equal(islandMode(summary([bot('a', 'working')]), state()), 'compact')+ assert.equal(islandMode(summary([bot('a', 'needsInput')]), state()), 'compact')})-const summary = (bots: IslandBot[], permissions: IslandPermission[] = []): IslandSummary => ({ bots, permissions })-const none = new Set<string>()-test('the island hides with nothing running and stays thin while bots work', () => {- assert.equal(islandMode(summary([bot('a', 'idle')]), { open: false, deferred: none, finished: false }), 'hidden')- assert.equal(islandMode(summary([bot('a', 'working')]), { open: false, deferred: none, finished: false }), 'compact')- assert.equal(islandMode(summary([bot('a', 'needsInput')]), { open: false, deferred: none, finished: false }), 'compact')- assert.equal(islandMode(summary([bot('a', 'idle')]), { open: false, deferred: none, finished: true }), 'finished')- assert.equal(islandMode(summary([bot('a', 'working')]), { open: true, deferred: none, finished: true }), 'bots')+test('open, it shows what needs you first, then the bots', () => {+ assert.equal(islandMode(summary([bot('a', 'working')]), state({ open: true })), 'overview')+ assert.equal(islandMode(summary([bot('a', 'idle')]), state({ open: true })), 'empty')+ assert.equal(islandMode(summary([bot('a', 'idle')]), state({ open: true, notice: { kind: 'finished', ref: 'a' } })), 'finished')+ assert.equal(islandMode(summary([bot('a', 'idle')]), state({ open: true, tab: 'bots', notice: { kind: 'finished', ref: 'a' } })), 'empty')+ assert.equal(islandMode(summary([bot('a', 'working')]), state({ open: true, tab: 'message' })), 'message')+ assert.equal(islandMode(summary([bot('a', 'working')], [card('e1')]), state({ open: true, tab: 'usage' })), 'usage')})test('an approval opens the island until it is put off, and opening shows it again', () => {const s = summary([bot('a', 'needsInput')], [card('e1')])- assert.equal(islandMode(s, { open: false, deferred: none, finished: false }), 'approval')- assert.equal(islandMode(s, { open: false, deferred: new Set(['e1']), finished: false }), 'compact')- assert.equal(islandMode(s, { open: true, deferred: new Set(['e1']), finished: false }), 'approval')+ assert.equal(islandMode(s, state()), 'approval')+ assert.equal(islandMode(s, state({ deferred: new Set(['e1']) })), 'compact')+ assert.equal(islandMode(s, state({ open: true, deferred: new Set(['e1']) })), 'approval')+ assert.equal(islandMode(s, state({ open: true, tab: 'bots', deferred: new Set(['e1']) })), 'overview')// A new card arrives while the first is put off.- assert.equal(islandMode(summary([], [card('e1'), card('e2')]), { open: false, deferred: new Set(['e1']), finished: false }), 'approval')+ assert.equal(islandMode(summary([], [card('e1'), card('e2')]), state({ deferred: new Set(['e1']) })), 'approval')})-test('only bots that were working count as finished', () => {- const before = new Map<string, BotStatus>([['a', 'working'], ['b', 'idle'], ['c', 'needsInput'], ['d', 'working']])+test('a bot that stops working is done, or failed when it ended in an error', () => {+ const before = new Map<string, string>([['a', 'working'], ['b', 'idle'], ['c', 'needsInput'], ['d', 'working']])const after = [bot('a', 'idle'), bot('b', 'idle'), bot('c', 'error'), bot('d', 'working'), bot('e', 'idle')]- assert.deepEqual(justFinished(before, after).map((b) => b.ref), ['a', 'c'])+ assert.deepEqual(transitions(before, after), [{ kind: 'finished', ref: 'a' }, { kind: 'failed', ref: 'c' }])+})++test('the big slot goes to the bot that needs you, the rest to the side', () => {+ const bots = [bot('a', 'idle'), bot('b', 'working'), bot('c', 'needsInput'), bot('d', 'idle'), bot('e', 'working')]+ assert.equal(focusOf(bots)?.ref, 'c')+ assert.deepEqual(othersOf(bots, focusOf(bots), 3).map((b) => b.ref), ['b', 'e', 'a'])+ assert.equal(focusOf([]), null)})test('the notch is the screen width minus the menu bar on both sides', () => {@@ -43,12 +65,15 @@ test('the notch is the screen width minus the menu bar on both sides', () => {assert.equal(notchOf([], { x: 0, width: 1512 }), null)})-test('the hidden island covers the notch, or leaves a thin strip at a plain top edge', () => {+test('shapes follow the notch, and a plain top edge keeps a thin strip that wakes it', () => {const notch = { notch: { width: 185, height: 32 } }- assert.deepEqual(islandFrame('hidden', notch, 0), { width: 185, height: 32, radius: 10 })- assert.equal(islandFrame('compact', notch, 0).width, 185 + 72)- assert.equal(islandFrame('approval', notch, 100).height, 32 + 100 + 14)- const edge = islandRect(islandFrame('hidden', { notch: null }, 0), 720)+ assert.deepEqual(islandFrame('hidden', notch), { width: 185, height: 32, radius: 14 })+ assert.equal(islandFrame('peek', notch).width, 185 + 64)+ assert.equal(islandFrame('compact', notch).width, 185 + 104)+ assert.deepEqual(islandFrame('approval', notch), { width: 640, height: 206, radius: 30 })+ // A taller notch pushes the content down.+ assert.equal(islandFrame('approval', { notch: { width: 200, height: 38 } }).height, 212)+ const edge = islandRect(islandFrame('hidden', { notch: null }), 720)assert.equal(hits(edge, 360, 0), true)assert.equal(hits(edge, 360, 12), false)assert.equal(hits(edge, 100, 0), false)diff --git a/apps/desktop/src/shared/island.ts b/apps/desktop/src/shared/island.tsindex 117891b9..ac7a2ef2 100644--- a/apps/desktop/src/shared/island.ts+++ b/apps/desktop/src/shared/island.ts@@ -1,32 +1,49 @@-import type { BotStatus } from './models'+import type { BotStatus, UsageProvider } from './models'-// The notch island: a black shape at the top of the screen (in the notch on a MacBook) that-// shows working bots and takes approvals. The chat window owns the stores and sends an-// `IslandSummary`; the island window only draws it (main/island.ts, views/island/).+// The notch island: a black shape at the top of the screen (in the notch on a+// MacBook) that shows working bots and takes approvals. The chat window owns the stores and+// sends an `IslandSummary`; the island window only draws it (main/island.ts, views/island/).++/** One tool call in a bot's ticker. */+export interface IslandStep {+ title: string+ /** The ACP tool kind: execute | edit | read | search | fetch | … */+ kind: string+}/** One bot as the island shows it (`ref` = computerId/botId). */export interface IslandBot {ref: stringname: stringshape: string+ /** Its avatar palette id. */color: string/** A `BotStatus`, or a newer one this app doesn't know. */status: BotStatus | string+ /** The agent it runs, as the app names it ("Claude Code"). */+ backend: string+ /** Its working folder's name. */+ folder: string/** What it's doing, that it needs you, or its last message. */detail: string+ /** Its latest tool calls, oldest first (only while it works). */+ steps: IslandStep[]+ /** Why it stopped, when it failed. */+ error: string | null}export interface IslandOption {id: stringlabel: string- allow: boolean+ /** allow_once | allow_always | reject_once | reject_always, or another the agent sent. */+ kind: string}/** A pending approval card: the conversation holding it and the bot asking. */export interface IslandPermission {ref: stringentryId: string- bot: Pick<IslandBot, 'name' | 'shape' | 'color'>+ bot: Pick<IslandBot, 'name' | 'shape' | 'color' | 'backend'>headline: stringtitle: stringoptions: IslandOption[]@@ -37,6 +54,8 @@ export interface IslandPermission {export interface IslandSummary {bots: IslandBot[]permissions: IslandPermission[]+ /** This computer's plan limits (Claude, Codex), as the menu bar shows them. */+ usage: UsageProvider[]}/** The display the island sits on: the notch's size in points, or null at a plain top edge. */@@ -61,59 +80,92 @@ export interface NotchScreen {right: number}-export type IslandMode = 'hidden' | 'compact' | 'bots' | 'approval' | 'finished'+/** Closed shapes, then the open views (640 pt wide, under a header of tabs). */+export type IslandMode = 'hidden' | 'peek' | 'compact' | 'overview' | 'empty' | 'approval' | 'finished' | 'failed' | 'message' | 'usage'+/** The header's choice: `auto` shows what needs you first (an approval, a finished or failed bot). */+export type IslandTab = 'auto' | 'bots' | 'message' | 'usage'+/** A bot that just stopped, shown until it times out (done) or is dismissed (failed). */+export interface IslandNotice {+ kind: 'finished' | 'failed'+ ref: string+}/** How long a bot that just finished stays in the island. */-export const FINISHED_MS = 4000+export const FINISHED_MS = 5200/** Extra room around the shape that still counts as on it, so a click at its edge is never lost. */export const HIT_MARGIN = 8/** The window holding the island: the largest shape fits, the rest is transparent and lets clicks through. */-export const PANEL = { width: 720, height: 360 }+export const PANEL = { width: 720, height: 300 }+/** The open island's width. */+export const OPEN_WIDTH = 640-const WING = 36-const BAR = 28+/** Height of each open view for a 32 pt notch (a taller notch adds its extra height). */+const OPEN_HEIGHT = { overview: 196, empty: 150, approval: 206, finished: 170, failed: 190, message: 156, usage: 196 }+/** The resting bar at a plain top edge (no notch). */+const BAR = 26export const isActive = (b: Pick<IslandBot, 'status'>) => b.status === 'working' || b.status === 'needsInput'+export const isOpenMode = (mode: IslandMode) => mode !== 'hidden' && mode !== 'peek' && mode !== 'compact'export function islandMode(summary: IslandSummary,- { open, deferred, finished }: { open: boolean; deferred: ReadonlySet<string>; finished: boolean },+ { open, peek, tab, deferred, notice }: { open: boolean; peek: boolean; tab: IslandTab; deferred: ReadonlySet<string>; notice: IslandNotice | null },): IslandMode {- if (summary.permissions.some((p) => open || !deferred.has(p.entryId))) return 'approval'- if (open) return 'bots'- if (finished) return 'finished'- return summary.bots.some(isActive) ? 'compact' : 'hidden'+ if (!open) {+ // Alerts open the island by themselves.+ if (summary.permissions.some((p) => !deferred.has(p.entryId))) return 'approval'+ if (notice) return notice.kind+ if (peek) return 'peek'+ return summary.bots.some(isActive) ? 'compact' : 'hidden'+ }+ if (tab === 'message' || tab === 'usage') return tab+ if (tab === 'auto') {+ if (summary.permissions.length) return 'approval'+ if (notice) return notice.kind+ }+ return summary.bots.some(isActive) ? 'overview' : 'empty'}-/** Bots that stopped working since `before` (their last statuses by ref). */-export function justFinished(before: ReadonlyMap<string, string>, bots: IslandBot[]): IslandBot[] {- return bots.filter((b) => {+/** Bots that just stopped working since `before` (their last statuses by ref): done or failed. */+export function transitions(before: ReadonlyMap<string, string>, bots: IslandBot[]): IslandNotice[] {+ return bots.flatMap((b): IslandNotice[] => {const was = before.get(b.ref)- return (was === 'working' || was === 'needsInput') && (b.status === 'idle' || b.status === 'error')+ if (was !== 'working' && was !== 'needsInput') return []+ if (b.status === 'idle') return [{ kind: 'finished', ref: b.ref }]+ if (b.status === 'error') return [{ kind: 'failed', ref: b.ref }]+ return []})}-/** Where content starts below the top edge: under the notch, never behind the camera. */-export const contentTop = (screen: IslandScreen) => screen.notch?.height ?? 10+/** The bot in the big slot: one that needs you, else one working, else the first. */+export function focusOf(bots: IslandBot[]) {+ return bots.find((b) => b.status === 'needsInput') ?? bots.find(isActive) ?? bots[0] ?? null+}++/** The other bots, working and waiting first, at most `limit`. */+export function othersOf(bots: IslandBot[], focus: IslandBot | null, limit: number) {+ const rest = bots.filter((b) => b.ref !== focus?.ref)+ return [...rest.filter(isActive), ...rest.filter((b) => !isActive(b))].slice(0, limit)+}++/** The header's height: a taller notch pushes the content down so nothing sits behind the camera. */+export const contentTop = (screen: IslandScreen) => 36 + Math.max(0, (screen.notch?.height ?? 32) - 32)-/** The shape's size for `mode`; `content` is the measured height of an open view's content. */-export function islandFrame(mode: IslandMode, screen: IslandScreen, content: number) {+/** The shape's size and bottom corner radius for `mode`. */+export function islandFrame(mode: IslandMode, screen: IslandScreen) {const notch = screen.notch- const gap = notch?.width ?? 0const bar = notch?.height ?? BAR- const open = (min: number) => ({ width: Math.max(gap + 2 * WING, min), height: contentTop(screen) + content + 14, radius: 24 })+ const closedRadius = notch ? 14 : bar / 2switch (mode) {case 'hidden':// At a plain top edge only a thin strip under the edge wakes it.- return notch ? { width: notch.width, height: notch.height, radius: 10 } : { width: 160, height: 0, radius: 0 }+ return notch ? { width: notch.width, height: notch.height, radius: closedRadius } : { width: 160, height: 0, radius: 0 }+ case 'peek':+ return { width: notch ? notch.width + 64 : 120, height: bar, radius: closedRadius }case 'compact':- return { width: gap + 2 * WING, height: bar, radius: notch ? 10 : bar / 2 }- case 'finished':- return open(340)- case 'bots':- return open(380)- case 'approval':- return open(440)+ return { width: notch ? notch.width + 104 : 240, height: bar, radius: closedRadius }+ default:+ return { width: OPEN_WIDTH, height: OPEN_HEIGHT[mode] + contentTop(screen) - 36, radius: 30 }}}diff --git a/docs/features/notch-island.md b/docs/features/notch-island.mdindex 46262f24..02868b1c 100644--- a/docs/features/notch-island.md+++ b/docs/features/notch-island.md@@ -5,27 +5,45 @@ MacBook it grows out of the notch; on a Mac without a notch, and on Windows andfrom the top edge. It draws Codync's own bot characters.Turn it on or off in **Settings → General → System** (*Show in notch* on macOS, *Show at top-of screen* elsewhere) or the menu bar / tray menu's **Settings**. It is on by default. The+of screen* elsewhere) or the menu bar / tray menu's **Settings**. It is off by default while it+is experimental. Thesetting belongs to the desktop installation (`showIsland` in `host-prefs.json`).## What it shows-| State | When | Shape |+Open, the island is 640 pt wide, with a header of tabs beside the notch+(Bots, Message a bot, Usage, New bot; the working count, a usage meter and Open Codync on the+right) over a card. The card holds the bot in focus as a big character with a glow and a state+badge; alerts tint the card from the bottom (amber, green, red). The other bots sit in a column+on the right.++Codync's own parts: the dot-grid bot characters (no mascot), the thinking orb as the working+badge, the usage meter and Usage tab (the tightest local plan limit, every limit with its reset;+amber from 70 %, red from 90 %, like the menu bar), messaging a bot from the island, and ⌥Y / ⌥N.++| State | When | What it shows ||---|---|---|| Hidden | No bot works or waits | Invisible over the notch (a thin strip at a plain top edge still wakes it) |-| Compact | A bot works or needs you | The notch widened: the bot in focus on the left; on the right an orb, how many work, or an amber dot when one needs you |-| Bots | The pointer rests on the island (250 ms, 600 ms over the bare notch) or a click | Up to six bots, working and waiting first, with their current step. A row opens the conversation |-| Approval | A permission card is pending | The bot, what it wants, the command, and the card's options (Allow once, Always allow, Deny…). Open conversation and Later (fold until the island is opened again or another card arrives) |-| Finished | A bot stops working | "*Bot* is done" or "failed" with its last message, for 4 s |+| Peek | The pointer reaches the bare notch | The notch a little wider, the bot in focus peeking out; opens after 650 ms |+| Compact | A bot works or needs you | The notch widened: the bot in focus with its badge on the left, the others (or an orb) on the right |+| Overview | Pointer rest or a click, bots working | The bot in focus with its last three tool calls (newest brightest) and the other bots as pills; each opens its conversation |+| Nothing running | Opened with no bot working | "Nothing running right now." and Message a bot |+| Approval | A permission card is pending | The command and the card's options, deny left and Allow once right (⌥N / ⌥Y from any app while it shows) |+| Finished | A bot stops working | "*Bot* is done" with its last message, Open conversation / OK, for 5.2 s |+| Failed | A bot stops on an error | "*Bot* stopped." with the error in red, until OK |+| Message a bot | The header's bubble | The bot chip (click for the next bot) and a field; Enter sends, Esc closes |+| Usage | The header's gauge or the usage meter | Claude and Codex limits side by side: each window's bar, percent and reset |-The island folds 500 ms after the pointer leaves it, or 8 s after it was opened without the-pointer on it (VoiceOver). A pending approval stays open until it is answered, expires or is-put off; answering folds the island. Answers go through the same `respondPermission` call as the-chat's permission card.+Opened by hover, the island folds 0.8 s after the pointer leaves; opened by a click or a tab,+10 s after (a 2 pt line counts down). The message field stays until it sends, Esc or a click in+another app. An approval opens by itself and stays until answered; the Bots tab puts it off+until another arrives. Answers and messages go through the chat window (`respondPermission`,+`send`), like the chat's own cards and composer. The states, sizes and motion are drawn in the+design canvas the island was built from.## How it works-- **Window** (`apps/desktop/src/main/island.ts`): a fixed 720 × 360 transparent, frameless,+- **Window** (`apps/desktop/src/main/island.ts`): a fixed 720 × 300 transparent, frameless,non-focusable window at the top center of the notch's display (else the main display). macOS:a non-activating panel at the main-menu level + 3, so it covers the menu bar, every Space andfull-screen apps. Windows: a toolbar window (out of Alt+Tab). It never resizes; the shape@@ -44,8 +62,10 @@ chat's permission card.- **Data**: the chat window owns the stores. `useIslandSummary` (next to the tray's summary)sends bots and pending permission cards when they change; the island window renders them(`views/island/`, state in `IslandModel`, pure rules in `shared/island.ts`). Buttons travel back- as `WindowCommand`s (`openBot`, `respondPermission`) to the chat window, which calls the host.- The island has no host connection of its own.+ as `WindowCommand`s (`openBot`, `respondPermission`, `sendMessage`) to the chat window, which+ calls the host. The island has no host connection of its own. It takes the keyboard only while+ the message field is open (`setFocusable`); ⌥Y / ⌥N are global shortcuts only while an+ approval shows.## Platforms and other clients