Skip to content

Commit 2e4e6f0

Browse files
committed
fix(console): show the platform-managed state on hosted storage and AI provider settings
Claude-Session: https://claude.ai/code/session_01ADHkmSWkWcHBfKEZ8RmTrv Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5a75579 commit 2e4e6f0

17 files changed

Lines changed: 536 additions & 10 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@object-ui/console': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
fix(console): on a cloud-managed environment, Setup's File storage page and the AI provider part of the AI page say the platform manages them
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
A direct route (a bookmark or a typed URL) to Setup → File storage on a cloud-managed environment used to draw the generic load error, because the server refuses that namespace there. The console now reads that refusal by its declared shape (`409 RESOURCE_CONFLICT` with `error.details.managedBy: 'platform'`) and draws "Managed by the platform" with no form and no retry. A `409` without `managedBy: 'platform'` keeps the error card.
12+
13+
The AI page is served without its provider, model and credential keys on a cloud-managed environment. When the served auth config says the environment is cloud-managed (`features.cloudManaged`) and the served page carries no `provider` key, the page draws one line saying the platform manages the AI provider; the conversation-title and observability settings stay editable. A save or an action the server refuses as platform-managed (a page loaded earlier) toasts the same managed text instead of the server's sentence.
14+
15+
Self-hosted environments are unchanged. Three new keys under `console.settingsView` in every `@object-ui/i18n` pack: `platformManagedTitle`, `platformManagedBody`, `aiProviderManaged`.

