Skip to content

Commit 4db3750

Browse files
feat(console): phone Home folds the setup checklist to one line after the apps; the phone bar's badge and title fit (#34723)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBXim82sEGBUBXqH4hkWyBJX)_ Fixes #34596 Clause-②: yes (widening) Metadata-protocol: none repo:objectstack#3 · os-support-ai · session_01WGufzi3ezPzTysQPDEjmVz (claim 6937591453, surface amended by the seat to add `InboxPopover.tsx`) · part of epic #34571 **Item 2 of the card (no floating AI button on a phone) is handed to #34608**, which removes the in-app AI button at every width under the ruling on #34608 (comment 6937495221: "the in-app bottom-right AI button is removed (one entry: the top-bar robot)"); it lands in PR #34665. This PR does not touch `ConsoleChatbotFab.tsx`. **Deviation from card item 3's wording.** Item 3 asks for a phone bar with "search, notifications, avatar" only. The phone bar keeps the top-bar AI robot (where the server serves AI) under the #34608 ruling (comment 6937495221: "one entry: the top-bar robot"), which postdates the card's wording; with the in-app AI button gone (#34665, now on `main`), hiding the robot on a phone would leave a phone with no AI entry. Live reading with the robot's 44 px slot in the bar: the phone title gets 89 px and "Opportunities" needs 89 px, so it fits (89/89 px, not truncated; 74/89 px and truncated on the old `main`). ## 维护者速读 - 改了什么:手机宽度(768 px 以下)首页的「初始化清单」挪到应用宫格之后,默认折叠成一行(标题、进度、「继续」),点「继续」原地展开,展开后可再收起;手机顶栏的通知角标「9+」移进铃铛的 44 px 点击区内,不再被顶栏上沿裁掉;640 px 以下顶栏三组按钮之间去掉分隔线和额外间距、标题去掉左边距,把宽度让给页面标题。 - 为什么改:375 宽实测改前清单占首屏 90%(375×667)、首屏一行应用图标都看不到;角标顶边在 y = -0.5 px,露在顶栏之外。 - 风险与回滚:只动控制台前端(`HomePage` 新增一个可选的清单插槽、清单组件新增摆放参数、铃铛角标两个手机类名、顶栏手机端间距、每种语言一个「继续」键);清单的行、完成判定、进度计数、关闭按钮都不变;768 px 及以上首页不变。回滚即 revert 本 PR。 - 先看:① `ui/packages/app-shell/src/console/home/HomePage.tsx` 的 `checklist?.('top')` / `checklist?.('afterApps')` 两处摆放;② `ui/apps/console/src/pages/settings/FirstRunChecklist.tsx` 的 `foldable && !unfolded` 折叠分支;③ `ui/packages/app-shell/src/layout/AppHeader.tsx` 右侧按钮簇的 `sm:` 分隔线类名。 - 两分钟验证:在仓根执行 `pnpm --dir ui exec vitest run apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx packages/app-shell/src/console/home/__tests__/HomePage.phoneTapTargets-29147.test.tsx`,预期 2 个文件全部通过(含「375 px: drawn once, after the apps」与「one line: the title, the progress and Continue」)。 - 需要你做的:无,席位落地。 ## What changes **Home's checklist slot** (`HomePage.tsx`, `@object-ui/app-shell`): `HomePage` takes an optional `checklist(placement)` render slot. Home calls it with `'top'` above the page's sections on a desktop, with `'afterApps'` in the content column right after the apps strip on a phone (`usePhoneViewport`, below 768 px, the hook the list and record pages already use), and with `'top'` above the empty state when there is no app yet. While the page is loading the slot is not drawn, so the checklist mounts once, where it stays. The console's Home route (`App.tsx`) passes the first-run checklist through the slot instead of mounting it above `DefaultHomePage`. **The folded card** (`FirstRunChecklist.tsx`): a `placement` prop (`'top'` default). `'afterApps'` starts folded to one line: the title, the progress line the card already draws ("3 of 6 done", same count, same key) and a **Continue** button (`aria-expanded=false`). Continue unfolds the whole card in place; the unfolded phone card adds a fold control (chevron, `aria-expanded`, `aria-controls` = the rows list, named by `common.collapse`) beside the progress and the close button. Folding is the mount's own state, like the done-rows fold: a fresh visit starts folded. No row, completion rule, progress count, write or dismiss record changes; with every required row done the card still draws nothing. **The phone top bar** (`AppHeader.tsx`, phone bar only; `InboxPopover.tsx`, the badge line only): - The bell's badge takes `max-md:top-1 max-md:right-1`: below 768 px it sits inside the 44 px trigger on the glyph's corner, instead of 2 px above the trigger, which put its top edge at y = -0.5 px, outside the 48 px bar. - Below 640 px the utility cluster's group dividers and their margins are `sm:`-scoped, so the 44 px controls sit side by side, and the page title beside the app pill takes no margin of its own (the pill's padding parts them). Both give the width to the title. - **Which controls the phone bar keeps is unchanged.** On `main` the phone bar already shows only search, the bell and the account menu, plus the AI robot where the server serves AI. The card asks for "search, notifications, avatar" only; the robot stays because the #34608 ruling makes it the one AI entry ("one entry: the top-bar robot"), and with the in-app AI button removed there, hiding it on a phone would leave a phone with no AI entry at all. The card's item 2 also routes the phone AI entry to the top-bar icon. **i18n**: `console.firstRunChecklist.continue` in all eleven packs (zh-Hant regenerated with `gen-zh-hant.mjs`). **Why the key is in the eager `locales/en.ts`, not a lazy namespace.** The eager pack is for keys the eager shell draws; a key only lazily loaded surfaces read belongs in the namespace that surface already uses. This key does not qualify for a namespace: `FirstRunChecklist` is a static import of the console entry (`App.tsx`), drawn by the `/home` route, which is where `RootLandingRedirect` lands a workspace by default, and it renders behind no namespace frame. Measured in the built console at `860300c36`: the call site `console.firstRunChecklist.continue` sits in the entry chunk `assets/index-DAb5a3hk.js`, the one chunk `eager-closure.json` lists in `entryChunks`; the rest of the `console.firstRunChecklist` group already lives in `en.ts`. The two pack-shaped namespaces (`marketplace`, `developer`) hold groups their own surfaces read, and `check:i18n-keys` refuses a namespace-only key read outside its frame, so moving this one key there would need a second loader for one string. Cost: `i18n-locale-en` reads **60.2 KB / 60.5 KB** ceiling (headroom 0.4 KB) after merging `main` (see Verification); the ceiling is not touched. ## Tests - `FirstRunChecklist.test.tsx` (new top-level describe in the existing harness, real settings client on a stubbed `fetch`): the folded line (title, "0 of 5 done", Continue, no rows, no write); Continue unfolds with every row, the fold control's `aria-expanded` / `aria-controls`, folding back; folding changes no completion rule (the folded line counts "3 of 5 done", a set workspace draws nothing); zh 「继续」; CONTROL: `'top'` draws the whole card with neither control. - `HomePage.phoneTapTargets-29147.test.tsx` (new top-level describe): at 1024 px the slot is asked once for `'top'`, drawn before the greeting and the apps, never `'afterApps'`; at 375 px once for `'afterApps'`, after the last app tile and before "My work"; 375 px with no app: `'top'`; CONTROL: no slot, page as before. The harness also gains the module-top `import '@objectstack/lint'` that `check:test-source-alias` asks of an edited file reaching `capabilityLint`. - `AppHeader.centeredSearch-12472.test.tsx` (new top-level describe): every divider rule on the cluster is `sm:`- or `min-[960px]:`-scoped; the phone title carries no margin class and sits in the left group. - `InboxPopover.phoneWidth-29076.test.tsx` (new top-level describe): the "9+" badge carries `max-md:top-1 max-md:right-1` beside its desktop offsets, inside the `relative max-md:size-11` trigger. No ablation: happy-dom computes no media query, so these pins read the classes and the slot calls; the pixel proof is the live reading below. ## Acceptance notes - **Robot vs. card wording** (the deviation stated above): kept by ruling. Measured on a phone app route with a 44 px robot slot in the bar: the title has 89 px, "Opportunities" needs 89 px, so it fits with no headroom; on the old `main` the same title had 74 px and truncated. A longer page name still truncates while the robot is in the bar. - **The bell's pulse.** When the unread count rises the trigger bounces for 1.2 s (`motion-safe:animate-bounce`, 25 % of its height); during that bounce the badge rides above the bar's edge again. Unchanged here. - **640–767 px.** The badge moves inside from 768 px down; the dividers and the title margin change only below 640 px (the title is drawn only below `sm`). - **Desktop first screen.** At 1280 × 800 the card is still above the page (48 % of the first screen, one row of app icons): unchanged, out of this card's scope. - **Clause-②: yes (widening)**, by the seat's ruling in the restated claim on #34596: a new locale key (`console.firstRunChecklist.continue`) and an optional `checklist` prop on the workspace-private app-shell `HomePage` export. L1 at TIER_DEFAULT is the review of record, no L2. `Metadata-protocol: none` and the `patch` level are unchanged; the changeset carries the same two lines. ## Verification **Fix round at `860300c36`** (merge of `origin/main` at `004513829`, which brought #34665 and #34642 into the locales, `App.tsx`, `HomePage.tsx` and `AppHeader.tsx`; clean text merge, then the Clause-② changeset line): | Reading at `860300c36` | result | |:---|:---| | `turbo run build --filter=@object-ui/console` (locked) | 75/75 tasks, VERDICT command-exit 0 | | `pnpm --dir ui run check:eager-closure` | exit 0; **`i18n-locale-en` 60.2 KB / 60.5 KB ceiling (headroom 0.4 KB)**; closure 1894.3 / 2431.6 KB | | `check:eager-locale-catalogues` | exit 0; `en` 60.2 KB EAGER (resident) | | `check:i18n-keys`, `check:i18n-drift`, `check:i18n-dead-keys` | exit 0 each | | scoped vitest (locked; list in the Tests block) | Test Files 272 passed (272), Tests 3654 passed, 13 skipped | | `type-check` of `@object-ui/app-shell`, `@object-ui/console`, `@object-ui/i18n` (locked) | exit 0 | Live, on this branch at `e78e39f48`, my own stack: showcase backend `objectstack dev --fresh -p 4796` from this worktree, Console Vite on :5196 against it, Chromium at `/opt/pw-browsers/chromium`, signed in as the seeded admin; 11 launcher apps (the showcase's own plus apps authored through `PUT /api/v1/meta/app` on that throwaway database) and 12 in-app messages sent to the admin through `POST /api/v1/messaging/in-app-messages`, so the bell reads "9+". "Before" is the same stack with the five source files restored from `origin/main` (then restored to `HEAD`, each file's hash equal to its `HEAD` blob). | Reading | before (`origin/main`) | after | |:---|:---|:---| | 375 × 667 Home: full rows of app icons on the first screen | 0 (checklist 677 px tall, 90.4 % of the screen) | **3** (checklist folded, 54 px, after the apps) | | 375 × 812 Home: full rows of app icons on the first screen | 0 (checklist 83.3 % of the screen) | **4** | | Folded line at 375 px (title / needs) | n/a | en 135/135, zh-CN 76/76, de 108/108: no truncation, 54 px tall | | Bell badge "9+" at 375 px (Home and app routes) | rect y = -0.5 px, 96.9 % visible, outside the bar | y = 5.5 px, **100 % visible, inside the bar**, text not overflowing | | Phone app-route title room, 44 px robot slot added, "Opportunities" | 74 px for 89 needed: truncated | **89 px for 89**: not truncated | | Phone app-route titles as served ("Expense Reports", "Business Units") | 110/110, 96/96 | 110/110, 96/96 | | 1280 × 800 Home | card above the page | unchanged | Screenshots (seat project files): `/mnt/project-files/objectstack-seat3/34596-live/` — `before-home-375x667.png`, `after-home-375x667.png`, `after-home-375x812.png`, `after-home-375x812-continued.png`, `after-folded-line-{en,zh-CN,de}.png`, `before-bar-375x812.png`, `after-bar-375x812.png`, `before-app-bar-showcase_expense_report-375x812.png`, `after-app-bar-showcase_expense_report-375x812.png`, `after-home-1280x800.png`. <details><summary>Tests (locked runs)</summary> - At `f61d7e2b5` (after merging `origin/main`, closure rebuilt): `pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/console/home/ packages/app-shell/src/layout/__tests__/AppHeader. packages/app-shell/src/layout/__tests__/InboxPopover. apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx apps/console/src/__tests__/ packages/i18n/` → Test Files 263 passed (263), Tests 3609 passed, 13 skipped. - At `b661a231c`: `@object-ui/console^...` built; `pnpm --filter @object-ui/app-shell --filter @object-ui/console --filter @object-ui/i18n run type-check` → exit 0 (both tsconfigs each); `AppHeader.` tests → 34 files, 285 tests passed. - At `e78e39f48`: the four edited harnesses plus `ui/scripts/` (derived family) → Test Files 175 passed, 2 skipped; Tests 5162 passed, 2 skipped; lock VERDICT command-exit 0. - At `860300c36` (head, after merging `origin/main`; console closure rebuilt): `pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/console/home/ packages/app-shell/src/layout/__tests__/AppHeader. packages/app-shell/src/layout/__tests__/InboxPopover. packages/app-shell/src/layout/__tests__/ConsoleLayout. apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx apps/console/src/__tests__/ packages/i18n/` → Test Files 272 passed (272), Tests 3654 passed, 13 skipped, VERDICT command-exit 0; `type-check` of the three packages → exit 0. </details> <details><summary>Gates (local subset, derived by dispatch-gates --commands at b661a23, re-run after later commits where they read the new edits)</summary> 40 derived families: the 39 non-vitest commands exit 0 except `check:test-source-alias` (exit 1 on the edited Home harness, fixed by the module-top import, then exit 0 at `e00081337`); `vitest run scripts/` ran in the locked head run above. `dispatch-gates --ran` → 40 derived, 40 run, 0 NOT-MEASURED, 0 UNRUN. Re-run after the last edits: `check:undeclared-dep-imports`, `check-changeset-no-major`, `check-empty-changeset`, `check-adr-0087-registration`, `check:test-source-alias`, `check:nul-bytes`, `check:cross-package-test-inputs` → exit 0. `overlap-check --branch=HEAD` at `e78e39f48` → VERDICT clean exit 0. Everything else is CI's. Fix round, at `860300c36`: `dispatch-gates --commands` (tree objectstack-ai/objectstack at `860300c36`) → the same 40 families; all 39 non-vitest commands exit 0 (each captured before any pipe), `vitest run scripts/` (locked) → Test Files 171 passed, 2 skipped; Tests 5077 passed, 2 skipped, VERDICT command-exit 0; `dispatch-gates --ran` → 40 derived, 40 run, 0 NOT-MEASURED, 0 UNRUN. Also `check:new-line-citations` → 0 new, exit 0. `overlap-check --branch=HEAD` at `860300c36` → VERDICT clean exit 0 (origin/main and PR heads #34713, #34697, #34677, #34674 merge cleanly). </details> --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzi3ezPzTysQPDEjmVz --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6dd5716 commit 4db3750

