Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Desktop Pet
The mini layout and interactions are superseded by Desktop mini v2. Binding, authorization, send ownership, and lifecycle rules below still apply.
Status: in progress (2026-10-04). Delivery is split into three PRs; see "Implementation notes".
Background
Avibe Desktop is a single-window Tauri v2 shell around the Workbench SPA. To talk to an agent the user has to bring that window forward, find the session, and type. Users want a lighter, always-available entry point: summon the agent with a hotkey, speak, see the words appear, and see at a glance whether the agent is working, waiting for them, or done.
Codex ships the same idea as "Pets". Lessons from its reception:
- an animated companion that reflects agent state;
- a global hotkey that opens a quick chat bar with voice;
- a hard off switch that every wake path respects;
- a rebindable hotkey;
- states that stay accurate;
- negligible idle cost.
The long-term target is the main agent: one long-lived session the user talks
to (see 2026-10-01-session-context-rotation.md). Session types do not exist
yet, so v1 binds the pet to any session the user picks. When the main-agent
session type lands, the pet binds to it and the picker goes away.
Concrete example
- The user is in a browser. They press
⌃⌥Space. - The pet, a small character in the screen corner, opens its panel. The mic starts, and the panel shows "Listening".
- The user says "Summarize yesterday's PR reviews and open an issue for anything unresolved." The words stream into the panel as they speak.
- They press
⌃⌥Spaceagain. The text is sent to the bound sessionSthrough the normal message API. The pet switches to Running, and the panel shows the running indicator until the agent's reply lands. - The agent starts a delegated run. The panel's activity strip shows "1 run".
- The user clicks back into the browser. The panel collapses; the pet keeps its running animation.
- The run finishes and the agent replies. The pet switches to Ready and shows a badge. The user clicks the pet, reads the reply, and the badge clears. That is the same "read" that the Workbench sidebar shows.
- If the agent had needed a vault approval, the pet would have shown Needs input, and the panel would have offered "Open in Avibe" for that request.
Scope
In v1:
- a pet window;
- a global hotkey;
- voice and text input to one bound session;
- live state, reply, and Harness progress for that session;
- an off switch.
Not in v1:
- custom or user-generated pets;
- multiple pets;
- binding the pet to more than one session;
- answering approvals inside the pet;
- a hotkey recorder UI.
Design
Window (desktop shell)
The pet is a second native window, label pet. This reopens G8 for one
window kind; see "G8 lifecycle" below.
- It is built by the shell with
WebviewWindowBuilder:transparent,decorations(false),always_on_top;skip_taskbar,visible_on_all_workspaces, not resizable by the user.- macOS transparency needs
app.macOSPrivateApi: true. That rules out the Mac App Store, which Avibe does not ship to.
- It loads
<runtime-origin>/petdirectly. That is the same loopback origin and auth model asmain, which treats loopback requests as local. - Two sizes. Collapsed, the window is only as big as the pet image, so transparent areas around it do not swallow clicks. Expanded, the window grows to fit the panel, anchored at the pet. The panel flips to the side with room near screen edges. The shell performs the resize.
- The user moves it by dragging the pet (
start-dragging). The mini drags through the shell instead, so Vibey can reach the top of the display and the column can flip below it; see the mini spec §9.1. - Position is the pet anchor, not the window frame. The window's origin
moves whenever the panel opens to the left or above the pet. A raw window
position saved while expanded would restore the collapsed pet displaced by
the panel's size. So the persisted value is the pet anchor: the pet image's
top-left in logical screen coordinates, plus its monitor.
- The shell owns it, because the shell lays out both sizes and knows the pet's offset inside the window. It is recomputed from the window origin and that offset when a drag ends, whether collapsed or expanded.
- It is stored as
anchorinpet.json. On restore it is clamped into a connected monitor's work area. - The window-state plugin stays filtered to
main. Its per-label frame (desktop-window-state.md) fits windows whose frame is the user's choice; the pet's frame is derived from the anchor, so the anchor is what is persisted.pet.jsonalready exists for pet preferences, so this adds no new store.
G8 lifecycle invariants
These are the multi-window invariants that G8 said must ship with the first extra window:
- Only
mainbootstraps.petis remote from its first frame. It never loads the bootstrap page and is granted no bootstrap capability; existing capability files stay keyed tomain. petexists exactly when the pet is enabled and a Runtime is ready. One shell function,pet_reconcile(), owns that invariant: it creates the window if it should exist and is missing, and destroys it if it should not exist. It runs on Runtime ready and stop, on a preference change, and at the start of every wake. No other path creates or destroyspet. A Runtime origin change (a changedui.setup_port) returns the shell to bootstrap, so the pet is destroyed and then recreated at the new origin by the same function.- An OS close request on
pet(for exampleAlt+F4on Windows) is prevented and hides the pet, asmainalready does for itself. Turning the pet off goes through the tray switch, not the window's close. If the window is lost anyway, the next wake recreates it throughpet_reconcile(). - Closing or destroying
petnever stops the Runtime and never quits the app. Single-instance hand-off and deep links keep targetingmain. - Navigation in
petis confined to the Runtime origin and the/petpath, so the pet can never become a second Workbench. New-window requests are denied, as they are inmain. - The notification focus gate stays
main-only, unchanged. Pet visibility does not suppress native notifications in v1.
Shell ↔ pet IPC
The IPC surface is kept minimal. It is granted to window pet for the remote
loopback origin only, through a new capability file:
- command
pet_ready() -> {binding, revision, summon_pending: null | {intent}}, which the route calls once/pethas mounted and its listeners are installed. It returns the current binding and consumes any summon that arrived before the page was ready, so a summon that recreated the window is never lost; - event
pet:summon {intent: 'listen' | 'show'}, sent from the shell to the pet when a wake happens and the page is ready. Beforepet_ready(), the shell records the summon as pending instead of emitting it, because Tauri events have no replay; a later summon replaces a pending one; - command
pet_set_expanded(expanded: bool) -> PetLayout, to resize and anchor the window. The shell is the only owner of placement, because only it knows the monitor work area and the anchor. It returns the layout it chose,{panel_side: left | right, panel_edge: top | bottom, pet_offset}, and the route renders the pet and panel from that value. The native frame and the DOM therefore share one placement decision; - command
pet_bind(session_id) -> {binding, revision, shown}and eventpet:bound {session_id, revision}, which set and carry the session binding (see Session binding). The pet usespet_bindfor its switcher; a call frommainalso wakes the pet; - command
pet_unbind(session_id) -> {binding, revision}, a compare-and-clear: it clears the binding only if it is stillsession_id, so a late result about an old session can never clear a newer one; - every binding the shell reports carries
revision, a counter it raises by one on each change. The page applies a report only if its revision is newer than the last one it applied, so apet:boundand a command answer that cross can never leave the older binding shown; a report without a revision is rejected; - command
pet_open(link), which takes any link the existing deep-link parser (desktop-deep-links.md) accepts: session, Show Page, settings, and vault request. It focusesmainthrough the same path a clicked deep link uses. The pet gets no new routing logic; anything the parser rejects is dropped; - permission
start-dragging.
main gets one command, pet_bind, through its own new capability file for
the remote loopback origin. It is the "Show in pet" action. No other main
capability changes.
Everything else the pet needs comes from the Runtime HTTP and SSE API, exactly as it does for the Workbench.
Global hotkey and off switch
- Add
tauri-plugin-global-shortcut. This is a new dependency, recorded indesktop/src-tauri/Cargo.tomlin the implementing PR. The shell registers the shortcut in Rust, so no JS plugin package is needed. - Default shortcut.
⌃⌥Spaceon macOS,Ctrl+Alt+Spaceon Windows. The common alternatives are taken:⌥Spaceis the Codex and ChatGPT summon key on macOS, andAlt+Spaceopens the window menu on Windows. - Rebinding. v1 has a tray submenu of presets, plus a
shortcutfield in the pet preferences file. A recorder UI is a follow-up. - Registration failure. If the OS refuses the shortcut, for example because another app holds it, the failure is shown in the tray submenu. It is never swallowed.
- One wake function. Every wake path (hotkey, tray item, "Show in pet",
any future one) calls
pet_wake(intent). It checks the enabled flag first, runspet_reconcile()so a missing window is recreated, then shows the pet and delivers the summon with its intent: emitted at once if the page is ready, otherwise recorded as pending forpet_ready().listencomes only from the hotkey, the one explicit request to talk.showcomes from every display or navigation path (tray item, "Show in pet"). It shows and expands the pet on the bound session and never starts capture.
- Off switch. A tray
CheckMenuItem"Show pet", next to "Notifications". Off destroys the window and unregisters the shortcut, so nothing can wake it. - Preferences.
pet.jsoninapp_local_data_dir, the same pattern asnotifications.json:{version: 1, enabled?, shortcut?, anchor?, binding?}. All durable pet state lives here.enabledis written only by the tray switch. An absentenabledmeans "use this build's default", so writes of the anchor or binding never freeze the default.- The default is off in the shell-and-state build and on from the voice build. A user who never touched the switch therefore gets the pet when voice ships, and a user who turned it off stays off.
- Only an absent file gets the build default. A file that is present but
unreadable, or has an unknown
version(for example after a downgrade), fails closed: the pet is disabled for this run with a warning, and the shell does not rewrite the file, so a newer build's state and a user's opt-out both survive. Toggling the tray switch is the explicit recovery: it writes a fresh version-1 file. The app never fails to start because ofpet.json. - Load fixtures cover an absent file (build default), a file without
enabled(build default), an explicitfalse, an unreadable file (disabled, file untouched), and an unknown version (disabled, file untouched).
Pet route (web UI)
/pet is a new route in the same SPA.
- It sits inside
AuthGuardand the existing providers (Api, Inbox), but outsideAppShell, so it has no sidebar or chrome. The transparentpet-windowstyle is installed by a route shell around the guard, so a loading or authorization recheck never paints an opaque body into the native window. AuthGuard itself returns nothing, not its usual loading surface, while/petis waiting on a session. Draft, in-flight send, and per-session send-uncertainty live in a document store so the same recheck cannot drop a lock or the text that belongs to it. /petis exempt fromAuthGuard's setup redirect. Before setup is complete, it renders its own setup-pending state ("Finish setting up in Avibe", which callspet_open("avibe://settings");main's own guard then shows setup) and stays on/pet. So a default-on pet on a fresh install never becomes a pet-sized setup wizard.- The pet leaves setup-pending by re-reading the authoritative setup check
(the same
getConfigresultAuthGuarduses), not by waiting for a notification: finishing the wizard inmaingives the pet no route change and no cross-window event. While setup-pending, the pet re-reads on everypet:summon, on window focus, and on becoming visible. Every way the user returns to the pet (hotkey, tray, clicking it) is one of these, so the first interaction after setup finds the completed setup and mounts the normal pet, with no restart. - It reuses the provider's single
EventSource('/api/events'). That is one connection per window. The server has no per-session filter, so the route filters onsession_idon the client.
Input freshness. The SSE broker is an in-memory fan-out with no replay, and some state changes publish no event at all. So every input the pet derives from needs three things: an initial read, a live trigger, and a gap fallback. The table is the contract. Its rules:
- Any trigger re-reads the authoritative API; events are hints, never state.
- The pet reads its own session
Sdirectly. It does not rely on a provider havingScached: a fresh pet window's providers only hold what their own bootstrap fetched, which is not the sessionmainpicked. - A trigger counts only if it is published after the state it signals is persisted. Each row below was checked against the publishing code for that ordering.
- A server-derived projection is not filtered by session on the client. When
an event's payload cannot say whether it touches
S, the pet re-reads on every event of that family, coalesced to one in-flight read plus one trailing read.AgentsPageandAgentGraphTabalready refresh this way onruns.updated.
| Input | Initial read | Live trigger | Gap fallback |
|---|---|---|---|
Message tail (latest exchange, quick_replies) |
listSessionMessages(S, {tail: true, cache: false}) |
message.new for S (merged, deduped by id) |
onConnected; window becomes visible |
quick_reply_chosen |
in the tail rows | message.updated for S, replacing the row by id, as the chat page already does. The Runtime starts publishing it for this field (see note) |
as above |
Turn state (foreground, in_flight, background_activities) |
GET /api/sessions/S/turn-state |
turn.start, turn.end, queue.updated for S; every runs.updated and every definitions.updated, unfiltered and coalesced |
onConnected; visible; the chat page's interval reconcile while work is present and the window is visible |
| Pending vault requests | usePendingVaultRequests |
vaults.updated (useVaultRequestRefresh) |
expiry timer; onConnected |
Session row (status, agent_status) |
getSession(S, {cache: false}) |
session.status for S, applied to the pet's own copy; any session.activity for S re-reads the row |
onConnected; visible: re-read getSession(S) |
| Unread count | Inbox provider unread_by_session, which its bootstrap reads for every session |
inbox.unread.changed |
provider's own onConnected |
Two notes on the table:
- Quick replies. Today the server records
quick_reply_chosenon the agent row only after the dispatch returns, and publishes no row update. The user message'smessage.newandqueue.updatedare emitted during dispatch (_publish_materialized_delivery), so they can arrive before the choice is persisted, and a re-read on them can race. The fix is at the Runtime layer: whenset_quick_reply_chosennewly records a choice, the messages endpoint publishesmessage.updatedwith the updated agent row after the write commits. Every window then closes the group from one ordered event, and the Workbench gains the same cross-tab lock for free. The window that clicked also locks optimistically, asQuickRepliesdoes today. This is a small server change in the shell-and-state PR, with a pytest that the event follows the write. - Turn state. The chat page already owns the subtle part: a grace window
after a local send, and an interval reconcile (60 s while working, 10 s while
background work is present) that recovers a dropped
turn.endwithout ever clearing a live turn on a timer. That logic is extracted fromChatPage.tsxinto a shareduseSessionTurnState(S)hook used by both, rather than re-implemented. The pet adds two unfiltered triggers.background_activitiesis a projection built from two sources: watch and task definitions bound toS, and delegated runs whosecallback_session_idisS. Neither event names that ownership.definitions.updatedis instance-scoped, andruns.updatedcarries the executor'ssession_id, which for a delegated run is by design notS. So the pet re-reads turn-state on every event of both families, and a first delegated run, watch, or task appears in the strip at once. The interval runs only while work is present and the window is visible, so an idle pet does no network work.
Session binding. The binding is durable pet state, so it lives where the
rest of the pet's durable state lives: binding in the shell-owned
pet.json. Browser storage is scoped to the Runtime origin, which changes
when the user changes the UI port, so it cannot own anything durable.
- The Workbench chat page's "Show in pet" action calls
pet_bind(S). It is offered only where the chat page's composer is: it is hidden wheneverisSessionReadOnly(session)(sessionArchived.ts) is true. - A bind from
mainalso shows the pet: after persisting, the shell runspet_wake('show'), the same single wake path as the hotkey with a display-only intent, so a pet hidden by an OS close reappears without opening the microphone.pet_bindreturns{shown}; when the pet is off, the binding is still saved andmainshows a toast pointing to the tray's "Show pet" switch. A bind from the pet's own switcher does not wake, since the pet is already visible. - The panel's compact recent-session switcher calls
pet_bindthe same way. Its rows come from the globallistSessions({status: 'active', limit: 20})(GET /api/sessionswith no project, newest first), filtered by the sameisSessionReadOnlypredicate. It is read when the switcher opens, and re-read onsession.activityandonConnectedwhile it is open, so a new session with no reply yet is listed. - The shell writes
pet.jsonand emitspet:boundto the pet. On load, the pet reads the binding frompet_ready(). Every report is ordered by its revision, and the pet's own picks and clears are sent one at a time in the order the user made them. - A binding is valid only while
Sis a writable session, by the chat page's own predicate:getSession(S)succeeds andisSessionReadOnly(session)is false. That rejects archived sessions and Runtime-owned system sessions such as the workspace-notices session, whose messages endpoint always refuses a send. Every read ofgetSession(S)checks this, on bind, on gaps, and on anysession.activityforS(archive, move, and the rest are all published there). When the read returns a read-only session or404, the route callspet_unbind(S)and shows the empty state with the switcher, so the pet never accepts input it cannot send. The rule is checked on the read, not tied to a particular event kind. - Every asynchronous read is fenced by binding and by order. Each source
(session, tail, turn state, vault requests, and the switcher's session
list) keeps a generation counter.
Starting a read, and merging a live event into that source, both bump it. A
read carries the session id and the generation it started at, and its
result is applied only if the session is still the binding and no newer
read or live merge has happened on that source since; otherwise it is
dropped. A live merge that invalidates an in-flight read schedules one
trailing read, so the source still converges on the server's state.
- Across bindings, a switch from
AtoBnever showsA's state, and a late404forAcannot clearB: the route drops it, andpet_unbind(A)would be a no-op in the shell anyway. - Within one binding, a tail read started before a quick-reply
message.updatedcannot land after it and reopen the group. - The switcher list is not tied to a binding, so it is fenced by
generation only: an older
listSessionsresponse cannot overwrite a newer refresh that already lists a new session.
- Across bindings, a switch from
- When the main-agent session type lands, the route resolves the main-agent session instead, and the switcher is removed.
Pet state
One pure function, derivePetState(inputs), unit-tested in Vitest. Each input
comes from an API the Workbench already uses:
| State | Condition | Source |
|---|---|---|
| Needs input | pending vault request for S (quick replies do not count; see note below) |
GET /api/vault/requests?status=pending&session=S (usePendingVaultRequests, refreshed on vaults.updated and expiry) |
| Blocked | agent_status = failed |
getSession(S) and session.status (see Input freshness) |
| Ready | foreground idle and unread_count > 0 |
inbox.unread.changed (unread_by_session) |
| Running | turn_state.foreground = running or in_flight |
turn.start/turn.end with GET /api/sessions/S/turn-state, as the chat page does |
| Idle | none of the above |
- Priority. Needs input > Blocked > Ready > Running > Idle, as in Codex.
- Background work. Delegated runs, watches, and tasks
(
turn_state.background_activities) do not change the state. The panel shows them as an activity strip, and the collapsed pet shows a count. The pet is "Running" only when the agent itself is working. - Other conversations move the pose only. When the bound session is
Idle (or nothing is bound) and an agent is mid-turn in any other
conversation the user can see, the avatar shows the Running pose and does
not fall asleep. The state, the panel, the badge and
data-statestill describe the bound session alone, so the panel never claimsSis running.- "Working" means an
activeinstance of aforegroundsession in the running-agents snapshot (GET /api/running-agents, the Agents page's source), on any surface. Background runs, Runtime-owned sessions and session-less processes do not count; an unreachable snapshot counts as nothing working. - It is read only with
can_use_agents. It is re-read on every event that can change an input of the rule, declared once asREFRESH_TRIGGERS: agent state (turn.start,turn.end,session.status,runs.updated), a session's visibility or existence (session.activity), what the reader may see (authorization changes), and gaps (reconnect, page return). A 30-second reconcile while visible covers IM turns and agents that stop without an event. turn.startis published before the backend registers the agent as active, so a started session is re-read every 2 seconds until the snapshot shows it active, itsturn.endarrives, or 30 seconds pass.derivePetPose(state, {othersWorking, asleep})is the pure rule; the bound session's non-Idle states always win.
- "Working" means an
- Reading. The pet marks read only what it rendered. The expanded panel
renders every unread agent result in the loaded tail, oldest first, in a
scrollable list, rather than only the latest one.
- It then calls the existing
POST /api/sessions/S/mark-readwithuntil_message_idset to the last row it rendered (markSessionRead(S, untilMessageId)). Ready clears in the pet and in the Workbench together. - A result that lands after rendering, for example from a queued turn, stays unread and keeps the badge.
- If the unread rows reach past the loaded tail — including when the
inbox count is ahead of the unread results in that tail — the panel
does not mark read at all. It shows "More in Avibe" (
pet_openwith the session link) and leaves reading to the Workbench.
- It then calls the existing
Quick replies never change the state. Agents end most replies with a quick-reply group, so treating an unanswered group as Needs input left a bound session in Needs input almost every time it was idle, and the state stopped meaning "the agent cannot go on without you". Quick replies are suggestions: the panel offers the open group as buttons, and answering one is a normal send. Needs input is reserved for a wait that blocks the agent, which today is a pending vault request.
The panel's open group (openQuickReplies) is the latest agent result's
group, while unanswered. This is a deliberate difference from the Workbench,
which keeps every unanswered group clickable regardless of age
(workbench-quick-replies.md): once a newer agent result exists the agent has
moved on, so the pet offers only the current group and older groups stay
clickable in the Workbench, reached with "Open in Avibe". A group is also
answered by any user input after it (a row whose type lists user in the
catalog's inputAuthors; a display-only Show Page annotation is not input).
This keeps the panel computable from the bounded tail, with no history scan.
Tool approvals and AskUserQuestion-style waits do not exist today. Claude
runs with permissions bypassed and Codex auto-approves, so vault requests are
the complete "needs input" set for now. A future backend that asks the user
must add its source to derivePetState.
Panel
Expanded, top to bottom:
- Live transcript while listening, then an editable input that is always available for typing.
- Latest exchange. The last user message and the unread agent results (or
the last one, when none are unread), from
the durable tail plus
message.newforS, rendered with the existing message renderer in a compact variant. Replies are not streamed: the Runtime persists an agent reply atomically as one result row, and there is no reply-delta event. While the turn runs, the panel shows the running indicator and the activity strip; the reply appears when its row lands. Token streaming would be a new Runtime transport and is a follow-up. - Activity strip for
turn_state.background_activities, reusing the chat page's strip in a compact variant. - Needs input and suggestions. Pending vault requests, and the open
quick-reply group as buttons. Quick replies are answered in place, through
the same path
QuickRepliesuses. Vault requests get "Open in Avibe" (pet_openwith the request's vaults link), because approval UI stays in the Workbench in v1.
Sending uses the same POST /api/sessions/S/messages call as the composer. A
message sent while a turn is running is queued by the server, exactly as in the
Workbench. The pet shows "Queued" and offers no steering control in v1.
Interaction
- Hotkey tap with the pet collapsed or hidden (
listenintent). Show the pet, expand it, focus it, and start listening. If voice is unavailable, focus the text input instead. Focus waits until the native frame has grown and the composer is on screen (a cold load still waits on the session grant). The listen request lives in the document store so an AuthGuard recheck cannot drop it. - No valid binding (none chosen yet, or cleared after an archive). The hotkey opens the panel on the session switcher and does not start listening or accept input, so nothing is ever captured without a destination.
- Hotkey tap while listening. Stop and send the transcript.
- Esc. Cancel listening, or collapse the panel if not listening.
- Click into the transcript while listening. Stop listening and keep the
text for editing;
Entersends. - Click the pet. Toggle the panel.
- Panel blur. Collapse, unless listening or the input has unsent text.
Voice
Reuse the composer's pipeline unchanged:
getUserMediafeedingVoiceRecordingPipeline, withclaimVoiceCapturefor single ownership (extended across windows, below);VoiceRealtimeSessionfor the live preview (preview.text + preview.stash) and final text;- the existing HTTP transcription fallback.
The capture and transcribe logic in Composer.tsx is extracted into a shared
hook used by both the composer and the pet. That is the second and third
consumer, together with Show Page dictation, so extraction is justified now.
Voice is available only when GET /api/asr/status reports available, which
needs Avibe Cloud. Otherwise the hotkey opens text input and the panel shows
a short hint that voice needs Avibe Cloud. That is a new i18n string; the
composer just hides its mic button.
Cross-window mic ownership. claimVoiceCapture keeps its owner in a
module variable, so it arbitrates only inside one JavaScript realm. main and
pet are separate realms: a hotkey summon while the composer is dictating
would start a second recorder. The claim is extended across same-origin realms
with the Web Locks API, which already gives one total order across them, so no
home-made protocol has to resolve simultaneous claims:
- Claiming requests the lock
avibe.voice-capturewithsteal: trueand holds it for the life of the capture. - The lock manager grants steals in order, so the newest claim always holds the lock, even when two realms claim within the same instant.
- A realm whose lock is stolen sees its request reject with
AbortError. It finishes its local owner through the samefinish()callback a local replacement uses, so captured speech is preserved, exactly as today. releasereleases the lock. Local semantics (isCurrent,release) are unchanged.- The pet never captures without the cross-window guarantee. If
navigator.locksis missing in the pet's webview, pet voice is turned off: the hotkey still summons the pet and focuses the text input, and the mic control is hidden. A browser tab keeps today's local-only behavior, since there is no second desktop realm there. Single ownership acrossmainandpetis therefore never silently dropped.
This lives in claimVoiceCapture itself, so every caller (composer, Show Page
dictation, pet) inherits it, and two Workbench browser tabs gain the same
guarantee. The shell is not involved, so the pet capability file stays as
listed. Lock sharing between the two webviews depends on their sharing one
origin data store, which is verified during implementation (see Risks).
The microphone usage string and audio-input entitlement already ship (#2293).
Rendering and idle cost
v1 art is the existing mascot, Vibey (歪比).
assets/mascot/already holds one pose per state, each a 1024 px PNG with a transparent background, so no new art is drawn:Pet state Pose Idle cloud-tuanzi.png;cloud-tuanzi-sleep.pngafter a few idle minutesListening cloud-tuanzi-focus.pngRunning cloud-tuanzi-thinking.pngReady cloud-tuanzi-celebrate.png, with the unread badgeNeeds input cloud-tuanzi-message.pngBlocked cloud-tuanzi-error.pngThe UI bundles downscaled copies (2x the collapsed display size) under
ui/src/assets/pet/; the 1024 px sources stay the masters.Motion. One pose per state, brought to life with CSS only: a slow breathing float, and a short cross-fade with a small squash on a state change. No sprite sheet, canvas, WebGL, or JS animation loop. A frame-based sprite sheet is a later upgrade if the stills feel flat.
Pausing. Animation pauses when the window is hidden or the document is not visible. Idle breathing stops after a short time.
prefers-reduced-motionshows the still pose and swaps it without motion.Design. The collapsed pet and the panel frames are designed in
../avibe-docs/design.penwith the existing tokens before the UI implementation. All copy goes throughui/src/i18n/en.jsonandzh.json.
Delivery
- Shell and state.
- Runtime: publish
message.updatedwhen a quick-reply choice is recorded; petwindow and its lifecycle invariants;- IPC surface;
- global shortcut, tray toggle and presets,
pet.json; /petroute with binding,derivePetState, collapsed and expanded panel;- text send, latest exchange, activity strip;
- "Show in pet";
- Vibey poses and CSS motion, and panel frames in
design.pen, so the first PR already looks finished.
- Runtime: publish
- Voice. Shared dictation hook extracted from the composer; listening flow in the pet. The pet is enabled by default from this PR on.
Tests
- Pytest: recording a quick-reply choice publishes
message.updatedfor the agent row after the write commits, and only when the choice is newly recorded. - Rust (
desktop/src-tauri/tests/shell_boundaries.rs):petgets no bootstrap command;- pet capabilities grant only the listed command, event, and permission;
- navigation outside
/petis denied; - destroying
petleaves the Runtime running andmainintact; - disabling unregisters the shortcut, and every wake path is a no-op while disabled;
- an OS close request on
pethides it, and a wake after the window is lost recreates it throughpet_reconcile(); - the saved anchor is the pet image position whichever side the panel opened on, and a restore onto a missing monitor is clamped on screen;
pet_set_expandedreturns the layout it applied, near each screen edge, and calls are applied in the order they were made, so a late collapse cannot overtake a later expand. The page sendspet_set_expandedone at a time in that same order, and still keeps only the answer to its latest request;pet_bindpersists topet.jsonand emitspet:bound, and the binding survives a Runtime origin change; every change raises the revision by one, andpet_ready,pet_bind,pet_unbindandpet:boundall carry it;maingains onlypet_bind, andpetis granted exactlypet_ready,pet_set_expanded,pet_bind,pet_unbind,pet_open, the two events, andstart-dragging;pet_unbind(A)is a no-op when the binding isB;- a wake that recreates the window delivers the summon through
pet_ready(), and a summon to a ready page is emitted once; - the hotkey wakes with
listen, and the tray item and "Show in pet" wake withshow; a pending summon keeps its intent throughpet_ready(); pet.jsonload fixtures: absent file, noenabled, explicitfalse, unreadable file; an absentenabledfollows the build default and an explicitfalsesurvives the default change.
- Vitest:
derivePetStatecovers every row and the priority order;- session binding through
pet_ready()andpet:bound; the switcher goes throughpet_bindand an invalid binding throughpet_unbind; switching fromAtoBwhileA's reads are in flight, withA's results (including a404) arriving after the switch, leavesBbound and shows onlyB's state; - a tail read started before a
message.updatedand resolved after it is dropped, the chosen row stays, and one trailing read follows; - "Show in pet" on a hidden, enabled pet binds and shows it, and on a disabled pet saves the binding and shows the tray toast;
- an older switcher
listSessionsresponse that resolves after a newer refresh is dropped; - "Show in pet" is hidden for archived and system sessions, a persisted binding to the workspace-notices session is cleared on load, and the switcher lists a new active session that has no reply yet and omits read-only ones;
- an open quick-reply group is offered in the panel but leaves the state Idle, and only a pending vault request derives Needs input; an older unanswered group under a newer agent result is not offered; the hotkey with no valid binding opens the switcher and never starts capture;
- before setup is complete,
/petrenders its setup-pending state and is not redirected to/setup; - with setup completed in another window, the next summon, focus, or visibility change re-reads setup and leaves setup-pending;
- Setup scenario: the shell-and-state PR adds a scenario to
tests/scenarios/auth_setup/catalog.yamlwith a closed-loop case intest_auth_setup_scenarios.py: on a fresh install the pet is setup-pending, setup is completed through the wizard, and the next summon shows the normal pet without a restart. The scenario ID goes in that PR's description;- the route renders the pet and panel from each
PetLayoutorientation; - with several unread results, all are rendered and mark-read passes the last rendered row; a result that arrives after rendering stays unread; unread rows past the loaded tail are not marked;
- each row of the input-freshness table: the initial read on bind, each live trigger, and each gap fallback re-read the authoritative API, and live rows merge without duplicates;
- a
message.updatedrow carryingquick_reply_chosencloses the group; - a freshly bound session that is already failed derives Blocked from
getSession(S), with no provider row present; - any
runs.updated, including one whosesession_idis the executor and notS, and anydefinitions.updatedre-read turn-state, and a burst coalesces to at most one in-flight and one trailing read; - the extracted
useSessionTurnStatekeeps the chat page's existing turn-state tests passing; - a stolen voice lock finishes the local owner and preserves its speech;
- without
navigator.locks, the pet hides the mic and the hotkey focuses text input instead of starting capture; two claims made at the same time leave exactly one owner, the later one;releasefrees the lock; - an archived or missing bound session clears the binding, from the
initial read and after
session.activity; - hotkey summon starts voice only when ASR is available;
- a
showsummon, including from "Show in pet", never starts capture.
- the route renders the pet and panel from each
- Manual sanity on a signed macOS build and on Windows:
- transparency;
- always on top over full-screen apps;
- drag and position restore: drag while expanded with the panel flipped left or up, quit, relaunch, and the collapsed pet is where it was seen;
- first-use mic prompt in the pet window;
- starting dictation in the pet while the composer dictates stops the composer's recorder;
- shortcut conflict reporting.
Risks to verify during implementation
- Shared Web Locks. Confirm that
mainandpetshare one origin data store, and therefore Web Locks, on both WKWebView and WebView2. Until this is confirmed for a platform, pet voice stays off there (the gate above). If a platform does not share them, the shell arbitrates voice claims in the order it receives them before pet voice is enabled there. - Mic prompts. WKWebView may prompt for the mic separately in the second webview. Confirm that the prompt appears once and is remembered.
- Full-screen Spaces. On macOS, appearing over full-screen apps may need
the
FullScreenAuxiliarycollection behavior, beyondvisible_on_all_workspaces. - Hidden windows. Confirm that a hidden Tauri window reports the document as hidden, so animation and polling pause.
- Focus. Summoning focuses the pet so that typing works. Confirm that the previously active app gets focus back when the panel collapses.
Implementation notes
Decisions made while building, where the code is simpler than the text above. The code and its tests are the contract; this section records why.
Three PRs instead of one for delivery 1. (a) the Runtime
message.updatedfor quick-reply choices (#2357); (b) the/petroute, state, panel, poses and i18n; (c) the shell: window, IPC, shortcut, tray,pet.json, and "Show in pet". The pet stays invisible until (c) lands, so (a) and (b) ship nothing a user can see./petsits insideAuthGuardwith a setup-redirect exemption only. It keeps the login and authorization gates, andSETUP_REDIRECT_EXEMPT_PATHSexempts it from the wizard redirect only. It is not a diagnostics-style bypass (SETUP_CHECK_BYPASS_PATHS), so it never renders without a session: if the first session probe fails, the guard keeps loading and checks again each time the page comes back, and the pet always runs with its authorization. Its own setup gate (usePetSetup) applies the same rule through the sharedisSetupCompleteand shows "finish setting up in Avibe" instead of a pet-sized wizard. The route stays outside the Workbench chrome. The setup re-read bypasses the config cache (getConfig({ cache: false })). Composing is shown only when both the instancecan_chatand the bound session's projectcapabilities.can_chatare true. The session GET carries that flag with the same role rule as bootstrap (get_effective_session_role+ editor); unknown or failed reads deny. The pet does not load bootstrap.Shell → page events are DOM events. The shell dispatches
avibe:pet-summonandavibe:pet-boundonwindowthrough a shell-evaluated script, the channel the Settings… menu already uses, so the pet needs no Tauri event permission. Page → shell stays Tauri commands. The contract lives inui/src/pet/petBridge.ts.One summon store per document.
petShell.tsinstalls the listeners from the first frame, before setup is known, and keeps the latest summon until the pet surface takes it. A summon during setup-pending re-reads setup and is then acted on, so a hotkey is never lost to loading order.PetLayouthas nopet_offset. The route places the pet and panel frompanel_sideandpanel_edgealone; the shell owns the offset.No
useSessionTurnStateextraction. The chat page's turn logic is interleaved with its Agent Activity buffer, so extracting it would be a risky refactor of the chat page for a consumer that needs less. The pet keeps the same rules inusePetSession: the authoritativeGET /turn-state, the same reconcile cadences, and the 4 s post-send grace.Generation fencing is one class,
FencedSource, used by every source including the switcher list. A key change frees the in-flight slot at once, so switching sessions never waits on the old session's read.The shell's revision orders bindings. The page never infers order from arrival:
pet_ready(),pet:bound, and the answers to its own picks and clears are applied only when newer than the last report it applied. Its own changes are shown at once and queued, so a second pick is not sent before the first is answered; when none is outstanding, it shows exactly what the shell last reported. A failed pick shows the shell's binding again. A failed clear is not undone, since re-showing an invalid session would only fail validation and clear it again.An unknown send result is not a failure. As in the chat composer (
useNewSession), a send counts as refused only for400,403,404,409or422. Any other failure (a network error, a5xx, adispatch_pending502/504) may have been admitted, so the pet keeps the draft, hides quick replies, closes input for that session and offers "Open in Avibe"; opening the session there is how the user finds out, and lifts it. Each session keeps its own lock, so inspecting B does not reopen A. The lock lifts only afterpet_opensucceeds; a failed open leaves it. Draft, in-flight send, those locks, and a pending listen-focus live outside React so an AuthGuard recheck cannot drop them. A listen summon focuses the input only after the panel has grown and the composer is on screen.The panel opens after the shell grows the frame. Closing hides it at once; opening waits for
pet_set_expandedto succeed, so replies are never marked read while still clipped. Native resizes are sent one at a time in the order they were asked, matching the shell's call-order contract, and only the latest request updates React. A failed request restores the last confirmed expansion, so a redundant expand of an already-open panel cannot hide it. Expansion lives inpetPanelso the setup-pending card grows the native frame too; until it confirms, only the avatar is shown. The setup-pending summon listener is stable, so a still-pending summon is not replayed into an expand/recheck loop.Read-marking waits for a tail snapshot. Live rows that arrive before the first tail read lands say nothing about older unread rows, so the pet treats the tail as having older rows until a read has landed. A live row or unread change that arrives with no snapshot yet also starts that first read; a mark-read in any window re-reads the bound session's tail so
read_atis not stale when the next result lands.Setup is monotonic. One wake runs several setup reads (a summon also focuses the window). Any read that sees setup complete wins; an incomplete answer applies only from the latest read; a failure only settles the first check and never turns a known state back.
An authorization change drops what was read under the old one. The session, tail, turn state and switcher rows are cleared at once and re-read. Pending vault requests do the same in the shared
usePendingVaultRequests(so the chat page gets it too), and the inbox has its own handler. Asession.statusevent that arrives with no session row starts a read instead of patching nothing.Mark-read answers are ordered in the inbox provider. A newer mark-read or read-changing event for a session supersedes an older answer for it, and the account-wide unread map in an answer is adopted only if no other write or snapshot has committed since the write began; otherwise only that session's count is merged.
design.penframes are deferred. The panel reuses existing tokens and primitives; frames follow once the shell PR makes the pet visible.Pet input uses the session GET's project grant. Workbench Chat combines instance
can_chatwith bootstrapcapabilities.can_chat. The pet already reads the session row, so GET/api/sessions/<id>now includes the same{capabilities:{can_chat}}sibling (the session fields stay top-level; the client stripscapabilitiesbefore treating the rest as the row). An instance editor who is a project viewer therefore sees state but no composer or quick replies; POST remains rejected by project-role middleware.The shell's window has one owner, and the pet keeps no copy of the Runtime.
reconcile_nowalone creates and destroyspet: the window exists exactly when the pet is on and the Workbench shows a Runtime, at that Runtime's origin. The Shell'sactive_originis the one record of that Runtime, andset_active_origin, its only writer, reconciles the pet, so every path that hands the Workbench a Runtime or takes it away (handoff, return to bootstrap, explicit stop,mainrecreated) moves the pet with it. The first review rounds found two call sites that forgot to tell an earlier pet-side copy; removing the copy closes that class rather than the instances. Every wake runs on the main thread and checks the switch first.pet_bindandpet_openmove their window work off the IPC callback, because creating a window inside one deadlocks on Windows.Commands check their caller twice. The
petcapability (andmain-pet-bindfor the Workbench) only grants literal-loopback pages, and each command checks again that its caller is the pet window on its own/petpage, or, forpet_bind, themainwindow on the active Runtime. The Workbench learns "Show in pet" exists from a top-level__AVIBE_DESKTOP_PET__marker, so an older shell never offers it.A summon before any Runtime waits as
show. The shortcut is live from launch and the tray can turn the pet on during bootstrap, before a window can exist. Such a summon is kept for the first page and delivered asshowwith the window focused, so the pet answers once the Runtime is ready, but a key pressed during a startup that can take a while never opens the microphone long after. A Runtime that goes away first drops it.The shortcut plugin is pinned to 2.3.
tauri-plugin-global-shortcut2.4 requires Tauri 2.12;~2.3keeps the locked Tauri 2.11 and adds only the hotkey crates to the lock file. Lift the pin with the Tauri upgrade.Placement has one coordinate space per platform. macOS places every window in one space of points. Windows and Linux place windows on one physical desktop, and the pet window's scale changes as it crosses displays, so the saved anchor is that desktop divided by the primary display's scale, both when saving and restoring, and the restored window is positioned in physical pixels. In that space each display carries a
unit, the length of one of its own points: the pet's extent, its default margin, its centre and the window's padding are all scaled by the unit of the display they are measured on, so a pet clamped onto a denser display stays whole. (Review found positions normalized but the extent not; every quantity measured in the stored space now goes through the unit.) The anchor saved after a drag settles (400 ms) is the pet's own top-left corner, rounded, with the display's name; it is clamped back onto a connected display when the window is built.⌃⌥Spacecan collide with macOS input-source switching. It is the default "Select next source in Input menu" shortcut, which many users with a second input method keep. The default stays as specified; a refused registration shows in the tray, and the presets are the way out.Scenario.
AUTH-SETUP-128stays partial: its packaged two-window journey is a manual check on the built shell. "Show in pet" has no scenario catalog of its own; the session-actions tests cover it.
Follow-ups
- Bind to the main-agent session when the session type lands, and remove the picker.
- Custom pets: an image or sprite format and an importer.
- Frame-based sprite animation for Vibey.
- A hotkey recorder in Settings.
- Hold-to-talk using shortcut press and release states.
- Streaming agent replies, once the Runtime has a reply-delta transport.
- Approvals inside the pet.
Todo
- Update G8 and G10 in
desktop-product-gaps.mdto point here. - Pet window, lifecycle invariants, capability file, and IPC.
- Global shortcut, tray toggle and presets,
pet.json. -
/petroute, session binding, and "Show in pet". -
derivePetStatewith Vitest coverage. - Panel: latest exchange, activity strip, needs input, text send.
- Input-freshness table for the pet route (
usePetSession,FencedSource). - Shared dictation hook; cross-window voice claim; pet listening flow.
- Vibey pose assets, CSS motion, i18n strings.
- Panel frames in
design.pen. - Rust boundary tests.
- Manual checks on macOS and Windows.
- User docs:
desktop/README.mdpet section.