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(settings): keep Models resident in the settings rail (#2447)

Call White2a4c6ddbc29a
diff --git a/ui/src/components/settings/SettingsLayout.test.tsx b/ui/src/components/settings/SettingsLayout.test.tsx
index 56558d661..95a1c3e92 100644
--- a/ui/src/components/settings/SettingsLayout.test.tsx
+++ b/ui/src/components/settings/SettingsLayout.test.tsx
@@ -15,6 +15,7 @@ import { ShellSidebarContext } from '@/context/ShellSidebarContext';
import { SETTINGS_MENU_PLACEMENT_STORAGE_KEY } from '@/lib/settingsMenuPlacement';
import { SETTINGS_LAST_SECTION_STORAGE_KEY } from '@/lib/settingsSectionMemory';
import { ModelHubCapabilityGate } from './models/ModelHubCapabilityGate';
+import { SettingsOverlayNavigationBoundary } from './SettingsOverlayNavigationBoundary';
import { SettingsLayout } from './SettingsLayout';
const api = vi.hoisted(() => {
@@ -104,6 +105,7 @@ const renderLayout = (
) => render(
<MemoryRouter initialEntries={[entry]}>
<ShellSidebarContext.Provider value={shellHasSidebar}>
+ <SettingsOverlayNavigationBoundary desktop={shellHasSidebar}>
<Routes>
<Route path="/settings" element={<SettingsLayoutHarness />}>
<Route path="general" element={<div>general-body</div>} />
@@ -121,6 +123,7 @@ const renderLayout = (
</Route>
<Route path="/chat/:sessionId" element={<div>chat-body</div>} />
</Routes>
+ </SettingsOverlayNavigationBoundary>
</ShellSidebarContext.Provider>
</MemoryRouter>,
);
@@ -294,21 +297,37 @@ describe('SettingsLayout', () => {
expect(standardFrame?.className).not.toContain('min-h-full');
});
- it('renders the three-group rail and feature-gated owner sections', async () => {
+ it('renders the three-group rail and feature-gated owner sections', () => {
renderLayout('/settings/replies');
expect(screen.getByText('replies-body')).toBeTruthy();
expect(screen.getByText('settings.groups.agents')).toBeTruthy();
expect(screen.getByText('settings.groups.connections')).toBeTruthy();
expect(screen.getByText('settings.groups.system')).toBeTruthy();
- await waitFor(() => {
- expect(screen.getByRole('link', { name: 'settings.sections.models' })).toBeTruthy();
+ expect(screen.getByRole('link', { name: 'settings.sections.models' })).toBeTruthy();
+ });
+
+ it('keeps Models on the rail before config resolves and while Model Hub is disabled', async () => {
+ let resolveConfig: ((config: unknown) => void) | undefined;
+ api.getConfig.mockImplementation(
+ () => new Promise((resolve) => {
+ resolveConfig = resolve;
+ }),
+ );
+ renderLayout('/settings/replies');
+
+ expect(screen.getByRole('link', { name: 'settings.sections.models' })).toBeTruthy();
+ expect(resolveConfig).toBeTypeOf('function');
+
+ await act(async () => {
+ resolveConfig?.({ capabilities: { model_hub: { enabled: false } } });
});
+ expect(screen.getByRole('link', { name: 'settings.sections.models' })).toBeTruthy();
});
// AUTH-SETUP-125: Settings opened over the wizard offers only the sections the
// setup visit keeps, so no row leads out of the setup and loses its step.
- it('offers only the setup visit sections over the wizard', async () => {
+ it('offers only the setup visit sections over the wizard', () => {
const setup: Location = { pathname: '/setup', search: '', hash: '', state: null, key: 'setup' };
renderLayout(
{ pathname: '/settings/general', state: settingsOverlayOpenState(setup, null) },
@@ -317,11 +336,28 @@ describe('SettingsLayout', () => {
expect(screen.getByText('general-body')).toBeTruthy();
expect(screen.getByRole('link', { name: 'settings.sections.general' })).toBeTruthy();
- await waitFor(() => {
- expect(screen.getByRole('link', { name: 'settings.sections.models' })).toBeTruthy();
- });
+ expect(screen.getByRole('link', { name: 'settings.sections.models' })).toBeTruthy();
+ const rail = screen.getByRole('navigation', { name: 'settings.navigationLabel' });
+ expect(rail.querySelectorAll('a[href^="/settings/"]')).toHaveLength(2);
+ expect(screen.queryByRole('link', { name: 'settings.sections.replies' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'nav.messagingPlatforms' })).toBeNull();
+ });
+
+ it('keeps a disabled Model Hub inside the setup overlay instead of leaving for Backends', async () => {
+ const setup: Location = { pathname: '/setup', search: '', hash: '', state: null, key: 'setup' };
+ api.getConfig.mockResolvedValue({ capabilities: { model_hub: { enabled: false } } });
+ renderLayout(
+ { pathname: '/settings/models', state: settingsOverlayOpenState(setup, null) },
+ { shellHasSidebar: false, gateModelHub: true },
+ );
+
+ expect(await screen.findByText('general-body')).toBeTruthy();
+ expect(screen.queryByText('backends-body')).toBeNull();
+ expect(screen.queryByText('models-body')).toBeNull();
const rail = screen.getByRole('navigation', { name: 'settings.navigationLabel' });
expect(rail.querySelectorAll('a[href^="/settings/"]')).toHaveLength(2);
+ expect(screen.getByRole('link', { name: 'settings.sections.models' })).toBeTruthy();
+ expect(screen.getByRole('link', { name: 'settings.sections.general' })).toBeTruthy();
expect(screen.queryByRole('link', { name: 'settings.sections.replies' })).toBeNull();
expect(screen.queryByRole('button', { name: 'nav.messagingPlatforms' })).toBeNull();
});
diff --git a/ui/src/components/settings/SettingsLayout.tsx b/ui/src/components/settings/SettingsLayout.tsx
index 78cc7d0dd..40b148aa1 100644
--- a/ui/src/components/settings/SettingsLayout.tsx
+++ b/ui/src/components/settings/SettingsLayout.tsx
@@ -41,14 +41,13 @@ import {
import { useStandaloneSettingsMenu } from '@/lib/settingsMenuPlacement';
import { AccountMenu } from '../AccountMenu';
import { VersionBadge } from '../VersionBadge';
-import { modelHubEnabledFromConfig } from './models/featureFlags';
type SettingsItem = {
path: string;
labelKey: TranslationKey;
icon: React.ComponentType<{ className?: string }>;
ownerOnly?: boolean;
- feature?: 'models' | 'channels';
+ feature?: 'channels';
children?: SettingsItem[];
defaultOpen?: boolean;
exact?: boolean;
@@ -70,7 +69,7 @@ const SETTINGS_GROUPS: SettingsGroup[] = [
labelKey: 'settings.groups.agents',
items: [
{ path: '/settings/backends', labelKey: 'settings.sections.backends', icon: Server, ownerOnly: true },
- { path: '/settings/models', labelKey: 'settings.sections.models', icon: Cpu, ownerOnly: true, feature: 'models' },
+ { path: '/settings/models', labelKey: 'settings.sections.models', icon: Cpu, ownerOnly: true },
{ path: '/settings/replies', labelKey: 'settings.sections.replies', icon: MessageSquare },
],
},
@@ -246,7 +245,6 @@ export const SettingsLayout: React.FC = () => {
const setupOriginPath = useSettingsOverlayContext()?.location.pathname;
const setupOrigin = setupOriginPath !== undefined && isChromelessShellPath(setupOriginPath);
const standaloneMenu = useStandaloneSettingsMenu();
- const [modelHubVisible, setModelHubVisible] = useState(false);
const [channelSettingsVisible, setChannelSettingsVisible] = useState(false);
const atRoot = location.pathname === '/settings' || location.pathname === '/settings/';
const isModelHub = pathMatches(location.pathname, '/settings/models');
@@ -260,7 +258,6 @@ export const SettingsLayout: React.FC = () => {
let cancelled = false;
let configVersion = 0;
const applyConfigVisibility = (config: unknown) => {
- setModelHubVisible(modelHubEnabledFromConfig(config));
setChannelSettingsVisible(
getEnabledPlatforms(config).some((platform) => platformSupportsChannels(config, platform)),
);
@@ -277,7 +274,6 @@ export const SettingsLayout: React.FC = () => {
})
.catch(() => {
if (!cancelled && requestedConfigVersion === configVersion) {
- setModelHubVisible(false);
setChannelSettingsVisible(false);
}
});
@@ -295,7 +291,6 @@ 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.feature === 'models' && !modelHubVisible) return [];
return [{
...item,
children: item.children?.filter((child) =>
@@ -303,7 +298,7 @@ export const SettingsLayout: React.FC = () => {
}];
}),
})).filter((group) => group.items.length > 0),
- [capabilities.can_manage_instance, channelSettingsVisible, modelHubVisible, setupOrigin],
+ [capabilities.can_manage_instance, channelSettingsVisible, setupOrigin],
);
const activeTrail = (() => {
@@ -347,10 +342,9 @@ export const SettingsLayout: React.FC = () => {
// it, which is the row the rail can show as current.
//
// Where the person actually is, is the whole input. A feature-gated row
- // (Models, Channels) can leave the rail while its page stays routed.
- // Nothing here consults the feature projections the rail draws
- // rows from, so a pending or failed read can neither erase a preference nor
- // record the wrong one.
+ // (Channels) can leave the rail while its page stays routed. Nothing here
+ // consults the feature projections the rail draws rows from, so a pending or
+ // failed read can neither erase a preference nor record the wrong one.
useEffect(() => {
const section = activeTrail.at(-1);
if (section) writeLastSettingsSection(section.path);
diff --git a/ui/src/components/settings/models/ModelHubCapabilityGate.test.tsx b/ui/src/components/settings/models/ModelHubCapabilityGate.test.tsx
index fbbd73b24..0c9369f87 100644
--- a/ui/src/components/settings/models/ModelHubCapabilityGate.test.tsx
+++ b/ui/src/components/settings/models/ModelHubCapabilityGate.test.tsx
@@ -11,6 +11,8 @@ import {
describe('Model Hub capability route gate', () => {
it('redirects the canonical model route while disabled', () => {
expect(modelHubRouteTarget(MODEL_HUB_SETTINGS_PATH, false)).toBe(MODEL_HUB_DISABLED_REDIRECT);
+ expect(modelHubRouteTarget(MODEL_HUB_SETTINGS_PATH, false, true)).toBe('/settings/general');
+ expect(modelHubRouteTarget(MODEL_HUB_SETTINGS_PATH, true, true)).toBe(MODEL_HUB_SETTINGS_PATH);
});
it('does not render the Models child while disabled or unresolved', () => {
diff --git a/ui/src/components/settings/models/ModelHubCapabilityGate.tsx b/ui/src/components/settings/models/ModelHubCapabilityGate.tsx
index e7f1ea43f..5c67acc5a 100644
--- a/ui/src/components/settings/models/ModelHubCapabilityGate.tsx
+++ b/ui/src/components/settings/models/ModelHubCapabilityGate.tsx
@@ -1,8 +1,9 @@
import * as React from 'react';
-import { Navigate } from 'react-router-dom';
+import { Navigate, useLocation } from 'react-router-dom';
+import { isChromelessShellPath, settingsOverlayOriginFromState } from '@/lib/settingsOverlay';
import { useModelHubCapability } from './useModelHubCapability';
-import { MODEL_HUB_DISABLED_REDIRECT } from './modelHubRoutes';
+import { modelHubDisabledRedirect } from './modelHubRoutes';
export const ModelHubRenderBoundary: React.FC<{
enabled: boolean | null;
@@ -15,10 +16,14 @@ export const ModelHubRenderBoundary: React.FC<{
export const ModelHubCapabilityGate: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const enabled = useModelHubCapability();
+ const location = useLocation();
+ const overSetup = isChromelessShellPath(
+ settingsOverlayOriginFromState(location.state)?.location.pathname ?? '',
+ );
return (
<ModelHubRenderBoundary
enabled={enabled}
- disabled={<Navigate to={MODEL_HUB_DISABLED_REDIRECT} replace />}
+ disabled={<Navigate to={modelHubDisabledRedirect(overSetup)} replace state={location.state} />}
>
{children}
</ModelHubRenderBoundary>
diff --git a/ui/src/components/settings/models/modelHubRoutes.ts b/ui/src/components/settings/models/modelHubRoutes.ts
index d6d041552..582b23a7f 100644
--- a/ui/src/components/settings/models/modelHubRoutes.ts
+++ b/ui/src/components/settings/models/modelHubRoutes.ts
@@ -1,11 +1,19 @@
// Where a Model Hub route lands, by capability. Pure so the redirect contract can be
// asserted without mounting the router (see ModelHubCapabilityGate.test.tsx).
+import { SETTINGS_LANDING_PATH } from '@/lib/adminNavigation';
+
export const MODEL_HUB_SETTINGS_PATH = '/settings/models';
export const MODEL_HUB_DISABLED_REDIRECT = '/settings/backends';
-export const modelHubRouteTarget = (requestedPath: string, enabled: boolean): string =>
- enabled ? requestedPath : MODEL_HUB_DISABLED_REDIRECT;
+export const modelHubDisabledRedirect = (overSetup: boolean): string =>
+ overSetup ? SETTINGS_LANDING_PATH : MODEL_HUB_DISABLED_REDIRECT;
+
+export const modelHubRouteTarget = (
+ requestedPath: string,
+ enabled: boolean,
+ overSetup = false,
+): string => enabled ? requestedPath : modelHubDisabledRedirect(overSetup);
// Opens the Model Hub with one backend's model catalog dialog in front, so a
// model picker can send the user straight to where its list is edited.