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.

fix(desktop): make the mini session switcher a real control and stop it squashing rows

Max4a710e1f516b
diff --git a/ui/e2e/pet-mini/fixture.tsx b/ui/e2e/pet-mini/fixture.tsx
index 6ac882a3d..866cf9d8d 100644
--- a/ui/e2e/pet-mini/fixture.tsx
+++ b/ui/e2e/pet-mini/fixture.tsx
@@ -22,6 +22,7 @@ petBridge.setHitRegions = async (rects) => { window.petLayoutHitRegions = rects;
const params = new URLSearchParams(location.search);
const hasMain = params.get('main') !== 'false';
const layers = Number(params.get('layers') ?? 3);
+const sessionCount = Number(params.get('sessions') ?? 1);
const title = 'A long unbroken title '.repeat(40);
const session = {
id: 'pet-layout', scope_id: 'fixture', title, agent_backend: 'codex',
@@ -37,6 +38,7 @@ const activities = Array.from({ length: layers + (hasMain ? 0 : 1) }, (_, i) =>
description: title, backend: 'codex', runtime_key: `fixture-${i}`,
session_id: session.id, kind: 'watch', started_at: '2026-10-12T00:00:00Z',
}));
+const switcherSessions = [session, ...Array.from({ length: sessionCount - 1 }, (_, i) => ({ ...session, id: `fixture-session-${i}`, title: `Session ${i + 1} ${title}` }))];
localStorage.setItem('avibe.pet.devBinding', JSON.stringify({ binding: session.id, revision: 1 }));
// Every API read is fixture-owned. Unexpected calls fail rather than reaching a
@@ -55,7 +57,7 @@ window.fetch = async (input) => {
'/api/vault/requests': { ok: true, requests: [] },
'/api/asr/status': { available: false },
'/api/running-agents': { ok: true, agents: [], counts: { total: 0, active: 0, idle: 0, orphan: 0, by_backend: {} } },
- '/api/sessions': { sessions: [session], next_before_id: null },
+ '/api/sessions': { sessions: switcherSessions, next_before_id: null },
'/api/inbox': { ok: true, sessions: [], unread_by_session: {}, total_unread: 0, next_before_id: null },
};
if (!(path in payloads)) throw new Error(`Unexpected pet fixture request: ${path}`);
diff --git a/ui/e2e/pet-mini/layout.spec.ts b/ui/e2e/pet-mini/layout.spec.ts
index 979bf09ae..431f81e17 100644
--- a/ui/e2e/pet-mini/layout.spec.ts
+++ b/ui/e2e/pet-mini/layout.spec.ts
@@ -79,3 +79,21 @@ for (const main of [true, false]) {
});
}
}
+
+test('the session picker keeps every row at its text height and scrolls', async ({ page }) => {
+ await page.goto('/e2e/pet-mini/fixture.html?main=true&layers=0&sessions=14');
+ await page.locator('.pet-mini-collapsed').click();
+ await page.locator('.pet-mini-card[role=button]').click();
+ const toggle = page.getByRole('button', { name: 'Switch session' });
+ await expect(toggle).toBeVisible();
+ // The switcher is a real button, not a text link.
+ expect(await toggle.evaluate((node) => getComputedStyle(node).borderTopStyle)).toBe('solid');
+ await toggle.click();
+ const options = page.locator('.pet-mini-session-option');
+ await expect(options).toHaveCount(15);
+ // A shrunk flex column squeezes overflow-hidden rows below their text height.
+ const rows = await options.evaluateAll((nodes) => nodes.map((node) => ({ client: node.clientHeight, content: node.scrollHeight })));
+ expect(rows.every((row) => row.client >= 36 && row.client >= row.content)).toBe(true);
+ const scroll = await page.locator('.pet-mini-scroll').evaluate((node) => ({ client: node.clientHeight, content: node.scrollHeight }));
+ expect(scroll.content).toBeGreaterThan(scroll.client);
+});
diff --git a/ui/src/pet/PetPage.tsx b/ui/src/pet/PetPage.tsx
index 306217124..150f7d16b 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 { ExternalLink, KeyRound } from 'lucide-react';
+import { ArrowLeftRight, ExternalLink, KeyRound } from 'lucide-react';
import { ApiError, useApi, type SessionActivityState, type WorkbenchMessage } from '@/context/ApiContext';
import { useInstanceAuthorization } from '@/context/InstanceAuthorizationContext';
@@ -600,6 +600,10 @@ const PetSurface: React.FC = () => {
);
};
+const SwitchSessionButton: React.FC<{ onClick: () => void; label: string }> = ({ onClick, label }) => (
+ <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 { t } = useTranslation();
const api = useApi();
@@ -625,7 +629,7 @@ const SessionPicker: React.FC<{ onPick: (sessionId: string) => void; canStartVib
<div className="pet-mini-panel" aria-label={t('pet.chooseSession')}>
<div className="pet-mini-scroll">
<div className="pet-mini-session-picker" data-pet-hit>
- {canStartVibey && <button type="button" onClick={pickVibey} disabled={vibeyPending} className="pet-mini-session-option">{t('pet.talkToVibey')}</button>}
+ {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>}
{sessions.length === 0 && <p className="pet-mini-detail-muted">{loading ? t('common.loading') : t('pet.noSessions')}</p>}
{sessions.map((session) => (
@@ -876,7 +880,7 @@ const ExpandedCards: React.FC<{ cards: PetCard[]; leaving: string[]; detailOpen:
return (
<div className="pet-mini-panel">
<div ref={scrollRef} onScroll={measure} className="pet-mini-scroll" style={{ maskImage: mask, WebkitMaskImage: mask }}>
- {onSwitch && <Button variant="link" size="sm" data-pet-hit onClick={onSwitch}>{t('pet.switchSession')}</Button>}
+ {onSwitch && <div className="pet-mini-action-row"><SwitchSessionButton onClick={onSwitch} label={t('pet.switchSession')} /></div>}
<ul className="pet-mini-list">
{cards.map((card) => {
const phase = stops[card.id];
@@ -942,7 +946,7 @@ const MainDetail: React.FC<{ epoch: PetSurfaceEpoch; voiceNeedsCloud: boolean; c
usePetMarkRead(props.epoch, props.binding, props.exchange, props.markRead, props.onRead, props.visible && (typeof IntersectionObserver === 'undefined' || (seenResult?.epoch === props.epoch && seenResult.key === resultKey)));
return (
<div className="pet-mini-detail-inner">
- <Button variant="link" size="sm" aria-label={t('pet.switchSession')} onClick={props.onSwitch}>{t('pet.switchSession')}</Button>
+ <div className="pet-mini-action-row"><SwitchSessionButton onClick={props.onSwitch} label={t('pet.switchSession')} /></div>
{props.exchange.user && <div className="pet-mini-detail-user"><Markdown content={props.exchange.user.text} softBreaks /></div>}
{props.exchange.results.map((message, index) => <div ref={index === props.exchange.results.length - 1 ? lastResultRef : undefined} key={message.id} className="pet-mini-detail-result"><Markdown content={message.text} softBreaks /></div>)}
{props.failure && (
diff --git a/ui/src/pet/pet-mini.css b/ui/src/pet/pet-mini.css
index 9cded0280..4b151853c 100644
--- a/ui/src/pet/pet-mini.css
+++ b/ui/src/pet/pet-mini.css
@@ -419,28 +419,89 @@ to {
color:color-mix(in srgb,var(--pet-ink) 30%,transparent);
cursor:default}
+/* The picker is a card like the others (no backing panel, §3.2), bottom-aligned
+ next to Vibey. `flex:none` keeps the scroll box from shrinking it to 292px: a
+ shrunk column squeezes its overflow-hidden rows below their text height. */
.pet-mini-session-picker {
display:flex;
- min-height:100%;
+ flex:none;
flex-direction:column;
- justify-content:flex-start;
gap:2px;
- padding:4px}
+ min-width:0;
+ margin-top:auto;
+ border:1px solid color-mix(in srgb,var(--pet-ink) 8%,transparent);
+ 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;
+ font-size:13px}
.pet-mini-session-option {
+ flex:none;
min-width:0;
border:0;
border-radius:12px;
background:transparent;
- padding:9px 10px;
+ padding:9px 12px;
color:var(--pet-ink);
text-align:left;
font-size:13px;
+ line-height:19.5px;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
cursor:pointer}
.pet-mini-session-option:hover {
background:color-mix(in srgb,var(--pet-ink) 8%,transparent)}
+.pet-mini-session-option:disabled {
+ cursor:default;
+ opacity:.5}
+.pet-mini-session-option.is-vibey {
+ color:color-mix(in srgb,var(--mint) 90%,transparent);
+ font-weight:600}
+
+/* Small pill action on the dark mini surface ("Switch session"). */
+.pet-mini-action-row {
+ display:flex;
+ justify-content:flex-end;
+ min-width:0}
+.pet-mini-detail-inner > .pet-mini-action-row {
+ margin-bottom:10px}
+/* Without a main card the row sits directly above the bottom-aligned list. */
+.pet-mini-scroll > .pet-mini-action-row {
+ flex:none;
+ margin-top:auto;
+ padding-top:10px}
+.pet-mini-scroll > .pet-mini-action-row + .pet-mini-list {
+ margin-top:0}
+.pet-mini-chip {
+ display:inline-flex;
+ align-items:center;
+ gap:6px;
+ height:28px;
+ border:1px solid color-mix(in srgb,var(--pet-ink) 10%,transparent);
+ border-radius:999px;
+ padding:0 12px;
+ background:color-mix(in srgb,var(--pet-ink) 8%,transparent);
+ color:color-mix(in srgb,var(--pet-ink) 82%,transparent);
+ font-size:12px;
+ font-weight:500;
+ white-space:nowrap;
+ cursor:pointer;
+ pointer-events:auto;
+ transition:background 150ms ease,color 150ms ease}
+.pet-mini-chip:hover {
+ background:color-mix(in srgb,var(--pet-ink) 14%,transparent);
+ color:var(--pet-ink)}
+.pet-mini-chip:focus-visible {
+ outline:2px solid color-mix(in srgb,var(--mint) 70%,transparent);
+ outline-offset:2px}
+.pet-mini-chip svg {
+ width:14px;
+ height:14px;
+ flex:none}
.pet-mini-avatar-wrap {
position:absolute;