Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d82cadc
feat(console-ai): the AI assistant is one right-side drawer, opened f…
claude Nov 17, 2026
9c18bb8
test(console-ai): run the drawer-target pins under a DOM, and regener…
claude Nov 17, 2026
910dbeb
test(console-ai): pay the layout's lint preflight load at collection …
claude Nov 17, 2026
815db93
feat(console-ai): an AI build shows the app itself in the main area, …
claude Nov 17, 2026
25e013b
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 17, 2026
7337fe1
test(ui): drop the deleted LiveCanvas test from the dom-heavy list
claude Nov 17, 2026
f2fcf9e
test(preview): pay the draft bar's lint preflight load at collection …
claude Nov 17, 2026
f7d6ae3
Merge commit '25e013bb634f0121d4c8eae4ef8054b143dfd5bf' into claude/i…
claude Nov 17, 2026
6a8506e
Merge remote-tracking branch 'origin/main' into claude/issue-34610-dr…
claude Nov 17, 2026
a33148b
test(views): the draft bar's pulse test reads the route app's package…
claude Nov 17, 2026
b1123f7
Merge remote-tracking branch 'origin/claude/issue-34610-drawer-build'…
claude Nov 17, 2026
159bd73
Merge remote-tracking branch 'origin/main' into claude/issue-34610-dr…
claude Nov 17, 2026
3d21b0b
feat(studio): the Studio AI panel matches the console's AI assistant …
claude Nov 17, 2026
f71c5f1
test(studio): pin the AI assistant panel's header, robot, width, hist…
claude Nov 17, 2026
a5bb849
test(studio): warm the lint load at collection; ledger ceiling for th…
claude Nov 17, 2026
2621daf
fix(console-ai): count and publish an app's drafts with its customiza…
claude Nov 17, 2026
a1521d1
fix(studio): the top bar names its pillars by its own width, so a wid…
claude Nov 17, 2026
db45412
Merge remote-tracking branch 'origin/main' into claude/issue-34610-dr…
claude Nov 17, 2026
c80f1db
chore(console-ai): name @object-ui/console and the TranslationKeys gr…
claude Nov 17, 2026
3c87dee
Merge remote-tracking branch 'origin/claude/issue-34610-drawer-build'…
claude Nov 17, 2026
e4f1d5a
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 17, 2026
48c6656
test(studio): load lint at collection in the narrow-header pin
claude Nov 17, 2026
c2034e7
fix(studio): a failed discard names items by label, not type/name and…
claude Nov 17, 2026
679c449
Merge origin/main into claude/project-thread-oclfj4 (merge-forward be…
claude Nov 17, 2026
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
23 changes: 23 additions & 0 deletions .changeset/34725-studio-ai-assistant-panel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@object-ui/app-shell': patch
'@object-ui/components': patch
'@object-ui/i18n': patch
---

feat(studio): the Studio AI panel matches the console's AI assistant

Clause-②: yes (widening — new studio-namespace locale keys, and one optional `columnMarks` member on the published `GridFieldAuthoring` interface of @object-ui/components)
Metadata-protocol: none

The AI panel on Studio's right side now looks and works like the console's AI assistant drawer.

- It is called "AI Assistant" (「AI 助手」) everywhere, including the line that says which tool drafted a change.
- Studio's top bar shows the console's robot button in the same place. It shows or hides the right panel and always opens it on the AI assistant. `⌘.` still switches between properties and the assistant. Without an assistant, the panel icon stays.
- The panel has one header row: the Properties | AI Assistant switch on the left; History, widen and Close on the right. Usage and Share moved into the History view, which covers the chat and lists earlier conversations with New chat.
- The panel opens 420 px wide, like the console drawer. It can be dragged or keyed wider from its left edge and remembers the width under its own key. On a small screen it stays an overlay. Studio's top bar now names its pillars by its own width rather than the window's, so a wide panel never pushes the robot under it.
- The chip above the composer reads "Viewing: <object label> · <view>" (「正在看:会议 · 记录」), never the internal name.
- On the Data canvas, the fields the AI assistant changed in the pending draft carry a draft chip on their records-grid column header and on their Form card. A line above the canvas says "The AI assistant just made N changes", with Review, which opens the pending changes, and "Discard all unpublished changes", which discards the package's drafts after a confirm.

`@object-ui/components`: `GridFieldAuthoring` takes an optional `columnMarks`, a node per accessorKey that `data-table` draws after the column's header label.

`@object-ui/i18n`: new studio keys `engine.studio.slot.history`, `engine.studio.slot.resize` and `engine.studio.copilotChanges.*`. Changed values: `engine.studio.aiCopilot` and `engine.studio.draftMark.agent.copilot` (AI Assistant), `console.ai.discussing` (Viewing / 正在看, in every pack), and `draftedByCopilot` (AI assistant). No key was removed. Studio no longer reads `engine.studio.slot.openFullPage`.
13 changes: 11 additions & 2 deletions ui/packages/app-shell/src/console/ai/AiChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,14 @@ interface ChatPaneProps {
onDebug?: () => void;
/** Show the Build Doctor button — true only for build-agent conversations. */
showDebug?: boolean;
/**
* objectstack#34725 — the host draws the panel's one title bar itself (the
* Studio right slot: 属性 | AI 助手, History, widen, Close), so the pane
* omits its own header row: the agent switcher, the app chip, Share and the
* Build Doctor button. The host then offers Share where it chooses.
* @default false
*/
hideHeader?: boolean;
}

export function ChatPane({
Expand Down Expand Up @@ -1812,6 +1820,7 @@ export function ChatPane({
onShare,
onDebug,
showDebug,
hideHeader = false,
}: ChatPaneProps) {
const { t, language } = useObjectTranslation();
const navigate = useNavigate();
Expand Down Expand Up @@ -2985,7 +2994,7 @@ export function ChatPane({
packageRemovalPartialLabel={(failed) => t('console.ai.packageRemovalPartial', { count: failed })}
surface="plain"
maxHeight="100%"
headerSlot={headerSlot}
headerSlot={hideHeader ? undefined : headerSlot}
// objectui#12978 — the drafts line (`pendingDraftsBar` above) is a row
// of the composer's own area, in
// flow above the input. The bar used to float (`absolute bottom-20`)
Expand Down Expand Up @@ -3276,7 +3285,7 @@ export function ChatPane({
surfaceContextLabel={
surfaceContext?.artifact
? t('console.ai.discussing', {
defaultValue: 'Discussing: {{target}}',
defaultValue: 'Viewing: {{target}}',
target:
surfaceArtifactLabel ||
`${surfaceContext.artifact.type} · ${surfaceContext.artifact.name}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* objectui#7254's ruling: what is READ is the label; the internal identity
* stays REACHABLE on a tooltip. Before this, ChatPane built the chip from the
* `context.surface` artifact alone, so the chip printed
* `Discussing: dashboard · customer_dashboard` at the reader.
* `Viewing: dashboard · customer_dashboard` at the reader.
*
* The display label reaches ChatPane as its OWN optional prop
* (`surfaceArtifactLabel`), never inside `surfaceContext` — that object is the
Expand Down Expand Up @@ -85,7 +85,7 @@ const SURFACE = {
artifact: { type: 'dashboard', name: 'customer_dashboard' },
};

function renderPane(extra: { surfaceArtifactLabel?: string; surfaceContext?: typeof SURFACE }) {
function renderPane(extra: { surfaceArtifactLabel?: string; surfaceContext?: typeof SURFACE; hideHeader?: boolean }) {
cleanup();
captured = {};
chatOptions = {};
Expand All @@ -110,6 +110,7 @@ function renderPane(extra: { surfaceArtifactLabel?: string; surfaceContext?: typ
pendingFirstMessageRef={{ current: null }}
onSent={vi.fn()}
onShare={vi.fn()}
hideHeader={extra.hideHeader}
{...labelProp}
/>
</MemoryRouter>
Expand All @@ -124,13 +125,13 @@ afterEach(() => cleanup());
describe('AI chat "discussing" chip — label read, internal id on the tooltip (objectui#8219)', () => {
it('with a display label: the chip reads the label and its title is the type · name pair', () => {
const { props } = renderPane({ surfaceContext: SURFACE, surfaceArtifactLabel: 'Customer dashboard' });
expect(props.surfaceContextLabel).toBe('Discussing: Customer dashboard');
expect(props.surfaceContextLabel).toBe('Viewing: Customer dashboard');
expect(props.surfaceContextTitle).toBe('dashboard · customer_dashboard');
});

it('with no display label: the chip falls back to the type · name pair, still reachable as its title', () => {
const { props } = renderPane({ surfaceContext: SURFACE });
expect(props.surfaceContextLabel).toBe('Discussing: dashboard · customer_dashboard');
expect(props.surfaceContextLabel).toBe('Viewing: dashboard · customer_dashboard');
expect(props.surfaceContextTitle).toBe('dashboard · customer_dashboard');
});

Expand All @@ -157,3 +158,12 @@ describe('AI chat "discussing" chip — label read, internal id on the tooltip (
expect(JSON.stringify(bodyOf(withLabel))).not.toContain('Customer dashboard');
});
});

// objectstack#34725 — a host that draws its own title bar (the Studio slot's
// one header row) asks the pane for none; every other host keeps the header.
describe('ChatPane hideHeader (objectstack#34725)', () => {
it('draws its header by default, and none when the host asks', () => {
expect(renderPane({ surfaceContext: SURFACE }).props.headerSlot).toBeTruthy();
expect(renderPane({ surfaceContext: SURFACE, hideHeader: true }).props.headerSlot).toBeUndefined();
});
});
2 changes: 1 addition & 1 deletion ui/packages/app-shell/src/preview/DraftChangesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ function EntryDetail({
data-testid="draft-entry-agent"
>
{source.by === 'copilot'
? t('preview.changes.draftedByCopilot', { defaultValue: 'Includes changes drafted by the AI copilot' })
? t('preview.changes.draftedByCopilot', { defaultValue: 'Includes changes drafted by the AI assistant' })
: source.client
? t('preview.changes.draftedByMcpClient', {
client: source.client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({
}),
}));

// The source loads `@objectstack/lint` lazily; paid here, at collection, not
// inside a case's clock (check:test-source-alias).
import '@objectstack/lint';
import { DraftChangesPanel, draftAgentSources } from '../DraftChangesPanel';

const PKG = 'com.x';
Expand Down Expand Up @@ -78,7 +81,7 @@ describe('objectstack#27176 — the drill-in names the AI tools that drafted the
await renderConfirm();
expect(agentLines()).toEqual([
'Includes changes drafted by the MCP client “Claude”',
'Includes changes drafted by the AI copilot',
'Includes changes drafted by the AI assistant',
]);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#34725 item 7 — the AI assistant's drafts on the Data canvas:
* - a line over the canvas, 「AI 刚改了 N 处」, counting the pending draft's
* `draftChanges` entries an AI tool wrote (copilot or MCP), with 查看 (the
* pending-changes sheet) and 放弃全部未发布改动 (the package's discard door,
* `packages.discardDrafts`, after a confirm) — the one undo there is;
* - the Form canvas's card of each field the assistant changed carries the
* 草稿 chip;
* - item 6: the copilot's chip names the open object by its label and the view
* on screen (`Task · Records`), never its internal name.
* CONTROL: entries a person wrote in Studio, or no draft, draw no line.
*
* The records grid's column marks ride on `GridFieldAuthoring.columnMarks`,
* pinned in `@object-ui/components` (`data-table-columnMarks-34725`): a
* field the assistant added is a draft, and the grid selects published fields
* only (cloud#1652), so a new field has no column until it is published.
*/

import '@testing-library/jest-dom/vitest';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';

const objectDef = {
name: 'showcase_task',
label: 'Task',
fields: {
priority: { name: 'priority', label: 'Priority', type: 'text' },
renewal_count: { name: 'renewal_count', label: 'Renewals', type: 'number' },
},
};

const minutesAgo = (n: number) => new Date(Date.now() - n * 60_000 - 5_000).toISOString();

/** What the next draft read serves: `null` for no draft. */
let draftEnvelope: Record<string, unknown> | null = null;

const mockClient = {
save: vi.fn(async () => ({})),
list: vi.fn(async (type: string) => (type === 'object' ? [{ name: 'showcase_task', label: 'Task' }] : [])),
listDrafts: vi.fn(async () => []),
layered: vi.fn(async () => ({ effective: objectDef, code: objectDef, draft: draftEnvelope?.item ?? null })),
getDraft: vi.fn(async () => draftEnvelope),
get: vi.fn(async () => null),
withPreviewDrafts() {
return this;
},
};

vi.mock('../metadata-admin/useMetadata', async (importOriginal) => {
const mod = await importOriginal<typeof import('../metadata-admin/useMetadata')>();
return { ...mod, useMetadataClient: () => mockClient, useMetadataTypes: () => ({ entries: [] }) };
});

vi.mock('./packages-io', async (importOriginal) => {
const mod = await importOriginal<typeof import('./packages-io')>();
return { ...mod, fetchPackages: vi.fn(async () => []) };
});

vi.mock('@object-ui/react', async (importOriginal) => {
const mod = await importOriginal<typeof import('@object-ui/react')>();
return { ...mod, useAdapter: () => dataSource };
});

import '@objectstack/lint';
import { DataPillar } from './StudioDesignSurface';
import { createEmptyDataSource, failOnAbsorbedFetchError } from './__tests__/emptyDataSource';
import { t, tFormat } from '../metadata-admin/i18n';

const discardDrafts = vi.fn(async () => ({ success: true, failedCount: 0, failed: [], discarded: [] }));
const dataSource = Object.assign(createEmptyDataSource(), {
getClient: () => ({ packages: { discardDrafts } }),
});
failOnAbsorbedFetchError();

beforeEach(() => {
draftEnvelope = null;
});
afterEach(() => {
cleanup();
vi.clearAllMocks();
});

const L = (key: string) => t(key, 'en-US');

function serveDraft(draftChanges?: unknown[]) {
draftEnvelope = {
type: 'object',
name: 'showcase_task',
item: { ...objectDef, _draft: true },
version: 'v1',
...(draftChanges ? { draftChanges } : {}),
};
}

function renderPillar(props: Partial<React.ComponentProps<typeof DataPillar>> = {}) {
return render(
<MemoryRouter initialEntries={['/studio/com.example.showcase/data']}>
<DataPillar packageId="com.example.showcase" {...props} />
</MemoryRouter>,
);
}

const AI_TWO = [
{ path: [], by: 'studio', actor: 'usr_1', at: minutesAgo(30) },
{ path: ['fields', 'renewal_count'], by: 'copilot', actor: 'usr_1', at: minutesAgo(2) },
{ path: ['fields', 'priority', 'label'], by: 'mcp', client: 'Claude Desktop', actor: 'usr_1', at: minutesAgo(1) },
];

describe('the AI assistant’s drafts on the Data canvas (objectstack#34725)', () => {
it('a line counts the AI entries; 查看 opens the review; the AI-changed field cards carry the chip', async () => {
serveDraft(AI_TWO);
const onReviewChanges = vi.fn();
renderPillar({ onReviewChanges });
const line = await screen.findByTestId('studio-copilot-changes');
expect(line).toHaveTextContent(tFormat('engine.studio.copilotChanges.line', 'en-US', { count: 2 }));
fireEvent.click(within(line).getByTestId('studio-copilot-changes-view'));
expect(onReviewChanges).toHaveBeenCalledTimes(1);

fireEvent.click(screen.getByRole('button', { name: L('engine.studio.data.tab.form') }));
await waitFor(() => expect(screen.getAllByTestId('studio-form-field-draft-chip')).toHaveLength(2));
expect(
screen.getAllByTestId('studio-form-field-draft-chip').map((chip) => chip.getAttribute('data-draft-of')).sort(),
).toEqual(['priority', 'renewal_count']);
});

it('one AI entry reads in the singular', async () => {
serveDraft([AI_TWO[1]]);
renderPillar();
expect(await screen.findByTestId('studio-copilot-changes')).toHaveTextContent(
tFormat('engine.studio.copilotChanges.lineOne', 'en-US', { count: 1 }),
);
});

it('放弃全部未发布改动 discards the package’s drafts after a confirm; a declined confirm sends nothing', async () => {
serveDraft(AI_TWO);
// jsdom draws no confirm; the pillar asks the window's.
const confirm = vi.fn().mockReturnValueOnce(false).mockReturnValueOnce(true);
const original = window.confirm;
window.confirm = confirm;
renderPillar();
const discard = await screen.findByTestId('studio-copilot-changes-discard');
expect(discard).toHaveTextContent(L('engine.studio.copilotChanges.discardAll'));
fireEvent.click(discard);
expect(confirm).toHaveBeenCalledWith(L('engine.studio.copilotChanges.discardConfirm'));
expect(discardDrafts).not.toHaveBeenCalled();

const reads = mockClient.getDraft.mock.calls.length;
draftEnvelope = null;
fireEvent.click(discard);
await waitFor(() => expect(discardDrafts).toHaveBeenCalledWith('com.example.showcase'));
// The open object is read again, and the line goes with the draft.
await waitFor(() => expect(mockClient.getDraft.mock.calls.length).toBeGreaterThan(reads));
await waitFor(() => expect(screen.queryByTestId('studio-copilot-changes')).toBeNull());
window.confirm = original;
});

it('a discard that fails names each item by its label; the server’s words stay under Details', async () => {
serveDraft(AI_TWO);
discardDrafts.mockResolvedValueOnce({
success: false,
failedCount: 2,
failed: [
{ type: 'object', name: 'showcase_task', error: 'E_LOCKED: row held by txn 42' },
{ type: 'view', name: 'showcase_task_grid', error: 'E_GONE' },
],
discarded: [],
} as never);
const original = window.confirm;
window.confirm = vi.fn(() => true);
renderPillar();
fireEvent.click(await screen.findByTestId('studio-copilot-changes-discard'));
const message = await screen.findByTestId('studio-refusal-message');
expect(message).toHaveTextContent(
tFormat('engine.studio.copilotChanges.discardFailed', 'en-US', {
items: ['Task', 'showcase_task_grid'].join(L('engine.studio.copilotChanges.itemSeparator')),
}),
);
expect(message.textContent).not.toContain('E_LOCKED');
expect(message.textContent).not.toContain('object/');
expect(screen.getByTestId('studio-refusal-detail')).toHaveTextContent('object/showcase_task: E_LOCKED: row held by txn 42');
window.confirm = original;
});

it('the copilot’s chip reads the object’s label and the view on screen', async () => {
const onSurfaceLabelChange = vi.fn();
renderPillar({ onSurfaceLabelChange });
await waitFor(() =>
expect(onSurfaceLabelChange).toHaveBeenLastCalledWith({
type: 'object',
name: 'showcase_task',
label: `Task · ${L('engine.studio.data.tab.records')}`,
}),
);
fireEvent.click(await screen.findByRole('button', { name: L('engine.studio.data.tab.form') }));
await waitFor(() =>
expect(onSurfaceLabelChange).toHaveBeenLastCalledWith(
expect.objectContaining({ label: `Task · ${L('engine.studio.data.tab.form')}` }),
),
);
});

it('CONTROL: entries a person wrote in Studio, or no draft at all, draw no line', async () => {
serveDraft([{ path: ['fields', 'renewal_count'], by: 'studio', actor: 'usr_1', at: minutesAgo(2) }]);
renderPillar();
await screen.findByRole('button', { name: L('engine.studio.data.tab.form') });
await waitFor(() => expect(mockClient.getDraft).toHaveBeenCalled());
expect(screen.queryByTestId('studio-copilot-changes')).toBeNull();
cleanup();

renderPillar();
await screen.findByRole('button', { name: L('engine.studio.data.tab.form') });
expect(screen.queryByTestId('studio-copilot-changes')).toBeNull();
});
});
Loading
Loading