Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b4986e8
wip(studio): top-bar Save and Cancel for the object page
claude Nov 22, 2026
2dc4f5e
test(studio): pin the object page's top-bar Save and Cancel
claude Nov 22, 2026
7bec409
test(studio): the top bar draws Save where Publish was
claude Nov 22, 2026
3688cdc
fix(studio): Save waits out the expression check; gate pins press Save
claude Nov 22, 2026
7e799ec
test(studio): Data pillar pins press the top bar's Save
claude Nov 22, 2026
17cc57e
test(studio): extension, verdict, switch and toast pins follow Save
claude Nov 22, 2026
4334528
test(studio): top-bar, in-flight, switch and conflict pins follow Save
claude Nov 22, 2026
9dac29f
chore(changeset): Studio object page saves with Cancel and Save
claude Nov 23, 2026
e428611
Merge remote-tracking branch 'origin/main' into claude/issue-36511-st…
claude Nov 23, 2026
b6f217c
test(studio): narrow the verdict double's refused errors
claude Nov 23, 2026
40ddad6
test(studio): the field-groups pins press Save
claude Nov 23, 2026
38d5312
test(studio): pay the linter's first load at collection; the lint deb…
claude Nov 23, 2026
1d6c084
fix(studio): the save bar's registry adds a buffer with enlist, not r…
claude Nov 23, 2026
a184f37
wip(studio): the hooks buffer lifted to the Data pillar, saved by the…
claude Nov 23, 2026
bb08756
wip(studio): the hooks conflict dialog drawn by the pillar
claude Nov 23, 2026
0a019af
fix(studio): drop the unused act imports; the live journey presses Sa…
claude Nov 23, 2026
e24dc99
Merge remote-tracking branch 'origin/claude/issue-36511-studio-save-c…
claude Nov 23, 2026
e31fc76
wip(studio): an installed app's pair actions are buffered by the Data…
claude Nov 23, 2026
143e648
wip(studio): a flow saves with the top bar; its switch and its creati…
claude Nov 23, 2026
4c422b7
wip(studio): a permission set in the Studio saves with the top bar an…
claude Nov 23, 2026
39ff806
Merge remote-tracking branch 'origin/main' into claude/issue-36511-st…
claude Nov 23, 2026
f1eaf8d
Merge remote-tracking branch 'origin/claude/issue-36511-studio-save-c…
claude Nov 23, 2026
1f40ec2
test(studio): hooks, pair actions, flows and permission sets save wit…
claude Nov 23, 2026
aaf407c
test(studio): the hooks, flow and permission suites send with the top…
claude Nov 23, 2026
3a6306c
test(studio): a flow created and switched on, and the first-save pins…
claude Nov 23, 2026
2892cbd
Merge remote-tracking branch 'origin/main' into claude/issue-36511-st…
claude Nov 23, 2026
1f94c2a
test(studio): the suites that reach the lint loader pay it at collection
claude Nov 23, 2026
de12f2b
Merge remote-tracking branch 'origin/main' into claude/issue-36511-st…
claude Nov 23, 2026
1dc9a50
feat(studio): every human editor saves live; an item's unpublished AI…
claude Nov 23, 2026
1371428
Merge remote-tracking branch 'origin/main' into claude/issue-36511-st…
claude Nov 23, 2026
f9e6bad
test(studio): warm the console's lazy authoring imports at module top…
claude Nov 23, 2026
a4ee300
fix(studio): the OWD overview reads live rows back before it asks the…
claude Nov 23, 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
13 changes: 13 additions & 0 deletions .changeset/36511-studio-save-cancel-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

feat(studio): every human editor in Studio saves live; an item's unpublished AI changes can be dropped on its page

Clause-②: no
Metadata-protocol: none

Every editor a person uses in Studio's object, automation and access pages now saves with the top bar's Save and Cancel, and a Save is live at once: an object's fields, field layout, validation rules, actions, settings and hooks, flows, and now permission sets and the Access pillar's record-sharing overview, which no longer has a Save of its own. A permission set no longer autosaves a draft 1.5 s after each edit, and the access banners say that Save makes a change live. Creating an object, a flow or a permission set makes it live at once too, so those create dialogs say Create instead of Save as draft; apps, pages, dashboards, reports and datasets are still created as drafts.

Changes and Publish are left for the AI assistant's drafts. When an object or a flow holds an unpublished draft the assistant wrote, its page says that saving makes those changes live too and offers to discard them: that one item's draft is dropped, the page goes back to the live version, and Changes counts one item fewer. Unsaved edits on the page go with the discard, after a confirm.
2 changes: 1 addition & 1 deletion .changeset/36511-studio-save-cancel.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
Expand All @@ -12,4 +12,4 @@

