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
feat(pet): history above the input, a content-sized thinking bubble, double-click to open (#2939)
Max7b4d8655fa30
diff --git a/docs/plans/2026-10-12-desktop-mini-main-agent.md b/docs/plans/2026-10-12-desktop-mini-main-agent.mdindex df7505764..731f9da4d 100644--- a/docs/plans/2026-10-12-desktop-mini-main-agent.md+++ b/docs/plans/2026-10-12-desktop-mini-main-agent.md@@ -73,6 +73,8 @@ the main agent; there is no Follow up on cards.- Expanded: 6px panel padding plus 12px scroll padding.- Collapsed: 18px stack padding.- A card's width never depends on its content or on the number of cards.+ Vibey's reply bubble is the one exception, and only while it shows a status+ word alone (§4.2); the activity cards always keep the column width.- **Long text never widens anything.** Every flex/grid item on the path fromthe list to a text node needs `min-width: 0`, and grid rows need`grid-template-columns: minmax(0, 1fr)`. (A grid column sized by a long@@ -248,9 +250,10 @@ order is unchanged; CSS places the detail above it, and the toggle'stoggle row. On open the history scrolls to the very bottom, chat-style: the endof the newest result and the quick replies, Vault handoffs and notices thatfollow it sit right above the toggle row, with the §7.5 edge fades (no bottom-fade, since the end is reached). While it is open, new content keeps a reader-who is at the bottom (within 8px) pinned there and leaves one who has scrolled-up where they are. Mark-read needs any part of the latest result in view. Collapsed shows an up chevron and expanded a down chevron.+fade, since the end is reached). While it is open, new content, or the box+shrinking because the input below it grows (§5.2), keeps a reader who is at the+bottom (within 8px) pinned there and leaves one who has scrolled up where they+are. The pin's own scroll is never read as the reader scrolling up. Mark-read needs any part of the latest result in view. Collapsed shows an up chevron and expanded a down chevron.Open in Avibe is an icon-only button (the card's `ExternalLink` open button,28px, on a solid surface) pinned to the top-right corner of the open history,@@ -274,7 +277,19 @@ fades show there is more.Detail retains the 280ms grid / 200ms opacity transition and closes on stackcollapse. Its own scroll region fits the existing window; opening it neverresizes the avatar or the 292px activity scroll box. Input and dictation hide-this detail according to §5.2, including quick replies.+the bubble, quick replies included, unless its history is open: an open history+stays above them (§5.2).++**Width (owner decision, 2026-10-23).** While the summary row is a status word+alone (thinking while the turn runs, or waiting with no reply) and the history+is closed, the bubble is sized to its content, at least 160px, and centred on+Vibey like the column, so its tail and Vibey stay put. When the reply (or a+failure notice) takes the summary row, or the history opens, it widens to the+column width from the centre over 300ms settle; a new running turn narrows it+the same way. Reduced motion switches at once. The width animates through an+explicit pixel width that is handed back to CSS when it lands, since CSS+cannot interpolate between a content size and a percentage. The activity+cards keep their width.### 4.3 Visible activity cards@@ -332,8 +347,20 @@ Known data limitations for P1:else keeps it shown (§4.2);- else, if there is any exchange, the bubble shows with the history open,scrolled to the bottom;- - with no messages yet, or while typing or dictating, the click does nothing- (the input and its draft are left as they are).+ - with no messages yet, the click does nothing.++ Typing and dictating do not stop a click (owner decision, 2026-10-23): the+ history opens and closes above the input or the marquee, which keep their+ draft, focus, caret and capture. A click on Vibey is not leaving the input:+ the input keeps the focus (Vibey's press does not take it).+- **Double-click Vibey** (owner decision, 2026-10-23) opens Vibey's+ conversation in the Avibe main window (`avibe://session/<main>`, routed to+ `/chat/<id>`). A single click is never delayed: the first click of a+ double-click acts at once like any click, and the second puts the history+ and the card list back as they were before the first, then opens the window.+ The double-click is the platform's own (the press's click count), so its+ speed follows the system setting. A hold or a drag is never a click, and+ keyboard activation is always a single click.Every branch leaves the shell's panel state matching what is drawn, sonothing stays expanded out of sight. Vibey's button is labelled "Recent@@ -383,7 +410,15 @@ Known data limitations for P1:Vibey. By priority it holds the marquee while dictating, otherwise theinput bubble when it is open, otherwise Vibey's reply bubble when it hasprogress, history, a notice, quick replies or a pending authorization.- Only the highest-priority content is interactive or eligible for mark-read.+ Only the highest-priority content is interactive or eligible for mark-read,+ except an open history.+- **History above the input (owner decision, 2026-10-23).** Vibey's history,+ opened while the marquee or the input holds the slot, is drawn above them in+ the same slot, 14px apart (room for the bubble's tail); both are+ interactive. Opening the input keeps an open history, and closing the+ history leaves the input as it is. The history's height also leaves room for+ the measured input below it, which grows to its four lines inside the fixed+ window; nothing clips.- **Mutually exclusive expansion.** Opening "Recent turns" collapses the cardsinto their layered stack. Opening the card stack expands the cards and closeshistory. Closing history returns to the collapsed mini.@@ -434,7 +469,8 @@ Known data limitations for P1:- Enter sends; Shift+Enter is a newline; Enter during IME composition doesnot send;- Esc closes the bubble and discards the draft. Esc while dictating cancels- dictation first. Esc with nothing open collapses the stack.+ dictation first. An open history above the input or the marquee closes+ before either. Esc with nothing open collapses the stack.- **Sending:**- goes to the main agent only, with the existing composer rules: onemessage in flight, the uncertain-send lock, server-side queueing;@@ -779,5 +815,12 @@ GET /api/sessions/main- [ ] Window: fixed size; Vibey anchored at the bottom; clicks pass througheverywhere except the reported regions on macOS and Windows (shadowsincluded); polling backs off and stops when hidden.+- [ ] With the input or dictation open, a Vibey click opens the history above+ it and a second closes it; draft, focus, caret and capture survive, and+ Esc closes the history first. Everything fits the fixed window.+- [ ] Vibey's bubble is content-sized and centred while it only says+ thinking/waiting, and widens from the centre when the reply arrives.+- [ ] A double-click on Vibey opens its conversation in Avibe and leaves the+ history and cards as they were; single clicks are not delayed.- [ ] Reduced motion turns everything above into instant switches.- [ ] Icons are SVG. All copy is localized in en and zh.diff --git a/ui/e2e/pet-mini/layout.spec.ts b/ui/e2e/pet-mini/layout.spec.tsindex 41116ce37..0ca311b85 100644--- a/ui/e2e/pet-mini/layout.spec.ts+++ b/ui/e2e/pet-mini/layout.spec.ts@@ -1164,13 +1164,145 @@ test('holding Vibey still starts input, not the history', async ({ page }) => {await page.mouse.up();await expect(page.getByRole('textbox')).toBeVisible();await expect(page.locator('.pet-mini-reply-bubble .pet-mini-detail.is-open')).toHaveCount(0);- // While typing, a Vibey click leaves the input, and its draft, alone.+ // While typing, a Vibey click opens the history above the input and leaves+ // the input, and its draft, as they are (§5.1).await page.getByRole('textbox').fill('a draft');await avatar.click();await expect(page.getByRole('textbox')).toHaveValue('a draft');- await expect(page.locator('.pet-mini-reply-bubble .pet-mini-detail.is-open')).toHaveCount(0);+ await expect(page.getByRole('textbox')).toBeFocused();+ await expect(page.locator('.pet-mini-reply-bubble .pet-mini-detail.is-open')).toHaveCount(1);});+for (const theme of ['light', 'dark']) {+ for (const reduced of [false, true]) {+ test(`the history opens above a growing input and both fit the fixed window (${theme}, reduced=${reduced})`, async ({ page }) => {+ await page.emulateMedia({ reducedMotion: reduced ? 'reduce' : 'no-preference' });+ await page.goto('/e2e/pet-mini/fixture.html?scenario=personal&lang=zh&history=long&activities=4');+ await page.evaluate((theme) => { document.documentElement.dataset.theme = theme; }, theme);+ const avatar = page.locator('.pet-mini-avatar-button');+ await expect(page.locator('.pet-mini-collapsed')).toBeVisible();+ const anchor = await avatar.boundingBox();+ await avatar.hover();+ await page.getByRole('button', { name: '输入消息', exact: true }).click();+ const input = page.getByRole('textbox');+ await input.fill('第一行');+ // The caret, mid-draft, survives the click: typing continues where it was.+ await input.evaluate((node: HTMLTextAreaElement) => node.setSelectionRange(2, 2));+ await avatar.click();+ await expect(page.locator('.pet-mini-detail')).toHaveClass(/is-open/);+ await expect(input).toBeFocused();+ await page.keyboard.type('·');+ await expect(input).toHaveValue('第一·行');+ await input.evaluate((node: HTMLTextAreaElement) => node.setSelectionRange(node.value.length, node.value.length));+ // Grow the draft to the input's four-line cap while the history is open.+ for (const line of ['第二行', '第三行', '第四行', '第五行']) {+ await page.keyboard.press('Shift+Enter');+ await page.keyboard.type(line);+ }+ await expect(input).toHaveValue('第一·行\n第二行\n第三行\n第四行\n第五行');+ await settleMotion(page);+ const fits = async () => {+ const stack = (await page.locator('.pet-mini-cards').boundingBox())!;+ const bubble = (await page.locator('.pet-mini-reply-bubble').boundingBox())!;+ const history = (await page.locator('.pet-mini-bubble-history').boundingBox())!;+ const form = (await page.locator('.pet-mini-input').boundingBox())!;+ expect(stack.y).toBeGreaterThanOrEqual(0);+ expect(stack.y + stack.height).toBeLessThanOrEqual(bubble.y + 1);+ expect(history.y).toBeGreaterThanOrEqual(bubble.y - 1);+ expect(history.height).toBeGreaterThan(40);+ // The tail (7px) sits in the gap above the input, which ends above Vibey.+ expect(bubble.y + bubble.height + 7).toBeLessThanOrEqual(form.y + 1);+ expect(form.y + form.height).toBeLessThanOrEqual(anchor!.y + 4 + 1);+ expect(await avatar.boundingBox()).toEqual(anchor);+ // Both are desktop input regions.+ await expect.poll(() => page.evaluate(() => {+ const covered = (selector: string) => {+ const box = document.querySelector(selector)!.getBoundingClientRect();+ return window.petLayoutHitRegions.some((rect) => rect.x <= box.left + 1 && rect.y <= box.top + 1+ && rect.x + rect.width >= box.right - 1 && rect.y + rect.height >= box.bottom - 1);+ };+ return covered('.pet-mini-reply-bubble') && covered('.pet-mini-input');+ })).toBe(true);+ };+ await fits();+ // The history scrolls inside its shrunken box, ending at the bottom.+ const history = page.locator('.pet-mini-bubble-history');+ expect(await history.evaluate((node) => node.scrollHeight > node.clientHeight)).toBe(true);+ await expect.poll(() => history.evaluate((node) => `${node.scrollTop} ${node.scrollHeight} ${node.clientHeight} ${Math.abs(node.scrollHeight - node.clientHeight - node.scrollTop) <= 1}`)).toMatch(/true$/);+ // Escape closes the history first, then the input.+ await page.keyboard.press('Escape');+ await expect(page.locator('.pet-mini-detail.is-open')).toHaveCount(0);+ await expect(input).toHaveValue('第一·行\n第二行\n第三行\n第四行\n第五行');+ await page.keyboard.press('Escape');+ await expect(page.getByRole('textbox')).toHaveCount(0);+ expect(await page.evaluate(() => window.petFixtureSends)).toEqual([]);+ });+ }+}++test('a double-click opens the conversation in Avibe and leaves the history as it was', async ({ page }) => {+ await page.goto('/e2e/pet-mini/fixture.html?scenario=personal&lang=zh&history=long');+ const avatar = page.locator('.pet-mini-avatar-button');+ await expect(avatar).toBeVisible();+ await avatar.dblclick();+ await expect.poll(() => page.evaluate(() => window.petFixtureOpens)).toEqual(['avibe://session/ses_main']);+ await page.waitForTimeout(100);+ await expect(avatar).toHaveAttribute('aria-expanded', 'false');+ await expect(page.locator('.pet-mini-detail.is-open')).toHaveCount(0);+ await avatar.click();+ await expect(page.locator('.pet-mini-detail.is-open')).toHaveCount(1);+ await avatar.dblclick();+ await expect.poll(() => page.evaluate(() => window.petFixtureOpens.length)).toBe(2);+ await page.waitForTimeout(100);+ await expect(avatar).toHaveAttribute('aria-expanded', 'true');+ await expect(page.locator('.pet-mini-detail.is-open')).toHaveCount(1);+ // A drag never opens it.+ const box = (await avatar.boundingBox())!;+ await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);+ await page.mouse.down();+ await page.mouse.move(box.x + box.width / 2 + 20, box.y + box.height / 2 + 5, { steps: 4 });+ await page.mouse.up();+ await page.waitForTimeout(100);+ expect(await page.evaluate(() => window.petFixtureOpens.length)).toBe(2);+});++for (const reduced of [false, true]) {+ test(`thinking is content-sized and centred, and the reply widens it from the centre (reduced=${reduced})`, async ({ page }) => {+ await page.emulateMedia({ reducedMotion: reduced ? 'reduce' : 'no-preference' });+ await page.goto('/e2e/pet-mini/fixture.html?scenario=personal&lang=zh&running=1');+ await expect(page.locator('.pet-mini-reply-toggle')).toContainText('思考中');+ await settleMotion(page);+ const avatar = (await page.locator('.pet-mini-avatar-button').boundingBox())!;+ const centre = avatar.x + avatar.width / 2;+ const full = await page.locator('.pet-mini-slot-body').evaluate((node) => node.clientWidth - 36);+ const narrow = (await page.locator('.pet-mini-reply-bubble').boundingBox())!;+ expect(narrow.width).toBeGreaterThanOrEqual(160 - 0.5);+ expect(narrow.width).toBeLessThan(full / 2);+ expect(Math.abs(narrow.x + narrow.width / 2 - centre)).toBeLessThanOrEqual(1);+ const frames = await page.evaluate(async () => {+ const node = document.querySelector('.pet-mini-reply-bubble')!;+ window.petFixtureFinishTurn({ id: 'live_reply', author: 'agent', type: 'result', text: '做完了,细节都整理好了。', read_at: null });+ const seen: { width: number; centre: number }[] = [];+ const start = performance.now();+ while (performance.now() - start < 450) {+ await new Promise((resolve) => requestAnimationFrame(resolve));+ const box = node.getBoundingClientRect();+ seen.push({ width: box.width, centre: box.left + box.width / 2 });+ }+ return seen;+ });+ await expect(page.locator('.pet-mini-reply-toggle')).toContainText('已回复');+ for (const frame of frames) expect(Math.abs(frame.centre - centre)).toBeLessThanOrEqual(1);+ const widths = frames.map((frame) => frame.width);+ for (let i = 1; i < widths.length; i += 1) expect(widths[i]).toBeGreaterThanOrEqual(widths[i - 1] - 0.5);+ expect(widths.at(-1)).toBeCloseTo(full, 0);+ const between = widths.filter((width) => width > narrow.width + 2 && width < full - 2);+ if (reduced) expect(between).toEqual([]);+ else expect(between.length).toBeGreaterThan(2);+ expect(await page.locator('.pet-mini-avatar-button').boundingBox()).toEqual(avatar);+ });+}+for (const cards of [1, 3]) {test(`with ${cards} card${cards > 1 ? 's' : ''}, the bubble hidden, shown or open fits without overlap`, async ({ page }) => {const fits = async () => {diff --git a/ui/eslint-baseline.json b/ui/eslint-baseline.jsonindex 2312eb4c0..b783c78ee 100644--- a/ui/eslint-baseline.json+++ b/ui/eslint-baseline.json@@ -376,7 +376,7 @@"react-hooks/set-state-in-effect": 1},"src/pet/PetPage.tsx": {- "react-hooks/preserve-manual-memoization": 3,+ "react-hooks/preserve-manual-memoization": 2,"react-hooks/set-state-in-effect": 6}},diff --git a/ui/src/pet/PetPage.test.tsx b/ui/src/pet/PetPage.test.tsxindex 1f786eb49..a10029e38 100644--- a/ui/src/pet/PetPage.test.tsx+++ b/ui/src/pet/PetPage.test.tsx@@ -1831,7 +1831,11 @@ describe('desktop mini v2 interaction contract', () => {expect(api.sendSessionMessage).toHaveBeenCalledExactlyOnceWith('S', { text: 'Yes', metadata: { quick_reply_for: 'q1' } });expect(screen.queryByRole('button', { name: 'Yes', exact: true })).toBeNull();expect(screen.queryByRole('button', { name: 'No', exact: true })).toBeNull();+ // The history stayed open above the input; Escape closes it, then the input.await userEvent.keyboard('{Escape}');+ expect(screen.getByRole('textbox')).toBeTruthy();+ await userEvent.keyboard('{Escape}');+ expect(screen.queryByRole('textbox')).toBeNull();await showDetail();// An older update must never reclaim a newer result's quick-reply group.await emit((h) => h.onMessageNew?.(message('q2', 'S', { content: { quick_replies: ['Continue', 'Wait'] } })));@@ -1999,6 +2003,175 @@ describe('desktop mini v2 interaction contract', () => {fireEvent.pointerUp(avatar, { pointerId: 2 });expect(api.sendSessionMessage).not.toHaveBeenCalled();});++ // Spec §5.1/§5.2: Vibey's history and the input are open together.+ const historyIsOpen = () => document.querySelector('.pet-mini-detail.is-open') !== null;+ const withHistory = () => {+ tails.S = [message('u', 'S', { author: 'user', type: 'user', text: 'hello' }), message('r', 'S', { text: 'Old reply' })];+ };++ it('opens the history above the typed input, keeping its draft, focus and caret, and Escape closes the history first', async () => {+ withHistory();+ mainSession('S'); render(<PetPage />);+ await waitFor(() => expect(document.querySelector('.pet-mini-reply-bubble')?.textContent).toContain('Old reply'));+ await userEvent.click(screen.getByLabelText('pet.keyboard.open'));+ const input = await screen.findByRole('textbox') as HTMLTextAreaElement;+ await userEvent.type(input, 'half a thought');+ input.setSelectionRange(4, 4);+ const avatar = screen.getByLabelText('pet.recentTurns');+ await userEvent.click(avatar);+ await waitFor(() => expect(historyIsOpen()).toBe(true));+ expect(avatar.getAttribute('aria-expanded')).toBe('true');+ expect(screen.getByRole('textbox')).toBe(input);+ expect(input.value).toBe('half a thought');+ expect(document.activeElement).toBe(input);+ expect([input.selectionStart, input.selectionEnd]).toEqual([4, 4]);+ // Drawn in the same slot, above the input.+ const bubble = document.querySelector('.pet-mini-reply-bubble')!;+ expect(bubble.closest('.pet-mini-slot')).toBe(input.closest('.pet-mini-slot'));+ expect(bubble.compareDocumentPosition(input) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ // A second click closes only the history.+ await userEvent.click(avatar);+ await waitFor(() => expect(historyIsOpen()).toBe(false));+ expect(document.querySelector('.pet-mini-reply-bubble')).toBeNull();+ expect(screen.getByRole('textbox')).toBe(input);+ expect(input.value).toBe('half a thought');+ // Escape: the history, then the input.+ await userEvent.click(avatar);+ await waitFor(() => expect(historyIsOpen()).toBe(true));+ await userEvent.keyboard('{Escape}');+ expect(historyIsOpen()).toBe(false);+ expect(screen.getByRole('textbox')).toBe(input);+ expect(input.value).toBe('half a thought');+ await userEvent.keyboard('{Escape}');+ expect(screen.queryByRole('textbox')).toBeNull();+ expect(api.sendSessionMessage).not.toHaveBeenCalled();+ });++ it('keeps an open history when the input opens, and sends from the input below it', async () => {+ withHistory();+ mainSession('S'); render(<PetPage />);+ await waitFor(() => expect(document.querySelector('.pet-mini-reply-bubble')?.textContent).toContain('Old reply'));+ await userEvent.click(screen.getByLabelText('pet.recentTurns'));+ await waitFor(() => expect(historyIsOpen()).toBe(true));+ await userEvent.click(screen.getByLabelText('pet.keyboard.open'));+ const input = await screen.findByRole('textbox');+ expect(historyIsOpen()).toBe(true);+ await userEvent.type(input, 'next{Enter}');+ expect(api.sendSessionMessage).toHaveBeenCalledExactlyOnceWith('S', { text: 'next' });+ });++ it('opens the history above dictation without ending it, and Escape closes the history before cancelling', async () => {+ const abort = vi.fn();+ const finish = vi.fn();+ class Dictation { done = new Promise<string>(() => {}); start = async () => {}; finish = finish; abort = abort; }+ await withVoiceEnv(() => true, Dictation, async () => {+ withHistory();+ mainSession('S'); render(<PetPage />);+ await userEvent.click(await screen.findByLabelText('pet.voice.open'));+ await waitFor(() => expect(pose()).toBe('listening'));+ expect(document.querySelector('.pet-mini-marquee')).not.toBeNull();+ await userEvent.click(screen.getByLabelText('pet.recentTurns'));+ await waitFor(() => expect(historyIsOpen()).toBe(true));+ expect(pose()).toBe('listening');+ expect(document.querySelector('.pet-mini-marquee')).not.toBeNull();+ const bubble = document.querySelector('.pet-mini-reply-bubble')!;+ expect(bubble.compareDocumentPosition(document.querySelector('.pet-mini-marquee')!) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();+ act(() => { window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })); });+ expect(historyIsOpen()).toBe(false);+ expect(pose()).toBe('listening');+ expect(abort).not.toHaveBeenCalled();+ expect(finish).not.toHaveBeenCalled();+ act(() => { window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })); });+ expect(abort).toHaveBeenCalledTimes(1);+ await waitFor(() => expect(pose()).not.toBe('listening'));+ });+ });++ it('a double-click opens the conversation in Avibe and leaves the history as before', async () => {+ const invoke = vi.fn((command: string) => {+ if (command === 'pet_ready') return Promise.resolve({ binding: 'S', revision: 1, summon_pending: null });+ if (command === 'pet_open') return Promise.resolve(null);+ return Promise.resolve({ panel_side: 'left', panel_edge: 'bottom' });+ });+ Object.defineProperty(window, '__AVIBE_DESKTOP_SHELL__', { value: true, configurable: true });+ Object.defineProperty(window, '__TAURI_INTERNALS__', { value: { invoke }, configurable: true });+ try {+ withHistory();+ mainSession('S'); render(<PetPage />);+ await waitFor(() => expect(document.querySelector('.pet-mini-reply-bubble')?.textContent).toContain('Old reply'));+ const avatar = screen.getByLabelText('pet.recentTurns');+ const opens = () => invoke.mock.calls.filter(([command]) => command === 'pet_open');+ // Closed before: closed after, with the conversation opened once.+ await userEvent.setup().dblClick(avatar);+ await waitFor(() => expect(opens()).toEqual([['pet_open', { link: 'avibe://session/S' }]]));+ await act(async () => new Promise((resolve) => setTimeout(resolve, 15)));+ expect(historyIsOpen()).toBe(false);+ expect(avatar.getAttribute('aria-expanded')).toBe('false');+ // Open before: open after.+ await userEvent.click(avatar);+ await waitFor(() => expect(historyIsOpen()).toBe(true));+ await userEvent.setup().dblClick(avatar);+ await waitFor(() => expect(opens()).toHaveLength(2));+ await act(async () => new Promise((resolve) => setTimeout(resolve, 15)));+ expect(historyIsOpen()).toBe(true);+ expect(avatar.getAttribute('aria-expanded')).toBe('true');+ // Keyboard activation (no click count) and single clicks never open it.+ fireEvent.click(avatar);+ await waitFor(() => expect(historyIsOpen()).toBe(false));+ await userEvent.click(avatar);+ await waitFor(() => expect(historyIsOpen()).toBe(true));+ expect(opens()).toHaveLength(2);+ } finally {+ Reflect.deleteProperty(window, '__AVIBE_DESKTOP_SHELL__');+ Reflect.deleteProperty(window, '__TAURI_INTERNALS__');+ }+ });++ it('a quick click after a hold is a single click, not a double-click', async () => {+ const invoke = vi.fn((command: string) => {+ if (command === 'pet_ready') return Promise.resolve({ binding: 'S', revision: 1, summon_pending: null });+ return Promise.resolve(command === 'pet_open' ? null : { panel_side: 'left', panel_edge: 'bottom' });+ });+ Object.defineProperty(window, '__AVIBE_DESKTOP_SHELL__', { value: true, configurable: true });+ Object.defineProperty(window, '__TAURI_INTERNALS__', { value: { invoke }, configurable: true });+ withHistory();+ mainSession('S'); render(<PetPage />);+ await waitFor(() => expect(document.querySelector('.pet-mini-reply-bubble')?.textContent).toContain('Old reply'));+ const avatar = screen.getByLabelText('pet.recentTurns');+ // A click, then a hold (which opens the input without voice), then a+ // press the platform counts as the second of a double-click.+ await userEvent.click(avatar);+ await waitFor(() => expect(historyIsOpen()).toBe(true));+ fireEvent.pointerDown(avatar, { button: 0, pointerId: 7 });+ fireEvent.mouseDown(avatar, { detail: 2 });+ await act(async () => new Promise((resolve) => setTimeout(resolve, 400)));+ fireEvent.pointerUp(avatar, { pointerId: 7 });+ expect(await screen.findByRole('textbox')).toBeTruthy();+ fireEvent.pointerDown(avatar, { button: 0, pointerId: 8 });+ fireEvent.mouseDown(avatar, { detail: 2 });+ fireEvent.pointerUp(avatar, { pointerId: 8 });+ await waitFor(() => expect(historyIsOpen()).toBe(false));+ expect(invoke.mock.calls.filter(([command]) => command === 'pet_open')).toEqual([]);+ });++ it('a double-click that first collapsed the card list puts the list back', async () => {+ canUseAgents = true;+ const row = workingIn('running').agents[0];+ runningAgents = { ...workingIn('running'), agents: [+ { ...row, session_id: 'A', title: 'Task A', visibility: 'foreground', openable_in_chat: true },+ { ...row, session_id: 'B', title: 'Task B', visibility: 'foreground', openable_in_chat: true },+ ] };+ withHistory();+ mainSession('S'); render(<PetPage />);+ await waitFor(() => expect(document.querySelector('.pet-mini-collapsed')).not.toBeNull());+ await showCards();+ await waitFor(() => expect(document.querySelector('.pet-mini-scroll')).not.toBeNull());+ await userEvent.setup().dblClick(screen.getByLabelText('pet.recentTurns'));+ await act(async () => new Promise((resolve) => setTimeout(resolve, 15)));+ expect(document.querySelector('.pet-mini-scroll')).not.toBeNull();+ expect(historyIsOpen()).toBe(false);+ });});@@ -2558,6 +2731,35 @@ describe('Vibey bubble visibility (spec §4.2)', () => {api.getTurnState.mockImplementation(async () => idleTurn);});+ // Spec §4.2: a status word alone sizes the bubble to its content.+ it('is content-sized while thinking, full width for the reply and whenever the history is open', async () => {+ const compact = () => document.querySelector('.pet-mini-reply-bubble')!.classList.contains('is-compact');+ tails.S = [message('u', 'S', { author: 'user', type: 'user', text: 'hello' })];+ let running = true;+ api.getTurnState.mockImplementation(async () => (running ? { ...idleTurn, in_flight: true, foreground: 'running' as const } : idleTurn));+ mainSession('S');+ render(<PetPage />);+ await waitFor(() => expect(bubbleOpen()).toBe(true));+ expect(document.querySelector('.pet-mini-reply-toggle')?.textContent).toContain('pet.thinking');+ expect(compact()).toBe(true);+ fireEvent.click(document.querySelector('.pet-mini-reply-toggle')!);+ await waitFor(() => expect(document.querySelector('.pet-mini-detail.is-open')).not.toBeNull());+ expect(compact()).toBe(false);+ fireEvent.click(document.querySelector('.pet-mini-reply-toggle')!);+ await waitFor(() => expect(document.querySelector('.pet-mini-detail.is-open')).toBeNull());+ expect(compact()).toBe(true);+ const result = message('r', 'S', { text: 'All done', read_at: null });+ tails.S = [...tails.S, result];+ running = false;+ await emit((h) => {+ h.onMessageNew?.(result);+ h.onTurnEnd?.({ session_id: 'S' });+ });+ await waitFor(() => expect(document.querySelector('.pet-mini-reply-toggle')?.textContent).toContain('pet.repliedPrefix'));+ expect(compact()).toBe(false);+ expect(bubbleOpen()).toBe(true);+ });+it('keeps the bubble open from running to its result, then shows the reply for 10s', async () => {const classes = await runToResult();// No closed frame between the running bubble and the reply.diff --git a/ui/src/pet/PetPage.tsx b/ui/src/pet/PetPage.tsxindex a128b20a4..3db5a5ed7 100644--- a/ui/src/pet/PetPage.tsx+++ b/ui/src/pet/PetPage.tsx@@ -272,15 +272,33 @@ const PetSurface: React.FC = () => {// A Vibey click (§5.1) is about Vibey's own conversation: it collapses an// expanded card list, else closes an open history, else opens the history.// The collapsed stack is the only way to expand the cards (§3.3). Every- // branch leaves the shell's panel state matching what is drawn.+ // branch leaves the shell's panel state matching what is drawn. Typing and+ // dictation stay as they are: the history opens above the input.const toggleVibey = () => {if (cardsListed) { void setPanel(false); return; }if (historyOpen) { setDetailOpen(false); void setPanel(false); return; }- // Typing and dictation keep the speech slot, and the draft, as they are.- if (composing || voice.busy) return;if (!binding || resolvingMain || (data.messages.length === 0 && !optimisticTitle)) return;openHistory();};+ // A double-click (§5.1) opens Vibey's conversation in the main window. Its+ // first click already acted, so the second puts the history and the cards+ // back as they were before it.+ const vibeyBefore = useRef<{ detailOpen: boolean; expanded: boolean } | null>(null);+ const clickVibey = () => {+ vibeyBefore.current = { detailOpen, expanded: petPanel.want() };+ toggleVibey();+ };+ const doubleClickVibey = () => {+ const before = vibeyBefore.current;+ vibeyBefore.current = null;+ if (before?.detailOpen) {+ if (!detailOpen) openHistory();+ } else if (before) {+ setDetailOpen(false);+ if (petPanel.want() !== before.expanded) void setPanel(before.expanded);+ }+ if (binding) void petBridge.open(sessionLink(binding)).catch(() => undefined);+ };const [composing, setComposing] = useState(false);const [presentations, setPresentations] = useState<Record<string, CardPresentation>>({});const presentationNow = useRef<Record<string, CardPresentation>>({});@@ -298,7 +316,9 @@ const PetSurface: React.FC = () => {const [orderedIds, setOrderedIds] = useState<string[]>([]);const stopTimers = useRef<Record<string, number>>({});const inputRef = useRef<HTMLTextAreaElement>(null);- const pressRef = useRef<{ held: boolean; dragged: boolean; x: number; y: number; timer: number } | null>(null);+ // `clicks` is the platform's click count for this press (its mousedown+ // `detail`): 2 is the second press of a double-click.+ const pressRef = useRef<{ held: boolean; dragged: boolean; clicks: number; x: number; y: number; timer: number } | null>(null);const dismissTimers = useRef<Record<string, number>>({});const updatePresentation = useCallback((key: string, patch: CardPresentation | null) => {const next = { ...presentationNow.current };@@ -459,9 +479,9 @@ const PetSurface: React.FC = () => {setComposing(false);setDraft('');}, [setDraft]);+ // An open history stays open: the input takes its place below it (§5.2).const openComposer = useCallback((text = '', selected?: SessionReference[]) => {if (!epoch.isCurrent()) return;- setDetailOpen(false);setDraft(text, selected);setComposing(true);window.setTimeout(() => { if (epoch.isCurrent()) inputRef.current?.focus(); }, 0);@@ -603,7 +623,9 @@ const PetSurface: React.FC = () => {const onKey = (event: KeyboardEvent) => {// Escape also dismisses an IME candidate list; that one is not ours.if (event.key !== 'Escape' || isComposingKey(event)) return;- if (voice.busy) voice.cancel();+ // A history opened above the input closes before the input does.+ if (detailOpen && (voice.busy || composing)) { setDetailOpen(false); void setPanel(false); }+ else if (voice.busy) voice.cancel();else if (composing) closeComposer();else if (detailOpen) { setDetailOpen(false); void setPanel(false); }else void setPanel(false);@@ -621,6 +643,17 @@ const PetSurface: React.FC = () => {const rootRef = useRef<HTMLDivElement>(null);useHitRegions(rootRef, epoch);+ // The input (or marquee) below an open history: its height leaves the+ // history less room in the fixed window.+ const [inputHeight, setInputHeight] = useState(0);+ const inputAreaRef = useCallback((node: HTMLDivElement | null) => {+ if (!node) return undefined;+ const measure = () => setInputHeight(node.offsetHeight);+ measure();+ const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure);+ observer?.observe(node);+ return () => observer?.disconnect();+ }, []);const collapsedRef = useRef<HTMLDivElement>(null);const [collapsedHeight, setCollapsedHeight] = useState(0);// One card is always drawn in its full form (spec §3.3): there is no stack to@@ -698,10 +731,12 @@ const PetSurface: React.FC = () => {}if (watched !== turnWatch) setTurnWatch(watched);const lingerReply = turnReply && !watched.seen.has(turnReply.id) ? turnReply : null;- // The bubble is drawn: the speech slot shows it rather than the input or the- // dictation marquee. Every input to the linger (time, pointer) means- // something only while this holds.- const bubbleDrawn = hasBubbleContent && Boolean(binding) && !voice.busy && !(composing && canChat && !uncertain);+ // The input or the dictation marquee holds the bottom of the speech slot.+ const inputShown = voice.busy || (composing && canChat && !uncertain);+ // The bubble is drawn: the speech slot shows it, alone or, while its history+ // is open or asked for, above the input or the marquee (§5.2). Every input+ // to the linger (time, pointer) means something only while this holds.+ const bubbleDrawn = hasBubbleContent && Boolean(binding) && (!inputShown || detailOpen);// The reply is on screen: the bubble is drawn and its summary row is the// reply (not "thinking" while the turn still runs, nor a failure notice).// Only then does the linger spend its time.@@ -711,14 +746,15 @@ const PetSurface: React.FC = () => {const bubbleRef = useRef<HTMLDivElement | null>(null);const avatarRef = useRef<HTMLButtonElement>(null);// Focus inside a bubble that is replaced (by the input, the dictation- // marquee, or a loading notice) moves to Vibey rather than to nowhere. The- // node is checked as it detaches, while it still holds the focus.+ // marquee, or a loading notice) moves to Vibey rather than to nowhere, or to+ // the input when the bubble closes above it. The node is checked as it+ // detaches, while it still holds the focus.const attachBubble = useCallback((node: HTMLDivElement | null) => {bubbleRef.current = node;if (!node) return undefined;return () => {if (bubbleRef.current === node) bubbleRef.current = null;- if (node.contains(document.activeElement)) avatarRef.current?.focus();+ if (node.contains(document.activeElement)) (inputRef.current ?? avatarRef.current)?.focus();};}, []);const { lingeringId, keepAtLeast } = useReplyLinger({@@ -770,7 +806,7 @@ const PetSurface: React.FC = () => {if (event.button !== 0) return;const target = event.currentTarget;const pointerId = event.pointerId;- pressRef.current = { held: false, dragged: false, x: event.clientX, y: event.clientY, timer: window.setTimeout(() => {+ pressRef.current = { held: false, dragged: false, clicks: 1, x: event.clientX, y: event.clientY, timer: window.setTimeout(() => {if (!epoch.isCurrent()) return;const press = pressRef.current;if (!press) return;@@ -782,6 +818,11 @@ const PetSurface: React.FC = () => {else openComposer(draft);}, HOLD_MS) };}}+ onMouseDown={(event) => {+ if (pressRef.current) pressRef.current.clicks = event.detail;+ // The input keeps its focus and caret: a Vibey click is not leaving it.+ if (inputRef.current && document.activeElement === inputRef.current) event.preventDefault();+ }}onPointerMove={(event) => {const press = pressRef.current;if (!press || press.held || press.dragged || event.buttons !== 1) return;@@ -793,6 +834,7 @@ const PetSurface: React.FC = () => {onPointerCancel={() => {const press = pressRef.current;pressRef.current = null;+ vibeyBefore.current = null;if (press) window.clearTimeout(press.timer);if (press?.held) voice.stop(true);}}@@ -801,14 +843,20 @@ const PetSurface: React.FC = () => {pressRef.current = null;if (!press) return;window.clearTimeout(press.timer);+ // Only a click right after a click on Vibey is its double-click; a+ // hold, a drag or a cancelled press in between starts over.+ if (press.held || press.dragged || press.clicks > 2) vibeyBefore.current = null;if (press.held) voice.stop(true);- else if (!press.dragged) toggleVibey();+ else if (press.dragged || press.clicks > 2) return;+ else if (press.clicks === 2 && vibeyBefore.current) doubleClickVibey();+ else clickVibey();}}onPointerLeave={() => {const press = pressRef.current;if (press && !press.held) {window.clearTimeout(press.timer);pressRef.current = null;+ vibeyBefore.current = null;}}}onContextMenu={(event) => event.preventDefault()}@@ -835,7 +883,7 @@ const PetSurface: React.FC = () => {return (<div ref={rootRef} className="pet-mini-stage" data-pet-root data-busy={busy} data-state={state}>- <div className={clsx('pet-mini-column', voice.busy && 'is-voice-active')} style={{ '--pet-collapsed-height': `${collapsedHeight}px` } as CSSProperties}>+ <div className={clsx('pet-mini-column', voice.busy && 'is-voice-active')} style={{ '--pet-collapsed-height': `${collapsedHeight}px`, '--pet-input-space': bubbleDrawn && inputShown ? `calc(${inputHeight}px + var(--pet-input-gap))` : '0px' } as CSSProperties}><div className={clsx('pet-mini-cards', voice.busy && 'is-hidden')} inert={voice.busy || undefined} aria-label={cardsExpanded ? t('pet.panel') : undefined} style={{ height: cardsListed ? (visibleCards.length > 0 ? STACK_HEIGHT : 'auto') : collapsedHeight }}><div ref={collapsedRef} key={singleCard ? 'single' : cardsExpanded ? 'expanded' : 'collapsed'} className="pet-mini-swap is-switching" onAnimationEnd={(event) => { if (event.target === event.currentTarget) event.currentTarget.classList.remove('is-switching'); }}>{visibleCards.length > 0 && (@@ -857,43 +905,14 @@ const PetSurface: React.FC = () => {</div></div><SpeechSlot open={voice.busy || composing || showReplyBubble || resolvingMain || !binding}>- {voice.busy ? <Marquee text={voice.finishing ? '' : voice.preview} listeningLabel={t(voice.finishing ? 'pet.voice.finishing' : 'pet.voice.listening')} /> : composing && canChat && !uncertain ? (- <>- {voice.error && <p className="pet-mini-input-note" role="status">{t(`pet.voice.${voice.error}`)}</p>}- <form className="pet-mini-input" data-pet-hit onSubmit={(event) => { event.preventDefault(); void submit(); }}>- {draftReferences.length > 0 && <div className="pet-mini-references">- {draftReferences.map((reference) => <span key={reference.session_id} className="pet-mini-reference-chip">- <span title={reference.title ?? reference.session_id}># {reference.title ?? reference.session_id}</span>- <button type="button" aria-label={t('pet.removeReference', { title: reference.title ?? reference.session_id })} onClick={() => setDraft(draft.replaceAll(referenceToMarker(reference), '').trim())}><X size={12} /></button>- </span>)}- </div>}- <div className="pet-mini-input-row">- <textarea- ref={inputRef}- rows={1}- value={inputDraft}- onChange={(event) => setDraft([...draftMarkers, event.target.value].join(' '))}- onKeyDown={(event) => {- if (event.key === 'Enter' && !event.shiftKey && !isComposingKey(event)) {- event.preventDefault();- void submit();- }- }}- placeholder={t('pet.inputPlaceholder')}- aria-label={t('pet.inputPlaceholder')}- />- {voice.available && <button type="button" className="pet-mini-input-button" onClick={() => voice.start()} aria-label={t('pet.voiceContinue')}><MicIcon /></button>}- <button type="submit" className="pet-mini-send" disabled={!draft.trim() || sending || uncertain} aria-label={t('pet.send')}><SendIcon /></button>- </div>- </form>- </>- ) : hasBubbleContent && binding ? (+ {bubbleDrawn && binding ? (// Still drawn while the slot closes, so it fades out rather than vanishing.<div// Its own identity, so a notice drawn in the same place replaces// it (and runs the focus handoff) instead of reusing this node.key="vibey-bubble"ref={attachBubble}+ className={clsx(inputShown && 'pet-mini-bubble-over-input')}onPointerEnter={() => setPointerOverBubble(true)}onPointerLeave={() => {// Leaving gives the reader a moment before it goes.@@ -920,15 +939,47 @@ const PetSurface: React.FC = () => {quickReplies={quickReplies}onChoose={choose}uncertain={uncertain}+ reducedMotion={reducedMotion}onInspect={() => { void petBridge.open(sessionLink(binding)).then(() => { if (epoch.isCurrent()) setUncertain(binding, false); }).catch(() => undefined); }}/></div>- ) : resolvingMain || !binding ? (+ ) : !inputShown && (resolvingMain || !binding) ? (<div className="pet-mini-reply-bubble pet-mini-detail-inner" data-pet-hit role="status"><p className="pet-mini-detail-muted">{t(data.canChat === null ? 'common.loading' : 'pet.vibeyUnavailable')}</p><Button variant="link" size="sm" className="px-0" onClick={() => void petBridge.open('avibe://settings')}>{t('pet.openInAvibe')}</Button></div>) : null}+ {inputShown && <div ref={inputAreaRef}>{voice.busy ? <Marquee text={voice.finishing ? '' : voice.preview} listeningLabel={t(voice.finishing ? 'pet.voice.finishing' : 'pet.voice.listening')} /> : (+ <>+ {voice.error && <p className="pet-mini-input-note" role="status">{t(`pet.voice.${voice.error}`)}</p>}+ <form className="pet-mini-input" data-pet-hit onSubmit={(event) => { event.preventDefault(); void submit(); }}>+ {draftReferences.length > 0 && <div className="pet-mini-references">+ {draftReferences.map((reference) => <span key={reference.session_id} className="pet-mini-reference-chip">+ <span title={reference.title ?? reference.session_id}># {reference.title ?? reference.session_id}</span>+ <button type="button" aria-label={t('pet.removeReference', { title: reference.title ?? reference.session_id })} onClick={() => setDraft(draft.replaceAll(referenceToMarker(reference), '').trim())}><X size={12} /></button>+ </span>)}+ </div>}+ <div className="pet-mini-input-row">+ <textarea+ ref={inputRef}+ rows={1}+ value={inputDraft}+ onChange={(event) => setDraft([...draftMarkers, event.target.value].join(' '))}+ onKeyDown={(event) => {+ if (event.key === 'Enter' && !event.shiftKey && !isComposingKey(event)) {+ event.preventDefault();+ void submit();+ }+ }}+ placeholder={t('pet.inputPlaceholder')}+ aria-label={t('pet.inputPlaceholder')}+ />+ {voice.available && <button type="button" className="pet-mini-input-button" onClick={() => voice.start()} aria-label={t('pet.voiceContinue')}><MicIcon /></button>}+ <button type="submit" className="pet-mini-send" disabled={!draft.trim() || sending || uncertain} aria-label={t('pet.send')}><SendIcon /></button>+ </div>+ </form>+ </>+ )}</div>}</SpeechSlot></div>{avatar}@@ -1287,22 +1338,78 @@ const CardBody: React.FC<{ card: PetCard; expanded: boolean; t: (key: string, optype MainDetailProps = { epoch: PetSurfaceEpoch; voiceNeedsCloud: boolean; canChat: boolean; visible: boolean; binding: string; exchange: ReturnType<typeof latestExchange>; messages: WorkbenchMessage[]; failure: WorkbenchMessage | null; running: boolean; queued: boolean; markRead: (sessionId: string, untilMessageId?: string) => Promise<boolean>; onRead: () => void; vaultRequestIds: string[]; quickReplies: ReturnType<typeof openQuickReplies>; onChoose: (message: WorkbenchMessage, choice: string) => Promise<boolean>; uncertain: boolean; onInspect: () => void };-const MainReplyBubble: React.FC<Omit<MainDetailProps, 'visible'> & { open: boolean; onToggle: () => void; pinnedReply?: WorkbenchMessage | null }> = ({ open, onToggle, pinnedReply, ...props }) => {+/**+ * Animates a box between two widths CSS cannot interpolate (its content's width+ * and the column's): from the width last drawn to the new one, then hands the+ * width back to CSS. Reduced motion switches at once.+ */+function useWidthMorph(key: unknown, reducedMotion: boolean) {+ const ref = useRef<HTMLDivElement>(null);+ const drawn = useRef<number | null>(null);+ const previous = useRef(key);+ useLayoutEffect(() => {+ const node = ref.current;+ if (!node || typeof ResizeObserver === 'undefined') return undefined;+ const observer = new ResizeObserver(() => { drawn.current = node.getBoundingClientRect().width; });+ observer.observe(node);+ return () => observer.disconnect();+ }, []);+ useLayoutEffect(() => {+ const node = ref.current;+ if (!node) return undefined;+ const changed = previous.current !== key;+ previous.current = key;+ const from = drawn.current;+ // Every width set here applies at once: only the last one is animated. A+ // width CSS can interpolate would otherwise start its own transition from+ // whatever was computed in between.+ const settle = (width: string) => {+ node.style.transition = 'none';+ node.style.width = width;+ void node.offsetWidth;+ node.style.transition = '';+ };+ // Whatever was moving lands at once when there is nothing to animate.+ settle('');+ if (!changed || reducedMotion) return undefined;+ const to = node.getBoundingClientRect().width;+ if (from === null || Math.abs(from - to) < 1) return undefined;+ settle(`${from}px`);+ node.style.width = `${to}px`;+ const release = (event: TransitionEvent) => {+ if (event.target === node && event.propertyName === 'width') settle('');+ };+ node.addEventListener('transitionend', release);+ node.addEventListener('transitioncancel', release);+ return () => {+ node.removeEventListener('transitionend', release);+ node.removeEventListener('transitioncancel', release);+ };+ }, [key, reducedMotion]);+ return ref;+}++const MainReplyBubble: React.FC<Omit<MainDetailProps, 'visible'> & { open: boolean; onToggle: () => void; pinnedReply?: WorkbenchMessage | null; reducedMotion: boolean }> = ({ open, onToggle, pinnedReply, reducedMotion, ...props }) => {const { t } = useTranslation();// A lingering reply keeps its summary even if a later result (a background// completion) arrives while it lingers.const last = pinnedReply ?? props.exchange.results.at(-1);+ const reply = last?.text?.trim() ?? '';const summary = props.running ? t('pet.thinking'): props.failure ? `${t('pet.failedPrefix')} ${props.failure.text.trim()}`- : last?.text?.trim() ? t('pet.repliedPrefix', { text: last.text.trim() })+ : reply ? t('pet.repliedPrefix', { text: reply }): t('pet.waiting');+ // A status word alone ("thinking", "waiting") sizes the bubble to its+ // content (§4.2); a reply, a failure or the open history take the column.+ const compact = !open && (props.running || (!props.failure && !reply));+ const bubbleRef = useWidthMorph(compact, reducedMotion);const detailId = useId();const { ref: fadeRef, measure: measureFade, style: fadeStyle } = useScrollEdgeFade(open, HISTORY_FADE);// The toggle stays first in the DOM, so focus order is unchanged, but the// bubble lays out bottom-up: the toggle keeps its place at the bottom and// the history opens above it, so expanding never moves what was clicked.return (- <div className="pet-mini-reply-bubble is-main" data-pet-hit>+ <div ref={bubbleRef} className={clsx('pet-mini-reply-bubble is-main', compact && 'is-compact')} data-pet-hit><button type="button" className="pet-mini-reply-toggle" onClick={onToggle} aria-expanded={open} aria-controls={detailId}><span className="pet-mini-bubble-speaker">{t('pet.mainAgent')}<span>{t(open ? 'pet.collapseHistory' : 'pet.recentTurns')}<ChevronUp size={11} /></span></span><p title={summary}>{props.running && <span className="pet-mini-running-dot" aria-hidden />}<span className="pet-mini-reply-summary">{summary}</span></p>@@ -1335,9 +1442,17 @@ const MainDetail: React.FC<MainDetailProps> = (props) => {const inner = innerRef.current;const history = inner?.closest<HTMLElement>('.pet-mini-bubble-history');if (!inner || !history) return undefined;- const toBottom = () => { history.scrollTop = history.scrollHeight - history.clientHeight; };+ // The box also shrinks while open (the input below it grows). The scroll+ // event of a pin arrives a frame later, read against a box that may have+ // shrunk since; it is the pin's own, not a reader scrolling up.+ let own = -1;+ const toBottom = () => { history.scrollTop = history.scrollHeight - history.clientHeight; own = history.scrollTop; };let pinned = true;- const onScroll = () => { pinned = history.scrollHeight - history.clientHeight - history.scrollTop <= HISTORY_STICK_PX; };+ const onScroll = () => {+ if (history.scrollTop === own) return;+ own = -1;+ pinned = history.scrollHeight - history.clientHeight - history.scrollTop <= HISTORY_STICK_PX;+ };toBottom();history.addEventListener('scroll', onScroll);const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => { if (pinned) toBottom(); });diff --git a/ui/src/pet/pet-mini.css b/ui/src/pet/pet-mini.cssindex 8963e3be3..251f4bdda 100644--- a/ui/src/pet/pet-mini.css+++ b/ui/src/pet/pet-mini.css@@ -14,6 +14,8 @@--pet-dismiss-hover:#4a4a50}.pet-mini-column {+ /* Between Vibey's bubble and the input below it: room for the bubble's tail. */+ --pet-input-gap:14px;position:absolute;left:50%;bottom:147px;@@ -791,7 +793,24 @@ to {mask, so it stays crisp and collapses away with the detail. */.pet-mini-reply-bubble.is-main {display:flex;- flex-direction:column-reverse}+ flex-direction:column-reverse;+ /* Centred on Vibey at every width; at full width the margins are zero. */+ margin-inline:auto;+ /* Runs only while useWidthMorph sets an inline width (§4.2). */+ transition:width 300ms var(--settle)}+/* A status word alone (thinking, waiting) sizes the bubble to its content,+ centred on Vibey like the column, so it grows from the centre and its tail+ never moves. The closed history must not lend it its own text's width. */+.pet-mini-reply-bubble.is-main.is-compact {+ width:fit-content;+ min-width:min(160px,100%);+ max-width:100%}+.pet-mini-reply-bubble.is-main.is-compact > .pet-mini-detail {+ contain:inline-size}+/* With the input or the marquee below it, the open history leaves room for+ the bubble's tail before the input. */+.pet-mini-bubble-over-input {+ margin-bottom:var(--pet-input-gap)}.pet-mini-reply-bubble.is-main .pet-mini-detail-clip {position:relative}.pet-mini-reply-bubble.is-main .pet-mini-detail-clip:after {@@ -815,6 +834,7 @@ to {display:flex;align-items:center;justify-content:space-between;+ gap:12px;color:var(--mint-ink);font-size:11px;line-height:16px;@@ -847,8 +867,9 @@ to {z-index:1;border-radius:21px 21px 0 0;/* Share the list's 292px box, bounded by the fixed avatar/dock reservation- (147px), bubble header (62px), top inset (16px), and measured stack. */- max-height:min(292px,max(0px,calc(100dvh - 225px - var(--pet-collapsed-height,0px))));+ (147px), bubble header (62px), top inset (16px), the measured stack, and+ the measured input below an open history (with its gap). */+ max-height:min(292px,max(0px,calc(100dvh - 225px - var(--pet-collapsed-height,0px) - var(--pet-input-space,0px))));overflow:auto;overscroll-behavior:contain;/* Hidden like the card list (§3.2); the edge fades show there is more. */