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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(desktop): mini switcher goes back, surfaces drop clipped shadows, dock shows on hover (#2592)
Max0967a5f0a050
diff --git a/desktop/runtime-host/src/pet.rs b/desktop/runtime-host/src/pet.rsindex 4afbf36d2..3c7eb59e4 100644--- a/desktop/runtime-host/src/pet.rs+++ b/desktop/runtime-host/src/pet.rs@@ -551,6 +551,17 @@ pub struct HitRect {pub y: f64,pub width: f64,pub height: f64,+ /// Part of the page's hover zone (Vibey and its dock). Absent from older+ /// pages, which then get no hover events.+ #[serde(default)]+ pub hover: bool,+}++/// Whether the cursor is over the page's hover zone. The shell reports this to+/// the page because a webview in a window that is not key (the pet never takes+/// focus on its own) receives no hover on macOS.+pub fn hovering(rects: &[HitRect], x: f64, y: f64) -> bool {+ rects.iter().any(|rect| rect.hover && rect.contains(x, y))}impl HitRect {pub fn valid(&self) -> bool {@@ -655,6 +666,7 @@ mod tests {y: 20.0,width: 30.0,height: 40.0,+ hover: false,};assert!(rect.valid());assert!(rect.contains(10.0, 20.0));@@ -674,6 +686,19 @@ mod tests {assert!(!HitRect { height: -1.0, ..rect }.valid());}+ #[test]+ fn only_hover_rects_make_the_cursor_hover_and_older_pages_omit_the_flag() {+ let rects: Vec<HitRect> = serde_json::from_str(+ r#"[{"x":0,"y":0,"width":100,"height":50},{"x":0,"y":60,"width":100,"height":50,"hover":true}]"#,+ )+ .unwrap();+ assert!(!rects[0].hover);+ assert!(!hovering(&rects, 50.0, 25.0));+ assert!(hovering(&rects, 50.0, 80.0));+ assert!(!hovering(&rects, 50.0, 55.0));+ assert!(!hovering(&[], 50.0, 80.0));+ }+#[test]fn releasing_a_shortcut_during_page_load_never_replays_a_held_microphone() {let directory = TestDirectory::new();diff --git a/desktop/src-tauri/src/pet.rs b/desktop/src-tauri/src/pet.rsindex 01d762f96..d05aae899 100644--- a/desktop/src-tauri/src/pet.rs+++ b/desktop/src-tauri/src/pet.rs@@ -16,9 +16,9 @@ use std::time::Duration;use avibe_runtime_host::deep_link::parse_deep_link;use avibe_runtime_host::pet::{- anchor_from_window, area_for, clamp_anchor, default_anchor, rescale, restored_window_origin, shortcut_label,- valid_session_id, window_size, HitRect, LogicalRect, PetAnchor, PetBinding, PetIntent, PetLayout, PetReady,- PetStore, WorkArea, SHORTCUT_PRESETS,+ anchor_from_window, area_for, clamp_anchor, default_anchor, hovering, rescale, restored_window_origin,+ shortcut_label, valid_session_id, window_size, HitRect, LogicalRect, PetAnchor, PetBinding, PetIntent, PetLayout,+ PetReady, PetStore, WorkArea, SHORTCUT_PRESETS,};use avibe_runtime_host::LoopbackOrigin;use serde::{Deserialize, Serialize};@@ -35,6 +35,7 @@ pub const SHORTCUT_MENU_PREFIX: &str = "pet-shortcut:";const PET_PATH: &str = "/pet";const SUMMON_EVENT: &str = "avibe:pet-summon";const BOUND_EVENT: &str = "avibe:pet-bound";+const HOVER_EVENT: &str = "avibe:pet-hover";/// A drag settles before its anchor is saved, as the main window's frame does.const MOVE_SETTLE: Duration = Duration::from_millis(400);@@ -661,6 +662,9 @@ fn start_cursor_poll(app: &AppHandle) {let app = app.clone();tauri::async_runtime::spawn(async move {let mut ignoring = true;+ // Hover the page cannot see itself: a webview in a window that is+ // not key gets no hover on macOS. Reported only when it changes.+ let mut hovered = false;loop {let handle = app.clone();let (send, receive) = tokio::sync::oneshot::channel();@@ -674,7 +678,10 @@ fn start_cursor_poll(app: &AppHandle) {return;};if !window.is_visible().unwrap_or(false) {- let _ = send.send((None, ignoring));+ if hovered {+ dispatch(&window, HOVER_EVENT, &serde_json::json!({ "hover": false }));+ }+ let _ = send.send((None, ignoring, false));return;}let (Ok(cursor), Ok(origin), Ok(scale), Ok(size)) = (@@ -683,27 +690,37 @@ fn start_cursor_poll(app: &AppHandle) {window.scale_factor(),window.inner_size(),) else {- let _ = send.send((Some(100), ignoring));+ let _ = send.send((Some(100), ignoring, hovered));return;};let x = (cursor.x - origin.x as f64) / scale;let y = (cursor.y - origin.y as f64) / scale;let in_window =x >= 0.0 && y >= 0.0 && x < size.width as f64 / scale && y < size.height as f64 / scale;- let next = !lock(&pet.hit_regions).iter().any(|rect| rect.contains(x, y));+ let (next, hover) = {+ let regions = lock(&pet.hit_regions);+ (+ !regions.iter().any(|rect| rect.contains(x, y)),+ in_window && hovering(®ions, x, y),+ )+ };if next != ignoring && window.set_ignore_cursor_events(next).is_ok() {ignoring = next;}- let _ = send.send((Some(if in_window { 16 } else { 100 }), ignoring));+ if hover != hovered {+ dispatch(&window, HOVER_EVENT, &serde_json::json!({ "hover": hover }));+ }+ let _ = send.send((Some(if in_window { 16 } else { 100 }), ignoring, hover));}).is_err(){break;}- let Ok((delay, applied)) = receive.await else {+ let Ok((delay, applied, hover)) = receive.await else {break;};ignoring = applied;+ hovered = hover;if let Some(delay) = delay {tokio::time::sleep(Duration::from_millis(delay)).await;} else {@@ -900,6 +917,7 @@ mod tests {y: 20.0,width: 100.0,height: 50.0,+ hover: false,});};seed();diff --git a/docs/plans/2026-10-12-desktop-mini-main-agent.md b/docs/plans/2026-10-12-desktop-mini-main-agent.mdindex 60a19e840..ba3542d61 100644--- a/docs/plans/2026-10-12-desktop-mini-main-agent.md+++ b/docs/plans/2026-10-12-desktop-mini-main-agent.md@@ -77,9 +77,15 @@ the main agent; there is no Follow up on cards.- **No backing panel on the desktop (owner decision, 2026-10-12).** Theexpanded list sits in a transparent wrapper with 6px padding (kept so thewidths in §3.1 hold). Cards float directly over the desktop, separated by- their own border and shadow. The gaps between cards show the wallpaper and+ their own border. The gaps between cards show the wallpaper andpass clicks through (§9.2). The prototype keeps a page-coloured plate onlyto hide the web page's own text behind it (§12).+- **No shadows on any mini surface (owner decision, 2026-10-14).** Cards, the+ switcher, the dock, the marquee and the input bubble separate from the+ desktop by their border alone. A shadow overflows its box, and the scroll+ box, the speech slot and the stack/list swap all clip it, so it showed as a+ grey rectangle behind the switcher and the input and flashed as a square+ during the swap.- **Scroll box:** **fixed height** of about 3.5 cards (prototype **292px**),horizontal padding 12px. The half card at the bottom signals "more".- Hidden scrollbar: `scrollbar-width: none`, plus `::-webkit-scrollbar@@ -118,7 +124,7 @@ the main agent; there is no Follow up on cards.| Part | Spec ||---|---|-| Container | Radius 28px; padding 20px × 14px; background `#2a2a2e`; border 1px `white / 8%`; shadow `0 18px 50px rgba(0,0,0,.45)`. |+| Container | Radius 28px; padding 20px × 14px; background `#2a2a2e`; border 1px `white / 8%`; no shadow (§3.2). || Title | 15px, semibold, tight tracking, white, one line, ellipsis. The full text is the tooltip. || Subtitle | 13px, `white / 45%`, 2px below the title, one line, ellipsis, with the full text as the tooltip. While running it has a 6px pulsing dot (`emerald-400`) before the text. || × (dismiss) | Expanded list only, never on the main agent card. 20px circle at the top-left corner, offset −6px/−6px. Background `#3a3a3e`, glyph 11px `white / 70%`; on hover `#4a4a50` with a white glyph. Sits above the card content. |@@ -131,8 +137,11 @@ the main agent; there is no Follow up on cards.- **Position:** always the first card, collapsed or expanded. It cannot bedismissed and has no stop button in this version.-- **Eyebrow:** "MAIN AGENT" above the title, 2px gap.- - 10px, semibold, uppercase, tracking 0.14em.+- **Eyebrow:** the agent's name above the title, 2px gap: "Vibey" / "歪比"+ as written, no forced uppercase (owner decision, 2026-10-14). The fallback+ title and the input placeholder ("Message Vibey…" / "和歪比说…") name+ Vibey the same way; "main agent" is never shown to the user.+ - 11px, semibold, normal case and tracking.- Light green at 80%: map to the theme's mint token; the prototype used`emerald-300`.- It names the card type, not the speaker.@@ -209,7 +218,7 @@ the main agent; there is no Follow up on cards.transform 260ms settle) and ignores the pointer. It comes back whendictation ends.- **Dock:** a pill under Vibey's feet that overlaps the image by 12px.- - Background `#2a2a2e`, padding 4px, shadow `0 8px 24px rgba(0,0,0,.45)`.+ - Background `#2a2a2e`, padding 4px, border 1px `white / 8%`, no shadow.- Two 32px buttons with a 4px gap and a 1px × 16px `white / 10%` hairlinebetween them:- **mic** starts or stops dictation; it turns solid rose with a stop@@ -219,6 +228,12 @@ the main agent; there is no Follow up on cards.- Hidden by default. It fades and rises in (opacity 180ms ease, transform220ms settle, from `translateY(-6px) scale(.92)`) on hover over Vibey orthe dock, or on keyboard focus.+ - Hover comes from the shell: on macOS a webview gets no hover while its+ window is not key, and the pet never takes focus by itself. The page marks+ the rects of Vibey and the dock `hover: true` in `pet_hit_regions`; the+ cursor poller (§9.2) sends `avibe:pet-hover { hover }` when the cursor+ enters or leaves them, and the page shows the dock while it is set. CSS+ `:hover` still applies where the webview does see hover.- It stays visible while dictating or typing, and is always visible ondevices without hover (`@media (hover: none)`).@@ -235,14 +250,14 @@ the main agent; there is no Follow up on cards.- the content fades and rises (opacity 180ms; `translateY(8px)scale(.97)` → rest over 300ms settle; 60ms delay on open);- closing reverses both;- - the slot clips while it moves, then unclips once open so shadows show;+ - the slot clips while it moves, then unclips once open;- a closed slot stays mounted but `inert`.### 5.3 Marquee (live transcript)- **Look:** one line, the same width as a card.- Pill: background `#2a2a2e`, padding 8px vertical, 12px left, 16px right,- shadow `0 12px 32px rgba(0,0,0,.45)`.+ no shadow.- A 10px pulsing rose dot on the left, then 13px white text.- **Text:** the realtime preview from the existing pipeline(`VoiceRealtimeSession` preview text + stash).@@ -261,9 +276,9 @@ the main agent; there is no Follow up on cards.- **Opens** after dictation, prefilled; or from the keyboard button, empty.Either way it gets focus.- **Look:** the same width as a card, radius 22px, background `#2a2a2e`,- border `white / 10%`, padding 6px (14px left), shadow as the marquee.+ border `white / 10%`, padding 6px (14px left), no shadow.- **Textarea:** one line by default, auto-grows to 4 lines (96px), 13px,- placeholder "和 main agent 说…".+ placeholder "和歪比说…".- **Buttons, right side:**- a 32px mic (`white / 10%`) that dictates more and appends;- a 32px send button: white with a black up-arrow SVG; `white / 10%` and@@ -502,6 +517,12 @@ Until the `main` type exists, the mini's main agent is a Vibey conversation`409 no_chat_project`, and the mini asks the user to create a Project.- **Binding.** The mini binds that session whenever nothing is bound. Anexisting binding is kept; the switcher offers "和歪比对话" to move to it.+- **Switcher navigation.** The switcher opens only from "切换会话", or by+ itself when nothing is bound. While a session is bound it has a "返回"+ control that goes back to the cards, and collapsing the panel leaves it. A+ bound session with nothing to show (no exchange, no sub-tasks) expands to the+ "切换会话" control alone, never to the switcher, so picking such a session+ does not reopen the list.A session the mini already bound and then cleared as invalid is notre-bound automatically, so a bad answer cannot loop.- **A turn Vibey cannot run is shown.** When the latest exchange ended in a@@ -563,7 +584,7 @@ Until the `main` type exists, the mini's main agent is a Vibey conversationthe end; recomputed on resize.- [ ] Cards, marquee and bubble share one width. A long title truncates andnever widens a card.-- [ ] Main card: "MAIN AGENT" eyebrow; mint border; `#34343b` background;+- [ ] Main card: "Vibey" / "歪比" eyebrow; mint border; `#34343b` background;16px after it; no ×; no stop; no avatar.- [ ] Clicking the main card opens and closes the detail inside the fixedbox (280ms). The detail has the latest exchange, mark-read, More indiff --git a/ui/e2e/pet-mini/layout.spec.ts b/ui/e2e/pet-mini/layout.spec.tsindex 431f81e17..4b59245eb 100644--- a/ui/e2e/pet-mini/layout.spec.ts+++ b/ui/e2e/pet-mini/layout.spec.ts@@ -97,3 +97,80 @@ test('the session picker keeps every row at its text height and scrolls', asyncconst scroll = await page.locator('.pet-mini-scroll').evaluate((node) => ({ client: node.clientHeight, content: node.scrollHeight }));expect(scroll.content).toBeGreaterThan(scroll.client);});++test('no mini surface casts a shadow the transparent window would clip', async ({ page }) => {+ await page.goto('/e2e/pet-mini/fixture.html?main=true&layers=2&sessions=4');+ await expect(page.locator('.pet-mini-collapsed')).toBeVisible();+ // Every mini rule, rendered or not (input bubble, marquee, setup card): the+ // window clips a shadow to a visible box while content moves.+ const ruleShadows = await page.evaluate(() => {+ const found: string[] = [];+ const visit = (rules: CSSRuleList) => {+ for (const rule of Array.from(rules)) {+ if (rule instanceof CSSStyleRule && rule.selectorText.includes('pet-mini')) {+ const value = rule.style.boxShadow || rule.style.filter;+ if (value && value !== 'none') found.push(`${rule.selectorText}: ${value}`);+ }+ if ('cssRules' in rule) visit((rule as CSSGroupingRule).cssRules);+ }+ };+ for (const sheet of Array.from(document.styleSheets)) visit(sheet.cssRules);+ return found;+ });+ expect(ruleShadows).toEqual([]);+ const shadowed = () => page.evaluate(() => Array.from(document.querySelectorAll<HTMLElement>('.pet-mini-stage *'))+ .filter((node) => getComputedStyle(node).boxShadow !== 'none')+ .map((node) => node.className.toString()));+ expect(await shadowed()).toEqual([]);+ await page.locator('.pet-mini-collapsed').click();+ await page.locator('.pet-mini-card[role=button]').click();+ await page.getByRole('button', { name: 'Switch session' }).click();+ await expect(page.locator('.pet-mini-session-option')).toHaveCount(5);+ expect(await shadowed()).toEqual([]);+});++test('the switcher goes back to the cards', async ({ page }) => {+ await page.goto('/e2e/pet-mini/fixture.html?main=true&layers=0&sessions=3');+ await page.locator('.pet-mini-collapsed').click();+ await page.locator('.pet-mini-card[role=button]').click();+ await page.getByRole('button', { name: 'Switch session' }).click();+ await expect(page.locator('.pet-mini-session-option')).toHaveCount(4);+ const back = page.getByRole('button', { name: 'Back' });+ expect(await back.evaluate((node) => getComputedStyle(node).borderTopStyle)).toBe('solid');+ await back.click();+ await expect(page.locator('.pet-mini-session-option')).toHaveCount(0);+ await expect(page.locator('.pet-mini-card.is-main')).toBeVisible();+});++test('Vibey and its dock are reported as the hover zone, and a shell hover shows the dock', async ({ page }) => {+ await page.goto('/e2e/pet-mini/fixture.html?main=true&layers=0');+ const dock = page.locator('.pet-mini-dock');+ await expect(page.locator('.pet-mini-avatar-button')).toBeVisible();+ await expect.poll(() => page.evaluate(() => {+ const avatar = document.querySelector('.pet-mini-avatar-button')!.getBoundingClientRect();+ const x = avatar.left + avatar.width / 2, y = avatar.top + avatar.height / 2;+ return window.petLayoutHitRegions.filter((rect) => rect.hover).some((rect) =>+ x >= rect.x && x < rect.x + rect.width && y >= rect.y && y < rect.y + rect.height);+ })).toBe(true);+ // Cards take the mouse but are not part of the hover zone.+ await expect.poll(() => page.evaluate(() => {+ const card = document.querySelector('.pet-mini-collapsed .pet-mini-card')!.getBoundingClientRect();+ const x = card.left + card.width / 2, y = card.top + card.height / 2;+ return window.petLayoutHitRegions.some((rect) => rect.hover && x >= rect.x && x < rect.x + rect.width && y >= rect.y && y < rect.y + rect.height);+ })).toBe(false);+ // The macOS shell reports hover itself: an unfocused window's webview gets none.+ await page.mouse.move(0, 0);+ await expect(dock).toHaveCSS('opacity', '0');+ await page.evaluate(() => window.dispatchEvent(new CustomEvent('avibe:pet-hover', { detail: { hover: true } })));+ await expect(dock).toHaveCSS('opacity', '1');+ await page.evaluate(() => window.dispatchEvent(new CustomEvent('avibe:pet-hover', { detail: { hover: false } })));+ await expect(dock).toHaveCSS('opacity', '0');+});++test('the main card names Vibey as written', async ({ page }) => {+ await page.goto('/e2e/pet-mini/fixture.html?main=true&layers=0');+ const eyebrow = page.locator('.pet-mini-collapsed .pet-mini-eyebrow');+ await expect(eyebrow).toBeVisible();+ // innerText applies text-transform, so this is what the user reads.+ expect(await eyebrow.evaluate((node) => node.innerText)).toBe('Vibey');+});diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex ad88c7759..4f7462469 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -5625,15 +5625,15 @@"chooseSession": "Choose a session","switchSession": "Switch session","openInAvibe": "Open in Avibe",- "inputPlaceholder": "Message the main agent…",+ "inputPlaceholder": "Message Vibey…","send": "Send","queued": "Queued — it will run after the current turn.","moreInAvibe": "More replies in Avibe","empty": "No messages yet. Say something to get started.","vaultRequest": "Approval needed — open in Avibe","noSessions": "No active sessions yet. Start one in Avibe.",- "mainAgent": "Main agent",- "mainAgentTitle": "Main agent",+ "mainAgent": "Vibey",+ "mainAgentTitle": "Vibey","thinking": "Thinking","waiting": "Waiting","repliedPrefix": "Replied:",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 44a188b85..0be7dc05e 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -5625,15 +5625,15 @@"chooseSession": "选择一个会话","switchSession": "切换会话","openInAvibe": "在 Avibe 中打开",- "inputPlaceholder": "和 main agent 说…",+ "inputPlaceholder": "和歪比说…","send": "发送","queued": "已排队,当前这轮结束后执行。","moreInAvibe": "更多回复请在 Avibe 中查看","empty": "还没有消息,说点什么开始吧。","vaultRequest": "需要授权,在 Avibe 中打开","noSessions": "还没有进行中的会话,先在 Avibe 里新建一个。",- "mainAgent": "MAIN AGENT",- "mainAgentTitle": "主 agent",+ "mainAgent": "歪比",+ "mainAgentTitle": "歪比","thinking": "思考中","waiting": "等待中","repliedPrefix": "已回复:",diff --git a/ui/src/pet/PetPage.test.tsx b/ui/src/pet/PetPage.test.tsxindex c6d9ca45d..5363ac612 100644--- a/ui/src/pet/PetPage.test.tsx+++ b/ui/src/pet/PetPage.test.tsx@@ -15,7 +15,7 @@ import type {import { ApiError } from '@/context/ApiContext';-import { PET_BOUND_EVENT, PET_SUMMON_EVENT } from './petBridge';+import { PET_BOUND_EVENT, PET_HOVER_EVENT, PET_SUMMON_EVENT } from './petBridge';vi.mock('react-i18next', () => ({useTranslation: () => ({ t: (key: string) => key }),@@ -1947,15 +1947,72 @@ describe('desktop mini v2 interaction contract', () => {devBind('S'); render(<PetPage />);await waitFor(() => expect(api.listSessionMessages).toHaveBeenCalledWith('S', expect.anything()));summon('show');- if (hasBackgroundWork) {- expect(await screen.findByText('watch:w1')).toBeTruthy();- fireEvent.click(await screen.findByText('pet.switchSession'));- }+ if (hasBackgroundWork) expect(await screen.findByText('watch:w1')).toBeTruthy();+ // An empty bound session is not the picker: it shows the switch control.+ expect(screen.queryByText('Another session')).toBeNull();+ fireEvent.click(await screen.findByText('pet.switchSession'));fireEvent.click(await screen.findByText('Another session'));await waitFor(() => expect(devBinding().binding).toBe('B'));expect(await screen.findAllByText('Session B')).toHaveLength(2);});+ it('picking a session with nothing to show leaves the switcher instead of reopening it', async () => {+ tails.S = [message('u', 'S', { author: 'user', type: 'user' }), message('r', 'S')];+ tails.B = [];+ switcherSessions = [session('B', { title: 'Another session' })];+ devBind('S'); render(<PetPage />);+ await showDetail();+ fireEvent.click(await screen.findByText('pet.switchSession'));+ fireEvent.click(await screen.findByText('Another session'));+ await waitFor(() => expect(devBinding().binding).toBe('B'));+ await waitFor(() => expect(api.listSessionMessages).toHaveBeenCalledWith('B', expect.anything()));+ await act(async () => new Promise((resolve) => setTimeout(resolve, 20)));+ expect(screen.queryByText('Another session')).toBeNull();+ expect(screen.getByText('pet.switchSession')).toBeTruthy();+ });++ it('goes back from the switcher with the back control, and a collapse leaves it', async () => {+ tails.S = [message('u', 'S', { author: 'user', type: 'user' }), message('r', 'S')];+ switcherSessions = [session('B', { title: 'Another session' })];+ devBind('S'); render(<PetPage />);+ await showDetail();+ fireEvent.click(await screen.findByText('pet.switchSession'));+ expect(await screen.findByText('Another session')).toBeTruthy();+ fireEvent.click(screen.getByText('common.back'));+ await waitFor(() => expect(screen.queryByText('Another session')).toBeNull());+ expect(document.querySelector('.pet-mini-card.is-main')).toBeTruthy();+ expect(devBinding().binding).toBe('S');++ fireEvent.click(screen.getByText('pet.switchSession'));+ expect(await screen.findByText('Another session')).toBeTruthy();+ fireEvent.click(screen.getByLabelText('pet.toggle'));+ await waitFor(() => expect(screen.getByLabelText('pet.toggle').getAttribute('aria-expanded')).toBe('false'));+ fireEvent.click(screen.getByLabelText('pet.toggle'));+ await waitFor(() => expect(screen.getByLabelText('pet.toggle').getAttribute('aria-expanded')).toBe('true'));+ expect(screen.queryByText('Another session')).toBeNull();+ expect(document.querySelector('.pet-mini-card.is-main')).toBeTruthy();+ });++ it('offers no back control when nothing is bound', async () => {+ canChat = false;+ switcherSessions = [session('B', { title: 'Another session' })];+ render(<PetPage />);+ summon('show');+ expect(await screen.findByText('Another session')).toBeTruthy();+ expect(screen.queryByText('common.back')).toBeNull();+ });++ it('shows the dock while the shell reports hover over Vibey, and reports that zone', async () => {+ devBind('S'); render(<PetPage />);+ const wrap = (await screen.findByLabelText('pet.toggle')).closest('.pet-mini-avatar-wrap')!;+ expect(wrap.hasAttribute('data-pet-hover')).toBe(true);+ expect(wrap.classList.contains('is-hovered')).toBe(false);+ act(() => { window.dispatchEvent(new CustomEvent(PET_HOVER_EVENT, { detail: { hover: true } })); });+ expect(wrap.classList.contains('is-hovered')).toBe(true);+ act(() => { window.dispatchEvent(new CustomEvent(PET_HOVER_EVENT, { detail: { hover: false } })); });+ expect(wrap.classList.contains('is-hovered')).toBe(false);+ });+it('keeps the unread count visible until the inbox confirms the result was read', async () => {tails.S = [message('u', 'S', { author: 'user', type: 'user' }), message('r', 'S', { read_at: null })];unreadBySession = { S: 1 };diff --git a/ui/src/pet/PetPage.tsx b/ui/src/pet/PetPage.tsxindex 150f7d16b..6877f84ec 100644--- a/ui/src/pet/PetPage.tsx+++ b/ui/src/pet/PetPage.tsx@@ -1,7 +1,7 @@import { useCallback, useEffect, useMemo, useRef, useState, useLayoutEffect, type ReactNode } from 'react';import { useTranslation } from 'react-i18next';import clsx from 'clsx';-import { ArrowLeftRight, ExternalLink, KeyRound } from 'lucide-react';+import { ArrowLeft, ArrowLeftRight, ExternalLink, KeyRound } from 'lucide-react';import { ApiError, useApi, type SessionActivityState, type WorkbenchMessage } from '@/context/ApiContext';import { useInstanceAuthorization } from '@/context/InstanceAuthorizationContext';@@ -16,7 +16,7 @@ import { ShowPageVoiceDictation } from '@/lib/showPageVoiceDictation';import { VoiceTranscriptionError } from '@/lib/voiceTranscription';import { PetAvatar, type PetPose } from './PetAvatar';-import { petBridge, sessionLink, vaultRequestLink } from './petBridge';+import { onPetHover, petBridge, sessionLink, vaultRequestLink } from './petBridge';import { petPanel, usePetPanel } from './petPanel';import { petComposer, usePetComposer } from './petComposer';import { petShell, useOnSummon, usePetBinding, usePetDismissed } from './petShell';@@ -233,8 +233,15 @@ const PetSurface: React.FC = () => {};}, [binding, epoch]);useEffect(() => {- if (!expanded) setDetailOpen(false);+ if (expanded) return;+ // Collapsing leaves the switcher too, so the next expand shows the cards.+ setDetailOpen(false);+ setSwitcherOpen(false);}, [expanded]);+ // The shell reports hover over Vibey and the dock: macOS gives a webview no+ // hover while its window is not key, and the pet never takes focus itself.+ const [hovered, setHovered] = useState(false);+ useEffect(() => onPetHover(setHovered), []);const mainCard = useMemo<PetCard | null>(() => {const user = exchange.user;@@ -463,7 +470,7 @@ const PetSurface: React.FC = () => {}, [expanded, visibleCards.length]);const avatar = (- <div className={clsx('pet-mini-avatar-wrap', voice.listening && 'is-listening')}>+ <div className={clsx('pet-mini-avatar-wrap', voice.listening && 'is-listening', hovered && 'is-hovered')} data-pet-hover>{voice.listening && <span className="pet-mini-listen-ring" aria-hidden />}<buttontype="button"@@ -543,13 +550,13 @@ const PetSurface: React.FC = () => {<div className={clsx('pet-mini-column', voice.listening && 'is-voice-active')}><div className={clsx('pet-mini-cards', voice.listening && 'is-hidden')} inert={voice.listening || undefined} aria-label={expanded ? t('pet.panel') : undefined} style={{ height: expanded ? STACK_HEIGHT : collapsedHeight }}><div ref={collapsedRef} key={expanded ? 'expanded' : 'collapsed'} className="pet-mini-swap is-switching" onAnimationEnd={(event) => { if (event.target === event.currentTarget) event.currentTarget.classList.remove('is-switching'); }}>- {expanded && (!binding || switcherOpen || visibleCards.length === 0) ? (- <SessionPicker canStartVibey={capabilities.can_chat} onPick={(sessionId) => {+ {expanded && (!binding || switcherOpen) ? (+ <SessionPicker canStartVibey={capabilities.can_chat} onBack={binding ? () => setSwitcherOpen(false) : undefined} onPick={(sessionId) => {if (!epoch.isCurrent()) return;petShell.pick(sessionId, epoch.isAuthorizationCurrent);setSwitcherOpen(false);}} />- ) : visibleCards.length > 0 && (+ ) : (expanded || visibleCards.length > 0) && (expanded ? (<ExpandedCardscards={visibleCards}@@ -604,7 +611,7 @@ const SwitchSessionButton: React.FC<{ onClick: () => void; label: string }> = ({<button type="button" className="pet-mini-chip" data-pet-hit aria-label={label} onClick={onClick}><ArrowLeftRight aria-hidden />{label}</button>);-const SessionPicker: React.FC<{ onPick: (sessionId: string) => void; canStartVibey: boolean }> = ({ onPick, canStartVibey }) => {+const SessionPicker: React.FC<{ onPick: (sessionId: string) => void; onBack?: () => void; canStartVibey: boolean }> = ({ onPick, onBack, canStartVibey }) => {const { t } = useTranslation();const api = useApi();const { sessions, loading } = useSessionSwitcher(true);@@ -628,6 +635,11 @@ const SessionPicker: React.FC<{ onPick: (sessionId: string) => void; canStartVibreturn (<div className="pet-mini-panel" aria-label={t('pet.chooseSession')}><div className="pet-mini-scroll">+ {onBack && (+ <div className="pet-mini-action-row">+ <button type="button" className="pet-mini-chip" data-pet-hit onClick={onBack}><ArrowLeft aria-hidden />{t('common.back')}</button>+ </div>+ )}<div className="pet-mini-session-picker" data-pet-hit>{canStartVibey && <button type="button" onClick={pickVibey} disabled={vibeyPending} className="pet-mini-session-option is-vibey">{t('pet.talkToVibey')}</button>}{vibeyError && <p className="pet-mini-detail-muted">{vibeyError}</p>}@@ -685,7 +697,8 @@ function useHitRegions(rootRef: React.RefObject<HTMLDivElement | null>, epoch?:top = Math.max(top, clip.top); bottom = Math.min(bottom, clip.bottom);}}- return right > left && bottom > top ? [{ x: left, y: top, width: right - left, height: bottom - top }] : [];+ const hover = node.closest('[data-pet-hover]') !== null;+ return right > left && bottom > top ? [{ x: left, y: top, width: right - left, height: bottom - top, ...(hover ? { hover } : {}) }] : [];});const encoded = JSON.stringify(rects);if (encoded !== last) {diff --git a/ui/src/pet/pet-mini.css b/ui/src/pet/pet-mini.cssindex 4b151853c..c57854184 100644--- a/ui/src/pet/pet-mini.css+++ b/ui/src/pet/pet-mini.css@@ -64,7 +64,6 @@border-radius:28px;padding:14px 20px;background:var(--pet-card);- box-shadow:0 18px 50px rgba(0,0,0,.45);text-align:left;pointer-events:auto}@@ -79,11 +78,9 @@.pet-mini-eyebrow {margin-bottom:2px;color:color-mix(in srgb,var(--mint) 80%,transparent);- font-size:10px;+ font-size:11px;font-weight:600;- letter-spacing:.14em;- line-height:15px;- text-transform:uppercase}+ line-height:15px}.pet-mini-title,.pet-mini-subtitle {min-width:0;@@ -335,8 +332,7 @@ to {min-width:0;align-items:center;border-radius:22px;- background:var(--pet-card);- box-shadow:0 12px 32px rgba(0,0,0,.45)}+ background:var(--pet-card)}.pet-mini-marquee {gap:8px;padding:8px 16px 8px 12px}@@ -433,7 +429,6 @@ to {border-radius:28px;padding:8px;background:var(--pet-card);- box-shadow:0 18px 50px rgba(0,0,0,.45);pointer-events:auto}.pet-mini-session-picker > .pet-mini-detail-muted {padding:9px 12px;@@ -476,6 +471,8 @@ to {padding-top:10px}.pet-mini-scroll > .pet-mini-action-row + .pet-mini-list {margin-top:0}+.pet-mini-scroll > .pet-mini-action-row + .pet-mini-session-picker {+ margin-top:8px}.pet-mini-chip {display:inline-flex;align-items:center;@@ -558,15 +555,15 @@ to {display:flex;align-items:center;gap:4px;+ border:1px solid color-mix(in srgb,var(--pet-ink) 8%,transparent);border-radius:999px;background:var(--pet-card);padding:4px;- box-shadow:0 8px 24px rgba(0,0,0,.45);opacity:0;transform:translateY(-6px) scale(.92);pointer-events:none;transition:opacity 180ms ease,transform 220ms var(--settle)}-.pet-mini-avatar-wrap:hover .pet-mini-dock,.pet-mini-avatar-wrap:focus-within .pet-mini-dock,.pet-mini-dock.is-active {+.pet-mini-avatar-wrap:hover .pet-mini-dock,.pet-mini-avatar-wrap.is-hovered .pet-mini-dock,.pet-mini-avatar-wrap:focus-within .pet-mini-dock,.pet-mini-dock.is-active {opacity:1;transform:none;pointer-events:auto}@@ -605,7 +602,6 @@ to {border-radius:24px;background:var(--pet-card);padding:16px;- box-shadow:0 18px 50px rgba(0,0,0,.45);font-size:12px}@media (hover:none) {@@ -651,13 +647,11 @@ to {border: 1px solid color-mix(in srgb,var(--mint) 45%,transparent);border-radius: 28px;background: var(--pet-main);- box-shadow: 0 18px 50px rgba(0,0,0,.45);}.pet-mini-card-wrap.is-main > .pet-mini-card {border: 0;background: transparent;- box-shadow: none;}.pet-mini-card[role=button] {diff --git a/ui/src/pet/petBridge.ts b/ui/src/pet/petBridge.tsindex d3ca0cad0..af3701549 100644--- a/ui/src/pet/petBridge.ts+++ b/ui/src/pet/petBridge.ts@@ -23,6 +23,10 @@ import { openLinkInNewContext } from '@/lib/pwaNavigation';* avibe:pet-summon detail { intent } only after pet_ready(); earlier summons* are returned by pet_ready() instead* avibe:pet-bound detail { session_id: string | null, revision }+ * avibe:pet-hover detail { hover: boolean } the cursor entered or left+ * the hit rects reported with `hover`;+ * a webview in a window that is not+ * key gets no hover of its own on macOS** `revision` is the shell's binding revision: it grows by one on every change* to the binding, and every answer and event carries the revision it reflects.@@ -54,6 +58,10 @@ export type PetReady = PetBinding & {export const PET_SUMMON_EVENT = 'avibe:pet-summon';export const PET_BOUND_EVENT = 'avibe:pet-bound';+export const PET_HOVER_EVENT = 'avibe:pet-hover';++/** A window-local rect that takes the mouse; `hover` marks Vibey's hover zone. */+export type PetHitRect = { x: number; y: number; width: number; height: number; hover?: boolean };// Outside the shell, `{ binding, revision }` as JSON: the dev stand-in for// `pet.json` and the shell's revision counter.@@ -132,7 +140,7 @@ export const petBridge = {};},- setHitRegions: async (rects: Array<{ x: number; y: number; width: number; height: number }>): Promise<void> => {+ setHitRegions: async (rects: PetHitRect[]): Promise<void> => {const invoke = shellInvoke();if (!invoke) return;await invoke('pet_hit_regions', { rects });@@ -202,6 +210,13 @@ export const sessionLink = (sessionId: string): string => `avibe://session/${sesexport const vaultRequestLink = (requestId: string): string => `avibe://vaults/request/${requestId}`;export const SETTINGS_LINK = 'avibe://settings';+/** Subscribe to the shell's hover reports; returns the unsubscribe function. */+export const onPetHover = (handler: (hover: boolean) => void): (() => void) => {+ const listener = (event: Event) => handler((event as CustomEvent<{ hover?: unknown }>).detail?.hover === true);+ window.addEventListener(PET_HOVER_EVENT, listener);+ return () => window.removeEventListener(PET_HOVER_EVENT, listener);+};+/** Subscribe to shell events; returns the unsubscribe function. */export const onPetEvents = (handlers: {summon?: (intent: PetIntent) => void;