Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .changeset/34608-ai-assistant-one-drawer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@object-ui/app-shell': patch
'@object-ui/console': patch
'@object-ui/i18n': patch
---

feat(console-ai): the AI assistant is one right-side drawer, opened from the top-bar robot, with no full page

Clause-②: yes (widening — new @object-ui/i18n locale keys only)
Metadata-protocol: none

The console's AI assistant now has one container, the right-side drawer (ui ADR-0057, amended).

- The robot in the top bar opens and closes the drawer on the page you are on. The URL does not change. The floating button in the bottom-right corner is gone. While a proposed plan waits for approval, the robot carries the marker that button used to carry.
- The drawer's expand button makes it fill the window in place, with the conversation history as a column beside the chat. The same button puts it back as a side panel. Moving to another page puts it back too. At side-panel width the history is behind a "History" button. On a phone the drawer is a bottom sheet with the same "History" button.
- Home hosts the same drawer. "Build with AI" and "Ask AI" on Home, and "Edit with AI" in app management, open the drawer instead of a page. A new build still starts unbound to any app (ADR-0057 A1).
- The old `/ai`, `/ai/AGENT` and `/ai/AGENT/CONVERSATION` addresses still work. That includes bookmarks, shared links, `?package=` and `?new=`. They open the drawer on the conversation they name, filling the window, over the home page. A Builder handoff still travels only as navigation state.
- Inside an app, a builder's empty state offers data questions as well as changes, as the composer hint already did. Its description and its first suggestions name both.
- The drawer's share button now opens the share dialog. Before, it did nothing in the drawer.

