Skip to content

Commit 714124a

Browse files
fix(app-shell): AI-draft discard says it deletes an item that was never published (#38602)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ844kETyNGBBt9atKc1Snfzd)_ Fixes #38302 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:Studio 里 AI 草稿提示的「放弃 AI 的改动」按钮,对从未发布过的项改说「会删除它」,未保存时的确认框也同样写明删除;已发布的项文案不变。 - 为什么做:AI 新建、从未发布的项没有线上版本,原文案说「回到线上版本」是误导。 - 出错会怎样:只影响提示与确认文字,放弃本身的行为不变;判断不出是否发布过时沿用原文案,可直接撤回。 - 要你做的:无。 ## What changes - `StudioAiDraftNotice` takes a `published` reading. `false` titles the discard with `engine.studio.aiDraft.discardTitleUnpublished`; `true` or `undefined` (host cannot tell) keeps `engine.studio.aiDraft.discardTitle`. - New exported `aiDraftDiscardConfirmUnsaved(locale, published)` picks the confirm asked over an unsaved edit: `engine.studio.aiDraft.discardConfirmUnsavedUnpublished` for a never-published item, the current `discardConfirmUnsaved` otherwise. - Three new keys, en and zh (the two locales the studio namespace carries): `engine.studio.aiDraft.discardTitleUnpublished`, `engine.studio.aiDraft.discardConfirmUnsavedUnpublished`, `engine.studio.owd.aiDraftDiscardConfirmUnsavedUnpublished`. - The flow preview's `published` reads the same `flowPublished` the AI line does (one expression, no behaviour change). - Hosts, each passing its own reading (measured per host; six notice hosts, not five, plus the Data pillar's own line): - Access permission set page: `read.published.has(name)` (already used by its person-draft discard). - Automations flow designer: `publishedFlowNames` (the published `listResponse`, `undefined` while unread or failed). - Pair actions: `row.published`, confirm in `pairObjectActions`. - Hooks tab: new `aiDraftPublished` on the hooks buffer (the published `list()` names), confirm in `objectHooksBuffer`. - Sharing overview (OWD): `row.saved`; a never-published object's unsaved-edit confirm uses its own new key, `engine.studio.owd.aiDraftDiscardConfirmUnsavedUnpublished` (the object is deleted and only this row's unsaved change goes with it: the discard keeps every other row's edit). - Generic item page: `!holdsNoLayer(layered)` (an item whose layers read holds no layer), for the title and the in-app confirm. - Data pillar object page, its own AI line (not a `StudioAiDraftNotice` host; folded in by claim amendment 1): `hasBaseline` (the object's layers read serves an effective or code version), already held by the pillar, no new fetch. Title through the new `aiDraftDiscardTitle(locale, published)` helper, which the notice uses too. - Behaviour is unchanged: the discard still asks only over an unsaved edit. ## Tests New pins, keys named and never copy: - `StudioAiDraftNotice.neverPublished-38302.test.tsx`: the line (title per `published`, the confirm helper, both keys present in en and zh), the Hooks tab (published-list reader) and the generic item page (layers reader), each with a never-published and a published item, on the title and the unsaved-edit confirm; and the sharing overview, a never-published object with a dirty row (title, the OWD confirm key and not the page-wide one, declined keeps the edit). - `DataPillar.aiDraftNeverPublished-38302.test.tsx`: the Data pillar's AI line (`hasBaseline` reader): never-published object on the title and the unsaved-edit confirm, plus a published-object control. Harness copied from `DataPillar.aiDraftDiscard-36511.test.tsx`. <details><summary>Local readings (head 560eb6e, after merging origin/main f5da514)</summary> - Dependency closure: `pnpm --workspace-concurrency=2 --filter '@object-ui/app-shell^...' build`, os-verify-lock VERDICT command-exit 0. - At 362dc0c (lock): both card files plus `PackageOwdOverviewPanel.aiDraftNotice-36660`: Test Files 3 passed, Tests 21 passed. - At 560eb6e (outside the lock, which a sibling held past its queue budget; declared): both card files, `PackageOwdOverviewPanel.aiDraftNotice-36660` and `AutomationsPillar.saveCancel-36511`: Test Files 4 passed, Tests 27 passed. - `@object-ui/app-shell` `type-check` (`tsc --noEmit` plus `tsconfig.test.json`): exit 0 at 560eb6e, 0 errors (run outside the lock, same reason). - Earlier rounds: host suites ObjectHooksPanel 36660, DataPillar pairActions 36660, StudioPermissionSetPage 36905, ResourceEditPage 36902, AutomationsPillar saveCancel 36511, DataPillar aiDraftDiscard 36511 (74 passed) and PackageOwdOverviewPanel aiDraftNotice 36660 (6 passed) at e5a0b5f; card files plus DataPillar aiDraftDiscard 36511 (18 passed) at 6dcdcd2. - Ablation 1 (e5a0b5f): both `published === false` choices in `StudioAiDraftNotice.tsx` forced to `false ?`: 4 failed / 7 passed; restored. - Ablation 2 (6dcdcd2): `DataPillar.tsx` passing `true` for `hasBaseline` to both helpers: 2 failed / 1 passed; restored. - Ablation 3 (560eb6e tree, lock): the OWD site's never-published key put back to the generic `engine.studio.aiDraft.discardConfirmUnsavedUnpublished`: 1 failed / 11 passed (the OWD never-published case); restored. </details> <details><summary>Gates (head 560eb6e)</summary> - `dispatch-gates --commands` (15 paths): the same 39 commands. 38 exit 0; `check:type-check-debt` first exited 3 on its own lock queue-timeout, rerun exit 0 (surplus none). - NOT MEASURED locally at 560eb6e: `pnpm --dir ui exec vitest run scripts/`, reason: lock queue-timeout (exit 99) behind a sibling's run. It was green at 6dcdcd2 (172 passed, 2 skipped); this delta touches no `ui/scripts` input. CI is the reading. - `overlap-check.mjs`: VERDICT clean exit 0 before each push. ui `check:new-line-citations`: 0 new at 6dcdcd2. - CI on 6dcdcd2: 47 success, 15 skipped. CI on 560eb6e is the reading for this delta. </details> ## Acceptance notes - Two reader mechanisms pinned (published-list membership on the Hooks tab, layers on the generic item page). The Access, Automations, pair-actions and OWD hosts read list membership through their own loads and are wired without a pin of their own. - A never-published item discarded with nothing unsaved still asks nothing (as before); only its title says it deletes. Adding a confirm there is a behaviour change the card did not ask for. - The Data pillar object page's own AI line had the same defect; folded in here by claim amendment 1 and pinned. - The sharing overview's never-published confirm has its own key (claim amendment 2): the generic one says the page's unsaved changes go too, which is false there. - Hooks buffer and pairObjectActions are the hosts' own reading/confirm halves; claim amendment 1 adds them, and `DataPillar.tsx`, to the file surface. ## Verification Read first: `StudioAiDraftNotice.tsx` (the choice and both helpers), `objectHooksBuffer.ts` (new published-names state), `DataPillar.tsx` (the `hasBaseline` reading). Two-minute check: in Studio, have the AI assistant create a new object, then hover 「放弃 AI 的改动」 on its AI line: the tooltip says the item has never been published and dropping its draft deletes it. On an object that already exists, the tooltip still says it goes back to the live version. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JQwxbamiNxp7695qyaEYsH <!-- signed: repo:objectstack#2 · os-warren · session_01JQwxbamiNxp7695qyaEYsH --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 34bc6c6 commit 714124a

15 files changed

Lines changed: 730 additions & 17 deletions
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
fix(app-shell): the AI-draft line's discard says it deletes an item that was never published
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
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.

‎ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ import {
128128
import { usePackageCreateAsk } from './PackageCreateAsk.js';
129129
// objectstack#36902 — Save takes effect at once; the AI draft's notice is the designers'.
130130
import { isAiDraft, publishDetailSave } from './detailSaveAtOnce.js';
131-
import { StudioAiDraftNotice } from '../studio-design/StudioAiDraftNotice.js';
131+
import { StudioAiDraftNotice, aiDraftDiscardConfirmUnsaved } from '../studio-design/StudioAiDraftNotice.js';
132132
import { publishFailureOf, publishRefusal, type StudioRefusal } from '../studio-design/metadataError.js';
133133
import { emitMetadataRefresh } from '../../assistant/assistantBus.js';
134134
// objectstack#29148 — the one strip a Studio editor draws for a refused draft read.
@@ -2648,7 +2648,8 @@ function MetadataResourceEditPageImpl({
26482648
setPendingConfirm({
26492649
kind: 'discardAi',
26502650
title: t('engine.studio.aiDraft.discard', locale),
2651-
description: t('engine.studio.aiDraft.discardConfirmUnsaved', locale),
2651+
// objectstack#38302 — an item that holds no layer was never published: the discard deletes it.
2652+
description: aiDraftDiscardConfirmUnsaved(locale, !holdsNoLayer(layered)),
26522653
actionLabel: t('engine.studio.aiDraft.discard', locale),
26532654
item: ownItemLabel() || `${type}/${name ?? ''}`,
26542655
});
@@ -3342,6 +3343,7 @@ function MetadataResourceEditPageImpl({
33423343
{aiDraft && (
33433344
<StudioAiDraftNotice
33443345
locale={locale}
3346+
published={!holdsNoLayer(layered)}
33453347
onDiscard={canWrite ? discardAiDraft : undefined}
33463348
busy={discardingAiDraft || saving || publishing}
33473349
/>

‎ui/packages/app-shell/src/views/studio-design/AutomationsPillar.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { AUTOMATIONS_CONFIG_FOLD_WIDTH, useIsNarrowerThan } from './wideViewport
2929
import { STUDIO_FOLD_LABEL } from './studio-tokens.js';
3030
import { StudioInspector } from './StudioInspector.js';
3131
import { isAgentDraftSurface } from './StudioDraftMark.js';
32-
import { StudioAiDraftNotice } from './StudioAiDraftNotice.js';
32+
import { StudioAiDraftNotice, aiDraftDiscardConfirmUnsaved } from './StudioAiDraftNotice.js';
3333
import { StudioTab } from './StudioItemHeader.js';
3434
import { ResourceDetailHeader, detailListHref } from '../metadata-admin/ResourceDetailHeader.js';
3535
import { ItemToolTabPanel, ItemToolTabStrip } from '../item-tools/ItemToolTabs.js';
@@ -799,10 +799,14 @@ export function AutomationsPillar({
799799
// read at), back to the live version. Edits not yet saved go with it, asked first.
800800
const flowAiDraft =
801801
flowLoaded && hasDraft && (flowDraftChanges ?? []).some((change) => isAgentDraftSurface(change.by));
802+
// objectstack#38302 — a flow the published list does not hold has no live
803+
// version: its discard deletes it, and the line and the confirm say so.
804+
// `undefined` while that list is unread or its read failed.
805+
const flowPublished = current && publishedFlowNames ? publishedFlowNames.has(current.name) : undefined;
802806
const [discardingFlowDraft, setDiscardingFlowDraft] = React.useState(false);
803807
const discardFlowDraft = React.useCallback(async () => {
804808
if (!current) return;
805-
if (autoDirty && !window.confirm(t('engine.studio.aiDraft.discardConfirmUnsaved', locale))) return;
809+
if (autoDirty && !window.confirm(aiDraftDiscardConfirmUnsaved(locale, flowPublished))) return;
806810
const at = flowReadAtRef.current?.key === `flow:${current.name}` ? flowReadAtRef.current.at : draftPackageId;
807811
setDiscardingFlowDraft(true);
808812
setError(null);
@@ -821,7 +825,7 @@ export function AutomationsPillar({
821825
} finally {
822826
setDiscardingFlowDraft(false);
823827
}
824-
}, [autoDirty, client, current, draftPackageId, locale, reloadFlowDraft]);
828+
}, [autoDirty, client, current, draftPackageId, flowPublished, locale, reloadFlowDraft]);
825829
// objectui#12725 — the header's draft line reads the badge's ledger.
826830
const flowDraftStatus = useStudioItemDraftStatus(
827831
current ? { type: 'flow', name: current.name } : null,
@@ -1497,6 +1501,7 @@ export function AutomationsPillar({
14971501
{flowAiDraft && (
14981502
<StudioAiDraftNotice
14991503
locale={locale}
1504+
published={flowPublished}
15001505
onDiscard={!editLocked ? () => void discardFlowDraft() : undefined}
15011506
busy={discardingFlowDraft || saving !== false}
15021507
/>
@@ -1597,7 +1602,7 @@ export function AutomationsPillar({
15971602
section,
15981603
onSectionChange: setFlowSection,
15991604
onProblemsChange: setProblemTally,
1600-
published: current && publishedFlowNames ? publishedFlowNames.has(current.name) : undefined,
1605+
published: flowPublished,
16011606
// objectstack#34818 — in the right slot, Debug draws the simulator there.
16021607
debugTarget: inSlot && section === 'debug' ? slot.propsTarget : null,
16031608
}}
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#38302 — the Data pillar's own AI line over the object canvas.
5+
* Its 「放弃 AI 的改动」 drops the object's draft: for an object with a
6+
* published or code version that goes back to it; for an object the AI
7+
* created and nobody published there is none, and the discard deletes it.
8+
* The button's title and the confirm asked over an unsaved edit say which,
9+
* from the pillar's own reading of the object's layers (`hasBaseline`: an
10+
* effective or code version). Keys are named, never copy.
11+
*
12+
* The harness is the one of `DataPillar.aiDraftDiscard-36511.test.tsx`, with
13+
* the layers read able to serve an object that holds no layer.
14+
*/
15+
16+
import '@testing-library/jest-dom/vitest';
17+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
18+
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
19+
import { MemoryRouter } from 'react-router-dom';
20+
21+
const PACKAGE = 'com.example.showcase';
22+
const live = {
23+
name: 'showcase_task',
24+
label: 'Task',
25+
fields: {
26+
priority: { name: 'priority', label: 'Priority', type: 'text' },
27+
},
28+
};
29+
/** The AI's version: one field added. */
30+
const aiVersion = {
31+
...live,
32+
fields: { ...live.fields, renewal_count: { name: 'renewal_count', label: 'Renewals', type: 'number' } },
33+
};
34+
35+
const minutesAgo = (n: number) => new Date(Date.now() - n * 60_000 - 5_000).toISOString();
36+
37+
/** What the next draft read serves: `null` for no draft. */
38+
let draftEnvelope: Record<string, unknown> | null = null;
39+
/** Whether the object has a version beyond its draft. */
40+
let published = true;
41+
42+
const mockClient = {
43+
save: vi.fn(async () => ({})),
44+
publish: vi.fn(async () => ({})),
45+
reset: vi.fn(async () => {
46+
draftEnvelope = null;
47+
return {};
48+
}),
49+
list: vi.fn(async (type: string) => (type === 'object' ? [{ name: 'showcase_task', label: 'Task' }] : [])),
50+
listDrafts: vi.fn(async () => []),
51+
// objectstack#38302 — `published` false serves an object with no layer
52+
// beyond its draft: no published row and no code baseline.
53+
layered: vi.fn(async () =>
54+
published
55+
? { effective: live, code: live, draft: draftEnvelope?.item ?? null }
56+
: { effective: null, code: null, overlay: null, draft: draftEnvelope?.item ?? null },
57+
),
58+
getDraft: vi.fn(async () => draftEnvelope),
59+
get: vi.fn(async () => null),
60+
withPreviewDrafts() {
61+
return this;
62+
},
63+
};
64+
65+
vi.mock('../metadata-admin/useMetadata', async (importOriginal) => {
66+
const mod = await importOriginal<typeof import('../metadata-admin/useMetadata')>();
67+
return { ...mod, useMetadataClient: () => mockClient, useMetadataTypes: () => ({ entries: [] }) };
68+
});
69+
70+
vi.mock('./packages-io', async (importOriginal) => {
71+
const mod = await importOriginal<typeof import('./packages-io')>();
72+
return { ...mod, fetchPackages: vi.fn(async () => []) };
73+
});
74+
75+
vi.mock('@object-ui/react', async (importOriginal) => {
76+
const mod = await importOriginal<typeof import('@object-ui/react')>();
77+
return { ...mod, useAdapter: () => dataSource };
78+
});
79+
80+
import '@objectstack/lint';
81+
import '@object-ui/plugin-detail';
82+
import { DataPillar } from './StudioDesignSurface';
83+
import { createEmptyDataSource, failOnAbsorbedFetchError } from './__tests__/emptyDataSource';
84+
import { addFieldFromFormToolbar } from './__tests__/dataPillarAddField';
85+
import { StudioSaveHarness } from './__tests__/studioSaveHarness';
86+
import { t } from '../metadata-admin/i18n';
87+
88+
const discardDrafts = vi.fn(async () => ({ success: true, failedCount: 0, failed: [], discarded: [] }));
89+
const dataSource = Object.assign(createEmptyDataSource(), {
90+
getClient: () => ({ packages: { discardDrafts } }),
91+
});
92+
failOnAbsorbedFetchError();
93+
94+
const L = (key: string) => t(key, 'en-US');
95+
96+
const confirmSpy = vi.fn((_message?: string) => true);
97+
beforeEach(() => {
98+
draftEnvelope = null;
99+
published = true;
100+
confirmSpy.mockReset();
101+
confirmSpy.mockReturnValue(true);
102+
window.confirm = confirmSpy as unknown as typeof window.confirm;
103+
});
104+
afterEach(() => {
105+
cleanup();
106+
vi.clearAllMocks();
107+
});
108+
109+
function serveDraft(by: string) {
110+
draftEnvelope = {
111+
type: 'object',
112+
name: 'showcase_task',
113+
item: { ...aiVersion, _draft: true },
114+
version: 'v1',
115+
draftChanges: [{ path: ['fields', 'renewal_count'], by, actor: 'usr_1', at: minutesAgo(2) }],
116+
};
117+
}
118+
119+
function renderPillar(onDraftSaved = vi.fn()): { onDraftSaved: ReturnType<typeof vi.fn> } {
120+
render(
121+
<MemoryRouter initialEntries={[`/studio/${PACKAGE}/data`]}>
122+
<StudioSaveHarness locale="en-US">
123+
<DataPillar objectName="showcase_task" packageId={PACKAGE} onDraftSaved={onDraftSaved} />
124+
</StudioSaveHarness>
125+
</MemoryRouter>,
126+
);
127+
return { onDraftSaved };
128+
}
129+
130+
async function openForm(): Promise<void> {
131+
fireEvent.click(await screen.findByRole('button', { name: L('engine.studio.data.tab.form') }));
132+
await screen.findByTestId('form-toolbar');
133+
}
134+
135+
const LIVE_TITLE = 'engine.studio.aiDraft.discardTitle';
136+
const DELETE_TITLE = 'engine.studio.aiDraft.discardTitleUnpublished';
137+
const LIVE_CONFIRM = 'engine.studio.aiDraft.discardConfirmUnsaved';
138+
const DELETE_CONFIRM = 'engine.studio.aiDraft.discardConfirmUnsavedUnpublished';
139+
140+
describe('the Data pillar AI line on an object never published (objectstack#38302)', () => {
141+
it('an object the AI created and nobody published: the discard title says it deletes it', async () => {
142+
published = false;
143+
serveDraft('copilot');
144+
renderPillar();
145+
const line = await screen.findByTestId('studio-copilot-changes');
146+
await waitFor(() => expect(within(line).getByTestId('studio-ai-draft-discard')).toHaveAttribute('title', L(DELETE_TITLE)));
147+
});
148+
149+
it('…and over an unsaved edit the confirm says so too; declined, nothing is sent', async () => {
150+
published = false;
151+
serveDraft('copilot');
152+
renderPillar();
153+
await openForm();
154+
await addFieldFromFormToolbar(undefined, { label: 'Due' });
155+
await screen.findByTestId('studio-save');
156+
confirmSpy.mockReturnValueOnce(false);
157+
fireEvent.click(screen.getByTestId('studio-ai-draft-discard'));
158+
expect(confirmSpy).toHaveBeenCalledWith(L(DELETE_CONFIRM));
159+
expect(mockClient.reset).not.toHaveBeenCalled();
160+
});
161+
162+
it('CONTROL: an object with a published version keeps the live-version wording on the title and the confirm', async () => {
163+
serveDraft('copilot');
164+
renderPillar();
165+
const line = await screen.findByTestId('studio-copilot-changes');
166+
await waitFor(() => expect(within(line).getByTestId('studio-ai-draft-discard')).toHaveAttribute('title', L(LIVE_TITLE)));
167+
await openForm();
168+
await addFieldFromFormToolbar(undefined, { label: 'Due' });
169+
await screen.findByTestId('studio-save');
170+
confirmSpy.mockReturnValueOnce(false);
171+
fireEvent.click(screen.getByTestId('studio-ai-draft-discard'));
172+
expect(confirmSpy).toHaveBeenCalledWith(L(LIVE_CONFIRM));
173+
});
174+
});

‎ui/packages/app-shell/src/views/studio-design/DataPillar.tsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ import { useMetadataRefreshNonce } from './useMetadataRefreshNonce.js';
137137
import { type Surface } from './navSurface.js';
138138
import { useSurfaceActionDeepLink } from './useSurfaceDeepLink.js';
139139
import { t, tFormat, translateMetadataType, useMetadataLocale } from '../metadata-admin/i18n.js';
140+
import { aiDraftDiscardConfirmUnsaved, aiDraftDiscardTitle } from './StudioAiDraftNotice.js';
140141
import { InspectorShellHostProvider } from '../metadata-admin/inspectors/_shared.js';
141142
import type { DestructiveChangeIssue } from '@objectstack/spec/api';
142143
import {
@@ -1463,7 +1464,9 @@ export function DataPillar({
14631464
const [discardingItemDraft, setDiscardingItemDraft] = React.useState(false);
14641465
const discardItemDraft = React.useCallback(async () => {
14651466
if (!current) return;
1466-
if (dirty && !window.confirm(t('engine.studio.aiDraft.discardConfirmUnsaved', locale))) return;
1467+
// objectstack#38302 — an object with no baseline (no published or code
1468+
// version) was never published: the discard deletes it, and the confirm says so.
1469+
if (dirty && !window.confirm(aiDraftDiscardConfirmUnsaved(locale, hasBaseline))) return;
14671470
setDiscardingItemDraft(true);
14681471
setError(null);
14691472
try {
@@ -1480,7 +1483,7 @@ export function DataPillar({
14801483
} finally {
14811484
setDiscardingItemDraft(false);
14821485
}
1483-
}, [client, current, dirty, locale, packageId, reloadObjDraft]);
1486+
}, [client, current, dirty, hasBaseline, locale, packageId, reloadObjDraft]);
14841487
// 放弃全部未发布改动 — the package's discard door (`packages.discardDrafts`),
14851488
// which drops every pending draft of the package, the author's own too; the
14861489
// confirm says so. There is no per-turn undo.
@@ -2154,7 +2157,7 @@ export function DataPillar({
21542157
data-testid="studio-ai-draft-discard"
21552158
onClick={() => void discardItemDraft()}
21562159
disabled={discardingItemDraft || discardingDrafts || saving !== false}
2157-
title={t('engine.studio.aiDraft.discardTitle', locale)}
2160+
title={aiDraftDiscardTitle(locale, hasBaseline)}
21582161
className="font-medium text-amber-700 hover:underline disabled:opacity-50 dark:text-amber-300"
21592162
>
21602163
{t('engine.studio.aiDraft.discard', locale)}

‎ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ export function ObjectActionsPanel({
827827
{selRow?.aiDraft && (
828828
<StudioAiDraftNotice
829829
locale={locale}
830+
published={selRow.published}
830831
onDiscard={editable(sel.name) ? () => added.discardAiDraft(selRow.name) : undefined}
831832
busy={added.discardingAiDraft !== null || added.saving}
832833
className="m-2 mb-0"

‎ui/packages/app-shell/src/views/studio-design/ObjectHooksPanel.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export function ObjectHooksPanel({
8282
addHook,
8383
reportCel,
8484
aiDraft,
85+
aiDraftPublished,
8586
discardAiDraft,
8687
discardingAiDraft,
8788
} = buffer;
@@ -213,6 +214,7 @@ export function ObjectHooksPanel({
213214
{aiDraft && (
214215
<StudioAiDraftNotice
215216
locale={locale}
217+
published={aiDraftPublished}
216218
onDiscard={disabled ? undefined : discardAiDraft}
217219
busy={discardingAiDraft || saving}
218220
className="m-3 mb-0"

‎ui/packages/app-shell/src/views/studio-design/PackageOwdOverviewPanel.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,15 @@ export function PackageOwdOverviewPanel({
771771
async (name: string) => {
772772
const own = rowState.find((s) => s.row.name === name);
773773
if (!own?.row.aiDraft) return;
774-
if (own.dirty && !window.confirm(t('engine.studio.owd.aiDraftDiscardConfirmUnsaved', locale))) return;
774+
// objectstack#38302 — an object the published list did not hold is
775+
// deleted by the discard; the other rows keep their edits either way.
776+
const ask = t(
777+
own.row.saved
778+
? 'engine.studio.owd.aiDraftDiscardConfirmUnsaved'
779+
: 'engine.studio.owd.aiDraftDiscardConfirmUnsavedUnpublished',
780+
locale,
781+
);
782+
if (own.dirty && !window.confirm(ask)) return;
775783
const others = rowState.filter((s) => s.dirty && s.row.name !== name);
776784
setDiscardingAiDraft(name);
777785
setSaveError(null);
@@ -937,6 +945,7 @@ export function PackageOwdOverviewPanel({
937945
<StudioAiDraftNotice
938946
locale={locale}
939947
text={t('engine.studio.owd.aiDraftNotice', locale)}
948+
published={row.saved}
940949
onDiscard={readOnly ? undefined : () => void discardAiDraft(row.name)}
941950
busy={discardingAiDraft !== null || saving}
942951
className="mt-1"

0 commit comments

Comments
 (0)