Skip to content

Commit 59a0510

Browse files
committed
refactor(studio): split #27485's inspector-close arm out of the WIP commit
The WIP commit carried both cards' code. The close arm (the CEL verdict kept with the draft after the inspector closes, its held line and its clause key) leaves here and lands again as its own commit, so it can be dropped on its own if the objectui#4306 sub-decision A ruling stands. Claude-Session: https://claude.ai/code/session_01Utp6CbCrKUjGeTReNEmUJx Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5002d07 commit 59a0510

3 files changed

Lines changed: 6 additions & 71 deletions

File tree

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

Lines changed: 6 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6415,54 +6415,13 @@ export function DataPillar({
64156415
// that does not parse must not be saveable, let alone publishable as the live
64166416
// field definition (objectui#4306).
64176417
//
6418-
// The report is STAMPED with the selection it came from: it is the open
6419-
// inspector's live verdict, and never reads as another selection's.
6418+
// The count is STAMPED with the selection it came from, so it expires by
6419+
// construction when the selection changes or the panel closes: an unmounted
6420+
// inspector can never retract its last verdict, and a host that waited for
6421+
// one would leave Save wedged shut with nothing on screen to fix.
64206422
const [blockingReport, setBlockingReport] = React.useState({ key: '', count: 0 });
64216423
const fieldSelKey = fieldSel ? `${current?.name ?? ''}:${fieldSel.kind}:${fieldSel.id}` : '';
6422-
// objectstack#27485 — the verdict belongs to the draft, not to the selection.
6423-
// Expiring it with the selection released the hold the moment the inspector
6424-
// closed (Escape, Close, another field, another tab) while the broken text
6425-
// stayed in the draft, and the autosave sent it. So each field's last live
6426-
// verdict is kept with the stamp of what it judged (`fieldCelStamp`, taken
6427-
// while the inspector is open on it) and holds, with the inspector closed,
6428-
// while the draft still carries that stamp: an edit to the text, the field's
6429-
// removal or the object's next load ends it. Nothing is left shut with
6430-
// nothing to fix: the held line names the field and its "Show me" opens it,
6431-
// and the open inspector's live verdict always wins.
6432-
const [celVerdicts, setCelVerdicts] = React.useState<Record<string, { field: string; count: number; stamp: string | null }>>({});
6433-
const liveFieldReport = fieldSel?.kind === 'field' && blockingReport.key === fieldSelKey;
6434-
const openFieldStamp = fieldSel?.kind === 'field' ? fieldCelStamp(objDraft, fieldSel.id) : null;
6435-
React.useEffect(() => {
6436-
if (!liveFieldReport || fieldSel === null) return;
6437-
const kept = { field: fieldSel.id, count: blockingReport.count, stamp: openFieldStamp };
6438-
setCelVerdicts((prev) => {
6439-
const was = prev[fieldSelKey];
6440-
if (was && was.count === kept.count && was.stamp === kept.stamp) return prev;
6441-
return { ...prev, [fieldSelKey]: kept };
6442-
});
6443-
}, [liveFieldReport, fieldSel, fieldSelKey, blockingReport.count, openFieldStamp]);
6444-
// The open object's fields whose verdict holds, and their summed count.
6445-
const celHeldFields: string[] = [];
6446-
let inspectorBlocking = 0;
6447-
const celFieldPrefix = `${current?.name ?? ''}:field:`;
6448-
for (const [key, kept] of Object.entries(celVerdicts)) {
6449-
if (!key.startsWith(celFieldPrefix) || key === fieldSelKey) continue;
6450-
if (kept.count > 0 && kept.stamp === fieldCelStamp(objDraft, kept.field)) {
6451-
celHeldFields.push(kept.field);
6452-
inspectorBlocking += kept.count;
6453-
}
6454-
}
6455-
if (blockingReport.key === fieldSelKey && blockingReport.count > 0) {
6456-
if (fieldSel?.kind === 'field') celHeldFields.push(fieldSel.id);
6457-
inspectorBlocking += blockingReport.count;
6458-
} else if (fieldSelKey !== '' && !liveFieldReport) {
6459-
// Opened, and its inspector has not reported yet: its kept verdict stands.
6460-
const kept = celVerdicts[fieldSelKey];
6461-
if (kept && kept.count > 0 && kept.stamp === openFieldStamp) {
6462-
celHeldFields.push(kept.field);
6463-
inspectorBlocking += kept.count;
6464-
}
6465-
}
6424+
const inspectorBlocking = blockingReport.key === fieldSelKey ? blockingReport.count : 0;
64666425
// The pillar's PANEL family reports separately (objectui#4527): the
64676426
// validations, actions and settings panels all write through this same draft
64686427
// and own no Save of their own, so their CEL faults have to reach this
@@ -6732,8 +6691,6 @@ export function DataPillar({
67326691
setLoading(true);
67336692
setError(null);
67346693
setFieldSel(null);
6735-
// objectstack#27485 — kept CEL verdicts judged the buffer this load replaces.
6736-
setCelVerdicts({});
67376694
setDirty(false);
67386695
(async () => {
67396696
try {
@@ -7010,27 +6967,8 @@ export function DataPillar({
70106967
snapshot: objDraft,
70116968
save: doSave,
70126969
});
7013-
// objectstack#27485 — an unsent edit the CEL verdict holds is named like an
7014-
// incomplete one: the held line, the surface's Publish and the rail's
7015-
// question all read it, so it outlives the inspector without going unseen.
7016-
const celHeldField = celHeldFields[0] ?? null;
7017-
const celHeldLabel = React.useMemo(() => {
7018-
if (celHeldField === null) return null;
7019-
const label = readFields(objDraft.fields).entries.find((e) => e.name === celHeldField)?.def.label;
7020-
return typeof label === 'string' && label.trim() !== '' ? label.trim() : celHeldField;
7021-
}, [celHeldField, objDraft.fields]);
7022-
const objCelHeld = React.useMemo<StudioHeld | null>(
7023-
() =>
7024-
dirty && celHeldField !== null && celHeldLabel !== null
7025-
? {
7026-
clause: tFormat('engine.studio.held.celInvalid', locale, { field: celHeldLabel }),
7027-
target: { kind: 'field', id: celHeldField },
7028-
}
7029-
: null,
7030-
[dirty, celHeldField, celHeldLabel, locale],
7031-
);
70326970
// Only the open object's own buffer is held (objectui#11272).
7033-
const objHeld = objLoaded ? (objIncomplete ?? objCelHeld) : null;
6971+
const objHeld = objLoaded ? objIncomplete : null;
70346972
// objectstack#26917 — the refusal's way out: the object holding the
70356973
// identifier is on this rail, so it opens instead of a second one being
70366974
// made. The New button already asked about a held edit (objectstack#26845).

‎ui/packages/i18n/src/namespaces/studio/en.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,8 +2999,6 @@ const STUDIO_EN: Record<string, string> = {
29992999
// objectui#11910 — a dashboard widget held until it is bound; `input` is the
30003000
// widget inspector's own label for it (Dataset, Values (measures)).
30013001
'engine.studio.held.widgetNeedsInput': '{input} on the widget “{widget}” needs a value',
3002-
// objectstack#27485 — a field CEL expression the inspector judged broken, held after it closes.
3003-
'engine.studio.held.celInvalid': 'an expression on the field “{field}” has an error to fix',
30043002
'engine.studio.held.line': 'Not saved yet: {clause}. Your changes are kept here and saved once it is filled in.',
30053003
'engine.studio.held.publish': 'Not published: {clause}, so that change is not saved yet. Finish it, then publish.',
30063004
'engine.studio.held.inputHint': 'Required. Changes are saved once this has a value.',

‎ui/packages/i18n/src/namespaces/studio/zh.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2668,7 +2668,6 @@ const STUDIO_ZH: Record<string, string> = {
26682668
'engine.studio.held.needsRuleField': '规则「{rule}」需要选择一个字段',
26692669
'engine.studio.held.needsRuleMessage': '规则「{rule}」需要一条错误消息',
26702670
'engine.studio.held.widgetNeedsInput': '组件「{widget}」的「{input}」需要填写',
2671-
'engine.studio.held.celInvalid': '字段「{field}」的表达式有错误需要修正',
26722671
'engine.studio.held.line': '尚未保存:{clause}。更改已保留在此处,补全后会自动保存。',
26732672
'engine.studio.held.publish': '未发布:{clause},该更改尚未保存。请先补全,再发布。',
26742673
'engine.studio.held.inputHint': '必填。填写后才会保存更改。',

0 commit comments

Comments
 (0)