From 50ae770af12145df41d6948d736356375832c598 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 11:07:31 +0000 Subject: [PATCH 1/5] feat(app-shell): design mode menu offers the AI inquiry page entry (WIP) Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cwGVgec21LwQTtRY85 --- .../app-shell/src/layout/DesignModeMenu.tsx | 214 +++++++++++++++++- .../src/layout/designModeMenuModel.ts | 162 ++++++++++++- 2 files changed, 364 insertions(+), 12 deletions(-) diff --git a/ui/packages/app-shell/src/layout/DesignModeMenu.tsx b/ui/packages/app-shell/src/layout/DesignModeMenu.tsx index 9a802bc13ab..cc830e5a128 100644 --- a/ui/packages/app-shell/src/layout/DesignModeMenu.tsx +++ b/ui/packages/app-shell/src/layout/DesignModeMenu.tsx @@ -43,6 +43,15 @@ * (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, the first entry shown being the app's home; + * it writes no `landing`. + * * 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 +113,7 @@ import { MoreVertical, Plus, Search, + Sparkles, Table2, BarChart3, Database, @@ -125,6 +135,7 @@ import { DropdownMenuTrigger, Input, Label, + Textarea, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, @@ -154,12 +165,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 +192,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 +313,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 +587,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 +642,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 +685,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 +911,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 +930,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 +946,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 +1006,7 @@ function useTargetRows(packageId: string, language: string): { rows: TargetRow[] function MenuItemPicker({ packageId, inMenu, + aiChatOffered: aiChatOpen, initialKind = null, onClose, onPick, @@ -955,10 +1015,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 +1055,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 +1072,7 @@ function MenuItemPicker({ {title} - {kind !== 'url' && ( + {kind !== 'url' && kind !== 'aiChat' && (