From f93475fb0b4cedcd9b508c35249c8c732353ad6f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 03:45:56 +0000 Subject: [PATCH 1/4] fix(app-shell): a Studio package create answers with a toast naming the new package; pin Revoke's toast on the Studio Access strip Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY --- .../metadata-admin/PackageFormDialog.test.tsx | 77 ++++++++++++++++++- .../metadata-admin/PackageFormDialog.tsx | 10 +++ ...e.accessSuggestionsReadOnly-33158.test.tsx | 63 +++++++++++++++ ui/packages/i18n/src/namespaces/studio/en.ts | 1 + ui/packages/i18n/src/namespaces/studio/zh.ts | 1 + 5 files changed, 151 insertions(+), 1 deletion(-) diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx index e6eaddc568f..ff7d8e59985 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx @@ -4,7 +4,8 @@ import * as React from 'react'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { render, screen, fireEvent, waitFor } from '@testing-library/react'; import { PackageFormDialog } from './PackageFormDialog'; -import { t } from './i18n'; +import { toast } from 'sonner'; +import { t, tFormat } from './i18n'; // The designer rows this suite reads in zh live in `@object-ui/i18n`'s `studio` // namespace, whose `zh` catalogue is fetched on demand (objectstack#25922). // Resident before any case, so the zh rows below read synchronously. @@ -199,3 +200,77 @@ describe('PackageFormDialog — capability refusal (objectstack#8270)', () => { expect(screen.queryByText(t('engine.packages.noCapability', 'en-US'))).toBeNull(); }); }); + +/** + * objectstack#33865 (`ux-conventions.write-feedback`) — a package create is a + * write, and it answers with a toast naming the new package by its display + * name (label first). The dialog closes on success and every caller then + * navigates or re-lists, so without the toast nothing on screen says the + * write landed. + * + * Pinned: + * - a create the server accepts toasts the created sentence once, naming the + * package by its display name, not its id; + * - zh: the same toast in the zh sentence; + * - CONTROL: a refused create (409) toasts nothing and keeps its banner; + * - CONTROL: an edit save does not answer with the created sentence. + */ +describe('PackageFormDialog — a create answers with a toast naming the package (objectstack#33865)', () => { + let success: ReturnType; + beforeEach(() => { + success = vi.spyOn(toast, 'success').mockImplementation(() => 'toast'); + }); + afterEach(() => success.mockRestore()); + + it('toasts the created sentence once, naming the package by its display name', async () => { + const onSaved = vi.fn(); + render(); + await submitCreate(); + + await waitFor(() => expect(onSaved).toHaveBeenCalledTimes(1)); + expect(success).toHaveBeenCalledTimes(1); + expect(success).toHaveBeenCalledWith(tFormat('engine.packages.create.created', 'en-US', { name: 'New App' })); + expect(success.mock.calls[0][0]).not.toContain('com.acme.new'); + }); + + it('zh: the toast reads the zh sentence', async () => { + localeFixture = 'zh-CN'; + const onSaved = vi.fn(); + render(); + await submitCreate('zh-CN'); + + await waitFor(() => expect(onSaved).toHaveBeenCalledTimes(1)); + const zh = tFormat('engine.packages.create.created', 'zh-CN', { name: 'New App' }); + expect(zh).not.toBe(tFormat('engine.packages.create.created', 'en-US', { name: 'New App' })); + expect(success).toHaveBeenCalledWith(zh); + }); + + it('CONTROL: a refused create toasts nothing and keeps its banner', async () => { + stubRefusal(409, "Package 'com.acme.new' already exists"); + const onSaved = vi.fn(); + render(); + await submitCreate(); + + expect(await screen.findByText(t('engine.packages.create.exists', 'en-US'))).toBeInTheDocument(); + expect(onSaved).not.toHaveBeenCalled(); + expect(success).not.toHaveBeenCalled(); + }); + + it('CONTROL: an edit save does not answer with the created sentence', async () => { + const onSaved = vi.fn(); + render( + , + ); + fireEvent.click(await screen.findByTestId('package-form-submit')); + + await waitFor(() => expect(onSaved).toHaveBeenCalledTimes(1)); + expect(calls[0].init.method).toBe('PATCH'); + expect(success).not.toHaveBeenCalled(); + }); +}); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.tsx index f12d844934e..fd0aefbaa84 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.tsx @@ -38,6 +38,7 @@ import * as React from 'react'; import { AlertTriangle, ChevronDown } from 'lucide-react'; +import { toast } from 'sonner'; import { ManifestSchema, deriveNamespaceFromPackageId } from '@objectstack/spec/kernel'; import { useAuth } from '@object-ui/auth'; import { NAMESPACE_RE, isSpecPackageId } from '../studio-design/packages-io.js'; @@ -610,6 +611,15 @@ export function PackageFormDialog({ }); const id = String((created?.manifest?.id as string) ?? manifestBody.id); result = { id, mode, package: created }; + // `ux-conventions.write-feedback`: the create answers with a toast + // naming the new package by its display name — the dialog closes + // and the caller may navigate away, so nothing else on screen says + // the write landed. A refusal stays in the dialog's banner below. + toast.success( + tFormat('engine.packages.create.created', locale, { + name: String((created?.manifest?.name as string) ?? manifestBody.name), + }), + ); } else { const id = String((manifest?.id as string) ?? draft.id ?? ''); // The REST PATCH persists name / description / version / dependencies diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.accessSuggestionsReadOnly-33158.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.accessSuggestionsReadOnly-33158.test.tsx index 134448ee906..bf2e6af79a3 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.accessSuggestionsReadOnly-33158.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.accessSuggestionsReadOnly-33158.test.tsx @@ -238,3 +238,66 @@ describe('objectstack#33864 — the suggested-bindings strip names its set by la ); }); }); + +/** + * objectstack#33865 (`ux-conventions.write-feedback`) — Revoke on a granted + * suggestion is a write, and it answers with a toast naming the set, as Grant + * and Dismiss do. The Studio mount hands the strip its own `revokedToast` + * sentence; this reads it through the REAL pillar: Grant, then Revoke on the + * row the Grant left. + * + * Pinned: + * - Grant → Revoke: the Revoke answers with the revoked sentence naming the + * set by its label, after the Grant's own toast, and the row then reads + * dismissed with Reconsider; + * - CONTROL: a Revoke the server refuses answers with the server's message + * and never the revoked sentence — the toast follows the write, not the + * press. + */ +describe('objectstack#33865 — Revoke on a granted suggestion answers with a toast', () => { + const fmt = (key: string, set: string, anchor?: string) => + tFormat(key, 'en', anchor === undefined ? { set } : { set, anchor }); + const GRANTED = { ...PENDING, status: 'confirmed' as const, deployment_decision: true }; + + async function grant() { + api.list.mockResolvedValue([PENDING]); + api.confirm.mockResolvedValue({ suggestion: GRANTED, bindingCreated: true }); + renderAccess(false); + const row = await screen.findByTestId('suggested-binding-crm_user', undefined, { timeout: 8000 }); + await waitFor(() => expect(row).toHaveTextContent('CRM user')); + within(row).getByTestId('suggested-binding-confirm-crm_user').click(); + await waitFor(() => + expect(toast.success).toHaveBeenCalledWith( + fmt('engine.studio.access.suggestConfirmedToast', 'CRM user', 'everyone'), + ), + ); + return screen.findByTestId('suggested-binding-revoke-crm_user'); + } + + it('Grant then Revoke: the Revoke toasts the revoked sentence naming the set, and the row reads dismissed', async () => { + api.dismiss.mockResolvedValue({ ...GRANTED, status: 'dismissed' }); + const revoke = await grant(); + expect(toast.success).toHaveBeenCalledTimes(1); + + revoke.click(); + await waitFor(() => + expect(toast.success).toHaveBeenLastCalledWith(fmt('engine.studio.access.suggestRevokedToast', 'CRM user')), + ); + expect(toast.success).toHaveBeenCalledTimes(2); + expect(api.dismiss).toHaveBeenCalledWith('sug_1'); + const row = screen.getByTestId('suggested-binding-crm_user'); + await waitFor(() => expect(row).toHaveAttribute('data-state', 'dismissed')); + expect(row).toHaveTextContent(fmt('engine.studio.access.suggestDismissedState', 'CRM user')); + expect(within(row).getByTestId('suggested-binding-reopen-crm_user')).toBeInTheDocument(); + }); + + it('CONTROL: a refused Revoke toasts the server message, never the revoked sentence', async () => { + api.dismiss.mockRejectedValue(refused(409, 'CONFLICT', 'the suggestion changed under you')); + const revoke = await grant(); + + revoke.click(); + await waitFor(() => expect(toast.error).toHaveBeenCalledWith('the suggestion changed under you')); + expect(toast.success).toHaveBeenCalledTimes(1); + expect(toast.success).not.toHaveBeenCalledWith(fmt('engine.studio.access.suggestRevokedToast', 'CRM user')); + }); +}); diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index a59794fa927..7dcd818609a 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -1954,6 +1954,7 @@ const STUDIO_EN: Record = { 'engine.packages.create.submit': 'Create package', 'engine.packages.create.failed': 'Failed to create package', 'engine.packages.create.exists': 'A package with this id already exists.', + 'engine.packages.create.created': 'Created package “{name}”.', // objectstack#8270 — the server refuses package writes without the ADR-0066 // `manage_metadata` capability, and its refusal is an English sentence that // reached a zh console verbatim. Deployments that withhold the capability do diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 6ae18787354..542ebb56066 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -1737,6 +1737,7 @@ const STUDIO_ZH: Record = { 'engine.packages.create.submit': '创建软件包', 'engine.packages.create.failed': '创建软件包失败', 'engine.packages.create.exists': '已存在相同 ID 的软件包。', + 'engine.packages.create.created': '已创建软件包「{name}」。', // objectstack#8270 — 这条正是在 zh 控制台里显示为英文原文的服务端拒绝信息。 'engine.packages.noCapability': '你没有在本系统管理软件包的权限 — 该操作需要「管理元数据」权限。', 'engine.packages.form.basics': '基本信息', From b37957ef64b1cdc8ed69958185954ceab9b7cebf Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 03:56:07 +0000 Subject: [PATCH 2/4] chore(changeset): package create toast Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY --- .changeset/33865-package-create-toast.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .changeset/33865-package-create-toast.md diff --git a/.changeset/33865-package-create-toast.md b/.changeset/33865-package-create-toast.md new file mode 100644 index 00000000000..66655f2b7c5 --- /dev/null +++ b/.changeset/33865-package-create-toast.md @@ -0,0 +1,15 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +--- + +fix(console): creating a package answers with a toast naming the new package + +Clause-②: no +Metadata-protocol: none + +Creating a package (Studio's *New app*, the Studio package switcher's *New package*, and the Packages page) closed the dialog and moved on with nothing on screen saying the write landed. The create dialog now shows a success toast naming the new package by its display name: "Created package “NAME”." (zh: 已创建软件包「NAME」。). A refused create shows no toast and keeps its message in the dialog, as before; saving an edit is unchanged. + +New locale key: `engine.packages.create.created` in the studio catalogue (en, zh). No props or exports change. + +Revoke on a granted suggested binding in Studio Access already answers with its toast ("“SET” is no longer granted by default."); a new pin on the Studio mount holds it. From c758722c8347c6870fb0441943abd0e326b2c1cb Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 04:13:13 +0000 Subject: [PATCH 3/4] test(app-shell): pay the CEL fields' dynamic loads at module top in the PackageFormDialog harness Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY --- .../src/views/metadata-admin/PackageFormDialog.test.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx index ff7d8e59985..c346d925d9a 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx @@ -10,6 +10,11 @@ import { t, tFormat } from './i18n'; // namespace, whose `zh` catalogue is fetched on demand (objectstack#25922). // Resident before any case, so the zh rows below read synchronously. import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; +// The source under test reaches dynamic `import('@objectstack/formula')` and +// `import('@objectstack/lint')` (the spec form's CEL fields); pay those loads +// during collection, never inside a case's clocked window. +import '@objectstack/formula'; +import '@objectstack/lint'; await loadStudioCatalogue('zh'); // Which console language the dialog renders in. Only `useMetadataLocale` is From e42d8d25d7035112baacb7f475c1861dee9aca4e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 04:17:30 +0000 Subject: [PATCH 4/4] test(app-shell): type the toast spy in the PackageFormDialog harness Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY --- .../src/views/metadata-admin/PackageFormDialog.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx index c346d925d9a..b01ef39415b 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.test.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. import * as React from 'react'; -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { describe, it, expect, vi, beforeEach, afterEach, type MockInstance } from 'vitest'; import { render, screen, fireEvent, waitFor } from '@testing-library/react'; import { PackageFormDialog } from './PackageFormDialog'; import { toast } from 'sonner'; @@ -221,7 +221,7 @@ describe('PackageFormDialog — capability refusal (objectstack#8270)', () => { * - CONTROL: an edit save does not answer with the created sentence. */ describe('PackageFormDialog — a create answers with a toast naming the package (objectstack#33865)', () => { - let success: ReturnType; + let success: MockInstance; beforeEach(() => { success = vi.spyOn(toast, 'success').mockImplementation(() => 'toast'); });