Repository navigation
Commit e8b494a
feat(console): the ⌘K palette previews the selected record, creates a record from the query, and names what Enter does (#36387)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbUq2j5tRRVo3TVY3wcS1Fdg)_
Part of #36286 — this PR is step 1 (to-do items 1 to 4); item 5, the
"current page" group on the empty palette, is left for a second PR on
the same card.
repo:objectstack#7 · zhuangjianguo · session_01QsR2jV3scu6UYPb42n5okQ
Clause-②: yes (widening) — eight new published language-pack keys, in
all eleven packs: console.commandPalette.create, createAs, previewEmpty,
enterOpenRecord, enterCreate, enterSwitchApp, enterApplyTheme, enterOpen
Metadata-protocol: none
## 维护者速读
-
在应用里打开搜索面板:搜到记录时右边显示选中记录的要点(标题和对象声明的关键字段),上下键跟着换;输入任意词,列表最后出现「新建『该词』为客户」等行,回车打开已填好名称的新建页;输入「新建」或对象名能找到「新建客户」这类入口;面板底部写明回车会做什么。
- 属于外壳体验对标 Attio 专题,落实维护者「立」的四条改进里的第 1 条(必做的前四项)。
- 出问题时用户最多看到预览或新建入口不对、点进一个空的新建页,不会改动任何数据,可以直接撤回。
- 请看下面的截图,确认右侧详情和新建行的样子是否符合预期。
## What changes
The ⌘K palette inside an app (`CommandPalette`,
`ui/packages/app-shell/src/chrome/`) gains the card's items 1 to 4.
Which records search finds and their order, the full search page, mobile
and the AI entry are untouched.
1. **Record preview on the right** (`PalettePreviewPane.tsx`). While the
query finds records, the palette widens (`sm:max-w-3xl`) and draws the
selected hit read-only through the existing `RecordPreviewCard` (object
label, title by the ADR-0079 ladder, the object's declared
`highlightFields` through the record page's highlight strip, field-level
security applied). The selection is cmdk's own, now controlled (`value`
/ `onValueChange`), so ArrowUp/ArrowDown move the preview. When a new
set of hits lands, the selection moves to the first hit. The pane is a
CSS container query on the palette frame: below a 45rem (720px) frame it
is `display: none`, so a narrow window shows the results alone and
nothing scrolls sideways.
2. **Create "words" as OBJECT** (`paletteCreate.ts`). Once something is
typed, the last group, "Create", offers up to three of the app's
navigation objects, the object of the page the palette was opened on
first, then the navigation's order. Enter opens
`/apps/APP/OBJECT/new?TITLEFIELD=words`, the create page that already
reads its query string as the create prefill. An object is offered by
the same verdict as the list's New: `resolveAffordance('listNew', …)`
(bucket, `userActions.create`, effective API operations, create grant),
then the create action's toolbar `visibleWhen` (fails closed) and
`disabledWhen` bound with no record, as `objectViewToolbarAffordances`
binds them. A "create as" row additionally needs the object's title
field (`resolveNameField`) to be a `text`/`textarea` field, not
`readonly`, that the member may write on create (`createFormFields`), so
the words always land.
3. **New OBJECT** entries, in the same group: one per creatable object
whose label ("New Customer", the list button's own
`console.objectView.newObject` key), object label, machine name or the
words "create new" match the query. An object whose New entry the query
found gets no "create as" row (the query names the action, not a
record).
4. **Enter hint** (`PaletteEnterHint.tsx`). A footer names what Enter
does to the selected entry, read off the first word of its cmdk value:
Open record (record, recent), Create, Switch app, Apply theme, or Open
(every navigation entry).
Eight new published `@object-ui/i18n` keys in all eleven packs, a
widening of the language packs (Clause-② yes):
`console.commandPalette.create`, `createAs`, `previewEmpty`,
`enterOpenRecord`, `enterCreate`, `enterSwitchApp`, `enterApplyTheme`,
`enterOpen` (zh-Hant regenerated by `gen:zh-hant`). No props or package
exports change. README section of the palette updated. Changeset:
`@object-ui/app-shell` + `@object-ui/i18n` patch.
### Screenshots (showcase app, 1440 wide, `zh-CN`; own `--fresh` backend
+ console dev server on this branch)
Hit: "north" on the Accounts list, the first hit previewed, footer 「打开记录
↵」

