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(ui): cap collapsed pet stack layers (#2722)
Maxb974019f7af5
diff --git a/docs/plans/2026-10-12-desktop-mini-main-agent.md b/docs/plans/2026-10-12-desktop-mini-main-agent.mdindex 878b95f65..35135454c 100644--- a/docs/plans/2026-10-12-desktop-mini-main-agent.md+++ b/docs/plans/2026-10-12-desktop-mini-main-agent.md@@ -118,8 +118,8 @@ the main agent; there is no Follow up on cards.- **Front card:** the **first** card (the main agent card when it exists),showing its title and subtitle only: no ×, no stop button.-- **Layers:** **one per remaining card**, behind the front card (6 cards →- front card + 5 layers). For layer `i` (0-based, nearest first):+- **Layers:** at most **three** behind the front card, regardless of the+ number of remaining cards. For layer `i` (0-based, nearest first):- **the same height as the front card**, offset `(i + 1) × 9px` below it,so its bottom edge peeks out `(i + 1) × 9px` under the front card'sbottom whatever the front card's height. Do not use a fixed layer height:@@ -129,7 +129,10 @@ the main agent; there is no Follow up on cards.- radius 24px, background `#1a1a1e`, border `white / 8%`;- **the same opacity as the front card** (no per-depth fade);- nearer layers stack above farther ones.-- The stack's height is the front card plus `layers × 9px`.+- The stack's height is the front card plus up to `3 × 9px`.+- When there are at least two cards, the front card's eyebrow row shows a+ muted count chip: `N items` in English or `共 N 项` in Chinese. Counts above+ 99 display as `99+`.- The whole stack is one button: a click expands it.## 4. Cards@@ -596,8 +599,9 @@ GET /api/sessions/main- [ ] Vibey never moves for any interaction in this spec.- [ ] Collapsed: the front card is the first card (main when present); there- is one layer per other card, with 9px steps, a `18+6+3i` inset and the- same opacity as the front card.+ are at most three layers, with 9px steps, a `18+6+3i` inset and the+ same opacity as the front card. Two or more cards show the count chip,+ capped at `99+`.- [ ] Clicking Vibey or the stack expands upward (360ms settle, height pluscontent fade); clicking Vibey again collapses.- [ ] Expanded: fixed 3.5-card box; cards bottom-aligned; overflow scrolls;diff --git a/ui/e2e/pet-mini/layout.spec.ts b/ui/e2e/pet-mini/layout.spec.tsindex a70fb605f..de2072ee8 100644--- a/ui/e2e/pet-mini/layout.spec.ts+++ b/ui/e2e/pet-mini/layout.spec.ts@@ -63,7 +63,8 @@ for (const main of [true, false]) {const errors: string[] = [];page.on('pageerror', (error) => errors.push(error.message));await page.goto(`/e2e/pet-mini/fixture.html?main=${main}&layers=${layers}`);- await expect(page.locator('.pet-mini-layer')).toHaveCount(layers);+ const renderedLayers = Math.min(layers, 3);+ await expect(page.locator('.pet-mini-layer')).toHaveCount(renderedLayers);// Wait for the real CSS entrance before measuring its transformed bounds.await page.locator('.pet-mini-swap').evaluate(async (node) => {await Promise.all(node.getAnimations().map((animation) => animation.finished));@@ -73,8 +74,8 @@ for (const main of [true, false]) {const backs = Array.from(stack.querySelectorAll('.pet-mini-layer'), (layer) => layer.getBoundingClientRect().toJSON());return { stack: stack.getBoundingClientRect().toJSON(), front: front.toJSON(), backs };});- expect(bounds.stack.height).toBeCloseTo(bounds.front.height + layers * 9, 1);- expect(bounds.backs.at(-1)!.bottom - bounds.front.bottom).toBeCloseTo(layers * 9, 1);+ expect(bounds.stack.height).toBeCloseTo(bounds.front.height + renderedLayers * 9, 1);+ expect(bounds.backs.at(-1)!.bottom - bounds.front.bottom).toBeCloseTo(renderedLayers * 9, 1);for (const [index, layer] of bounds.backs.entries()) {expect(layer.height).toBeCloseTo(bounds.front.height, 1);expect(layer.bottom - bounds.front.bottom).toBeCloseTo((index + 1) * 9, 1);@@ -108,6 +109,53 @@ for (const main of [true, false]) {}}+for (const cards of [2, 4, 20]) {+ test(`caps collapsed layers for ${cards} cards`, async ({ page }) => {+ await page.goto(`/e2e/pet-mini/fixture.html?activities=${cards}&layers=1`);+ await expect(page.locator('.pet-mini-collapsed')).toBeVisible();+ await expect(page.locator('.pet-mini-layer')).toHaveCount(Math.min(cards - 1, 3));+ await expect(page.locator('.pet-mini-collapsed')).toHaveAttribute(+ 'aria-label',+ `Expand ${cards} session cards`,+ );+ });+}++for (const cards of [1, 2, 12, 120]) {+ test(`shows the collapsed count for ${cards} cards`, async ({ page }) => {+ await page.goto(`/e2e/pet-mini/fixture.html?activities=${cards}&layers=1`);+ await expect(page.locator('.pet-mini-collapsed')).toBeVisible();+ const displayCount = cards > 99 ? '99+' : String(cards);+ const countChip = page.locator('.pet-mini-stack-count');+ if (cards === 1) {+ await expect(countChip).toHaveCount(0);+ } else {+ await expect(countChip).toHaveText(`${displayCount} items`);+ }+ const expectedLabel = cards === 1+ ? `Expand ${displayCount} session card`+ : `Expand ${displayCount} session cards`;+ await expect(page.locator('.pet-mini-collapsed')).toHaveAttribute(+ 'aria-label',+ expectedLabel,+ );+ });+}++for (const theme of ['light', 'dark']) {+ for (const cards of [2, 4, 20]) {+ test(`captures collapsed stack count (${theme}, ${cards} cards)`, async ({ page }, testInfo) => {+ await page.goto(`/e2e/pet-mini/fixture.html?activities=${cards}&layers=1`);+ await page.evaluate((theme) => { document.documentElement.dataset.theme = theme; }, theme);+ await expect(page.locator('.pet-mini-collapsed')).toBeVisible();+ await page.locator('.pet-mini-swap').evaluate(async (node) => {+ await Promise.all(node.getAnimations().map((animation) => animation.finished));+ });+ await page.screenshot({ path: testInfo.outputPath(`collapsed-${theme}-${cards}.png`), scale: 'css', animations: 'disabled' });+ });+ }+}+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();diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex bbdfd7598..358f81291 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -5942,7 +5942,10 @@"close": "Close input"},"stack": {- "expand": "Expand session cards"+ "count_one": "{{displayCount}} item",+ "count_other": "{{displayCount}} items",+ "expand_one": "Expand {{displayCount}} session card",+ "expand_other": "Expand {{displayCount}} session cards"},"activityKind": {"watch": "Monitor",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex ff81da902..a4faa792c 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -5942,7 +5942,10 @@"close": "关闭输入"},"stack": {- "expand": "展开会话卡片"+ "count_one": "共 {{displayCount}} 项",+ "count_other": "共 {{displayCount}} 项",+ "expand_one": "展开 {{displayCount}} 张卡片",+ "expand_other": "展开 {{displayCount}} 张卡片"},"activityKind": {"watch": "监控",diff --git a/ui/src/pet/PetPage.tsx b/ui/src/pet/PetPage.tsxindex e0eaed3a7..01e214a8b 100644--- a/ui/src/pet/PetPage.tsx+++ b/ui/src/pet/PetPage.tsx@@ -36,6 +36,8 @@ const STOP_CONFIRM_MS = 3000;const STOP_LINGER_MS = 2500;const STACK_HEIGHT = 304; // 292px scroll box + 6px panel padding on each side.const FADE_PX = 32;+const MAX_COLLAPSED_LAYERS = 3;+const MAX_COLLAPSED_COUNT = 99;const EMPTY_INBOX: InboxSession[] = [];const REFUSED_SEND_STATUSES = new Set([400, 403, 404, 409, 422]);const sendRefused = (error: unknown) => error instanceof ApiError && REFUSED_SEND_STATUSES.has(error.status);@@ -710,7 +712,7 @@ const PetSurface: React.FC = () => {t={(key, options) => String(t(key as never, options as never))}/>) : (- <CollapsedCards cards={visibleCards} onOpen={openCards} t={(key) => String(t(key as never))} />+ <CollapsedCards cards={visibleCards} onOpen={openCards} t={(key, options) => String(t(key as never, options as never))} />))}</div>@@ -982,16 +984,32 @@ const MiniDock: React.FC<{ enabled: boolean; listening: boolean; typing: boolean</div>);-const CollapsedCards: React.FC<{ cards: PetCard[]; onOpen: () => void; t: (key: string) => string }> = ({ cards, onOpen, t }) => {- const [front, ...layers] = cards;+const CollapsedCards: React.FC<{ cards: PetCard[]; onOpen: () => void; t: (key: string, options?: Record<string, unknown>) => string }> = ({ cards, onOpen, t }) => {+ const [front, ...remainingCards] = cards;if (!front) return null;+ const layers = remainingCards.slice(0, MAX_COLLAPSED_LAYERS);+ const count = cards.length;+ const displayCount = count > MAX_COLLAPSED_COUNT ? `${MAX_COLLAPSED_COUNT}+` : String(count);return (- <button type="button" className="pet-mini-collapsed" style={{ paddingBottom: layers.length * 9 }} onClick={onOpen} aria-label={t('pet.stack.expand')}>+ <button+ type="button"+ className="pet-mini-collapsed"+ style={{ paddingBottom: layers.length * 9 }}+ onClick={onOpen}+ aria-label={t('pet.stack.expand', { count, displayCount })}+ >{layers.map((card, index) => {const inset = 18 + 6 + index * 3;return <span key={card.id} data-pet-hit className="pet-mini-layer" style={{ top: (index + 1) * 9, bottom: (layers.length - index - 1) * 9, left: inset, right: inset, zIndex: layers.length - index }} aria-hidden />;})}- <div className="pet-mini-front" style={{ zIndex: layers.length + 1 }}><CardBody card={front} expanded={false} t={t} /></div>+ <div className="pet-mini-front" style={{ zIndex: layers.length + 1 }}>+ <CardBody+ card={front}+ expanded={false}+ t={t}+ stackCount={count > 1 ? t('pet.stack.count', { count, displayCount }) : undefined}+ />+ </div></button>);};@@ -1038,7 +1056,7 @@ const ExpandedCards: React.FC<{ cards: PetCard[]; leaving: string[]; onReference);};-const CardBody: React.FC<{ card: PetCard; expanded: boolean; t: (key: string, options?: Record<string, unknown>) => string; phase?: StopPhase; onDismiss?: () => void; onStop?: () => void; onClick?: () => void }> = ({ card, expanded, t, phase, onDismiss, onStop, onClick }) => {+const CardBody: React.FC<{ card: PetCard; expanded: boolean; t: (key: string, options?: Record<string, unknown>) => string; stackCount?: string; phase?: StopPhase; onDismiss?: () => void; onStop?: () => void; onClick?: () => void }> = ({ card, expanded, t, stackCount, phase, onDismiss, onStop, onClick }) => {const running = card.running && phase !== 'stopped' && phase !== 'stopping';const subtitle = phase === 'stopping' ? t('pet.stop.stopping') : phase === 'stopped' ? t('pet.stop.stopped') : phase === 'failed' ? t('pet.stop.failed') : card.status;const stopText = phase === 'confirm' ? t('pet.stop.confirmStop') : t('pet.stop.stop', { title: card.title });@@ -1047,7 +1065,10 @@ const CardBody: React.FC<{ card: PetCard; expanded: boolean; t: (key: string, op<article className={clsx('pet-mini-card', card.needsInput && 'is-needs-input')} title={card.title} data-session-id={card.sessionId} data-pet-hit>{expanded && <button type="button" className="pet-mini-dismiss" data-pet-hit onClick={onDismiss} aria-label={t('pet.dismiss')}><svg viewBox="0 0 16 16" aria-hidden><path d="m4 4 8 8M12 4 4 12" /></svg></button>}<Reference className="pet-mini-card-content pet-mini-card-reference" onClick={onClick} {...(expanded ? { type: 'button' as const, 'aria-label': t('pet.referenceSession', { title: card.title }) } : {})}>- <div className="pet-mini-eyebrow"><span title={card.eyebrow}>{card.eyebrow}</span></div>+ <div className="pet-mini-eyebrow">+ <span className="pet-mini-eyebrow-text" title={card.eyebrow}>{card.eyebrow}</span>+ {stackCount && <span className="pet-mini-stack-count">{stackCount}</span>}+ </div><div className="pet-mini-title">{card.title}</div><div className={clsx('pet-mini-subtitle', phase === 'stopped' && 'is-stopped')} title={subtitle}>{running && <span className="pet-mini-running-dot" aria-hidden />}diff --git a/ui/src/pet/pet-mini.css b/ui/src/pet/pet-mini.cssindex bc66a6ffc..a5a504c48 100644--- a/ui/src/pet/pet-mini.css+++ b/ui/src/pet/pet-mini.css@@ -688,11 +688,22 @@ to {gap:6px;line-height:16px;color:color-mix(in srgb,var(--pet-ink) 65%,transparent)}-.pet-mini-eyebrow > span {+.pet-mini-eyebrow-text {min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}+.pet-mini-stack-count {+ flex:none;+ margin-left:auto;+ padding:0 6px;+ border-radius:999px;+ color:color-mix(in srgb,var(--pet-ink) 55%,transparent);+ background:var(--pet-dismiss);+ font-size:11px;+ font-weight:500;+ line-height:16px;+ white-space:nowrap}.pet-mini-card.is-needs-input {border-color:var(--gold);background:color-mix(in srgb,var(--gold) 8%,var(--pet-card))}