@things-factory/figure-ui 10.1.167 → 10.1.169

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/client/figure-assistant.ts +15 -1
  2. package/client/modeller/ai-proposal.ts +60 -11
  3. package/client/modeller/figure-properties.ts +1 -3
  4. package/client/modeller/product-session.ts +32 -13
  5. package/client/modeller/refusals.ts +14 -0
  6. package/client/pages/figure-modeller-page.ts +14 -10
  7. package/dist-client/figure-assistant.d.ts +6 -0
  8. package/dist-client/figure-assistant.js +14 -1
  9. package/dist-client/figure-assistant.js.map +1 -1
  10. package/dist-client/modeller/ai-proposal.d.ts +23 -5
  11. package/dist-client/modeller/ai-proposal.js +55 -13
  12. package/dist-client/modeller/ai-proposal.js.map +1 -1
  13. package/dist-client/modeller/clips.d.ts +1 -1
  14. package/dist-client/modeller/figure-properties.d.ts +1 -2
  15. package/dist-client/modeller/figure-properties.js +1 -3
  16. package/dist-client/modeller/figure-properties.js.map +1 -1
  17. package/dist-client/modeller/product-session.d.ts +14 -4
  18. package/dist-client/modeller/product-session.js +31 -13
  19. package/dist-client/modeller/product-session.js.map +1 -1
  20. package/dist-client/modeller/refusals.d.ts +1 -5
  21. package/dist-client/modeller/refusals.js +14 -1
  22. package/dist-client/modeller/refusals.js.map +1 -1
  23. package/dist-client/pages/figure-modeller-page.js +14 -9
  24. package/dist-client/pages/figure-modeller-page.js.map +1 -1
  25. package/dist-client/route.d.ts +1 -1
  26. package/dist-client/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +7 -7
  28. package/test/ai-proposal.test.ts +115 -5
  29. package/test/browser/acceptance-page.js +3 -1
  30. package/test/browser/product-page.check.mjs +63 -3
  31. package/test/browser/product-page.js +7 -2
  32. package/test/figure-assistant-surface.test.ts +65 -1
  33. package/test/proposal-record.test.ts +18 -6
  34. package/translations/en.json +6 -12
  35. package/translations/es.json +6 -12
  36. package/translations/ja.json +6 -12
  37. package/translations/ko.json +6 -12
  38. package/translations/ms.json +6 -12
  39. package/translations/zh.json +6 -12
  40. package/client/modeller/carrier-declaration.ts +0 -63
  41. package/client/modeller/figure-carrier.ts +0 -117
  42. package/dist-client/modeller/carrier-declaration.d.ts +0 -31
  43. package/dist-client/modeller/carrier-declaration.js +0 -53
  44. package/dist-client/modeller/carrier-declaration.js.map +0 -1
  45. package/dist-client/modeller/figure-carrier.d.ts +0 -26
  46. package/dist-client/modeller/figure-carrier.js +0 -123
  47. package/dist-client/modeller/figure-carrier.js.map +0 -1
  48. package/test/carrier-declaration.test.ts +0 -69
@@ -1,4 +1,4 @@
1
- import { clipLossOf, refusalRecordOf } from './refusals.js';
1
+ import { clipLossOf, editRefusalOf, refusalRecordOf } from './refusals.js';
2
2
  /**
3
3
  * The dock's "check the result" (ADR-0097 §5.6 item 5): what the server recorded of a proposal. Saved into figures:
4
4
  * accepted, named. Nothing recorded: not known -- applied and not saved yet, undone, or never taken -- so `undefined`,
@@ -25,7 +25,8 @@ function refused(refusal, say) {
25
25
  ? (error ?? '')
26
26
  : clips
27
27
  ? say('figure.text.proposal-would-drop-clips', { clips: clips.map(c => c.clip).join(', ') })
28
- : say('figure.text.proposal-refused', { reason: error ?? '' });
28
+ : /* A refusal with a code is said from it, as the modeller says an edit it refuses; never its message (audit N6). */
29
+ say('figure.text.proposal-refused', { reason: code ? editRefusalOf(refusal, (key, params) => say(key, params)) : (error ?? '') });
29
30
  return { verdict: 'refused', errorCode: code ?? 'refused', note };
30
31
  }
