Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .changeset/39055-palette-nav-keywords.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@objectstack/spec': patch
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

feat(app-shell): the command palette finds a navigation entry by its old name or another alias, and shows each navigation result under its group path

Clause-②: yes (widening)
Metadata-protocol: none

A navigation entry's `keywords` now have their reader.

- **The served app carries each entry's aliases for the reader's locale.** `translateApp` gives every navigation node its own source-language `keywords` plus the reader's locale's `apps.<app>.navigation.<id>.keywords` from the translation bundle (the first locale along the chain that lists any), each word once. A locale's words add to the source words; they never replace them. So an English alias still finds the entry in a Chinese session, and a Chinese-only alias finds it there and not in English. A node whose bundle lists no keywords is served as before.
- **The ⌘K palette matches navigation entries on their `keywords`** as well as on their label and machine name, under the same word-prefix and substring rule. When only an alias found the entry, the row shows it after the entry's name: 「原名 岗位持有人」 in Chinese, "Formerly Position Holders" in English (a new `console.commandPalette.formerName` string in every console locale). A group's label and `keywords` find the visible entries under it, so a renamed group is still found by its old name, and each of its entries shows the group's matched alias. An entry found through an alias counts as found, so the palette does not offer to create a record from those words. `action` and `doc` entries accept `keywords`, but nothing reads them yet.
- **Every navigation result shows its group path** before its name, 「人员与组织 › 业务单元」, nested groups outermost first; an entry at the top level of the menu shows its name alone.

The key's liveness row (`navigation.children.keywords`) is now `live`, and its describe no longer carries the `[PLANNED — not yet read]` marker.

