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): Computer Use setup guide in desktop Settings (#2894)
Max57bed3196b39
diff --git a/docs/desktop-computer-use.md b/docs/desktop-computer-use.mdindex b9e1175a4..3f9d15ceb 100644--- a/docs/desktop-computer-use.md+++ b/docs/desktop-computer-use.md@@ -22,6 +22,21 @@ Avibe desktop shell is running.missing permission, quit and reopen that exact installed app withoutreplacing or updating it, then turn **Computer Use** on.+### Settings guide++In the desktop app, **Settings → System → Computer Use** walks through the same+setup as four numbered steps: turn on Computer Use, allow Accessibility, allow+Screen & System Audio Recording, then come back and recheck. Each step is+marked done, current, or not yet done from the live Computer Use status, so the+page shows which permission is still missing. The page refreshes every five+seconds, when the window becomes visible or focused, and when you click+**Recheck**. Accessibility comes first because the managed driver checks it+before Screen Recording.++The Settings entry appears only in the Avibe desktop app. A browser tab or phone+that opens `/settings/computer-use` directly sees a short notice that the page+is available in the desktop app, without the steps.+Avibe requests permissions only when you turn the feature on. It does not keepshowing permission prompts in the background. If the menu still reports that apermission is needed, open **System Settings → Privacy & Security**, confirm@@ -56,8 +71,9 @@ The Workbench shows one read-only Computer Use status line. It refreshes withoutbrowser caching when the page opens, every five seconds, and when the windowbecomes visible or focused. It reflects the native state and gives localizedguidance for a missing permission, a driver failure, damaged state, or an-unavailable desktop shell. It does not expose internal reason codes, turn the-feature on, or issue permission changes. The line appears only in the+unavailable desktop shell. Until Computer Use is ready, the desktop app adds a+**Finish in Settings** link to the Settings guide above. The line does not+expose internal reason codes, turn the feature on, or issue permission changes. The line appears only in thedesktop-managed macOS Runtime; a terminal-installed Avibe Runtime does not showa native desktop control it cannot own.diff --git a/ui/src/App.tsx b/ui/src/App.tsxindex 52de1514d..e547b0b2d 100644--- a/ui/src/App.tsx+++ b/ui/src/App.tsx@@ -37,6 +37,7 @@ import { SettingsPlatformsPage } from './components/settings/SettingsPlatformsPaimport { SettingsServicePage } from './components/settings/SettingsServicePage';import { SettingsGeneralPage } from './components/settings/SettingsGeneralPage';import { SettingsShortcutsPage } from './components/settings/SettingsShortcutsPage';+import { SettingsComputerUsePage } from './components/settings/SettingsComputerUsePage';import { SettingsLayout } from './components/settings/SettingsLayout';import { SettingsOverlayRouteSurface } from './components/settings/SettingsOverlayRouteSurface';import { StatusProvider } from './context/StatusProvider';@@ -728,6 +729,7 @@ const settingsRoute = () => (<Route path="appearance" element={<Navigate to="/settings/general" replace />} /><Route path="account" element={<Navigate to="/settings/replies" replace />} /><Route path="shortcuts" element={<SettingsShortcutsPage />} />+ <Route path="computer-use" element={<SettingsComputerUsePage />} /><Route path="service" element={<SettingsServicePage />} /><Route path="platforms" element={<SettingsPlatformsPage />} /><Route path="platforms/groups" element={<ChannelList isPage />} />diff --git a/ui/src/components/settings/SettingsComputerUsePage.test.tsx b/ui/src/components/settings/SettingsComputerUsePage.test.tsxnew file mode 100644index 000000000..0770daf49--- /dev/null+++ b/ui/src/components/settings/SettingsComputerUsePage.test.tsx@@ -0,0 +1,152 @@+/* @vitest-environment jsdom */++import { cleanup, render, screen, waitFor } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { afterEach, describe, expect, it, vi } from 'vitest';++import en from '../../i18n/en.json';+import zh from '../../i18n/zh.json';+import {+ COMPUTER_USE_GUIDE_STEPS,+ computerUseGuideProgress,+} from '../workbench/computerUseStatus';+import { SettingsComputerUsePage } from './SettingsComputerUsePage';++const apiFetch = vi.hoisted(() => vi.fn());++vi.mock('@/lib/apiFetch', () => ({ apiFetch }));+vi.mock('react-i18next', () => ({+ useTranslation: () => ({ t: (key: string) => key }),+}));++const statusResponse = (body: Record<string, unknown>) => ({ ok: true, json: async () => body });++const enterDesktopShell = () =>+ Object.defineProperty(window, '__AVIBE_DESKTOP_SHELL__', { value: true, configurable: true });++const stepStates = () => Object.fromEntries(+ screen.getAllByRole('listitem').map((item) => [+ item.getAttribute('data-step'),+ item.getAttribute('data-step-state'),+ ]),+);++afterEach(() => {+ cleanup();+ apiFetch.mockReset();+ Reflect.deleteProperty(window, '__AVIBE_DESKTOP_SHELL__');+});++describe('computerUseGuideProgress', () => {+ const progress = (status: string, reason: string | null = null) =>+ COMPUTER_USE_GUIDE_STEPS.map((step) => computerUseGuideProgress({ status, reason })[step]);++ it('advances the steps only as far as the status proves', () => {+ expect(progress('off', 'never_enabled')).toEqual(['current', 'pending', 'pending', 'pending']);+ expect(progress('needs_permission', 'accessibility'))+ .toEqual(['complete', 'current', 'pending', 'pending']);+ // The driver checks Accessibility first, so a Screen Recording gap proves it passed.+ expect(progress('needs_permission', 'screen_recording'))+ .toEqual(['complete', 'complete', 'current', 'pending']);+ expect(progress('needs_permission', null)).toEqual(['complete', 'current', 'pending', 'pending']);+ expect(progress('ready')).toEqual(['complete', 'complete', 'complete', 'complete']);+ });++ it('claims no permission progress for states that happen before or beside the permission checks', () => {+ for (const status of ['starting', 'needs_runtime', 'error']) {+ expect(progress(status, 'any')).toEqual(['complete', 'pending', 'pending', 'pending']);+ }+ expect(progress('unavailable', 'shell_not_running')).toEqual(['pending', 'pending', 'pending', 'pending']);+ // An unknown state reads as off, matching the status copy's fallback.+ expect(progress('future_state')).toEqual(['current', 'pending', 'pending', 'pending']);+ });+});++describe('SettingsComputerUsePage', () => {+ it('renders the numbered guide inside the desktop shell, driven by the status API', async () => {+ enterDesktopShell();+ apiFetch.mockResolvedValue(statusResponse({+ supported: true,+ status: 'needs_permission',+ reason: 'screen_recording',+ }));++ render(<SettingsComputerUsePage />);++ await waitFor(() => {+ expect(screen.getByTestId('computer-use-guide-status').getAttribute('data-computer-use-status'))+ .toBe('needs_permission');+ });+ expect(apiFetch).toHaveBeenCalledWith('/api/desktop/computer-use/status', { cache: 'no-store' });+ expect(screen.getByText('workbench.home.computerUse.screenRecordingDetail')).toBeTruthy();+ expect(stepStates()).toEqual({+ enable: 'complete',+ accessibility: 'complete',+ screenRecording: 'current',+ recheck: 'pending',+ });+ expect(screen.getAllByRole('listitem').find((item) => item.getAttribute('aria-current') === 'step')+ ?.getAttribute('data-step')).toBe('screenRecording');+ expect(screen.queryByTestId('computer-use-unsupported')).toBeNull();+ });++ it('rechecks the status API on demand and moves the steps forward', async () => {+ enterDesktopShell();+ apiFetch.mockResolvedValue(statusResponse({+ supported: true,+ status: 'needs_permission',+ reason: 'accessibility',+ }));+ const user = userEvent.setup();++ render(<SettingsComputerUsePage />);+ await waitFor(() => expect(stepStates().accessibility).toBe('current'));+ const callsBefore = apiFetch.mock.calls.length;++ apiFetch.mockResolvedValue(statusResponse({ supported: true, status: 'ready', reason: null }));+ await user.click(screen.getByRole('button', { name: /settings\.computerUse\.recheck/ }));++ await waitFor(() => expect(stepStates().recheck).toBe('complete'));+ expect(apiFetch.mock.calls.length).toBeGreaterThan(callsBefore);+ expect(Object.values(stepStates())).toEqual(['complete', 'complete', 'complete', 'complete']);+ });++ it('shows only the desktop-app notice without the shell, and never reads the status', () => {+ render(<SettingsComputerUsePage />);++ expect(screen.getByTestId('computer-use-unsupported')).toBeTruthy();+ expect(screen.getByText('settings.computerUse.unsupportedTitle')).toBeTruthy();+ expect(screen.queryByTestId('computer-use-steps')).toBeNull();+ expect(screen.queryByRole('button', { name: /settings\.computerUse\.recheck/ })).toBeNull();+ expect(apiFetch).not.toHaveBeenCalled();+ });++ it('shows the same notice when the host reports Computer Use unsupported', async () => {+ enterDesktopShell();+ apiFetch.mockResolvedValue(statusResponse({+ supported: false,+ status: 'unavailable',+ reason: 'unsupported_host',+ }));++ render(<SettingsComputerUsePage />);++ expect(await screen.findByTestId('computer-use-unsupported')).toBeTruthy();+ expect(screen.queryByTestId('computer-use-steps')).toBeNull();+ });++ it('ships the page copy in both locales', () => {+ expect(en.settings.sections.computerUse).toBe('Computer Use');+ expect(zh.settings.sections.computerUse).toBe('电脑操作');+ expect(en.settings.computerUse.unsupportedTitle).toBe('Available in the Avibe desktop app');+ expect(zh.settings.computerUse.unsupportedTitle).toBe('仅桌面端可用');+ for (const step of COMPUTER_USE_GUIDE_STEPS) {+ for (const locale of [en, zh]) {+ expect(locale.settings.computerUse.steps[step].title).toBeTruthy();+ expect(locale.settings.computerUse.steps[step].detail).toBeTruthy();+ }+ }+ expect(zh.settings.computerUse.steps.screenRecording.detail).toContain('屏幕与系统音频录制');+ expect(en.settings.computerUse.steps.screenRecording.detail).toContain('Screen & System Audio Recording');+ });+});diff --git a/ui/src/components/settings/SettingsComputerUsePage.tsx b/ui/src/components/settings/SettingsComputerUsePage.tsxnew file mode 100644index 000000000..9bdf69afb--- /dev/null+++ b/ui/src/components/settings/SettingsComputerUsePage.tsx@@ -0,0 +1,226 @@+import { useCallback, useEffect, useRef, useState } from 'react';+import type { FC } from 'react';+import { Check, LoaderCircle, Monitor, RotateCw } from 'lucide-react';+import { useTranslation } from 'react-i18next';+import clsx from 'clsx';++import { Button } from '@/components/ui/button';+import { isDesktopShell } from '@/lib/desktopShell';+import type { TranslationKey } from '@/i18n/types';+import { ComputerUseStatusIcon } from '../workbench/ComputerUseStatusLine';+import {+ COMPUTER_USE_GUIDE_STEPS,+ COMPUTER_USE_REFRESH_INTERVAL_MS,+ computerUseGuideProgress,+ computerUseToneClass,+ readComputerUseStatus,+ type ComputerUseGuideStep,+ type ComputerUseGuideStepState,+ type ComputerUseStatusRead,+} from '../workbench/computerUseStatus';+import { computerUseStatusCopy, type ComputerUseCopyKey } from '../workbench/computerUseStatusCopy';+import { SettingsPageShell } from './SettingsPageShell';+import { SettingsPanel } from './SettingsPrimitives';++const STEP_COPY: Record<ComputerUseGuideStep, { title: TranslationKey; detail: TranslationKey }> = {+ enable: {+ title: 'settings.computerUse.steps.enable.title',+ detail: 'settings.computerUse.steps.enable.detail',+ },+ accessibility: {+ title: 'settings.computerUse.steps.accessibility.title',+ detail: 'settings.computerUse.steps.accessibility.detail',+ },+ screenRecording: {+ title: 'settings.computerUse.steps.screenRecording.title',+ detail: 'settings.computerUse.steps.screenRecording.detail',+ },+ recheck: {+ title: 'settings.computerUse.steps.recheck.title',+ detail: 'settings.computerUse.steps.recheck.detail',+ },+};++const STEP_STATE_LABEL: Record<ComputerUseGuideStepState, TranslationKey> = {+ complete: 'settings.computerUse.stepState.complete',+ current: 'settings.computerUse.stepState.current',+ pending: 'settings.computerUse.stepState.pending',+};++const StepMarker: FC<{ index: number; state: ComputerUseGuideStepState }> = ({ index, state }) => (+ <span+ aria-hidden="true"+ className={clsx(+ 'grid size-6 shrink-0 place-items-center rounded-full border text-[11px] font-semibold',+ state === 'complete' && 'border-mint/40 bg-mint-soft text-mint-ink',+ state === 'current' && 'border-gold/60 bg-gold/[0.12] text-gold-ink',+ state === 'pending' && 'border-border bg-surface text-muted',+ )}+ >+ {state === 'complete' ? <Check className="size-3.5" /> : index + 1}+ </span>+);++/**+ * Settings → Computer Use: the macOS permission setup as one numbered guide+ * whose progress is read from the desktop status endpoint. Only the desktop+ * shell lists this page; any other host reaching it gets a short notice.+ */+export const SettingsComputerUsePage: FC = () => {+ const { t } = useTranslation();+ const desktopShell = isDesktopShell();+ const [read, setRead] = useState<ComputerUseStatusRead | null>(null);+ const [checking, setChecking] = useState(false);+ // A poll that started before a Recheck must not overwrite the newer answer.+ const latestRequest = useRef(0);++ // Resolves to the read, or `undefined` once a newer read has started.+ const readLatest = useCallback(async (): Promise<ComputerUseStatusRead | null | undefined> => {+ const request = ++latestRequest.current;+ const next = await readComputerUseStatus();+ return request === latestRequest.current ? next : undefined;+ }, []);++ // A transient failure (`null`) keeps the last observed state.+ const apply = (next: ComputerUseStatusRead | null | undefined) => {+ if (next) setRead(next);+ };++ const recheck = () => {+ setChecking(true);+ void readLatest().then((next) => {+ setChecking(false);+ apply(next);+ });+ };++ useEffect(() => {+ if (!desktopShell) return undefined;+ const poll = () => {+ void readLatest().then((next) => {+ if (next) setRead(next);+ });+ };+ poll();+ const interval = window.setInterval(poll, COMPUTER_USE_REFRESH_INTERVAL_MS);+ // Granting a permission happens in System Settings; returning to the+ // window is the moment the answer is most likely to have changed.+ const onVisibilityChange = () => {+ if (document.visibilityState === 'visible') poll();+ };+ window.addEventListener('focus', poll);+ document.addEventListener('visibilitychange', onVisibilityChange);+ return () => {+ // Invalidate a read still in flight so it lands nowhere.+ latestRequest.current += 1;+ window.clearInterval(interval);+ window.removeEventListener('focus', poll);+ document.removeEventListener('visibilitychange', onVisibilityChange);+ };+ }, [desktopShell, readLatest]);++ const unsupported = !desktopShell || read?.kind === 'unsupported';+ const status = read?.kind === 'status' ? read.status : null;++ if (unsupported) {+ return (+ <SettingsPageShell+ activeTab="computer-use"+ title={t('settings.computerUse.title')}+ subtitle={t('settings.computerUse.subtitle')}+ >+ <SettingsPanel variant="preference">+ <div className="flex items-start gap-3" data-testid="computer-use-unsupported">+ <Monitor className="mt-0.5 size-5 shrink-0 text-muted" aria-hidden="true" />+ <div className="flex min-w-0 flex-col gap-1">+ <p className="text-[14px] font-semibold text-foreground">+ {t('settings.computerUse.unsupportedTitle')}+ </p>+ <p className="text-[12px] leading-relaxed text-muted">+ {t('settings.computerUse.unsupportedDetail')}+ </p>+ </div>+ </div>+ </SettingsPanel>+ </SettingsPageShell>+ );+ }++ const copy = status ? computerUseStatusCopy(status, (key: ComputerUseCopyKey) => t(key)) : null;+ const progress = status ? computerUseGuideProgress(status) : null;++ return (+ <SettingsPageShell+ activeTab="computer-use"+ title={t('settings.computerUse.title')}+ subtitle={t('settings.computerUse.subtitle')}+ actions={+ <Button+ type="button"+ variant="secondary"+ size="xs"+ disabled={checking}+ onClick={recheck}+ >+ <RotateCw className={clsx('size-3.5', checking && 'animate-spin')} aria-hidden="true" />+ {checking ? t('settings.computerUse.checking') : t('settings.computerUse.recheck')}+ </Button>+ }+ >+ <div+ role="status"+ aria-live="polite"+ className={clsx(+ 'flex items-start gap-2.5 rounded-[10px] border px-4 py-3 text-[12px]',+ computerUseToneClass[copy?.tone ?? 'muted'],+ )}+ data-testid="computer-use-guide-status"+ data-computer-use-status={status?.status ?? 'loading'}+ >+ {status+ ? <ComputerUseStatusIcon status={status.status} />+ : <LoaderCircle className="size-4 shrink-0 animate-spin" aria-hidden="true" />}+ <div className="min-w-0">+ <p className="font-semibold">{copy?.label ?? t('settings.computerUse.loading')}</p>+ {copy && <p className="mt-0.5 text-[11px] opacity-80">{copy.detail}</p>}+ </div>+ </div>++ <SettingsPanel title={t('settings.computerUse.stepsTitle')}>+ <ol className="flex flex-col" data-testid="computer-use-steps">+ {COMPUTER_USE_GUIDE_STEPS.map((step, index) => {+ const state = progress?.[step] ?? 'pending';+ return (+ <li+ key={step}+ aria-current={state === 'current' ? 'step' : undefined}+ data-step={step}+ data-step-state={state}+ className={clsx(+ 'flex items-start gap-3 border-b border-border px-5 py-3.5 last:border-b-0',+ state === 'current' && 'bg-gold/[0.05]',+ )}+ >+ <StepMarker index={index} state={state} />+ <div className="flex min-w-0 flex-col gap-0.5">+ <p+ className={clsx(+ 'text-[13px] font-medium',+ state === 'pending' ? 'text-muted' : 'text-foreground',+ )}+ >+ {t(STEP_COPY[step].title)}+ <span className="sr-only">{` — ${t(STEP_STATE_LABEL[state])}`}</span>+ </p>+ <p className="max-w-2xl text-[12px] leading-relaxed text-muted">+ {t(STEP_COPY[step].detail)}+ </p>+ </div>+ </li>+ );+ })}+ </ol>+ </SettingsPanel>+ </SettingsPageShell>+ );+};diff --git a/ui/src/components/settings/SettingsLayout.test.tsx b/ui/src/components/settings/SettingsLayout.test.tsxindex 95a1c3e92..7c960edb5 100644--- a/ui/src/components/settings/SettingsLayout.test.tsx+++ b/ui/src/components/settings/SettingsLayout.test.tsx@@ -205,6 +205,31 @@ describe('SettingsLayout', () => {}});+ it('lists Computer Use under System only inside the desktop shell, whatever the viewport', () => {+ // A wide browser tab is a desktop viewport but not the desktop host.+ media.matches = true;+ const view = renderLayout('/settings/shortcuts');+ expect(screen.queryByRole('link', { name: 'settings.sections.computerUse' })).toBeNull();+ view.unmount();++ Object.defineProperty(window, '__AVIBE_DESKTOP_SHELL__', { value: true, configurable: true });+ try {+ for (const canManage of [true, false]) {+ authorization.capabilities.can_manage_instance = canManage;+ const shellView = renderLayout('/settings/shortcuts');+ const link = screen.getByRole('link', { name: 'settings.sections.computerUse' });+ expect(link.getAttribute('href')).toBe('/settings/computer-use');+ const systemRows = screen.getAllByRole('link').map((row) => row.getAttribute('href'));+ expect(systemRows.indexOf('/settings/computer-use')).toBe(+ systemRows.indexOf('/settings/shortcuts') + 1,+ );+ shellView.unmount();+ }+ } finally {+ Reflect.deleteProperty(window, '__AVIBE_DESKTOP_SHELL__');+ }+ });+it('keeps the settings rail fixed while the route pane owns vertical scrolling', () => {renderLayout('/settings/replies');diff --git a/ui/src/components/settings/SettingsLayout.tsx b/ui/src/components/settings/SettingsLayout.tsxindex 40b148aa1..aaeda4f78 100644--- a/ui/src/components/settings/SettingsLayout.tsx+++ b/ui/src/components/settings/SettingsLayout.tsx@@ -11,6 +11,7 @@ import {Hash,Keyboard,Layers,+ MonitorCog,MessageCircle,MessageSquare,Package,@@ -48,6 +49,8 @@ type SettingsItem = {icon: React.ComponentType<{ className?: string }>;ownerOnly?: boolean;feature?: 'channels';+ /** Listed only inside the Avibe desktop shell (the host, not the viewport). */+ desktopShellOnly?: boolean;children?: SettingsItem[];defaultOpen?: boolean;exact?: boolean;@@ -105,6 +108,12 @@ const SETTINGS_GROUPS: SettingsGroup[] = [labelKey: 'settings.groups.system',items: [{ path: '/settings/shortcuts', labelKey: 'settings.sections.shortcuts', icon: Keyboard },+ {+ path: '/settings/computer-use',+ labelKey: 'settings.sections.computerUse',+ icon: MonitorCog,+ desktopShellOnly: true,+ },{ path: '/settings/service', labelKey: 'settings.sections.service', icon: Layers, ownerOnly: true },{ path: '/settings/dependencies', labelKey: 'settings.sections.dependencies', icon: Package, ownerOnly: true },{ path: '/settings/diagnostics', labelKey: 'settings.sections.diagnostics', icon: Stethoscope, ownerOnly: true },@@ -291,6 +300,7 @@ export const SettingsLayout: React.FC = () => {// row would leave the setup and lose the step it is on.if (setupOrigin && !SETUP_VISIT_SETTINGS_PATHS.has(item.path)) return [];if (item.ownerOnly && !capabilities.can_manage_instance) return [];+ if (item.desktopShellOnly && !desktopShell) return [];return [{...item,children: item.children?.filter((child) =>@@ -298,7 +308,7 @@ export const SettingsLayout: React.FC = () => {}];}),})).filter((group) => group.items.length > 0),- [capabilities.can_manage_instance, channelSettingsVisible, setupOrigin],+ [capabilities.can_manage_instance, channelSettingsVisible, desktopShell, setupOrigin],);const activeTrail = (() => {diff --git a/ui/src/components/workbench/ComputerUseStatusLine.test.tsx b/ui/src/components/workbench/ComputerUseStatusLine.test.tsxindex 00e052221..3d321c6d7 100644--- a/ui/src/components/workbench/ComputerUseStatusLine.test.tsx+++ b/ui/src/components/workbench/ComputerUseStatusLine.test.tsx@@ -1,6 +1,7 @@/* @vitest-environment jsdom */import { cleanup, render, screen, waitFor } from '@testing-library/react';+import { MemoryRouter } from 'react-router-dom';import { afterEach, describe, expect, it, vi } from 'vitest';import en from '../../i18n/en.json';@@ -18,8 +19,11 @@ vi.mock('react-i18next', () => ({afterEach(() => {cleanup();apiFetch.mockReset();+ Reflect.deleteProperty(window, '__AVIBE_DESKTOP_SHELL__');});+const renderLine = () => render(<MemoryRouter><ComputerUseStatusLine /></MemoryRouter>);+describe('computerUseStatusCopy', () => {it('maps permission reasons to localized copy without exposing raw reason codes', () => {const copy = computerUseStatusCopy(@@ -118,7 +122,7 @@ describe('ComputerUseStatusLine', () => {json: async () => ({ status: 'needs_permission', reason: 'screen_recording' }),});- render(<ComputerUseStatusLine />);+ renderLine();await waitFor(() => {expect(screen.getByTestId('computer-use-status')).toBeTruthy();@@ -141,7 +145,7 @@ describe('ComputerUseStatusLine', () => {json: async () => ({ supported: false, status: 'unavailable', reason: 'unsupported_host' }),});- render(<ComputerUseStatusLine />);+ renderLine();await waitFor(() => {expect(apiFetch).toHaveBeenCalled();@@ -159,7 +163,7 @@ describe('ComputerUseStatusLine', () => {}),});- render(<ComputerUseStatusLine />);+ renderLine();await waitFor(() => {expect(screen.getByTestId('computer-use-status')).toBeTruthy();@@ -170,4 +174,33 @@ describe('ComputerUseStatusLine', () => {expect(screen.getByText('workbench.home.computerUse.controllerUnavailableDetail')).toBeTruthy();expect(screen.queryByText('workbench.home.computerUse.readyDetail')).toBeNull();});++ it('links to the Settings guide only inside the desktop shell and only until ready', async () => {+ const link = () => screen.queryByRole('link', { name: 'workbench.home.computerUse.finishInSettings' });+ apiFetch.mockResolvedValue({+ ok: true,+ json: async () => ({ supported: true, status: 'needs_permission', reason: 'accessibility' }),+ });++ renderLine();+ await waitFor(() => expect(screen.getByTestId('computer-use-status')).toBeTruthy());+ expect(link()).toBeNull();+ cleanup();++ Object.defineProperty(window, '__AVIBE_DESKTOP_SHELL__', { value: true, configurable: true });+ renderLine();+ await waitFor(() => expect(link()).toBeTruthy());+ expect(link()?.getAttribute('href')).toBe('/settings/computer-use');+ cleanup();++ apiFetch.mockResolvedValue({+ ok: true,+ json: async () => ({ supported: true, status: 'ready', reason: null }),+ });+ renderLine();+ await waitFor(() => {+ expect(screen.getByTestId('computer-use-status').getAttribute('data-computer-use-status')).toBe('ready');+ });+ expect(link()).toBeNull();+ });});diff --git a/ui/src/components/workbench/ComputerUseStatusLine.tsx b/ui/src/components/workbench/ComputerUseStatusLine.tsxindex e000e50f9..44ab31555 100644--- a/ui/src/components/workbench/ComputerUseStatusLine.tsx+++ b/ui/src/components/workbench/ComputerUseStatusLine.tsx@@ -1,18 +1,22 @@import { useEffect, useSyncExternalStore } from 'react';import type { FC } from 'react';import { CircleAlert, CircleCheck, LoaderCircle, ShieldAlert } from 'lucide-react';+import { Link } from 'react-router-dom';import { useTranslation } from 'react-i18next';-import { apiFetch } from '../../lib/apiFetch';+import { isDesktopShell } from '../../lib/desktopShell';+import {+ COMPUTER_USE_REFRESH_INTERVAL_MS,+ COMPUTER_USE_SETTINGS_PATH,+ computerUseToneClass,+ readComputerUseStatus,+} from './computerUseStatus';import {computerUseStatusCopy,type ComputerUseCopyKey,type ComputerUseStatus,- type StatusTone,} from './computerUseStatusCopy';-const REFRESH_INTERVAL_MS = 5_000;-let statusSnapshot: ComputerUseStatus | null = null;const listeners = new Set<() => void>();@@ -38,33 +42,14 @@ const publishStatus = (next: ComputerUseStatus | null) => {};const refreshComputerUseStatus = async () => {- try {- const response = await apiFetch('/api/desktop/computer-use/status', { cache: 'no-store' });- if (!response.ok) return;- const payload = await response.json() as Partial<ComputerUseStatus> & { supported?: boolean };- if (payload.supported === false) {- publishStatus(null);- return;- }- if (typeof payload.status !== 'string') return;- publishStatus({- status: payload.status,- reason: typeof payload.reason === 'string' ? payload.reason : null,- });- } catch {- // A transient UI response is not a Computer Use state. Keep the last- // observed line until the next no-store refresh.- }-};--const toneClass: Record<StatusTone, string> = {- muted: 'border-border bg-surface text-muted',- mint: 'border-mint/30 bg-mint-soft text-mint-ink',- gold: 'border-gold/35 bg-gold/[0.08] text-gold-ink',- destructive: 'border-destructive/35 bg-destructive/[0.06] text-destructive-ink',+ const read = await readComputerUseStatus();+ // A transient UI response is not a Computer Use state. Keep the last+ // observed line until the next no-store refresh.+ if (!read) return;+ publishStatus(read.kind === 'status' ? read.status : null);};-const StatusIcon: FC<{ status: string }> = ({ status }) => {+export const ComputerUseStatusIcon: FC<{ status: string }> = ({ status }) => {if (status === 'ready') return <CircleCheck className="size-4 shrink-0" aria-hidden="true" />;if (status === 'needs_permission' || status === 'needs_runtime') {return <ShieldAlert className="size-4 shrink-0" aria-hidden="true" />;@@ -82,7 +67,7 @@ export const ComputerUseStatusLine: FC = () => {useEffect(() => {void refreshComputerUseStatus();- const interval = window.setInterval(() => void refreshComputerUseStatus(), REFRESH_INTERVAL_MS);+ const interval = window.setInterval(() => void refreshComputerUseStatus(), COMPUTER_USE_REFRESH_INTERVAL_MS);const onVisibilityChange = () => {if (document.visibilityState === 'visible') void refreshComputerUseStatus();};@@ -100,18 +85,29 @@ export const ComputerUseStatusLine: FC = () => {if (!status) return null;const copy = computerUseStatusCopy(status, (key: ComputerUseCopyKey) => t(key));+ const setupLink = status.status !== 'ready' && isDesktopShell();return (<divaria-label={copy.label}- className={`flex w-full items-start gap-2.5 rounded-[10px] border px-4 py-2.5 text-[12px] ${toneClass[copy.tone]}`}+ className={`flex w-full items-start gap-2.5 rounded-[10px] border px-4 py-2.5 text-[12px] ${computerUseToneClass[copy.tone]}`}data-computer-use-status={status.status}data-testid="computer-use-status">- <StatusIcon status={status.status} />- <div className="min-w-0">+ <ComputerUseStatusIcon status={status.status} />+ <div className="min-w-0 flex-1"><p className="font-semibold">{copy.label}</p><p className="mt-0.5 text-[11px] opacity-80">{copy.detail}</p></div>+ {/* The step-by-step guide lives in Settings, which only the desktop+ shell shows; a browser tab keeps the line as status alone. */}+ {setupLink && (+ <Link+ to={COMPUTER_USE_SETTINGS_PATH}+ className="shrink-0 self-center rounded-md px-2 py-1 text-[11px] font-semibold underline-offset-2 hover:underline"+ >+ {t('workbench.home.computerUse.finishInSettings')}+ </Link>+ )}</div>);};diff --git a/ui/src/components/workbench/computerUseStatus.ts b/ui/src/components/workbench/computerUseStatus.tsnew file mode 100644index 000000000..4ab63f042--- /dev/null+++ b/ui/src/components/workbench/computerUseStatus.ts@@ -0,0 +1,91 @@+import { apiFetch } from '../../lib/apiFetch';+import type { ComputerUseStatus, StatusTone } from './computerUseStatusCopy';++export const COMPUTER_USE_STATUS_PATH = '/api/desktop/computer-use/status';+export const COMPUTER_USE_SETTINGS_PATH = '/settings/computer-use';+export const COMPUTER_USE_REFRESH_INTERVAL_MS = 5_000;++/**+ * One read of the desktop status endpoint.+ *+ * - `unsupported`: the host has no live desktop shell (`supported: false`).+ * - `null`: a transient or malformed response. It is not a Computer Use state,+ * so callers keep whatever they last observed.+ */+export type ComputerUseStatusRead =+ | { kind: 'unsupported' }+ | { kind: 'status'; status: ComputerUseStatus };++export const readComputerUseStatus = async (): Promise<ComputerUseStatusRead | null> => {+ try {+ const response = await apiFetch(COMPUTER_USE_STATUS_PATH, { cache: 'no-store' });+ if (!response.ok) return null;+ const payload = await response.json() as Partial<ComputerUseStatus> & { supported?: boolean };+ if (payload.supported === false) return { kind: 'unsupported' };+ if (typeof payload.status !== 'string') return null;+ return {+ kind: 'status',+ status: {+ status: payload.status,+ reason: typeof payload.reason === 'string' ? payload.reason : null,+ },+ };+ } catch {+ return null;+ }+};++export const computerUseToneClass: Record<StatusTone, string> = {+ muted: 'border-border bg-surface text-muted',+ mint: 'border-mint/30 bg-mint-soft text-mint-ink',+ gold: 'border-gold/35 bg-gold/[0.08] text-gold-ink',+ destructive: 'border-destructive/35 bg-destructive/[0.06] text-destructive-ink',+};++export const COMPUTER_USE_GUIDE_STEPS = [+ 'enable',+ 'accessibility',+ 'screenRecording',+ 'recheck',+] as const;++export type ComputerUseGuideStep = (typeof COMPUTER_USE_GUIDE_STEPS)[number];+export type ComputerUseGuideStepState = 'complete' | 'current' | 'pending';++/**+ * How far the setup has observably progressed.+ *+ * Steps only claim progress the status reports. The managed driver checks+ * Accessibility before Screen Recording, so `screen_recording` proves+ * Accessibility passed while `accessibility` says nothing about Screen+ * Recording. Every other non-ready state (starting, waiting for the service,+ * error) only proves Computer Use was turned on; the status header carries+ * the detail for those.+ */+export const computerUseGuideProgress = (+ status: ComputerUseStatus,+): Record<ComputerUseGuideStep, ComputerUseGuideStepState> => {+ const stateAt = (completed: number, current: number | null) =>+ Object.fromEntries(COMPUTER_USE_GUIDE_STEPS.map((step, index) => [+ step,+ index < completed ? 'complete' : index === current ? 'current' : 'pending',+ ])) as Record<ComputerUseGuideStep, ComputerUseGuideStepState>;++ switch (status.status) {+ case 'ready':+ return stateAt(COMPUTER_USE_GUIDE_STEPS.length, null);+ case 'needs_permission':+ return status.reason === 'screen_recording' ? stateAt(2, 2) : stateAt(1, 1);+ case 'starting':+ case 'needs_runtime':+ case 'error':+ return stateAt(1, null);+ case 'unavailable':+ // The shell or driver cannot be read, so even the toggle is unknown.+ return stateAt(0, null);+ default:+ // `off`, and any state this build does not know, which the status copy+ // also renders as off.+ return stateAt(0, 0);+ }+};diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex edddde3fc..322b8b7d7 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -437,6 +437,7 @@"platformConnections": "Platform Connections","remoteAccess": "Remote Access","shortcuts": "Shortcuts",+ "computerUse": "Computer Use","service": "Service","dependencies": "Dependencies","diagnostics": "Diagnostics & Logs",@@ -517,6 +518,39 @@},"reset": "Restore defaults"},+ "computerUse": {+ "title": "Computer Use",+ "subtitle": "Let Avibe agents see and operate this Mac. Follow the steps in order; this page updates as each one is done.",+ "recheck": "Recheck",+ "checking": "Checking…",+ "loading": "Checking Computer Use status…",+ "stepsTitle": "Setup steps",+ "unsupportedTitle": "Available in the Avibe desktop app",+ "unsupportedDetail": "Computer Use is set up from Avibe Desktop on a Mac. Open the desktop app to continue.",+ "stepState": {+ "complete": "done",+ "current": "current step",+ "pending": "not done yet"+ },+ "steps": {+ "enable": {+ "title": "Turn on Computer Use",+ "detail": "In the Avibe Desktop menu bar (tray) menu, turn on Computer Use."+ },+ "accessibility": {+ "title": "Allow Accessibility",+ "detail": "In System Settings → Privacy & Security → Accessibility, turn on Avibe. Avibe usually opens this pane for you; if Avibe is not listed, click + and add it."+ },+ "screenRecording": {+ "title": "Allow Screen & System Audio Recording",+ "detail": "In System Settings → Privacy & Security → Screen & System Audio Recording, authorize the running Avibe Desktop app: click +, or drag Avibe into the list, then turn it on."+ },+ "recheck": {+ "title": "Come back and recheck",+ "detail": "After you grant Screen Recording, macOS may quit and reopen Avibe. When it reopens, come back here and click Recheck."+ }+ }+ },"diagnosticsTab": "Diagnostics","logsTab": "Logs","diagnosticsNavigationLabel": "Diagnostics and logs",@@ -3214,7 +3248,8 @@"shellNotRunningDetail": "Open or reopen the Avibe desktop app to make Computer Use available.","daemonUnreachableDetail": "The desktop driver is not reachable. Turn Computer Use off and on; reopen Avibe if it repeats.","controllerUnavailableDetail": "The Avibe Controller is not reachable. Wait for the service to recover before using the Computer Use CLI.",- "socketPathTooLongDetail": "macOS could not create the managed driver socket. Update or reinstall the Avibe desktop app."+ "socketPathTooLongDetail": "macOS could not create the managed driver socket. Update or reinstall the Avibe desktop app.",+ "finishInSettings": "Finish in Settings"},"continueOnPhone": "Continue on your phone","connectChatApps": "Connect chat apps in <settings>Settings</settings>"diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 784f39fa4..613d717ec 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -437,6 +437,7 @@"platformConnections": "平台接入","remoteAccess": "远程访问","shortcuts": "快捷键",+ "computerUse": "电脑操作","service": "服务","dependencies": "依赖","diagnostics": "诊断与日志",@@ -517,6 +518,39 @@},"reset": "恢复默认"},+ "computerUse": {+ "title": "电脑操作",+ "subtitle": "让 Avibe Agent 查看并操作这台 Mac。请按顺序完成以下步骤,每完成一步本页都会自动更新。",+ "recheck": "重新检查",+ "checking": "检查中…",+ "loading": "正在检查电脑操作状态…",+ "stepsTitle": "设置步骤",+ "unsupportedTitle": "仅桌面端可用",+ "unsupportedDetail": "电脑操作需要在 Mac 上的 Avibe 桌面应用中设置。请打开桌面应用继续。",+ "stepState": {+ "complete": "已完成",+ "current": "当前步骤",+ "pending": "待完成"+ },+ "steps": {+ "enable": {+ "title": "开启电脑操作",+ "detail": "在菜单栏的 Avibe 桌面应用菜单(托盘)中开启“电脑操作”。"+ },+ "accessibility": {+ "title": "允许辅助功能",+ "detail": "在“系统设置 → 隐私与安全性 → 辅助功能”中开启 Avibe。Avibe 通常会自动打开这个页面;如果列表里没有 Avibe,请点击 + 添加。"+ },+ "screenRecording": {+ "title": "允许屏幕与系统音频录制",+ "detail": "在“系统设置 → 隐私与安全性 → 屏幕与系统音频录制”中授权正在运行的 Avibe 桌面应用:点击 +,或将 Avibe 拖入列表,然后启用它。"+ },+ "recheck": {+ "title": "返回这里重新检查",+ "detail": "授权“屏幕录制”后,macOS 可能会退出并重新打开 Avibe。应用重新打开后,请回到本页点击“重新检查”。"+ }+ }+ },"diagnosticsTab": "诊断","logsTab": "日志","diagnosticsNavigationLabel": "诊断与日志",@@ -3214,7 +3248,8 @@"shellNotRunningDetail": "请打开或重新打开 Avibe 桌面应用,以使用电脑操作。","daemonUnreachableDetail": "桌面驱动当前无法连接。请关闭并重新开启电脑操作;如果问题重复出现,请重新打开 Avibe。","controllerUnavailableDetail": "当前无法连接 Avibe Controller。请等待服务恢复后再使用电脑操作 CLI。",- "socketPathTooLongDetail": "macOS 无法创建受管理的驱动端点。请更新或重新安装 Avibe 桌面应用。"+ "socketPathTooLongDetail": "macOS 无法创建受管理的驱动端点。请更新或重新安装 Avibe 桌面应用。",+ "finishInSettings": "在设置中完成"},"continueOnPhone": "在手机 APP 上继续","connectChatApps": "聊天应用可在<settings>设置</settings>中连接"diff --git a/ui/src/lib/applicationRoutes.ts b/ui/src/lib/applicationRoutes.tsindex 29d07dfa8..2de5888e7 100644--- a/ui/src/lib/applicationRoutes.ts+++ b/ui/src/lib/applicationRoutes.ts@@ -52,6 +52,7 @@ export const APPLICATION_ROUTE_PATHS = ['/settings/appearance','/settings/account','/settings/shortcuts',+ '/settings/computer-use','/settings/service','/settings/platforms','/settings/platforms/groups',