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(setup): remove remote-only wizard restrictions (#2027)

Call White62c0daa5b349
diff --git a/docs/plans/2026-09-17-remote-setup-parity.md b/docs/plans/2026-09-17-remote-setup-parity.md
new file mode 100644
index 000000000..932f06784
--- /dev/null
+++ b/docs/plans/2026-09-17-remote-setup-parity.md
@@ -0,0 +1,41 @@
+# Setup access parity
+
+## Contract
+
+The setup wizard has no local-versus-remote access policy. An authenticated
+remote manager follows the same setup completion state and wizard route as a
+local manager. This supersedes the remote setup exception introduced in #1162
+and the preservation of that exception in the shared Web/desktop design plan.
+
+Remove the remote setup recovery card, its translations, the remote-manager
+setup bypass, and their unused types. Reuse the existing wizard, completion
+mutation, and setup-boundary revalidation.
+
+## Acceptance
+
+- An unfinished local, personal remote, or organization remote installation
+ enters `/setup` and can save completion, then reach the workbench.
+- Explicit `/setup` navigation opens the same wizard, including on an already
+ configured installation.
+- Completed installations keep opening ordinary routes normally.
+- Authentication, authorization recovery, non-manager shell access, and
+ diagnostic escape routes retain their existing behavior.
+- Setup HTTP reads and writes use existing role and CSRF authorization, persist
+ completion, and preserve remote pairing.
+
+## Evidence
+
+Use AuthGuard navigation tests with the real Summary completion component,
+AppShell route tests, and AUTH-SETUP-405 for the real HTTP/config write boundary.
+Run the relevant UI suites, i18n/theme checks, production build, and focused
+Python scenario tests. All state and runtime effects must be test-owned.
+
+Live tunnel/browser and local Incus verification remain separate from the
+hermetic tests. This change does not require backend authorization changes,
+new dependencies, or a new setup flow.
+
+Local verification: the four remote-only UI regressions failed on the old
+implementation; after removing both exceptions, 98 focused UI tests and all four
+HTTP setup cases passed. The scenario catalog check, UI production build,
+TypeScript lint baseline, theme validation, i18n coverage, and changed-file Ruff
+check passed.
diff --git a/tests/scenarios/auth_setup/catalog.yaml b/tests/scenarios/auth_setup/catalog.yaml
index 77bf2f1c1..533274fb6 100644
--- a/tests/scenarios/auth_setup/catalog.yaml
+++ b/tests/scenarios/auth_setup/catalog.yaml
@@ -246,6 +246,16 @@ scenarios:
layer: scenario
backend: show_identity
test: tests/scenarios/auth_setup/test_auth_setup_scenarios.py::test_limited_show_identity_closed_loop_installs_guest_lease
+ - id: AUTH-SETUP-405
+ name: Local and authenticated remote managers complete the same setup flow without changing pairing
+ status: covered
+ kind: historical_regression
+ layer: scenario
+ backend: web
+ test: tests/scenarios/auth_setup/test_auth_setup_scenarios.py::test_setup_completion_uses_the_same_authorized_config_flow
+ supporting_tests:
+ - ui/src/App.remoteAuth.test.tsx
+ - ui/src/components/AppShell.test.tsx
- id: AUTH-SETUP-210
name: Lost Model Hub OAuth start response converges on one provider flow
status: covered
diff --git a/tests/scenarios/auth_setup/test_auth_setup_scenarios.py b/tests/scenarios/auth_setup/test_auth_setup_scenarios.py
index a0c1c7e67..169eedf81 100644
--- a/tests/scenarios/auth_setup/test_auth_setup_scenarios.py
+++ b/tests/scenarios/auth_setup/test_auth_setup_scenarios.py
@@ -86,6 +86,79 @@ def test_auth_setup_catalog_priorities_reference_live_scenarios():
assert set(catalog.get("next_priority", [])) <= live_ids
+ ("access", "role"),
+ [("local", "owner"), ("personal", "owner"), ("organization", "owner"), ("organization", "member")],
+)
+def test_setup_completion_uses_the_same_authorized_config_flow(monkeypatch, tmp_path, access, role):
+ """Scenario: AUTH-SETUP-405 — real auth, CSRF, config persistence and read-back."""
+ from config.v2_settings import SettingsStore
+ from vibe import internal_client
+
+ config = _save_config(tmp_path, paired=True, instance_kind="personal" if access == "local" else access)
+ pairing = config.remote_access
+ monkeypatch.setattr(ui_server, "_ensure_remote_access_monitoring", lambda *_args: None)
+ reconcile = AsyncMock(return_value={"status_code": 200, "body": {"ok": True}})
+ monkeypatch.setattr(internal_client, "reconcile_platforms", reconcile)
+ # Any unintended runtime action must fail instead of starting a real process.
+ monkeypatch.setattr(remote_access, "reconcile", Mock(side_effect=AssertionError("pairing changed")))
+ monkeypatch.setattr(
+ ui_server, "_schedule_service_restart_for_config_fallback",
+ Mock(side_effect=AssertionError("unexpected restart")),
+ )
+ client = app.test_client()
+ base_url = "http://localhost" if access == "local" else "https://alex.avibe.bot"
+ peer = {"REMOTE_ADDR": "127.0.0.1" if access == "local" else "203.0.113.44"}
+ if access != "local":
+ client.set_cookie(
+ remote_access.SESSION_COOKIE_NAME,
+ remote_session_cookie(
+ config, "[email protected]", "owner-1",
+ role=role,
+ access_source="owner" if role == "owner" else "organization_group",
+ organization_id="组织-甲" if access == "organization" else None,
+ organization_member_id="成员-甲" if access == "organization" else None,
+ organization_role=role if access == "organization" else None,
+ group_ids=["研发组"] if access == "organization" else None,
+ ),
+ domain="alex.avibe.bot",
+ )
+ headers = csrf_headers(client, base_url=base_url)
+ SettingsStore.reset_instance()
+ try:
+ session = client.get("/api/session", base_url=base_url, environ_base=peer).get_json()
+ assert session["remote"] is (access != "local")
+ assert session["capabilities"]["can_manage_instance"] is True
+ initial = client.get("/api/config", base_url=base_url, environ_base=peer)
+ assert initial.status_code == 200
+ assert initial.get_json()["setup_state"]["needs_setup"] is True
+ settings = client.get("/api/settings?platform=slack", base_url=base_url, environ_base=peer)
+ assert settings.status_code == 200
+
+ # Use the same narrow POSTs as the platform step and Summary.
+ for payload in (
+ {"slack": {"bot_token": "xoxb-setup-fixture", "app_token": "xapp-setup-fixture"}},
+ {"setup_completed": True, "update": {"auto_update": False}},
+ ):
+ response = client.post(
+ "/api/config", json=payload, headers=headers, base_url=base_url, environ_base=peer,
+ )
+ assert response.status_code == 200, response.get_json()
+ assert response.get_json()["setup_state"]["needs_setup"] is False
+
+ saved = V2Config.load()
+ assert saved.setup_completed is True
+ assert saved.slack.bot_token == "xoxb-setup-fixture"
+ assert saved.remote_access == pairing
+ assert saved.setup_state()["needs_setup"] is False
+ reread = client.get("/api/config", base_url=base_url, environ_base=peer)
+ assert reread.status_code == 200
+ assert reread.get_json()["setup_state"]["needs_setup"] is False
+ reconcile.assert_awaited()
+ finally:
+ SettingsStore.reset_instance()
+
+
def test_limited_show_identity_closed_loop_installs_guest_lease(monkeypatch, tmp_path):
"""Scenario: AUTH-SETUP-404"""
monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
diff --git a/ui/src/App.remoteAuth.test.tsx b/ui/src/App.remoteAuth.test.tsx
index 0bdf58ec3..112140373 100644
--- a/ui/src/App.remoteAuth.test.tsx
+++ b/ui/src/App.remoteAuth.test.tsx
@@ -1,11 +1,13 @@
/* @vitest-environment jsdom */
import { act, cleanup, render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
import { useLayoutEffect } from 'react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { MemoryRouter, Navigate, Route, Routes } from 'react-router-dom';
import { AuthGuard } from './App';
+import { Summary } from './components/steps/Summary';
import { useInstanceAuthorization } from './context/InstanceAuthorizationContext';
import { DENIED_INSTANCE_CAPABILITIES, OWNER_INSTANCE_CAPABILITIES } from './lib/sessionInfo';
import { isOwnerOnlyPath } from './lib/adminNavigation';
@@ -27,11 +29,15 @@ vi.hoisted(() => {
const api = vi.hoisted(() => ({
getAuthSession: vi.fn(),
getConfig: vi.fn(),
+ mutateConfig: vi.fn(),
}));
+const status = vi.hoisted(() => ({ control: vi.fn() }));
vi.mock('./context/ApiContext', () => ({
useApi: () => api,
}));
+vi.mock('./context/StatusContext', () => ({ useStatus: () => status }));
+vi.mock('./context/ToastContext', () => ({ useToast: () => ({ showToast: vi.fn() }) }));
vi.mock('react-i18next', () => ({
useTranslation: () => ({ t: (key: string) => key }),
@@ -198,3 +204,116 @@ describe('AuthGuard setup-bypass authorization', () => {
expect(screen.queryByText('workbench-home')).toBeNull();
});
});
+
+describe('AuthGuard setup access parity (AUTH-SETUP-405)', () => {
+ const managers = [
+ { remote: false, instance_kind: 'personal', instance_role: 'owner' },
+ { remote: true, instance_kind: 'personal', instance_role: 'owner' },
+ { remote: true, instance_kind: 'organization', instance_role: 'owner' },
+ { remote: true, instance_kind: 'organization', instance_role: 'member' },
+ ] as const;
+
+ const connect = (context: typeof managers[number], needsSetup: boolean) => {
+ api.getAuthSession.mockResolvedValue({
+ ...context,
+ authenticated: true,
+ email: '[email protected]',
+ capabilities: {
+ ...OWNER_INSTANCE_CAPABILITIES,
+ is_instance_owner: context.instance_role === 'owner',
+ can_manage_access_members: context.instance_role === 'owner',
+ },
+ authorization_state: 'current',
+ });
+ api.getConfig.mockResolvedValue({
+ mode: 'self_host',
+ setup_state: { needs_setup: needsSetup },
+ });
+ };
+
+ const renderSetupRoutes = (path: string) => render(
+ <MemoryRouter initialEntries={[path]}>
+ <AuthGuard>
+ <Routes>
+ <Route path="/" element={<div>workbench-home</div>} />
+ <Route path="/setup" element={
+ <Summary
+ data={{ platforms: { enabled: [] } }}
+ onNext={() => undefined}
+ onBack={() => undefined}
+ isFirst={false}
+ isLast
+ />
+ } />
+ </Routes>
+ </AuthGuard>
+ </MemoryRouter>,
+ );
+
+ it.each(managers)(
+ 'completes setup and returns home for $instance_kind $instance_role (remote: $remote)',
+ async (context) => {
+ connect(context, true);
+ api.mutateConfig.mockImplementation(async () => {
+ api.getConfig.mockResolvedValue({
+ mode: 'self_host',
+ setup_state: { needs_setup: false },
+ });
+ return { setup_completed: true, platforms: { enabled: [] } };
+ });
+ status.control.mockResolvedValue(undefined);
+ const user = userEvent.setup();
+ renderSetupRoutes('/');
+
+ await user.click(await screen.findByRole('button', { name: 'summary.finishAndStart' }));
+
+ expect(api.mutateConfig).toHaveBeenCalledWith(expect.arrayContaining([
+ { kind: 'set', path: ['setup_completed'], value: true },
+ ]));
+ expect(status.control).toHaveBeenCalledWith('start');
+ expect(await screen.findByText('workbench-home', {}, { timeout: 2_000 })).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'summary.finishAndStart' })).toBeNull();
+ },
+ );
+
+ it.each(managers)('keeps completed $instance_kind $instance_role at home (remote: $remote)', async (context) => {
+ connect(context, false);
+ renderSetupRoutes('/');
+ expect(await screen.findByText('workbench-home')).toBeTruthy();
+ expect(api.mutateConfig).not.toHaveBeenCalled();
+ });
+
+ it.each(managers)('allows explicit setup for configured $instance_kind $instance_role (remote: $remote)', async (context) => {
+ connect(context, false);
+ renderSetupRoutes('/setup');
+ expect(await screen.findByRole('button', { name: 'summary.finishAndStart' })).toBeTruthy();
+ expect(api.mutateConfig).not.toHaveBeenCalled();
+ });
+
+ it.each(['editor', 'viewer'])('does not force a remote %s to complete instance setup', async (role) => {
+ api.getAuthSession.mockResolvedValue({
+ remote: true,
+ authenticated: true,
+ instance_kind: 'organization',
+ instance_role: role,
+ authorization_state: 'current',
+ capabilities: { ...DENIED_INSTANCE_CAPABILITIES, can_read_instance: true },
+ });
+ renderSetupRoutes('/');
+ expect(await screen.findByText('workbench-home')).toBeTruthy();
+ expect(api.getConfig).not.toHaveBeenCalled();
+ });
+
+ it('keeps a revoked remote session out of setup', async () => {
+ api.getAuthSession.mockResolvedValue({
+ remote: true,
+ authenticated: true,
+ instance_kind: 'organization',
+ authorization_state: 'revoked',
+ });
+ renderSetupRoutes('/setup');
+ expect(await screen.findByText('remoteAuthorization.revoked.body')).toBeTruthy();
+ expect(api.getConfig).not.toHaveBeenCalled();
+ expect(api.mutateConfig).not.toHaveBeenCalled();
+ });
+});
diff --git a/ui/src/App.tsx b/ui/src/App.tsx
index b7eb06238..f1785d0d2 100644
--- a/ui/src/App.tsx
+++ b/ui/src/App.tsx
@@ -61,7 +61,6 @@ import {
REMOTE_AUTH_STATE_EVENT,
reportRemoteAuthorizationState,
type RemoteAuthorizationState,
- shouldBypassSetupForRemoteOwner,
shouldDeferRemoteAuthRedirect,
} from './lib/remoteAuth';
import { useIsDesktop } from './lib/useIsDesktop';
@@ -401,10 +400,6 @@ export const AuthGuard = ({ children }: { children: ReactNode }) => {
? setupState.needs_setup === false
: hasConfiguredPlatformCredentials(config);
if (!config || !config.mode || !setupReady) {
- if (shouldBypassSetupForRemoteOwner(session)) {
- setGuardStatus('ready');
- return;
- }
setGuardStatus('needs-setup');
return;
}
diff --git a/ui/src/components/AppShell.test.tsx b/ui/src/components/AppShell.test.tsx
index 30871a54a..796f12952 100644
--- a/ui/src/components/AppShell.test.tsx
+++ b/ui/src/components/AppShell.test.tsx
@@ -111,6 +111,7 @@ vi.mock('react-i18next', () => ({
beforeEach(() => {
viewport.isDesktop = false;
clearMobileProjectsListSnapshot();
+ instanceAuth.remote = true;
instanceAuth.instanceKind = null;
instanceAuth.capabilities.can_manage_instance = true;
instanceAuth.capabilities.can_chat = true;
@@ -131,8 +132,13 @@ afterEach(() => {
vi.clearAllMocks();
});
-describe('AppShell setup recovery', () => {
- it('shows the remote-owner recovery card instead of the wizard', async () => {
+describe('AppShell setup access', () => {
+ it.each([
+ { remote: false, instanceKind: 'personal' as const },
+ { remote: true, instanceKind: 'personal' as const },
+ { remote: true, instanceKind: 'organization' as const },
+ ])('renders the wizard for $instanceKind access (remote: $remote)', async (context) => {
+ Object.assign(instanceAuth, context);
render(
<MemoryRouter initialEntries={['/setup']}>
<Routes>
@@ -143,9 +149,8 @@ describe('AppShell setup recovery', () => {
</MemoryRouter>,
);
- expect(await screen.findByText('setup.remoteOwner.title')).toBeTruthy();
- expect(screen.getByRole('link', { name: 'setup.remoteOwner.action' }).getAttribute('href')).toBe('/settings/service');
- expect(screen.queryByTestId('wizard')).toBeNull();
+ expect(await screen.findByTestId('wizard')).toBeTruthy();
+ expect(screen.queryByTestId('workbench-sidebar')).toBeNull();
});
});
diff --git a/ui/src/components/AppShell.tsx b/ui/src/components/AppShell.tsx
index bedff66dd..4057e45b2 100644
--- a/ui/src/components/AppShell.tsx
+++ b/ui/src/components/AppShell.tsx
@@ -14,7 +14,6 @@ import { VersionBadge } from './VersionBadge';
import { WorkbenchSidebar } from './workbench/WorkbenchSidebar';
import { AppsLauncher } from './AppsLauncher';
import { ErrorBoundary } from './ui/error-boundary';
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from './ui/card';
import { WindowManagerProvider } from '../context/WindowManagerProvider';
import { DockProvider } from '../context/DockProvider';
import { ShowPageDragProvider } from '../context/ShowPageDragProvider';
@@ -172,10 +171,7 @@ export const AppShell: React.FC = () => {
// fetch on a phone. A demand gate keyed on mounting is only honest if mounting
// implies visible, so the mount site has to carry the viewport too.
const isDesktop = useIsDesktop();
- const {
- capabilities,
- remote,
- } = useInstanceAuthorization();
+ const { capabilities } = useInstanceAuthorization();
const api = useApi();
const location = useLocation();
const navigate = useNavigate();
@@ -269,45 +265,6 @@ export const AppShell: React.FC = () => {
window.history.replaceState(window.history.state, '', `${url.pathname}${url.search}${url.hash}`);
}, [chromeless, location.pathname, location.search]);
- if (
- location.pathname === '/setup' &&
- remote &&
- capabilities.can_manage_instance
- ) {
- return (
- <main className="flex min-h-screen items-center justify-center bg-background p-4 text-foreground">
- <Card className="w-full max-w-md">
- <CardHeader>
- <CardTitle>{t('setup.remoteOwner.title')}</CardTitle>
- <CardDescription>{t('setup.remoteOwner.body')}</CardDescription>
- </CardHeader>
- <CardContent className="space-y-4">
- {/* This copy deliberately names no address. Composing one here from
- `ui.setup_host` / `ui.setup_port` was wrong twice (port, then
- address family), and delegating to
- `remote_access.origin_service_for_pairing` was wrong too: that
- function answers which origin `cloudflared` should dial, which
- only equals "which address opens this UI" while the cloud tunnel
- is enabled, because that is the only case where the bind is
- widened to a wildcard. This card renders before setup is
- finished — usually with the tunnel off — where the projected
- `127.0.0.1` is unreachable for every non-loopback `setup_host`.
- No address means none to get wrong. See issue #1965 for the
- pre-existing pairing bug that analysis uncovered. */}
- <p className="text-sm leading-relaxed text-muted">
- {t('setup.remoteOwner.hint')}
- </p>
- <Button asChild>
- <Link to="/settings/service">
- {t('setup.remoteOwner.action')}
- </Link>
- </Button>
- </CardContent>
- </Card>
- </main>
- );
- }
-
const isRunning = status.state === 'running';
const canUseApps = capabilities.can_chat;
const canUseShowPageApp =
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 52bafcdd1..3a5353c34 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -2672,14 +2672,6 @@
}
}
},
- "setup": {
- "remoteOwner": {
- "title": "Setup runs on the machine itself",
- "body": "You're connected through remote access, so Avibe skips the first-run wizard here.",
- "hint": "Platforms, backends, and models are all in Settings. The wizard itself only runs on the machine running Avibe.",
- "action": "Open Settings"
- }
- },
"wizard": {
"title": "Avibe Setup"
},
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 1a4e14103..18ce89777 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -2672,14 +2672,6 @@
}
}
},
- "setup": {
- "remoteOwner": {
- "title": "首次设置需在本机完成",
- "body": "你正通过远程访问连接,Avibe 在这里会跳过首次设置向导。",
- "hint": "通讯平台、后端和模型都在设置里。向导只能在运行 Avibe 的机器上打开。",
- "action": "打开设置"
- }
- },
"wizard": {
"title": "Avibe 设置向导"
},
diff --git a/ui/src/lib/remoteAuth.test.ts b/ui/src/lib/remoteAuth.test.ts
index 5f45e9ada..ab185d8bc 100644
--- a/ui/src/lib/remoteAuth.test.ts
+++ b/ui/src/lib/remoteAuth.test.ts
@@ -12,7 +12,6 @@ import {
deferRemoteAuthRedirect,
reportRemoteAuthorizationState,
remoteLoginPath,
- shouldBypassSetupForRemoteOwner,
REMOTE_AUTH_REQUIRED_EVENT,
REMOTE_AUTH_STATE_EVENT,
shouldDeferRemoteAuthRedirect,
@@ -84,6 +83,17 @@ describe('remote auth navigation', () => {
});
});
+ it('requires authentication before opening remote setup', async () => {
+ await expect(checkRemoteAuthForPath(
+ '/setup',
+ async () => ({ remote: true, authenticated: false }),
+ )).resolves.toEqual({
+ session: { remote: true, authenticated: false },
+ loginRequired: true,
+ checkSetup: true,
+ });
+ });
+
it('signals AuthGuard instead of navigating automatically', () => {
platform.isIosDevice.mockReturnValue(true);
platform.isStandalonePwa.mockReturnValue(true);
@@ -96,7 +106,6 @@ describe('remote auth navigation', () => {
expect(dispatchEvent.mock.calls[0]?.[0].type).toBe(REMOTE_AUTH_REQUIRED_EVENT);
});
});
-
describe('remote authorization recovery', () => {
beforeEach(() => {
vi.useFakeTimers();
@@ -169,29 +178,3 @@ describe('remote authorization recovery', () => {
expect(fetchMock).toHaveBeenCalledOnce();
});
});
-
-describe('setup bypass for remote runtime access', () => {
- it('bypasses setup only for an authenticated Instance Owner', () => {
- expect(
- shouldBypassSetupForRemoteOwner({
- remote: true,
- authenticated: true,
- capabilities: { can_manage_instance: true },
- }),
- ).toBe(true);
- expect(
- shouldBypassSetupForRemoteOwner({
- remote: true,
- authenticated: true,
- capabilities: { can_manage_instance: false },
- }),
- ).toBe(false);
- expect(
- shouldBypassSetupForRemoteOwner({
- remote: false,
- authenticated: true,
- capabilities: { can_manage_instance: true },
- }),
- ).toBe(false);
- });
-});
diff --git a/ui/src/lib/remoteAuth.ts b/ui/src/lib/remoteAuth.ts
index 3a06a8b2e..875f54361 100644
--- a/ui/src/lib/remoteAuth.ts
+++ b/ui/src/lib/remoteAuth.ts
@@ -51,21 +51,6 @@ export function isSetupCheckBypassed(path: string): boolean {
return SETUP_CHECK_BYPASS_PATHS.has(path);
}
-export type RemoteContext = {
- remote: boolean;
-};
-type RemoteSetupSession = RemoteContext & {
- authenticated?: boolean;
- capabilities?: { can_manage_instance?: boolean };
-};
-
-/** Remote runtime principals skip the local setup wizard and use shell recovery. */
-export function shouldBypassSetupForRemoteOwner(session: RemoteSetupSession | null | undefined): boolean {
- return !!session?.remote && session.authenticated === true && (
- session.capabilities?.can_manage_instance === true
- );
-}
-
export async function checkRemoteAuthForPath<Session extends RemoteSession>(
path: string,
getSession: () => Promise<Session>,