`@object-ui/i18n`: new keys `console.ai.dock.history`, `console.ai.dock.backToChat`, `console.ai.dock.expand`, `console.ai.dock.restore` and `console.ai.empty.editApp.askOrChangeDescription`, in every locale pack. No key was removed or changed. The console no longer reads `console.ai.dock.maximize` or `console.ai.empty.editApp.description`. Retiring them is a separate change.
44 changes: 18 additions & 26 deletions ui/apps/console/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { DevModal } from './dev/DevModal';
import { DevLookup } from './dev/DevLookup';
import { DevRowActions } from './dev/DevRowActions';
import {
AiAddressRedirect,
ConsoleShell,
RequireAiSurface,
RequireOrganization,
Expand Down Expand Up @@ -94,20 +95,12 @@ const DocsSlug = lazy(() => import('./pages/DocsSlug'));
const DocPage = lazy(() => import('./pages/DocPage'));

/*
* The AI chat surfaces, lazy for the same reason (objectui#13410).
*
* `/ai…` and the public share page `/s/:token` are the two console routes that
* render the chat UI (`ChatbotEnhanced` and everything it reaches in
* `@object-ui/plugin-chatbot`: `streamdown`, `shiki`, the AI Elements). Imported
* statically here, that UI was in every first page load, the third-largest
* eager chunk, including for users who never open a chat. The AI page arrives
* through `./components/aiChatPage`, a console-local module nothing imports
* statically, because an `import()` of the `@object-ui/app-shell` barrel this
* file already imports would move nothing (see `./components/studioBuilder`).
* The public share page `/s/:token` renders the chat UI (`ChatbotEnhanced` and
* everything it reaches in `@object-ui/plugin-chatbot`), so it is lazy for the
* same reason (objectui#13410). The `/ai…` addresses no longer draw a page: they
* open the console's chat drawer (objectstack#34608, `AiAddressRedirect`), whose
* body loads the chat UI when it first renders.
*/
const DefaultAiChatPage = lazy(() =>
import('./components/aiChatPage').then((m) => ({ default: m.DefaultAiChatPage })),
);
const SharedRecordPage = lazy(() => import('./pages/SharedRecordPage'));

const SERVER_URL = import.meta.env.VITE_SERVER_URL || '';
Expand Down Expand Up @@ -498,34 +491,33 @@ export function App() {
</Route>
<Route path="/system/*" element={<SystemRedirect />} />
{/*
AI surfaces are agent-scoped: the active assistant is baked into
the route (`/ai/:agent`) rather than a `?agent=` query snapshot,
so each assistant ("build" authoring vs "ask" data Q&A, plus any
custom `*.agent.ts`) is its own page. AiChatPage handles the
back-compat redirects: bare `/ai` → the default agent surface, and
a single-segment `/ai/:agent` that is actually a legacy bare
conversation id → `/ai/:agent/:conversationId`.
objectstack#34608 (ui ADR-0057 as amended) — the AI assistant has
one container, the right-side drawer, and no page. The old
full-page addresses (`/ai`, `/ai/:agent`,
`/ai/:agent/:conversationId`, with `?package=` / `?new=`) stay
routed so bookmarks and shared links keep working:
`AiAddressRedirect` opens the drawer on the conversation the
address names, filling the window, over the declared landing.

`RequireAiSurface` keeps these from dead-ending on a runtime that
serves no AI (Community Edition): with AI unavailable a stale
bookmark / external link gets a screen saying so, with the way
home, instead of a chat with no agent to talk to. Cloud installs
pass straight through. Purely additive runtime gating — same
server signal the floating-chat FAB has always used.
home. Purely additive runtime gating — the same server signal the
top-bar robot uses.
*/}
<Route path="/ai" element={
<ProtectedRoute>
<RequireAiSurface><Suspense fallback={<LoadingScreen />}><DefaultAiChatPage /></Suspense></RequireAiSurface>
<RequireAiSurface><AiAddressRedirect /></RequireAiSurface>
</ProtectedRoute>
} />
<Route path="/ai/:agent" element={
<ProtectedRoute>
<RequireAiSurface><Suspense fallback={<LoadingScreen />}><DefaultAiChatPage /></Suspense></RequireAiSurface>
<RequireAiSurface><AiAddressRedirect /></RequireAiSurface>
</ProtectedRoute>
} />
<Route path="/ai/:agent/:conversationId" element={
<ProtectedRoute>
<RequireAiSurface><Suspense fallback={<LoadingScreen />}><DefaultAiChatPage /></Suspense></RequireAiSurface>
<RequireAiSurface><AiAddressRedirect /></RequireAiSurface>
</ProtectedRoute>
} />
{/* `RedirectWithSplash`, not a bare `<Navigate>` (objectui#6378).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
* `internalFormShell.test.tsx` does. A hand-copied route list would be free to
* agree with whatever the source does. Everything `App.tsx` imports but this
* card does not touch is stubbed, with the same list that file uses. The
* catch-all's element (`RedirectWithSplash`) and the chat page
* (`DefaultAiChatPage`) are stubbed to markers; the chat stub reports the
* catch-all's element (`RedirectWithSplash`) and the chat address's element
* (`AiAddressRedirect`, which opens the chat drawer since objectstack#34608)
* are stubbed to markers; the chat stub reports the
* `:agent` and `:conversationId` params and the `new` flag it was routed with.
*
* The href is not written here: it is the one the REAL registered agent
Expand Down Expand Up @@ -91,7 +92,9 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => {
DefaultInvitationsPage: stub('invitations-page'),
DefaultSettingsPage: stub('settings-page'),
DefaultAcceptInvitationPage: stub('accept-invitation-page'),
DefaultAiChatPage: AiChatPageProbe,
// objectstack#34608 — the `/ai…` routes render `AiAddressRedirect` (it opens
// the chat drawer on the address); the probe reports what it was routed with.
AiAddressRedirect: AiChatPageProbe,
StudioDesignSurface: stub('studio-design-surface'),
BuilderLanding: stub('builder-landing'),
getProductName: () => 'ObjectOS',
Expand Down
2 changes: 1 addition & 1 deletion ui/apps/console/src/__tests__/App.docsPortalLazy.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({
DefaultInvitationsPage: stub('invitations-page'),
DefaultSettingsPage: stub('settings-page'),
DefaultAcceptInvitationPage: stub('accept-invitation-page'),
DefaultAiChatPage: stub('ai-chat-page'),
AiAddressRedirect: stub('ai-chat-page'),
StudioDesignSurface: stub('studio-design-surface'),
BuilderLanding: stub('builder-landing'),
getProductName: () => 'ObjectOS',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({
DefaultInvitationsPage: stub('invitations-page'),
DefaultSettingsPage: stub('settings-page'),
DefaultAcceptInvitationPage: stub('accept-invitation-page'),
DefaultAiChatPage: stub('ai-chat-page'),
AiAddressRedirect: stub('ai-chat-page'),
StudioDesignSurface: stub('studio-design-surface'),
BuilderLanding: stub('builder-landing'),
getProductName: () => 'ObjectOS',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({
DefaultInvitationsPage: stub('invitations-page'),
DefaultSettingsPage: stub('settings-page'),
DefaultAcceptInvitationPage: stub('accept-invitation-page'),
DefaultAiChatPage: stub('ai-chat-page'),
AiAddressRedirect: stub('ai-chat-page'),
StudioDesignSurface: stub('studio-design-surface'),
BuilderLanding: stub('builder-landing'),
getProductName: () => 'ObjectOS',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({
DefaultInvitationsPage: stub('invitations-page'),
DefaultSettingsPage: stub('settings-page'),
DefaultAcceptInvitationPage: stub('accept-invitation-page'),
DefaultAiChatPage: stub('ai-chat-page'),
AiAddressRedirect: stub('ai-chat-page'),
StudioDesignSurface: stub('studio-design-surface'),
BuilderLanding: stub('builder-landing'),
getProductName: () => 'ObjectOS',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({
DefaultInvitationsPage: stub('invitations-page'),
DefaultSettingsPage: stub('settings-page'),
DefaultAcceptInvitationPage: stub('accept-invitation-page'),
DefaultAiChatPage: stub('ai-chat-page'),
AiAddressRedirect: stub('ai-chat-page'),
StudioDesignSurface: stub('studio-design-surface'),
BuilderLanding: stub('builder-landing'),
getProductName: () => 'ObjectOS',
Expand Down
2 changes: 1 addition & 1 deletion ui/apps/console/src/__tests__/internalFormShell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({
DefaultInvitationsPage: stub('invitations-page'),
DefaultSettingsPage: stub('settings-page'),
DefaultAcceptInvitationPage: stub('accept-invitation-page'),
DefaultAiChatPage: stub('ai-chat-page'),
AiAddressRedirect: stub('ai-chat-page'),
StudioDesignSurface: stub('studio-design-surface'),
BuilderLanding: stub('builder-landing'),
getProductName: () => 'ObjectOS',
Expand Down
18 changes: 0 additions & 18 deletions ui/apps/console/src/components/aiChatPage.ts

This file was deleted.

6 changes: 4 additions & 2 deletions ui/apps/console/src/pages/system/AppManagementPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ import {
} from 'lucide-react';
import { toast } from 'sonner';
import type { ObjectStackClient } from '@objectstack/client';
import { ConsolePageHeader, useMetadata, useAdapter } from '@object-ui/app-shell';
import { ConsolePageHeader, useMetadata, useAdapter, useOpenAssistant } from '@object-ui/app-shell';
import { useObjectTranslation } from '@object-ui/i18n';
import { resolveKeyedI18nLabel } from '../../utils';

Expand Down Expand Up @@ -237,6 +237,7 @@ function SetDefaultStar({
export function AppManagementPage() {
const { t } = useObjectTranslation();
const navigate = useNavigate();
const openAssistant = useOpenAssistant();
const { appName } = useParams();
const basePath = appName ? `/apps/${appName}` : '';
const { apps, refresh } = useMetadata();
Expand Down Expand Up @@ -657,8 +658,9 @@ export function AppManagementPage() {
// pre-scoped to this app's package (passed as the chat
// context.packageId the cloud seeds as the active package),
// so the AI iterates within THIS app, not the whole env.
// objectstack#34608 — in the console's chat drawer, in place.
onClick={() =>
navigate(`/ai/build?package=${encodeURIComponent(app._packageId!)}&new=1`)
openAssistant({ agent: 'build', packageId: app._packageId, fresh: true })
}
>
<Sparkles className="h-4 w-4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
*/

import '@testing-library/jest-dom/vitest';
// The layout reaches `import('@objectstack/lint')` (the draft bar's publish
// preflight); pay its first load at collection, never inside a clocked case.
import '@objectstack/lint';
import { describe, it, expect, vi, afterEach } from 'vitest';
import React, { useState } from 'react';
import { render, screen, fireEvent, cleanup, waitFor, act } from '@testing-library/react';
Expand All @@ -52,6 +55,8 @@ vi.mock('../layout/ChatDock', () => ({
width: 420,
dragging: false,
maximized: false,
fullWindow: false,
setFullWindow: vi.fn(),
toggle: () => {},
expand: () => {},
collapse: () => {},
Expand Down
48 changes: 48 additions & 0 deletions ui/packages/app-shell/src/console/ai/AiAddressRedirect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#34608 (ui ADR-0057 as amended) — the old full-page chat
* addresses, `/ai`, `/ai/AGENT` and `/ai/AGENT/CONVERSATION` (with `?package=`
* and `?new=`), open the console's chat drawer instead: a bookmark, a shared
* link or an in-app link from a surface without a drawer (Studio) still lands
* on the conversation it named.
*
* The address is parsed into the drawer's target and armed per tab, with the
* drawer open and filling the window — the closest thing to the page the link
* used to open — then the visit is replaced by the declared landing
* (`useHomePath`), which hosts the drawer. While the app list is still loading
* that answers the launcher (`/home`), which hosts the same drawer, so a cold
* boot on an old link still opens the conversation. A Builder handoff carried as
* navigation state (objectui#12493: never in the URL) is handed on the same
* way, as navigation state of the landing.
*
* Deliberately light: it imports no chat code, so following an old link loads
* the chat graph only when the drawer body renders.
*/

import { useEffect } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { useHomePath } from '../../hooks/useHomePath.js';
import { writeStoredDockExpanded, DOCK_EXPANDED_STORAGE_KEY } from '../../layout/chatDockState.js';
import {
parseAiAddress,
readBuilderHandoffState,
writeStoredDockFullWindow,
writeStoredDockTarget,
DOCK_HANDOFF_STATE_KEY,
} from '../../layout/chatDockTarget.js';

export function AiAddressRedirect() {
const location = useLocation();
const navigate = useNavigate();
const homePath = useHomePath();
useEffect(() => {
writeStoredDockTarget(parseAiAddress(location.pathname, location.search));
writeStoredDockExpanded(DOCK_EXPANDED_STORAGE_KEY, true);
writeStoredDockFullWindow(true);
const handoff = readBuilderHandoffState(location.state);
const carries = Boolean(handoff.handoffPrompt || handoff.parentConversationId);
navigate(homePath, { replace: true, state: carries ? { [DOCK_HANDOFF_STATE_KEY]: handoff } : null });
}, [location.key, location.pathname, location.search, location.state, homePath, navigate]);
return null;
}
Loading
Loading