Skip to content

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.

feat(desktop): show working bots and approvals in the notch

leepokai028ca074ecba
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts
index c43a3e12..9dd4a25a 100644
--- a/apps/desktop/src/main/index.ts
+++ b/apps/desktop/src/main/index.ts
@@ -18,6 +18,7 @@ import { registerScreenIPC } from './screen'
import { registerCloud } from './cloud'
import { registerSSH } from './ssh'
import { QuitLifecycle } from './quit-lifecycle'
+import { Island } from './island'
/** macOS's user-facing computer name, else the host name. */
function computerName() {
@@ -210,9 +211,11 @@ if (!app.requestSingleInstanceLock()) {
// would otherwise show Electron's.
if (isMac && !app.isPackaged) app.dock?.setIcon(join(__dirname, '../../resources/icon.png'))
applyDockVisibility()
- const tray = new Tray({ openChat, openPairing, send, host, updates })
+ const island = new Island({ url: rendererURL('island'), preload: join(__dirname, '../preload/index.js'), send, changed: () => tray.hostChanged() })
+ const tray = new Tray({ openChat, openPairing, send, host, updates, island })
updates.on('change', () => tray.hostChanged())
registerIPC(tray)
+ island.register()
registerAuthIPC()
registerSpeech()
registerScreenIPC()
diff --git a/apps/desktop/src/main/island.ts b/apps/desktop/src/main/island.ts
new file mode 100644
index 00000000..8546f05c
--- /dev/null
+++ b/apps/desktop/src/main/island.ts
@@ -0,0 +1,201 @@
+import { execFile } from 'node:child_process'
+import { BrowserWindow, 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'
+
+// Every NSScreen's frame, safe-area top and the menu bar on each side of the notch. JXA reaches
+// AppKit without a helper binary; it runs when the island opens and when displays change.
+const SCREENS = `ObjC.import('AppKit'); JSON.stringify($.NSScreen.screens.js.map((s) => {
+ const top = s.safeAreaInsets.top
+ return { x: s.frame.origin.x, width: s.frame.size.width, top,
+ left: top > 0 ? s.auxiliaryTopLeftArea.size.width : 0, right: top > 0 ? s.auxiliaryTopRightArea.size.width : 0 }
+}))`
+
+/** Linux on Wayland: a window can't place itself at the top of the screen or stay above others. */
+export const islandSupported = process.platform !== 'linux' || process.env.XDG_SESSION_TYPE !== 'wayland'
+
+/**
+ * Linux (X11) only learns where the pointer is from its own windows' events, so it can't poll it
+ * like macOS and Windows do: the window is shaped to the island instead, and the renderer sees
+ * the pointer arrive.
+ */
+const shapedWindow = process.platform === 'linux'
+/** A shrinking shape keeps its old outline until the close animation (0.34 s) is over. */
+const SHRINK_MS = 400
+
+function readScreens(): Promise<NotchScreen[]> {
+ if (process.platform !== 'darwin') return Promise.resolve([])
+ return new Promise((resolve) => {
+ execFile('/usr/bin/osascript', ['-l', 'JavaScript', '-e', SCREENS], { timeout: 5000 }, (error, stdout) => {
+ try {
+ if (error) throw error
+ resolve(JSON.parse(stdout) as NotchScreen[])
+ } catch (e) {
+ // Without the notch's size the island sits at the top edge like on a screen without one.
+ console.error(`island: couldn't read the notch: ${e instanceof Error ? e.message : String(e)}`)
+ resolve([])
+ }
+ })
+ })
+}
+
+interface Deps {
+ url: string
+ preload: string
+ send: (command: WindowCommand, show?: boolean) => void
+ /** The setting changed (the tray's Settings menu shows it). */
+ changed: () => void
+}
+
+/**
+ * The notch island's window: a fixed transparent panel at the top center of
+ * the notch's display. The renderer animates the shape inside it and reports where it is; the
+ * window takes the mouse only over that shape and lets every other click through.
+ */
+export class Island {
+ private window: BrowserWindow | null = null
+ private summary: IslandSummary = { bots: [], permissions: [] }
+ private screen: IslandScreen = { notch: null }
+ private rect: IslandRect = { x: 0, y: 0, width: 0, height: 0 }
+ private inside = false
+ private timer: NodeJS.Timeout | null = null
+ private shaped: IslandRect = { x: 0, y: 0, width: 0, height: 0 }
+
+ constructor(private deps: Deps) {}
+
+ get enabled() {
+ return islandSupported && prefs.get('showIsland') !== false
+ }
+
+ setEnabled(on: boolean) {
+ prefs.set('showIsland', on)
+ this.sync()
+ this.deps.changed()
+ return this.enabled
+ }
+
+ register() {
+ ipcMain.on('island:supported', (e) => (e.returnValue = islandSupported))
+ ipcMain.handle('island:enabled', () => this.enabled)
+ ipcMain.handle('island:setEnabled', (_e, on: boolean) => this.setEnabled(on))
+ ipcMain.handle('island:state', () => ({ screen: this.screen, summary: this.summary }))
+ ipcMain.on('island:summary', (_e, summary: IslandSummary) => {
+ this.summary = summary
+ this.window?.webContents.send('island:summary', summary)
+ })
+ ipcMain.on('island:shape', (_e, rect: IslandRect) => {
+ this.rect = rect
+ if (shapedWindow) this.shape()
+ })
+ ipcMain.on('island:respond', (_e, ref: string, entryId: string, optionId: string) =>
+ this.deps.send({ kind: 'respondPermission', ref, entryId, optionId }, false),
+ )
+ ipcMain.on('island:openBot', (_e, ref: string) => this.deps.send({ kind: 'openBot', ref }))
+ screen.on('display-added', () => void this.place())
+ screen.on('display-removed', () => void this.place())
+ screen.on('display-metrics-changed', () => void this.place())
+ this.sync()
+ }
+
+ private sync() {
+ if (this.enabled) this.open()
+ else this.close()
+ }
+
+ private open() {
+ if (this.window) return
+ const isMac = process.platform === 'darwin'
+ const win = new BrowserWindow({
+ ...PANEL,
+ show: false,
+ frame: false,
+ transparent: true,
+ backgroundColor: '#00000000',
+ hasShadow: false,
+ resizable: false,
+ movable: false,
+ minimizable: false,
+ maximizable: false,
+ fullscreenable: false,
+ focusable: false,
+ skipTaskbar: true,
+ // Lets the panel cover the menu bar.
+ enableLargerThanScreen: true,
+ acceptFirstMouse: true,
+ // macOS: a non-activating panel on every Space and over full-screen apps; Windows: out of Alt+Tab.
+ ...(isMac ? { type: 'panel' } : process.platform === 'win32' ? { type: 'toolbar' } : {}),
+ webPreferences: { preload: this.deps.preload, sandbox: true, contextIsolation: true },
+ })
+ // Above the menu bar on macOS (main menu + 3).
+ win.setAlwaysOnTop(true, isMac ? 'main-menu' : 'screen-saver', isMac ? 3 : 0)
+ if (!isMac) win.setVisibleOnAllWorkspaces(true)
+ // Takes no mouse until the renderer reports the shape.
+ this.rect = { x: 0, y: 0, width: 0, height: 0 }
+ this.shaped = this.rect
+ if (shapedWindow) win.setShape([this.shaped])
+ else win.setIgnoreMouseEvents(true)
+ win.once('ready-to-show', () => win.showInactive())
+ win.on('closed', () => {
+ if (this.window === win) this.window = null
+ })
+ this.window = win
+ this.inside = false
+ void this.place()
+ void win.loadURL(this.deps.url)
+ if (!shapedWindow) this.tick()
+ }
+
+ private close() {
+ if (this.timer) clearTimeout(this.timer)
+ this.timer = null
+ this.window?.destroy()
+ this.window = null
+ }
+
+ /** Top center of the display with the notch, else the main display. */
+ private async place() {
+ if (!this.window) return
+ const screens = await readScreens()
+ const win = this.window
+ if (!win || win.isDestroyed()) return
+ const display = screen.getAllDisplays().find((d) => notchOf(screens, d.bounds)) ?? screen.getPrimaryDisplay()
+ this.screen = { notch: notchOf(screens, display.bounds) }
+ const b = display.bounds
+ win.setBounds({ x: Math.round(b.x + (b.width - PANEL.width) / 2), y: b.y, ...PANEL })
+ win.webContents.send('island:screen', this.screen)
+ }
+
+ /** Linux: the window draws and takes the mouse only over the island. */
+ private shape() {
+ const win = this.window
+ if (!win) return
+ const next = hitRect(this.rect)
+ const grows = next.width * next.height >= this.shaped.width * this.shaped.height
+ if (this.timer) clearTimeout(this.timer)
+ const apply = () => {
+ this.shaped = next
+ if (!win.isDestroyed()) win.setShape([next])
+ }
+ if (grows) apply()
+ else this.timer = setTimeout(apply, SHRINK_MS)
+ }
+
+ /** macOS and Windows: follows the pointer, 60 Hz near the panel and a few times a second elsewhere. */
+ private tick = () => {
+ const win = this.window
+ if (!win || win.isDestroyed()) return
+ const point = screen.getCursorScreenPoint()
+ const bounds = win.getBounds()
+ const x = point.x - bounds.x
+ const y = point.y - bounds.y
+ const inside = hits(this.rect, x, y)
+ if (inside !== this.inside) {
+ this.inside = inside
+ win.setIgnoreMouseEvents(!inside)
+ win.webContents.send('island:hover', inside)
+ }
+ const near = x > -60 && x < bounds.width + 60 && y < bounds.height + 60
+ this.timer = setTimeout(this.tick, near ? 16 : 150)
+ }
+}
diff --git a/apps/desktop/src/main/tray.ts b/apps/desktop/src/main/tray.ts
index e31287a9..79eb66ce 100644
--- a/apps/desktop/src/main/tray.ts
+++ b/apps/desktop/src/main/tray.ts
@@ -5,6 +5,8 @@ import type { HostController } from './host-controller'
import type { Updates } from './updates'
import { setShowInDock, showInDock } from './dock'
import { identity } from './environment'
+import { islandSupported, type Island } from './island'
+import { islandLabel } from '../shared/island'
interface Deps {
openChat: () => unknown
@@ -12,6 +14,7 @@ interface Deps {
send: (command: WindowCommand, show?: boolean) => void
host: HostController
updates: Updates
+ island: Island
}
const resources = () => (app.isPackaged ? process.resourcesPath : join(__dirname, '../../resources'))
@@ -174,7 +177,7 @@ export class Tray {
}
private settingsMenu(): Electron.MenuItemConstructorOptions[] {
- const { host, send } = this.deps
+ const { host, send, island } = this.deps
const s = this.summary
const style = s?.usageIconStyle ?? 'character'
const size = s?.textSize ?? 12
@@ -206,6 +209,7 @@ export class Tray {
},
},
...(process.platform === 'darwin' ? [{ label: 'Show in Dock', type: 'checkbox' as const, checked: showInDock(), click: () => { setShowInDock(!showInDock()); this.rebuild() } }] : []),
+ ...(islandSupported ? [{ label: islandLabel(process.platform), type: 'checkbox' as const, checked: island.enabled, click: () => island.setEnabled(!island.enabled) }] : []),
{ type: 'separator' },
{ label: 'Updates', submenu: this.updatesMenu() },
{ type: 'separator' },
diff --git a/apps/desktop/src/preload/index.ts b/apps/desktop/src/preload/index.ts
index ff212591..4c4be809 100644
--- a/apps/desktop/src/preload/index.ts
+++ b/apps/desktop/src/preload/index.ts
@@ -63,6 +63,19 @@ const bridge: CodyncBridge = {
onEvent: (cb) => listen('speech:event', cb),
},
ssh: sshBridge,
+ island: {
+ supported: ipcRenderer.sendSync('island:supported') as boolean,
+ enabled: () => ipcRenderer.invoke('island:enabled'),
+ setEnabled: (on) => ipcRenderer.invoke('island:setEnabled', on),
+ setSummary: (summary) => ipcRenderer.send('island:summary', summary),
+ state: () => ipcRenderer.invoke('island:state'),
+ onSummary: (cb) => listen('island:summary', cb),
+ onScreen: (cb) => listen('island:screen', cb),
+ onHover: (cb) => listen('island:hover', cb),
+ setShape: (rect) => ipcRenderer.send('island:shape', rect),
+ respond: (ref, entryId, optionId) => ipcRenderer.send('island:respond', ref, entryId, optionId),
+ openBot: (ref) => ipcRenderer.send('island:openBot', ref),
+ },
cloud: {
request: (method, path, body, signed) => ipcRenderer.invoke('cloud:request', method, path, body, signed),
},
diff --git a/apps/desktop/src/renderer/components/Avatar.tsx b/apps/desktop/src/renderer/components/Avatar.tsx
index f49b3c23..653326f5 100644
--- a/apps/desktop/src/renderer/components/Avatar.tsx
+++ b/apps/desktop/src/renderer/components/Avatar.tsx
@@ -105,6 +105,8 @@ interface CharacterProps {
tint?: string
size?: number
mood?: Mood
+ /** Draws for a dark ground whatever the system appearance (the notch island is always black). */
+ dark?: boolean
style?: CSSProperties
}
@@ -112,9 +114,9 @@ interface CharacterProps {
* Grok-Bot-style character drawn like the app icon: an even grid of dots shaded as if the
* silhouette were a ball, with hollow eyes that glance while it works and blink now and then.
*/
-export const CharacterAvatar = memo(function CharacterAvatar({ shape, color, tint, size = 40, mood = 'idle', style }: CharacterProps) {
+export const CharacterAvatar = memo(function CharacterAvatar({ shape, color, tint, size = 40, mood = 'idle', dark: forceDark, style }: CharacterProps) {
const canvas = useRef<HTMLCanvasElement>(null)
- const dark = useDark()
+ const dark = useDark() || forceDark === true
const reduce = useReduceMotion()
const fill = tint ?? avatarColor(color)
diff --git a/apps/desktop/src/renderer/demo/bridge.ts b/apps/desktop/src/renderer/demo/bridge.ts
index 184a2615..7dc9b0a5 100644
--- a/apps/desktop/src/renderer/demo/bridge.ts
+++ b/apps/desktop/src/renderer/demo/bridge.ts
@@ -67,6 +67,19 @@ const bridge: CodyncBridge = {
trustHostKey() {},
chooseKey: async () => null,
},
+ island: {
+ supported: false,
+ enabled: async () => false,
+ setEnabled: async () => false,
+ setSummary() {},
+ state: async () => ({ screen: { notch: null }, summary: { bots: [], permissions: [] } }),
+ onSummary: none,
+ onScreen: none,
+ onHover: none,
+ setShape() {},
+ respond() {},
+ openBot() {},
+ },
cloud: { request: async () => ({ ok: false, error: { status: 503, code: 'demo', message: DEMO_UNAVAILABLE } }) },
updates: { state: async () => updates, onChange: none, check() {}, setAutoCheck() {}, setAutoDownload() {} },
files: { begin: unavailable, write: async () => {}, finish: async () => {}, cancel: async () => {} },
diff --git a/apps/desktop/src/renderer/main.tsx b/apps/desktop/src/renderer/main.tsx
index 66b80a7f..9cfcf27d 100644
--- a/apps/desktop/src/renderer/main.tsx
+++ b/apps/desktop/src/renderer/main.tsx
@@ -2,6 +2,8 @@ import { createRoot } from 'react-dom/client'
import './styles/theme.css'
import { ChatWindow } from './views/ChatWindow'
import { PairingWindow } from './views/PairingWindow'
+import { IslandWindow } from './views/island/IslandWindow'
+import { IslandModel } from './views/island/island-model'
import { AppModel } from './store/app-model'
import { AppContext } from './store/context'
import { applyTextSize, prefs } from './lib/prefs'
@@ -10,13 +12,19 @@ import { account } from './store/account'
const page = new URLSearchParams(location.search).get('window') ?? 'chat'
document.title = window.codync.appName
document.documentElement.dataset.platform = window.codync.platform
+document.documentElement.dataset.window = page
applyTextSize(prefs.textSize.get())
+const root = createRoot(document.getElementById('root')!)
-// The pairing window only needs this computer's host, not a mirror of its bots.
-const app = new AppModel(page !== 'pairing')
-void app.start()
-if (page !== 'pairing') void account.start()
-
-createRoot(document.getElementById('root')!).render(
- <AppContext.Provider value={app}>{page === 'pairing' ? <PairingWindow /> : <ChatWindow />}</AppContext.Provider>,
-)
+if (page === 'island') {
+ // The island only draws what the chat window sends it: no host connection of its own.
+ const island = new IslandModel()
+ island.start()
+ root.render(<IslandWindow model={island} />)
+} else {
+ // The pairing window only needs this computer's host, not a mirror of its bots.
+ const app = new AppModel(page !== 'pairing')
+ void app.start()
+ if (page !== 'pairing') void account.start()
+ root.render(<AppContext.Provider value={app}>{page === 'pairing' ? <PairingWindow /> : <ChatWindow />}</AppContext.Provider>)
+}
diff --git a/apps/desktop/src/renderer/views/ChatWindow.tsx b/apps/desktop/src/renderer/views/ChatWindow.tsx
index 497c62e3..b9a3a79e 100644
--- a/apps/desktop/src/renderer/views/ChatWindow.tsx
+++ b/apps/desktop/src/renderer/views/ChatWindow.tsx
@@ -31,6 +31,7 @@ import { StarPrompt } from './StarPrompt'
import { OpenVoiceSettings } from './call/CallView'
import { AccountPanelLayer, DesktopActionMenu, ProfileAvatar } from './PanelMenus'
import { useTraySummary } from './tray-summary'
+import { useIslandSummary } from './island-summary'
import { useSSH, useSSHAttachments } from './settings/ssh-model'
import './chat-window.css'
import './sidebar-header.css'
@@ -45,6 +46,7 @@ export function ChatWindow() {
const [showAccess, setShowAccess] = useState(false)
const [confirmReset, setConfirmReset] = useState(false)
useTraySummary(app)
+ useIslandSummary(app)
useSSHAttachments(app)
const ssh = useSSH()
const showsChat = shouldShowChat(app.host.state.kind, app.computers.length, ssh.state)
@@ -78,6 +80,13 @@ export function ChatWindow() {
case 'setRemoteScreen':
void app.setRemoteScreen(c.on)
return
+ case 'respondPermission': {
+ const ref = parseRef(c.ref)
+ const store = ref ? app.store(ref.computerId) : null
+ const entry = ref ? store?.allEntries(ref.botId).find((e) => e.id === c.entryId) : undefined
+ if (store && entry) store.respond(entry, c.optionId)
+ return
+ }
}
}),
[app],
diff --git a/apps/desktop/src/renderer/views/island-summary.ts b/apps/desktop/src/renderer/views/island-summary.ts
new file mode 100644
index 00000000..57a8757d
--- /dev/null
+++ b/apps/desktop/src/renderer/views/island-summary.ts
@@ -0,0 +1,65 @@
+import { useEffect } from 'react'
+import type { IslandPermission, IslandSummary } from '@shared/island'
+import { isGroup } from '@shared/models'
+import { useModels } from '../lib/observable'
+import { refKey, type AppModel, type RosterItem } from '../store/app-model'
+import { botDetail } from './tray-summary'
+import { optionLabel, permissionHeadline, sortedOptions } from './thread/PermissionCard'
+
+let sent = ''
+let pending: ReturnType<typeof setTimeout> | null = null
+
+/**
+ * Sends the notch island what it shows when the stores change: at most every 150 ms while
+ * replies stream (reading the stores when it fires), and only when that changed.
+ */
+export function useIslandSummary(app: AppModel) {
+ useModels([...app.stores.values()])
+ useEffect(() => {
+ if (pending) return
+ pending = setTimeout(() => {
+ pending = null
+ const summary = islandSummary(app)
+ const json = JSON.stringify(summary)
+ if (json === sent) return
+ sent = json
+ window.codync.island.setSummary(summary)
+ }, 150)
+ })
+}
+
+function islandSummary(app: AppModel): IslandSummary {
+ const many = app.computers.length > 1
+ 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),
+ })),
+ permissions: app.roster.flatMap(pendingCards),
+ }
+}
+
+/** A conversation's unanswered approval cards; in a group, the member that asks. */
+function pendingCards({ ref, bot, store }: RosterItem): IslandPermission[] {
+ return store
+ .allEntries(bot.id)
+ .filter((e) => e.kind === 'permission' && e.data.status === 'pending')
+ .map((e) => {
+ const author = (e.data.author ? store.bots.get(e.data.author) : undefined) ?? bot
+ return {
+ ref: refKey(ref),
+ entryId: e.id,
+ bot: { name: author.name, shape: author.avatarShape, color: author.avatarColor },
+ 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') })),
+ answering: store.answering.get(e.id) ?? null,
+ }
+ })
+}
diff --git a/apps/desktop/src/renderer/views/island/IslandWindow.tsx b/apps/desktop/src/renderer/views/island/IslandWindow.tsx
new file mode 100644
index 00000000..c318e971
--- /dev/null
+++ b/apps/desktop/src/renderer/views/island/IslandWindow.tsx
@@ -0,0 +1,142 @@
+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 { useModel } from '../../lib/observable'
+import type { IslandModel } from './island-model'
+import './island.css'
+
+const INK = '#f2f2f2'
+
+/** The notch island: a black shape at the top of the screen that grows from 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'
+ return (
+ <div
+ className={`island ${model.growing ? 'growing' : 'shrinking'}`}
+ data-mode={mode}
+ style={{ width: frame.width, height: frame.height }}
+ role={closed ? 'button' : undefined}
+ aria-label={closed ? 'Show bots' : undefined}
+ onClick={closed ? () => model.openNow() : undefined}
+ >
+ <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>
+ </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 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>
+ )
+}
+
+function Approval({ model, card }: { model: IslandModel; card: IslandPermission }) {
+ const count = model.summary.permissions.length
+ return (
+ <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>
+ </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.ts
new file mode 100644
index 00000000..a869c5ab
--- /dev/null
+++ b/apps/desktop/src/renderer/views/island/island-model.ts
@@ -0,0 +1,142 @@
+import {
+ FINISHED_MS, isActive, islandFrame, islandMode, islandRect, justFinished,
+ type IslandBot, type IslandPermission, type IslandScreen, type IslandSummary,
+} 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 island window's state: the chat window's summary, the pointer, and approvals put off. */
+export class IslandModel extends Observable {
+ summary: IslandSummary = { bots: [], permissions: [] }
+ screen: IslandScreen = { notch: null }
+ open = false
+ finished: IslandBot | null = null
+ /** The shape grew on its last change: open with a spring, close without one. */
+ growing = true
+ private hovering = false
+ private deferred = new Set<string>()
+ private content = 0
+ private statuses: Map<string, string> | null = null
+ private hoverTimer: ReturnType<typeof setTimeout> | undefined
+ private finishTimer: ReturnType<typeof setTimeout> | undefined
+ private shape = { width: 0, height: 0 }
+
+ start() {
+ const island = window.codync.island
+ island.onSummary((s) => this.apply(s))
+ island.onScreen((s) => this.update(() => (this.screen = s)))
+ island.onHover((inside) => this.hover(inside))
+ // 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))
+ document.documentElement.addEventListener('mouseleave', () => this.hover(false))
+ }
+ void island.state().then(({ screen, summary }) => {
+ this.screen = screen
+ this.apply(summary)
+ })
+ }
+
+ get mode() {
+ return islandMode(this.summary, { open: this.open, deferred: this.deferred, finished: this.finished !== null })
+ }
+
+ get frame() {
+ return islandFrame(this.mode, this.screen, this.content)
+ }
+
+ /** The approval to answer now: the first not put off, else the first. */
+ get permission(): IslandPermission | null {
+ const cards = this.summary.permissions
+ 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
+ }
+
+ 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)
+ }
+
+ setContentHeight(height: number) {
+ if (height !== this.content) this.update(() => (this.content = height))
+ }
+
+ /** A click on the closed island opens it at once. */
+ openNow() {
+ clearTimeout(this.hoverTimer)
+ if (!this.hovering) this.hoverTimer = setTimeout(() => this.update(() => (this.open = false)), UNATTENDED_MS)
+ this.update(() => (this.open = true))
+ }
+
+ /** Folds the approval away until the island is opened again or another one arrives. */
+ later(card: IslandPermission) {
+ this.update(() => {
+ this.deferred.add(card.entryId)
+ this.open = false
+ })
+ }
+
+ /** 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))
+ }
+
+ openBot(ref: string) {
+ window.codync.island.openBot(ref)
+ clearTimeout(this.finishTimer)
+ this.update(() => {
+ this.open = false
+ this.finished = null
+ })
+ }
+
+ private apply(summary: IslandSummary) {
+ const done = this.statuses ? justFinished(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])
+ })
+ }
+
+ private showFinished(bot: IslandBot) {
+ clearTimeout(this.finishTimer)
+ this.finished = bot
+ this.finishTimer = setTimeout(() => this.update(() => (this.finished = 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 = inside
+ clearTimeout(this.hoverTimer)
+ const delay = inside ? (this.mode === 'hidden' ? 600 : 250) : 500
+ this.hoverTimer = setTimeout(() => this.update(() => (this.open = inside)), delay)
+ }
+
+ private update(change: () => void) {
+ change()
+ const frame = this.frame
+ if (frame.width !== this.shape.width || frame.height !== this.shape.height) {
+ this.growing = frame.width * frame.height >= this.shape.width * this.shape.height
+ this.shape = { width: frame.width, height: frame.height }
+ window.codync.island.setShape(islandRect(frame, window.innerWidth))
+ }
+ this.changed()
+ }
+}
diff --git a/apps/desktop/src/renderer/views/island/island.css b/apps/desktop/src/renderer/views/island/island.css
new file mode 100644
index 00000000..f4ef36c5
--- /dev/null
+++ b/apps/desktop/src/renderer/views/island/island.css
@@ -0,0 +1,189 @@
+/* The island window is a transparent panel: only the black shape is drawn. */
+html[data-window='island'],
+html[data-window='island'] body,
+html[data-window='island'] #root {
+ background: transparent;
+}
+
+/* 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;
+ --scale: 1;
+ position: absolute;
+ top: 0;
+ left: 50%;
+ transform: translateX(-50%);
+ color: var(--text);
+ font-size: 12px;
+ /* 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);
+}
+.island.shrinking {
+ transition: width 0.34s cubic-bezier(0.45, 0, 0.2, 1), height 0.34s cubic-bezier(0.45, 0, 0.2, 1), opacity 0.2s var(--ease);
+}
+/* Resting over the notch (or as a strip at a plain top edge): nothing to see. */
+.island[data-mode='hidden'] {
+ opacity: 0;
+}
+
+.island-body {
+ position: absolute;
+ inset: 0;
+ overflow: hidden;
+ background: #000;
+ transition: border-radius 0.34s var(--ease);
+}
+
+/* Concave corners where the shape meets the top edge, so it flows out of the screen's border. */
+.island-ear {
+ position: absolute;
+ top: 0;
+ width: 8px;
+ height: 8px;
+}
+.island-ear.left {
+ left: -8px;
+ background: radial-gradient(circle at 0 100%, transparent 7.5px, #000 8px);
+}
+.island-ear.right {
+ right: -8px;
+ background: radial-gradient(circle at 100% 100%, transparent 7.5px, #000 8px);
+}
+
+.island-compact {
+ position: absolute;
+ inset: 0 0 auto 0;
+ display: flex;
+ justify-content: space-between;
+}
+.island-wing {
+ width: 36px;
+ display: grid;
+ place-items: center;
+}
+.island-count {
+ font-weight: 600;
+ font-variant-numeric: tabular-nums;
+}
+.island-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: var(--warning);
+ flex: none;
+}
+.island-dot.error {
+ background: var(--danger);
+}
+
+.island-content {
+ position: absolute;
+ left: 50%;
+ transform: translateX(-50%);
+ padding: 6px 14px 0;
+}
+.island-content > * {
+ animation: island-in 0.3s 0.16s var(--ease) backwards;
+}
+@keyframes island-in {
+ from {
+ opacity: 0;
+ filter: blur(6px);
+ transform: scale(0.97);
+ }
+}
+
+.island-list {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+.island-row {
+ 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);
+}
+.island-row:hover {
+ background: rgba(255, 255, 255, 0.08);
+}
+.island-text {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ flex: 1;
+}
+.island-name {
+ font-weight: 600;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.island-detail {
+ color: var(--secondary);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.island-empty {
+ color: var(--secondary);
+ text-align: center;
+ padding: 10px 0;
+}
+
+.island-approval {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+}
+.island-head {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+}
+.island-command {
+ font-family: var(--mono);
+ font-size: 11px;
+ color: var(--secondary);
+ background: #141414;
+ border-radius: 10px;
+ padding: 8px 10px;
+ overflow-wrap: anywhere;
+ display: -webkit-box;
+ -webkit-line-clamp: 3;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+}
+.island-options {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ gap: 8px;
+}
+.island-options .island-deny {
+ color: var(--danger);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .island,
+ .island.shrinking,
+ .island-body {
+ transition: none;
+ }
+ .island-content > * {
+ animation: none;
+ }
+}
diff --git a/apps/desktop/src/renderer/views/settings/SettingsView.tsx b/apps/desktop/src/renderer/views/settings/SettingsView.tsx
index f248cd9c..7cd9b4d1 100644
--- a/apps/desktop/src/renderer/views/settings/SettingsView.tsx
+++ b/apps/desktop/src/renderer/views/settings/SettingsView.tsx
@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react'
import type { UpdateState } from '@shared/ipc'
+import { islandLabel } from '@shared/island'
import { Button, CardForm, CardSection, ChoicePicker, IconButton, Switch, ValueRow } from '../../components/Controls'
import { Icon } from '../../components/Icon'
import { useDismiss } from '../../components/Overlay'
@@ -108,6 +109,8 @@ function GeneralSettings() {
useEffect(() => void window.codync.app.showInDock().then(setShowInDock), [])
const [launchAtLogin, setLaunchAtLogin] = useState(false)
useEffect(() => void window.codync.app.launchAtLogin().then(setLaunchAtLogin), [])
+ const [island, setIsland] = useState(false)
+ useEffect(() => void window.codync.island.enabled().then(setIsland), [])
return (
<CardForm>
@@ -155,6 +158,11 @@ function GeneralSettings() {
</CardSection>
<CardSection title="System">
{window.codync.platform === 'darwin' ? <Switch on={showInDock} onChange={(on) => void window.codync.app.setShowInDock(on).then(setShowInDock)}>Show in Dock</Switch> : null}
+ {window.codync.island.supported ? (
+ <Switch on={island} onChange={(on) => void window.codync.island.setEnabled(on).then(setIsland)}>
+ {islandLabel(window.codync.platform)}
+ </Switch>
+ ) : null}
<Switch on={launchAtLogin} onChange={(on) => void window.codync.app.setLaunchAtLogin(on).then(setLaunchAtLogin)}>
Open at login
</Switch>
diff --git a/apps/desktop/src/renderer/views/thread/PermissionCard.tsx b/apps/desktop/src/renderer/views/thread/PermissionCard.tsx
index 6d5689f7..9da8a4a1 100644
--- a/apps/desktop/src/renderer/views/thread/PermissionCard.tsx
+++ b/apps/desktop/src/renderer/views/thread/PermissionCard.tsx
@@ -4,7 +4,8 @@ import { Disclosure, Spinner } from '../../components/Controls'
import { Icon } from '../../components/Icon'
import { font, px } from '../../lib/fonts'
-const headline = (toolKind?: string) => {
+/** What the agent wants, from the tool's kind (also the notch island's headline). */
+export const permissionHeadline = (toolKind?: string) => {
switch (toolKind) {
case 'execute':
return 'Wants to run a command'
@@ -24,7 +25,10 @@ const headline = (toolKind?: string) => {
const rank: Record<string, number> = { allow_once: 0, allow_always: 1, reject_once: 2, reject_always: 3 }
-function optionLabel(o: PermissionOption) {
+/** Allow before deny, once before always. */
+export const sortedOptions = (options: PermissionOption[]) => [...options].sort((a, b) => (rank[a.kind] ?? 9) - (rank[b.kind] ?? 9))
+
+export function optionLabel(o: PermissionOption) {
switch (o.kind) {
case 'allow_once':
return 'Allow once'
@@ -45,13 +49,13 @@ export function PermissionCard({ entry, hostName, answering, respond }: { entry:
const d = entry.data
const pending = d.status === 'pending'
const hasDetail = !!d.command || !!d.detail || !!d.diffs?.length
- const options = [...(d.options ?? [])].sort((a, b) => (rank[a.kind] ?? 9) - (rank[b.kind] ?? 9))
+ const options = sortedOptions(d.options ?? [])
const cwd = d.cwd ? ` · ${d.cwd.split('/').filter(Boolean).pop() ?? d.cwd}` : ''
return (
<div style={{ paddingRight: 40 }}>
<div style={{ display: 'flex', flexDirection: 'column', gap: 10, padding: 16, background: 'var(--bubble-agent)', borderRadius: 22 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
- <span style={{ ...font('headline'), color: 'var(--text)' }}>{headline(d.toolKind)}</span>
+ <span style={{ ...font('headline'), color: 'var(--text)' }}>{permissionHeadline(d.toolKind)}</span>
{pending ? <span style={{ width: 7, height: 7, borderRadius: '50%', background: 'var(--warning)' }} /> : null}
</div>
<div
diff --git a/apps/desktop/src/renderer/views/tray-summary.ts b/apps/desktop/src/renderer/views/tray-summary.ts
index 25b6da9f..03a133aa 100644
--- a/apps/desktop/src/renderer/views/tray-summary.ts
+++ b/apps/desktop/src/renderer/views/tray-summary.ts
@@ -50,6 +50,11 @@ function avatarIcon(bot: Bot) {
})
}
+/** A bot's line under its name: that it needs you, what it's doing, or its last message. */
+export function botDetail(bot: Bot) {
+ return needsInput(bot) ? 'Needs your response' : isWorking(bot) ? bot.activity || 'Working…' : (bot.lastMessage ?? folderName(bot))
+}
+
/** One usage limit's bar in the provider's color: amber from 70%, red from 90%. */
function barIcon(providerId: string, window: UsageWindow) {
const percent = Math.round(window.percent)
@@ -99,7 +104,7 @@ export function useTraySummary(app: AppModel) {
bots: roster.map((i) => ({
ref: `${i.ref.computerId}/${i.ref.botId}`,
name: app.computers.length > 1 ? `${i.bot.name} · ${i.computer.name}` : i.bot.name,
- detail: needsInput(i.bot) ? 'Needs your response' : isWorking(i.bot) ? i.bot.activity || 'Working…' : (i.bot.lastMessage ?? folderName(i.bot)),
+ detail: botDetail(i.bot),
working: isWorking(i.bot),
avatar: avatarIcon(i.bot),
})),
diff --git a/apps/desktop/src/shared/ipc.ts b/apps/desktop/src/shared/ipc.ts
index ede3155f..21feb3b3 100644
--- a/apps/desktop/src/shared/ipc.ts
+++ b/apps/desktop/src/shared/ipc.ts
@@ -1,6 +1,7 @@
import type { SharedFile } from './models'
import type { SSHBridge } from './ssh'
import type { ScreenAgentState } from './computer-access'
+import type { IslandRect, IslandScreen, IslandSummary } from './island'
// The bridge between the main process (host lifecycle, loopback HTTP, tray, windows)
// and the renderer (stores and UI). Exposed as `window.codync` by the preload script.
@@ -65,6 +66,7 @@ export type WindowCommand =
| { kind: 'search' }
| { kind: 'toggleSidebar' }
| { kind: 'toggleDetails' }
+ | { kind: 'respondPermission'; ref: string; entryId: string; optionId: string }
/** The app's own updates (electron-updater, release builds only). */
export interface UpdateState {
@@ -138,6 +140,22 @@ export interface CodyncBridge {
onEvent(cb: (e: SpeechEvent) => void): () => void
}
ssh: SSHBridge
+ /** The notch island (shared/island.ts): its setting, the chat window's summary, and the island window's side. */
+ island: {
+ /** False where a window can't place itself at the top of the screen (Linux on Wayland). */
+ supported: boolean
+ enabled(): Promise<boolean>
+ setEnabled(on: boolean): Promise<boolean>
+ setSummary(summary: IslandSummary): void
+ state(): Promise<{ screen: IslandScreen; summary: IslandSummary }>
+ onSummary(cb: (summary: IslandSummary) => void): () => void
+ onScreen(cb: (screen: IslandScreen) => void): () => void
+ /** The pointer reached or left the shape. */
+ onHover(cb: (inside: boolean) => void): () => void
+ setShape(rect: IslandRect): void
+ respond(ref: string, entryId: string, optionId: string): void
+ openBot(ref: string): void
+ }
/** The Codync cloud's `/v1` API with the signed-in session (and the device key for `signed`). */
cloud: {
request(method: string, path: string, body: unknown, signed: boolean): Promise<{ ok: true; value: unknown } | { ok: false; error: { status: number; code: string; message: string | null } }>
diff --git a/apps/desktop/src/shared/island.test.ts b/apps/desktop/src/shared/island.test.ts
new file mode 100644
index 00000000..549cfdc1
--- /dev/null
+++ b/apps/desktop/src/shared/island.test.ts
@@ -0,0 +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'
+
+const bot = (ref: string, status: BotStatus): IslandBot => ({ ref, name: ref, shape: 'circle', color: 'blue', status, detail: '' })
+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,
+})
+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('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')
+ // 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')
+})
+
+test('only bots that were working count as finished', () => {
+ const before = new Map<string, BotStatus>([['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'])
+})
+
+test('the notch is the screen width minus the menu bar on both sides', () => {
+ const screens = [
+ { x: 0, width: 1512, top: 32, left: 663.5, right: 663.5 },
+ { x: 1512, width: 2560, top: 0, left: 0, right: 0 },
+ ]
+ assert.deepEqual(notchOf(screens, { x: 0, width: 1512 }), { width: 185, height: 32 })
+ assert.equal(notchOf(screens, { x: 1512, width: 2560 }), null)
+ 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', () => {
+ 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.equal(hits(edge, 360, 0), true)
+ assert.equal(hits(edge, 360, 12), false)
+ assert.equal(hits(edge, 100, 0), false)
+ // Linux shapes the window to this: the strip under the top edge, never above the window.
+ assert.deepEqual(hitRect(edge), { x: 272, y: 0, width: 176, height: 8 })
+ assert.deepEqual(hitRect({ x: 0, y: 0, width: 0, height: 0 }), { x: 0, y: 0, width: 0, height: 0 })
+})
diff --git a/apps/desktop/src/shared/island.ts b/apps/desktop/src/shared/island.ts
new file mode 100644
index 00000000..117891b9
--- /dev/null
+++ b/apps/desktop/src/shared/island.ts
@@ -0,0 +1,147 @@
+import type { BotStatus } 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/).
+
+/** One bot as the island shows it (`ref` = computerId/botId). */
+export interface IslandBot {
+ ref: string
+ name: string
+ shape: string
+ color: string
+ /** A `BotStatus`, or a newer one this app doesn't know. */
+ status: BotStatus | string
+ /** What it's doing, that it needs you, or its last message. */
+ detail: string
+}
+
+export interface IslandOption {
+ id: string
+ label: string
+ allow: boolean
+}
+
+/** A pending approval card: the conversation holding it and the bot asking. */
+export interface IslandPermission {
+ ref: string
+ entryId: string
+ bot: Pick<IslandBot, 'name' | 'shape' | 'color'>
+ headline: string
+ title: string
+ options: IslandOption[]
+ /** The option on its way to the host. */
+ answering: string | null
+}
+
+export interface IslandSummary {
+ bots: IslandBot[]
+ permissions: IslandPermission[]
+}
+
+/** The display the island sits on: the notch's size in points, or null at a plain top edge. */
+export interface IslandScreen {
+ notch: { width: number; height: number } | null
+}
+
+/** The island's shape in its window, in points: the part that takes the mouse. */
+export interface IslandRect {
+ x: number
+ y: number
+ width: number
+ height: number
+}
+
+/** One `NSScreen`: its frame's x and width, the safe area's top inset and the menu bar on each side of the notch. */
+export interface NotchScreen {
+ x: number
+ width: number
+ top: number
+ left: number
+ right: number
+}
+
+export type IslandMode = 'hidden' | 'compact' | 'bots' | 'approval' | 'finished'
+
+/** How long a bot that just finished stays in the island. */
+export const FINISHED_MS = 4000
+/** 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 }
+
+const WING = 36
+const BAR = 28
+
+export const isActive = (b: Pick<IslandBot, 'status'>) => b.status === 'working' || b.status === 'needsInput'
+
+export function islandMode(
+ summary: IslandSummary,
+ { open, deferred, finished }: { open: boolean; deferred: ReadonlySet<string>; finished: boolean },
+): 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'
+}
+
+/** 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) => {
+ const was = before.get(b.ref)
+ return (was === 'working' || was === 'needsInput') && (b.status === 'idle' || b.status === 'error')
+ })
+}
+
+/** Where content starts below the top edge: under the notch, never behind the camera. */
+export const contentTop = (screen: IslandScreen) => screen.notch?.height ?? 10
+
+/** 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) {
+ const notch = screen.notch
+ const gap = notch?.width ?? 0
+ const bar = notch?.height ?? BAR
+ const open = (min: number) => ({ width: Math.max(gap + 2 * WING, min), height: contentTop(screen) + content + 14, radius: 24 })
+ switch (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 }
+ 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)
+ }
+}
+
+/** The shape centered at the top of a `windowWidth`-wide window. */
+export function islandRect(frame: { width: number; height: number }, windowWidth: number): IslandRect {
+ return { x: (windowWidth - frame.width) / 2, y: 0, width: frame.width, height: frame.height }
+}
+
+/** The part of the window that takes the mouse: the shape with `HIT_MARGIN` around it, inside the window. */
+export function hitRect(rect: IslandRect): IslandRect {
+ if (rect.width <= 0) return { x: 0, y: 0, width: 0, height: 0 }
+ const x = Math.max(0, Math.floor(rect.x - HIT_MARGIN))
+ const y = Math.max(0, Math.floor(rect.y - HIT_MARGIN))
+ return { x, y, width: Math.ceil(rect.x + rect.width + HIT_MARGIN) - x, height: Math.ceil(rect.y + rect.height + HIT_MARGIN) - y }
+}
+
+/** Whether a point in window coordinates is on the island. The window's top edge is the screen's, so above it counts too. */
+export function hits(rect: IslandRect, x: number, y: number) {
+ const r = hitRect(rect)
+ return r.width > 0 && x >= r.x && x <= r.x + r.width && y <= r.y + r.height && (r.y === 0 || y >= r.y)
+}
+
+/** The notch of the display at `bounds`, from the screens `NSScreen` reports (same points and x axis). */
+export function notchOf(screens: NotchScreen[], bounds: { x: number; width: number }) {
+ const s = screens.find((s) => s.x === bounds.x && s.width === bounds.width && s.top > 0)
+ const width = s ? s.width - s.left - s.right : 0
+ return s && width > 0 ? { width, height: s.top } : null
+}
+
+/** The setting's name: a notch on the Mac, the top edge elsewhere. */
+export const islandLabel = (platform: string) => (platform === 'darwin' ? 'Show in notch' : 'Show at top of screen')
diff --git a/docs/README.md b/docs/README.md
index b797a203..77232033 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -29,6 +29,7 @@ Source review, a passing build, local integration tests and production acceptanc
- [Voice calls](features/voice-call.md)
- [File attachments](features/file-attachments.md)
- [Remote screen](features/remote-screen.md)
+- [Notch island (desktop)](features/notch-island.md)
- [Marketplace and agent setup](features/marketplace.md)
- [Connector setup and credentials](features/connector-credentials.md)
- [Routines](features/routines.md)
diff --git a/docs/architecture/desktop-app.md b/docs/architecture/desktop-app.md
index 9d24ca95..3537f25b 100644
--- a/docs/architecture/desktop-app.md
+++ b/docs/architecture/desktop-app.md
@@ -24,7 +24,7 @@ determines when there are no earlier messages.
| Path | |
|---|---|
-| `src/main/` | Main process: host service (`host-controller.ts`), loopback HTTP/SSE proxy (`host-proxy.ts`), menu bar/tray, windows, account sign-in (Clerk Frontend API, `account.ts`), cloud API and device key (`cloud.ts`), updates (`updates.ts`), SSH tunnels (`ssh.ts`), Codync Screen agent (`screen.ts`), on-device speech (`speech.ts`), browser sign-in callbacks (`auth.ts`) |
+| `src/main/` | Main process: host service (`host-controller.ts`), loopback HTTP/SSE proxy (`host-proxy.ts`), menu bar/tray, windows, account sign-in (Clerk Frontend API, `account.ts`), cloud API and device key (`cloud.ts`), updates (`updates.ts`), SSH tunnels (`ssh.ts`), Codync Screen agent (`screen.ts`), on-device speech (`speech.ts`), browser sign-in callbacks (`auth.ts`), the [notch island](../features/notch-island.md) window (`island.ts`) |
| `src/preload/` | The `window.codync` bridge (types in `src/shared/ipc.ts`) |
| `src/renderer/store/` | `BotStore` (port of kit's; `bot-store.ts` actions over `bot-sync.ts` events stream and `bot-mirror.ts` state), `AppModel` (window state, approvals), `CloudModel` (claims, cloud default), `AccountSession` |
| `src/renderer/components/` | Design system: controls, overlays (sheets, dialogs, menus), SF Symbol icons, character avatars, thinking orbs |
diff --git a/docs/features/notch-island.md b/docs/features/notch-island.md
new file mode 100644
index 00000000..46262f24
--- /dev/null
+++ b/docs/features/notch-island.md
@@ -0,0 +1,58 @@
+# Notch island (desktop)
+
+The desktop app shows working bots in a black shape at the top center of the screen. On a
+MacBook it grows out of the notch; on a Mac without a notch, and on Windows and Linux, it hangs
+from 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
+setting belongs to the desktop installation (`showIsland` in `host-prefs.json`).
+
+## What it shows
+
+| State | When | Shape |
+|---|---|---|
+| 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 |
+
+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.
+
+## How it works
+
+- **Window** (`apps/desktop/src/main/island.ts`): a fixed 720 × 360 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 and
+ full-screen apps. Windows: a toolbar window (out of Alt+Tab). It never resizes; the shape
+ animates inside it with CSS (spring open, plain close).
+- **Click-through**: the window takes the mouse only over the shape (+8 pt); the renderer
+ reports the shape's target rect on every change. macOS and Windows: the main process polls
+ the pointer (60 Hz near the panel, ~7 Hz elsewhere), toggles `setIgnoreMouseEvents` and tells
+ the renderer when the pointer enters or leaves. Linux (X11) only reports the pointer over the
+ app's own windows, so the window is shaped to the island instead (`setShape`, kept at the old
+ outline until a shrink's animation ends) and the renderer's own mouseenter/mouseleave is the
+ hover.
+- **Notch size**: Electron has no notch API, so `osascript -l JavaScript` reads each
+ `NSScreen`'s `safeAreaInsets.top` and `auxiliaryTopLeftArea` / `auxiliaryTopRightArea`; the
+ notch is the width between them (a 14" MacBook Pro: 185 × 32 pt). It is read again when
+ displays change.
+- **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.
+
+## Platforms and other clients
+
+- **Linux on Wayland**: not available (a window can't place itself at the top or stay above
+ others), so the setting is hidden. On X11 the transparent corners need a compositing window
+ manager (GNOME, KDE and most desktops have one); without one they show as a solid margin.
+- **iPhone**: Live Activities and the Dynamic Island already cover this
+ ([notifications and Live Activities](../design/push-and-live-activity.md)); no change.
+- **Terminal UI**: a terminal can't draw over other apps; its roster already shows working and
+ waiting bots.