Skip to content

Commit a127a45

Browse files
feat(console): the first-run checklist shows the built-in AI provider and folds done rows; every not-found page has a way back (#32728)
Part of #32021 Fixes #32157 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 改了什么:首次使用清单新增一行「设置内置 AI」,读取服务端实际在用的 AI 服务商(`GET /api/settings/ai` 的 `live.provider`);清单里已完成的项默认折叠,只留待办;四种「找不到」页面(对象、网址、记录、应用)共用一个组件,每种都有返回路径(返回列表 / 返回首页)。 - 为什么改:新装私有部署的管理员最先想用内置 AI,清单里却没有这一步;清单占满手机首屏且已完成项占位置;有两种「找不到」页面是死胡同。 - 风险与回滚:只动控制台 UI 与语言包(只增键);服务端未声明 `live` 时不画 AI 这一行,旧服务端行为不变。回滚即还原本 PR。 - 先看:`ui/apps/console/src/pages/settings/firstRunChecklistLogic.ts`(`aiProviderState`:只读 `live`,不读 `values`)、`ui/packages/app-shell/src/components/NotFoundState.tsx`(`BackToHomeButton` 的首页解析)、`ui/apps/console/src/pages/settings/FirstRunChecklist.tsx`(折叠控件)。 - 两分钟验证:`pnpm --dir ui exec vitest run apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx packages/app-shell/src/components/__tests__/NotFoundState.test.tsx`,预期全部通过。 - 需要你做的:无,席位落地。 ## What changes **#32021 item 4: the built-in AI on the first-run checklist.** A new row, "Set up the built-in AI", is read from `live.provider` of `GET /api/settings/ai`, which landed in #32057. It never reads `values.provider`, because that only says what was saved, and the runtime can detect a provider from its boot environment while nothing is saved. A provider in use makes the row done. The row names the provider by its option label and says where it came from: "set in Setup", or "detected from the server environment". With `source: 'none'` the row is not done and links to Setup → AI & Embedder. A server that does not state the provider gets no row, because unknown is not unset. Only a session that may write `ai` reads it. The external assistant row keeps the wording from PR #32050, and its Home claim is unaffected. Item 4 was the last open item on #32021: once this merges, the card can close. The values arrive once the AI runtime fills `registerLiveStatus('ai')`. That runtime is cloud service-ai, and the carry is recorded on #32052. On this repository alone `live` is absent, so the row stays out, as designed. **#32157: Home crowding.** Rows that are done are folded away. The list draws the rows still to do. One control under them ("Show completed (N)" / "Hide completed", with `aria-expanded` and `aria-controls`) unfolds the done rows in their place. Every visit starts folded. The progress count is unchanged. **#32157: not-found states.** Unknown object, unmatched URL, unknown record and unknown app now draw through one `NotFoundState`. Each keeps its own title and cause sentence and offers its own way back first, then "Back to home": - unknown object: "Back to home" only (before: no way out); - unmatched URL: "Go back" and "Back to home"; - unknown record: "Back to OBJECT-LIST", a link to the object's list, then "Back to home" (before: no way out); - unknown app: "Retry" and "Back to home". The app-access-denied screen uses the same button. `BackToHomeButton` resolves Home with `useHomePath()`'s policy (`resolveDeclaredHomePath`, else the launcher) against `@object-ui/react`'s metadata context. Screens that already hold `useHomePath()` pass it as `to`, as every AppContent screen does. It does not import `useHomePath` itself, because that module loads the console metadata provider and the metadata client factory into every view that draws a not-found state. That import broke 18 RecordDetailView harnesses at collection. New `@object-ui/i18n` keys in all 11 packs (zh-Hant regenerated with `gen:zh-hant`): `console.firstRunChecklist.aiProvider.{title,todo,doneSettings,doneEnvironment,action}`, `console.firstRunChecklist.{showDone,hideDone}`, `empty.backToList`. No key is removed or renamed. ## Tests Final head `4b7db52a3`: - Consumer sweep: every test file in `packages/app-shell/src` and `apps/console/src` that reaches `RecordDetailView`, `objectViewChrome`, `ObjectView`, `NotFoundState` or `AppContent`, plus the checklist and i18n parity tests. 312 files, 2813 tests passed, in 4 chunks under the shared lock. - Type-checks: `@object-ui/app-shell`, `@object-ui/console`, `@object-ui/i18n` `type-check` all exit 0. <details><summary>Ablations (each via scripts/ablation-replace.mjs on the committed tree, restored blob == HEAD, git diff HEAD empty)</summary> - A1, environment-detected provider treated as not in use: `FirstRunChecklist.test.tsx` 1 failed / 35 passed ("detected from the boot environment"). - A2, done rows not folded: `FirstRunChecklist.test.tsx` 2 failed / 34 passed (both fold pins). - A3, unknown-object state without its Home button: `NotFoundState.test.tsx` 3 failed / 0 passed. - A4, record not-found without the list link: `RecordDetailView.recordReadFailure-11902.test.tsx` 2 failed / 9 passed (control on the same head: 11/11 passed). </details> ## Acceptance notes - The unknown-object title stays "Object Not Found" (title case) beside "Page not found" / "Record not found". Changing an `en` value reds `check:i18n-drift` for all ten follower packs, and the claim allows adding keys only. Noted, not changed. - The premise reading (the checklist takes about 60% of a 1440×900 first screen, and all of a 390 px one) was not re-measured in a browser in this run. NOT MEASURED: no backend stack was built, and the shared lock was contended. On `origin/main` the code draws every row, done or not, which is the mechanism #32157 names. - Existing harnesses touched: `AppContent.noAppComponentRoutes` now loads `@objectstack/lint` at module top, as `check:test-source-alias` asks of an edited file. `recordReadFailure-11902` mounts the record page on the console's record route, so the list link has its app segment. ## Verification Gates derived by `node scripts/pm/dispatch-gates.mjs --commands` at `4b7db52a3`, and run locally. Also run: `check:i18n-keys`, `check:i18n-drift` and `check:i18n-dead-keys` (all exit 0), `pnpm --dir ui exec vitest run scripts/` (5062 passed, 2 skipped), and `gen:zh-hant` reports zh-Hant already current. Dogfood battery: n/a (no `!` in the title, no narrowing arm). --- _Generated by [Claude Code](https://claude.ai/code/session_012MmDsRT6hvZsQH9dTzn4CA)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 19f9053 commit a127a45

23 files changed

Lines changed: 824 additions & 82 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@object-ui/console': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(console): the first-run checklist shows the AI provider the server is running and folds the rows that are done; every "not found" page now has a way back
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
What an administrator sees on Home, and what anyone sees after following a stale link (objectstack#32021 item 4, objectstack#32157):
12+
13+
- **The built-in AI on the first-run checklist.** A new row, "Set up the built-in AI", reads `live.provider` from `GET /api/settings/ai`. That field says which provider the running system uses and where it came from. The row never reads `values.provider`, because that only says what was saved, and the runtime can detect a provider from its own boot environment while nothing is saved. When a provider is in use, the row is done and names it by its option label, followed by "set in Setup" or "detected from the server environment". When `source` is `none`, the row is not done and links to Setup → AI & Embedder. A server that does not state the provider at all draws no row, because unknown is not the same as unset. Only a session that may write the `ai` namespace reads it. The external assistant row keeps its wording and stays a separate step.
14+
- **Rows that are done are folded away.** The checklist now draws only the rows still to do. Under them, one control ("Show completed (N)" / "Hide completed", with `aria-expanded`) shows the done rows in their place or folds them again. Every visit starts folded, so the card keeps the first screen for the work left. Progress still counts every row.
15+
- **A way back from every not-found page.** Four pages now share one `NotFoundState`, each keeping its own title and cause: unknown object, unmatched URL, unknown record and unknown app. Each page offers its own way back first, then "Back to home", which goes to the deployment's declared landing app when it has one. For an unmatched URL that is "Go back". For an unknown record it is "Back to OBJECT-LIST", a link to the object's list. For an unknown app it is "Retry". Before this change, the unknown-object and unknown-record pages offered no way out. The "no access to this app" page uses the same Home button.
16+
17+
New `@object-ui/i18n` keys in every pack: `console.firstRunChecklist.aiProvider.{title,todo,doneSettings,doneEnvironment,action}`, `console.firstRunChecklist.{showDone,hideDone}` and `empty.backToList`. No key is removed or renamed.

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

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@
3636
* what that notice says is ruled (objectstack#30120), so the row yields.
3737
* 6. Invite colleagues: a second member or a pending invitation; links to
3838
* Setup → Users, where Invite User is.
39-
* 7. Connect an external AI assistant: done once this administrator has
39+
* 7. The built-in AI: a provider is in use in the running system, as the
40+
* server states it (`live.provider` of `GET /api/settings/ai`, never the
41+
* saved `values.provider`, which misses a provider the runtime detected
42+
* from its boot environment). The row names the provider and where it
43+
* came from (Setup, or the server's environment) and links to Setup →
44+
* AI & Embedder. Only for a session that may write `ai`; a server that
45+
* states nothing about the provider gets no row (unknown is not unset).
46+
* 8. Connect an external AI assistant: done once this administrator has
4047
* authorized an AI assistant or holds an API key that still works, read
4148
* from those records by `useConnectedAccess` (the read Connect an AI
4249
* Assistant's Connected line uses), never from a click; links to that
@@ -54,6 +61,12 @@
5461
* Once every row shown is done the checklist draws nothing; it comes back on
5562
* its own if a setting is unset again.
5663
*
64+
* Rows that are done are folded away: the list draws the rows still to do, and
65+
* one control under them names how many are done and shows them (in their
66+
* place in the list) or folds them again, so the card keeps the first screen
67+
* for the work left (objectstack#32157). Unfolding is this mount's own state:
68+
* a fresh visit starts folded.
69+
*
5770
* ## Hiding it
5871
*
5972
* The close button hides it for this administrator in this workspace on this
@@ -77,7 +90,7 @@
7790
import { useEffect, useState, type ReactNode } from 'react';
7891
import { Link } from 'react-router-dom';
7992
import { toast } from 'sonner';
80-
import { CheckCircle2, Circle, Loader2, X } from 'lucide-react';
93+
import { CheckCircle2, ChevronDown, ChevronUp, Circle, Loader2, X } from 'lucide-react';
8194
import { Button, cn } from '@object-ui/components';
8295
import {
8396
connectAssistantPath,
@@ -97,6 +110,8 @@ import { resolveLabel, type ResolvedSettingValue } from './types';
97110
import { useSettingsLabel, type SettingsLabelHelpers } from './useSettingsLabel';
98111
import { whenBootPainted } from '../../loadLocales';
99112
import {
113+
AI_NAMESPACE,
114+
AI_PROVIDER_KEY,
100115
COUNTRY_KEY,
101116
CURRENCY_KEY,
102117
LOCALE_KEY,
@@ -384,8 +399,11 @@ export function FirstRunChecklist() {
384399
const { systemPermissions } = usePermissions();
385400
const { apps } = useMetadata();
386401
const labels = useSettingsLabel(LOCALIZATION_NAMESPACE);
402+
const aiLabels = useSettingsLabel(AI_NAMESPACE);
387403

388404
const [editing, setEditing] = useState<ChecklistSettingsRow['id'] | null>(null);
405+
// Whether the rows that are done are drawn; folded on every visit.
406+
const [showDone, setShowDone] = useState(false);
389407
// The browser's answers are read once per mount: what the rows offer does not
390408
// change under the administrator while they look at it.
391409
const [browser] = useState(readBrowserAnswers);
@@ -599,6 +617,37 @@ export function FirstRunChecklist() {
599617
});
600618
}
601619

620+
if (settings.ai) {
621+
const ai = settings.ai;
622+
const provider = ai.value ? aiLabels.optionLabel(AI_PROVIDER_KEY, ai.value, ai.optionLabel ?? ai.value) : '';
623+
rows.push({
624+
id: 'ai_provider',
625+
done: ai.done,
626+
node: (
627+
<ChecklistRow
628+
key="ai_provider"
629+
id="ai_provider"
630+
done={ai.done}
631+
title={t('console.firstRunChecklist.aiProvider.title')}
632+
detail={
633+
!ai.done
634+
? t('console.firstRunChecklist.aiProvider.todo')
635+
: ai.source === 'environment'
636+
? t('console.firstRunChecklist.aiProvider.doneEnvironment', { provider })
637+
: t('console.firstRunChecklist.aiProvider.doneSettings', { provider })
638+
}
639+
action={
640+
<RowLink
641+
to={`${setupPath}/system/settings/${AI_NAMESPACE}`}
642+
label={ai.done ? t('console.firstRunChecklist.change') : t('console.firstRunChecklist.aiProvider.action')}
643+
testId="first-run-checklist-link-ai_provider"
644+
/>
645+
}
646+
/>
647+
),
648+
});
649+
}
650+
602651
if (assistantPath && assistant.state === 'ready') {
603652
const done = assistant.connected;
604653
rows.push({
@@ -665,7 +714,30 @@ export function FirstRunChecklist() {
665714
</button>
666715
</div>
667716
</div>
668-
<ol className="mt-2 divide-y divide-border">{rows.map((row) => row.node)}</ol>
717+
<ol className="mt-2 divide-y divide-border" id="first-run-checklist-rows">
718+
{rows.filter((row) => showDone || !row.done).map((row) => row.node)}
719+
</ol>
720+
{doneCount > 0 ? (
721+
<div className="border-t border-border py-2">
722+
<button
723+
type="button"
724+
onClick={() => setShowDone((shown) => !shown)}
725+
aria-expanded={showDone}
726+
aria-controls="first-run-checklist-rows"
727+
className="inline-flex items-center gap-1 rounded-md px-1 py-0.5 text-xs text-muted-foreground hover:bg-accent hover:text-foreground"
728+
data-testid="first-run-checklist-toggle-done"
729+
>
730+
{showDone ? (
731+
<ChevronUp className="h-3.5 w-3.5" aria-hidden />
732+
) : (
733+
<ChevronDown className="h-3.5 w-3.5" aria-hidden />
734+
)}
735+
{showDone
736+
? t('console.firstRunChecklist.hideDone')
737+
: t('console.firstRunChecklist.showDone', { done: doneCount })}
738+
</button>
739+
</div>
740+
) : null}
669741
</section>
670742
</div>
671743
);

0 commit comments

Comments
 (0)