21 files changed

Lines changed: 389 additions & 66 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
'@object-ui/i18n': patch
5+
---
6+
7+
feat(console): on a phone, Home keeps its first screen for the apps, and the top bar's badge and title fit
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: none
11+
12+
**Home's setup checklist.** Below 768 px, Home draws the administrator's first-run checklist after the apps instead of above the greeting, folded to one line: its title, its progress ("2 of 5 done") and **Continue**. Continue opens the whole card in place; a fold control beside the progress closes it to one line again. A fresh visit starts folded. The rows, the progress count, the done rule and the close button are unchanged, and from 768 px up the card is drawn above the page as before. With no app yet the card stays above the empty state at every width.
13+
14+
`HomePage` (`@object-ui/app-shell`) takes an optional `checklist(placement)` slot: Home calls it with `'top'` on a desktop or with no app, and with `'afterApps'` on a phone, and draws what it returns there. The console's Home route passes the first-run checklist through it. `@object-ui/i18n` adds `console.firstRunChecklist.continue` to every pack.
15+
16+
**The phone top bar.** Below 768 px the bell's unread badge ("9+") sits inside the bell's 44 px target, on the glyph's corner, instead of 2 px above it, where the bar's top edge cut it. Below 640 px the bar's control groups draw no divider and no extra gap, and the page title beside the app pill takes no margin of its own, so the title keeps that width. The controls the bar shows are unchanged: search, the bell, the AI assistant (where the server serves AI) and the account menu.

