Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

feat(pet): draw a lone activity card in full, whatever the panel state (#2837)

Max7a71d4cc6e66
diff --git a/docs/plans/2026-10-12-desktop-mini-main-agent.md b/docs/plans/2026-10-12-desktop-mini-main-agent.md
index 3f9bde595..d3354ede3 100644
--- a/docs/plans/2026-10-12-desktop-mini-main-agent.md
+++ b/docs/plans/2026-10-12-desktop-mini-main-agent.md
@@ -116,6 +116,17 @@ the main agent; there is no Follow up on cards.
### 3.3 Collapsed stack
+A stack needs at least **two** visible cards. **Exactly one** visible card is
+never collapsed: it is always drawn in its full expanded form (stop or
+authorize, Open in Avibe, × on hover, click to reference) at its own height,
+whatever the panel state. Clicking Vibey does not change it, so Vibey's button
+carries no `aria-expanded` then. With a lone card a Vibey click toggles no
+panel state at all, so nothing waits to appear when a second card arrives: it
+closes an open history (and the panel with it) and otherwise does nothing. All of the card's controls are hit regions in
+every panel state. Opening the history keeps the card in full beside it, and
+the history's height bound uses the card's measured height. Going between one
+and two cards follows the data with the ordinary swap transition.
+
- **Front card:** the **first** card (the main agent card when it exists),
showing its title and subtitle only: no ×, no stop button.
- **Layers:** at most **three** behind the front card, regardless of the
@@ -144,8 +155,8 @@ the main agent; there is no Follow up on cards.
| 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 activity cards only. 20px circle at the top-left corner, offset −6px/−6px. Hidden until the card is hovered or receives focus within; always visible when hover is unavailable. Background `#3a3a3e`, glyph 11px `white / 70%`; on hover `#4a4a50` with a white glyph. Sits above the card content. |
-| Stop | Expanded list only, running sub-tasks only (§6). A 32px circle with background `white / 10%` and a filled rounded-square SVG icon at `white / 80%`. Its right gap and top gap to the card edge are both 16px. |
+| × (dismiss) | Expanded activity cards only (a lone card always counts as expanded, §3.3). 20px circle at the top-left corner, offset −6px/−6px. Hidden until the card is hovered or receives focus within; always visible when hover is unavailable. Background `#3a3a3e`, glyph 11px `white / 70%`; on hover `#4a4a50` with a white glyph. Sits above the card content. |
+| Stop | Expanded list or a lone card only (§3.3), running sub-tasks only (§6). A 32px circle with background `white / 10%` and a filled rounded-square SVG icon at `white / 80%`. Its right gap and top gap to the card edge are both 16px. |
- There is **no reply/return button** and **no Follow up** (owner decisions).
- **Icons are SVG**, never Unicode glyphs. iOS renders `↩` as a blue emoji.
diff --git a/ui/e2e/pet-mini/fixture.tsx b/ui/e2e/pet-mini/fixture.tsx
index 682a4b376..a492f9218 100644
--- a/ui/e2e/pet-mini/fixture.tsx
+++ b/ui/e2e/pet-mini/fixture.tsx
@@ -39,6 +39,7 @@ declare global {
setPetMainAvailable: (available: boolean) => void;
petFixtureConnection: (connected: boolean) => void;
petFixtureMessage: (message: Record<string, unknown>) => void;
+ petFixtureAddActivity: () => void;
}
}
window.petLayoutHitRegions = [];
@@ -175,6 +176,13 @@ window.petFixtureMessage = (message) => {
stream.dispatchEvent(new MessageEvent('message.new', { data: JSON.stringify({ type: 'message.new', data }) }));
}
};
+// Start one more visible activity, announced the way a run change is.
+window.petFixtureAddActivity = () => {
+ agents.push({ ...agents[0], session_id: `ses_fixture_${agents.length}`, base_session_id: `native_${agents.length}`, title: 'Another task' });
+ for (const stream of streams) {
+ stream.dispatchEvent(new MessageEvent('runs.updated', { data: JSON.stringify({ type: 'runs.updated', data: { run_id: `run_${agents.length}`, status: 'running' } }) }));
+ }
+};
const root = createRoot(document.getElementById('root')!);
window.setPetLayoutVisible = (visible) => root.render(
diff --git a/ui/e2e/pet-mini/layout.spec.ts b/ui/e2e/pet-mini/layout.spec.ts
index baafea9df..433c8c5b6 100644
--- a/ui/e2e/pet-mini/layout.spec.ts
+++ b/ui/e2e/pet-mini/layout.spec.ts
@@ -121,23 +121,16 @@ for (const cards of [2, 4, 20]) {
});
}
-for (const cards of [1, 2, 12, 120]) {
+// One card is never a stack; see "one card is always drawn in full".
+for (const cards of [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-stack-count')).toHaveText(`${displayCount} items`);
await expect(page.locator('.pet-mini-collapsed')).toHaveAttribute(
'aria-label',
- expectedLabel,
+ `Expand ${displayCount} session cards`,
);
});
}
@@ -198,7 +191,7 @@ test('Vibey and its dock are reported as the hover zone, and a shell hover shows
})).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 card = document.querySelector('.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);
@@ -781,3 +774,147 @@ for (const theme of ['light', 'dark']) {
await expect(tooltip).toHaveCount(0);
});
}
+
+for (const theme of ['light', 'dark']) {
+ test(`one card is always drawn in full and Vibey does not toggle it (${theme})`, async ({ page }) => {
+ await page.goto('/e2e/pet-mini/fixture.html?activities=1');
+ await page.evaluate((theme) => { document.documentElement.dataset.theme = theme; }, theme);
+ const settle = () => page.evaluate(async () => {
+ await Promise.all(document.getAnimations()
+ .filter((animation) => animation.effect?.getTiming().iterations !== Infinity)
+ .map((animation) => animation.finished.catch(() => {})));
+ });
+ const card = page.locator('.pet-mini-card');
+ const stop = card.locator('.pet-mini-stop');
+ const open = card.locator('.pet-mini-open');
+ const avatar = page.locator('.pet-mini-avatar-button');
+ await expect(card).toHaveCount(1);
+ await expect(stop).toBeVisible();
+ await expect(open).toBeVisible();
+ await expect(page.locator('.pet-mini-collapsed')).toHaveCount(0);
+ await expect(page.locator('.pet-mini-stack-count')).toHaveCount(0);
+ expect(await avatar.getAttribute('aria-expanded')).toBeNull();
+ await settle();
+ const box = await card.boundingBox();
+
+ for (let click = 0; click < 2; click += 1) {
+ await avatar.click();
+ await settle();
+ expect(await card.boundingBox()).toEqual(box);
+ await expect(stop).toBeVisible();
+ await expect(open).toBeVisible();
+ await expect(page.locator('.pet-mini-collapsed')).toHaveCount(0);
+ expect(await avatar.getAttribute('aria-expanded')).toBeNull();
+ }
+
+ // The window passes clicks through except over hit regions, so every
+ // control of the card must be one, without opening anything first.
+ const inRegions = async (locator: typeof card) => {
+ const target = (await locator.boundingBox())!;
+ const x = target.x + target.width / 2, y = target.y + target.height / 2;
+ return page.evaluate(([x, y]) => window.petLayoutHitRegions.some((rect) =>
+ x >= rect.x && x < rect.x + rect.width && y >= rect.y && y < rect.y + rect.height), [x, y]);
+ };
+ await expect.poll(() => inRegions(stop)).toBe(true);
+ await expect.poll(() => inRegions(open)).toBe(true);
+ await card.hover();
+ const dismiss = page.locator('.pet-mini-dismiss');
+ await expect(dismiss).toBeVisible();
+ await expect.poll(() => inRegions(dismiss)).toBe(true);
+
+ // The lone card's open button is the shared one: the pet tooltip, and no
+ // native tooltip inherited from the card's title.
+ expect(await open.getAttribute('title')).toBe('');
+ await open.hover();
+ await expect(page.getByRole('tooltip')).toHaveText('Open in Avibe');
+ await open.click();
+ await expect.poll(() => page.evaluate(() => window.petFixtureOpens)).toEqual(['avibe://session/ses_fixture_0']);
+ await stop.click();
+ await expect(stop).toHaveAttribute('aria-label', 'Stop?');
+ await dismiss.click();
+ await expect(card).toHaveCount(0);
+ });
+
+ test(`one card stays in full beside the open history and everything fits (${theme})`, async ({ page }) => {
+ await page.goto('/e2e/pet-mini/fixture.html?scenario=personal&lang=zh&activities=1&history=long');
+ await page.evaluate((theme) => { document.documentElement.dataset.theme = theme; }, theme);
+ const card = page.locator('.pet-mini-card');
+ await expect(card.locator('.pet-mini-open')).toBeVisible();
+ const anchor = await page.locator('.pet-mini-avatar-button').boundingBox();
+ await page.locator('.pet-mini-reply-toggle').click();
+ await expect(page.locator('.pet-mini-reply-bubble .pet-mini-detail')).toHaveClass(/is-open/);
+ await page.evaluate(async () => {
+ await Promise.all(document.getAnimations()
+ .filter((animation) => animation.effect?.getTiming().iterations !== Infinity)
+ .map((animation) => animation.finished.catch(() => {})));
+ });
+ await expect(card).toBeVisible();
+ await expect(card.locator('.pet-mini-open')).toBeVisible();
+ const cardBox = (await card.boundingBox())!;
+ const bubble = (await page.locator('.pet-mini-reply-bubble').boundingBox())!;
+ const avatar = (await page.locator('.pet-mini-avatar-button').boundingBox())!;
+ expect(cardBox.y).toBeGreaterThanOrEqual(0);
+ expect(cardBox.y + cardBox.height).toBeLessThanOrEqual(bubble.y);
+ expect(avatar).toEqual(anchor);
+ expect(bubble.y + bubble.height).toBeLessThanOrEqual(600);
+ expect(avatar.y + avatar.height).toBeLessThanOrEqual(600);
+ });
+}
+
+test('Vibey clicks with a lone card leave no hidden expansion for a second card', async ({ page }) => {
+ await page.goto('/e2e/pet-mini/fixture.html?activities=1');
+ const avatar = page.locator('.pet-mini-avatar-button');
+ await expect(page.locator('.pet-mini-card')).toHaveCount(1);
+ await avatar.click();
+ await avatar.click();
+ await avatar.click();
+ await page.evaluate(() => window.petFixtureAddActivity());
+ await expect(page.locator('.pet-mini-collapsed')).toBeVisible();
+ await expect(page.locator('.pet-mini-stack-count')).toHaveText('2 items');
+ await expect(page.locator('.pet-mini-scroll')).toHaveCount(0);
+ await expect(avatar).toHaveAttribute('aria-expanded', 'false');
+});
+
+test('with a lone card, Vibey closes the open history and leaves the card alone', async ({ page }) => {
+ await page.goto('/e2e/pet-mini/fixture.html?scenario=personal&activities=1');
+ const card = page.locator('.pet-mini-card');
+ const avatar = page.locator('.pet-mini-avatar-button');
+ await expect(card.locator('.pet-mini-open')).toBeVisible();
+ await page.locator('.pet-mini-reply-toggle').click();
+ await expect(page.locator('.pet-mini-reply-bubble .pet-mini-detail')).toHaveClass(/is-open/);
+ const size = async () => {
+ await page.evaluate(async () => {
+ await Promise.all(document.getAnimations()
+ .filter((animation) => animation.effect?.getTiming().iterations !== Infinity)
+ .map((animation) => animation.finished.catch(() => {})));
+ });
+ const box = (await card.boundingBox())!;
+ return { width: box.width, height: box.height };
+ };
+ const before = await size();
+ await avatar.click();
+ await expect(page.locator('.pet-mini-reply-bubble .pet-mini-detail')).not.toHaveClass(/is-open/);
+ // The card moves down with the shrinking bubble, but keeps its full form.
+ await expect(card.locator('.pet-mini-open')).toBeVisible();
+ await expect(card.locator('.pet-mini-authorize')).toBeVisible();
+ expect(await size()).toEqual(before);
+ // Nothing was left expanded behind it either.
+ await page.evaluate(() => window.petFixtureAddActivity());
+ await expect(page.locator('.pet-mini-collapsed')).toBeVisible();
+ await expect(page.locator('.pet-mini-scroll')).toHaveCount(0);
+});
+
+test('two or more cards keep the collapsed stack that Vibey toggles', async ({ page }) => {
+ await page.goto('/e2e/pet-mini/fixture.html?activities=2');
+ const avatar = page.locator('.pet-mini-avatar-button');
+ await expect(page.locator('.pet-mini-collapsed')).toBeVisible();
+ await expect(page.locator('.pet-mini-stack-count')).toBeVisible();
+ await expect(avatar).toHaveAttribute('aria-expanded', 'false');
+ await avatar.click();
+ await expect(page.locator('.pet-mini-scroll')).toBeVisible();
+ await expect(page.locator('.pet-mini-card')).toHaveCount(2);
+ await expect(avatar).toHaveAttribute('aria-expanded', 'true');
+ await avatar.click();
+ await expect(page.locator('.pet-mini-collapsed')).toBeVisible();
+ await expect(avatar).toHaveAttribute('aria-expanded', 'false');
+});
diff --git a/ui/src/pet/PetPage.tsx b/ui/src/pet/PetPage.tsx
index bb8fde13f..27e472f16 100644
--- a/ui/src/pet/PetPage.tsx
+++ b/ui/src/pet/PetPage.tsx
@@ -267,6 +267,16 @@ const PetSurface: React.FC = () => {
void setPanel(true);
}, [setPanel]);
const togglePanel = () => {
+ // A lone card has no stack to open (§3.3). Vibey still closes an open
+ // history, but otherwise toggles nothing: flipping the panel state here
+ // would be invisible until a second card arrived and opened the list.
+ if (singleCard) {
+ if (detailOpen) {
+ setDetailOpen(false);
+ void setPanel(false);
+ }
+ return;
+ }
if (detailOpen) openCards();
else void setPanel(!petPanel.want());
};
@@ -612,9 +622,15 @@ const PetSurface: React.FC = () => {
useHitRegions(rootRef, epoch);
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
+ // open, so Vibey's panel toggle never changes it, and it is measured like the
+ // collapsed stack so the history beside it is sized for its real height.
+ const singleCard = visibleCards.length === 1;
+ const cardsFull = cardsExpanded || singleCard;
+ const cardsListed = cardsExpanded && !singleCard;
useLayoutEffect(() => {
const node = collapsedRef.current;
- if (!node || cardsExpanded) return;
+ if (!node || cardsListed) return;
// The entrance scales this wrapper; layout height must include its spacing
// without capturing that transient transform.
const measure = () => setCollapsedHeight(node.offsetHeight);
@@ -622,7 +638,7 @@ const PetSurface: React.FC = () => {
const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure);
observer?.observe(node);
return () => observer?.disconnect();
- }, [cardsExpanded, visibleCards.length]);
+ }, [cardsListed, visibleCards.length]);
const queued = (data.turn?.pending_input_count ?? 0) > 0;
const resolvingMain = data.canChat === null;
@@ -639,7 +655,8 @@ const PetSurface: React.FC = () => {
type="button"
className="pet-mini-avatar-button"
aria-label={t('pet.toggle')}
- aria-expanded={expanded}
+ // A lone card is always drawn in full, so Vibey expands nothing there.
+ aria-expanded={singleCard ? undefined : expanded}
data-pet-hit
onClick={(event) => { if (event.detail === 0) togglePanel(); }}
onPointerDown={(event) => {
@@ -711,11 +728,12 @@ 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.listening && 'is-voice-active')} style={{ '--pet-collapsed-height': `${collapsedHeight}px` } as CSSProperties}>
- <div className={clsx('pet-mini-cards', voice.listening && 'is-hidden')} inert={voice.listening || undefined} aria-label={cardsExpanded ? t('pet.panel') : undefined} style={{ height: cardsExpanded ? (visibleCards.length > 0 ? STACK_HEIGHT : 'auto') : collapsedHeight }}>
- <div ref={collapsedRef} key={cardsExpanded ? 'expanded' : 'collapsed'} className="pet-mini-swap is-switching" onAnimationEnd={(event) => { if (event.target === event.currentTarget) event.currentTarget.classList.remove('is-switching'); }}>
+ <div className={clsx('pet-mini-cards', voice.listening && 'is-hidden')} inert={voice.listening || 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 && (
- cardsExpanded ? (
+ cardsFull ? (
<ExpandedCards
+ natural={singleCard}
cards={visibleCards}
leaving={leaving}
onReference={referenceCard}
@@ -1057,11 +1075,13 @@ function useScrollEdgeFade(contentKey: unknown, profile: FadeProfile) {
return { ref, measure, style: { maskImage: mask, WebkitMaskImage: mask } satisfies CSSProperties };
}
-const ExpandedCards: React.FC<{ cards: PetCard[]; leaving: string[]; onReference: (card: PetCard) => void; onDismiss: (card: PetCard) => void; stops: Record<string, StopPhase>; onStop: (card: PetCard) => void; t: (key: string, options?: Record<string, unknown>) => string }> = ({ cards, leaving, onReference, onDismiss, stops, onStop, t }) => {
+/** The full card list. `natural` sizes it to its content instead of the 292px
+ * scroll box, for the lone card that is always drawn in full. */
+const ExpandedCards: React.FC<{ natural?: boolean; cards: PetCard[]; leaving: string[]; onReference: (card: PetCard) => void; onDismiss: (card: PetCard) => void; stops: Record<string, StopPhase>; onStop: (card: PetCard) => void; t: (key: string, options?: Record<string, unknown>) => string }> = ({ natural = false, cards, leaving, onReference, onDismiss, stops, onStop, t }) => {
const { ref: fadeRef, measure: measureFade, style: fadeStyle } = useScrollEdgeFade(cards.length, CARD_FADE);
return (
- <div className="pet-mini-panel">
- <div ref={fadeRef} onScroll={measureFade} className="pet-mini-scroll" style={fadeStyle}>
+ <div className={clsx('pet-mini-panel', natural && 'is-natural')}>
+ <div ref={fadeRef} onScroll={measureFade} className="pet-mini-scroll" style={natural ? undefined : fadeStyle}>
<ul className="pet-mini-list">
{cards.map((card) => {
const phase = stops[card.id];
diff --git a/ui/src/pet/pet-mini.css b/ui/src/pet/pet-mini.css
index ee7d6d27a..8963e3be3 100644
--- a/ui/src/pet/pet-mini.css
+++ b/ui/src/pet/pet-mini.css
@@ -146,6 +146,10 @@ to {
.pet-mini-scroll::-webkit-scrollbar {
display:none}
+/* A lone card is drawn in full at its own height: nothing to scroll, no fade. */
+.pet-mini-panel.is-natural .pet-mini-scroll {
+ height:auto;
+ overflow:visible}
.pet-mini-list {
display:flex;
flex-direction:column;