Repository navigation
Commit 14619f5
feat(console-ai): an AI build shows the app itself in the main area, with one Publish on screen (#34713)
<!-- 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 #34610
Implements ui ADR-0057 Amendment A3 and ADR-0037 as amended (#34640,
merged), on top of #34665 (merged). Ruling 6937505798 on #34610.
## 维护者速读
- 改了什么:用 AI 搭建时,聊天留在右侧抽屉,主区域直接显示正在搭建的应用,并随每个草稿件原地刷新。嵌套的 Live Canvas
iframe 和分屏去掉了。新应用(已物化、未上架)按 ADR-0045 显示为真实应用,由「尚未发布」条发布;已发布应用的改动在
`?preview=draft`
中显示,由草稿栏发布。整屏只有一个发布按钮,聊天里不再有发布按钮,只给指引,发布后在聊天里显示回执。计数统一为当前应用的待发布改动(应用包加上它的
ADR-0146 定制包)。Studio 副驾的放大改为原地加宽,不再跳到 `/ai/build`。
- 本轮修复(L1-b REWORK 6943358263 的实机读数中发现):代码安装的应用(如 CRM)改动落在
`<base>.custom` 定制包,按单包计数会读成 0;新应用「尚未发布」条的发布按路由段(包
id)保存被服务端拒绝;同一对象在后续回合再次起草时主区域不进草稿模式;搭建结果卡仍写着「在聊天里点发布」。四处都已修复并加了测试。
- 为什么改:#34610 的「同意」裁定(6937505798);ADR 依据 #34640(A3「Building」「One publish
control」「One container」)。
- 风险与回滚:只改控制台前端(app-shell、plugin-chatbot 一个可选 prop、i18n
新键),不动元数据、契约和服务端。回滚即 revert。
- 先看:`console/ai/mainAreaDraft.ts`(主区去向与两种发布形态)、`AiChatPage.tsx` 的
ChatPane
主区块(只在进行中的回合移动、跨页移动等回合结束)、`PendingDraftsBar.tsx`、`preview/DraftPreviewBar.tsx`(按包计数、按包发布、不再整页刷新)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/console/ai/__tests__/mainAreaDraft-34610.test.ts
packages/app-shell/src/console/ai/__tests__/AiChatPage.draftInMainArea-34610.test.tsx
packages/app-shell/src/console/ai/__tests__/PendingDraftsBar.test.tsx
packages/app-shell/src/preview/__tests__/DraftPreviewBar.test.tsx
packages/app-shell/src/views/studio-design/__tests__/studioCopilotWidenInPlace-34610.test.tsx`,预期全部通过。
## What changes
**The app shows in the main area** (`console/ai/mainAreaDraft.ts`,
`AiChatPage.tsx`)
- `mainAreaDraftMove(target, here, inPlace)` decides where the main area
goes. It stays on the current page when the drawer sits beside the app
being built, and otherwise opens `/apps/<package>`. Changes to a
published app get `?preview=draft`. A materialized build shows the real
app, and if it leaves draft mode the sticky preview keeper is told
(`markPreviewExit`).
- ChatPane moves the main area only for drafts reported during a turn it
is streaming:
- a move to another page waits for the turn to end, so the stream in
flight is not cut;
- a conversation reopened from history moves nothing;
- a new build moves in only after its package binds (A1).
- Each drafted artifact emits one coalesced `emitCanvasInvalidate` per
type (200 ms), the per-artifact refresh of ADR-0037 Phase 2.
`emitMetadataRefresh` runs once more when the turn ends.
- Removed: `LiveCanvas.tsx`, the split pane, the resizable chat width,
the mobile canvas pill and overlay. The dock's auto-maximize latch
(`maximize`/`restore`, driven by the canvas) is removed from
`ChatDock.tsx` and `ChatDockConversation.tsx`.
**One Publish on screen**
- `ChatbotEnhanced` takes `publishFromShellBar`. When set, the draft
cards draw no Publish; Preview, the Published badge and auto-publish
stay.
- `PendingDraftsBar` no longer publishes. While the main area shows this
package's draft it says "N unpublished changes. Publish them from the
draft bar at the top." Otherwise it offers **Show draft**.
- A publish from the draft bar or the unpublished-app bar emits
`emitPublishReceipt` (assistant bus). The chat shows "Published. Your
changes are live." until drafts are pending again or the receipt is
dismissed.
**One count, two wordings**
- **Scope = the app's package plus its ADR-0146 customization pair.**
`DraftPreviewBar`, its `DraftChangesPanel` and the chat count one app's
drafts: those whose package is the app's package or its pair
`<base>.custom` (`appDraftPackages` in `preview/usePendingDrafts.ts`,
built on the spec's `customizationPackageId` /
`customizationBasePackageId`). They read the env-wide `_drafts` and
filter, because the pair may not be installed and `?package=` refuses a
package that is not. A code-shipped app's edits are drafted into the
pair, so a count scoped to the base alone read 0 (measured live, below).
Another app's drafts and package-less drafts are not counted.
- The bar's separate "on this page" count is gone (`draftSurface.ts`
keeps only the deep-link path).
- The draft bar publishes that app (`publishAll({ packageId })`: the
base and the pair, each through its own `publish-drafts`) and no longer
reloads the page, so the drawer conversation and the receipt survive.
The chat matches a receipt by the base package, so a receipt for the
pair is the same app's.
- On a page outside any app (no route app) the bar counts and publishes
environment-wide, as before, with the older generic wording: there is no
app to scope to.
- New wordings: `preview.unpublishedBar.notPublishedYet` ("This app is
not published yet…") and `preview.draftBar.pendingInApp` ("N unpublished
changes in this app", with plural forms).
**Fixed in this round, found by the live readings**
- `UnpublishedAppBar` saved the app under the route segment. For every
app the AI builds that segment is the package id (ADR-0048), and the
meta door refuses an app whose `name` disagrees with its key, so Publish
on a new app failed. It now saves under the app's own `name`.
- An edit that re-drafts an artifact the conversation already listed
(the object a build made, edited in the next turn) never reached
`onDraftArtifacts`, whose set only fires when it grows. The main area
stayed out of draft mode with the edit pending. A finished live turn now
reads its own draft review (`turnDraftPackage`), moves the main area to
that app, and refreshes the drafted types.
- The build result card's footer still said "click Publish here in the
chat". Under `publishFromShellBar` that sentence is not drawn.
**Studio copilot**
- Expand widens the copilot's slot in place (`StudioRightSlot`
`wideWidth`) and the same button restores. It no longer navigates to
`/ai/build?package=…` (A3 "One container").
- Without a drawer host there is no main area to move, so the copilot's
cards draw no Preview, and Studio's own top bar publishes.
**i18n.** New keys in all 11 packs (zh-Hant regenerated):
`preview.draftBar.pendingInApp`,
`preview.unpublishedBar.notPublishedYet`, and
`console.ai.pendingDrafts.publishFromBar` / `showDraftToPublish`
(plurals), `showDraft`, `receipt`, `dismissReceipt`. No existing value
changed. The changeset lists the keys the console no longer reads.
## Why
Ruling 6937505798 on #34610: "the build happens in the same right drawer
with the app draft itself in the main area; no nested preview; one
publish button and one change count." #34640's contract review added the
ADR-0045 regimes (a new app is materialized and published by its own
bar) and the Studio in-place maximize.
## Verification
- **Live readings (L1-b M1)** on head `2621daf5`, from a booted console
(Vite dev server over a fresh CRM example backend), standing in only for
`/api/v1/ai/**`. The stand-in streams a real UI-message stream and
performs each turn's metadata writes against the real backend before
streaming the tool result that names them. Script, `readings.txt` and 17
screenshots: `/mnt/project-files/objectstack-seat3/34610-live/`. The
readings are posted as a PR comment. In summary:
- **Acceptance 2:** the main area stays on `/home` mid-turn and moves to
`/apps/com.example.tracker/tracker_task` once the turn ends. The new app
shows its own nav, the unpublished-app bar and no draft bar. 1 Publish
on screen, 0 iframes. Publish from that bar puts the receipt in the
chat. In zh-CN the bar reads 「这个应用还没发布过…」.
- **Acceptance 1:** a drawer edit in the published app enters
`?preview=draft` on the same page, with the draft bar on top and 0
iframes.
- **Acceptance 3:** 1 visible Publish with the drawer open and the
result card drawn. The chat line, the Changes button and the changes
panel all read 1, while the environment holds another package's draft
too (2 env-wide).
- **Acceptance 4:** Publish from the bar puts the receipt in the chat
and removes the bar. It is the same document (no reload), and the
conversation is kept. The published field is in the New record form
without a reload and after one.
- **CRM pair:** the view edit lands in `com.example.crm.custom`
(`?package=com.example.crm` lists nothing). The bar, the panel and the
chat line still read 1, Publish empties the pair and the receipt shows.
- **Studio:** expand widens the slot from 360 to 920 px with the URL
unchanged, and the same button restores it.
- **375 px:** the drawer sheet and the draft bar show, with 0 iframes
and no horizontal overflow.
- **Not met, and not from this PR:** under draft preview a draft-only
field does not show in the New record form. A fresh `?preview=draft`
load with the same draft does not show it either, so this is the preview
overlay's reach, not this PR. After Publish it shows without a reload.
Tracked as #34807.
- **i18n budget (seat ruling 08:39Z):** after merging `main` 07f2861
(which brings #34723's eager key), a console build (`turbo run build
--filter=@object-ui/console...`, then `pnpm check:eager-closure`) reads
`i18n-locale-en` at **61,824 B gzip (60.4 KB of the 60.5 KB ceiling,
headroom 176 B)**, exit 0. The previous reading, at 159bd73, was 61,746
B. This PR adds no locale key after that. CI's Build & E2E UI on the
2621daf merge ref read the same 60.4 KB / headroom 0.2 KB. Per the
seat's conditional waiver, the `console.ai.pendingDrafts.*` keys stay in
`en.ts` with their siblings. If a later merge of main reads over the
ceiling, the whole group moves to a pack-shaped lazy namespace
(`@object-ui/i18n/namespaces/drafts`, behind a frame in `console/ai/`).
That move is prepared and measured as tests-green, but it is not
applied.
- **Affected test dirs** (app-shell `console/ai`, `preview`, `layout`,
`views/studio-design`, `chrome`, the pulse test, and `plugin-chatbot`):
702 files, 5428 tests, all green on 2621daf.
- New pins: `usePublishAllDrafts.appScope-34610` (base + pair published,
another app's not, the pair names the same app, the unscoped control),
the pair and other-app cases in `PendingDraftsBar` and
`draftPreview-12968`, the unpublished-app Publish keyed by the app name,
the turn-end move and refresh in `AiChatPage.draftInMainArea-34610`, and
the posture line under `publishFromShellBar`.
- `usePublishAllDrafts.appScope-34610` loads `@objectstack/lint` at
module top (CI's `check:test-source-alias` on 2621daf).
- Earlier in this PR, `PendingDraftsBar.sentenceWraps-13088` had pinned
a plural form that a test with no i18n instance cannot draw; its
assertion is now plural-agnostic.
- **Type-check:** app-shell `tsc -p tsconfig.json` and
`tsconfig.test.json` exit 0, and plugin-chatbot `tsc -p
tsconfig.test.json` exits 0. eslint on every changed file: 0 errors.
- **`dispatch-gates --ran`** (first round): all 51 derived families ran,
0 not measured. First-run reds and how each was answered:
- The ui `scripts/` suite still listed `LiveCanvas.test.tsx` in the
dom-heavy list. Fixed in `ui/vitest.config.mts`.
- `check:test-source-alias`: edited tests that reach the draft bar
needed a module-top `import '@objectstack/lint'`. Added.
- Two spec gates ran before a gitignored generated file existed. Re-run
exit 0.
- `check:dts-closure` needed a console build. Re-run exit 0.
- **Merges:** `origin/main` merged cleanly three times, most recently
07f2861 (db45412). The branch was cut from #34665's head; #34665 was
squash-merged, so its final head and then `main` were merged in. The PR
is now 69 files, +1789 −2573.
Clause-②: yes (widening — new @object-ui/i18n locale keys, so
`TranslationKeys` grows; and two additive @object-ui/plugin-chatbot
changes: the optional `ChatbotEnhanced` prop `publishFromShellBar` and
the optional `opts.appSegment` argument of `onBuildMaterialized`;
nothing removed or renamed)
Metadata-protocol: none
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(No spec change.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English. (The 维护者速读 block is
the seat's maintainer summary.)
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufzidTEhaEGRzboS7xTa
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzidTEhaEGRzboS7xTa -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8383e1a commit 14619f5
69 files changed
Lines changed: 1789 additions & 2573 deletions
File tree
- .changeset
- ui
- packages
- app-shell/src
- assistant
- chrome
- console/ai
- __tests__
- layout
- __tests__
- preview
- __tests__
- views
- studio-design
- __tests__
- i18n/src/locales
- plugin-chatbot/src
- __tests__
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 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
63 | | - | |
64 | | - | |
65 | 62 | | |
66 | 63 | | |
67 | 64 | | |
| |||
0 commit comments