‎ui/apps/console/src/App.tsx‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import {
4444
} from '@object-ui/app-shell';
4545

4646
import { AppContent, ConsolePermissionsRequest, ConsolePermissionsScope } from './AppContent';
47-
import { FirstRunChecklist } from './pages/settings/FirstRunChecklist';
47+
import { FirstRunChecklist, type FirstRunChecklistPlacement } from './pages/settings/FirstRunChecklist';
4848
import { publishAuthState } from './i18nSession';
4949
import { FaviconSync } from './components/FaviconSync';
5050
import { RootLandingRedirect } from './components/RootLandingRedirect';
@@ -191,19 +191,24 @@ function NativeShellRouting() {
191191
return null;
192192
}
193193

194+
/** Home's checklist slot: the first-run checklist, where Home places it. */
195+
function homeChecklist(placement: FirstRunChecklistPlacement) {
196+
return <FirstRunChecklist placement={placement} />;
197+
}
198+
194199
/**
195200
* Wraps `DefaultHomeLayout` so the FAB gets the signed-in user id, and draws
196-
* an administrator's first-run checklist above the page's own sections
197-
* (objectstack#30206). The route sits under `ConsolePermissionsScope`, which
198-
* is what tells the checklist whether this session may write the settings it
199-
* lists; for anyone else it draws nothing.
201+
* an administrator's first-run checklist in Home's checklist slot
202+
* (objectstack#30206): above the page's own sections on a desktop, after the
203+
* apps on a phone (objectstack#34596). The route sits under
204+
* `ConsolePermissionsScope`, which is what tells the checklist whether this
205+
* session may write the settings it lists; for anyone else it draws nothing.
200206
*/
201207
function HomeRoute() {
202208
const { user } = useAuth();
203209
return (
204210
<DefaultHomeLayout userId={user?.id}>
205-
<FirstRunChecklist />
206-
<DefaultHomePage />
211+
<DefaultHomePage checklist={homeChecklist} />
207212
</DefaultHomeLayout>
208213
);
209214
}

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

