Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(setup): put the assistants' caption in flow and OpenCode's permission in its card (#2388)
Call White834e0bdf0bfe
diff --git a/docs/plans/setup-three-screen/contracts.md b/docs/plans/setup-three-screen/contracts.mdindex c4ff08a98..0ed33fc20 100644--- a/docs/plans/setup-three-screen/contracts.md+++ b/docs/plans/setup-three-screen/contracts.md@@ -242,11 +242,15 @@ wires are drawn in the same 1040 space. Below 1024 the story and the assistantstwo columns without wires; below 760 they stack. The intro card states its role under thename, inside the same `--ob-card-h` box as the assistant card, so both steps keep one cardbox. The built-in card on screen 3 may grow to offer models while the others keep-`--ob-card-h`, top-aligned. Every band's stage floor reserves that card at its worst-reading (`--ob-offer-h`), so opening the offer cannot move the action; while it is open,-the shell's aside hangs under the action pair instead of resting on the band the card-reaches into. The action and the gateway card are-299 of 1040, centred.+`--ob-card-h`, top-aligned. The assistants' readiness caption is the last row of their own+grid (`.onboarding-setup-aside`), in flow under the cards, so it is never drawn over one;+the built-in card offering its models spans that row and the caption takes the columns+beside it. OpenCode's tool-call permission is requested in OpenCode's card (a note and an+"Allow tool calls" row; a refused write takes the note's place), not in an aside. Every+band's stage floor reserves the offer (`--ob-offer-h`), the permission row+(`--ob-permission-extra`) and the caption row (`--ob-hint-row`), so none of them can move+the action. The shell's post-action slot is left to the introduction's detection failure.+The action and the gateway card are 299 of 1040, centred.**Motion bail-out.** Under `prefers-reduced-motion`, a hidden page, or an explicit pause thehandoff is skipped and the screen changes instantly; on phones the view scrolls to topdiff --git a/ui/e2e/onboarding-fidelity/geometry.spec.ts b/ui/e2e/onboarding-fidelity/geometry.spec.tsindex ccfaff2f1..e5173dde2 100644--- a/ui/e2e/onboarding-fidelity/geometry.spec.ts+++ b/ui/e2e/onboarding-fidelity/geometry.spec.ts@@ -560,12 +560,6 @@ const pair = (page: Page) => page.evaluate(() => {return { primary: read('.onboarding-primary-action'), back: read('.onboarding-back-action') };});-/** The height of the stage the pair currently sits under — every screen keeps one. */-const stageHeight = (page: Page) => page.evaluate(() => {- const stage = [...document.querySelectorAll('.onboarding-stage')].find((node) => node.getBoundingClientRect().height);- return stage ? stage.getBoundingClientRect().height : 0;-});-type Pair = Awaited<ReturnType<typeof pair>>;const expectSamePair = async (page: Page, before: Pair) => {@@ -745,14 +739,13 @@ test.describe('shared action anchor', () => {/*** The anchor fence above walks a journey where nothing goes wrong, and everything the* shell's post-action slot exists for appears only when something does: a detection that- * failed, a permission write that was refused, a completion that found a saved platform- * it cannot use. All three carry a server's own sentence, so all three GROW — and each of+ * failed, or a completion that found a saved platform it cannot use. (OpenCode's+ * permission request is in its card; `lineup.spec.ts` holds the pair through it.) All three carry a server's own sentence, so all three GROW — and each of* them used to be drawn inside the screen, above the footer, which is the one place in* this layout where content can drag the anchor. So the same tiers are walked again with* those states actually produced rather than mocked into place.*/const LONG_DETAIL = `probe exited 1: ${'the cli-detect subprocess reported an unreadable execution environment; '.repeat(3)}see the service log for the full trace`;-const LONG_PERMISSION = `opencode.json could not be written: ${'the configuration directory is owned by another user and the write was refused; '.repeat(2)}resolve the ownership and try again`;/** The toast container, which is `fixed` and therefore a different surface with its own* placement. It is dismissed before any pointer question is asked, so the answer is@@ -775,25 +768,6 @@ async function switchableDetect(page: Page) {return { recover: () => { failing = false; } };}-/** OpenCode's permission write, held open so the callout's loading, refusal and success- * are three observable moments rather than one settled render. */-async function deferredPermission(page: Page) {- const waiting: (() => void)[] = [];- let failing = true;- await page.route('**/api/opencode/permission-status', (route) =>- route.fulfill({ json: { ok: true, permission_allowed: false, config_path: '/fixture/opencode.json' } }));- await page.route('**/api/opencode/setup-permission', async (route) => {- await new Promise<void>((resolve) => { waiting.push(resolve); });- return route.fulfill({ json: failing- ? { ok: false, message: LONG_PERMISSION, config_path: '/fixture/opencode.json' }- : { ok: true, message: 'Allowed', config_path: '/fixture/opencode.json' } });- });- return {- settle: async () => { await expect.poll(() => waiting.length).toBeGreaterThan(0); waiting.shift()!(); },- succeed: () => { failing = false; },- };-}-test.describe('post-action aside', () => {for (const viewport of ANCHOR_TIERS) {for (const lang of ['en', 'zh'] as const) {@@ -841,88 +815,6 @@ test.describe('post-action aside', () => {expect(denied).toEqual([]);});- test(`${size(viewport)} ${lang} holds a refused permission write under the pair`, async ({ page }) => {- await page.setViewportSize(viewport);- const denied = await serveProduct(page);- await serveModelHub(page);- const permission = await deferredPermission(page);- await openOnboarding(page, { lang });- // The fence starts one screen earlier than the state it is about. The reservation- // claims the pair is in the same place on the introduction as on a connection step- // carrying the offer and the refused permission write at once, so the introduction's- // pair is what every box below is compared against — not the first setup render.- await toTop(page);- const before = await pair(page);- await openSetup(page, lang);-- // The permission callout is in the slot after the pair: an aside under the anchor.- const callout = page.locator('.onboarding-action-aside').getByText(- lang === 'zh' ? '不设置时 OpenCode' : 'Without this, OpenCode');- await expect(callout).toBeVisible();- await expectSamePair(page, before);-- // A write that has not answered yet: the callout says so and nothing moves.- const setup = page.locator('.onboarding-action-aside').getByRole('button', {- name: lang === 'zh' ? '在 opencode.json 写入 allow' : 'Allow tool calls in opencode.json' });- await setup.scrollIntoViewIfNeeded();- await setup.click();- await expect(setup).toBeDisabled();- await expectSamePair(page, before);-- await permission.settle();- await expect(page.locator('.onboarding-action-aside').getByText(LONG_PERMISSION)).toBeVisible();- await expectSamePair(page, before);- expect(await page.evaluate(() => document.documentElement.scrollWidth <= globalThis.innerWidth)).toBe(true);- await clearToasts(page);- expect(await hitSelf(page, '.onboarding-primary-action')).toBe(true);- expect(await hitSelf(page, '.onboarding-back-action')).toBe(true);-- // Granted, the callout is not a cleared message but an absent one.- permission.succeed();- await setup.click();- await permission.settle();- await expect(page.locator('.onboarding-action-aside').getByText(LONG_PERMISSION)).toHaveCount(0);- await expect(callout).toHaveCount(0);- await expectSamePair(page, before);- await clearToasts(page);-- // The stage is floored at the tallest step's cards, so a card that wraps past- // `--ob-card-h` cannot move the pair either.- const stageBefore = await stageHeight(page);- await expectSamePair(page, before);- expect(await page.evaluate(() => document.documentElement.scrollWidth <= globalThis.innerWidth)).toBe(true);- expect(await hitSelf(page, '.onboarding-primary-action')).toBe(true);- expect(await hitSelf(page, '.onboarding-back-action')).toBe(true);-- // A portal escapes `inert`, so leaving the screen has to empty the slot rather- // than leave reachable content behind a hidden screen.- await page.locator('.onboarding-back-action').click();- await page.clock.runFor(950);- await expect(page.locator('[data-setup-sequence]')).toHaveAttribute('data-setup-screen', 'intro');- expect(await page.locator('.onboarding-action-aside').evaluate((node) => ({- children: node.childElementCount,- focusable: node.querySelectorAll('a[href], button, input, select, textarea, [tabindex]').length,- }))).toEqual({ children: 0, focusable: 0 });- // Back is the other half of the cross-screen claim: the introduction the pair- // returns to is the one it started on, after the step it came from had spent a- // permission write.- await expectSamePair(page, before);-- // And re-entering is not a third position. The clock here is frozen and only a- // test moves it, so the handoff is nudged until the screen has arrived rather- // than once, which races the click's own commit.- await page.getByRole('button', { name: lang === 'zh' ? '立即开始' : 'Get started' }).click();- await expect.poll(async () => {- await page.clock.runFor(950);- return page.locator('[data-setup-sequence]').getAttribute('data-setup-screen');- }).toBe('assistants');- await page.locator('.onboarding-assistants').waitFor();- await expectSamePair(page, before);- expect(await stageHeight(page)).toBeCloseTo(stageBefore, 1);- expect(await hitSelf(page, '.onboarding-primary-action')).toBe(true);- expect(await hitSelf(page, '.onboarding-back-action')).toBe(true);- expect(denied).toEqual([]);- });}}});diff --git a/ui/e2e/onboarding-fidelity/lineup.spec.ts b/ui/e2e/onboarding-fidelity/lineup.spec.tsindex e2bfd0c8a..47be2c8f9 100644--- a/ui/e2e/onboarding-fidelity/lineup.spec.ts+++ b/ui/e2e/onboarding-fidelity/lineup.spec.ts@@ -9,9 +9,11 @@ import { CONTRACT_VERSION } from '../../src/components/settings/models/types';const LINEUP = ['vibey', 'claude', 'codex', 'opencode'];const NATIVE_MODELS: Record<string, string> = { claude: 'claude-opus-5-5', codex: 'gpt-5.6-sol', opencode: 'openai/gpt-5.6-sol' };-/** Every backend on the Hub with a runnable route, except the built-in one: it has no model yet. */-async function serveLineup(page: Page, { permitted = true } = {}) {- const models = NATIVE_MODELS;+/** Every backend on the Hub with a runnable route, except the built-in one unless it is+ * given a model. `ready: false` leaves every connection unready, so entry is held and+ * the caption has something to say. */+async function serveLineup(page: Page, { permitted = true, vibey = null as string | null, ready = true } = {}) {+ const models: Record<string, string> = { ...NATIVE_MODELS, ...(vibey ? { vibey } : {}) };const supply = (backend: string) => ({backend, cli_present: backend !== 'vibey', mode: 'hub', menu_kind: 'fixed',named_agents: [{ name: backend, effective_model_id: models[backend] ?? null, supply_status: models[backend] ? 'ok' : null }],@@ -46,7 +48,7 @@ async function serveLineup(page: Page, { permitted = true } = {}) {} } }));await page.route('**/api/backend/*/connection', (route) => route.fulfill({ json: {ok: true, backend: new URL(route.request().url()).pathname.split('/').at(-2), installed: true, enabled: true,- auth: 'api_key', application: 'applied', ready: true, entry_eligible: true, supply_mode: 'hub',+ auth: 'api_key', application: 'applied', ready, entry_eligible: ready, supply_mode: 'hub',} }));await page.route('**/api/opencode/permission-status', (route) => route.fulfill({ json: { ok: true, permission_allowed: permitted } }));}@@ -54,6 +56,10 @@ async function serveLineup(page: Page, { permitted = true } = {}) {type Box = { x: number; y: number; width: number; height: number };const boxes = (page: Page, selector: string): Promise<Box[]> => page.locator(selector).evaluateAll((nodes) =>nodes.map((node) => { const { x, y, width, height } = node.getBoundingClientRect(); return { x, y, width, height }; }));+/** Where the action sits in the shell's own scroll space: a click Playwright makes may+ * scroll the shell, and that moves the viewport, not the layout. */+const actionTop = (page: Page) => page.locator('.onboarding-primary-action').evaluate((node) =>+ node.getBoundingClientRect().top + (node.closest('.onboarding-shell') as HTMLElement).scrollTop);const overlaps = (a: Box, b: Box) => a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;test('the lineup stands the built-in assistant first, on the reference tracks of every screen', async ({ page }) => {@@ -92,29 +98,93 @@ test('the lineup stands the built-in assistant first, on the reference tracks of});/**- * Every band reserves the offer at its worst reading, so opening it moves nothing: the- * aside is never drawn over a card and the action keeps the introduction's y.+ * The caption is a row of the assistants' own grid and OpenCode asks for its permission in+ * its own card, so nothing is drawn over a card at any band; every band reserves both and+ * the offer, so the action keeps the introduction's y. Walked with the caption speaking+ * beside the open offer, and silent beside a Vibey that already has its model.*/-for (const [width, height] of [[1200, 800], [1440, 900], [1920, 1080], [1024, 768], [800, 1000], [390, 844]] as const) {- test(`${width}x${height}: the built-in offer is never drawn under the aside, and the action holds still`, async ({ page }) => {+for (const [width, height] of [[1200, 800], [1440, 900], [1920, 1080], [1280, 1024], [1024, 768], [800, 1000], [390, 844]] as const) {+ for (const state of ['held', 'ready'] as const) {+ test(`${width}x${height} ${state}: the caption is in flow under the cards, and the action holds still`, async ({ page }) => {+ await page.setViewportSize({ width, height });+ await serveProduct(page);+ await serveLineup(page, state === 'held' ? { permitted: false, ready: false } : { permitted: false, vibey: 'gpt-5.6-sol' });+ await openOnboarding(page);+ await freezeAt(page, PHASES['codex-working']);+ const introAction = await actionTop(page);+ await openSetup(page, 'en');+ await page.clock.runFor(2000);+ const opencode = page.locator('.onboarding-assistant[data-backend="opencode"]');+ await expect(opencode.getByRole('button', { name: 'Allow tool calls' })).toBeVisible();+ const caption = page.locator('[data-setup-screen="assistants"] .onboarding-setup-aside');+ if (state === 'held') {+ await expect(page.locator('.onboarding-assistant[data-backend="vibey"] .onboarding-model-offer')).toBeVisible();+ await expect(caption).toContainText('Pick a model for Vibey');+ }+ const captionBox = (await boxes(page, '[data-setup-screen="assistants"] .onboarding-setup-aside'))[0];+ const footer = (await boxes(page, '.onboarding-setup-footer'))[0];+ for (const card of await boxes(page, '[data-setup-screen="assistants"] .onboarding-assistant')) {+ expect(overlaps(card, captionBox)).toBe(false);+ }+ expect(overlaps(footer, captionBox)).toBe(false);+ expect(await actionTop(page)).toBeCloseTo(introAction, 0);+ });+ }+}++/** OpenCode's permission write, held open so the card's loading, refusal and success are+ * three observable moments rather than one settled render. */+async function deferredPermission(page: Page) {+ const waiting: (() => void)[] = [];+ let failing = true;+ await page.route('**/api/opencode/setup-permission', async (route) => {+ await new Promise<void>((resolve) => { waiting.push(resolve); });+ return route.fulfill({ json: failing+ ? { ok: false, message: 'opencode.json could not be written: the configuration directory is owned by another user', config_path: '/fixture/opencode.json' }+ : { ok: true, message: 'Allowed', config_path: '/fixture/opencode.json' } });+ });+ return {+ settle: async () => { await expect.poll(() => waiting.length).toBeGreaterThan(0); waiting.shift()!(); },+ succeed: () => { failing = false; },+ };+}++for (const [width, height] of [[1366, 768], [1920, 1080]] as const) {+ test(`${width}x${height}: OpenCode asks for its permission in its card, and the pair holds through the write`, async ({ page }) => {await page.setViewportSize({ width, height });await serveProduct(page);await serveLineup(page, { permitted: false });+ const permission = await deferredPermission(page);await openOnboarding(page);- await freezeAt(page, PHASES['codex-working']);- const introAction = (await boxes(page, '.onboarding-primary-action'))[0];+ const introAction = await actionTop(page);await openSetup(page, 'en');await page.clock.runFor(2000);- await expect(page.locator('.onboarding-assistant[data-backend="vibey"] .onboarding-model-offer')).toBeVisible();- const aside = page.locator('[data-setup-screen="assistants"] .onboarding-action-aside');- await expect(aside).not.toBeEmpty();- const asideBox = (await boxes(page, '[data-setup-screen="assistants"] .onboarding-action-aside'))[0];- const footer = (await boxes(page, '.onboarding-setup-footer'))[0];- for (const card of await boxes(page, '[data-setup-screen="assistants"] .onboarding-assistant')) {- expect(overlaps(card, asideBox)).toBe(false);- }- expect(overlaps(footer, asideBox)).toBe(false);- const action = (await boxes(page, '.onboarding-primary-action'))[0];- expect(action.y).toBeCloseTo(introAction.y, 0);+ const card = page.locator('.onboarding-assistant[data-backend="opencode"]');+ await expect(card.getByText('OpenCode stops to approve every tool call')).toBeVisible();+ const allow = card.getByRole('button', { name: 'Allow tool calls' });+ const holds = async () => {+ expect(await actionTop(page)).toBeCloseTo(introAction, 0);+ const caption = (await boxes(page, '[data-setup-screen="assistants"] .onboarding-setup-aside'))[0];+ for (const one of await boxes(page, '[data-setup-screen="assistants"] .onboarding-assistant')) {+ expect(overlaps(one, caption)).toBe(false);+ }+ };+ await holds();+ // Unanswered: the row says so and nothing moves.+ await allow.click();+ await expect(allow).toBeDisabled();+ await holds();+ // Refused: in the note's place; the server's sentence is a click away.+ await permission.settle();+ const refusal = card.locator('details.onboarding-assistant-note');+ await expect(refusal).toContainText('Could not allow tool calls');+ await holds();+ // Granted: the request is not a cleared message but an absent one.+ permission.succeed();+ await allow.click();+ await permission.settle();+ await expect(allow).toHaveCount(0);+ await expect(refusal).toHaveCount(0);+ await holds();});}diff --git a/ui/src/components/onboarding/AssistantRow.tsx b/ui/src/components/onboarding/AssistantRow.tsxindex 86ed5b9d8..2ac858e4e 100644--- a/ui/src/components/onboarding/AssistantRow.tsx+++ b/ui/src/components/onboarding/AssistantRow.tsx@@ -1,5 +1,5 @@import type { ReactNode } from 'react';-import { Check, ChevronRight, Download, KeyRound, RefreshCw, SlidersHorizontal } from 'lucide-react';+import { Check, ChevronRight, Download, KeyRound, RefreshCw, Settings, SlidersHorizontal } from 'lucide-react';import { useTranslation } from 'react-i18next';import { BackendIcon } from '../visual';import { Button } from '../ui/button';@@ -47,6 +47,9 @@ export interface AssistantRowProps {enabled?: boolean;/** The route read's evidence; pending and failed reads cannot assert absence. */route?: AssistantRouteView;+ /** A tool-call permission this assistant needs before it can work (OpenCode's+ opencode.json). The card says so and offers the write itself. */+ permission?: { required: boolean; pending: boolean; error?: string; onAllow: () => void };}/**@@ -102,7 +105,7 @@ export function RouteChoice({ name, route, live, disabled = false, pending = fal*/export function AssistantRow({ backend, status, installing, detecting, error, lifecycle, upgrade, enabledControl,onInstall, onDetect, onConfigure, configuringDisabled = false, connection, onAddKey, onRefreshConnection, onRetryRoute, connectionPending, connectionError, routeError,- hubManaged = false, enabled = false, route }: AssistantRowProps) {+ hubManaged = false, enabled = false, route, permission }: AssistantRowProps) {const { t } = useTranslation();const label = getBackendUiMeta(backend).label;// With Model Hub holding the credentials, a card has three things it can be, and@@ -117,6 +120,9 @@ export function AssistantRow({ backend, status, installing, detecting, error, li: 'checking';const routeModel = route?.kind === 'route' ? route.model : null;const routeUnknown = route?.kind === 'pending' || route?.kind === 'failed';+ // A permission the installed assistant still needs is the card's most pressing note:+ // without it the assistant stalls on its first tool call, whatever its route says.+ const permissionNeeded = status === 'ok' && !!permission?.required;// Switched off, the switch above is the only thing that changes the model shown.const routeChoice = (live: boolean) => (<RouteChoice name={label} route={route} live={live} onOpen={onConfigure} pending={!!connectionPending}@@ -166,8 +172,15 @@ export function AssistantRow({ backend, status, installing, detecting, error, lihub-owned credential is managed — rather than a static description of theassistant. The frames keep it to one line at every tier, which aper-state sentence is short enough to honour in both languages. */}- <p className="onboarding-assistant-note">- {hubState+ {/* A refused permission write is the guidance for the state the card is in, so it+ takes the note's place — the slot the card already reserves — and keeps the+ server's own sentence one click away. */}+ {permissionNeeded && permission?.error ? (+ <details className="onboarding-assistant-note" data-tone="error" role="alert">+ <summary>{t('onboarding.setup.permissionFailed')}</summary>{permission.error}+ </details>+ ) : <p className="onboarding-assistant-note">+ {permissionNeeded ? t('onboarding.setup.notePermission', { name: label }) : hubState? t(hubState === 'missing' ? 'onboarding.setup.noteNotInstalled': hubState === 'enabled' || hubState === 'idle'? (route?.kind === 'no-agent-model' ? 'onboarding.setup.noteModelUnset'@@ -179,10 +192,17 @@ export function AssistantRow({ backend, status, installing, detecting, error, li: native? t(`onboarding.setup.${native}ConnectedHint`): t(`onboarding.setup.${backend}Guide`)}- </p>+ </p>}{/* One full-width row per connection method, subscription above API Key, andthe connected state wearing the same row with a mint check. */}<div className="onboarding-assistant-actions">+ {permissionNeeded && permission && (+ <Button type="button" variant="secondary" className="onboarding-method-row onboarding-method-row--attention"+ onClick={permission.onAllow} disabled={permission.pending || installing || detecting}>+ {permission.pending ? <RefreshCw size={16} className="motion-safe:animate-spin" /> : <Settings size={16} />}+ {t('onboarding.setup.allowToolCalls')}+ </Button>+ )}{hubState === 'checking' ? null : hubState === 'missing' ? (<Button type="button" variant="secondary" className="onboarding-method-row" onClick={onInstall} disabled={installing || detecting}>{installing ? <RefreshCw size={16} className="motion-safe:animate-spin" /> : <Download size={16} />}diff --git a/ui/src/components/onboarding/AssistantSetup.test.tsx b/ui/src/components/onboarding/AssistantSetup.test.tsxindex 4e7aeae80..f6308950e 100644--- a/ui/src/components/onboarding/AssistantSetup.test.tsx+++ b/ui/src/components/onboarding/AssistantSetup.test.tsx@@ -18,7 +18,9 @@ import { SETUP_LINEUP } from './collaborationTimeline';const mock = vi.hoisted(() => ({ api: {detectCli: vi.fn(), installAgent: vi.fn(), getConfig: vi.fn(), getBackendRuntime: vi.fn(), getBackendConnection: vi.fn(), mutateConfig: vi.fn(), getClaudeAuth: vi.fn(), getCodexAuth: vi.fn(), getOpencodeProviders: vi.fn(), saveClaudeAuth: vi.fn(),listVibeAgents: vi.fn(), getVibeAgent: vi.fn(),-}, showToast: vi.fn(), models: { getAgentChain: vi.fn(), getAgentChains: vi.fn(), previewAgentChain: vi.fn(), putAgentChain: vi.fn(), listSources: vi.fn() } }));+}, showToast: vi.fn(), permission: { permissionAllowed: true, statusLoaded: true, state: 'idle', message: '', setupPermission: vi.fn() } as {+ permissionAllowed: boolean; statusLoaded: boolean; state: string; message: string; setupPermission: ReturnType<typeof vi.fn>;+}, models: { getAgentChain: vi.fn(), getAgentChains: vi.fn(), previewAgentChain: vi.fn(), putAgentChain: vi.fn(), listSources: vi.fn() } }));vi.mock('../../context/ApiContext', () => ({ useApi: () => mock.api }));vi.mock('../settings/models/modelsApi', async (importOriginal) => {const actual = await importOriginal<typeof import('../settings/models/modelsApi')>();@@ -26,7 +28,7 @@ vi.mock('../settings/models/modelsApi', async (importOriginal) => {});vi.mock('../../context/ToastContext', () => ({ useToast: () => ({ showToast: mock.showToast }) }));vi.mock('../settings/models/useModelHubCapability', () => ({ useModelHubCapability: () => false }));-vi.mock('../settings/shared/useOpencodePermission', () => ({ useOpencodePermission: () => ({ permissionAllowed: true, statusLoaded: true }) }));+vi.mock('../settings/shared/useOpencodePermission', () => ({ useOpencodePermission: () => mock.permission }));vi.mock('../settings/providers/BackendProviderConfig', () => ({ BackendProviderConfig: ({ backend }: { backend: string }) => <div>Existing provider: {backend}</div> }));const i18n = createInstance();await i18n.init({ lng: 'en', resources: { en: { translation: en } }, interpolation: { escapeValue: false } });@@ -67,6 +69,7 @@ const setupSource: Source = {};beforeEach(() => {vi.resetAllMocks();+ mock.permission = { permissionAllowed: true, statusLoaded: true, state: 'idle', message: '', setupPermission: vi.fn(async () => undefined) };mock.api.getConfig.mockResolvedValue(data());mock.api.mutateConfig.mockResolvedValue({});mock.api.getBackendConnection.mockImplementation((backend) => Promise.resolve({ ok: true, backend, installed: true, enabled: true, auth: 'api_key', application: 'applied', ready: true, entry_eligible: true }));@@ -664,6 +667,43 @@ describe('assistant installation presentation', () => {});});+describe('OpenCode tool-call permission', () => {+ it('is asked for in OpenCode\'s own card, and granting it re-reads the connection', async () => {+ mock.permission = { ...mock.permission, permissionAllowed: false };+ const saved = data(); saved.agents.opencode.status = 'ok';+ render(wrap(<AgentDetection data={saved} onNext={vi.fn()} />));+ const card = row('OpenCode');+ expect(await card.findByText(en.onboarding.setup.notePermission.replace('{{name}}', 'OpenCode'))).toBeTruthy();+ expect(row('Claude Code').queryByRole('button', { name: en.onboarding.setup.allowToolCalls })).toBeNull();+ const reads = mock.api.getBackendConnection.mock.calls.length;+ fireEvent.click(card.getByRole('button', { name: en.onboarding.setup.allowToolCalls }));+ expect(mock.permission.setupPermission).toHaveBeenCalledOnce();+ await waitFor(() => expect(mock.api.getBackendConnection.mock.calls.length).toBeGreaterThan(reads));+ expect(mock.api.getBackendConnection).toHaveBeenLastCalledWith('opencode');+ });++ it('reports a refused write in the note\'s place, with the server\'s sentence behind it', () => {+ mock.permission = { ...mock.permission, permissionAllowed: false, state: 'error', message: 'opencode.json is not writable' };+ const saved = data(); saved.agents.opencode.status = 'ok';+ render(wrap(<AgentDetection data={saved} onNext={vi.fn()} />));+ const refusal = row('OpenCode').getByRole('alert');+ expect(refusal.tagName).toBe('DETAILS');+ expect(within(refusal).getByText(en.onboarding.setup.permissionFailed)).toBeTruthy();+ expect(refusal.textContent).toContain('opencode.json is not writable');+ });++ it('asks nothing of an assistant that is not installed, or once it is allowed', () => {+ mock.permission = { ...mock.permission, permissionAllowed: false };+ render(wrap(<AgentDetection data={data()} onNext={vi.fn()} />));+ expect(row('OpenCode').queryByRole('button', { name: en.onboarding.setup.allowToolCalls })).toBeNull();+ cleanup();+ mock.permission = { ...mock.permission, permissionAllowed: true };+ const saved = data(); saved.agents.opencode.status = 'ok';+ render(wrap(<AgentDetection data={saved} onNext={vi.fn()} />));+ expect(row('OpenCode').queryByRole('button', { name: en.onboarding.setup.allowToolCalls })).toBeNull();+ });+});+describe('Hub route refresh', () => {it.each([false, true])('AUTH-SETUP-126: returns to providers with an empty inventory (direct eligible: %s)', async (directEligible) => {const saved = { ...data(), capabilities: { model_hub: { enabled: true } } };diff --git a/ui/src/components/onboarding/onboarding.css b/ui/src/components/onboarding/onboarding.cssindex 569a4af5e..46d58697d 100644--- a/ui/src/components/onboarding/onboarding.css+++ b/ui/src/components/onboarding/onboarding.css@@ -154,12 +154,24 @@Every band reserves it at its worst reading — the note at its two-line clamp —because whether the note wraps is the platform's fonts' answer, not the design's. */--ob-offer-h: calc(var(--ob-assistant-h) + var(--ob-method-h) * 2 - var(--ob-method-gap) + 3px);+ /* The assistants' readiness caption is a row of their own grid, under the cards: one+ line of the caption's type and the gap above it. The built-in card offering its+ models spans it, so the offer and the caption share the height rather than stack. */+ --ob-hint-gap: 16px;+ --ob-hint-row: calc(var(--ob-hint-gap) + var(--ob-cap-fs) * 1.5);+ /* An installed OpenCode that still needs its tool-call permission asks for it in its+ card: one more action row and its gap over the two the card formula counts — the+ connection rows a card shows while its route is still being read — and the identity+ header's hairline the formula leaves out. One card at a time can be in this state,+ so the lineup reserves it once. */+ --ob-permission-extra: calc(var(--ob-method-h) + var(--ob-method-gap) + 1px);/* One floor under the cards, so a card that grows while its step is read — asentence that wraps in one language, a state row that arrives with detection, thebuilt-in card opening its model offer — cannot move the action. It reserves thecards only; whatever a step draws under them adds its own height on top, and theshared cell (see `.onboarding-screens`) is what then holds the three steps level. */- --ob-stage-h: max(var(--ob-diagram-h), var(--ob-assistant-h), var(--ob-offer-h));+ --ob-stage-h: max(var(--ob-diagram-h),+ var(--ob-assistant-h) + var(--ob-permission-extra) + var(--ob-hint-row), var(--ob-offer-h));/* The diagram keeps the box the reference draws it in: the story's card plus theband the return wire needs under it — the card plus 64 at every reading. Areservation that has to hold a wrapped sentence on another step does not@@ -1057,11 +1069,41 @@contents change. The container makes `--ob-card-h`'s width guard resolve againstthis box, exactly as the story's resolves against the diagram.Top-aligned rather than stretched: the built-in card grows to offer its models while- the others keep the card's own height, as the reference draws it. */+ the others keep the card's own height, as the reference draws it.+ Its last row is the readiness caption (`.onboarding-setup-aside`), in flow under the+ cards it explains, so it can never be drawn over one. The row is there whether or+ not it has something to say, so the cards stay put when it starts or stops. */.onboarding-assistants-list {align-items: start;+ row-gap: var(--ob-hint-gap);container-type: inline-size;}+.onboarding-setup-aside {+ grid-column: 1 / -1;+ min-height: calc(var(--ob-cap-fs) * 1.5);+ display: flex;+ flex-direction: column;+ gap: 8px;+}+/* A screen nobody is reading has no caption to give, and before its first showing its+ cards sit in their tallest, not-yet-checked state; the row would only add to the share+ of the shared cell that screen holds. It is there from the moment the screen is the+ current one — the handoff measures it — so the cards never move on arrival. */+[data-setup-screen-root][hidden] .onboarding-setup-aside { display: none; }+/* Side by side, the cards are one row of the lineup's own count, which the shell+ states. The built-in card offering its models spans the caption's row too, and the+ caption takes the columns beside it: the offer and the caption share the height the+ stage reserves instead of stacking. The built-in card stands first in the lineup. */+@media (min-width: 1024px) {+ .onboarding-assistants-list {+ grid-auto-flow: row;+ grid-template-columns: repeat(var(--ob-cards), minmax(0, 1fr));+ }+ .onboarding-assistants-list > .onboarding-assistant:has(.onboarding-model-offer) { grid-row: span 2; }+ .onboarding-assistants-list:has(> .onboarding-assistant .onboarding-model-offer) > .onboarding-setup-aside {+ grid-column: 2 / -1;+ }+}/* The state row is where the story puts its caption: the lifecycle pill on the leftand, opposite it, the one action the pill offers — update or install — on the right.Wrapping is allowed so a long localized pill drops the button to its own line@@ -1229,6 +1271,9 @@ span.onboarding-model-offer-row { cursor: default; }.onboarding-model-offer-empty { padding: 8px; font-size: 12px; line-height: 1.5; color: var(--muted); }/* A note that says why the assistant cannot run is the card's one error line. */.onboarding-assistant-note[data-tone="error"] { color: var(--destructive-ink); }+/* A note with more to say behind it is a disclosure: one line closed, all of it open. */+details.onboarding-assistant-note { display: block; overflow: visible; }+details.onboarding-assistant-note > summary { cursor: pointer; }/* Installed but off: a line, not a control. The switch above is the only thing topress, and this says the binary is already there. */.onboarding-method-receipt {@@ -1296,6 +1341,7 @@ span.onboarding-model-offer-row { cursor: default; }.onboarding-assistant-error { font-size: 12px; color: var(--destructive-ink); overflow-wrap: anywhere; margin-top: 8px; }.onboarding-assistant-error pre { margin-top: 8px; max-height: 160px; overflow: auto; white-space: pre-wrap; }.onboarding-assistant-error summary { margin-top: 8px; cursor: pointer; color: inherit; }+details.onboarding-assistant-error > summary { margin-top: 0; }/* "Open workspace and Back to introduction share a width and stack vertically." Thefull width is what makes that true: without it this column shrink-wraps its widestchild, and the action's own `299/976` then resolves against that shrunken box and@@ -1321,7 +1367,8 @@ span.onboarding-model-offer-row { cursor: default; }/* The fold's rows, the first holding the built-in card at its tallest. The shellstates the row count from the lineup. */--ob-stage-h: calc(max(var(--ob-card-h), var(--ob-offer-h))- + (max(var(--ob-card-h), var(--ob-assistant-h)) + var(--ob-stack-gap)) * (var(--ob-fold-rows) - 1));+ + (max(var(--ob-card-h), var(--ob-assistant-h)) + var(--ob-stack-gap)) * (var(--ob-fold-rows) - 1)+ + var(--ob-permission-extra) + var(--ob-hint-row));}.onboarding-collaboration-cards, .onboarding-assistants-list {grid-auto-flow: row;@@ -1377,7 +1424,8 @@ span.onboarding-model-offer-row { cursor: default; }card at its tallest, then one of the taller card per other assistant, and thegaps between them. `--ob-cards` is the lineup's own count, which the shell states. */--ob-stage-h: calc(max(var(--ob-card-h), var(--ob-offer-h))- + (max(var(--ob-card-h), var(--ob-assistant-h)) + var(--ob-stack-gap)) * (var(--ob-cards) - 1));+ + (max(var(--ob-card-h), var(--ob-assistant-h)) + var(--ob-stack-gap)) * (var(--ob-cards) - 1)+ + var(--ob-permission-extra) + var(--ob-hint-row));--ob-main-top: 0px;--ob-access-w: 100%;--ob-access-pad: 24px;@@ -1492,7 +1540,9 @@ span.onboarding-model-offer-row { cursor: default; }lifted out of flow and offset back over the footer. The slot itself costs nothingwhen no screen is contributing one; the caption brings its own gap. *//* The slot sits in the screens' shared cell, on its bottom edge, and grows upward into- the room the screen leaves above the action.+ the room the screen leaves above the action. The introduction's detection failure is+ what uses it; the assistants' caption is a row of their own grid, and OpenCode's+ permission request is in OpenCode's card.It is in the cell rather than in the column because the column is centred in thewindow: a caption in the flow moves the heading, the cards and the action by half ofits own height, which is exactly how the assistants step came to sit 9px above the@@ -1512,40 +1562,6 @@ span.onboarding-model-offer-row { cursor: default; }flex-direction: column;gap: 16px;}-/* The assistants step leaves more room than the band gap — 76 clear at the narrowest- desktop tier, 60 on a phone — and it is the step that carries the OpenCode permission- block, the tallest thing the slot ever holds. 48 is what every tier can give it- without reaching the cards; the block scrolls inside that. */-@media (min-width: 760px) {- /* The hint grows around the caption line inside the room above the action. */- .onboarding-step[data-setup-screen="assistants"] > .onboarding-screens > .onboarding-action-aside:not(:empty) {- --ob-aside-half: calc(var(--ob-card-h) * 38 / 300 - 8px);- margin-bottom: calc(var(--ob-band-gap) + var(--ob-summary-h) / 2 - var(--ob-aside-half));- min-height: calc(var(--ob-aside-half) * 2);- max-height: calc(var(--ob-aside-half) * 2);- justify-content: center;- }-}-@media (max-width: 759px) {- .onboarding-step[data-setup-screen="assistants"] { --ob-aside-max: 48px; }-}-/* The built-in card offering its models is taller than any card the band above was- measured for, and it reaches into it. While it does, the aside hangs under the pair- instead — out of flow, so the action stays where every screen puts it and nothing- it says is drawn over a card. Picking a model closes the offer, and the aside goes- back to its band. */-/* Positioned from the cell it lives in: the pair under the cell is two action rows- and the footer's 10 between them. */-.onboarding-step[data-setup-screen="assistants"]:has(.onboarding-model-offer) > .onboarding-screens > .onboarding-action-aside:not(:empty) {- position: absolute;- top: calc(100% + var(--ob-action-h) * 2 + 10px + 16px);- left: 0;- right: 0;- margin: 0;- min-height: 0;- max-height: none;- overflow: visible;-}.onboarding-setup-hint { width: 100%; text-align: center; }/* Sentence centred on the action's axis, rescan beside it: equal flanking columns putthe middle one in the middle of the slot whatever the link costs, and the link startsdiff --git a/ui/src/components/steps/AgentDetection.tsx b/ui/src/components/steps/AgentDetection.tsxindex 64b73c5f5..742b5de4a 100644--- a/ui/src/components/steps/AgentDetection.tsx+++ b/ui/src/components/steps/AgentDetection.tsx@@ -1,5 +1,4 @@import React, { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';-import { createPortal } from 'react-dom';import {ArrowLeft,ArrowRight,@@ -653,7 +652,6 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, on// entering on another assistant would leave Vibey on a model nobody chose.const choiceHeld = BUILTIN_BACKENDS.some((backend) => choice.holds(backend));- const opencodeAgent = agents['opencode'];const requiresSource = canEditSetupRoute && modelHubEnabled;const hasSource = sharedRouteReady() && routeRead.sources.some(usableSource);const needsSource = requiresSource && sharedRouteReady() && !hasSource;@@ -697,19 +695,6 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, ondisabled: !canContinue || actionBusy, busy: actionBusy, icon: entering ? 'spinner' : 'arrow-right' });}, [active, onActionChange, entering, canContinue, actionBusy]);- // What sits under the shared pair in the shell: the readiness caption and the- // OpenCode permission callout. Both are ancillary to the action and both grow — a- // permission error carries a full diagnostic. Kept inside the screen they push the- // anchor the two steps share; lifted out of flow they cover the very buttons they- // explain. So the shell reserves a slot after the pair and the active screen portals- // them into it.- const setupRoot = useRef<HTMLDivElement>(null);- const [actionAside, setActionAside] = useState<HTMLElement | null>(null);- useEffect(() => {- setActionAside(onActionChange- ? setupRoot.current?.closest('.onboarding-step')?.querySelector<HTMLElement>('[data-setup-action-aside]') ?? null- : null);- }, [onActionChange]);// Only while the action is held. Once it lights up, the cards already say which// assistants are connected and the button says the rest; a caption repeating it is a// line of type under a settled screen. Held, it is the only place that says WHY the@@ -753,21 +738,24 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, on{hintSentence}{entryError && <div role="alert" className="connection-error">{entryError} <Button variant="link" size="sm" disabled={!canContinue || actionBusy} onClick={() => void handlePrimaryAction()}>{t('common.retry')}</Button></div>}</>) : null;- // Hosted in one place so the order under the pair is the same every time, and so the- // standalone host keeps the arrangement it already had.- const permissionNode = <OpencodePermissionSetup cliReady={opencodeAgent?.status === 'ok'}- permissionAllowed={permission.permissionAllowed} state={permission.state} message={permission.message}- // Granting permission succeeds at permission. It says nothing about whether- // enabling the backend was persisted, so it reads the connection without- // spending a verdict that is about something else.- onSetup={() => void permission.setupPermission().then(() => refreshConnection('opencode'))} className="w-full" />;- // A portal leaves the screen root, and with it the `inert` the shell puts on a screen- // nobody is reading, so what it carries has to answer to the same activity itself.- const asideNode = onActionChange- ? (active && routeSurfaceActive && actionAside ? createPortal(<>- {hintInner && <div className="onboarding-setup-hint">{hintInner}</div>}- {permissionNode}- </>, actionAside) : null)+ // OpenCode's tool-call permission is OpenCode's own state, so its card asks for it.+ // Granting permission succeeds at permission. It says nothing about whether enabling+ // the backend was persisted, so it reads the connection without spending a verdict+ // that is about something else.+ const opencodePermission = {+ required: permission.statusLoaded && !permission.permissionAllowed,+ pending: permission.state === 'loading',+ error: permission.state === 'error' ? permission.message : undefined,+ onAllow: () => void permission.setupPermission().then(() => refreshConnection('opencode')),+ };+ // In the shell, the readiness caption is a row of the assistants' own grid, under the+ // cards it explains — in flow, so it can never be drawn over a card. The row is there+ // even when it has nothing to say, so the cards do not move when it starts or stops+ // saying something. The standalone host keeps the footer it always had.+ const asideRow = onActionChange+ ? <div className="onboarding-setup-aside">{hintInner && <div className="onboarding-setup-hint">{hintInner}</div>}</div>+ : null;+ const asideNode = onActionChange ? null: (<div className="onboarding-setup-footer"><Button type="button" variant="brand" className="group onboarding-action-w onboarding-primary-action" onClick={() => void handlePrimaryAction()}@@ -952,7 +940,7 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, on}return (- <div className="onboarding-setup" ref={setupRoot}>+ <div className="onboarding-setup"><header className="onboarding-heading"><h1 tabIndex={-1}>{t('onboarding.setup.title')}</h1><p>{t('onboarding.setup.subtitle')}</p>@@ -1026,6 +1014,7 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, onhubManaged={hubRoute}enabled={agent.enabled}route={routeViewFor(name)}+ permission={name === 'opencode' ? opencodePermission : undefined}connectionPending={connectionPending[name]}connectionError={connectionErrors[name] || connections[name]?.message}onRefreshConnection={() => void refreshConnection(name, { acknowledge: true })}@@ -1072,9 +1061,9 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, on) : undefined}/>;})}+ {asideRow}</div></div>- {!onActionChange && permissionNode}</div>{providerDialog}{pickerFor && (diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 350b4d360..61a023dc3 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -5275,6 +5275,9 @@"noteNoModels": "No usable model yet","ownershipChanged": "Connection changed. Refresh to continue","noteModelUnset": "No model set yet; you can set one later in Model Hub",+ "notePermission": "{{name}} stops to approve every tool call",+ "allowToolCalls": "Allow tool calls",+ "permissionFailed": "Could not allow tool calls","builtinAlwaysOn": "Built-in · always on","noteBuiltinUnset": "No model yet. Pick one to start.","noteGatewayOff": "Model gateway is off. {{name}} needs it to run.",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 36b076761..b50929f29 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -5275,6 +5275,9 @@"noteNoModels": "还没有可用的模型","ownershipChanged": "连接状态已变化,请刷新后继续","noteModelUnset": "尚未设置模型,可稍后在模型网关中设置",+ "notePermission": "{{name}} 每次调用工具都会停下等待审批",+ "allowToolCalls": "允许工具调用",+ "permissionFailed": "未能允许工具调用","builtinAlwaysOn": "内置 · 始终开启","noteBuiltinUnset": "还没有模型,选一个即可开始","noteGatewayOff": "模型网关已关闭,{{name}} 需要它才能运行",