From a38005afd1d1bf320b666be575d81357e3466763 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 13:40:01 +0000 Subject: [PATCH 1/2] fix(console): read in-use from the live source, so a host's own mail transport ticks the checklist The console's isMailDelivering and aiProviderState now read { value: null, source: 'environment' } as in use, as the settings contract states it: in-use is read from source, never from a null value. Claude-Session: https://claude.ai/code/session_012MmDsS4GoHCgYwA2uv3n3C Co-authored-by: Claude --- .../src/pages/settings/FirstRunChecklist.tsx | 6 +- .../__tests__/FirstRunChecklist.test.tsx | 28 ++++++++- .../__tests__/firstRunChecklistLogic.test.ts | 58 +++++++++++++++++++ .../pages/settings/firstRunChecklistLogic.ts | 57 ++++++++++++------ ui/apps/console/src/pages/settings/types.ts | 10 +++- 5 files changed, 135 insertions(+), 24 deletions(-) diff --git a/ui/apps/console/src/pages/settings/FirstRunChecklist.tsx b/ui/apps/console/src/pages/settings/FirstRunChecklist.tsx index 0daa27a550a..0d56897ebb8 100644 --- a/ui/apps/console/src/pages/settings/FirstRunChecklist.tsx +++ b/ui/apps/console/src/pages/settings/FirstRunChecklist.tsx @@ -762,7 +762,11 @@ export function FirstRunChecklist({ placement = 'top' }: { placement?: FirstRunC !ai.done ? t('console.firstRunChecklist.aiProvider.todo') : ai.source === 'environment' - ? t('console.firstRunChecklist.aiProvider.doneEnvironment', { provider }) + ? provider + ? t('console.firstRunChecklist.aiProvider.doneEnvironment', { provider }) + : // In use, handed over by the host, and named by no option: + // there is no provider name to put in the sentence. + t('console.settingsView.aiProviderManaged') : t('console.firstRunChecklist.aiProvider.doneSettings', { provider }) } action={ diff --git a/ui/apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx b/ui/apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx index f8e1b594011..eaab9234ed4 100644 --- a/ui/apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx +++ b/ui/apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx @@ -149,6 +149,8 @@ function freshLocalization(): Record> { let localizationValues = freshLocalization(); let mailValues: Record> = { provider: resolved('smtp') }; +// The mail page's `live` statement, when the test serves one. +let mailLive: Record | null = null; let putRefusal: unknown = null; // Manifests listed beside localization and mail (the `ai` one, for the built-in AI row), and the `ai` page. let extraManifests: unknown[] = []; @@ -169,7 +171,9 @@ function routeFetch() { if (url === '/api/settings/localization' && method === 'GET') { return ok({ manifest: LOCALIZATION_MANIFEST, values: localizationValues }); } - if (url === '/api/settings/mail' && method === 'GET') return ok({ manifest: MAIL_MANIFEST, values: mailValues }); + if (url === '/api/settings/mail' && method === 'GET') { + return ok({ manifest: MAIL_MANIFEST, values: mailValues, ...(mailLive ? { live: mailLive } : {}) }); + } if (url === '/api/settings/localization' && method === 'PUT') { if (putRefusal) { return { ok: false, status: 400, statusText: 'Bad Request', json: async () => putRefusal } as unknown as Response; @@ -246,6 +250,7 @@ beforeEach(() => { localStorage.clear(); localizationValues = freshLocalization(); mailValues = { provider: resolved('smtp') }; + mailLive = null; putRefusal = null; extraManifests = []; aiPayload = null; @@ -686,6 +691,16 @@ describe('the built-in AI: the provider the server runs, from live.provider (obj expect(within(r).getByText('DeepSeek (OpenAI-compatible), detected from the server environment.')).toBeTruthy(); }); + it('handed over by the host and named by no option (environment, null): done, and says the platform manages it (objectstack#34749)', async () => { + serveAi({ value: null, source: 'environment' }, null); + renderChecklist(ADMIN); + await showDone(); + const r = await screen.findByTestId('first-run-checklist-row-ai_provider'); + expect(r.getAttribute('data-done')).toBe('true'); + expect(within(r).getByText('The AI provider, its model and credentials are managed by the platform.')).toBeTruthy(); + expect(within(r).queryByText(/detected from the server environment/)).toBeNull(); + }); + it('a saved provider the running system does not use is not done: live decides, not values', async () => { serveAi({ value: null, source: 'none' }, 'openai'); renderChecklist(ADMIN); @@ -1018,6 +1033,17 @@ describe('the host profile: a managed environment adds the first-app and first-r expect(row('mail').getAttribute('data-done')).toBe('true'); }); + it("managed, the host's own transport (live provider environment, null) with nothing saved: mail is drawn, done (objectstack#34749)", async () => { + MANAGED(); + mailLive = { provider: { value: null, source: 'environment' } }; + SHELL.apps = [SETUP_APP]; + activityAdapter([]); + renderChecklist(ADMIN); + await screen.findByTestId('first-run-checklist-row-first_record'); + await showDone(); + expect(row('mail').getAttribute('data-done')).toBe('true'); + }); + it('managed, every required row done and no record yet: the checklist draws nothing', async () => { MANAGED(); localizationValues = { diff --git a/ui/apps/console/src/pages/settings/__tests__/firstRunChecklistLogic.test.ts b/ui/apps/console/src/pages/settings/__tests__/firstRunChecklistLogic.test.ts index dff660f10f4..969a1ae51da 100644 --- a/ui/apps/console/src/pages/settings/__tests__/firstRunChecklistLogic.test.ts +++ b/ui/apps/console/src/pages/settings/__tests__/firstRunChecklistLogic.test.ts @@ -10,6 +10,7 @@ import { describe, it, expect } from 'vitest'; import { DEFAULT_ORGANIZATION_NAME, + aiProviderState, browserRegion, checklistCompletion, dismissRecordKey, @@ -243,3 +244,60 @@ describe('completion counts the required rows; email delivery is optional (objec expect(checklistCompletion([{ id: 'connect_assistant', done: false }]).complete).toBe(false); }); }); + +describe('in use is read from the stated source, never from a null value (objectstack#34749)', () => { + // A host's own transport, which no option names, is stated `{ value: null, source: 'environment' }`. + const HOST_OWN = { value: null, source: 'environment' } as const; + const SAVED = { provider: fromTenant('smtp'), from_email: fromTenant('a@b.co'), smtp_host: fromTenant('mx') }; + + it('mail: environment with a null value delivers; none does not; settings with an empty value does not', () => { + expect(isMailDelivering({ values: {}, live: { provider: HOST_OWN } })).toBe(true); + expect(isMailDelivering({ values: {}, live: { provider: { value: null, source: 'none' } } })).toBe(false); + expect(isMailDelivering({ values: SAVED, live: { provider: { value: '', source: 'settings' } } })).toBe(false); + }); + + it('mail: saved values that would pass, under a host-own transport, read done from the statement', () => { + expect(isMailConfigured(SAVED)).toBe(true); + expect(isMailDelivering({ values: SAVED, live: { provider: HOST_OWN } })).toBe(true); + // The statement decides, not the saved values: the same host-own statement over nothing that would pass. + expect(isMailDelivering({ values: { provider: fromTenant('log') }, live: { provider: HOST_OWN } })).toBe(true); + }); + + it('CONTROL mail: a payload without the statement still falls back to the saved values', () => { + expect(isMailDelivering({ values: SAVED })).toBe(true); + expect(isMailDelivering({ values: {} })).toBe(false); + }); + + const AI_MANIFEST = { + namespace: 'ai', + label: 'AI', + scope: 'global', + writePermission: 'manage_platform_settings', + specifiers: [{ type: 'select', key: 'provider', label: 'Provider', options: [{ value: 'openai', label: 'OpenAI' }] }], + } as unknown as SettingsManifest; + + it('ai: environment with a null value is done, its source kept, with no option to name it by', () => { + expect(aiProviderState({ manifest: AI_MANIFEST, live: { provider: HOST_OWN } })).toEqual({ + done: true, + value: null, + source: 'environment', + }); + }); + + it('ai: none is not done', () => { + expect(aiProviderState({ manifest: AI_MANIFEST, live: { provider: { value: null, source: 'none' } } })).toEqual({ + done: false, + value: null, + source: 'none', + }); + }); + + it('CONTROL ai: a provider named by an option keeps its value, source and label', () => { + expect(aiProviderState({ manifest: AI_MANIFEST, live: { provider: { value: 'openai', source: 'environment' } } })).toEqual({ + done: true, + value: 'openai', + source: 'environment', + optionLabel: 'OpenAI', + }); + }); +}); diff --git a/ui/apps/console/src/pages/settings/firstRunChecklistLogic.ts b/ui/apps/console/src/pages/settings/firstRunChecklistLogic.ts index ae4b5651a0b..b179599c3f1 100644 --- a/ui/apps/console/src/pages/settings/firstRunChecklistLogic.ts +++ b/ui/apps/console/src/pages/settings/firstRunChecklistLogic.ts @@ -498,27 +498,40 @@ export function isMailConfigured(values: Record): return true; } +/** + * Is the stated live value one in use? Read from `source`, never from a `null` + * value ({@link SettingsLiveValue}): `'none'` is nothing in use; `'settings'` + * is in use and always names an option; `'environment'` is in use, naming an + * option or, with `value: null`, a provider the host hands over that no option + * names (a hosting platform's own mail transport). `undefined` when the entry + * is no statement the server serves, so the caller decides as if unstated. + */ +function liveValueInUse(stated: SettingsLiveValue | undefined): boolean | undefined { + if (!stated || typeof stated !== 'object') return undefined; + const { value, source } = stated; + if (source === 'none') return false; + if (source === 'environment' && value === null) return true; + if (source === 'settings' || source === 'environment') return typeof value === 'string' && value !== ''; + return undefined; +} + /** * The mail row from the `mail` namespace's payload: done when the running * system delivers mail. * * The server's statement (`live.provider` of `GET /api/settings/mail`) decides - * first: a provider in use, taken from the settings or from the deployment's - * own boot environment, is done; `source: 'none'` (the development log, which - * delivers nothing) is not done, whatever was saved. Mail set up through the - * environment saves nothing, so the saved values alone would keep that row not - * done for good. A payload without the statement (a server older than it, or - * one that cannot state the provider) falls back to the saved values - * ({@link isMailConfigured}), never to "not set". + * first, read from its `source` ({@link liveValueInUse}): a provider in use, + * taken from the settings or from the deployment's own boot environment or + * host (a host's own transport is stated with a `null` value), is done; + * `source: 'none'` (the development log, which delivers nothing) is not done, + * whatever was saved. Mail set up through the environment saves nothing, so + * the saved values alone would keep that row not done for good. A payload + * without the statement (a server older than it, or one that cannot state the + * provider) falls back to the saved values ({@link isMailConfigured}), never + * to "not set". */ export function isMailDelivering(payload: Pick): boolean { - const stated = payload.live?.[MAIL_PROVIDER_KEY]; - if (stated && typeof stated === 'object') { - const { value, source } = stated; - if (source === 'none') return false; - if (source === 'settings' || source === 'environment') return typeof value === 'string' && value !== ''; - } - return isMailConfigured(payload.values); + return liveValueInUse(payload.live?.[MAIL_PROVIDER_KEY]) ?? isMailConfigured(payload.values); } /** Has the organization been given a name of its own? */ @@ -545,9 +558,12 @@ export function hasInvitedColleagues( * names it. */ export interface AiProviderState { - /** A provider is in use: the stated value is one, from the settings or the boot environment. */ + /** A provider is in use, read from the stated `source`: from the settings, or from the boot environment or host. */ done: boolean; - /** The stated value, or `null` when none is in use. */ + /** + * The stated value: `null` when none is in use, or when the provider in use + * comes from the environment and no option names it. + */ value: string | null; /** Where the running system took it from. */ source: SettingsLiveValue['source']; @@ -568,10 +584,13 @@ export interface AiProviderState { export function aiProviderState(payload: Pick): AiProviderState | undefined { const stated = payload.live?.[AI_PROVIDER_KEY]; if (!stated || typeof stated !== 'object') return undefined; - const { value, source } = stated; - if (source !== 'settings' && source !== 'environment' && source !== 'none') return undefined; - const inUse = source !== 'none' && typeof value === 'string' && value !== ''; + const inUse = liveValueInUse(stated); + if (inUse === undefined) return undefined; if (!inUse) return { done: false, value: null, source: 'none' }; + const { value, source } = stated; + // In use from the environment, named by no option: done, the stated source + // kept, and no option to name it by. + if (value === null) return { done: true, value: null, source }; const spec = payload.manifest.specifiers.find((s) => s.key === AI_PROVIDER_KEY); const option = (spec?.options ?? []).find((o) => String(o.value) === value); const label = option ? resolveLabel(option.label) : undefined; diff --git a/ui/apps/console/src/pages/settings/types.ts b/ui/apps/console/src/pages/settings/types.ts index e3cbaef648f..9ac7dfd6f42 100644 --- a/ui/apps/console/src/pages/settings/types.ts +++ b/ui/apps/console/src/pages/settings/types.ts @@ -176,9 +176,13 @@ export interface ResolvedSettingValue { /** * One key's value in the RUNNING system, as the namespace's owner states it - * (service-settings `SettingsLiveValue`). `value` is one of the key's options, - * `null` exactly when `source` is `'none'`; `'environment'` means the runtime - * detected it from its own boot environment, outside the namespace. + * (service-settings `SettingsLiveValue`). `value` is one of the key's options; + * `null` when `source` is `'none'`, or when `source` is `'environment'` and no + * option names what is in use (a transport the host hands over). Whether + * something is in use is read from `source`, never from a `null` value. + * `'settings'` always names an option; `'environment'` means the runtime + * detected it from its own boot environment, or its host handed it over, + * outside the namespace. */ export interface SettingsLiveValue { value: string | null; From 772eafd4f2a87d0b6642867a3078c8a5792b438a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 13:42:50 +0000 Subject: [PATCH 2/2] chore(changeset): console patch for the host-own mail transport reading Claude-Session: https://claude.ai/code/session_012MmDsS4GoHCgYwA2uv3n3C Co-authored-by: Claude --- .changeset/34749-mail-delivering-environment.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .changeset/34749-mail-delivering-environment.md diff --git a/.changeset/34749-mail-delivering-environment.md b/.changeset/34749-mail-delivering-environment.md new file mode 100644 index 00000000000..e57737f9311 --- /dev/null +++ b/.changeset/34749-mail-delivering-environment.md @@ -0,0 +1,12 @@ +--- +'@object-ui/console': patch +--- + +fix(console): the setup checklist reads a host's own mail transport as delivering + +Clause-②: no +Metadata-protocol: none + +`GET /api/settings/mail` states a transport that the host hands over, which no provider option names, as `live.provider = { value: null, source: 'environment' }`. The settings contract says in-use is read from `source`, never from a `null` value. The first-run checklist still required a non-empty `value`, so on a hosted environment its Email delivery row stayed not done while mail was being delivered. This included a deployment whose saved mail values would pass on their own. + +The checklist now reads in-use from `source`. `environment` with a `null` value is in use, `none` is not, and a page without the statement still falls back to the saved mail values. The built-in AI row follows the same rule. If the server ever states its provider as `environment` with a `null` value, the row is done, keeps the `environment` source and says the platform manages the provider, because there is no option name to show.