31
32
  /**
@@ -38,6 +39,13 @@ export function takeFigureOffer(session, detail, { onSavedFigure, say }) {
38
39
  const view = session.read();
39
40
  if (detail.create && onSavedFigure)
40
41
  return false;
42
+ /*
43
+ A revision is for the figure the model read; with another open it is left untaken, and the handler says it needs that
44
+ figure open. The version is no proof of the figure: two figures opened in two page loads stood at the same one
45
+ (figure audit 2026-10-16 N3).
46
+ */
47
+ if (!detail.create && typeof detail.figureId === 'string' && detail.figureId !== (view.id ?? view.creationId))
48
+ return false;
41
49
  if (detail.create && view.dirty) {
42
50
  /* A new figure already being made is the person's; a proposal does not go on top of it or replace it. */
43
51
  detail.applied = false;
@@ -47,9 +55,11 @@ export function takeFigureOffer(session, detail, { onSavedFigure, say }) {
47
55
  }
48
56
  try {
49
57
  if (detail.create) {
50
- /* Created under the proposal's key: taken twice, it meets the first figure, never a second (ADR-0097 §5.6 item 5). */
51
- if (detail.key)
52
- session.createUnder(detail.key);
58
+ /*
59
+ Taken on the new figure the modeller has open, whose conversation asked for it: the figure keeps its own creation
60
+ id, the anchor of that conversation (ADR-0061 decision 3, ruled 2026-10-16). One proposal stays one figure by the
61
+ save's record of it, which `runFigureProposal` reads before the card runs again.
62
+ */
53
63
  session.applyProposal(detail.steps, view.revision, view.context, detail.key);
54
64
  }
55
65
  else if (detail.steps)
@@ -69,14 +79,25 @@ export function takeFigureOffer(session, detail, { onSavedFigure, say }) {
69
79
  export async function runFigureProposal(card, target, say) {
70
80
  const steps = card?.steps;
71
81
  if (!Array.isArray(steps) || !steps.length)
72
- return { verdict: 'unavailable', errorCode: 'no-steps' };
82
+ return { verdict: 'unavailable', errorCode: 'no-steps', note: say('figure.text.proposal-empty') };
73
83
  const create = card.create === true;
84
+ /*
85
+ A new figure's proposal already saved into a figure is not made again: that figure is opened (ADR-0061 decision 3,
86
+ ruled 2026-10-16). Taken on a new figure that kept its own creation id, the save's record is what says it was made.
87
+ */
88
+ if (create && card.key) {
89
+ const saved = await target.savedInto(card.key);
90
+ if (saved.length) {
91
+ target.openSaved(saved[0].figureId);
92
+ return proposalOutcomeFrom(saved, say);
93
+ }
94
+ }
74
95
  const accepted = () => ({
75
96
  verdict: 'accepted',
76
97
  applied: steps.length,
77
98
  note: say('figure.text.proposal-applied', { n: String(steps.length) })
78
99
  });
79
- const detail = target.offer({ key: card.key, steps, create, context: card.context, revision: card.revision });
100
+ const detail = target.offer({ key: card.key, steps, create, figureId: create ? undefined : card.figureId, context: card.context, revision: card.revision });
80
101
  if (detail.applied)
81
102
  return accepted();
82
103
  if (detail.applied === false)
@@ -91,15 +112,12 @@ export async function runFigureProposal(card, target, say) {
91
112
  ? { verdict: 'unavailable', errorCode: 'not-opened', note: say('figure.text.proposal-not-opened') }
92
113
  : refused(opened, say);
93
114
  }
94
- /*
95
- A new figure's proposal handed to the modeller page across a navigation: the handler leaves it here and opens the
96
- modeller on a new figure; the page takes it once it has started that figure. Left untaken, it lapses -- a later new
97
- figure must not receive steps nobody is waiting for.
98
- */
99
115
  let pending;
100
116
  export function pendNewFigure(steps, key, ms = 10_000) {
101
117
  pending?.settle({ applied: false, code: 'not-opened' });
102
118
  return new Promise(resolve => {
119
+ let timer;
120
+ const lapse = () => mine.settle({ applied: false, code: 'not-opened' });
103
121
  const mine = {
104
122
  steps,
105
123
  key,
@@ -108,12 +126,36 @@ export function pendNewFigure(steps, key, ms = 10_000) {
108
126
  if (pending === mine)
109
127
  pending = undefined;
110
128
  resolve(result);
129
+ },
130
+ hold: () => clearTimeout(timer),
131
+ resume: () => {
132
+ clearTimeout(timer);
133
+ timer = setTimeout(lapse, ms);
111
134
  }
112
135
  };
113
- const timer = setTimeout(() => mine.settle({ applied: false, code: 'not-opened' }), ms);
136
+ mine.resume();
114
137
  pending = mine;
115
138
  });
116
139
  }
140
+ /**
141
+ * For a page about to ask the person whether to leave unsaved edits: the new figure waiting to open stops its clock
142
+ * while they answer -- an answer is no absent page (figure audit 2026-10-16 N4). Give it the answer: leaving runs the
143
+ * clock again for the page that opens; staying says now that it was not opened. Nothing waiting: undefined.
144
+ */
145
+ export function askingToLeave() {
146
+ const waiting = pending;
147
+ if (!waiting)
148
+ return undefined;
149
+ waiting.hold();
150
+ return leaving => {
151
+ if (pending !== waiting)
152
+ return;
153
+ if (leaving)
154
+ waiting.resume();
155
+ else
156
+ waiting.settle({ applied: false, code: 'not-opened' });
157
+ };
158
+ }
117
159
  /** For the page, on a new figure it has just started: the steps waiting for it, and where to say how it went. */
118
160
  export function takePendingNewFigure() {
119
161
  const taken =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zC,OAAO,CAAC,MAAM,CAAC,CAAA;YACjB,CAAC;SACF,CAAA;QACD,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;QACvF,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,oBAAoB;IAGlC,MAAM,KAAK,GAAG,OAAO,CAAA;IACrB,OAAO,GAAG,SAAS,CAAA;IACnB,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["/*\n * An AI proposal reaching the modeller (ADR-0094). The dock's card carries the modeller's own commands; running it\n * applies them as one step of the modeller's history, undone whole, on the version the model saw. Nothing half made\n * is applied, and every outcome is said: applied, refused with the reason, or not possible here.\n *\n * Kept free of Lit, i18n and the shell so node tests read it directly; the handler and the page pass in what they own.\n */\nimport type { FigureProposalStep } from '@hatiolab/figure-model'\nimport type { FigureProductSession } from './product-session.js'\nimport { clipLossOf, refusalRecordOf, type FigureRefusalRecord } from './refusals.js'\n\n/** What the card carries, as `proposeFigureCandidate` returned it. */\nexport interface FigureProposalCard {\n /** The proposal's own name, given by the tool: a save records it, a new figure made from it is created under it. */\n key?: string\n steps?: FigureProposalStep[]\n create?: boolean\n figureId?: string\n context?: string\n revision?: number\n}\n\n/**\n * The `figure-apply` event's detail. The page that takes it sets `applied`, and when refused `error` and the refusal in\n * figure-model's shape (`code`, `details`, the `clips` it would stop).\n */\nexport interface FigureApplyDetail extends FigureRefusalRecord {\n key?: string\n steps: FigureProposalStep[]\n create: boolean\n context?: string\n revision?: number\n applied?: boolean\n error?: string\n}\n\nexport type Say = (key: string, params?: Record<string, string>) => string\n\nexport interface FigureProposalTarget {\n /** Offers the proposal to a modeller on screen. It comes back untouched when none took it. */\n offer(detail: FigureApplyDetail): FigureApplyDetail\n /** Opens a new figure in the modeller and applies the steps there; resolves once the page has, or has not. */\n openNew(steps: FigureProposalStep[], key?: string): Promise<{ applied: boolean; error?: string; code?: string }>\n}\n\nexport interface FigureProposalOutcome {\n verdict: 'accepted' | 'refused' | 'unavailable'\n errorCode?: string\n applied?: number\n note?: string\n}\n\n/**\n * The dock's \"check the result\" (ADR-0097 §5.6 item 5): what the server recorded of a proposal. Saved into figures:\n * accepted, named. Nothing recorded: not known -- applied and not saved yet, undone, or never taken -- so `undefined`,\n * which the dock keeps as \"not known\" and never turns into a refusal. Nothing is run again.\n */\nexport function proposalOutcomeFrom(saved: ReadonlyArray<{ figureId: string; type?: string; name?: string }>, say: Say): FigureProposalOutcome | undefined {\n if (!saved.length) return undefined\n const names = saved.map(f => f.name || f.type || f.figureId).join(', ')\n return { verdict: 'accepted', note: say('figure.text.proposal-saved-into', { names }) }\n}\n\n/** The workspace refuses a request made on another version; said as what happened, not as the kernel's code. */\nconst STALE = new Set(['REVISION_CONFLICT', 'CONTEXT_CONFLICT'])\n\nfunction refused(refusal: FigureRefusalRecord & { error?: string }, say: Say): FigureProposalOutcome {\n const { code, error } = refusal\n const clips = clipLossOf(refusal)\n /*\n A proposal that would stop clips is refused whole; nobody but the person may agree to that, and a proposal is not\n asked about -- the person edits by hand if they mean it (designer 2026-09-27).\n */\n const note =\n code && STALE.has(code)\n ? say('figure.text.proposal-stale')\n : code === 'NEW_FIGURE_UNSAVED'\n ? (error ?? '')\n : clips\n ? say('figure.text.proposal-would-drop-clips', { clips: clips.map(c => c.clip).join(', ') })\n : say('figure.text.proposal-refused', { reason: error ?? '' })\n return { verdict: 'refused', errorCode: code ?? 'refused', note }\n}\n\n/**\n * The modeller page's way of taking an offer from the dock (`figure-apply`): input changes, or a proposal's commands\n * as one step (ADR-0094). A revision is applied on the version the model saw; a new figure's proposal only on a new\n * figure not yet touched, and a page on a saved figure leaves it untaken. Never with a consent to let clips go: a\n * proposal that would stop one is refused whole, the clips named (designer 2026-09-27). True when it was applied.\n */\nexport function takeFigureOffer(\n session: FigureProductSession,\n detail: FigureApplyDetail & { changes?: unknown },\n { onSavedFigure, say }: { onSavedFigure: boolean; say: Say }\n): boolean {\n const view = session.read()\n if (detail.create && onSavedFigure) return false\n if (detail.create && view.dirty) {\n /* A new figure already being made is the person's; a proposal does not go on top of it or replace it. */\n detail.applied = false\n detail.code = 'NEW_FIGURE_UNSAVED'\n detail.error = say('figure.text.proposal-new-figure-unsaved')\n return false\n }\n try {\n if (detail.create) {\n /* Created under the proposal's key: taken twice, it meets the first figure, never a second (ADR-0097 §5.6 item 5). */\n if (detail.key) session.createUnder(detail.key)\n session.applyProposal(detail.steps, view.revision!, view.context!, detail.key)\n } else if (detail.steps) session.applyProposal(detail.steps, detail.revision!, detail.context!, detail.key)\n else session.apply(detail.changes as never, 'ai', detail.revision, detail.context)\n detail.applied = true\n return true\n } catch (error) {\n detail.applied = false\n Object.assign(detail, refusalRecordOf(error))\n detail.error = error instanceof Error ? error.message : String(error)\n return false\n }\n}\n\nexport async function runFigureProposal(card: FigureProposalCard, target: FigureProposalTarget, say: Say): Promise<FigureProposalOutcome> {\n const steps = card?.steps\n if (!Array.isArray(steps) || !steps.length) return { verdict: 'unavailable', errorCode: 'no-steps' }\n const create = card.create === true\n const accepted = (): FigureProposalOutcome => ({\n verdict: 'accepted',\n applied: steps.length,\n note: say('figure.text.proposal-applied', { n: String(steps.length) })\n })\n\n const detail = target.offer({ key: card.key, steps, create, context: card.context, revision: card.revision })\n if (detail.applied) return accepted()\n if (detail.applied === false) return refused(detail, say)\n\n /* A revision belongs to the figure the model saw; with that modeller gone there is nowhere true to apply it. */\n if (!create) return { verdict: 'unavailable', errorCode: 'modeller-not-open', note: say('figure.text.proposal-needs-modeller') }\n\n const opened = await target.openNew(steps, card.key)\n if (opened.applied) return accepted()\n return opened.code === 'not-opened'\n ? { verdict: 'unavailable', errorCode: 'not-opened', note: say('figure.text.proposal-not-opened') }\n : refused(opened, say)\n}\n\n/*\n A new figure's proposal handed to the modeller page across a navigation: the handler leaves it here and opens the\n modeller on a new figure; the page takes it once it has started that figure. Left untaken, it lapses -- a later new\n figure must not receive steps nobody is waiting for.\n*/\nlet pending: { steps: FigureProposalStep[]; key?: string; settle: (result: { applied: boolean; error?: string; code?: string }) => void } | undefined\n\nexport function pendNewFigure(steps: FigureProposalStep[], key?: string, ms = 10_000): Promise<{ applied: boolean; error?: string; code?: string }> {\n pending?.settle({ applied: false, code: 'not-opened' })\n return new Promise(resolve => {\n const mine = {\n steps,\n key,\n settle: (result: { applied: boolean; error?: string; code?: string }) => {\n clearTimeout(timer)\n if (pending === mine) pending = undefined\n resolve(result)\n }\n }\n const timer = setTimeout(() => mine.settle({ applied: false, code: 'not-opened' }), ms)\n pending = mine\n })\n}\n\n/** For the page, on a new figure it has just started: the steps waiting for it, and where to say how it went. */\nexport function takePendingNewFigure():\n | { steps: FigureProposalStep[]; key?: string; settle: (result: { applied: boolean; error?: string; code?: string }) => void }\n | undefined {\n const taken = pending\n pending = undefined\n return taken\n}\n"]}
1
+ {"version":3,"file":"ai-proposal.js","sourceRoot":"","sources":["../../client/modeller/ai-proposal.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAA4B,MAAM,eAAe,CAAA;AAiDpG;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAwE,EAAE,GAAQ;IACpH,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,SAAS,CAAA;IACnC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAA;AACzF,CAAC;A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sourcesContent":["/*\n * An AI proposal reaching the modeller (ADR-0094). The dock's card carries the modeller's own commands; running it\n * applies them as one step of the modeller's history, undone whole, on the version the model saw. Nothing half made\n * is applied, and every outcome is said: applied, refused with the reason, or not possible here.\n *\n * Kept free of Lit, i18n and the shell so node tests read it directly; the handler and the page pass in what they own.\n */\nimport type { FigureProposalStep } from '@hatiolab/figure-model'\nimport type { FigureProductSession } from './product-session.js'\nimport { clipLossOf, editRefusalOf, refusalRecordOf, type FigureRefusalRecord } from './refusals.js'\n\n/** What the card carries, as `proposeFigureCandidate` returned it. */\nexport interface FigureProposalCard {\n /** The proposal's own name, given by the tool: a save records it, a new figure made from it is created under it. */\n key?: string\n steps?: FigureProposalStep[]\n create?: boolean\n figureId?: string\n context?: string\n revision?: number\n}\n\n/**\n * The `figure-apply` event's detail. The page that takes it sets `applied`, and when refused `error` and the refusal in\n * figure-model's shape (`code`, `details`, the `clips` it would stop).\n */\nexport interface FigureApplyDetail extends FigureRefusalRecord {\n key?: string\n steps: FigureProposalStep[]\n create: boolean\n /** The figure a revision was made for: the one the model read. */\n figureId?: string\n context?: string\n revision?: number\n applied?: boolean\n error?: string\n}\n\nexport type Say = (key: string, params?: Record<string, string>) => string\n\nexport interface FigureProposalTarget {\n /** Offers the proposal to a modeller on screen. It comes back untouched when none took it. */\n offer(detail: FigureApplyDetail): FigureApplyDetail\n /** Opens a new figure in the modeller and applies the steps there; resolves once the page has, or has not. */\n openNew(steps: FigureProposalStep[], key?: string): Promise<{ applied: boolean; error?: string; code?: string }>\n /** The figures the server recorded a save of this proposal into (`figureProposalOutcome`), first saved first. */\n savedInto(key: string): Promise<ReadonlyArray<{ figureId: string; type?: string; name?: string }>>\n /** Opens a saved figure in the modeller. */\n openSaved(figureId: string): void\n}\n\nexport interface FigureProposalOutcome {\n verdict: 'accepted' | 'refused' | 'unavailable'\n errorCode?: string\n applied?: number\n note?: string\n}\n\n/**\n * The dock's \"check the result\" (ADR-0097 §5.6 item 5): what the server recorded of a proposal. Saved into figures:\n * accepted, named. Nothing recorded: not known -- applied and not saved yet, undone, or never taken -- so `undefined`,\n * which the dock keeps as \"not known\" and never turns into a refusal. Nothing is run again.\n */\nexport function proposalOutcomeFrom(saved: ReadonlyArray<{ figureId: string; type?: string; name?: string }>, say: Say): FigureProposalOutcome | undefined {\n if (!saved.length) return undefined\n const names = saved.map(f => f.name || f.type || f.figureId).join(', ')\n return { verdict: 'accepted', note: say('figure.text.proposal-saved-into', { names }) }\n}\n\n/** The workspace refuses a request made on another version; said as what happened, not as the kernel's code. */\nconst STALE = new Set(['REVISION_CONFLICT', 'CONTEXT_CONFLICT'])\n\nfunction refused(refusal: FigureRefusalRecord & { error?: string }, say: Say): FigureProposalOutcome {\n const { code, error } = refusal\n const clips = clipLossOf(refusal)\n /*\n A proposal that would stop clips is refused whole; nobody but the person may agree to that, and a proposal is not\n asked about -- the person edits by hand if they mean it (designer 2026-09-27).\n */\n const note =\n code && STALE.has(code)\n ? say('figure.text.proposal-stale')\n : code === 'NEW_FIGURE_UNSAVED'\n ? (error ?? '')\n : clips\n ? say('figure.text.proposal-would-drop-clips', { clips: clips.map(c => c.clip).join(', ') })\n : /* A refusal with a code is said from it, as the modeller says an edit it refuses; never its message (audit N6). */\n say('figure.text.proposal-refused', { reason: code ? editRefusalOf(refusal, (key, params) => say(key, params)) : (error ?? '') })\n return { verdict: 'refused', errorCode: code ?? 'refused', note }\n}\n\n/**\n * The modeller page's way of taking an offer from the dock (`figure-apply`): input changes, or a proposal's commands\n * as one step (ADR-0094). A revision is applied on the version the model saw; a new figure's proposal only on a new\n * figure not yet touched, and a page on a saved figure leaves it untaken. Never with a consent to let clips go: a\n * proposal that would stop one is refused whole, the clips named (designer 2026-09-27). True when it was applied.\n */\nexport function takeFigureOffer(\n session: FigureProductSession,\n detail: FigureApplyDetail & { changes?: unknown },\n { onSavedFigure, say }: { onSavedFigure: boolean; say: Say }\n): boolean {\n const view = session.read()\n if (detail.create && onSavedFigure) return false\n /*\n A revision is for the figure the model read; with another open it is left untaken, and the handler says it needs that\n figure open. The version is no proof of the figure: two figures opened in two page loads stood at the same one\n (figure audit 2026-10-16 N3).\n */\n if (!detail.create && typeof detail.figureId === 'string' && detail.figureId !== (view.id ?? view.creationId)) return false\n if (detail.create && view.dirty) {\n /* A new figure already being made is the person's; a proposal does not go on top of it or replace it. */\n detail.applied = false\n detail.code = 'NEW_FIGURE_UNSAVED'\n detail.error = say('figure.text.proposal-new-figure-unsaved')\n return false\n }\n try {\n if (detail.create) {\n /*\n Taken on the new figure the modeller has open, whose conversation asked for it: the figure keeps its own creation\n id, the anchor of that conversation (ADR-0061 decision 3, ruled 2026-10-16). One proposal stays one figure by the\n save's record of it, which `runFigureProposal` reads before the card runs again.\n */\n session.applyProposal(detail.steps, view.revision!, view.context!, detail.key)\n } else if (detail.steps) session.applyProposal(detail.steps, detail.revision!, detail.context!, detail.key)\n else session.apply(detail.changes as never, 'ai', detail.revision, detail.context)\n detail.applied = true\n return true\n } catch (error) {\n detail.applied = false\n Object.assign(detail, refusalRecordOf(error))\n detail.error = error instanceof Error ? error.message : String(error)\n return false\n }\n}\n\nexport async function runFigureProposal(card: FigureProposalCard, target: FigureProposalTarget, say: Say): Promise<FigureProposalOutcome> {\n const steps = card?.steps\n if (!Array.isArray(steps) || !steps.length) return { verdict: 'unavailable', errorCode: 'no-steps', note: say('figure.text.proposal-empty') }\n const create = card.create === true\n /*\n A new figure's proposal already saved into a figure is not made again: that figure is opened (ADR-0061 decision 3,\n ruled 2026-10-16). Taken on a new figure that kept its own creation id, the save's record is what says it was made.\n */\n if (create && card.key) {\n const saved = await target.savedInto(card.key)\n if (saved.length) {\n target.openSaved(saved[0]!.figureId)\n return proposalOutcomeFrom(saved, say)!\n }\n }\n const accepted = (): FigureProposalOutcome => ({\n verdict: 'accepted',\n applied: steps.length,\n note: say('figure.text.proposal-applied', { n: String(steps.length) })\n })\n\n const detail = target.offer({ key: card.key, steps, create, figureId: create ? undefined : card.figureId, context: card.context, revision: card.revision })\n if (detail.applied) return accepted()\n if (detail.applied === false) return refused(detail, say)\n\n /* A revision belongs to the figure the model saw; with that modeller gone there is nowhere true to apply it. */\n if (!create) return { verdict: 'unavailable', errorCode: 'modeller-not-open', note: say('figure.text.proposal-needs-modeller') }\n\n const opened = await target.openNew(steps, card.key)\n if (opened.applied) return accepted()\n return opened.code === 'not-opened'\n ? { verdict: 'unavailable', errorCode: 'not-opened', note: say('figure.text.proposal-not-opened') }\n : refused(opened, say)\n}\n\n/*\n A new figure's proposal handed to the modeller page across a navigation: the handler leaves it here and opens the\n modeller on a new figure; the page takes it once it has started that figure. Left untaken, it lapses -- a later new\n figure must not receive steps nobody is waiting for.\n*/\ntype Settle = (result: { applied: boolean; error?: string; code?: string }) => void\nlet pending: { steps: FigureProposalStep[]; key?: string; settle: Settle; hold(): void; resume(): void } | undefined\n\nexport function pendNewFigure(steps: FigureProposalStep[], key?: string, ms = 10_000): Promise<{ applied: boolean; error?: string; code?: string }> {\n pending?.settle({ applied: false, code: 'not-opened' })\n return new Promise(resolve => {\n let timer: ReturnType<typeof setTimeout> | undefined\n const lapse = () => mine.settle({ applied: false, code: 'not-opened' })\n const mine = {\n steps,\n key,\n settle: (result: { applied: boolean; error?: string; code?: string }) => {\n clearTimeout(timer)\n if (pending === mine) pending = undefined\n resolve(result)\n },\n hold: () => clearTimeout(timer),\n resume: () => {\n clearTimeout(timer)\n timer = setTimeout(lapse, ms)\n }\n }\n mine.resume()\n pending = mine\n })\n}\n\n/**\n * For a page about to ask the person whether to leave unsaved edits: the new figure waiting to open stops its clock\n * while they answer -- an answer is no absent page (figure audit 2026-10-16 N4). Give it the answer: leaving runs the\n * clock again for the page that opens; staying says now that it was not opened. Nothing waiting: undefined.\n */\nexport function askingToLeave(): ((leaving: boolean) => void) | undefined {\n const waiting = pending\n if (!waiting) return undefined\n waiting.hold()\n return leaving => {\n if (pending !== waiting) return\n if (leaving) waiting.resume()\n else waiting.settle({ applied: false, code: 'not-opened' })\n }\n}\n\n/** For the page, on a new figure it has just started: the steps waiting for it, and where to say how it went. */\nexport function takePendingNewFigure(): { steps: FigureProposalStep[]; key?: string; settle: Settle } | undefined {\n const taken = pending\n pending = undefined\n return taken\n}\n"]}
@@ -65,5 +65,5 @@ export declare const trackEdit: (clip: Clip, track: ClipTrack, patch?: Partial<P
65
65
  clip: string;
66
66
  keys: ClipKey[];
67
67
  loop: "wrap" | "hold";
68
- interpolation: "step" | "linear";
68
+ interpolation: "linear" | "step";
69
69
  };
@@ -1,6 +1,5 @@
1
1
  import '@material/web/icon/icon.js';
2
2
  import { LitElement } from 'lit';
3
- import './figure-carrier.js';
4
3
  import type { FigureRevision } from './revision.js';
5
4
  declare const FigureProperties_base: (new (...args: any[]) => LitElement) & typeof LitElement;
6
5
  /**
@@ -10,7 +9,7 @@ declare const FigureProperties_base: (new (...args: any[]) => LitElement) & type
10
9
  * catalogue files it.
11
10
  *
12
11
  * Two kinds of change leave this tab, and it does neither itself:
13
- * - `command` carries an authoring command (rename, declare the room, the mounting face, the carrier). The page runs it
12
+ * - `command` carries an authoring command (rename, declare the room, the mounting face). The page runs it
14
13
  * through the session, so it is one step of the same undo history as every other edit, and is saved with it.
15
14
  * - `catalog` carries a change to the row (category, tags). Those are not in the asset; the page writes them
16
15
  * to the saved row at once, so they need a saved figure.
@@ -5,7 +5,6 @@ import { customElement, property, state } from 'lit/decorators.js';
5
5
  import { live } from 'lit/directives/live.js';
6
6
  import { i18next, localize } from '@operato/i18n';
7
7
  import { FIGURE_FACES } from '@hatiolab/figure-model';
8
- import './figure-carrier.js';
9
8
  import { occupancyFromParts } from './occupancy.js';
10
9
  import { tagsOf, figureFigureFacts } from './figure-facts.js';
11
10
  import { offeredMountingOf } from './mounting-part.js';
@@ -20,7 +19,7 @@ const FACES = Object.keys(FIGURE_FACES);
20
19
  * catalogue files it.
21
20
  *
22
21
  * Two kinds of change leave this tab, and it does neither itself:
23
- * - `command` carries an authoring command (rename, declare the room, the mounting face, the carrier). The page runs it
22
+ * - `command` carries an authoring command (rename, declare the room, the mounting face). The page runs it
24
23
  * through the session, so it is one step of the same undo history as every other edit, and is saved with it.
25
24
  * - `catalog` carries a change to the row (category, tags). Those are not in the asset; the page writes them
26
25
  * to the saved row at once, so they need a saved figure.
@@ -102,7 +101,6 @@ let FigureProperties = class FigureProperties extends localize(i18next)(LitEleme
102
101
  <h3>${i18next.t('figure.label.group-standing')}</h3>
103
102
  ${this.renderSpace(facts)} ${this.renderMounting(facts)}
104
103
  </section>
105
- <figure-carrier .carrier=${this.revision?.asset.carrier}></figure-carrier>
106
104
  <section>
107
105
  <h3>${i18next.t('figure.label.group-catalog')}</h3>
108
106
  ${this.renderCatalog()}
@@ -1 +1 @@
1
- {"version":3,"file":"figure-properties.js","sourceRoot":"","sources":["../../client/modeller/figure-properties.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAGrD,OAAO,qBAAqB,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAA0C,MAAM,mBAAmB,CAAA;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,gEAAgE,CAAA;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,UAAU,GAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,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AAO,CAAC,CAAC,CAAC,IAAI,CAAA,UAAU,OAAO,CAAC,CAAC,CAAC,kCAAkC,CAAC,UAAU;;KAE5F,CAAA;IACH,CAAC;IAEO,OAAO,CAAC,SAAoB;QAClC,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAM;QAC1B,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAA;IAClE,CAAC;IAEO,OAAO,CAAC,MAA6B;QAC3C,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACvG,CAAC;IAEO,OAAO,CAAC,KAA6C;QAC3D,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClG,CAAC;;AA3M+B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;kDAA0B;AAE7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wDAAwB;AACxB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;oDAAsB;AAE/B;IAAhB,KAAK,EAAE;;oDAA4B;AACnB;IAAhB,KAAK,EAAE;;oDAAgC;AAlC7B,gBAAgB;IAD5B,aAAa,CAAC,mBAAmB,CAAC;GACtB,gBAAgB,CAuO5B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport { FIGURE_FACES } from '@hatiolab/figure-model'\nimport type { FigureAuthoringAction, FigureFace } from '@hatiolab/figure-model'\n\nimport './figure-carrier.js'\nimport { occupancyFromParts } from './occupancy.js'\nimport { tagsOf, figureFigureFacts, type Placement, type FigureFigureFacts } from './figure-facts.js'\nimport { offeredMountingOf } from './mounting-part.js'\nimport type { FigureRevision } from './revision.js'\nimport { SidePanelStyles } from '@things-factory/figure-viewer/dist-client/side-panel-styles.js'\nimport { ScrollbarStyles } from '@operato/styles'\n\nconst PLACEMENTS: Placement[] = ['floor', 'ceiling', 'center', 'wall']\nconst FACES = Object.keys(FIGURE_FACES) as FigureFace[]\n\n/**\n * 속성 — the modeller's figure properties.\n *\n * The tab opens with what the figure is: its name, the face it is placed by, the room it takes up, where the\n * catalogue files it.\n *\n * Two kinds of change leave this tab, and it does neither itself:\n * - `command` carries an authoring command (rename, declare the room, the mounting face, the carrier). The page runs it\n * through the session, so it is one step of the same undo history as every other edit, and is saved with it.\n * - `catalog` carries a change to the row (category, tags). Those are not in the asset; the page writes them\n * to the saved row at once, so they need a saved figure.\n *\n * Not here yet, because has no place for them: editing the declared room by hand (declares it from the\n * parts, as graph expressions), and the detail level. Both wait on a ruling.\n */\n@customElement('figure-properties')\nexport class FigureProperties extends localize(i18next)(LitElement) {\n static styles = [ScrollbarStyles, SidePanelStyles, css`\n :host {\n display: block;\n /* It stands inside the properties tab's panel, which gives the margin; a second one indented it past the type. */\n padding: 0;\n overflow: auto;\n }\n div[row] {\n display: flex;\n gap: 6px;\n align-items: center;\n }\n div[row] > select {\n flex: 1;\n }\n div[row] > button[act] {\n flex: 1;\n width: auto;\n margin-top: 0;\n }\n div[row] > span {\n flex: 1;\n }\n `]\n\n /** The figure at the version on screen. */\n @property({ attribute: false }) revision?: FigureRevision\n /** The saved row, if any. Category and tags live on it. */\n @property({ type: String }) figureId?: string\n @property({ type: String }) figureCategory?: string\n @property({ type: Array }) figureTags?: string[]\n /** The part and face picked for the mounting face, before 「이 면으로」 is pressed. */\n @state() private pickedPart?: string\n @state() private pickedFace?: FigureFace\n\n private facts(): FigureFigureFacts | undefined {\n try {\n return this.revision ? figureFigureFacts(this.revision) : undefined\n } catch {\n /* A source the format refuses has no facts to show; the verdict tab says why. */\n return undefined\n }\n }\n\n /*\n The figure's own settings are shown while no part is picked; with one picked this is out of sight, and working out its\n facts (the figure parsed and compiled) on every edit is for nobody. Out of sight it keeps what it last drew, and it\n draws again when it comes back into view.\n */\n private lastDrawn?: unknown\n private outOfSight = false\n private watch?: ResizeObserver\n connectedCallback() {\n super.connectedCallback()\n this.watch = new ResizeObserver(() => {\n if (this.outOfSight && this.checkVisibility?.() !== false) {\n this.outOfSight = false\n this.requestUpdate()\n }\n })\n this.watch.observe(this)\n }\n disconnectedCallback() {\n this.watch?.disconnect()\n super.disconnectedCallback()\n }\n\n render() {\n if (this.hasUpdated && this.checkVisibility?.() === false) {\n this.outOfSight = true\n return this.lastDrawn ?? nothing\n }\n this.lastDrawn = this.draw()\n return this.lastDrawn\n }\n\n private draw() {\n const facts = this.facts()\n if (!facts) return nothing\n /* The figure's type is the page's (it lives on the row); it is slotted into the first section. */\n return html`<section>\n <h3>${i18next.t('figure.label.group-figure')}</h3>\n <slot name=\"type\"></slot>\n ${this.renderName(facts)} ${this.renderPlacement(facts)}\n </section>\n <section>\n <h3>${i18next.t('figure.label.group-standing')}</h3>\n ${this.renderSpace(facts)} ${this.renderMounting(facts)}\n </section>\n <figure-carrier .carrier=${this.revision?.asset.carrier}></figure-carrier>\n <section>\n <h3>${i18next.t('figure.label.group-catalog')}</h3>\n ${this.renderCatalog()}\n </section>`\n }\n\n private renderName(facts: FigureFigureFacts) {\n return html`\n <div field>\n <label>${i18next.t('figure.label.name')}</label>\n <input\n .value=${facts.name}\n placeholder=${i18next.t('figure.text.figure-display-name')}\n @change=${(event: Event) => {\n const input = event.target as HTMLInputElement\n if (!input.value.trim()) {\n /* The format refuses a blank name; put the old one back rather than send a command that fails. */\n input.value = facts.name\n return\n }\n if (input.value.trim() !== facts.name) this.command({ kind: 'rename', name: input.value })\n }}\n />\n </div>\n `\n }\n\n /**\n * The face the figure is placed by. In it is part of the room declaration, so choosing one declares the room\n * again from the parts — the only way declares it — with the new face. The hint says so.\n */\n private renderPlacement(facts: FigureFigureFacts) {\n const current = facts.placement ?? 'floor'\n return html`\n <div field>\n <label>${i18next.t('figure.label.figure-placement')}</label>\n <select\n .value=${live(current)}\n @change=${(event: Event) => {\n const select = event.target as HTMLSelectElement\n /* The figure's own setting (ADR-0097): chosen with no part too, and the room is left as it is declared. */\n this.command({ kind: 'set-placement', placement: select.value as Placement })\n /* Refused, the figure is placed as it was, and the list says so; taken, the figure drawn again says the new one. */\n select.value = current\n }}\n >\n ${PLACEMENTS.map(\n one => html`<option value=${one} ?selected=${one === current}>${i18next.t('figure.label.placement-' + one)}</option>`\n )}\n </select>\n <small>${i18next.t('figure.text.placement-is-intent')}</small>\n </div>\n `\n }\n\n private renderSpace(facts: FigureFigureFacts) {\n return html`\n <div field>\n <label>${i18next.t('figure.label.declared-space')}</label>\n <div row>\n <span>${i18next.t(facts.declared ? 'figure.text.declared-space-declared' : 'figure.text.declared-space-none')}</span>\n <button act ?disabled=${!facts.parts.length} @click=${() => this.declare(facts.placement ?? 'floor')}>\n <md-icon>fit_screen</md-icon>${i18next.t('figure.button.fit-base-to-parts')}\n </button>\n </div>\n </div>\n `\n }\n\n private renderMounting(facts: FigureFigureFacts) {\n const mounting = facts.mounting\n /* Chosen, or what is set, or where the figure meets its plane -- not the first part listed (walk 1). */\n const { part, face } = offeredMountingOf(facts, { part: this.pickedPart, face: this.pickedFace })\n return html`\n <div field>\n <label>${i18next.t('figure.label.mounting-face')}</label>\n <div row>\n <select ?disabled=${!facts.declared} @change=${(e: Event) => (this.pickedPart = (e.target as HTMLSelectElement).value)}>\n ${facts.parts.map(one => html`<option value=${one} ?selected=${one === part}>${one}</option>`)}\n </select>\n <select ?disabled=${!facts.declared} @change=${(e: Event) => (this.pickedFace = (e.target as HTMLSelectElement).value as FigureFace)}>\n ${FACES.map(one => html`<option value=${one} ?selected=${one === face}>${i18next.t('figure.label.face-' + one)}</option>`)}\n </select>\n </div>\n <div row>\n <button act ?disabled=${!facts.declared || !part} @click=${() => this.command({ kind: 'set-mounting-face', part: part!, face })}>\n <md-icon>check</md-icon>${i18next.t('figure.button.set-mounting-face')}\n </button>\n <button act ?disabled=${!mounting} @click=${() => this.command({ kind: 'clear-mounting-face' })}>\n <md-icon>close</md-icon>${i18next.t('figure.button.clear-mounting-face')}\n </button>\n </div>\n <small>\n ${facts.declared\n ? mounting\n ? `${mounting.part} · ${i18next.t('figure.label.face-' + mounting.face)}`\n : i18next.t('figure.label.mounting-face-none')\n : i18next.t('figure.text.mounting-face-needs-space')}\n </small>\n </div>\n `\n }\n\n private renderCatalog() {\n const saved = !!this.figureId\n return html`\n <div field>\n <label>${i18next.t('figure.label.category')}</label>\n <input\n .value=${this.figureCategory ?? ''}\n ?disabled=${!saved}\n placeholder=${i18next.t('figure.text.category-placeholder')}\n @change=${(e: Event) => this.catalog({ category: (e.target as HTMLInputElement).value.trim() })}\n />\n </div>\n <div field>\n <label>${i18next.t('figure.label.tags')}</label>\n <input\n .value=${(this.figureTags ?? []).join(', ')}\n ?disabled=${!saved}\n placeholder=${i18next.t('figure.text.tags-placeholder')}\n @change=${(e: Event) => this.catalog({ tags: tagsOf((e.target as HTMLInputElement).value) })}\n />\n ${saved ? nothing : html`<small>${i18next.t('figure.text.catalog-needs-a-save')}</small>`}\n </div>\n `\n }\n\n private declare(placement: Placement) {\n if (!this.revision) return\n this.command(occupancyFromParts(this.revision.asset, placement))\n }\n\n private command(action: FigureAuthoringAction) {\n this.dispatchEvent(new CustomEvent('command', { detail: { action }, bubbles: true, composed: true }))\n }\n\n private catalog(patch: { category?: string; tags?: string[] }) {\n this.dispatchEvent(new CustomEvent('catalog', { detail: patch, bubbles: true,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AAA;IACvG,CAAC;IAEO,OAAO,CAAC,KAA6C;QAC3D,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClG,CAAC;;AA1M+B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;kDAA0B;AAE7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wDAAwB;AACxB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;oDAAsB;AAE/B;IAAhB,KAAK,EAAE;;oDAA4B;AACnB;IAAhB,KAAK,EAAE;;oDAAgC;AAlC7B,gBAAgB;IAD5B,aAAa,CAAC,mBAAmB,CAAC;GACtB,gBAAgB,CAsO5B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport { FIGURE_FACES } from '@hatiolab/figure-model'\nimport type { FigureAuthoringAction, FigureFace } from '@hatiolab/figure-model'\n\nimport { occupancyFromParts } from './occupancy.js'\nimport { tagsOf, figureFigureFacts, type Placement, type FigureFigureFacts } from './figure-facts.js'\nimport { offeredMountingOf } from './mounting-part.js'\nimport type { FigureRevision } from './revision.js'\nimport { SidePanelStyles } from '@things-factory/figure-viewer/dist-client/side-panel-styles.js'\nimport { ScrollbarStyles } from '@operato/styles'\n\nconst PLACEMENTS: Placement[] = ['floor', 'ceiling', 'center', 'wall']\nconst FACES = Object.keys(FIGURE_FACES) as FigureFace[]\n\n/**\n * 속성 — the modeller's figure properties.\n *\n * The tab opens with what the figure is: its name, the face it is placed by, the room it takes up, where the\n * catalogue files it.\n *\n * Two kinds of change leave this tab, and it does neither itself:\n * - `command` carries an authoring command (rename, declare the room, the mounting face). The page runs it\n * through the session, so it is one step of the same undo history as every other edit, and is saved with it.\n * - `catalog` carries a change to the row (category, tags). Those are not in the asset; the page writes them\n * to the saved row at once, so they need a saved figure.\n *\n * Not here yet, because has no place for them: editing the declared room by hand (declares it from the\n * parts, as graph expressions), and the detail level. Both wait on a ruling.\n */\n@customElement('figure-properties')\nexport class FigureProperties extends localize(i18next)(LitElement) {\n static styles = [ScrollbarStyles, SidePanelStyles, css`\n :host {\n display: block;\n /* It stands inside the properties tab's panel, which gives the margin; a second one indented it past the type. */\n padding: 0;\n overflow: auto;\n }\n div[row] {\n display: flex;\n gap: 6px;\n align-items: center;\n }\n div[row] > select {\n flex: 1;\n }\n div[row] > button[act] {\n flex: 1;\n width: auto;\n margin-top: 0;\n }\n div[row] > span {\n flex: 1;\n }\n `]\n\n /** The figure at the version on screen. */\n @property({ attribute: false }) revision?: FigureRevision\n /** The saved row, if any. Category and tags live on it. */\n @property({ type: String }) figureId?: string\n @property({ type: String }) figureCategory?: string\n @property({ type: Array }) figureTags?: string[]\n /** The part and face picked for the mounting face, before 「이 면으로」 is pressed. */\n @state() private pickedPart?: string\n @state() private pickedFace?: FigureFace\n\n private facts(): FigureFigureFacts | undefined {\n try {\n return this.revision ? figureFigureFacts(this.revision) : undefined\n } catch {\n /* A source the format refuses has no facts to show; the verdict tab says why. */\n return undefined\n }\n }\n\n /*\n The figure's own settings are shown while no part is picked; with one picked this is out of sight, and working out its\n facts (the figure parsed and compiled) on every edit is for nobody. Out of sight it keeps what it last drew, and it\n draws again when it comes back into view.\n */\n private lastDrawn?: unknown\n private outOfSight = false\n private watch?: ResizeObserver\n connectedCallback() {\n super.connectedCallback()\n this.watch = new ResizeObserver(() => {\n if (this.outOfSight && this.checkVisibility?.() !== false) {\n this.outOfSight = false\n this.requestUpdate()\n }\n })\n this.watch.observe(this)\n }\n disconnectedCallback() {\n this.watch?.disconnect()\n super.disconnectedCallback()\n }\n\n render() {\n if (this.hasUpdated && this.checkVisibility?.() === false) {\n this.outOfSight = true\n return this.lastDrawn ?? nothing\n }\n this.lastDrawn = this.draw()\n return this.lastDrawn\n }\n\n private draw() {\n const facts = this.facts()\n if (!facts) return nothing\n /* The figure's type is the page's (it lives on the row); it is slotted into the first section. */\n return html`<section>\n <h3>${i18next.t('figure.label.group-figure')}</h3>\n <slot name=\"type\"></slot>\n ${this.renderName(facts)} ${this.renderPlacement(facts)}\n </section>\n <section>\n <h3>${i18next.t('figure.label.group-standing')}</h3>\n ${this.renderSpace(facts)} ${this.renderMounting(facts)}\n </section>\n <section>\n <h3>${i18next.t('figure.label.group-catalog')}</h3>\n ${this.renderCatalog()}\n </section>`\n }\n\n private renderName(facts: FigureFigureFacts) {\n return html`\n <div field>\n <label>${i18next.t('figure.label.name')}</label>\n <input\n .value=${facts.name}\n placeholder=${i18next.t('figure.text.figure-display-name')}\n @change=${(event: Event) => {\n const input = event.target as HTMLInputElement\n if (!input.value.trim()) {\n /* The format refuses a blank name; put the old one back rather than send a command that fails. */\n input.value = facts.name\n return\n }\n if (input.value.trim() !== facts.name) this.command({ kind: 'rename', name: input.value })\n }}\n />\n </div>\n `\n }\n\n /**\n * The face the figure is placed by. In it is part of the room declaration, so choosing one declares the room\n * again from the parts — the only way declares it — with the new face. The hint says so.\n */\n private renderPlacement(facts: FigureFigureFacts) {\n const current = facts.placement ?? 'floor'\n return html`\n <div field>\n <label>${i18next.t('figure.label.figure-placement')}</label>\n <select\n .value=${live(current)}\n @change=${(event: Event) => {\n const select = event.target as HTMLSelectElement\n /* The figure's own setting (ADR-0097): chosen with no part too, and the room is left as it is declared. */\n this.command({ kind: 'set-placement', placement: select.value as Placement })\n /* Refused, the figure is placed as it was, and the list says so; taken, the figure drawn again says the new one. */\n select.value = current\n }}\n >\n ${PLACEMENTS.map(\n one => html`<option value=${one} ?selected=${one === current}>${i18next.t('figure.label.placement-' + one)}</option>`\n )}\n </select>\n <small>${i18next.t('figure.text.placement-is-intent')}</small>\n </div>\n `\n }\n\n private renderSpace(facts: FigureFigureFacts) {\n return html`\n <div field>\n <label>${i18next.t('figure.label.declared-space')}</label>\n <div row>\n <span>${i18next.t(facts.declared ? 'figure.text.declared-space-declared' : 'figure.text.declared-space-none')}</span>\n <button act ?disabled=${!facts.parts.length} @click=${() => this.declare(facts.placement ?? 'floor')}>\n <md-icon>fit_screen</md-icon>${i18next.t('figure.button.fit-base-to-parts')}\n </button>\n </div>\n </div>\n `\n }\n\n private renderMounting(facts: FigureFigureFacts) {\n const mounting = facts.mounting\n /* Chosen, or what is set, or where the figure meets its plane -- not the first part listed (walk 1). */\n const { part, face } = offeredMountingOf(facts, { part: this.pickedPart, face: this.pickedFace })\n return html`\n <div field>\n <label>${i18next.t('figure.label.mounting-face')}</label>\n <div row>\n <select ?disabled=${!facts.declared} @change=${(e: Event) => (this.pickedPart = (e.target as HTMLSelectElement).value)}>\n ${facts.parts.map(one => html`<option value=${one} ?selected=${one === part}>${one}</option>`)}\n </select>\n <select ?disabled=${!facts.declared} @change=${(e: Event) => (this.pickedFace = (e.target as HTMLSelectElement).value as FigureFace)}>\n ${FACES.map(one => html`<option value=${one} ?selected=${one === face}>${i18next.t('figure.label.face-' + one)}</option>`)}\n </select>\n </div>\n <div row>\n <button act ?disabled=${!facts.declared || !part} @click=${() => this.command({ kind: 'set-mounting-face', part: part!, face })}>\n <md-icon>check</md-icon>${i18next.t('figure.button.set-mounting-face')}\n </button>\n <button act ?disabled=${!mounting} @click=${() => this.command({ kind: 'clear-mounting-face' })}>\n <md-icon>close</md-icon>${i18next.t('figure.button.clear-mounting-face')}\n </button>\n </div>\n <small>\n ${facts.declared\n ? mounting\n ? `${mounting.part} · ${i18next.t('figure.label.face-' + mounting.face)}`\n : i18next.t('figure.label.mounting-face-none')\n : i18next.t('figure.text.mounting-face-needs-space')}\n </small>\n </div>\n `\n }\n\n private renderCatalog() {\n const saved = !!this.figureId\n return html`\n <div field>\n <label>${i18next.t('figure.label.category')}</label>\n <input\n .value=${this.figureCategory ?? ''}\n ?disabled=${!saved}\n placeholder=${i18next.t('figure.text.category-placeholder')}\n @change=${(e: Event) => this.catalog({ category: (e.target as HTMLInputElement).value.trim() })}\n />\n </div>\n <div field>\n <label>${i18next.t('figure.label.tags')}</label>\n <input\n .value=${(this.figureTags ?? []).join(', ')}\n ?disabled=${!saved}\n placeholder=${i18next.t('figure.text.tags-placeholder')}\n @change=${(e: Event) => this.catalog({ tags: tagsOf((e.target as HTMLInputElement).value) })}\n />\n ${saved ? nothing : html`<small>${i18next.t('figure.text.catalog-needs-a-save')}</small>`}\n </div>\n `\n }\n\n private declare(placement: Placement) {\n if (!this.revision) return\n this.command(occupancyFromParts(this.revision.asset, placement))\n }\n\n private command(action: FigureAuthoringAction) {\n this.dispatchEvent(new CustomEvent('command', { detail: { action }, bubbles: true, composed: true }))\n }\n\n private catalog(patch: { category?: string; tags?: string[] }) {\n this.dispatchEvent(new CustomEvent('catalog', { detail: patch, bubbles: true, composed: true }))\n }\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  import { type FigureRevision } from './revision.js';
2
2
  import { type FigureInputChange, type FigurePrimitiveCreation, type FigurePartEdit, type FigureAuthoringAction, type FigureProposalStep, type FigureClipConsent } from '@hatiolab/figure-model';
3
- /** Consent to let clips go, and the figure and version it was given on. */
4
3
  export interface FigureClipConsentFor extends FigureClipConsent {
5
4
  context: string;
6
5
  revision: number;
@@ -34,6 +33,7 @@ export interface FigureProductStore {
34
33
  export declare function createFigureProductSession(store: FigureProductStore): {
35
34
  read: () => {
36
35
  id: string | undefined;
36
+ creationId: string | undefined;
37
37
  loading: boolean;
38
38
  saving: boolean;
39
39
  error: string | undefined;
@@ -50,6 +50,7 @@ export declare function createFigureProductSession(store: FigureProductStore): {
50
50
  asset?: undefined;
51
51
  } | {
52
52
  id: string | undefined;
53
+ creationId: string | undefined;
53
54
  loading: boolean;
54
55
  saving: boolean;
55
56
  error: string | undefined;
@@ -78,6 +79,7 @@ export declare function createFigureProductSession(store: FigureProductStore): {
78
79
  discard?: boolean | undefined;
79
80
  }): {
80
81
  id: string | undefined;
82
+ creationId: string | undefined;
81
83
  loading: boolean;
82
84
  saving: boolean;
83
85
  error: string | undefined;
@@ -94,6 +96,7 @@ export declare function createFigureProductSession(store: FigureProductStore): {
94
96
  asset?: undefined;
95
97
  } | {
96
98
  id: string | undefined;
99
+ creationId: string | undefined;
97
100
  loading: boolean;
98
101
  saving: boolean;
99
102
  error: string | undefined;
@@ -115,6 +118,7 @@ export declare function createFigureProductSession(store: FigureProductStore): {
115
118
  discard?: boolean | undefined;
116
119
  }): Promise<{
117
120
  id: string | undefined;
121
+ creationId: string | undefined;
118
122
  loading: boolean;
119
123
  saving: boolean;
120
124
  error: string | undefined;
@@ -131,6 +135,7 @@ export declare function createFigureProductSession(store: FigureProductStore): {
131
135
  asset?: undefined;
132
136
  } | {
133
137
  id: string | undefined;
138
+ creationId: string | undefined;
134
139
  loading: boolean;
135
140
  saving: boolean;
136
141
  error: string | undefined;
@@ -152,6 +157,7 @@ export declare function createFigureProductSession(store: FigureProductStore): {
152
157
  discard?: boolean | undefined;
153
158
  }): {
154
159
  id: string | undefined;
160
+ creationId: string | undefined;
155
161
  loading: boolean;
156
162
  saving: boolean;
157
163
  error: string | undefined;
@@ -168,6 +174,7 @@ export declare function createFigureProductSession(store: FigureProductStore): {
168
174
  asset?: undefined;
169
175
  } | {
170
176
  id: string | undefined;
177
+ creationId: string | undefined;
171
178
  loading: boolean;
172
179
  saving: boolean;
173
180
  error: string | undefined;
@@ -244,9 +251,10 @@ export declare function createFigureProductSession(store: FigureProductStore): {
244
251
  palette: Record<string, string>;
245
252
  };
246
253
  /**
247
- * A new figure made from an AI proposal is created under the proposal's key (ADR-0097 §5.6 item 5): the same
248
- * proposal taken twice meets the first figure on the server, never a second one. Only on a new figure not yet
249
- * touched -- one being made is the person's, and keeps its own.
254
+ * A new figure opened for an AI proposal from another screen is created under the proposal's key (ADR-0097 §5.6
255
+ * item 5). Only before the modeller names the figure to the AI dock: once a conversation is anchored on the creation
256
+ * id it stays (ADR-0061 decision 3), and the save's record of the proposal keeps one proposal one figure. Only on a
257
+ * new figure not yet touched -- one being made is the person's, and keeps its own.
250
258
  */
251
259
  createUnder(key: string): void;
252
260
  /** The AI proposals whose steps are in the model now, each once. */
@@ -451,6 +459,7 @@ export declare function createFigureProductSession(store: FigureProductStore): {
451
459
  type?: string;
452
460
  }): Promise<{
453
461
  id: string | undefined;
462
+ creationId: string | undefined;
454
463
  loading: boolean;
455
464
  saving: boolean;
456
465
  error: string | undefined;
@@ -467,6 +476,7 @@ export declare function createFigureProductSession(store: FigureProductStore): {
467
476
  asset?: undefined;
468
477
  } | {
469
478
  id: string | undefined;
479
+ creationId: string | undefined;
470
480
  loading: boolean;
471
481
  saving: boolean;
472
482
  error: string | undefined;
@@ -1,6 +1,14 @@
1
1
  import { thumbnailHashOf } from './thumbnail-hash.js';
2
2
  import { revisionFromView } from './revision.js';
3
3
  import { createFigureAsset, createFigureEditorWorkspace, serializeFigureAsset, parseFigureAsset } from '@hatiolab/figure-model';
4
+ /** Consent to let clips go, and the figure and version it was given on. */
5
+ /**
6
+ * A request the session refuses, with its code: a screen says it from the code (`sessionRefusalOf`), never from the
7
+ * message, which stays for logs (ADR-0054; figure audit 2026-10-16 N6 -- an AI card put the message in its note).
8
+ */
9
+ function refusal(code, message) {
10
+ return Object.assign(Error(message), { code });
11
+ }
4
12
  /** Product lifecycle boundary. A late response can never change another editor's asset or ID. */
5
13
  export function createFigureProductSession(store) {
6
14
  const workspace = createFigureEditorWorkspace();
@@ -29,8 +37,12 @@ export function createFigureProductSession(store) {
29
37
  return result;
30
38
  }
31
39
  const inEffect = () => [...new Set(done.filter((tag) => !!tag))];
40
+ /*
41
+ The creation id is read with the rest: a figure not saved yet is named by it (ADR-0061 decision 3) -- its AI
42
+ conversation is anchored on it, and its first save inserts the row under it, so the name holds across that save.
43
+ */
32
44
  function read() {
33
- return { ...workspace.read(), id, loading, saving, error };
45
+ return { ...workspace.read(), id, creationId, loading, saving, error };
34
46
  }
35
47
  /*
36
48
  The version on screen, one object for as long as it is the version: the workspace hands out one asset per version
@@ -66,14 +78,19 @@ export function createFigureProductSession(store) {
66
78
  }
67
79
  return { dropClips: given.dropClips };
68
80
  };
69
- function writable() {
81
+ /* A model open to read: the draft is read during a save too -- the dock reads it when the person sends (audit N5). */
82
+ function readable() {
70
83
  const view = workspace.read();
71
84
  if (loading || error || !view.context || view.revision === null)
72
- throw Error('먼저 모델을 정상적으로 열어 주세요.');
85
+ throw refusal('SESSION_NOT_OPEN', '먼저 모델을 정상적으로 열어 주세요.');
86
+ return { context: view.context, expectedRevision: view.revision, origin: 'ui' };
87
+ }
88
+ function writable() {
89
+ const open = readable();
73
90
  // Serializing writes also makes create retries safe: no second create while the first is pending.
74
91
  if (saving)
75
- throw Error('저장이 끝난 뒤 편집해 주세요.');
76
- return { context: view.context, expectedRevision: view.revision, origin: 'ui' };
92
+ throw refusal('SESSION_SAVING', '저장이 끝난 뒤 편집해 주세요.');
93
+ return open;
77
94
  }
78
95
  function clear() {
79
96
  workspace.close({ discardDesignChanges: true });
@@ -145,7 +162,7 @@ export function createFigureProductSession(store) {
145
162
  const control = writable();
146
163
  // AI must supply the context AND revision captured when it started. Never substitute current values.
147
164
  if (origin === 'ai' && (context === undefined || expectedRevision === undefined))
148
- throw Error('AI 편집에는 요청 당시의 모델 문맥과 리비전이 필요합니다.');
165
+ throw refusal('SESSION_VERSION_MISSING', 'AI 편집에는 요청 당시의 모델 문맥과 리비전이 필요합니다.');
149
166
  return tracked('do', () => workspace.apply({
150
167
  ...control,
151
168
  origin,
@@ -164,15 +181,16 @@ export function createFigureProductSession(store) {
164
181
  return tracked('do', () => workspace.applyProposal({ origin: 'ai', context, expectedRevision, steps }), key);
165
182
  },
166
183
  /**
167
- * A new figure made from an AI proposal is created under the proposal's key (ADR-0097 §5.6 item 5): the same
168
- * proposal taken twice meets the first figure on the server, never a second one. Only on a new figure not yet
169
- * touched -- one being made is the person's, and keeps its own.
184
+ * A new figure opened for an AI proposal from another screen is created under the proposal's key (ADR-0097 §5.6
185
+ * item 5). Only before the modeller names the figure to the AI dock: once a conversation is anchored on the creation
186
+ * id it stays (ADR-0061 decision 3), and the save's record of the proposal keeps one proposal one figure. Only on a
187
+ * new figure not yet touched -- one being made is the person's, and keeps its own.
170
188
  */
171
189
  createUnder(key) {
172
190
  if (id || workspace.read().dirty)
173
- throw Error('손대지 않은 새 모델에만 쓸 수 있습니다.');
191
+ throw refusal('SESSION_NEW_FIGURE_TOUCHED', '손대지 않은 새 모델에만 쓸 수 있습니다.');
174
192
  if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(key))
175
- throw Error('제안 식별자가 올바르지 않습니다.');
193
+ throw refusal('SESSION_PROPOSAL_KEY', '제안 식별자가 올바르지 않습니다.');
176
194
  creationId = key;
177
195
  },
178
196
  /** The AI proposals whose steps are in the model now, each once. */
@@ -195,7 +213,7 @@ export function createFigureProductSession(store) {
195
213
  previewCommand(action) {
196
214
  const view = workspace.read();
197
215
  if (loading || error || !view.context || view.revision === null)
198
- throw Error('먼저 모델을 정상적으로 열어 주세요.');
216
+ throw refusal('SESSION_NOT_OPEN', '먼저 모델을 정상적으로 열어 주세요.');
199
217
  return workspace.previewCommand({ context: view.context, action });
200
218
  },
201
219
  /** One authoring command — what a person means, not a graph edit — as one step of the same history. */
@@ -223,7 +241,7 @@ export function createFigureProductSession(store) {
223
241
  return tracked('redo', () => workspace.redo(writable()));
224
242
  },
225
243
  source() {
226
- const { context } = writable();
244
+ const { context } = readable();
227
245
  return workspace.export({ context }).text;
228
246
  },
229
247
  /**