Changes and Publish are drawn only while drafts are pending (a copilot's, or another editor's), and a publish waits while the page holds edits Save has not sent. A Save refused by the server keeps the edits on the page with the reason, and its toast names each refused item with its reason and lists the items that were saved. Removing or retyping a published field asks first. Save waits out the expression checks of the last keystroke, so a formula or rule guard that does not parse is never sent. Leaving the page, or opening another object, with unsaved edits asks, as every departure does.

Other Studio editors (flows, hooks, list and form views, navigation, permissions) keep their draft autosave for now.
Hooks, flows and permission sets moved to the same Save in later changes; list views and navigation keep their draft autosave for now.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
* bulk arms, in `PermissionMatrixEditor.bulkMergeKeys.test.tsx`.
*/

// Warmed at module top so the first load of the console's lazily loaded
// authoring code is paid during collection, not inside a test's clock.
import '@objectstack/formula';
import '@objectstack/lint';
import '@testing-library/jest-dom/vitest';
import { describe, it, expect, vi, afterEach } from 'vitest';
import { render, screen, cleanup, fireEvent, waitFor, within } from '@testing-library/react';
Expand Down Expand Up @@ -53,6 +57,9 @@ function makeClient(server: FakeServer) {
server.set = payload; // the reopen reads what was saved
return payload;
},
// objectstack#36511 — the Studio's Save publishes the set it wrote.
publish: async () => ({ success: true }),
reset: async () => ({ success: true }),
} as any;
}

Expand All @@ -74,6 +81,7 @@ vi.mock('@object-ui/fields', async (importOriginal) => ({
}));

import { PermissionMatrixEditPage } from './PermissionMatrixEditor';
import { StudioSaveHarness, pressStudioSave } from '../studio-design/__tests__/studioSaveHarness';

afterEach(cleanup);