Lines changed: 122 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,23 @@
1010
*
1111
* ## Where it is drawn
1212
*
13-
* Home (`/home`), above the page's own sections. Home is the environment's own
14-
* home (ObjectUI ADR-0075): every deployment that declares no landing app opens
13+
* Home (`/home`), in the slot Home's page gives its host's checklist
14+
* (app-shell's `HomePage`, `checklist`). Home is the environment's own home
15+
* (ObjectUI ADR-0075): every deployment that declares no landing app opens
1516
* there after sign-in, the Setup-only one included (`RootLandingRedirect`).
1617
* Mounted by the console's Home route (`App.tsx`), inside the
1718
* `ConsolePermissionsScope` that route already sits under: that provider is
1819
* what answers which capabilities this session holds.
1920
*
21+
* Home names the placement (`placement`). `top`, above the page's sections
22+
* (a desktop, or a page with no app yet), draws the card as it always was.
23+
* `afterApps` is a phone's: the card sits in the content column after the
24+
* apps and starts folded to one line, its title, its progress and Continue,
25+
* so the first screen keeps the launcher (objectstack#34596). Continue opens
26+
* the card in place, and a fold control closes it again; like the done rows'
27+
* fold, this is the mount's own state and a fresh visit starts folded.
28+
* Folding changes no row and no completion rule.
29+
*
2030
* ## Who sees it, and what each row says
2131
*
2232
* An administrator: a session that may write `localization`
@@ -110,7 +120,7 @@
110120
import { useEffect, useState, type ReactNode } from 'react';
111121
import { Link } from 'react-router-dom';
112122
import { toast } from 'sonner';
113-
import { CheckCircle2, ChevronDown, ChevronUp, Circle, Loader2, X } from 'lucide-react';
123+
import { CheckCircle2, ChevronDown, ChevronRight, ChevronUp, Circle, Loader2, X } from 'lucide-react';
114124
import { Button, cn } from '@object-ui/components';
115125
import {
116126
appRouteSegment,
@@ -444,7 +454,13 @@ function SettingsRowEditor({
444454
);
445455
}
446456

447-
export function FirstRunChecklist() {
457+
/**
458+
* Where Home draws the checklist: app-shell's `HomeChecklistPlacement`, by
459+
* value (see the module doc).
460+
*/
461+
export type FirstRunChecklistPlacement = 'top' | 'afterApps';
462+
463+
export function FirstRunChecklist({ placement = 'top' }: { placement?: FirstRunChecklistPlacement } = {}) {
448464
const { t, language } = useObjectTranslation();
449465
const { user, activeOrganization, getMembers, listInvitations, getAuthConfig } = useAuth();
450466
const { systemPermissions } = usePermissions();
@@ -459,6 +475,9 @@ export function FirstRunChecklist() {
459475
const [editing, setEditing] = useState<ChecklistSettingsRow['id'] | null>(null);
460476
// Whether the rows that are done are drawn; folded on every visit.
461477
const [showDone, setShowDone] = useState(false);
478+
// A phone's card starts folded to one line; folded on every visit.
479+
const foldable = placement === 'afterApps';
480+
const [unfolded, setUnfolded] = useState(false);
462481
// The browser's answers are read once per mount: what the rows offer does not
463482
// change under the administrator while they look at it.
464483
const [browser] = useState(readBrowserAnswers);
@@ -847,61 +866,114 @@ export function FirstRunChecklist() {
847866
setHiddenKey(recordKey);
848867
};
849868

850-
return (
851-
<div className="px-4 pt-4 sm:px-6 lg:px-8">
869+
const progress = t('console.firstRunChecklist.progress', { done: completion.done, total: completion.total });
870+
871+
if (foldable && !unfolded) {
872+
return (
852873
<section
853-
className="mx-auto max-w-[1120px] rounded-xl border border-border bg-card px-5 pt-4 pb-1"
874+
className="flex items-center justify-between gap-2 rounded-xl border border-border bg-card py-2 pl-4 pr-1.5"
854875
data-testid="first-run-checklist"
876+
data-folded="true"
855877
aria-labelledby="first-run-checklist-title"
856878
>
857-
<div className="flex items-start justify-between gap-4">
858-
<div className="min-w-0">
859-
<h2 id="first-run-checklist-title" className="text-base font-semibold tracking-tight">
860-
{t('console.firstRunChecklist.title')}
861-
</h2>
862-
<p className="mt-1 text-[13px] text-muted-foreground">{t('console.firstRunChecklist.description')}</p>
863-
</div>
864-
<div className="flex shrink-0 items-center gap-2">
865-
<span className="text-xs text-muted-foreground" data-testid="first-run-checklist-progress">
866-
{t('console.firstRunChecklist.progress', { done: completion.done, total: completion.total })}
867-
</span>
868-
<button
869-
type="button"
870-
onClick={hide}
871-
aria-label={t('console.firstRunChecklist.dismiss')}
872-
title={t('console.firstRunChecklist.dismiss')}
873-
className="rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-foreground"
874-
data-testid="first-run-checklist-dismiss"
875-
>
876-
<X className="h-4 w-4" />
877-
</button>
878-
</div>
879+
<p className="flex min-w-0 items-baseline gap-2">
880+
<span id="first-run-checklist-title" className="truncate text-[13px] font-semibold tracking-tight">
881+
{t('console.firstRunChecklist.title')}
882+
</span>
883+
<span className="shrink-0 text-xs text-muted-foreground" data-testid="first-run-checklist-progress">
884+
{progress}
885+
</span>
886+
</p>
887+
<Button
888+
size="sm"
889+
variant="ghost"
890+
className="shrink-0 gap-0.5 px-1.5 text-primary"
891+
onClick={() => setUnfolded(true)}
892+
aria-expanded={false}
893+
data-testid="first-run-checklist-continue"
894+
>
895+
{t('console.firstRunChecklist.continue')}
896+
<ChevronRight className="h-4 w-4" aria-hidden />
897+
</Button>
898+
</section>
899+
);
900+
}
901+
902+
const card = (
903+
<section
904+
className={cn(
905+
'rounded-xl border border-border bg-card px-5 pt-4 pb-1',
906+
!foldable && 'mx-auto max-w-[1120px]',
907+
)}
908+
data-testid="first-run-checklist"
909+
data-folded={foldable ? 'false' : undefined}
910+
aria-labelledby="first-run-checklist-title"
911+
>
912+
<div className="flex items-start justify-between gap-4">
913+
<div className="min-w-0">
914+
<h2 id="first-run-checklist-title" className="text-base font-semibold tracking-tight">
915+
{t('console.firstRunChecklist.title')}
916+
</h2>
917+
<p className="mt-1 text-[13px] text-muted-foreground">{t('console.firstRunChecklist.description')}</p>
879918
</div>
880-
<ol className="mt-2 divide-y divide-border" id="first-run-checklist-rows">
881-
{drawn.filter((row) => showDone || !row.done).map((row) => row.node)}
882-
</ol>
883-
{doneCount > 0 ? (
884-
<div className="border-t border-border py-2">
919+
<div className="flex shrink-0 items-center gap-2">
920+
<span className="text-xs text-muted-foreground" data-testid="first-run-checklist-progress">
921+
{progress}
922+
</span>
923+
{foldable ? (
885924
<button
886925
type="button"
887-
onClick={() => setShowDone((shown) => !shown)}
888-
aria-expanded={showDone}
926+
onClick={() => setUnfolded(false)}
927+
aria-expanded
889928
aria-controls="first-run-checklist-rows"
890-
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"
891-
data-testid="first-run-checklist-toggle-done"
929+
aria-label={t('common.collapse')}
930+
title={t('common.collapse')}
931+
className="rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-foreground"
932+
data-testid="first-run-checklist-fold"
892933
>
893-
{showDone ? (
894-
<ChevronUp className="h-3.5 w-3.5" aria-hidden />
895-
) : (
896-
<ChevronDown className="h-3.5 w-3.5" aria-hidden />
897-
)}
898-
{showDone
899-
? t('console.firstRunChecklist.hideDone')
900-
: t('console.firstRunChecklist.showDone', { done: doneCount })}
934+
<ChevronUp className="h-4 w-4" aria-hidden />
901935
</button>
902-
</div>
903-
) : null}
904-
</section>
905-
</div>
936+
) : null}
937+
<button
938+
type="button"
939+
onClick={hide}
940+
aria-label={t('console.firstRunChecklist.dismiss')}
941+
title={t('console.firstRunChecklist.dismiss')}
942+
className="rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-foreground"
943+
data-testid="first-run-checklist-dismiss"
944+
>
945+
<X className="h-4 w-4" />
946+
</button>
947+
</div>
948+
</div>
949+
<ol className="mt-2 divide-y divide-border" id="first-run-checklist-rows">
950+
{drawn.filter((row) => showDone || !row.done).map((row) => row.node)}
951+
</ol>
952+
{doneCount > 0 ? (
953+
<div className="border-t border-border py-2">
954+
<button
955+
type="button"
956+
onClick={() => setShowDone((shown) => !shown)}
957+
aria-expanded={showDone}
958+
aria-controls="first-run-checklist-rows"
959+
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"
960+
data-testid="first-run-checklist-toggle-done"
961+
>
962+
{showDone ? (
963+
<ChevronUp className="h-3.5 w-3.5" aria-hidden />
964+
) : (
965+
<ChevronDown className="h-3.5 w-3.5" aria-hidden />
966+
)}
967+
{showDone
968+
? t('console.firstRunChecklist.hideDone')
969+
: t('console.firstRunChecklist.showDone', { done: doneCount })}
970+
</button>
971+
</div>
972+
) : null}
973+
</section>
906974
);
975+
976+
// In the content column (a phone's placement) the column gives the width
977+
// and the gutters; above the page the card brings its own.
978+
return foldable ? card : <div className="px-4 pt-4 sm:px-6 lg:px-8">{card}</div>;
907979
}

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

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ vi.mock('@object-ui/react', async (importOriginal) => ({
6262
}));
6363

6464
import { useHomeItemClaimed, type HomeItem } from '@object-ui/app-shell';
65-
import { FirstRunChecklist } from '../FirstRunChecklist';
65+
import { FirstRunChecklist, type FirstRunChecklistPlacement } from '../FirstRunChecklist';
6666
import { __resetBootPainted } from '../../../loadLocales';
6767
import type { Specifier } from '../types';
6868

@@ -206,12 +206,16 @@ const ADMIN = ['setup.access', 'setup.write', 'manage_platform_settings'];
206206
const MEMBER = ['setup.access'];
207207

208208
/** No default for `systemPermissions`: "not reported" must stay apart from the admin set. */
209-
function renderChecklist(systemPermissions: string[] | undefined, language = 'en') {
209+
function renderChecklist(
210+
systemPermissions: string[] | undefined,
211+
language = 'en',
212+
placement?: FirstRunChecklistPlacement,
213+
) {
210214
return render(
211215
<MemoryRouter>
212216
<I18nProvider config={{ defaultLanguage: language, detectBrowserLanguage: false }}>
213217
<MePermissionsProvider initialPermissions={permissionsPayload(systemPermissions)}>
214-
<FirstRunChecklist />
218+
<FirstRunChecklist placement={placement} />
215219
</MePermissionsProvider>
216220
</I18nProvider>
217221
</MemoryRouter>,
@@ -1042,3 +1046,72 @@ describe('the host profile: a managed environment adds the first-app and first-r
10421046
expect(within(await screen.findByTestId('first-run-checklist-row-first_record')).getByText('添加第一条记录')).toBeTruthy();
10431047
});
10441048
});
1049+
1050+
describe('on a phone, after the apps, the card starts folded to one line (objectstack#34596)', () => {
1051+
const card = () => screen.getByTestId('first-run-checklist');
1052+
const progress = () => screen.getByTestId('first-run-checklist-progress').textContent;
1053+
1054+
it('one line: the title, the progress and Continue; no row is drawn and nothing is written', async () => {
1055+
renderChecklist(ADMIN, 'en', 'afterApps');
1056+
await waitFor(() => expect(progress()).toBe('0 of 5 done'));
1057+
expect(card().getAttribute('data-folded')).toBe('true');
1058+
expect(within(card()).getByText('Get your system ready')).toBeTruthy();
1059+
expect(within(card()).queryAllByRole('listitem')).toHaveLength(0);
1060+
const go = screen.getByTestId('first-run-checklist-continue');
1061+
expect(go.textContent).toBe('Continue');
1062+
expect(go.getAttribute('aria-expanded')).toBe('false');
1063+
expect(screen.queryByTestId('first-run-checklist-dismiss')).toBeNull();
1064+
expect(puts()).toHaveLength(0);
1065+
});
1066+
1067+
it('Continue opens the card in place with every row; the fold control closes it to one line again', async () => {
1068+
renderChecklist(ADMIN, 'en', 'afterApps');
1069+
fireEvent.click(await screen.findByTestId('first-run-checklist-continue'));
1070+
expect(card().getAttribute('data-folded')).toBe('false');
1071+
expect(await screen.findByTestId('first-run-checklist-row-invite')).toBeTruthy();
1072+
const fold = screen.getByTestId('first-run-checklist-fold');
1073+
expect(fold.getAttribute('aria-expanded')).toBe('true');
1074+
expect(fold.getAttribute('aria-controls')).toBe(screen.getByRole('list').id);
1075+
expect(screen.getByTestId('first-run-checklist-dismiss')).toBeTruthy();
1076+
expect(progress()).toBe('0 of 5 done');
1077+
1078+
fireEvent.click(fold);
1079+
expect(card().getAttribute('data-folded')).toBe('true');
1080+
expect(screen.queryByTestId('first-run-checklist-row-invite')).toBeNull();
1081+
expect(progress()).toBe('0 of 5 done');
1082+
});
1083+
1084+
it('folding changes no completion rule: the folded line counts what the card counts, and a set workspace draws nothing', async () => {
1085+
localizationValues = {
1086+
locale: resolved('zh-CN', 'tenant'),
1087+
default_country: resolved('CN', 'tenant'),
1088+
timezone: resolved('Asia/Shanghai', 'tenant'),
1089+
currency: resolved('CNY', 'tenant'),
1090+
};
1091+
renderChecklist(ADMIN, 'en', 'afterApps');
1092+
await waitFor(() => expect(progress()).toBe('3 of 5 done'));
1093+
cleanup();
1094+
1095+
AUTH.activeOrganization = { id: 'org_1', name: 'Acme' };
1096+
AUTH.getMembers.mockResolvedValue([{ id: 'm_1' }, { id: 'm_2' }]);
1097+
mailValues = { provider: resolved('smtp', 'global'), smtp_host: resolved('mx', 'global'), from_email: resolved('a@b.co', 'global') };
1098+
renderChecklist(ADMIN, 'en', 'afterApps');
1099+
await settle();
1100+
await waitFor(() => expect(AUTH.getMembers).toHaveBeenCalled());
1101+
await settle();
1102+
expect(screen.queryByTestId('first-run-checklist')).toBeNull();
1103+
});
1104+
1105+
it('zh: Continue reads in the reader language', async () => {
1106+
renderChecklist(ADMIN, 'zh', 'afterApps');
1107+
expect((await screen.findByTestId('first-run-checklist-continue')).textContent).toBe('继续');
1108+
});
1109+
1110+
it('CONTROL: above the page the card is drawn whole, with no Continue and no fold control', async () => {
1111+
renderChecklist(ADMIN, 'en', 'top');
1112+
expect(await screen.findByTestId('first-run-checklist-row-invite')).toBeTruthy();
1113+
expect(card().getAttribute('data-folded')).toBeNull();
1114+
expect(screen.queryByTestId('first-run-checklist-continue')).toBeNull();
1115+
expect(screen.queryByTestId('first-run-checklist-fold')).toBeNull();
1116+
});
1117+
});

0 commit comments

Comments
 (0)