No action needed for existing metadata.
90 changes: 45 additions & 45 deletions content/docs/references/ui/app.mdx

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions content/docs/ui/apps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ rejected — a divider has nothing to label, gate, or badge.)
| :--- | :--- | :--- |
| `id` | `string` | Unique identifier (`snake_case`, required) |
| `label` | `string` | Display label |
| `keywords` | `string[]` | Search aliases, such as a page's old name after a rename (planned: the command palette will read them) |
| `keywords` | `string[]` | Search aliases, such as a page's old name after a rename; the command palette matches them |
| `icon` | `string` | Icon name (Lucide) |
| `order` | `number` | Sort order within the same level (lower = first); entries [contributed by another package](#contributing-navigation-to-another-app) sort in the same level |
| `badge` | `string \| number` | Badge text or count displayed on the item |
Expand All @@ -313,9 +313,15 @@ console's own name for the index. A `label` you write renders verbatim; never wr
key instead.

`keywords` lists other words a person may type to find the entry, such as its old
name after a rename; they are never shown and never gate anything, and a
translation bundle gives each locale its own under
`apps.<app>.navigation.<id>.keywords`, beside that entry's `label`.
name after a rename; they never gate anything, and a translation bundle gives each
locale its own under `apps.<app>.navigation.<id>.keywords`, beside that entry's
`label`. A locale's words add to the entry's own, never replace them, so a word
written in the source language finds the entry in every language. The ⌘K command
palette finds an `object`, `dashboard`, `page`, `report`, `component` or `url` entry
by any of them, and when only one of these words matched it shows that word beside
the entry ("Formerly …"). A `group`'s label and `keywords` find the entries under
it, so a renamed group is still found by its old name. An `action` or `doc` entry
accepts `keywords`, but nothing reads them there yet.

## Designing the navigation

Expand Down
7 changes: 4 additions & 3 deletions packages/spec/liveness/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@
"note": "rendered everywhere; translateApp swaps in the per-locale label by node id. 2026-08-28: RE-ANCHORED (commit 8f10a79f7) and REPOINTED — `:456` had rotted onto `opts?: ResolveOptions` in `lookupActionResultDialogText`'s signature, ~195 lines above `lookupNavLabel`. Re-closed by hand against 8cb96ec41."
},
"keywords": {
"status": "planned",
"status": "live",
"verifiedAt": "2026-12-02",
"evidenceScope": "cross-repo",
"note": "PLANNED RECORD (#39052, 2026-12-02, Claim 7339233623 by seat repo:objectstack@os-support-ai; epic #39050 row 8, protocol half): search aliases on a navigation entry, `keywords: string[]`, declared on the shared nav base so the nine branches that spread it carry it (a separator refuses it with its own prescription). Named `keywords`, not `aliases`, because `aliases` is the retired-key rename map across packages/spec/src/ai/*.zod.ts. The per-locale half is the translation bundle's `apps.<app>.navigation.<id>.keywords`, keyed by the same entry id as `label` (translation.json's `apps` row, not drilled below the record value). PLANNED, not live: the declared reader is the command palette card #39055 (Blocked-by #39052), whose read points are ui/packages/app-shell/src/chrome/CommandPalette.tsx (matches label and machine name only today) and ui/packages/app-shell/src/views/appReportIndex.ts#flattenNavigation; objectui's nav mirror (ui/packages/types/src/zod/app.zod.ts) declares the key with the spec's accept set so the console parse keeps it, and the Studio nav editor's retype keeps it (ui/packages/app-shell/src/views/metadata-admin/inspectors/nav-target.ts NAV_ENTRY_BASE_KEYS), but no source reads it today. `authorWarn` is deliberately OFF: an authored alias that nothing reads costs a search hit, not a gate or a route, and the platform-items card #39057 authors it on the first-party Setup app, where a warning would fire on every stock build until the palette lands. Flip to `live` on the commit that cites the palette's reader, and drop the `[PLANNED — not yet read]` describe marker in the same edit."
"evidenceScope": "in-repo",
"evidence": "packages/spec/src/system/i18n-resolver.ts#translateApp (serves each node's match set for the reader's locale: its own `keywords` plus the first `apps.<app>.navigation.<id>.keywords` along the locale chain); packages/spec/src/system/i18n-nav-keywords.ts#mergeNavKeywords (the add rule: source words first, the locale's words added, each once); ui/packages/app-shell/src/chrome/CommandPalette.tsx#CommandPalette (matches the six navigation entry kinds it offers, `object`, `dashboard`, `page`, `report`, `component` and `url`, on label, machine name and `keywords`, plus the label and `keywords` of each group above an entry, and shows the alias that found it); ui/packages/app-shell/src/chrome/paletteNavKeywords.ts#paletteKeywordHit (a keyword is tried only when the label and machine name miss, so the hint names the alias that found the entry); ui/packages/app-shell/src/chrome/paletteNavKeywords.ts#paletteNavEntryHit (a `group`'s label or `keywords` find the visible entries under it, the group keyword named when only it matched)",
"note": "LIVE (#39055): search aliases on a navigation entry, `keywords: string[]`, declared on the shared nav base (#39052; a separator refuses it with its own prescription), named `keywords`, not `aliases`, because `aliases` is the retired-key rename map across packages/spec/src/ai/*.zod.ts. The per-locale half is the translation bundle's `apps.<app>.navigation.<id>.keywords`, keyed by the same entry id as `label`. A locale's list ADDS to the source list, never replaces it (seat ruling 7347779833 (a), after ADR-0149 D1): `translateApp` merges the two at the /meta boundary, so the console reads one list and resolves no bundle itself. The command palette finds an `object`, `dashboard`, `page`, `report`, `component` or `url` entry by any of them and, when only an alias matched, shows 「原名 X」 beside the entry. A `group`'s keywords (a renamed group's old name) find the visible entries under it, each with the hint. An `action` or `doc` entry accepts the key (it is on the shared nav base) but NOTHING READS IT there yet (#39168); the grade is `live` because the six kinds and groups are read. `authorWarn` stays OFF: the key now has its reader, and an author is never warned for writing it."
},
"icon": {
"status": "live",
Expand Down
2 changes: 1 addition & 1 deletion packages/spec/liveness/state-counts/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them.

| Type | live | exp | elsewhere | dead | planned | classified |
|---|---|---|---|---|---|---|
| `app` | 53 | 0 | 0 | 0 | 7 | 60 |
| `app` | 54 | 0 | 0 | 0 | 6 | 60 |
4 changes: 2 additions & 2 deletions packages/spec/liveness/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"apps": {
"status": "live",
"verifiedAt": "2026-08-28",
"evidence": "packages/spec/src/system/i18n-resolver.ts#lookupAppAttr (`apps.<name>.label` / `.description`); packages/spec/src/system/i18n-resolver.ts#lookupNavLabel (`apps.<name>.navigation.<id>.label`); packages/rest/src/rest-server.ts#translateMetaItem (the /meta read path that applies it — dispatches through `translateMetadataDocument` to `translateApp`)",
"note": "translateApp swaps app label/description and walks the navigation tree replacing node labels by id — applied on every /meta app read. 2026-08-28: RE-ANCHORED (commit 8f10a79f7) and REPOINTED, both legs — `i18n-resolver.ts:442` had rotted onto a PARAMETER in `lookupActionResultDialogNode`'s signature, and `rest-server.ts:2001` onto a blank line in the Server-Timing disclosure gate ~570 lines from the translate seam. The rest leg is also named more honestly than the note was: this repo has NO `translateApp` call site — the REST layer calls `translateMetaItem`, which reaches `translateApp` through the per-type translator map in `translateMetadataDocument`. Re-closed by hand against 8cb96ec41. 2026-12-02 (#39052): the navigation node gained `keywords` (`apps.<app>.navigation.<id>.keywords`, this locale's search aliases for the entry). It sits below this row's walk boundary, so it inherits this row's `live` verdict without being read: its reader is the command palette card #39055, and the nav item's own key is graded `planned` on app.json's `navigation.children.keywords`, which carries the record."
"evidence": "packages/spec/src/system/i18n-resolver.ts#lookupAppAttr (`apps.<name>.label` / `.description`); packages/spec/src/system/i18n-resolver.ts#lookupNavLabel (`apps.<name>.navigation.<id>.label`); packages/rest/src/rest-server.ts#translateMetaItem (the /meta read path that applies it — dispatches through `translateMetadataDocument` to `translateApp`); packages/spec/src/system/i18n-nav-keywords.ts#mergeNavKeywords (`apps.<name>.navigation.<id>.keywords`, added to the node's own keywords)",
"note": "translateApp swaps app label/description and walks the navigation tree replacing node labels by id — applied on every /meta app read. 2026-08-28: RE-ANCHORED (commit 8f10a79f7) and REPOINTED, both legs — `i18n-resolver.ts:442` had rotted onto a PARAMETER in `lookupActionResultDialogNode`'s signature, and `rest-server.ts:2001` onto a blank line in the Server-Timing disclosure gate ~570 lines from the translate seam. The rest leg is also named more honestly than the note was: this repo has NO `translateApp` call site — the REST layer calls `translateMetaItem`, which reaches `translateApp` through the per-type translator map in `translateMetadataDocument`. Re-closed by hand against 8cb96ec41. 2026-12-02 (#39052): the navigation node gained `keywords` (`apps.<app>.navigation.<id>.keywords`, this locale's search aliases for the entry). It sits below this row's walk boundary and inherits this row's `live` verdict. 2026-12-02 (#39055): it is READ — `translateApp` serves each node's own `keywords` plus the first locale list along the chain (`i18n-nav-keywords.ts#mergeNavKeywords`; a locale's list ADDS to the source list, never replaces it, seat ruling 7347779833 (a)), and the console command palette matches the served list; the nav item's own key is graded `live` on app.json's `navigation.children.keywords`, which carries the record."
},
"messages": {
"status": "live",
Expand Down
49 changes: 49 additions & 0 deletions packages/spec/src/system/i18n-nav-keywords.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* A navigation entry's search aliases for the reader's locale — the add rule
* (#39055, seat ruling 7347779833 (a), following ADR-0149 D1).
*
* An entry's `keywords` (`ui/app.zod.ts`) are source-language words, as
* authored. A translation bundle node `apps.<app>.navigation.<id>.keywords`
* gives one locale's own. The match set for the entry is the source list PLUS
* the current locale's list: a locale's words never replace the source words,
* so an English source alias still finds the entry in a zh session, and a
* zh-only alias joins it there and nowhere else.
*
* "The current locale's list" is the first list found along the locale chain,
* the same rung order a translated label takes ({@link translateApp} walks
* the chain and stops at the first locale that answers).
*
* Bundle keywords are not translations of the source list — they are further
* words for the same entry — so ADR-0146 D2's changed/unchanged question,
* which picks the catalog a TRANSLATED string is read from, does not drop
* them when an override changes the source list: they are read from the
* unchanged catalog (the override pair's, then the deployment's, locale by
* locale), and the override's own list is always the source half.
*
* Internal to `@objectstack/spec`: {@link translateApp} is the one caller.
*/

/** The non-empty strings of an authored or bundled `keywords` value, or `undefined` when it holds none. */
function keywordList(value: unknown): string[] | undefined {
if (!Array.isArray(value)) return undefined;
const words = value.filter((word): word is string => typeof word === 'string' && word.length > 0);
return words.length > 0 ? words : undefined;
}

/**
* The entry's merged `keywords`: `source` first, then the first non-empty
* list among `localeNodes` (the bundle's nav nodes for this entry, one per
* locale of the chain, in chain order), each word once. `undefined` when the
* bundle adds nothing, so the caller leaves the node's own key as it is.
*/
export function mergeNavKeywords(source: unknown, localeNodes: Iterable<unknown>): string[] | undefined {
let added: string[] | undefined;
for (const node of localeNodes) {
added = node !== null && typeof node === 'object' ? keywordList((node as { keywords?: unknown }).keywords) : undefined;
if (added) break;
}
if (!added) return undefined;
return [...new Set([...(keywordList(source) ?? []), ...added])];
}
92 changes: 92 additions & 0 deletions packages/spec/src/system/i18n-resolver.nav-keywords.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* Pin: `translateApp` serves a navigation entry's search aliases for the
* reader's locale under the add rule (#39055, seat ruling 7347779833 (a),
* after ADR-0149 D1): the entry's own source-language `keywords` PLUS the
* locale's bundle `apps.<app>.navigation.<id>.keywords`, never one in place
* of the other. The command palette reads the merged list off the served app
* and resolves no bundle itself.
*/
import { describe, it, expect } from 'vitest';
import { translateApp } from './i18n-resolver';
import type { TranslationBundle } from './translation.zod';

const app = {
name: 'setup_39055',
label: 'Setup',
navigation: [
{
id: 'group_people_org',
type: 'group',
label: 'People & Organization',
children: [
{ id: 'nav_position_members', type: 'object', objectName: 'sys_position_member', label: 'Position Members', keywords: ['Position Holders'] },
{ id: 'nav_business_units', type: 'object', objectName: 'sys_business_unit', label: 'Business Units' },
],
},
],
};

const bundle: TranslationBundle = {
'zh-CN': {
apps: {
setup_39055: {
navigation: {
group_people_org: { label: '人员与组织' },
nav_position_members: { label: '岗位成员', keywords: ['岗位持有人', 'Position Holders'] },
nav_business_units: { label: '业务单元', keywords: ['部门', '组织架构'] },
},
},
},
},
en: {
apps: {
setup_39055: {
navigation: {
nav_position_members: { label: 'Position Members' },
},
},
},
},
};

const leaf = (out: typeof app, index: number) => out.navigation[0].children[index] as { label: string; keywords?: string[] };

describe('translateApp — a nav entry\'s keywords follow the locale under the add rule (#39055)', () => {
it('zh-CN: the locale\'s words are added after the source words, each once', () => {
const out = translateApp(app, bundle, { locale: 'zh-CN' });
expect(leaf(out, 0).label).toBe('岗位成员');
expect(leaf(out, 0).keywords).toEqual(['Position Holders', '岗位持有人']);
});

it('zh-CN: an entry with no source words gets the locale\'s words', () => {
const out = translateApp(app, bundle, { locale: 'zh-CN' });
expect(leaf(out, 1).keywords).toEqual(['部门', '组织架构']);
});

it('en: a zh-only word is not served; the source words stay as authored', () => {
const out = translateApp(app, bundle, { locale: 'en' });
expect(leaf(out, 0).keywords).toEqual(['Position Holders']);
expect(leaf(out, 1).keywords).toBeUndefined();
});

it('the first locale along the chain that lists words is the one added', () => {
const out = translateApp(app, bundle, { locale: 'fr', fallbackChain: ['zh-CN'] });
expect(leaf(out, 1).keywords).toEqual(['部门', '组织架构']);
});

it('a group node takes keywords the same way', () => {
const withGroupWords: TranslationBundle = {
'zh-CN': { apps: { setup_39055: { navigation: { group_people_org: { label: '人员与组织', keywords: ['组织'] } } } } },
};
const out = translateApp(app, withGroupWords, { locale: 'zh-CN' });
expect((out.navigation[0] as { keywords?: string[] }).keywords).toEqual(['组织']);
});

it('does not mutate the input app', () => {
const snapshot = JSON.parse(JSON.stringify(app));
translateApp(app, bundle, { locale: 'zh-CN' });
expect(app).toEqual(snapshot);
});
});
14 changes: 14 additions & 0 deletions packages/spec/src/system/i18n-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import { flowScreenFieldOptionKey } from '../automation/flow-screen-option-key.j
import { pageComponentSlotPositions } from '../ui/component.zod.js';
import { templateSlotSource } from '../automation/flow-text-slot-template.js';
import { PLATFORM_LOCALE_TAGS, platformLocaleTagOf } from './platform-locales.js';
import { mergeNavKeywords } from './i18n-nav-keywords.js';

import type {
PlatformTranslationBundle,
Expand Down Expand Up @@ -2205,6 +2206,13 @@ function packagedNavNodes(base: Record<string, unknown> | undefined): (id: strin
* reads only the pair's translations and otherwise keeps its own text; a
* string it left alone takes the pair's translation, then the base's. No base
* supplied: the catalog applies to every string, as before.
*
* ## A navigation node's `keywords` — the add rule
*
* A node's search aliases are its own source-language `keywords` plus the
* reader's locale's `apps.<app>.navigation.<id>.keywords`, never one in place
* of the other ({@link mergeNavKeywords}), so the served app already carries
* the match set the command palette reads.
*/
export function translateApp<T extends AppLike>(
doc: T,
Expand Down Expand Up @@ -2232,6 +2240,12 @@ export function translateApp<T extends AppLike>(
const changed = valueOverridesPackagedBase(packagedNode(node.id), 'label', node.label);
const translated = lookupNavLabel(catalogFor(catalogs, changed), appName, node.id, opts);
if (translated) next.label = translated;
const navId = node.id;
const keywords = mergeNavKeywords(
node.keywords,
localeChain(opts).map((code) => pickData(catalogs.unchanged, code)?.apps?.[appName]?.navigation?.[navId]),
);
if (keywords) next.keywords = keywords;
}
if (Array.isArray(node.children)) {
next.children = node.children.map(translateNav);
Expand Down
Loading
Loading