‎ui/apps/console/src/pages/settings/SettingsView.tsx‎

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import { useEffect, useMemo, useRef, useState } from 'react';
1212
import { useParams, useNavigate } from 'react-router-dom';
1313
import { toast } from 'sonner';
1414
import { ConsolePageHeader } from '@object-ui/app-shell';
15-
import { Loader2, ArrowLeft, ChevronRight, RotateCcw, ShieldAlert } from 'lucide-react';
15+
import { Loader2, ArrowLeft, ChevronRight, RotateCcw, ShieldAlert, Cloud } from 'lucide-react';
1616
import { Button, Card, CardContent, Skeleton, Badge, getLazyIcon } from '@object-ui/components';
1717
import { ExpressionEvaluator } from '@object-ui/core';
1818
import { useObjectTranslation } from '@object-ui/i18n';
19+
import { useAuth } from '@object-ui/auth';
1920
import { SettingsField } from './SettingsField';
2021
import type { MapRefusalAt } from './SettingsMapField';
2122
import { fieldWording, settingsFieldRefusals } from './settingsFieldRefusals';
@@ -28,6 +29,7 @@ import {
2829
type JudgedClientAddress,
2930
type JudgedClientAddressRoute,
3031
} from './api';
32+
import { AI_PROVIDER_NAMESPACE, aiProviderManagedByPlatform, isPlatformManagedRefusal } from './platformManaged';
3133
import { resolveLabel, type SettingsNamespacePayload, type Specifier } from './types';
3234
import { useSettingsLabel, type SettingsLabelHelpers } from './useSettingsLabel';
3335
import { useUnsavedLeaveGuard } from './useUnsavedLeaveGuard';
@@ -371,7 +373,12 @@ export function SettingsView() {
371373
* when it sent one; without one the card shows `console.settingsView.loadError`,
372374
* translated at render so the fetch below reads no `t` (objectui#13254).
373375
*/
374-
const [error, setError] = useState<{ message?: string } | null>(null);
376+
/**
377+
* The load's failure, or null. `managed` marks the hosted refusal
378+
* (`platformManaged.ts`): the platform provides this page's settings, so the
379+
* page says so instead of drawing an error or a form.
380+
*/
381+
const [error, setError] = useState<{ message?: string; managed?: boolean } | null>(null);
375382
/** Live edit map keyed by spec.key. Falls back to resolved value when undefined. */
376383
const [draft, setDraft] = useState<Record<string, unknown>>({});
377384
/**
@@ -448,14 +455,47 @@ export function SettingsView() {
448455
setFieldErrors({});
449456
setCryptoRefusal(null);
450457
} catch (err: any) {
451-
setError({ message: err?.message });
458+
setError(
459+
isPlatformManagedRefusal(err?.status, err?.payload)
460+
? { managed: true }
461+
: { message: err?.message },
462+
);
452463
} finally {
453464
setLoading(false);
454465
}
455466
};
456467
void loadNamespace();
457468
}, [namespace]);
458469

470+
/**
471+
* The served auth config's `features`, read once per page that can use them:
472+
* the AI page draws one line when the platform manages its provider
473+
* ({@link aiProviderManagedByPlatform}). The auth client holds the config
474+
* sign-in already read, so this asks no new request. The read goes through a
475+
* ref so the effect keys on the namespace alone (AGENTS.md #10).
476+
*/
477+
const { getAuthConfig } = useAuth();
478+
const getAuthConfigRef = useRef(getAuthConfig);
479+
useEffect(() => {
480+
getAuthConfigRef.current = getAuthConfig;
481+
});
482+
const [authFeatures, setAuthFeatures] = useState<{ cloudManaged?: unknown } | null>(null);
483+
const readsAuthFeatures = namespace === AI_PROVIDER_NAMESPACE;
484+
useEffect(() => {
485+
if (!readsAuthFeatures) return;
486+
let live = true;
487+
Promise.resolve(getAuthConfigRef.current?.())
488+
.then((config) => {
489+
if (live) setAuthFeatures(config?.features ?? null);
490+
})
491+
.catch(() => {
492+
// Unreadable: no line, the page is what it serves.
493+
});
494+
return () => {
495+
live = false;
496+
};
497+
}, [readsAuthFeatures]);
498+
459499
/**
460500
* The caller's address as the server judges it, on a page that draws it
461501
* ({@link CLIENT_ADDRESS_ROUTES}), or null: another page, not read yet, or
@@ -529,6 +569,24 @@ export function SettingsView() {
529569
);
530570
}
531571

572+
if (error?.managed) {
573+
// No form and no retry: nothing here is the administrator's to set.
574+
return (
575+
<div className="p-6 max-w-3xl">
576+
<Button variant="ghost" size="sm" onClick={() => navigate(-1)}>
577+
<ArrowLeft className="h-4 w-4 mr-1" /> {t('console.settingsView.back')}
578+
</Button>
579+
<Card className="mt-3" data-testid="settings-platform-managed">
580+
<CardContent className="py-8 text-center text-sm">
581+
<Cloud className="h-6 w-6 mx-auto mb-2 text-muted-foreground" aria-hidden="true" />
582+
<p className="font-medium">{t('console.settingsView.platformManagedTitle')}</p>
583+
<p className="mt-1 text-muted-foreground">{t('console.settingsView.platformManagedBody')}</p>
584+
</CardContent>
585+
</Card>
586+
</div>
587+
);
588+
}
589+
532590
if (error) {
533591
return (
534592
<div className="p-6 max-w-3xl">
@@ -550,6 +608,7 @@ export function SettingsView() {
550608
const Icon = manifest.icon ? getLazyIcon(manifest.icon) : null;
551609
const title = labels.title(resolveLabel(manifest.label));
552610
const description = labels.description(manifest.description);
611+
const aiProviderManaged = aiProviderManagedByPlatform(namespace, manifest.specifiers, authFeatures);
553612

554613
/**
555614
* Read the namespace again after a successful save or action and take the
@@ -650,6 +709,10 @@ export function SettingsView() {
650709
? t('console.settingsView.cryptoRefusalToast', { subject: refusal.subject })
651710
: t('console.settingsView.cryptoRefusalToastNoSubject'),
652711
);
712+
} else if (isPlatformManagedRefusal(err?.status, err?.payload)) {
713+
// A page read before the environment became hosted wrote a key the
714+
// platform now manages: nothing was written.
715+
toast.error(t('console.settingsView.platformManagedTitle'));
653716
} else {
654717
// Per-field rejections render against the inputs that caused them
655718
// (objectstack#4224). `extractFieldErrors` reads `details.fields`, so it
@@ -731,7 +794,11 @@ export function SettingsView() {
731794
toast.error(result.message ?? t('console.settingsView.actionFailed'));
732795
}
733796
} catch (err: any) {
734-
toast.error(err?.message ?? t('console.settingsView.actionFailed'));
797+
toast.error(
798+
isPlatformManagedRefusal(err?.status, err?.payload)
799+
? t('console.settingsView.platformManagedTitle')
800+
: (err?.message ?? t('console.settingsView.actionFailed')),
801+
);
735802
} finally {
736803
setSaving(false);
737804
}
@@ -790,6 +857,17 @@ export function SettingsView() {
790857
<p className="text-sm text-muted-foreground whitespace-pre-wrap">{manifest.helpText}</p>
791858
) : null}
792859

860+
{aiProviderManaged ? (
861+
<Card className="mt-4" data-testid="settings-ai-provider-managed">
862+
<CardContent className="py-3">
863+
<p className="flex items-center gap-2 text-sm text-muted-foreground">
864+
<Cloud className="h-4 w-4 shrink-0" aria-hidden="true" />
865+
{t('console.settingsView.aiProviderManaged')}
866+
</p>
867+
</CardContent>
868+
</Card>
869+
) : null}
870+
793871
{cryptoRefusal ? (
794872
<Card className="mt-4 border-destructive/50 bg-destructive/5">
795873
<CardContent className="py-4">

0 commit comments

Comments
 (0)