Repository navigation
Commit a931063
feat(console-ai): the AI assistant is one right-side drawer, opened from the top-bar robot and maximized in place (#34665)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_
Fixes #34608
Clause-②: yes (widening — new @object-ui/i18n locale keys only)
Metadata-protocol: none
ADR: the ui ADR-0057 amendment this implements is #34640 (Amendment A3,
docs only, Tier H).
## 维护者速读
- 改了什么:AI 助手只剩右侧抽屉这一个容器。顶栏机器人在当前页开关抽屉,URL
不变;右下角浮动按钮去掉。抽屉的「放大」是原地铺满整个窗口,左侧多一列历史,同一个按钮收回;侧栏宽度时历史在「History」按钮后面。Home
也有同一个抽屉。Home 的「用 AI 搭建 / 问 AI」和应用管理的「用 AI 编辑」改为打开抽屉。旧的
`/ai`、`/ai/build/<id>`
链接(包括分享链接)打开抽屉并铺满,显示链接指向的会话。应用内搭建者的空状态同时给出「问数据」和「改应用」的引导。
- 为什么改:#34608
的裁定「同意」:一个右侧抽屉,原地放大可收回,入口只有顶栏机器人,旧链接重定向到打开的抽屉。新搭建仍然先不绑定应用(ADR-0057 A1
保留)。
- 风险与回滚:只改控制台前端(app-shell、console、i18n 新键),不动元数据、契约和服务端。`/ai`
路由保留,书签和分享链接继续可用。抽屉显示哪个会话存在本标签页的 sessionStorage,不进 URL。回滚即 revert 本
PR。改动行数 3214,超过 3000 行的人工合并阈值,主要是重写抽屉主体和删除浮动按钮的旧测试。
- 先看:①
`ui/packages/app-shell/src/layout/useConsoleChatDock.tsx`(抽屉托管:开关、放大、目标、交接、快捷键);②
`layout/ChatDock.tsx` 的 `ChatDockPanel`(同一个 aside 切换 `fixed
inset-0`,历史按钮)和 `layout/ChatDockConversation.tsx`(按目标解析会话、历史列);③
`console/ai/AiAddressRedirect.tsx` 和 `ui/apps/console/src/App.tsx` 的
`/ai` 路由。
- 两分钟验证:在仓根执行 `pnpm --dir ui exec vitest run
packages/app-shell/src/layout/__tests__/ConsoleLayout.robotTogglesDrawer-34608.test.tsx
packages/app-shell/src/layout/__tests__/ChatDock.test.tsx
packages/app-shell/src/console/ai/__tests__/AiAddressRedirect-34608.test.tsx
packages/app-shell/src/console/ai/__tests__/AiChatPage.appContextComposer-11658.test.tsx`,预期全部通过(对应验收
1 到 4)。
- 需要你做的:先审批 ADR PR #34640(Tier H)。本 PR 超过人工合并阈值,需要你来合并。
## Before and after
| | Before (`origin/main` 97defd6) | After |
|---|---|---|
| Top-bar robot | `<Link to="/ai">`: leaves the page for the full-page
chat | Toggles the drawer on the current page; `aria-pressed` follows
it; the URL does not change |
| Bottom-right floating button | Shown while the dock is closed; carried
the plan-pending marker | Removed; the robot carries the marker |
| Maximize | Navigated to `/ai` or `/ai/build?package=PKG` | The same
`<aside>` becomes `fixed inset-0 z-40` in place (no remount); the same
button restores |
| History | Only on the `/ai` page | Rail: behind a "History" button.
Full window: a column beside the chat. Phone sheet: a "History" button |
| Home | Floating button to the full page; no dock | Hosts the same
drawer |
| `/ai`, `/ai/:agent`, `/ai/:agent/:id` | The full-page chat | Open the
drawer on that address, filling the window, over the declared home |
| "Build with AI" / "Ask AI" (Home), "Edit with AI" (app management) |
Navigated to `/ai/build…` / `/ai/ask` | Open the drawer on that agent /
package / fresh thread |
| Builder empty state inside an app | Change guidance only; change
starters | Names data questions and changes; the first two starters are
data questions |
| Share in the dock | No-op (`onShare` unwired) | Opens the share dialog
|
## What changes
**The drawer host.** New `layout/useConsoleChatDock.tsx`, mounted by
both `ConsoleLayout` and `HomeLayout`. It owns:
- The dock state: `useChatDockState` with the per-tab expanded flag and
a new per-tab full-window flag.
- The drawer's target, a `ChatDockTarget` (`agent`, `conversationId`,
`packageId`, `fresh`) kept in sessionStorage. Absent means the ambient
thread, so the existing app binding (A2) is unchanged.
- A Builder handoff held in memory with a sequence number
(objectui#12493).
- The ⌘/Ctrl+Shift+I toggle and the assistant-bus open request.
- Leaving the page (pathname or search changes) drops full window back
to the rail.
It returns the rail (for `AppShell`'s `rightRail`), the phone sheet, and
a `ChatDockControl` handle provided through `ChatDockControlProvider`.
**Opening the drawer.** New `layout/chatDockControl.tsx`:
`useChatDockControl()` and `useOpenAssistant()`. `useOpenAssistant`
opens the drawer in place inside a host. Outside one (a page no host
wraps) it navigates to the old address, which the console routes back
into the drawer. `ChatPane`'s agent launcher, package switcher, "New
app" and "Open in Builder" go through it. Inside the drawer a nested
provider maps those calls onto the drawer's target.
**The target grammar.** New React-free `layout/chatDockTarget.ts`:
`parseAiAddress`, `aiAddressOf`, the target and full-window storage
helpers (no-ops inside a frame, objectstack#26470), `sameDockTarget`,
and `readBuilderHandoffState` (moved from `AiChatPage`).
**The panel.** `layout/ChatDock.tsx`:
- `useChatDockState` gains `fullWindow` and `setFullWindow`. Setting it
expands the drawer; `toggle` and `collapse` clear it. It persists with
`persistFullWindow`.
- `ChatDockPanel`: with `fullWindow` the same `<aside>` switches to
`fixed inset-0 z-40` with no width or resize handle. The expand button
(`chat-dock-maximize`, "Expand" / "Restore side panel") calls
`setFullWindow`. A History toggle shows at rail width.
- `ChatDockMobileSheet`: the deferred maximize bridge is removed; it
gets a History toggle.
- `onMaximize` and `onBoundPackageChange` are removed. The Live Canvas
`maximize()` / `restore()` latch is unchanged.
**The body.** `layout/ChatDockConversation.tsx` resolves its agent and
conversation from the target:
- A named agent through `resolveAgentParam`. A legacy bare conversation
id is resolved to its agent through `fetchConversation`.
- A maker opening a bare `ask` is converged to `build` (cloud#1674).
- `forceNew` for a fresh target. The minted id is written back to the
target once the first send creates it.
- A1.b bind-on-create re-keys the scope and names the package on the
target.
- The handoff is seeded once per sequence.
- Full window draws `ConversationsSidebar` as a column. Rail and sheet
draw it as an overlay over the still-mounted pane.
- The share dialog and the build debug drawer are wired.
**History.** `console/ai/ConversationsSidebar.tsx` gets a hosted mode
(`onSelectConversation`, `onNewConversation`, `activeConversationId`):
rows, "New" and deleting the open thread call back instead of
navigating.
**Entries.**
- New `layout/AssistantTopBarButton.tsx` replaces AppHeader's robot
link. With a host it is a toggle; without one it is still a link to
`/ai`.
- `HomePage` and `AppManagementPage` use `useOpenAssistant`.
- `ConsoleChatbotFab.tsx` and its two test files are deleted.
**Addresses.** New `console/ai/AiAddressRedirect.tsx` writes the parsed
target, the expanded flag and the full-window flag, then replaces the
visit with `useHomePath()`, passing a handoff on as navigation state.
`ui/apps/console/src/App.tsx` routes the three `/ai` paths to it inside
`RequireAiSurface`. The lazy `DefaultAiChatPage` and
`components/aiChatPage.ts` are removed. `AiChatPage` stays exported; the
console no longer routes to it.
**Guidance.** `agentEmptyState`'s edit-mode description reads
`console.ai.empty.editApp.askOrChangeDescription`. The new exported
`editAppDataSuggestions(t)` puts two data questions ahead of the change
starters when editing.
**i18n.** New keys in all 11 packs: `console.ai.dock.history`,
`.backToChat`, `.expand`, `.restore`,
`console.ai.empty.editApp.askOrChangeDescription`. No key removed or
changed.
## Tests
New:
- `layout/__tests__/ConsoleLayout.robotTogglesDrawer-34608.test.tsx`
(replaces `ConsoleLayout.fabYieldsToOpenDock-10899`): real
`ConsoleLayout`, host, dock state and robot. The robot opens the drawer
on `/apps/crm/opportunity` with the URL unchanged, closes it again, and
no floating button exists. **Acceptance 1.**
- `layout/__tests__/ChatDock.test.tsx`: expand asks for full window, the
full panel is `fixed inset-0` with no resize handle and a "Restore side
panel" button that restores. The same `<aside>` and the same body
element survive the switch (no remount). The rail's History toggle and
the full window's column (no toggle). The sheet has no expand button and
has a History toggle. `useChatDockState` full-window semantics and
persistence. **Acceptance 2.**
- `console/ai/__tests__/AiChatPage.appContextComposer-11658.test.tsx`:
inside an app the build pane's first two suggestions are data questions,
then the change starters, and the empty description names data. A
control with no app. **Acceptance 3.**
- `console/ai/__tests__/AiAddressRedirect-34608.test.tsx`:
`/ai/build/c-42` lands home with the target, expanded and full window
armed. `?package=&new=1` is kept. Bare `/ai` clears an old target. The
declared home is honoured. A handoff rides navigation state and never
storage. **Acceptance 4.**
- `layout/__tests__/ChatDock.appBinding-10926.test.tsx`: a build target
naming app X opened with no app in view resumes the thread the in-app
dock bound to X. A target naming a conversation shows that conversation.
**Acceptance 4.**
- `layout/__tests__/chatDockTarget.test.tsx`: address parsing (mount
prefix, `?agent=`, escapes), `aiAddressOf` round trip, storage round
trip, malformed storage, frame isolation.
- `console/ai/__tests__/ConversationsSidebar.test.tsx`: the hosted mode.
- `console/ai/__tests__/editModeEmptyState.test.ts`: the description and
`editAppDataSuggestions`.
Re-pointed:
- The plan-pending marker pins (`launcherPlanApprovalMarker-11666`,
`AiChatPage.planApprovalReachesLaunchers-11666`) now target the robot.
- `ConsoleLayout.previewFrameDock-26470` presses the robot.
- `ConsoleLayout.dockBinding-10926`'s two maximize-routing cases became
"the target is held per tab and survives a remount" and "back to ambient
clears it".
- Dock-state stubs gained `fullWindow`.
- The console `App.*` tests stub `AiAddressRedirect` where they stubbed
`DefaultAiChatPage`.
Deleted: `ConsoleChatbotFab.test.tsx`,
`ConsoleChatbotFab.yieldsCorner-12248.test.tsx` (the component is gone),
`ConsoleLayout.aiEntryAsksUnsaved-13253.test.tsx` (maximize no longer
leaves the page, so there is nothing to confirm).
## Acceptance notes
- The order lists acceptance 4 as "an old `/_console/ai/build/<id>` link
shows that conversation". The redirect is pinned on the route table's
paths (the router basename strips `/_console`), and the drawer resolving
the conversation is pinned on the real body.
- Moving between apps with a target set (L1 S1, read live on 910dbeb,
comment below): the target is per tab and never infers the app, so it
follows you. A history row names its agent and conversation only (the
server stores no package on a thread), so a build row picked inside CRM
shows with the "New app" chip and stays on that thread after you move to
Setup. A target that names a package (the drawer's app switcher, "Edit
with AI") keeps naming it: after moving from CRM to Setup the chip still
reads "CRM" and the empty state "Editing “CRM”". With no target the
drawer shows the ambient thread of the app in view: "Editing “CRM”" in
CRM, and the unbound "Build with AI" thread in Setup (a built-in app,
not authorable). Before A3, A2 bound the in-app dock to the app in view
in every case; this PR keeps that only for the ambient thread.
- What the drawer shows lives in sessionStorage per tab, not in the URL.
ui ADR-0054 C3 asks for URL reflection where deep-linking matters. The
`/ai…` addresses are that door, as Amendment A3 records.
- Cold boot on an old link: `useHomePath()` answers `/home` until the
app list loads, so the drawer opens over the launcher rather than the
declared app. Both host the same drawer.
- `data-fab-yield` attributes in `plugin-detail` (`InlineEditSaveBar`)
and `RecordAttachmentsPanel` no longer have a reader. Left in place. A
follow-up can remove them.
- `console.ai.dock.maximize` and `console.ai.empty.editApp.description`
are no longer read. They are kept, because the scope is new keys only.
The dead-key report lists the first as needs-review.
- Studio's copilot maximize still navigates to `/ai/build?package=…`. It
now lands on Home with the drawer maximized on that package's thread.
#34610 replaces it with an in-place widen (A3, "One container").
- The `AiChatPage` page component stays exported (17 test files render
it). Unrouting it is a follow-up.
- The composer hint already read 「问问数据,或让我改改这个应用…」 / "Ask about your
data, or ask me to change this app…". I left it as it was.
- Neighbours: no change to `ChatbotEnhanced.tsx` or
`PendingDraftsBar.tsx` (#34609, #34539).
## Verification
Head 910dbeb. Run in a 4-vCPU cloud container.
Tests:
- `pnpm --dir ui exec vitest run packages/app-shell/src/console/ai
packages/app-shell/src/console/home packages/app-shell/src/layout
packages/app-shell/src/chrome
packages/app-shell/src/views/studio-design/__tests__/studioCopilotOpenFullPage-12842.test.tsx
packages/app-shell/src/__tests__/print-stylesheet-4462.test.ts`: 265 of
266 files passed and 1746 tests passed. `chatDockTarget.test.ts` failed
to collect under the node project (`window is not defined`). It is
renamed to `.tsx` in 9c18bb8 and passes (with `ChatDock.test.tsx` and
`ChatDock.appBinding-10926`: 3 files, 34 tests).
- `pnpm --dir ui exec vitest run
packages/app-shell/src/layout/__tests__/ChatDock
packages/app-shell/src/layout/__tests__/ConsoleLayout packages/i18n
apps/console/src/__tests__/App …`: 134 of 135 files passed.
`zh-hant-generated` failed because `zh-Hant.ts` is generated output. It
was regenerated with `pnpm --filter @object-ui/i18n gen:zh-hant` in
9c18bb8 and passes (10 tests).
- After 910dbeb: `KeyboardShortcutsDialog.wiredOnly-11674` and every
`ConsoleLayout.*` test: 10 files, 45 tests, all passed.
- The full app-shell suite was not run: about 2200 files, more than 40
minutes on this box. The affected directories above were run instead.
Type-check and lint:
- `tsc --noEmit` and `tsc -p tsconfig.test.json` in
`ui/packages/app-shell`: exit 0.
- `tsc --noEmit` in `ui/apps/console` after `pnpm --filter
@object-ui/app-shell build`: exit 0.
- `npx eslint` on every changed ui file: 0 errors. The warnings are
pre-existing kinds; the one new `react-hooks/refs` warning was removed.
- `node ui/scripts/check-i18n-call-site-keys.mjs`: exit 0. `node
ui/scripts/check-i18n-en-drift.mjs`: exit 0. `node
ui/scripts/check-i18n-dead-keys.mjs`: exit 0 (a report; it lists
`console.ai.dock.maximize` as needs-review).
Derived gates (`node scripts/pm/dispatch-gates.mjs --commands`, 41
commands, run at d82cadc while 9c18bb8's rename and regeneration
landed; neither touches what a gate reads except test-source-alias,
re-run at 910dbeb):
- `node scripts/check-adr-0087-registration.mjs --base origin/main`:
exit 0
- `node scripts/check-adr-0087-registration.mjs --self-test`: exit 0
- `node scripts/check-changeset-no-major.mjs --base origin/main`: exit 0
- `node scripts/check-closing-keyword-parity.mjs`: exit 0
- `node scripts/check-closing-keyword-parity.mjs --self-test`: exit 0
- `node scripts/check-comment-mask-corpus.mjs`: exit 0
- `node scripts/check-empty-changeset.mjs --base origin/main`: exit 0
- `node scripts/check-empty-changeset.mjs --self-test`: exit 0
- `node scripts/check-sdui-manifest.mjs`: exit 0
- `node scripts/check-sdui-manifest.mjs --self-test`: exit 0
- `node scripts/ci/snapshot-next.mjs --self-test`: exit 0
- `node scripts/pm/check-governed-queue-guard.mjs --self-test`: exit 0
- `node scripts/pm/release-rehearsal-clone.mjs --self-test`: exit 0
- `node scripts/release-pending-publish.mjs --self-test`: exit 0
- `pnpm --dir ui exec vitest run scripts/`: exit 0
- `pnpm --filter @objectstack/spec run check:duration-unit-keys`: exit 0
- `pnpm check:adr-anchors`: exit 0
- `pnpm check:changeset-gate-self-tests`: exit 0
- `pnpm check:closed-ceremony-text`: exit 0
- `pnpm check:cross-package-test-inputs`: exit 0
- `pnpm check:dispatcher-error-vocabulary`: exit 0
- `pnpm check:driver-memory-census`: exit 0
- `pnpm check:engine-double-contract`: exit 0
- `pnpm check:error-status-conformance`: exit 0
- `pnpm check:gitlink-declared`: exit 0
- `pnpm check:merge-driver`: exit 0
- `pnpm check:nul-bytes`: exit 0
- `pnpm check:published-files`: exit 0
- `pnpm check:query-options-erasure`: exit 0
- `pnpm check:refd-timer-probe`: exit 0
- `pnpm check:registry-log-declared`: exit 0
- `pnpm check:rest-log-spy-declared`: exit 0
- `pnpm check:role-word`: exit 0
- `pnpm check:skill-identifier-liveness`: exit 0
- `pnpm check:test-source-alias`: exit 1 on the first run (five edited
layout tests reach `import('@objectstack/lint')` through
`ConsoleLayout`'s draft bar). Fixed in 910dbeb with a module-top
import; re-run exit 0.
- `pnpm check:tier-file-adoption`: exit 0
- `pnpm check:type-check-coverage`: exit 0
- `pnpm check:type-check-debt`: exit 0
- `pnpm check:undeclared-dep-imports`: exit 0
- `pnpm check:watch-hint-literal`: exit 0
- `pnpm check:where-matcher`: exit 0
The gate report puts the change at 3214 changed lines, over the
3000-line human-merge threshold.
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzidTEhaEGRzboS7xTa -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent b1da9f5 commit a931063
58 files changed
Lines changed: 2038 additions & 1192 deletions
File tree
- .changeset
- ui
- apps/console/src
- __tests__
- components
- pages/system
- packages
- app-shell/src
- chrome
- console
- ai
- __tests__
- home
- layout
- __tests__
- i18n/src/locales
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
107 | 103 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | 104 | | |
112 | 105 | | |
113 | 106 | | |
| |||
498 | 491 | | |
499 | 492 | | |
500 | 493 | | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
508 | 501 | | |
509 | 502 | | |
510 | 503 | | |
511 | 504 | | |
512 | | - | |
513 | | - | |
514 | | - | |
| 505 | + | |
| 506 | + | |
515 | 507 | | |
516 | 508 | | |
517 | 509 | | |
518 | | - | |
| 510 | + | |
519 | 511 | | |
520 | 512 | | |
521 | 513 | | |
522 | 514 | | |
523 | | - | |
| 515 | + | |
524 | 516 | | |
525 | 517 | | |
526 | 518 | | |
527 | 519 | | |
528 | | - | |
| 520 | + | |
529 | 521 | | |
530 | 522 | | |
531 | 523 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
94 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
This file was deleted.
0 commit comments