Expand All @@ -93,13 +101,15 @@ async function mount(server: FakeServer, site: Site, packageId?: string) {
const utils = render(
<MemoryRouter>
{site === 'studio' ? (
<PermissionMatrixEditPage
type="permission"
name="sales_perms"
packageId={packageId}
embedded
studio={{ tab: 'objects', onTabChange: () => {} }}
/>
<StudioSaveHarness>
<PermissionMatrixEditPage
type="permission"
name="sales_perms"
packageId={packageId}
embedded
studio={{ tab: 'objects', onTabChange: () => {} }}
/>
</StudioSaveHarness>
) : (
<PermissionMatrixEditPage type="permission" name="sales_perms" packageId={packageId} />
)}
Expand Down Expand Up @@ -220,6 +230,8 @@ describe.each<Site>(['page', 'studio'])('record scope pickers (%s renderer)', (s
await mount(server, site, 'app.a');

await pick(readPicker('a_account'), 'Own and reports');
// objectstack#36511 — in the Studio the top bar's Save sends it; the page autosaves.
if (site === 'studio') await pressStudioSave();
const payload = await autosaved(server);
expect(payload.objects.a_account).toEqual({ allowRead: true, readScope: 'own_and_reports' });
expect(payload.objects.b_order).toEqual({ allowRead: true, readScope: 'unit' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* query string the server would read.
*/

// Warmed at module top so the first load of the console's lazily loaded
// authoring code is paid during collection, not inside a test's clock.
import '@objectstack/lint';
import '@testing-library/jest-dom/vitest';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
Expand Down Expand Up @@ -63,6 +66,8 @@ const client = {
getDraft: async () => null,
get: async () => null,
save: (...args: Parameters<MetadataClient['save']>) => wire.save(...args),
publish: (...args: Parameters<MetadataClient['publish']>) => wire.publish(...args),
reset: (...args: Parameters<MetadataClient['reset']>) => wire.reset(...args),
};

vi.mock('./useMetadata', async (importOriginal) => {
Expand All @@ -85,6 +90,7 @@ vi.mock('../studio-design/StudioAiCopilot', () => ({ StudioChatDock: () => null
import '../../services/builtinComponents.js';
import { MetadataResourceEditPage } from './ResourceEditPage';
import { AccessPillar } from '../studio-design/StudioDesignSurface';
import { StudioSaveHarness, pressStudioSave } from '../studio-design/__tests__/studioSaveHarness';

window.matchMedia = ((query: string) => ({
matches: false,
Expand All @@ -111,13 +117,17 @@ afterEach(cleanup);
describe('the permission matrix states `surface` only under the Studio host (objectui#12725)', () => {
it('Studio’s Access pillar: the draft save sends `?surface=studio`, once', async () => {
render(
<MemoryRouter>
<AccessPillar packageId={PKG} />
</MemoryRouter>,
<StudioSaveHarness>
<MemoryRouter>
<AccessPillar packageId={PKG} />
</MemoryRouter>
</StudioSaveHarness>,
);
await waitFor(() => expect(readBox()).toBeInTheDocument(), AUTOSAVE);

fireEvent.click(readBox());
// objectstack#36511 — sent by the top bar's Save.
await pressStudioSave();
await waitFor(() => expect(puts).toHaveLength(1), AUTOSAVE);
expect(puts[0]!.get('mode')).toBe('draft');
expect(puts[0]!.get('package')).toBe(PKG);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#36511 — a permission set in the Studio's Access pillar saves with
* the top bar's Save and Cancel, and a Save is live at once.
*
* - A grant clicked sends nothing: no draft write leaves before Save is
* pressed, however long the page waits (the set's 1.5 s autosave is gone
* from the Studio).
* - Save writes the set's draft at its package, then publishes that one set at
* the same package (`POST /meta/permission/NAME/publish?package=`).
* - Cancel sends nothing and puts the matrix back as the server holds it.
* - A refused publish keeps the grant unsaved, says why on the page, and takes
* back the draft the Save wrote.
*
* The REAL `AccessPillar` inside the top bar's coordinator; the writes go
* through a REAL `MetadataClient` whose transport records each one, so the pins
* read the URL the server would read. The environment door (metadata-admin,
* no package) keeps its own Save and live write: pinned in
* `PermissionMatrixEditor.saveSurface-12725.test.tsx`.
*/

// Warmed at module top so the first load of the console's lazily loaded
// authoring code is paid during collection, not inside a test's clock.
import '@objectstack/lint';
import '@testing-library/jest-dom/vitest';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { MetadataClient } from '@object-ui/data-objectstack';

const PKG = 'com.acme.crm';

const SET = {
name: 'sales_perms',
label: 'Sales',
objects: { a_account: { allowRead: false, allowCreate: true } },
fields: {},
};

interface Write {
method: string;
url: URL;
body: Record<string, unknown> | null;
}
const writes: Write[] = [];
const door = { refusePublish: false };

const json = (status: number, body: unknown) =>
new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } });

async function serve(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
const url = new URL(String(input), 'http://console.test');
const method = (init?.method ?? 'GET').toUpperCase();
if (method === 'GET') return json(404, { error: { code: 'NOT_FOUND', message: 'absent' } });
writes.push({ method, url, body: init?.body ? JSON.parse(String(init.body)) : null });
if (method === 'POST' && door.refusePublish) {
return json(422, { success: false, error: { code: 'INVALID_METADATA', message: 'The set grants on an object that is not live.' } });
}
return json(200, { success: true, version: 'v2', state: url.searchParams.get('mode') ?? 'active' });
}

const wire = new MetadataClient({ baseUrl: '', fetch: vi.fn(serve) as unknown as typeof fetch });

/** The reads the pillar makes, answered in memory; the writes are the real client's. */
const client = {
withPreviewDrafts() { return this; },
list: async (type: string) => {
if (type === 'permission') return [{ name: SET.name, label: SET.label }];
if (type === 'object') return [{ name: 'a_account', label: 'Account' }];
return [];
},
listDrafts: async () => [],
layered: async () => ({ effective: SET, code: null, overlay: null, overlayScope: null }),
getDraft: async () => null,
get: async () => null,
save: (...args: Parameters<MetadataClient['save']>) => wire.save(...args),
publish: (...args: Parameters<MetadataClient['publish']>) => wire.publish(...args),
reset: (...args: Parameters<MetadataClient['reset']>) => wire.reset(...args),
};

vi.mock('./useMetadata', async (importOriginal) => {
const actual = await importOriginal<Record<string, unknown>>();
return {
...actual,
useMetadataClient: () => client,
useMetadataTypes: () => ({
loading: false,
error: null,
entries: [{ type: 'permission', label: 'Permission', allowEnvironmentOverlay: true }],
}),
};
});
vi.mock('sonner', () => ({
toast: { success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn(), message: vi.fn(), dismiss: vi.fn() },
Toaster: () => null,
}));
vi.mock('./AssignedUsersSection', () => ({ AssignedUsersSection: () => null }));
vi.mock('./AccessExplainPanel', () => ({ AccessExplainPanel: () => null }));
vi.mock('../../components/SuggestedBindingsPanel', () => ({ SuggestedBindingsPanel: () => null }));
vi.mock('../studio-design/StudioAiCopilot', () => ({ StudioChatDock: () => null }));

import { toast } from 'sonner';
import { AccessPillar } from '../studio-design/StudioDesignSurface';
import { StudioSaveHarness, pressStudioCancel, pressStudioSave } from '../studio-design/__tests__/studioSaveHarness';
import { tFormat } from './i18n';

window.matchMedia = ((query: string) => ({
matches: false,
media: query,
onchange: null,
addEventListener: () => {},
removeEventListener: () => {},
addListener: () => {},
removeListener: () => {},
dispatchEvent: () => false,
})) as unknown as typeof window.matchMedia;

const readBox = () => screen.getByRole('checkbox', { name: 'a_account Read' });
const describeWrite = (w: Write) => `${w.method} ${w.url.pathname}${w.url.search}`;

/** Past the retired autosave's 1.5 s debounce and a round trip. */
async function waitPastTheOldAutosave(): Promise<void> {
await act(async () => {
await new Promise((r) => setTimeout(r, 2300));
});
}

async function mount(): Promise<void> {
render(
<StudioSaveHarness>
<MemoryRouter>
<AccessPillar packageId={PKG} />
</MemoryRouter>
</StudioSaveHarness>,
);
await waitFor(() => expect(readBox()).toBeInTheDocument(), { timeout: 8000 });
expect(readBox()).not.toBeChecked();
}

beforeEach(() => {
window.confirm = vi.fn(() => true) as unknown as typeof window.confirm;
});
afterEach(() => {
cleanup();
writes.length = 0;
door.refusePublish = false;
vi.mocked(toast.success).mockClear();
vi.mocked(toast.error).mockClear();
});

describe('Access — a permission set saves with the top bar, live at once (objectstack#36511)', () => {
it('a grant sends nothing until Save; Save writes the draft, then publishes that set at its package', async () => {
await mount();
expect(screen.queryByTestId('studio-save')).toBeNull();
fireEvent.click(readBox());
expect(await screen.findByTestId('studio-save')).toBeInTheDocument();
await waitPastTheOldAutosave();
expect(writes.map(describeWrite), 'no write before Save').toEqual([]);

await pressStudioSave();
await waitFor(() => expect(writes).toHaveLength(2), { timeout: 4000 });
const [draft, publish] = writes;
expect(draft.method).toBe('PUT');
expect(draft.url.pathname).toBe('/api/v1/meta/permission/sales_perms');
expect(draft.url.searchParams.get('mode')).toBe('draft');
expect(draft.url.searchParams.get('package')).toBe(PKG);
expect((draft.body?.objects as Record<string, { allowRead?: boolean }>).a_account.allowRead).toBe(true);
expect(publish.method).toBe('POST');
expect(publish.url.pathname).toBe('/api/v1/meta/permission/sales_perms/publish');
expect(publish.url.searchParams.get('package')).toBe(PKG);

await waitFor(() => expect(screen.queryByTestId('studio-save')).toBeNull());
expect(readBox()).toBeChecked();
expect(toast.success).toHaveBeenCalledWith(tFormat('engine.studio.save.done', 'en', { items: 'Sales' }), { id: 'studio-save' });
});

it('Cancel sends nothing and puts the matrix back as the server holds it', async () => {
await mount();
fireEvent.click(readBox());
expect(readBox()).toBeChecked();
await pressStudioCancel();
await waitFor(() => expect(readBox()).not.toBeChecked());
expect(screen.queryByTestId('studio-save')).toBeNull();
await waitPastTheOldAutosave();
expect(writes.map(describeWrite)).toEqual([]);
});

it('a refused publish keeps the grant unsaved, says why, and takes back the draft it wrote', async () => {
door.refusePublish = true;
await mount();
fireEvent.click(readBox());
await pressStudioSave();
await waitFor(() => expect(writes.map((w) => w.method)).toEqual(['PUT', 'POST', 'DELETE']), { timeout: 4000 });
const discard = writes[2];
expect(discard.url.pathname).toBe('/api/v1/meta/permission/sales_perms');
expect(discard.url.searchParams.get('state')).toBe('draft');
expect(discard.url.searchParams.get('package')).toBe(PKG);
expect(readBox(), 'the grant is still on the page').toBeChecked();
expect(screen.getByTestId('studio-save'), 'and still offered to Save').toBeInTheDocument();
expect(await screen.findByText(/The set grants on an object that is not live\./)).toBeInTheDocument();
expect(toast.success).not.toHaveBeenCalled();
});
});
Loading
Loading