diff --git a/.changeset/37832-design-mode-menu-ai-inquiry-entry.md b/.changeset/37832-design-mode-menu-ai-inquiry-entry.md new file mode 100644 index 00000000000..b46ceda948a --- /dev/null +++ b/.changeset/37832-design-mode-menu-ai-inquiry-entry.md @@ -0,0 +1,17 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +--- + +feat(app-shell): 「Design layout」's menu adds the app's AI inquiry page, and 「Set as home」 makes it the app's home + +Clause-②: no +Metadata-protocol: none + +The design mode's menu picker gains 「AI inquiry」, which adds the app's AI inquiry page: a `type: 'component'` navigation entry whose `componentRef` is `ai:chat`. Like 「Link」 it lists nothing. A small form takes the entry's name and the page's copy (heading, subtitle, question-box hint, and up to four suggested questions, one per line); a field left empty keeps the page's default text. The form refuses, under the field, what `AiChatNavParamsSchema` refuses, and cannot be sent until it is mended. An app carries at most one such entry, so the kind is not offered once the app has one, nested in a group included, or when its stored menu holds one the reader is not shown. + +That entry's 「⋮」 menu gains 「Edit inquiry page」, which edits the same copy again, and 「Set as home」, which moves the entry to the first place of the top level. The home follows the app's existing landing rule: a declared `landing` comes first; with none, from 768 px up the first entry shown lands; below 768 px the app root is the app's menu, where the entry becomes its first row. So the move is the whole edit: no `landing` is written, and an app that declares `landing` keeps landing where it declares. + +The entry is saved like every other menu edit: into the app's own package when it is writable, else into its customization package, and published at once. Who sees it is set in Studio, as for every entry. `@object-ui/i18n` carries the new strings in all eleven locales. + +Nothing to migrate. diff --git a/ui/packages/app-shell/src/layout/DesignModeMenu.tsx b/ui/packages/app-shell/src/layout/DesignModeMenu.tsx index 9a802bc13ab..f70337314fa 100644 --- a/ui/packages/app-shell/src/layout/DesignModeMenu.tsx +++ b/ui/packages/app-shell/src/layout/DesignModeMenu.tsx @@ -43,6 +43,17 @@ * (objectstack#36538, review N9), since the save could put such an entry * nowhere but the end of the stored menu. * + * The picker's 「AI inquiry」 (objectstack#37832) adds the app's AI inquiry + * page, an `ai:chat` component entry (ui ADR-0057 Amendment A4). Like a link + * it lists nothing: a small form takes the entry's name and the page's copy, + * judged by `AiChatNavParamsSchema` as typed (`aiChatParamsOf`). An app has at + * most one, so the kind is not offered once the app has one (`aiChatOffered`). + * That entry's 「⋮」 edits the copy again, and 「Set as home」 moves it to the + * first place of the top level, and writes no `landing`. The home follows the + * app's landing rule (ui ADR-0057 Amendment A4): a declared `landing` comes + * first; with none, from 768 px up the first entry shown lands; below 768 px + * the app root is the app's menu, where the entry is its first row. + * * In the picker's 「Dashboards」, the first row is 「New dashboard…」 * (objectstack#36364): it asks for a name, and on 「Create」 the dashboard is * created, empty, where the menu is saved, its entry takes the dashed row's @@ -104,6 +115,7 @@ import { MoreVertical, Plus, Search, + Sparkles, Table2, BarChart3, Database, @@ -125,6 +137,7 @@ import { DropdownMenuTrigger, Input, Label, + Textarea, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, @@ -154,12 +167,18 @@ import { import { useDesignModeChange, useDesignModeOpening } from './designMode.js'; import { MENU_TARGET_KINDS, + aiChatFormOf, + aiChatOffered, + aiChatParamsOf, + asHome, + canBeHome, canMoveBy, entryFor, entryOf, groupsOf, inShownOrder, insertEntry, + isAiChatEntry, isGroup, menuTargets, moveBy, @@ -175,9 +194,12 @@ import { withOwnBeforeForeignRuns, type Menu, labelGoesToTranslation, + type AiChatForm, + type AiChatFormIssue, type MenuEntry, type MenuTargetKind, } from './designModeMenuModel.js'; +import type { AiChatNavParams } from '@objectstack/spec/ui'; import { consoleAppMenuDoors, fetchDeploymentLocales, @@ -293,6 +315,8 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso const [addAt, setAddAt] = React.useState(null); const [renaming, setRenaming] = React.useState(null); + /** The AI inquiry page entry whose copy is being edited (objectstack#37832). */ + const [editingCopy, setEditingCopy] = React.useState(null); // The stored menu and the deployment's languages, for where a rename lands // (objectstack#36504); both `undefined` while read. @@ -565,6 +589,15 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso onAddAfter={() => place && startAdd({ parentId: place.parentId, index: place.index + 1 })} onRename={() => setRenaming(id)} onRemove={() => update(removeEntry(menu, id))} + aiChat={ + isAiChatEntry(entry) + ? { + canBeHome: canBeHome(menu, id), + onEditCopy: () => setEditingCopy(id), + onSetHome: () => update(asHome(menu, id)), + } + : undefined + } /> } /> @@ -611,6 +644,7 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso }; const renamed = renaming ? entryOf(menu, renaming) : null; + const copyEdited = editingCopy ? entryOf(menu, editingCopy) : null; /** * The language a name typed for the entry `id` is a translation in, or * `null` when it is the stored label (objectstack#36504): the save's own @@ -653,13 +687,26 @@ export default function DesignModeMenu({ app, basePath, resolveTargetLabel, reso pick(entryFor(kind, name, newEntryId([...menu, ...(storedMenu ?? [])]), link))} + onPick={(kind, name, link, params) => + pick(entryFor(kind, name, newEntryId([...menu, ...(storedMenu ?? [])]), link, params)) + } onCreate={createItem} language={language} /> )} + {copyEdited && ( + setEditingCopy(null)} + onDone={(params) => { + update(patchEntry(menu, String(copyEdited.id), { params })); + setEditingCopy(null); + }} + /> + )} {renamed && ( void; onRename: () => void; onRemove: () => void; + /** The AI inquiry page entry's own actions (objectstack#37832); absent for every other entry. */ + aiChat?: { canBeHome: boolean; onEditCopy: () => void; onSetHome: () => void }; }) { const { t } = useObjectTranslation(); return ( @@ -863,6 +913,16 @@ function EntryActions({ {t('designMode.menu.rename', { defaultValue: 'Rename and icon' })} + {aiChat && ( + <> + + {t('designMode.menu.aiChatEdit', { defaultValue: 'Edit inquiry page' })} + + + {t('designMode.menu.setAsHome', { defaultValue: 'Set as home' })} + + + )} {t('designMode.menu.remove', { defaultValue: 'Remove from menu' })} @@ -872,8 +932,8 @@ function EntryActions({ ); } -/** The metadata type each picked kind lists (a link lists nothing). */ -const KIND_METADATA: Record, string> = { +/** The metadata type each picked kind lists (a link and the AI inquiry page list nothing). */ +const KIND_METADATA: Record, string> = { object: 'object', view: 'view', dashboard: 'dashboard', @@ -888,6 +948,7 @@ const KIND_ICON: Record>) { + for (const kind of Object.keys(KIND_METADATA) as Array) { const seen = new Set(); for (const pkg of packages) { let listed: Array>; @@ -947,6 +1008,7 @@ function useTargetRows(packageId: string, language: string): { rows: TargetRow[] function MenuItemPicker({ packageId, inMenu, + aiChatOffered: aiChatOpen, initialKind = null, onClose, onPick, @@ -955,10 +1017,12 @@ function MenuItemPicker({ }: { packageId: string; inMenu: ReadonlySet; + /** Whether 「AI inquiry」 is offered: the app has no AI inquiry page yet (objectstack#37832). */ + aiChatOffered: boolean; /** The kind the picker opens on (objectstack#36907); `null`: the list of kinds. */ initialKind?: MenuTargetKind | null; onClose: () => void; - onPick: (kind: MenuTargetKind, name: string, link?: { label: string; url: string }) => void; + onPick: (kind: MenuTargetKind, name: string, link?: { label: string; url: string }, params?: AiChatNavParams) => void; /** Create a new `kind` named `label`; `taken` is every name of that kind the picker lists. */ onCreate: (kind: NewMenuItemKind, label: string, taken: readonly string[]) => Promise; language: string; @@ -993,6 +1057,7 @@ function MenuItemPicker({ report: t('designMode.menu.kind.report', { defaultValue: 'Reports' }), page: t('designMode.menu.kind.page', { defaultValue: 'Pages' }), url: t('designMode.menu.kind.url', { defaultValue: 'Link' }), + aiChat: t('designMode.menu.kind.aiChat', { defaultValue: 'AI inquiry' }), }; const kindText = (k: MenuTargetKind) => kindTexts[k]; const q = query.trim().toLowerCase(); @@ -1009,7 +1074,7 @@ function MenuItemPicker({ {title} - {kind !== 'url' && ( + {kind !== 'url' && kind !== 'aiChat' && (