diff --git a/.changeset/38302-ai-draft-discard-never-published.md b/.changeset/38302-ai-draft-discard-never-published.md new file mode 100644 index 00000000000..115f9793789 --- /dev/null +++ b/.changeset/38302-ai-draft-discard-never-published.md @@ -0,0 +1,11 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +--- + +fix(app-shell): the AI-draft line's discard says it deletes an item that was never published + +Clause-②: no +Metadata-protocol: none + +Studio's AI-draft line (「放弃 AI 的改动」) titled its discard "go back to the live version" on every item. An item that was never published has no live version, and dropping its draft deletes it. The line now takes a `published` reading from its host and, for an item with none, titles the discard and words the unsaved-edit confirm as a delete (`engine.studio.aiDraft.discardTitleUnpublished`, `engine.studio.aiDraft.discardConfirmUnsavedUnpublished`, en and zh). A host that cannot tell keeps the live-version wording. diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx index fdd7af7db79..448ab7027ed 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx @@ -128,7 +128,7 @@ import { import { usePackageCreateAsk } from './PackageCreateAsk.js'; // objectstack#36902 — Save takes effect at once; the AI draft's notice is the designers'. import { isAiDraft, publishDetailSave } from './detailSaveAtOnce.js'; -import { StudioAiDraftNotice } from '../studio-design/StudioAiDraftNotice.js'; +import { StudioAiDraftNotice, aiDraftDiscardConfirmUnsaved } from '../studio-design/StudioAiDraftNotice.js'; import { publishFailureOf, publishRefusal, type StudioRefusal } from '../studio-design/metadataError.js'; import { emitMetadataRefresh } from '../../assistant/assistantBus.js'; // objectstack#29148 — the one strip a Studio editor draws for a refused draft read. @@ -2648,7 +2648,8 @@ function MetadataResourceEditPageImpl({ setPendingConfirm({ kind: 'discardAi', title: t('engine.studio.aiDraft.discard', locale), - description: t('engine.studio.aiDraft.discardConfirmUnsaved', locale), + // objectstack#38302 — an item that holds no layer was never published: the discard deletes it. + description: aiDraftDiscardConfirmUnsaved(locale, !holdsNoLayer(layered)), actionLabel: t('engine.studio.aiDraft.discard', locale), item: ownItemLabel() || `${type}/${name ?? ''}`, }); @@ -3342,6 +3343,7 @@ function MetadataResourceEditPageImpl({ {aiDraft && ( diff --git a/ui/packages/app-shell/src/views/studio-design/AutomationsPillar.tsx b/ui/packages/app-shell/src/views/studio-design/AutomationsPillar.tsx index adc8b166fbf..e453fed7d52 100644 --- a/ui/packages/app-shell/src/views/studio-design/AutomationsPillar.tsx +++ b/ui/packages/app-shell/src/views/studio-design/AutomationsPillar.tsx @@ -29,7 +29,7 @@ import { AUTOMATIONS_CONFIG_FOLD_WIDTH, useIsNarrowerThan } from './wideViewport import { STUDIO_FOLD_LABEL } from './studio-tokens.js'; import { StudioInspector } from './StudioInspector.js'; import { isAgentDraftSurface } from './StudioDraftMark.js'; -import { StudioAiDraftNotice } from './StudioAiDraftNotice.js'; +import { StudioAiDraftNotice, aiDraftDiscardConfirmUnsaved } from './StudioAiDraftNotice.js'; import { StudioTab } from './StudioItemHeader.js'; import { ResourceDetailHeader, detailListHref } from '../metadata-admin/ResourceDetailHeader.js'; import { ItemToolTabPanel, ItemToolTabStrip } from '../item-tools/ItemToolTabs.js'; @@ -799,10 +799,14 @@ export function AutomationsPillar({ // read at), back to the live version. Edits not yet saved go with it, asked first. const flowAiDraft = flowLoaded && hasDraft && (flowDraftChanges ?? []).some((change) => isAgentDraftSurface(change.by)); + // objectstack#38302 — a flow the published list does not hold has no live + // version: its discard deletes it, and the line and the confirm say so. + // `undefined` while that list is unread or its read failed. + const flowPublished = current && publishedFlowNames ? publishedFlowNames.has(current.name) : undefined; const [discardingFlowDraft, setDiscardingFlowDraft] = React.useState(false); const discardFlowDraft = React.useCallback(async () => { if (!current) return; - if (autoDirty && !window.confirm(t('engine.studio.aiDraft.discardConfirmUnsaved', locale))) return; + if (autoDirty && !window.confirm(aiDraftDiscardConfirmUnsaved(locale, flowPublished))) return; const at = flowReadAtRef.current?.key === `flow:${current.name}` ? flowReadAtRef.current.at : draftPackageId; setDiscardingFlowDraft(true); setError(null); @@ -821,7 +825,7 @@ export function AutomationsPillar({ } finally { setDiscardingFlowDraft(false); } - }, [autoDirty, client, current, draftPackageId, locale, reloadFlowDraft]); + }, [autoDirty, client, current, draftPackageId, flowPublished, locale, reloadFlowDraft]); // objectui#12725 — the header's draft line reads the badge's ledger. const flowDraftStatus = useStudioItemDraftStatus( current ? { type: 'flow', name: current.name } : null, @@ -1497,6 +1501,7 @@ export function AutomationsPillar({ {flowAiDraft && ( void discardFlowDraft() : undefined} busy={discardingFlowDraft || saving !== false} /> @@ -1597,7 +1602,7 @@ export function AutomationsPillar({ section, onSectionChange: setFlowSection, onProblemsChange: setProblemTally, - published: current && publishedFlowNames ? publishedFlowNames.has(current.name) : undefined, + published: flowPublished, // objectstack#34818 — in the right slot, Debug draws the simulator there. debugTarget: inSlot && section === 'debug' ? slot.propsTarget : null, }} diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.aiDraftNeverPublished-38302.test.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.aiDraftNeverPublished-38302.test.tsx new file mode 100644 index 00000000000..f89b7f92677 --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.aiDraftNeverPublished-38302.test.tsx @@ -0,0 +1,174 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#38302 — the Data pillar's own AI line over the object canvas. + * Its 「放弃 AI 的改动」 drops the object's draft: for an object with a + * published or code version that goes back to it; for an object the AI + * created and nobody published there is none, and the discard deletes it. + * The button's title and the confirm asked over an unsaved edit say which, + * from the pillar's own reading of the object's layers (`hasBaseline`: an + * effective or code version). Keys are named, never copy. + * + * The harness is the one of `DataPillar.aiDraftDiscard-36511.test.tsx`, with + * the layers read able to serve an object that holds no layer. + */ + +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 PACKAGE = 'com.example.showcase'; +const live = { + name: 'showcase_task', + label: 'Task', + fields: { + priority: { name: 'priority', label: 'Priority', type: 'text' }, + }, +}; +/** The AI's version: one field added. */ +const aiVersion = { + ...live, + fields: { ...live.fields, 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 | null = null; +/** Whether the object has a version beyond its draft. */ +let published = true; + +const mockClient = { + save: vi.fn(async () => ({})), + publish: vi.fn(async () => ({})), + reset: vi.fn(async () => { + draftEnvelope = null; + return {}; + }), + list: vi.fn(async (type: string) => (type === 'object' ? [{ name: 'showcase_task', label: 'Task' }] : [])), + listDrafts: vi.fn(async () => []), + // objectstack#38302 — `published` false serves an object with no layer + // beyond its draft: no published row and no code baseline. + layered: vi.fn(async () => + published + ? { effective: live, code: live, draft: draftEnvelope?.item ?? null } + : { effective: null, code: null, overlay: null, 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(); + return { ...mod, useMetadataClient: () => mockClient, useMetadataTypes: () => ({ entries: [] }) }; +}); + +vi.mock('./packages-io', async (importOriginal) => { + const mod = await importOriginal(); + return { ...mod, fetchPackages: vi.fn(async () => []) }; +}); + +vi.mock('@object-ui/react', async (importOriginal) => { + const mod = await importOriginal(); + return { ...mod, useAdapter: () => dataSource }; +}); + +import '@objectstack/lint'; +import '@object-ui/plugin-detail'; +import { DataPillar } from './StudioDesignSurface'; +import { createEmptyDataSource, failOnAbsorbedFetchError } from './__tests__/emptyDataSource'; +import { addFieldFromFormToolbar } from './__tests__/dataPillarAddField'; +import { StudioSaveHarness } from './__tests__/studioSaveHarness'; +import { t } from '../metadata-admin/i18n'; + +const discardDrafts = vi.fn(async () => ({ success: true, failedCount: 0, failed: [], discarded: [] })); +const dataSource = Object.assign(createEmptyDataSource(), { + getClient: () => ({ packages: { discardDrafts } }), +}); +failOnAbsorbedFetchError(); + +const L = (key: string) => t(key, 'en-US'); + +const confirmSpy = vi.fn((_message?: string) => true); +beforeEach(() => { + draftEnvelope = null; + published = true; + confirmSpy.mockReset(); + confirmSpy.mockReturnValue(true); + window.confirm = confirmSpy as unknown as typeof window.confirm; +}); +afterEach(() => { + cleanup(); + vi.clearAllMocks(); +}); + +function serveDraft(by: string) { + draftEnvelope = { + type: 'object', + name: 'showcase_task', + item: { ...aiVersion, _draft: true }, + version: 'v1', + draftChanges: [{ path: ['fields', 'renewal_count'], by, actor: 'usr_1', at: minutesAgo(2) }], + }; +} + +function renderPillar(onDraftSaved = vi.fn()): { onDraftSaved: ReturnType } { + render( + + + + + , + ); + return { onDraftSaved }; +} + +async function openForm(): Promise { + fireEvent.click(await screen.findByRole('button', { name: L('engine.studio.data.tab.form') })); + await screen.findByTestId('form-toolbar'); +} + +const LIVE_TITLE = 'engine.studio.aiDraft.discardTitle'; +const DELETE_TITLE = 'engine.studio.aiDraft.discardTitleUnpublished'; +const LIVE_CONFIRM = 'engine.studio.aiDraft.discardConfirmUnsaved'; +const DELETE_CONFIRM = 'engine.studio.aiDraft.discardConfirmUnsavedUnpublished'; + +describe('the Data pillar AI line on an object never published (objectstack#38302)', () => { + it('an object the AI created and nobody published: the discard title says it deletes it', async () => { + published = false; + serveDraft('copilot'); + renderPillar(); + const line = await screen.findByTestId('studio-copilot-changes'); + await waitFor(() => expect(within(line).getByTestId('studio-ai-draft-discard')).toHaveAttribute('title', L(DELETE_TITLE))); + }); + + it('…and over an unsaved edit the confirm says so too; declined, nothing is sent', async () => { + published = false; + serveDraft('copilot'); + renderPillar(); + await openForm(); + await addFieldFromFormToolbar(undefined, { label: 'Due' }); + await screen.findByTestId('studio-save'); + confirmSpy.mockReturnValueOnce(false); + fireEvent.click(screen.getByTestId('studio-ai-draft-discard')); + expect(confirmSpy).toHaveBeenCalledWith(L(DELETE_CONFIRM)); + expect(mockClient.reset).not.toHaveBeenCalled(); + }); + + it('CONTROL: an object with a published version keeps the live-version wording on the title and the confirm', async () => { + serveDraft('copilot'); + renderPillar(); + const line = await screen.findByTestId('studio-copilot-changes'); + await waitFor(() => expect(within(line).getByTestId('studio-ai-draft-discard')).toHaveAttribute('title', L(LIVE_TITLE))); + await openForm(); + await addFieldFromFormToolbar(undefined, { label: 'Due' }); + await screen.findByTestId('studio-save'); + confirmSpy.mockReturnValueOnce(false); + fireEvent.click(screen.getByTestId('studio-ai-draft-discard')); + expect(confirmSpy).toHaveBeenCalledWith(L(LIVE_CONFIRM)); + }); +}); diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.tsx index 07f37ff9d1f..4f88e43cc41 100644 --- a/ui/packages/app-shell/src/views/studio-design/DataPillar.tsx +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.tsx @@ -137,6 +137,7 @@ import { useMetadataRefreshNonce } from './useMetadataRefreshNonce.js'; import { type Surface } from './navSurface.js'; import { useSurfaceActionDeepLink } from './useSurfaceDeepLink.js'; import { t, tFormat, translateMetadataType, useMetadataLocale } from '../metadata-admin/i18n.js'; +import { aiDraftDiscardConfirmUnsaved, aiDraftDiscardTitle } from './StudioAiDraftNotice.js'; import { InspectorShellHostProvider } from '../metadata-admin/inspectors/_shared.js'; import type { DestructiveChangeIssue } from '@objectstack/spec/api'; import { @@ -1463,7 +1464,9 @@ export function DataPillar({ const [discardingItemDraft, setDiscardingItemDraft] = React.useState(false); const discardItemDraft = React.useCallback(async () => { if (!current) return; - if (dirty && !window.confirm(t('engine.studio.aiDraft.discardConfirmUnsaved', locale))) return; + // objectstack#38302 — an object with no baseline (no published or code + // version) was never published: the discard deletes it, and the confirm says so. + if (dirty && !window.confirm(aiDraftDiscardConfirmUnsaved(locale, hasBaseline))) return; setDiscardingItemDraft(true); setError(null); try { @@ -1480,7 +1483,7 @@ export function DataPillar({ } finally { setDiscardingItemDraft(false); } - }, [client, current, dirty, locale, packageId, reloadObjDraft]); + }, [client, current, dirty, hasBaseline, locale, packageId, reloadObjDraft]); // 放弃全部未发布改动 — the package's discard door (`packages.discardDrafts`), // which drops every pending draft of the package, the author's own too; the // confirm says so. There is no per-turn undo. @@ -2154,7 +2157,7 @@ export function DataPillar({ data-testid="studio-ai-draft-discard" onClick={() => void discardItemDraft()} disabled={discardingItemDraft || discardingDrafts || saving !== false} - title={t('engine.studio.aiDraft.discardTitle', locale)} + title={aiDraftDiscardTitle(locale, hasBaseline)} className="font-medium text-amber-700 hover:underline disabled:opacity-50 dark:text-amber-300" > {t('engine.studio.aiDraft.discard', locale)} diff --git a/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx b/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx index e6e567cfd14..a4406072cf6 100644 --- a/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx +++ b/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx @@ -827,6 +827,7 @@ export function ObjectActionsPanel({ {selRow?.aiDraft && ( added.discardAiDraft(selRow.name) : undefined} busy={added.discardingAiDraft !== null || added.saving} className="m-2 mb-0" diff --git a/ui/packages/app-shell/src/views/studio-design/ObjectHooksPanel.tsx b/ui/packages/app-shell/src/views/studio-design/ObjectHooksPanel.tsx index f8dfb2155a8..fde33c32885 100644 --- a/ui/packages/app-shell/src/views/studio-design/ObjectHooksPanel.tsx +++ b/ui/packages/app-shell/src/views/studio-design/ObjectHooksPanel.tsx @@ -82,6 +82,7 @@ export function ObjectHooksPanel({ addHook, reportCel, aiDraft, + aiDraftPublished, discardAiDraft, discardingAiDraft, } = buffer; @@ -213,6 +214,7 @@ export function ObjectHooksPanel({ {aiDraft && ( { const own = rowState.find((s) => s.row.name === name); if (!own?.row.aiDraft) return; - if (own.dirty && !window.confirm(t('engine.studio.owd.aiDraftDiscardConfirmUnsaved', locale))) return; + // objectstack#38302 — an object the published list did not hold is + // deleted by the discard; the other rows keep their edits either way. + const ask = t( + own.row.saved + ? 'engine.studio.owd.aiDraftDiscardConfirmUnsaved' + : 'engine.studio.owd.aiDraftDiscardConfirmUnsavedUnpublished', + locale, + ); + if (own.dirty && !window.confirm(ask)) return; const others = rowState.filter((s) => s.dirty && s.row.name !== name); setDiscardingAiDraft(name); setSaveError(null); @@ -937,6 +945,7 @@ export function PackageOwdOverviewPanel({ void discardAiDraft(row.name)} busy={discardingAiDraft !== null || saving} className="mt-1" diff --git a/ui/packages/app-shell/src/views/studio-design/StudioAiDraftNotice.neverPublished-38302.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioAiDraftNotice.neverPublished-38302.test.tsx new file mode 100644 index 00000000000..5fa84b47220 --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/StudioAiDraftNotice.neverPublished-38302.test.tsx @@ -0,0 +1,438 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#38302 — the AI-draft line's discard (「放弃 AI 的改动」) drops the + * item's draft. For an item with a published version that goes back to the + * live version; for an item that was never published there is none, and the + * discard deletes it. The button's title and the confirm asked over an unsaved + * edit say which, from the host's own reading of "has a published version". + * + * Pinned on the line itself, and on one host per distinct reader: + * + * - the published-list reader (the open item's name in the type's published + * `list()`): the object designer's Hooks tab, whose buffer keeps those + * names. The Access, Automations, pair-actions and sharing-overview hosts + * read the same list membership, each through its own load; + * - the layers reader (an item whose `/layers` read holds no layer at all): + * the generic item page. + * + * And the sharing overview's own confirm: its discard keeps every other row's + * unsaved edit, so a never-published object is asked about with the OWD + * wording (only this row's change goes), never the page-wide one. + * + * Copy is never pinned: each assertion names the key the text must come from. + */ + +import '@testing-library/jest-dom/vitest'; +import * as React from 'react'; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; +import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; +import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { z } from 'zod'; +import { ComponentRegistry } from '@object-ui/core'; +import { DocSchema } from '@objectstack/spec/system'; +import { MetadataClient } from '@object-ui/data-objectstack'; + +const toasts = vi.hoisted(() => ({ success: vi.fn(), error: vi.fn(), info: vi.fn(), warning: vi.fn() })); +vi.mock('sonner', () => ({ toast: toasts })); + +vi.mock('../metadata-admin/i18n', async (importOriginal) => ({ + ...(await importOriginal>()), + useMetadataLocale: () => 'en-US', +})); + +/** Which client the mocked `useMetadataClient` answers with, set per suite. */ +const client = vi.hoisted(() => ({ current: null as unknown, docTypes: false })); + +vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { + const mod = await importOriginal(); + return { + ...mod, + useMetadataClient: () => client.current, + useMetadataTypes: (...args: Parameters) => + client.docTypes + ? { + loading: false, + entries: [ + { + type: 'doc', + label: 'Documentation', + domain: 'system', + allowEnvironmentOverlay: false, + allowRuntimeCreate: true, + schema: DOC_JSON_SCHEMA, + }, + ], + } + : mod.useMetadataTypes(...args), + }; +}); + +import { StudioAiDraftNotice, aiDraftDiscardConfirmUnsaved } from './StudioAiDraftNotice'; +import { PackageOwdOverviewPanel } from './PackageOwdOverviewPanel'; +import { StudioSaveHarness } from './__tests__/studioSaveHarness'; +import { HooksPanelHost } from './__tests__/hooksPanelHost'; +import { MetadataResourceEditPage } from '../metadata-admin/ResourceEditPage'; +import { registerBuiltinInspectors } from '../metadata-admin/inspectors'; +import { registerDefaultMetadataSchemas } from '../metadata-admin/default-schemas'; +import { registerBuiltinPreviews } from '../metadata-admin/previews'; +import { t } from '../metadata-admin/i18n'; +// The source reaches a dynamic `import('@objectstack/lint')`: its first load is paid at collection (`check:test-source-alias`). +import '@objectstack/lint'; +import { __setCelFormulaLoader } from '../metadata-admin/celAuthoring'; + +const DOC_JSON_SCHEMA = z.toJSONSchema(DocSchema as unknown as z.ZodType) as Record; + +registerBuiltinInspectors(); +registerDefaultMetadataSchemas(); +registerBuiltinPreviews(); + +const LIVE_TITLE = 'engine.studio.aiDraft.discardTitle'; +const DELETE_TITLE = 'engine.studio.aiDraft.discardTitleUnpublished'; +const LIVE_CONFIRM = 'engine.studio.aiDraft.discardConfirmUnsaved'; +const DELETE_CONFIRM = 'engine.studio.aiDraft.discardConfirmUnsavedUnpublished'; +const en = (key: string) => t(key, 'en-US'); + +const confirmSpy = vi.fn((_message?: string) => false); + +beforeEach(() => { + for (const fn of Object.values(toasts)) fn.mockClear(); + confirmSpy.mockReset(); + confirmSpy.mockReturnValue(false); + Object.defineProperty(window, 'confirm', { configurable: true, writable: true, value: confirmSpy }); +}); +afterEach(() => { + cleanup(); +}); + +async function settle() { + await act(async () => { + for (let i = 0; i < 20; i++) await new Promise((r) => setTimeout(r, 0)); + }); +} + +describe('the line: its discard title follows "has a published version"', () => { + it('the two keys exist in both locales the namespace carries, and differ from the live-version ones', () => { + for (const locale of ['en-US', 'zh-CN']) { + for (const key of [DELETE_TITLE, DELETE_CONFIRM]) expect(t(key, locale)).not.toBe(key); + expect(t(DELETE_TITLE, locale)).not.toBe(t(LIVE_TITLE, locale)); + expect(t(DELETE_CONFIRM, locale)).not.toBe(t(LIVE_CONFIRM, locale)); + } + }); + + it.each([ + [false, DELETE_TITLE], + [true, LIVE_TITLE], + [undefined, LIVE_TITLE], + ] as const)('published=%s titles the discard with %s', (published, key) => { + render( {}} />); + expect(screen.getByTestId('studio-ai-draft-discard')).toHaveAttribute('title', en(key)); + }); + + it.each([ + [false, DELETE_CONFIRM], + [true, LIVE_CONFIRM], + [undefined, LIVE_CONFIRM], + ] as const)('published=%s confirms an unsaved edit with %s', (published, key) => { + expect(aiDraftDiscardConfirmUnsaved('en-US', published)).toBe(en(key)); + }); +}); + +// --------------------------------------------------------------------------- +// The published-list reader: the object designer's Hooks tab. +// --------------------------------------------------------------------------- + +const PKG = 'com.example.showcase'; +const GUARD = { name: 'guard_hook', label: 'Guard', object: 'invoice', events: ['beforeInsert'], handler: 'guard_fn' }; +const AI_GUARD = { ...GUARD, label: 'Guard (AI)', condition: "record.status == 'held'" }; + +const hookDoor = { published: [] as Array>, aiDraft: false }; +const hookClient = { + list: vi.fn(async () => hookDoor.published), + listDrafts: vi.fn(async () => (hookDoor.aiDraft ? [{ type: 'hook', name: 'guard_hook' }] : [])), + getDraft: vi.fn(async (_type: string, name: string) => + hookDoor.aiDraft && name === 'guard_hook' + ? { + type: 'hook', + name, + item: { ...AI_GUARD }, + version: 'hmac-sha256:ai', + draftChanges: [{ path: ['condition'], by: 'copilot', actor: 'u1', at: '2026-11-27T10:00:00.000Z' }], + } + : null, + ), + get: vi.fn(async () => null), + withPreviewDrafts() { + return this; + }, + save: vi.fn(async () => ({ success: true, version: 'hmac-sha256:receipt', state: 'draft' })), + publish: vi.fn(async () => ({ success: true })), + reset: vi.fn(async () => ({ success: true })), +}; + +describe('the Hooks tab (published-list reader)', () => { + beforeEach(() => { + client.current = hookClient; + client.docTypes = false; + hookDoor.published = []; + hookDoor.aiDraft = true; + for (const fn of [hookClient.list, hookClient.listDrafts, hookClient.getDraft, hookClient.reset]) fn.mockClear(); + __setCelFormulaLoader(() => + Promise.resolve({ + validateExpression: () => ({ ok: true, errors: [], warnings: [] }), + introspectScope: () => ({ fields: ['status'], roots: ['record'], functions: ['has'] }), + inferExpressionType: () => 'boolean' as const, + }), + ); + }); + afterEach(() => { + __setCelFormulaLoader(undefined); + }); + + async function openGuard() { + render(); + fireEvent.click(await screen.findByText('Guard (AI)', undefined, { timeout: 8000 })); + } + + async function editCondition(value: string) { + fireEvent.click(await screen.findByText('Expression')); + const box = screen.getAllByRole('combobox').find((el) => el.tagName === 'TEXTAREA') as HTMLTextAreaElement; + fireEvent.change(box, { target: { value } }); + } + + it('a hook the AI created and nobody published: the discard says it deletes it, and so does the unsaved-edit confirm', async () => { + await openGuard(); + expect(await screen.findByTestId('studio-ai-draft-discard')).toHaveAttribute('title', en(DELETE_TITLE)); + await editCondition("record.status == 'unsaved'"); + fireEvent.click(screen.getByTestId('studio-ai-draft-discard')); + expect(confirmSpy).toHaveBeenCalledWith(en(DELETE_CONFIRM)); + // Declined: nothing is dropped. + expect(hookClient.reset).not.toHaveBeenCalled(); + }); + + it('a published hook with the AI\'s draft: the live-version wording, on the title and the confirm', async () => { + hookDoor.published = [GUARD]; + await openGuard(); + expect(await screen.findByTestId('studio-ai-draft-discard')).toHaveAttribute('title', en(LIVE_TITLE)); + await editCondition("record.status == 'unsaved'"); + fireEvent.click(screen.getByTestId('studio-ai-draft-discard')); + expect(confirmSpy).toHaveBeenCalledWith(en(LIVE_CONFIRM)); + expect(hookClient.reset).not.toHaveBeenCalled(); + }); +}); + +// --------------------------------------------------------------------------- +// The layers reader: the generic item page, over a real MetadataClient whose +// transport answers as the framework's `/meta` doors do. +// --------------------------------------------------------------------------- + +interface Row { + body: Record; + version: string; + draftChanges?: Array<{ path: string[]; by: string; actor: string; at: string }>; +} + +const server = { active: new Map(), drafts: new Map(), deletes: 0 }; + +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 { + const method = (init?.method ?? 'GET').toUpperCase(); + const url = new URL(String(input), 'http://console.test'); + const meta = url.pathname.match(/^\/api\/v1\/meta\/(.+)$/); + if (!meta) return json(200, []); + const seg = meta[1].split('/').map(decodeURIComponent); + if (seg[0] === '_drafts') { + return json(200, { drafts: [...server.drafts.keys()].map((k) => ({ type: k.split('/')[0], name: k.split('/')[1] })) }); + } + if (seg.length === 1) return json(200, { items: [{ name: 'guide' }] }); + const key = `${seg[0]}/${seg[1]}`; + if (seg.length === 3 && seg[2] === 'layers') { + const row = server.active.get(key); + return row + ? json(200, { + code: null, + overlay: row.body, + overlayScope: 'env', + effective: row.body, + draft: server.drafts.get(key)?.body ?? null, + overlayVersion: row.version, + editable: true, + deletable: true, + resettable: false, + lock: 'none', + }) + : json(404, { error: { code: 'NOT_FOUND', message: 'absent' } }); + } + if (seg.length === 3 && seg[2] === 'references') return json(200, []); + if (method === 'DELETE') { + server.deletes += 1; + return json(200, { success: true }); + } + if (url.searchParams.get('state') === 'draft') { + const row = server.drafts.get(key); + if (!row) return json(404, { error: { code: 'NO_DRAFT', message: 'absent' } }); + return json(200, { + type: seg[0], + name: seg[1], + item: row.body, + version: row.version, + ...(row.draftChanges ? { draftChanges: row.draftChanges } : {}), + }); + } + const row = server.active.get(key); + return row + ? json(200, { type: seg[0], name: seg[1], item: row.body }) + : json(404, { error: { code: 'NOT_FOUND', message: 'absent' } }); +} + +const metadataClient = new MetadataClient({ baseUrl: '', fetch: vi.fn(serve) as unknown as typeof fetch }); + +const STUB_NS = 'ai-draft-never-published-38302'; +function StubMarkdown({ schema }: { schema: { content?: string } }) { + return
{schema.content}
; +} + +describe('the generic item page (layers reader)', () => { + beforeAll(() => { + ComponentRegistry.register('markdown', StubMarkdown as never, { namespace: STUB_NS }); + }); + afterAll(() => { + ComponentRegistry.unregister('markdown', STUB_NS); + }); + beforeEach(() => { + client.current = metadataClient; + client.docTypes = true; + server.active.clear(); + server.drafts.clear(); + server.deletes = 0; + server.drafts.set('doc/guide', { + body: { name: 'guide', label: 'Guide', content: '# From the AI', group: 'reference' }, + version: 'draft:ai', + draftChanges: [{ path: ['content'], by: 'copilot', actor: 'u1', at: '2026-11-24T10:00:00.000Z' }], + }); + window.history.replaceState(null, '', '/metadata/doc/guide'); + }); + afterEach(() => { + window.history.replaceState(null, '', '/'); + }); + + const source = () => screen.findByRole('textbox', { name: /Markdown source|Markdown/ }, { timeout: 8000 }); + + async function openGuide() { + render( + + + } /> + } /> + + , + ); + await source(); + await settle(); + } + + async function discardOverAnEdit() { + fireEvent.change(await source(), { target: { value: '# unsaved' } }); + await settle(); + fireEvent.click(screen.getByTestId('studio-ai-draft-discard')); + } + + it('an item the AI created and nobody published: the title and the in-app confirm say the discard deletes it', async () => { + await openGuide(); + expect(screen.getByTestId('studio-ai-draft-discard')).toHaveAttribute('title', en(DELETE_TITLE)); + await discardOverAnEdit(); + expect(await screen.findByTestId('resource-edit-confirm-body')).toHaveTextContent(en(DELETE_CONFIRM)); + fireEvent.click(screen.getByTestId('resource-edit-confirm-cancel')); + await settle(); + expect(server.deletes).toBe(0); + }); + + it('a published item with the AI\'s draft: the live-version wording, on the title and the confirm', async () => { + server.active.set('doc/guide', { + body: { name: 'guide', label: 'Guide', content: '# Live', group: 'reference' }, + version: 'pub:v0', + }); + await openGuide(); + await waitFor(() => + expect(screen.getByTestId('studio-ai-draft-discard')).toHaveAttribute('title', en(LIVE_TITLE)), + ); + await discardOverAnEdit(); + expect(await screen.findByTestId('resource-edit-confirm-body')).toHaveTextContent(en(LIVE_CONFIRM)); + expect(confirmSpy).not.toHaveBeenCalled(); + }); +}); + +// --------------------------------------------------------------------------- +// The sharing overview (OWD): a never-published object's row, over its own +// unsaved edit. The client is the panel's prop, not the mocked hook. +// --------------------------------------------------------------------------- + +describe('the sharing overview: a never-published object with a dirty row', () => { + type Body = Record; + const account = { name: 'crm_account', label: 'Account', sharingModel: 'private', fields: { name: { type: 'text' } } }; + const contact = { name: 'crm_contact', label: 'Contact', sharingModel: 'private' }; + const owd = { published: new Map(), drafts: new Map(), resets: [] as string[] }; + const owdClient = { + list: vi.fn(async (type: string) => + type === 'object' ? [...owd.published.values()].map((b) => ({ name: b.name, label: b.label })) : [], + ), + listDrafts: vi.fn(async () => [...owd.drafts.keys()].map((name) => ({ type: 'object', name }))), + layered: vi.fn(async (_type: string, name: string) => { + const pub = owd.published.get(name) ?? null; + return { effective: pub, code: null, overlay: pub }; + }), + getDraft: vi.fn(async (_type: string, name: string) => { + const body = owd.drafts.get(name); + return body + ? { + type: 'object', + name, + item: structuredClone(body), + version: `draft:${name}`, + draftChanges: [{ path: ['fields', 'notes'], by: 'copilot', actor: 'u1', at: '2026-11-27T10:00:00.000Z' }], + } + : null; + }), + save: vi.fn(async () => ({ success: true, version: 'draft:2', state: 'draft' })), + publish: vi.fn(async () => ({ success: true })), + reset: vi.fn(async (_type: string, name: string) => { + owd.resets.push(name); + owd.drafts.delete(name); + return { success: true }; + }), + }; + + beforeEach(() => { + Element.prototype.scrollIntoView = vi.fn(); + owd.published = new Map([['crm_contact', contact]]); + // The AI created Account; nobody published it. + owd.drafts = new Map([['crm_account', { ...account, fields: { ...account.fields, notes: { type: 'textarea' } } }]]); + owd.resets = []; + owdClient.reset.mockClear(); + }); + + async function pickOwd(testId: string, label: string): Promise { + fireEvent.keyDown(screen.getByTestId(testId), { key: 'ArrowDown' }); + const listbox = await screen.findByRole('listbox'); + fireEvent.click(within(listbox).getByRole('option', { name: label })); + } + + it('the title says the discard deletes it, and the confirm names only this row\'s unsaved change', async () => { + render( + + + , + ); + const row = await screen.findByTestId('owd-row-crm_account', undefined, { timeout: 8000 }); + expect(within(row).getByTestId('studio-ai-draft-discard')).toHaveAttribute('title', en(DELETE_TITLE)); + await pickOwd('owd-internal-crm_account', en('engine.studio.settings.sharingPublicRead')); + fireEvent.click(within(screen.getByTestId('owd-row-crm_account')).getByTestId('studio-ai-draft-discard')); + expect(confirmSpy).toHaveBeenCalledWith(en('engine.studio.owd.aiDraftDiscardConfirmUnsavedUnpublished')); + expect(confirmSpy).not.toHaveBeenCalledWith(en(DELETE_CONFIRM)); + // Declined: nothing is dropped, and the row keeps its edit. + expect(owdClient.reset).not.toHaveBeenCalled(); + expect(screen.getByTestId('owd-dirty-crm_account')).toBeInTheDocument(); + }); +}); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioAiDraftNotice.tsx b/ui/packages/app-shell/src/views/studio-design/StudioAiDraftNotice.tsx index f6c4e4dfed4..dc5d04e35a4 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioAiDraftNotice.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioAiDraftNotice.tsx @@ -6,6 +6,13 @@ * Save makes it live together with the page's own edits, and 「放弃 AI 的改动」 * drops that one item's draft, back to the live version. * + * objectstack#38302 — an item that was never published has no live version to + * go back to: dropping its draft deletes it. The host says which it is + * (`published`), and the button's title and the confirm the host asks over an + * unsaved edit ({@link aiDraftDiscardConfirmUnsaved}) say "deletes it" for an + * item that has none. A host that cannot tell passes nothing and keeps the + * live-version wording, as before. + * * The object page carries the same sentence and button inside its own AI line * (with its change count and Review); this is the line for the other item * pages, drawn the same way. @@ -16,9 +23,33 @@ import { Sparkles } from 'lucide-react'; import { cn } from '@object-ui/components'; import { t } from '../metadata-admin/i18n.js'; +/** + * The confirm a host asks before the discard drops an unsaved edit with the + * draft: the live-version wording when the item has a published version (or + * the host cannot tell), the delete wording when it has none. + */ +export function aiDraftDiscardConfirmUnsaved(locale: string, published: boolean | undefined): string { + return t( + published === false ? 'engine.studio.aiDraft.discardConfirmUnsavedUnpublished' : 'engine.studio.aiDraft.discardConfirmUnsaved', + locale, + ); +} + +/** + * The discard button's title: the live-version wording when the item has a + * published version (or the host cannot tell), the delete wording when it has none. + */ +export function aiDraftDiscardTitle(locale: string, published: boolean | undefined): string { + return t( + published === false ? 'engine.studio.aiDraft.discardTitleUnpublished' : 'engine.studio.aiDraft.discardTitle', + locale, + ); +} + export function StudioAiDraftNotice({ locale, text, + published, onDiscard, busy = false, className, @@ -26,6 +57,11 @@ export function StudioAiDraftNotice({ locale: string; /** The sentence, where the page names what the draft covers; else the item line's own. */ text?: string; + /** + * Whether the item has a published version: `false` = never published, so + * the discard deletes it; `undefined` = the host cannot tell, read as `true`. + */ + published?: boolean; /** Drop the item's draft; `undefined` draws no button (a read-only item). */ onDiscard?: () => void; busy?: boolean; @@ -50,7 +86,7 @@ export function StudioAiDraftNotice({ data-testid="studio-ai-draft-discard" onClick={onDiscard} disabled={busy} - title={t('engine.studio.aiDraft.discardTitle', locale)} + title={aiDraftDiscardTitle(locale, published)} className="ml-auto font-medium text-amber-700 hover:underline disabled:opacity-50 dark:text-amber-300" > {t('engine.studio.aiDraft.discard', locale)} diff --git a/ui/packages/app-shell/src/views/studio-design/StudioPermissionSetPage.tsx b/ui/packages/app-shell/src/views/studio-design/StudioPermissionSetPage.tsx index a90b1dd3fd8..e6dcd44a475 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioPermissionSetPage.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioPermissionSetPage.tsx @@ -57,7 +57,7 @@ import { confirmUnsavedLeave } from '../../chrome/unsavedEdits.js'; import { SuggestedBindingsPanel } from '../../components/SuggestedBindingsPanel.js'; import { suggestedSetLabel } from '../../components/suggestedSetLabel.js'; import { StudioReadOnlyLink } from './StudioPillarKit.js'; -import { StudioAiDraftNotice } from './StudioAiDraftNotice.js'; +import { StudioAiDraftNotice, aiDraftDiscardConfirmUnsaved } from './StudioAiDraftNotice.js'; import { isAgentDraftSurface } from './StudioDraftMark.js'; import type { StudioItemStatus } from './StudioItemHeader.js'; import { customizationPairBaseOf } from './StudioRailCustomizations.js'; @@ -209,7 +209,8 @@ export function StudioPermissionSetPage({ // The AI's draft: asked first only when the matrix holds unsaved edits. const discardAiDraft = () => dropDraft( - () => !matrixDirty || window.confirm(t('engine.studio.aiDraft.discardConfirmUnsaved', locale)), + (_item, neverPublished) => + !matrixDirty || window.confirm(aiDraftDiscardConfirmUnsaved(locale, !neverPublished)), (e) => toast.error(tFormat('engine.studio.aiDraft.discardFailed', locale, { reason: formatMetadataError(e) }), { classNames: { description: 'whitespace-pre-line' }, @@ -390,6 +391,7 @@ export function StudioPermissionSetPage({ {aiDraft && ( void discardAiDraft()} busy={discarding} className="mx-3 mt-2" diff --git a/ui/packages/app-shell/src/views/studio-design/objectHooksBuffer.ts b/ui/packages/app-shell/src/views/studio-design/objectHooksBuffer.ts index 538d0792a0a..f621c96d035 100644 --- a/ui/packages/app-shell/src/views/studio-design/objectHooksBuffer.ts +++ b/ui/packages/app-shell/src/views/studio-design/objectHooksBuffer.ts @@ -49,6 +49,7 @@ import { } from '../metadata-admin/DraftConflictDialog.js'; import type { HookTargetScope } from '../metadata-admin/inspectors/HookDefaultInspector.js'; import { t, tFormat, useMetadataLocale } from '../metadata-admin/i18n.js'; +import { aiDraftDiscardConfirmUnsaved } from './StudioAiDraftNotice.js'; import { loadPackageSurfaces } from './packageSurfaces.js'; import { confirmDropUnsavedWork } from './StudioPillarKit.js'; import { publishSavedItem, useStudioSaveEntry, type StudioSaveResult } from './studioSaveBar.js'; @@ -116,6 +117,11 @@ export interface ObjectHooksBuffer { blockingIssues: number; /** The open hook's pending draft was written by the AI assistant (copilot or MCP). */ aiDraft: boolean; + /** + * objectstack#38302 — the open hook has a published version (the published + * list held its name at load): `false` means the AI draft's discard deletes it. + */ + aiDraftPublished: boolean; /** Drop the open hook's AI draft at the package; asks first over an unsaved edit. */ discardAiDraft: () => void; /** That discard is in flight. */ @@ -168,6 +174,8 @@ export function useObjectHooksBuffer({ // The listed hooks whose pending draft the AI assistant wrote (a `copilot` // or `mcp` entry in the draft read's `draftChanges`). const [aiDrafted, setAiDrafted] = React.useState>(() => new Set()); + // objectstack#38302 — the names the published list served at load, whatever they target. + const [publishedNames, setPublishedNames] = React.useState>(() => new Set()); const [loading, setLoading] = React.useState(true); const [error, setError] = React.useState(null); const [selected, setSelected] = React.useState(null); @@ -341,6 +349,7 @@ export function useObjectHooksBuffer({ setRefusedHooks(refused); setDrafted(pending); setAiDrafted(byAgent); + setPublishedNames(new Set((pub || []).map((h) => String(h?.name ?? '')).filter(Boolean))); // A hook whose buffer holds an unsent edit keeps the pins that edit was built on. const open = bufferRef.current; for (const [n, pin] of pins) { @@ -499,7 +508,7 @@ export function useObjectHooksBuffer({ const discardAiDraft = React.useCallback(() => { const name = bufferRef.current.hook; if (name === null || !aiDrafted.has(name)) return; - if (bufferRef.current.dirty && !window.confirm(t('engine.studio.aiDraft.discardConfirmUnsaved', locale))) return; + if (bufferRef.current.dirty && !window.confirm(aiDraftDiscardConfirmUnsaved(locale, publishedNames.has(name)))) return; setDiscardingAiDraft(true); setError(null); void (async () => { @@ -517,8 +526,9 @@ export function useObjectHooksBuffer({ setDiscardingAiDraft(false); } })(); - }, [aiDrafted, client, locale, packageId, reloadHooks]); + }, [aiDrafted, client, locale, packageId, publishedNames, reloadHooks]); const aiDraft = draftFor !== null && !isCreated && aiDrafted.has(draftFor); + const aiDraftPublished = draftFor !== null && publishedNames.has(draftFor); const cancel = React.useCallback(() => { setError(null); @@ -557,6 +567,7 @@ export function useObjectHooksBuffer({ renamedFrom, blockingIssues, aiDraft, + aiDraftPublished, discardAiDraft, discardingAiDraft, hookTargetScope, diff --git a/ui/packages/app-shell/src/views/studio-design/pairObjectActions.ts b/ui/packages/app-shell/src/views/studio-design/pairObjectActions.ts index 41a8b298520..6511fece4fc 100644 --- a/ui/packages/app-shell/src/views/studio-design/pairObjectActions.ts +++ b/ui/packages/app-shell/src/views/studio-design/pairObjectActions.ts @@ -64,6 +64,7 @@ import { } from '@object-ui/data-objectstack'; import { useMetadataClient } from '../metadata-admin/useMetadata.js'; import { t as tStudio, tFormat, useMetadataLocale } from '../metadata-admin/i18n.js'; +import { aiDraftDiscardConfirmUnsaved } from './StudioAiDraftNotice.js'; import { draftReceiptVersion, publishedPinOf, @@ -416,10 +417,11 @@ export function usePairObjectActions( const discardAiDraft = React.useCallback( (name: string) => { if (doorRef.current?.walled) return; - if (!allRef.current.find((r) => r.name === name)?.aiDraft) return; + const row = allRef.current.find((r) => r.name === name); + if (!row?.aiDraft) return; if ( pendingRef.current.edited.has(name) && - !window.confirm(tStudio('engine.studio.aiDraft.discardConfirmUnsaved', localeRef.current)) + !window.confirm(aiDraftDiscardConfirmUnsaved(localeRef.current, row.published)) ) { return; } diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index 98421c5425d..4dc0080e8d1 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -3491,6 +3491,12 @@ const STUDIO_EN: Record = { 'engine.studio.aiDraft.discardConfirmUnsaved': 'Discarding the AI’s changes also drops the changes on this page that you have not saved. Discard anyway?', 'engine.studio.aiDraft.discardFailed': 'The AI’s changes were not discarded: {reason}', + // objectstack#38302 — an item never published has no live version: dropping + // its draft deletes it, so the button's title and the unsaved-edit confirm say so. + 'engine.studio.aiDraft.discardTitleUnpublished': + 'This item has never been published, so dropping its draft deletes it', + 'engine.studio.aiDraft.discardConfirmUnsavedUnpublished': + 'This item has never been published, so discarding the AI’s changes deletes it, together with the changes on this page that you have not saved. Discard anyway?', // objectstack#36511 — the create dialogs of the editors whose Save is live // (objects, automations, permission sets): the item is created and live at // once, so the confirm says Create, never Save as draft. @@ -4059,6 +4065,10 @@ const STUDIO_EN: Record = { 'This object has unpublished changes from the AI assistant. Saving this row makes all of them live too.', 'engine.studio.owd.aiDraftDiscardConfirmUnsaved': 'Discarding the AI’s changes drops all of this object’s unpublished changes, and this row’s change that you have not saved. Discard anyway?', + // objectstack#38302 — an object never published is deleted by the discard; + // only this row's unsaved change goes with it, the other rows keep theirs. + 'engine.studio.owd.aiDraftDiscardConfirmUnsavedUnpublished': + 'This object has never been published, so discarding the AI’s changes deletes it, together with this row’s change that you have not saved. Discard anyway?', 'engine.studio.owd.byParent': 'Follows its {master}', 'engine.studio.owd.cbpPrereqTitle': 'Make the relationship required?', 'engine.studio.owd.cbpPrereqDesc': diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 642d93e9d6e..3df5aaf2023 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -3102,6 +3102,10 @@ const STUDIO_ZH: Record = { 'engine.studio.aiDraft.discardTitle': '丢弃这一项未发布的草稿,回到已生效的版本', 'engine.studio.aiDraft.discardConfirmUnsaved': '放弃 AI 的改动会一并丢掉本页还没保存的改动。仍要放弃吗?', 'engine.studio.aiDraft.discardFailed': '没有放弃 AI 的改动:{reason}', + // objectstack#38302 — 见英文条目。 + 'engine.studio.aiDraft.discardTitleUnpublished': '这一项从未发布过,丢弃它的草稿会删除它', + 'engine.studio.aiDraft.discardConfirmUnsavedUnpublished': + '这一项从未发布过,放弃 AI 的改动会删除它,并一并丢掉本页还没保存的改动。仍要放弃吗?', // objectstack#36511 — 见英文条目。 'engine.studio.createLive': '创建', 'engine.studio.held.lineExplicit': '还不能保存:{clause}。改动已保留在此处,补全后再点保存。', @@ -3590,6 +3594,9 @@ const STUDIO_ZH: Record = { 'engine.studio.owd.aiDraftNotice': '这个对象有 AI 未发布的改动,保存这一行会让它们全部生效', 'engine.studio.owd.aiDraftDiscardConfirmUnsaved': '放弃 AI 的改动会丢掉这个对象全部未发布的改动,以及这一行还没保存的改动。仍要放弃吗?', + // objectstack#38302 — 见英文条目。 + 'engine.studio.owd.aiDraftDiscardConfirmUnsavedUnpublished': + '这个对象从未发布过,放弃 AI 的改动会删除它,并一并丢掉这一行还没保存的改动。仍要放弃吗?', 'engine.studio.owd.byParent': '跟随所属的{master}', 'engine.studio.owd.cbpPrereqTitle': '将该关系设为必填?', 'engine.studio.owd.cbpPrereqDesc':