diff --git a/docs/adr/0037-live-canvas-draft-preview.md b/docs/adr/0037-live-canvas-draft-preview.md index f2ceaf28c7e..15f276abd9c 100644 --- a/docs/adr/0037-live-canvas-draft-preview.md +++ b/docs/adr/0037-live-canvas-draft-preview.md @@ -1,6 +1,7 @@ # ADR-0037: Live Canvas — draft-overlay live preview while you build **Status**: Accepted (2026-06-10) — all four phases implemented: `previewDrafts` reads (`runtime/http-dispatcher.ts`), objectui LiveCanvas/PreviewModeContext/DraftPreviewBar, draft-data preview via `service-analytics/preview-evaluator.ts` (+test), assistantBus back-channel (Phase 4 the least exercised). +**Amended**: 2026-11-17 by ui ADR-0057 Amendment A3 (objectstack#34608, objectstack#34610) — the presentation changes: the build chat is the console's one right-side drawer and the canvas is the app itself in the main area, not a split-view iframe host. The main area shows the app in the regime the build is in: the real unpublished app for a new or still-unpublished app (ADR-0045 §5, §7), and draft mode (`?preview=draft`) for changes to a published app. The draft-overlay mechanism, the per-artifact refresh and the four phases' data plane are unchanged; the screen's one Publish is the shell's bar for the regime shown. **Deciders**: ObjectStack Protocol Architects **Builds on**: [ADR-0033](./0033-ai-assisted-metadata-authoring.md) (AI authors metadata as DRAFTS; publish is the human gate), [ADR-0021](./0021-analytics-dataset-semantic-layer.md) (datasets as the single analytics form — what dashboards render from), [ADR-0005](./0005-metadata-customization-overlay.md) (the overlay model the draft state lives in) **Consumers**: `@objectstack/runtime` + `@objectstack/objectql` (preview data plane — mostly already present), `@objectstack/service-analytics` (Phase 3 draft-data queries), `../objectui` (`data-objectstack` preview client, `app-shell` Live Canvas + assistant bus, view/dashboard renderers), `../cloud` (Build-with-AI entry surface) @@ -19,7 +20,7 @@ Everything hard about live preview already exists in the platform; it has simply 2. The chat already knows, in real time, **which artifact just changed**: the streaming build tree (`data-build-progress` parts) and every authoring tool's `drafted` envelope name the exact `(type, name)`. 3. The chat and the host app already share an **event bus** (`assistantBus` in objectui app-shell) with an editor-context primitive. -**Decision.** Ship a split-view **Live Canvas**: chat on the left, the user's app rendered from the **draft overlay** on the right, refreshed per-artifact by the existing stream events. Four phases: (1) static draft preview behind a `?preview=draft` mode + watermark; (2) event-driven live refresh during builds and edits; (3) draft **data** preview (seed rows visible pre-publish — the only genuinely new mechanism); (4) canvas→chat back-channel ("change *this*" while pointing). Publish remains the only commit point; the canvas is a read-only window onto the draft layer. +**Decision.** Ship a ~~split-view~~ **Live Canvas**: ~~chat on the left, the user's app rendered from the **draft overlay** on the right~~ *(amended 2026-11-17, ui ADR-0057 Amendment A3: the build chat is the console's right-side drawer and the canvas is the user's app itself in the main area, no nested preview. Changes to a published app render from the **draft overlay** through the shell's `?preview=draft` mode; a new or still-unpublished app is the real unpublished app, per ADR-0045)*, refreshed per-artifact by the existing stream events. Four phases: (1) static draft preview behind a `?preview=draft` mode + watermark; (2) event-driven live refresh during builds and edits; (3) draft **data** preview (seed rows visible pre-publish — the only genuinely new mechanism); (4) canvas→chat back-channel ("change *this*" while pointing). Publish remains the only commit point; the canvas is a read-only window onto the draft layer. **Open-core boundary**: the preview data plane (`preview=draft` reads, draft-data query overlay) is **open mechanism** (framework). The Live Canvas surface, the chat wiring, and the build intelligence stay in objectui/cloud. @@ -68,11 +69,11 @@ The 2026-06-10 reliability batch closed the failure modes a live canvas would ha ### Phase 2 — event-driven live canvas (objectui, ~3–4 days) - `assistantBus`: `emitCanvasInvalidate({ type, name })` / `subscribeCanvasInvalidate` (mirrors the existing review-request pattern). -- Both chat hosts (`ConsoleFloatingChatbot`, `AiChatPage`) emit invalidations from (a) `buildProgress.items` diffs and (b) `drafted` envelopes — the data is already in hand; this is wiring. -- A `LiveCanvas` split-view host: opens automatically for Build-with-AI sessions; re-keys/refetches the affected renderer per `(type, name)`; a ~200 ms coalescing window prevents invalidation storms during whole-app builds. +- Both chat hosts (`ConsoleFloatingChatbot`, `AiChatPage`) *(amended 2026-11-17, ui ADR-0057 A3: the console's one drawer)* emit invalidations from (a) `buildProgress.items` diffs and (b) `drafted` envelopes — the data is already in hand; this is wiring. +- ~~A `LiveCanvas` split-view host~~ *(amended 2026-11-17, ui ADR-0057 A3: no separate host; the console's own shell is the canvas, beside the drawer: in draft mode for changes to a published app, and the real unpublished app for a new or still-unpublished app per ADR-0045)*: opens automatically for Build-with-AI sessions; re-keys/refetches the affected renderer per `(type, name)`; a ~200 ms coalescing window prevents invalidation storms during whole-app builds. - Renderers accept an external refresh key (most already expose a reload hook). -**Acceptance**: during `apply_blueprint` the right pane grows artifact-by-artifact in step with the build tree; an incremental "add a field" edit reflects in the rendered form/kanban in < 1 s. +**Acceptance**: during `apply_blueprint` the ~~right pane~~ main area *(amended 2026-11-17, ui ADR-0057 A3)* grows artifact-by-artifact in step with the build tree; an incremental "add a field" edit reflects in the rendered form/kanban in < 1 s. ### Phase 3 — draft data preview (framework, ~1–2 weeks; the only new mechanism) @@ -132,7 +133,7 @@ All write paths converge on the same draft rows; **Publish remains the single co 1. **One truth.** The canvas has NO store of its own — no "AI workspace" parallel repository. It renders the same `sys_metadata` rows Studio edits. 2. **The canvas never edits in place.** It renders and *selects* (point at a widget/field); changing anything goes through exactly two doors — say it (chat → authoring tools → draft) or **"Open in Studio"** (the existing review/designer deep-link). This rule is what guarantees the canvas can never grow into a second Studio. -3. **There is one chat.** The canvas ships no chat of its own; in build sessions the existing `ChatbotEnhanced` (same conversation, same component) becomes the left pane and the canvas is its result pane. The floating button keeps its role as the everywhere intent-entry; the canvas appears only in building contexts. +3. **There is one chat.** The canvas ships no chat of its own; in build sessions the existing `ChatbotEnhanced` (same conversation, same component) ~~becomes the left pane~~ is the right-side drawer *(amended 2026-11-17, ui ADR-0057 A3)* and the canvas is its result pane. ~~The floating button keeps its role as the everywhere intent-entry;~~ *(Amended 2026-11-17 by ui ADR-0057 Amendment A3, objectstack#34608: the floating button is retired; the top-bar robot, which opens the console's one chat drawer, is the everywhere intent-entry.)* The canvas appears only in building contexts. 4. **No new lifecycle semantics.** The canvas's Publish calls the existing endpoints; Review deep-links to Studio's diff. Nothing new to govern. **Relationship to Studio's existing previews**: Studio's dataset-designer live preview (ADR-0021) is *artifact-level* preview; the canvas is *app-level* preview. Both consume the same primitives (`preview=draft` reads; `queryDataset` already accepts inline draft definitions — the hook originally added for Studio preview), so the mechanism is shared, not duplicated. Canvas selection and Studio deep-links ride the same `assistantBus` — three surfaces, one context bus. diff --git a/ui/docs/adr/0057-console-ai-chat-one-conversation-docked.md b/ui/docs/adr/0057-console-ai-chat-one-conversation-docked.md index f5699292b93..2c7e0f27d6c 100644 --- a/ui/docs/adr/0057-console-ai-chat-one-conversation-docked.md +++ b/ui/docs/adr/0057-console-ai-chat-one-conversation-docked.md @@ -14,10 +14,17 @@ change** — this ADR only rearranges how the objectui console *renders and wire chat surfaces. **Amended**: Amendment A2 (2026-09-28) — the dock binds its build thread to the current authorable app, reversing A1.b's dock clause (objectui#10926). +Amendment A3 (2026-11-17) — the right-side drawer is the ONLY chat container: +the top-bar robot toggles it, maximize fills the window in place, the +floating button and the full page are retired and the `/ai…` addresses open +the drawer (objectstack#34608). It supersedes §3's focus mode, A2's maximize +clause and open questions 2 and 5, and, for building, ADR-0037's split-view +presentation and its `LiveCanvas` host: the app shows in the main area +(objectstack#34610). **Author**: ObjectUI app-shell / Studio team **Consumers**: `@object-ui/app-shell` (`console/ai/AiChatPage.tsx`, `layout/ConsoleFloatingChatbot.tsx`, -`layout/ConsoleChatbotFab.tsx`, `layout/ConsoleLayout.tsx`, `layout/agentPicker.ts`, +`layout/ConsoleChatbotFab.tsx` (deleted by Amendment A3), `layout/ConsoleLayout.tsx`, `layout/agentPicker.ts`, `views/studio-design/StudioAiCopilot.tsx`, `views/studio-design/StudioDesignSurface.tsx`, `assistant/assistantBus.ts`, `hooks/useChatConversation.ts`, `hooks/useConversationList.ts`, `hooks/useAiSurface.ts`), @@ -90,7 +97,9 @@ is **console-layer surface sprawl**, not the agent model. 3. **Canonical presentation = a right-docked, collapsible, resizable panel** (the VS Code / Cursor idiom). The floating FAB **retires** to a launcher / shortcut that opens the same dock. Full-page `/ai` becomes the same panel - **maximized** (focus mode + Live Canvas), sharing the thread. + **maximized** (focus mode + Live Canvas), sharing the thread. *(Amendment + A3: there is no full page and no Live Canvas pane; maximize fills the + window in place and the build's app shows in the main area.)* 4. **Runtime end-user apps keep the bubble.** A support-widget presentation is the right *audience* idiom; same state code, different chrome. **Presentation is decoupled from state.** @@ -213,11 +222,15 @@ convention repeated five times. collapsed**, resizable. Replaces the FAB as the canonical console chat; the FAB button becomes the launcher / keyboard toggle (⌘I / ⌘L idiom). Default-collapsed preserves the FAB's virtue — zero layout cost, no reflow of dense data grids — - until invoked. -- **Focus / full-screen.** `/ai` = the same panel **maximized** (build + Live + until invoked. *(Amendment A3: the launcher is the top-bar robot, a toggle; + the floating button is retired.)* +- **Focus / full-screen.** ~~`/ai` = the same panel **maximized** (build + Live Canvas). "Expand" from the rail, "collapse" back — **same thread**. Deep links (`/ai/build/:conversationId`, share links, ADR-0013) open the dock maximized on - that thread. + that thread.~~ **Superseded by Amendment A3:** maximize is the same drawer + filling the window **in place**, on the page underneath, with no route of + its own; the same control restores it. Deep links and share links open the + drawer, maximized, on the thread they name. - **Bubble / embedded.** Runtime apps + the SDUI `chatbot` keep the support-widget chrome; **same state code**, different presentation. - **Side = right** (VS Code / Cursor norm; the left is nav). **Consequence:** @@ -404,10 +417,12 @@ The terms it was presented with (objectui#10926): `app:PKG:build` yet, it adopts the product-only thread only if that thread's own history binds it to `PKG`. So the dock and the full page arrive at the same thread whichever of them resolves first. -- **Maximize.** A bound dock opens `/ai/build?package=PKG`, carrying the same +- **Maximize.** ~~A bound dock opens `/ai/build?package=PKG`, carrying the same one-shot full-page opt-out the Studio dock's door sets, so the built-moment transition (objectui#5799) does not bounce the arrival straight on to - Studio. An app-less dock opens `/ai`, as before. + Studio. An app-less dock opens `/ai`, as before.~~ **Superseded by Amendment + A3:** maximize no longer navigates. The bound thread stays bound while the + drawer fills the window; the key decision above is unchanged. **Consequences.** Each authorable app a maker opens the dock in gets its own build thread, minted on first open, as the Studio copilot already does per @@ -417,6 +432,110 @@ and in the dock outside any authorable app. This extends A1's direction ("the `app` axis becomes always present for `build`") to the one surface A1.b had kept product-only. Implemented under objectui#10926. +## Amendment A3 (2026-11-17, Accepted) — one drawer, maximized in place + +**What it changes.** §3's focus mode ("`/ai` = the same panel maximized"), A2's +maximize clause ("Maximize goes to `/ai/build?package=PKG`"), open question 2 +(the floating button stays as the dock's collapsed affordance) and open +question 5 ("the routes are untouched"); and, with objectstack#34610 under the +same ruling, ADR-0037's split-view presentation ("chat on the left … draft +overlay on the right") and its `LiveCanvas` host. Everything else stands: one +conversation context (§1), one resolver (§2), the runtime bubble (§4), one +gate and OSS → nothing (§5, §6), A1 and A2's key decision, ADR-0037's draft +overlay and its per-artifact refresh (Phase 2), and ADR-0045's regimes: a new +or still-unpublished app is materialized, real and unlisted, and published by +the visibility flip; changes to a published app are drafts, published by +publishing them. + +**Why.** Measured on staging (epic objectstack#34571, comment 6936163971): +the console drew one conversation in two containers, the rail and the `/ai` +page. The top-bar robot was a link to that page, and the dock's maximize +navigated to it too, so a user who maximized lost the page they were on. The +build page nested a second shell inside the console's, with the chat +squeezed to about 310 px. The floating button was a third entry, which sat on +page content (objectui#12248). + +**Maintainer ruling** (objectstack#34608, recorded 2026-11-17T03:40Z in +comment 6937495221), verbatim, not translated: + +> 同意 + +It accepted the seat's recommendation as presented: + +- The AI assistant becomes one right-side drawer. +- Maximize is in place and restores. +- The in-app bottom-right AI button is removed; the top-bar robot is the one + entry. +- Old `/ai` and `/ai/build` links, shared links included, redirect to the + opened drawer. +- With it (objectstack#34610, ruled the same day, comment 6937505798): a + 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. +- Kept: A1, a new build starts UNBOUND (no empty app is created first). + ADR-0063 stays compatible: the product is still chosen by principal. + +**Decision.** + +- **One container.** In the console shell, Home and every app page, the + right-side drawer is the one place the assistant's conversation is drawn: + the rail on a desktop, a bottom sheet on a phone. There is no `/ai` page. + Three surfaces keep their own chrome, as before: Studio's copilot in its + right slot (objectui#12725), the public `/s/:token` share page (read-only, + ADR-0013) and the runtime bubble (§4). Studio's maximize, which navigated to + `/ai/build?package=…` and so lost the Studio page, widens the copilot's slot + in place instead (objectstack#34610). +- **Entry.** The top-bar robot opens and closes the drawer on the current + page; the address does not change. It carries the plan-awaiting-approval + marker the floating button carried (objectui#11666). The floating button is + retired, and with it the corner-yield rule written for it (objectui#12248). + The keyboard toggle stays. +- **Maximize.** The drawer's expand control makes the same element fill the + window in place, so the conversation is not remounted and a stream in + flight continues. The same control restores the rail. Leaving the page + (for a record the chat linked to) restores the rail too. +- **History.** At rail width the conversation history is behind a "History" + button. Maximized, it is a column beside the chat. +- **Addresses.** `/ai`, `/ai/:agent` and `/ai/:agent/:conversationId`, with + `?package=` and `?new=`, stay routed so bookmarks, share links (ADR-0013) + and links from surfaces without a drawer keep working. Each one opens the + drawer, maximized, on the thread it names, over the declared landing. What + the drawer shows is kept per tab, never in the URL. A Builder handoff still + travels only as navigation state (objectui#12493). +- **Entries.** "Build with AI" and "Ask AI" on Home and "Edit with AI" in app + management open the drawer on the agent, package or fresh thread they used + to address. +- **Builder guidance.** Inside an app, a maker's empty state names both + halves, data questions and changes, as the composer hint already did. +- **Building (objectstack#34610, same ruling).** A build runs in the same + drawer, and the main area shows the app itself, in the regime the build is + in (ADR-0045): + - a new or still-unpublished app is materialized, so the main area shows + the real, unlisted app; + - changes to a published app are drafts, so the main area shows the app in + the shell's draft mode (`?preview=draft`). + The main area refreshes in place per artifact, as ADR-0037 Phase 2 already + specifies, and once more when a build turn ends. There is no nested + preview: the ADR-0037 `LiveCanvas` iframe host is retired, and its + split-view presentation with it (ADR-0037 is amended to match). A new + build still starts UNBOUND (A1): the main area keeps its page until the + build binds a package, then shows that app. +- **One publish control.** The screen has one Publish: the shell's bar for + the regime the main area is in. The two bars never stack (the + unpublished-app bar yields in draft mode). The unpublished-app bar says the + app has never been published and publishes it by the visibility flip. The + draft bar says how many unpublished changes the app has and publishes them. + That count is the current app's (package's) pending drafts, and the draft + bar, its changes panel and the chat show the same number. The chat draws no + Publish of its own: it points to the bar and shows a receipt once a publish + lands. + +**Consequences.** The full-page chat component is no longer routed. A page +that is not wrapped by a drawer host can still link to an `/ai…` address and +reach the drawer. A surface whose state matters for deep-linking (ui ADR-0054 +C3) reaches the drawer through those addresses, not through a query +parameter on every page. Implemented under objectstack#34608 (the drawer) +and objectstack#34610 (building with the app draft in the main area). + ## Open design questions 1. **Dock side under Studio (P3).** ~~Chat right vs properties right.~~ @@ -425,9 +544,11 @@ A1.b had kept product-only. Implemented under objectui#10926. P3c** (Interfaces pillar `[Canvas | Properties]` center tabs; Data/Automations keep their in-center inspectors). 2. **FAB retirement path (P3).** ~~Hard-retire, or keep the FAB as the collapsed - affordance?~~ **DECIDED (2026-07-13): the FAB becomes the dock's collapsed + affordance?~~ ~~**DECIDED (2026-07-13): the FAB becomes the dock's collapsed affordance** — the bottom-right button stays and expands the right rail - (gentle migration; the familiar entry point survives). + (gentle migration; the familiar entry point survives).~~ **RE-DECIDED + (2026-11-17, Amendment A3): hard-retired.** The top-bar robot is the one + entry and toggles the drawer. 3. **Handoff aggressiveness (P4).** **DECIDED & SHIPPED: explicit** "Open in Builder →" (#2439), carrying the ask conversation as first-turn context (#2444 + cloud#819). A second handoff landing on a pending blueprint simply @@ -437,10 +558,13 @@ A1.b had kept product-only. Implemented under objectui#10926. custom agents withdrawn). Confirm the resolver **rejects** anything else rather than silently falling through. 5. **Focus-mode routing.** ~~Does `/ai/build/:conversationId` stay a deep-linkable, - shareable URL (ADR-0013) once the dock is canonical?~~ **DECIDED & SHIPPED + shareable URL (ADR-0013) once the dock is canonical?~~ ~~**DECIDED & SHIPPED (P3c): yes** — the routes are untouched; the full page IS the dock maximized (same P1 thread), with a maximize button on the rail and a collapse-to-dock - button on the page bridging the two presentations. + button on the page bridging the two presentations.~~ **RE-DECIDED + (2026-11-17, Amendment A3):** the URLs stay deep-linkable and shareable, + but there is no page behind them: each opens the drawer, maximized, on the + thread it names. ## Alternatives considered