Miss: 「张三丰」, the page's object first, footer 「新建 ↵」

「新建」: the New entries (below the navigation pages the word also finds)

Enter on the miss row: the create page with the name filled

A 700px window: results alone, no preview, no sideways scroll (measured
`scrollWidth - clientWidth` = 0)

English:
[hit](https://github.com/objectstack-ai/objectstack/blob/00a0d416b65d2cf4c2fbb706adbe46270a083051/screens/36286/1-hit.png?raw=true)
·
[miss](https://github.com/objectstack-ai/objectstack/blob/00a0d416b65d2cf4c2fbb706adbe46270a083051/screens/36286/2-miss.png?raw=true).
The images live on the orphan ref `claude/issue-36286-screenshots` (no
code), so this PR's diff carries no binary.
## Read first (by risk)
1. `ui/packages/app-shell/src/chrome/CommandPalette.tsx` — the hunk that
computes `createTargets` / `newRecordRows` / `createAsRows`, and the
render-time block that moves the selection to the first record hit when
`hitSignature` changes (state adjusted during render, not in an effect).
2. `ui/packages/app-shell/src/chrome/paletteCreate.ts` —
`paletteMayCreate` (the New verdict) and `palettePrefillField`.
3. `ui/packages/app-shell/src/chrome/PalettePreviewPane.tsx` — the 150
ms settle before the by-id read.
## Tests
New file `CommandPalette.previewCreate-36286.test.tsx` (15 tests)
against the real `CommandPaletteProvider` over the `find` fanout and
`findOne`: the preview draws title + declared key fields and Enter opens
the record; ArrowDown moves the preview and only the settled records are
read (`findOne` called for C1 then C2, nothing else); the
container-query classes; no pane and no wide palette without a hit;
create-as order (route object first, else navigation order), the invoice
the member may not create never offered, Enter lands on
`/apps/crm/customer_36286/new?name=Zhang+San`; the empty palette and a
cleared query offer no create row; "new" finds one New entry per
creatable object and no create-as row; an object's name finds its New
entry; the footer per entry kind; `visibleWhen` / `disabledWhen` /
title-field gates as units.
<details><summary>Local runs at 862d69b</summary>
- `pnpm --filter @object-ui/app-shell type-check` (both `tsc --noEmit`
and `tsconfig.test.json`), then `vitest run
packages/app-shell/src/chrome/` under the lock: `VERDICT command-exit
0`, Test Files 29 passed (29), Tests 173 passed (173).
- `vitest run packages/i18n/`: Test Files 106 passed (106), Tests 1978
passed, 13 skipped. (First run had 3 reds, fixed in this branch: zh-Hant
not regenerated, and the de quote-pair count pin 121 to 122 for the new
`createAs` pair.)
- Earlier on this branch: every `CommandPalette.*.test.tsx`,
`paletteMatch.test.ts` and `views/record-preview/*.test.tsx` green (part
of the 126-file run whose only reds were the two i18n files above).
- `ui`: `check:i18n-keys`, `check:i18n-drift` (0 en values changed, 8
keys added), `check:i18n-dead-keys`: exit 0.
- eslint `--no-inline-config` on the changed files: 0 errors;
`CommandPalette.tsx` carries the same 10 warnings as on `main`.
- Derived families run locally (exit 0): `check-adr-0087-registration`,
`check-changeset-no-major`, `check-empty-changeset`,
`check-closing-keyword-parity`, `check-sdui-manifest`,
`check-comment-mask-corpus`, `check:nul-bytes`, `check:published-files`,
`check:cross-package-test-inputs`, `check:test-source-alias`,
`check:undeclared-dep-imports`, `check:adr-anchors`, `check:role-word`,
`check:watch-hint-literal`, `check:type-check-coverage`. NOT MEASURED:
`check:type-check-debt` (killed at its 300 s local timeout; CI's).
- `overlap-check`: VERDICT clean, merges with origin/main and 6 open PRs
sharing the locale packs.
</details>
## Acceptance notes
- **Create opens the create page, not the list's modal.** The palette
navigates to `/apps/APP/OBJECT/new` (the route the bare data surface's
New and a related list's New open; it reads the query string as
prefill). The list page's New opens a modal through `AppContent`'s
`handleEdit`, which is outside this claim's file surface; reaching it
from the palette would mean a new prop wired there. Worth a decision if
the modal is wanted.
- **Key fields are the declared `highlightFields` only.** An object that
declares none previews its title alone: that is `RecordPreviewCard`'s
rule, from the record page's 「没声明就不挑」 ruling, not a new choice. The
card's acceptance line (industry, phone, email) holds for an object that
declares them.
- **At most three "create as" rows** (`CREATE_AS_MAX`), a judgment to
keep the list short in apps with many objects; every other creatable
object is still one "New OBJECT" entry away by name.
- **The Create group comes last**, so Enter on a query that finds
anything opens that thing; with the English word "new", records whose
status is "new" come first and the New entries sit below them (the 「新建」
screenshot shows the Chinese case).
- **Home's palette** reads the host app's navigation, so it offers the
same rows there; the Studio palette offers none (no records, no app).
- **One extra read per previewed record**: the hit payload carries the
row, but `RecordPreviewCard` reads by id with `$expand` on the reference
fields it shows, so lookups render as names; holding an arrow key reads
nothing until the selection rests 150 ms.
- The showcase's account object is labelled "Account (Success Overlay)"
by that example; the screenshots show it as served.
- The de pack's quote-pair count pin moves 121 to 122; a sibling PR
adding another „“ pair will need the same one-line bump on merge.
- Item 5 of the card (the "current page" group on the empty palette) is
not in this PR.
<details><summary>Readings at head a17d2c7 (after the first-push
verification above)</summary>
- 50b1abd merged origin/main: the PR conflicted on the de quote-pair
count pin (main's #36011 added two pairs); the pin now reads 124.
- 50b1abd went red in `Test UI (10/16)` on
`dialogViewportGutterCensus-12603`: the palette's 768 px wide cap lacked
the shared gutter. a17d2c7 reads `DIALOG_VIEWPORT_GUTTER` and lists the
palette in `WIDE_SITES`.
- Under the verify lock at a17d2c7: the gutter census plus
`packages/app-shell/src/chrome/` gave `Test Files 30 passed (30)`,
`Tests 180 passed (180)`; `pnpm --filter @object-ui/app-shell
type-check` VERDICT command-exit 0 (after rebuilding
`@object-ui/plugin-view`'s stale dist).
- At 50b1abd: `packages/i18n/` plus the palette test gave `Test Files
107 passed (107)`, `Tests 1993 passed | 13 skipped`; `ui scripts/` gave
`Test Files 172 passed | 2 skipped`, `Tests 5127 passed`.
- CI on a17d2c7: 45 success, 13 skipped, 0 failed.
- overlap-check at a17d2c7: exit 1 only against #36398 on
`de-quote-pairing-3876.test.ts` (the same count pin; the second lander
bumps it by one).
- Dev report: comment 7077770300 on #36286.
</details>
## Verification
Two minutes: `cd examples/app-showcase && pnpm exec objectstack dev
--seed-admin --fresh -p PORT`, then in `ui/apps/console`
`DEV_PROXY_TARGET=http://localhost:PORT pnpm exec vite --port VPORT
--strictPort`; sign in, open Accounts, press ⌘K, type `north`: Northwind
is selected and the right pane shows Lifecycle / Industry / Annual
Revenue; type `张三丰` and press Enter: the account create page opens with
Account Name filled.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jV3scu6UYPb42n5okQ)_
<!-- signed: repo:objectstack#7 · zhuangjianguo ·
session_01QsR2jV3scu6UYPb42n5okQ -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent a10422d commit e8b494a
20 files changed
Lines changed: 959 additions & 11 deletions
File tree
- .changeset
- ui/packages
- app-shell
- src/chrome
- components/src/__tests__
- i18n/src
- __tests__
- locales
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1426 | 1426 | | |
1427 | 1427 | | |
1428 | 1428 | | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
1429 | 1439 | | |
1430 | 1440 | | |
1431 | 1441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
0 commit comments