Skip to content

Commit 14619f5

Browse files
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

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
'@object-ui/plugin-chatbot': patch
5+
'@object-ui/i18n': patch
6+
---
7+
8+
feat(console-ai): an AI build shows the app itself in the main area, with one Publish on screen
9+
10+
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
11+
Metadata-protocol: none
12+
13+
Building with AI happens in the console's right-side drawer, and the app it builds shows in the page beside it (ui ADR-0057 Amendment A3, ADR-0037 as amended). There is no nested preview any more.
14+
15+
- Changes to a published app show on the page you are on, in draft mode, with the draft bar on top. A new app shows in the main area once the build creates its package. Before that, the page stays. A new app is materialized (ADR-0045), so it shows as the real, not-yet-published app. The main area refreshes as each drafted item lands, and once more when the build's turn ends. Opening an older conversation from the history does not move the page.
16+
- The screen has one Publish: the draft bar, or the "not published yet" bar for an app that has never been published. The chat's result cards and the line above the composer no longer publish. The line says where to publish, or offers "Show draft" when the page is elsewhere. After a publish from the bar, the chat shows a receipt.
17+
- One count: the draft bar, its changes panel and the chat all count the current app's pending changes. An app's changes are those in its package and in its customization package (ADR-0146), where changes to an app installed from code are saved. The bar no longer counts the whole environment, and its separate "on this page" count is gone. Publishing from the draft bar publishes that app's changes and no longer reloads the page.
18+
- Publishing from the "not published yet" bar works for an app opened at its package id: the app is saved under its own name. Before, that save was refused.
19+
- The bar for an app that is not published yet says so. The draft bar says how many unpublished changes the app has.
20+
- In Studio, the AI copilot's expand button widens the copilot beside the page instead of leaving Studio. The copilot's cards no longer draw a Preview or Publish of their own. Studio's own top bar publishes.
21+
22+
`@object-ui/console`: ships the console with the changes above (it bundles `@object-ui/app-shell`).
23+
24+
`@object-ui/plugin-chatbot`: `ChatbotEnhanced` takes `publishFromShellBar`. When it is set, the draft cards draw no Publish button, and the build result card no longer says to click Publish in the chat. The Published badge, auto-publish and Preview stay. `onBuildMaterialized` also receives `{ appSegment }`, the built app's package id.
25+
26+
`@object-ui/i18n`: new keys `preview.draftBar.pendingInApp` (with plural forms), `preview.unpublishedBar.notPublishedYet`, and `console.ai.pendingDrafts.publishFromBar`, `showDraftToPublish` (both with plural forms), `showDraft`, `receipt` and `dismissReceipt`, in every locale pack, so the `TranslationKeys` type grows by those keys. No key was removed or changed. The console no longer reads `preview.draftBar.pendingHere`, `preview.unpublishedBar.message`, `console.ai.pendingDrafts.count`, `publish`, `published`, `failed`, `publishedWithFindings`, `console.ai.previewApp`, `console.ai.resizeSplit`, `console.ai.liveCanvas`, `console.ai.liveCanvasLive` or `console.ai.liveCanvasUnlisted`. Retiring them is a separate change.

‎ui/packages/app-shell/src/assistant/assistantBus.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,30 @@ export function requestAssistantOpen(): void {
308308
export function requestAssistantReview(target: AssistantReviewTarget): void {
309309
assistantBus.requestReview(target);
310310
}
311+
312+
// ── objectstack#34610 — a publish landed ───────────────────────────────────
313+
// The screen's one Publish is the shell's bar (the draft bar, or the
314+
// unpublished-app bar for an app not yet published), and the chat draws none
315+
// of its own. So the chat learns a publish landed from here and shows a
316+
// receipt for it. Fire-and-forget, off the snapshot bus, like the two
317+
// signals above; `emitMetadataRefresh` still carries the "re-read" half.
318+
319+
export interface PublishReceipt {
320+
/** The package the publish covered; null when it covered the whole environment. */
321+
packageId: string | null;
322+
}
323+
324+
const publishReceiptListeners = new Set<(receipt: PublishReceipt) => void>();
325+
326+
/** Announce that a publish from the shell's bar landed. */
327+
export function emitPublishReceipt(receipt: PublishReceipt): void {
328+
for (const l of publishReceiptListeners) l(receipt);
329+
}
330+
331+
/** Subscribe to landed publishes; returns an unsubscriber. */
332+
export function subscribePublishReceipt(listener: (receipt: PublishReceipt) => void): () => void {
333+
publishReceiptListeners.add(listener);
334+
return () => {
335+
publishReceiptListeners.delete(listener);
336+
};
337+
}

‎ui/packages/app-shell/src/chrome/KeyboardShortcutsDialog.wiredOnly-11674.test.tsx‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,11 @@ vi.mock('../layout/ChatDock', () => ({
5454
expanded: false,
5555
width: 420,
5656
dragging: false,
57-
maximized: false,
5857
fullWindow: false,
5958
setFullWindow: vi.fn(),
6059
toggle: () => {},
6160
expand: () => {},
6261
collapse: () => {},
63-
maximize: () => {},
64-
restore: () => {},
6562
onResizePointerDown: () => {},
6663
}),
6764
ChatDockPanel: () => null,

0 commit comments

Comments
 (0)