@things-factory/board-ui 10.1.58 → 10.1.80
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.
|
@@ -54,7 +54,19 @@ export declare class BoardModellerPage extends PageView {
|
|
|
54
54
|
private _componentSchemasCache?;
|
|
55
55
|
private get componentSchemas();
|
|
56
56
|
private board;
|
|
57
|
+
/** When the board was last saved, as the server said (ADR-0098) - the next save must find it unchanged. */
|
|
58
|
+
private savedAt;
|
|
59
|
+
/** A draft was put back and not saved yet; the scene's own count of unsaved steps starts from it. */
|
|
60
|
+
private restoredDraft;
|
|
61
|
+
/** The save a restored draft began from - the next save goes out against it, not the newer one. */
|
|
62
|
+
private draftBase;
|
|
63
|
+
private drafts;
|
|
57
64
|
private _loadTracker?;
|
|
65
|
+
/** Something is not saved: an edit since the last save, or a draft put back and not saved yet. */
|
|
66
|
+
private unsaved;
|
|
67
|
+
private _draftScene;
|
|
68
|
+
private _onEdit;
|
|
69
|
+
private _watchScene;
|
|
58
70
|
private _fontCtrl;
|
|
59
71
|
modeller?: BoardModeller;
|
|
60
72
|
get context(): {
|
|
@@ -171,7 +183,8 @@ export declare class BoardModellerPage extends PageView {
|
|
|
171
183
|
private provideAssistantBoard;
|
|
172
184
|
pageUpdated(changes: any, lifecycle: any): void;
|
|
173
185
|
render(): import("lit-html").TemplateResult<1>;
|
|
174
|
-
|
|
186
|
+
/** Saves the board; true when the server took it. A failure is told to the person and answered false. */
|
|
187
|
+
updateBoard(): Promise<boolean>;
|
|
175
188
|
saveBoard(): Promise<void>;
|
|
176
189
|
/**
|
|
177
190
|
* C3: 마지막 동기 모델 → 현재 모델 diff 를 recordDirectPatch 로 기록(=같은 board 구독자 방송).
|
|
@@ -11,8 +11,9 @@ import { customElement, property, query, state } from 'lit/decorators.js';
|
|
|
11
11
|
import { BoardModeller } from '@operato/board/ox-board-modeller.js';
|
|
12
12
|
import { LoadTracker, SceneSearchEngine } from '@hatiolab/things-scene';
|
|
13
13
|
import { OxPropertyEditor } from '@operato/property-editor';
|
|
14
|
-
import { PageView, FontController } from '@operato/shell';
|
|
15
|
-
import {
|
|
14
|
+
import { PageView, FontController, UnsavedDraftController } from '@operato/shell';
|
|
15
|
+
import { getPathInfo } from '@operato/utils';
|
|
16
|
+
import { auth, hasPrivilege } from '@things-factory/auth-base/dist-client/index.js';
|
|
16
17
|
import { applyScenePatchVerbose, dispatchSceneAction, dispatchSceneEditOp, findSceneComponent } from '@operato/scene-ops';
|
|
17
18
|
import { client, gqlContext, subscribe } from '@operato/graphql';
|
|
18
19
|
import { clearAssistantSurface, provideAssistantSurface } from '@things-factory/ai-assistant/dist-client/index.js';
|
|
@@ -91,6 +92,36 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
91
92
|
// C3 직접편집 캡처 — 마지막으로 동기화된(서버/타참여자가 아는) 모델. diff 의 baseline.
|
|
92
93
|
this._syncedModel = null;
|
|
93
94
|
this.board = null;
|
|
95
|
+
/** When the board was last saved, as the server said (ADR-0098) - the next save must find it unchanged. */
|
|
96
|
+
this.savedAt = null;
|
|
97
|
+
/** A draft was put back and not saved yet; the scene's own count of unsaved steps starts from it. */
|
|
98
|
+
this.restoredDraft = false;
|
|
99
|
+
/** The save a restored draft began from - the next save goes out against it, not the newer one. */
|
|
100
|
+
this.draftBase = null;
|
|
101
|
+
/*
|
|
102
|
+
* The edit kept as a draft in this browser, offered back when the board opens (ADR-0098). No leave
|
|
103
|
+
* question at reload - only where drafts cannot be kept does the controller bring the browser's back.
|
|
104
|
+
*/
|
|
105
|
+
this.drafts = new UnsavedDraftController(this, {
|
|
106
|
+
address: () => {
|
|
107
|
+
const user = auth.credential?.id;
|
|
108
|
+
return this.boardId && user
|
|
109
|
+
? { user, domain: getPathInfo(location.pathname).domain || '', screen: 'board-modeller', target: this.boardId }
|
|
110
|
+
: undefined;
|
|
111
|
+
},
|
|
112
|
+
snapshot: () => this.unsaved() && this.scene?.model
|
|
113
|
+
? { value: JSON.stringify(this.scene.model), base: this.draftBase ?? this.savedAt }
|
|
114
|
+
: undefined,
|
|
115
|
+
savedRevision: () => this.savedAt,
|
|
116
|
+
restore: (value, base) => {
|
|
117
|
+
this.model = JSON.parse(value);
|
|
118
|
+
this.restoredDraft = true;
|
|
119
|
+
this.draftBase = base == null ? null : String(base);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
/* The scene's history says when the edit changed - the draft follows it. */
|
|
123
|
+
this._draftScene = null;
|
|
124
|
+
this._onEdit = () => this.drafts.changed();
|
|
94
125
|
this._fontCtrl = new FontController(this);
|
|
95
126
|
/**
|
|
96
127
|
* AI 채팅 mention popup (`#`) 검색 위임 — things-scene SceneSearchEngine 으로 wrap.
|
|
@@ -421,6 +452,20 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
421
452
|
}
|
|
422
453
|
return this._componentSchemasCache;
|
|
423
454
|
}
|
|
455
|
+
/** Something is not saved: an edit since the last save, or a draft put back and not saved yet. */
|
|
456
|
+
unsaved() {
|
|
457
|
+
return this.restoredDraft || !!this.modeller?.hasUnpreservedChanges();
|
|
458
|
+
}
|
|
459
|
+
_watchScene(scene) {
|
|
460
|
+
if (this._draftScene === scene)
|
|
461
|
+
return;
|
|
462
|
+
const events = ['execute', 'undo', 'redo'];
|
|
463
|
+
for (const event of events)
|
|
464
|
+
this._draftScene?.commander?.off?.(event, this._onEdit, this);
|
|
465
|
+
this._draftScene = scene;
|
|
466
|
+
for (const event of events)
|
|
467
|
+
scene?.commander?.on?.(event, this._onEdit, this);
|
|
468
|
+
}
|
|
424
469
|
get context() {
|
|
425
470
|
return {
|
|
426
471
|
title: this.board ? this.boardName : this.preparing ? 'Fetching board...' : '',
|
|
@@ -460,6 +505,7 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
460
505
|
id
|
|
461
506
|
name
|
|
462
507
|
model
|
|
508
|
+
updatedAt
|
|
463
509
|
}
|
|
464
510
|
}
|
|
465
511
|
`,
|
|
@@ -480,6 +526,11 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
480
526
|
this.model = {
|
|
481
527
|
...this.board.model
|
|
482
528
|
};
|
|
529
|
+
this.savedAt = board.updatedAt ?? null;
|
|
530
|
+
this.restoredDraft = false;
|
|
531
|
+
this.draftBase = null;
|
|
532
|
+
/* An edit kept from before a reload or a closed tab is offered back once the saved board is here. */
|
|
533
|
+
this.updateComplete.then(() => this.drafts.offer());
|
|
483
534
|
/* Another board is another conversation - the dock reopens for the new surface. */
|
|
484
535
|
this.chatSessionId = undefined;
|
|
485
536
|
this.provideAssistantBoard();
|
|
@@ -787,6 +838,7 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
787
838
|
.scene=${this.scene}
|
|
788
839
|
@scene-changed=${e => {
|
|
789
840
|
this.scene = e.detail.value;
|
|
841
|
+
this._watchScene(this.scene);
|
|
790
842
|
}}
|
|
791
843
|
.selected=${this.selected}
|
|
792
844
|
@selected-changed=${e => {
|
|
@@ -806,37 +858,58 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
806
858
|
</div>
|
|
807
859
|
`;
|
|
808
860
|
}
|
|
861
|
+
/** Saves the board; true when the server took it. A failure is told to the person and answered false. */
|
|
809
862
|
async updateBoard() {
|
|
810
863
|
try {
|
|
811
864
|
this.preparing = true;
|
|
812
865
|
const { id, name, description, groupId } = this.board;
|
|
813
866
|
const model = JSON.stringify(this.scene.model);
|
|
814
|
-
|
|
867
|
+
/* Saved only over the save this edit began from (ADR-0098); someone else's newer save is refused. */
|
|
868
|
+
const expectedUpdatedAt = this.draftBase ?? this.savedAt;
|
|
869
|
+
const response = await client.mutate({
|
|
815
870
|
mutation: gql `
|
|
816
871
|
mutation UpdateBoard($id: String!, $patch: BoardPatch!) {
|
|
817
872
|
updateBoard(id: $id, patch: $patch) {
|
|
818
873
|
id
|
|
874
|
+
updatedAt
|
|
819
875
|
}
|
|
820
876
|
}
|
|
821
877
|
`,
|
|
822
878
|
variables: {
|
|
823
879
|
id,
|
|
824
|
-
patch: { name, description, model, groupId }
|
|
880
|
+
patch: { name, description, model, groupId, ...(expectedUpdatedAt ? { expectedUpdatedAt } : {}) }
|
|
825
881
|
},
|
|
826
882
|
context: gqlContext()
|
|
827
883
|
});
|
|
884
|
+
/*
|
|
885
|
+
* A refusal (saved elsewhere since) arrives as an error, already told to the person by the client's
|
|
886
|
+
* error link - not told again here. Not saved: the draft stays, nothing below runs.
|
|
887
|
+
*/
|
|
888
|
+
if (response.errors?.length)
|
|
889
|
+
return false;
|
|
890
|
+
this.savedAt = response.data?.updateBoard?.updatedAt ?? this.savedAt;
|
|
891
|
+
this.restoredDraft = false;
|
|
892
|
+
this.draftBase = null;
|
|
893
|
+
await this.drafts.settled();
|
|
828
894
|
notify('info', i18next.t('text.saved'));
|
|
895
|
+
return true;
|
|
829
896
|
}
|
|
830
897
|
catch (ex) {
|
|
831
898
|
notifyError(ex);
|
|
899
|
+
return false;
|
|
832
900
|
}
|
|
833
901
|
finally {
|
|
834
902
|
this.preparing = false;
|
|
903
|
+
this.updateContext();
|
|
835
904
|
}
|
|
836
|
-
this.updateContext();
|
|
837
905
|
}
|
|
838
906
|
async saveBoard() {
|
|
839
|
-
|
|
907
|
+
/*
|
|
908
|
+
* Marked saved only when it was. preserve() ran after a failed save too, so the modeller counted the
|
|
909
|
+
* edit as kept and leaving the page no longer asked - the edit was lost without a word.
|
|
910
|
+
*/
|
|
911
|
+
if (!(await this.updateBoard()))
|
|
912
|
+
return;
|
|
840
913
|
this.modeller?.preserve();
|
|
841
914
|
// C3: 저장 후(이산적·사용자 의도) 직접편집을 ops 로 캡처해 방송. best-effort —
|
|
842
915
|
// 실패해도 저장 자체엔 영향 없음(이미 완료). (라이브 per-edit 동기화는 C3c 후보.)
|
|
@@ -882,13 +955,17 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
882
955
|
}
|
|
883
956
|
}
|
|
884
957
|
async canDeactivate() {
|
|
885
|
-
if (this.
|
|
886
|
-
|
|
958
|
+
if (this.unsaved()) {
|
|
959
|
+
const leave = await OxPrompt.open({
|
|
887
960
|
title: i18next.t('text.are_you_sure'),
|
|
888
961
|
text: i18next.t('prompt.sure to navigate away?'),
|
|
889
962
|
confirmButton: { text: i18next.t('button.confirm') },
|
|
890
963
|
cancelButton: { text: i18next.t('button.cancel') }
|
|
891
964
|
});
|
|
965
|
+
/* Leaving without saving, chosen: nothing to keep (ADR-0098 decision 3). */
|
|
966
|
+
if (leave)
|
|
967
|
+
await this.drafts.settled();
|
|
968
|
+
return leave;
|
|
892
969
|
}
|
|
893
970
|
return true;
|
|
894
971
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board-modeller-page.js","sourceRoot":"","sources":["../../client/pages/board-modeller-page.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,yBAAyB,CAAA;AAChC,OAAO,qCAAqC,CAAA;AAC5C,OAAO,eAAe,CAAA;AACtB,OAAO,0BAA0B,CAAA;AAEjC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,sBAAsB,EAAuB,MAAM,8CAA8C,CAAA;AAC1G,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAA;AAC7E,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,kB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AAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE;aACnD,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;;AAl0B2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAwB;AACvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAwB;AAElC;IAAhB,KAAK,EAAE;;sDAAwD;AACpC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAkB;AAClB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;mDAAmB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CAAkB;AAChB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;uDAA+B;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAkB;AAClB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;6DAAkD;AACjD;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;yDAAoB;AACjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;oDAAoB;AAuJpB;IAA3B,KAAK,CAAC,mBAAmB,CAAC;8BAAY,aAAa;mDAAA;AA/NzC,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;;GACxB,iBAAiB,CA+3B7B","sourcesContent":["import '@material/web/icon/icon.js'\nimport 'things-scene-components'\nimport '@operato/board/ox-board-modeller.js'\nimport '@operato/oops'\nimport '@things-factory/board-ai'\n\nimport gql from 'graphql-tag'\nimport { getModellerToolbarMode, ModellerToolbarMode } from '../setting-let/board-modeller-setting-let.js'\nimport { css, html, nothing } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { BoardModeller } from '@operato/board/ox-board-modeller.js'\nimport { LoadTracker, SceneSearchEngine } from '@hatiolab/things-scene'\nimport { OxPropertyEditor } from '@operato/property-editor'\nimport { PageView, FontController } from '@operato/shell'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client/index.js'\nimport {\n applyScenePatchVerbose,\n dispatchSceneAction,\n dispatchSceneEditOp,\n findSceneComponent,\n type SceneEditOp,\n type SceneEditPatch\n} from '@operato/scene-ops'\nimport { client, gqlContext, subscribe } from '@operato/graphql'\nimport {\n clearAssistantSurface,\n provideAssistantSurface\n} from '@things-factory/ai-assistant/dist-client/index.js'\nimport { i18next } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\nimport { provider } from '@operato/board/board-provider.js'\nimport '../board-placement-tray.js' // 배치 팔레트 오버레이(호스트-등록 provider 있을 때만 표시)\nimport { boardPlacementProvider } from '@operato/board/board-placement-palette.js'\nimport components from 'things-scene-components-with-tools'\nimport { notify, notifyError } from '../utils/notify-helper.js'\nimport { PatchApplyGate } from '../utils/patch-apply-gate.js'\nimport { diffBoardModel } from '../utils/board-model-diff.js'\n\nexport { findSceneComponent }\n\n/** 서버 PatchEntry.reverted=true 플래그 영속용 mutation. */\nconst REVERT_PATCH_MUTATION = gql`\n mutation RevertPatch($patchId: String!) {\n revertPatch(patchId: $patchId)\n }\n`\n\n/**\n * default 위에 override 를 깊게 merge.\n * - override 의 키 값이 undefined 가 아닌 경우 우선 적용\n * - override 의 nested object 는 default 와 deep merge\n * - array / primitive 는 override 가 그대로 우선\n */\nfunction mergeDefaultsDeep(defaults: any, override: any): any {\n if (defaults === null || defaults === undefined) return override\n if (override === null || override === undefined) return defaults\n if (typeof defaults !== 'object' || typeof override !== 'object') return override\n if (Array.isArray(defaults) || Array.isArray(override)) return override\n\n const out: any = { ...defaults }\n for (const key of Object.keys(override)) {\n const dv = (defaults as any)[key]\n const ov = (override as any)[key]\n if (\n dv !== null &&\n ov !== null &&\n typeof dv === 'object' &&\n typeof ov === 'object' &&\n !Array.isArray(dv) &&\n !Array.isArray(ov)\n ) {\n out[key] = mergeDefaultsDeep(dv, ov)\n } else if (ov !== undefined) {\n out[key] = ov\n }\n }\n return out\n}\n\n@customElement('board-modeller-page')\nexport class BoardModellerPage extends PageView {\n constructor() {\n super()\n\n components.forEach(({ templates = [], groups = [] }) => {\n groups.forEach(group => BoardModeller.registerGroup(group))\n BoardModeller.registerTemplate(templates)\n })\n\n /* 컴포넌트에서 정의된 에디터들을 MODELLER_EDITORS에 등록 */\n const addedEditors = {}\n for (const component in components) {\n let { editors } = components[component]\n\n editors &&\n editors.forEach(editor => {\n let { type, element } = editor\n\n addedEditors[type] = element\n })\n }\n\n OxPropertyEditor.register(addedEditors)\n }\n\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: row;\n\n overflow: hidden;\n position: relative;\n /* The modeller's own layers (the save button is z-index 1000) stay inside the page - the AI dock opens over it. */\n isolation: isolate;\n }\n\n .modeller-area {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n position: relative;\n }\n\n ox-board-modeller {\n flex: 1;\n }\n\n ox-oops-note {\n display: block;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n\n `\n ]\n\n @property({ type: String }) boardId?: string | null\n @property({ type: String }) boardName?: string = ''\n /* Read from the user's board-modeller setting each time the page is shown. */\n @state() private toolbarMode: ModellerToolbarMode = 'contextual'\n @property({ type: Object }) model: any = null\n @property({ type: Array }) selected: any = []\n @property({ type: Number }) mode?: number = 1\n @property({ type: Boolean }) hideProperty?: boolean = false\n @property({ type: String }) overlay?: string | null = null\n @property({ type: Object }) scene: any = null\n @property({ type: Array }) componentGroupList?: any[] = BoardModeller.groups\n @property({ type: Array }) propertyEditor: any\n @property({ type: Boolean }) preparing?: boolean\n\n /**\n * The AI conversation open for this board - the framework's dock owns it (design/ai/shared-dock.md) and tells\n * this page through the board surface's `sessionChanged`. Direct edits are recorded under it (C3).\n */\n private chatSessionId?: string\n\n /**\n * 적용된 patch 별 inverse op 시퀀스 — Revert 기능용.\n *\n * Map<patchId, inverseOps[]>: 각 patch 적용 시점에 계산해 저장. revert 클릭\n * 시 역순 in-place 적용. 페이지 reload 시 손실 — reload 후 revert 시도는\n * notify 로 안내 (메모리 외 영속은 별개 작업).\n */\n private patchInverses = new Map<string, SceneEditOp[]>()\n\n // C2 실시간 공동편집 — apply-once 게이트(echo/순서 무관 dedup) + board-patch 구독.\n private _patchGate = new PatchApplyGate()\n private _patchSub?: { unsubscribe: () => void | Promise<void> }\n // C3 직접편집 캡처 — 마지막으로 동기화된(서버/타참여자가 아는) 모델. diff 의 baseline.\n private _syncedModel: any = null\n\n /** 모델러에 등록된 컴포넌트 type 목록 — chat 호출 시 LLM 에 전달 (lazy cache) */\n private _knownTypesCache?: string[]\n /** 등록된 type 의 group 분류 — categories 로 LLM 에 전달 */\n private _knownCategoriesCache?: string[]\n\n private get knownTypes(): string[] {\n if (!this._knownTypesCache) {\n const types = new Set<string>()\n for (const group of BoardModeller.groups || []) {\n for (const t of group.templates || []) {\n if (t && typeof t.type === 'string') types.add(t.type)\n }\n }\n this._knownTypesCache = Array.from(types).sort()\n }\n return this._knownTypesCache\n }\n\n private get knownCategories(): string[] {\n if (!this._knownCategoriesCache) {\n const cats = new Set<string>()\n for (const group of BoardModeller.groups || []) {\n for (const t of group.templates || []) {\n if (t && typeof t.group === 'string') cats.add(t.group)\n }\n }\n this._knownCategoriesCache = Array.from(cats).sort()\n }\n return this._knownCategoriesCache\n }\n\n /**\n * type 별 유효 속성 스킴 — LLM 이 정확한 컴포넌트를 만들도록 (lazy cache).\n *\n * 핵심: 좌표 표현은 type 마다 다르다 (left/top vs cx/cy vs points 등).\n * 따라서 OMIT 하지 않고 `geometryKeys` 로 별도 노출 → LLM 이 type 별 좌표 키 사용 가능.\n */\n private _componentSchemasCache?: Array<{\n type: string\n description?: string\n group?: string\n /** template.model 의 좌표/크기 관련 키들 — type 별 다름 */\n geometryKeys?: string[]\n /** 좌표 외 type 특화 속성 (default 값 또는 nested 키 목록) */\n properties?: Record<string, any>\n }>\n\n private get componentSchemas() {\n if (!this._componentSchemasCache) {\n const out: Array<{\n type: string\n description?: string\n group?: string\n geometryKeys?: string[]\n properties?: Record<string, any>\n }> = []\n const NON_PROPS = new Set(['type', 'id', 'name', 'class'])\n // 좌표/크기/경로 관련 키들 — type 마다 다른 조합으로 사용\n const GEOMETRY_KEYS = new Set([\n 'left',\n 'top',\n 'right',\n 'bottom',\n 'x',\n 'y',\n 'cx',\n 'cy',\n 'width',\n 'height',\n 'rx',\n 'ry',\n 'radius',\n 'rotation',\n 'translate',\n 'scale',\n 'points',\n 'path',\n 'vertices',\n 'verticles',\n 'startX',\n 'startY',\n 'endX',\n 'endY',\n 'startPoint',\n 'endPoint'\n ])\n for (const group of BoardModeller.groups || []) {\n for (const t of group.templates || []) {\n if (!t || typeof t.type !== 'string') continue\n const properties: Record<string, any> = {}\n const geometryKeys: string[] = []\n const model: any = t.model || {}\n for (const key of Object.keys(model)) {\n if (NON_PROPS.has(key)) continue\n if (GEOMETRY_KEYS.has(key)) {\n geometryKeys.push(key)\n continue\n }\n const v = model[key]\n if (v && typeof v === 'object' && !Array.isArray(v)) {\n properties[key] = Object.fromEntries(\n Object.keys(v)\n .slice(0, 8)\n .map(k => [k, null])\n )\n } else if (Array.isArray(v)) {\n properties[key] = []\n } else {\n properties[key] = v\n }\n }\n out.push({\n type: t.type,\n description: t.description || undefined,\n group: t.group || undefined,\n geometryKeys: geometryKeys.length > 0 ? geometryKeys : undefined,\n properties: Object.keys(properties).length > 0 ? properties : undefined\n })\n }\n }\n this._componentSchemasCache = out\n }\n return this._componentSchemasCache\n }\n\n private board: any = null\n private _loadTracker?: LoadTracker\n private _fontCtrl = new FontController(this)\n @query('ox-board-modeller') modeller?: BoardModeller\n\n get context() {\n return {\n title: this.board ? this.boardName : this.preparing ? 'Fetching board...' : '',\n help: 'board-modeller/modeller',\n widebleed: true,\n /* No title row: the canvas is the subject here, the name is in the browser tab and the\n * property panel already. Same call figure-modeller-page.ts makes; the title itself stays\n * because the tab and the document title read it. */\n heading: false\n }\n }\n\n get oopsNote() {\n return {\n icon: 'color_lens',\n title: i18next.t('title.no board to design'),\n description: i18next.t('text.no board to design')\n }\n }\n\n async refresh() {\n if (!this.boardId) {\n this.board = null\n this.model = null\n\n return\n }\n try {\n // 이전 보드 완전히 클리어\n this.board = null\n this.model = null\n this._loadTracker = new LoadTracker()\n this._loadTracker.setPhase('fetch')\n this.preparing = true\n this.updateContext()\n\n const response = await client.query({\n query: gql`\n query FetchBoardById($id: String!) {\n board(id: $id) {\n id\n name\n model\n }\n }\n `,\n variables: { id: this.boardId },\n context: gqlContext()\n })\n\n this._loadTracker?.setPhase('parse')\n\n const board = response.data.board\n\n if (!board) {\n this.board = null\n throw new Error('board not found')\n }\n\n this.board = {\n ...board,\n model: JSON.parse(board.model)\n }\n\n this.boardName = this.board.name\n this.model = {\n ...this.board.model\n }\n\n /* Another board is another conversation - the dock reopens for the new surface. */\n this.chatSessionId = undefined\n this.provideAssistantBoard()\n } catch (ex) {\n notifyError(ex)\n } finally {\n this.preparing = false\n this.updateContext()\n }\n }\n\n\n /**\n * 모델러의 selected (things-scene Component 인스턴스 배열) 에서 refid 추출.\n *\n * refid 는 things-scene 이 모든 컴포넌트에 자동 발급하는 universal numeric handle.\n * AI 의 selection 표현은 항상 refid 기반 (id 는 데이터 바인딩 이름이며 unique 가\n * 아니라 targeting 에 부적합).\n */\n private extractSelectedRefids(): number[] {\n const sel = this.selected || []\n return sel\n .map((c: any) => {\n if (!c || typeof c.get !== 'function') return null\n const refid = c.get('refid')\n return typeof refid === 'number' && Number.isFinite(refid) ? refid : null\n })\n .filter((x: number | null): x is number => x !== null)\n }\n\n /**\n * AI 채팅 mention popup (`#`) 검색 위임 — things-scene SceneSearchEngine 으로 wrap.\n *\n * F-key Finder 와 동일한 검색 룰 (id → name → tag → type → class → text → data → property)\n * 을 그대로 mention popup 에 재사용. 컴포넌트 트리를 직접 순회하므로 model JSON 으로\n * 변환할 필요 없음 — 일관성 + 성능 이점.\n *\n * 반환 구조 (FilterResult) 는 chat 의 mention-popup 표시 모델. host 는 things-scene\n * Component 에서 refid/id/type/tag/class/text 를 뽑아 candidate 로 채워 넘긴다.\n */\n private searchSceneForMention = (() => {\n const engine = new SceneSearchEngine()\n return (query: string): any[] => {\n const root = (this.scene as any)?.root\n if (!root) return []\n const results = engine.search(root, query)\n return results.map(r => {\n const c: any = r.component\n const refid = typeof c.get === 'function' ? c.get('refid') : undefined\n const id = typeof c.get === 'function' ? c.get('id') : undefined\n const type = typeof c.get === 'function' ? c.get('type') : undefined\n const tag = typeof c.get === 'function' ? c.get('tag') : undefined\n const cls = typeof c.get === 'function' ? c.get('class') : undefined\n const text = typeof c.get === 'function' ? c.get('text') : undefined\n return {\n candidate: {\n refid: typeof refid === 'number' ? refid : undefined,\n label: id || type || 'unknown',\n type: typeof type === 'string' ? type : 'unknown',\n id: typeof id === 'string' && id ? id : undefined,\n tag: typeof tag === 'string' && tag ? tag : undefined,\n class: typeof cls === 'string' && cls ? cls : undefined,\n text: typeof text === 'string' && text ? text : undefined\n },\n matchType: r.matchType,\n matchValue: r.matchValue\n }\n })\n }\n })()\n\n /**\n * 라이브 보드 모델 — things-scene 캔버스가 들고 있는 가장 최신 상태의 deep clone.\n *\n * 사용자 수작업 편집은 scene.model 에만 반영되고 this.model property 에는 자동\n * 동기화되지 않는다. AI 한테 보드 상태를 넘기거나 patch 를 적용할 때는 반드시\n * 이쪽을 쓴다.\n *\n * id 와 refid 는 별개 필드 — 컴포넌트는 model.id (선택, 사용자/AI 가 명시 설정)\n * 와 model.refid (필수, things-scene 자동 발급) 를 둘 다 가질 수 있고 AI 가\n * 양쪽을 구별해서 다룬다 (tool 인자가 분리됨). 따라서 여기서는 model 을 mutate\n * 하지 않고 raw deep clone 만 반환.\n */\n private getLiveBoard(): any {\n const sceneModel = (this.scene as any)?.model\n if (sceneModel) {\n return JSON.parse(JSON.stringify(sceneModel))\n }\n return this.model\n }\n\n /**\n * 채팅에서 patch 도착 — things-scene 에 in-place 적용.\n *\n * 핵심: `this.model = next` 로 모델을 통째 교체하면 ox-scene-viewer 가 scene 을\n * dispose → 재생성 → undo 히스토리/dirty 플래그가 모두 초기화된다.\n * 따라서 일반 add/modify/remove 는 scene 의 in-place mutation API 로 적용 →\n * commander 가 자동으로 snapshot push → CMD+Z 와 저장 안내 팝업이 정상 동작.\n *\n * 'replace' op (보드 전체 교체) 만은 부득이 wholesale 경로로 빠진다 — 이 경우는\n * 사용자에게 명시적으로 안내 후 진행.\n */\n private onSceneEditPatch = (e: CustomEvent) => {\n const { patch, patchId } = e.detail || {}\n if (!patch) return\n // C2: 같은 patch 를 이 클라이언트에서 1회만. 원격 구독이 먼저 적용했으면 로컬 낙관적 적용 skip.\n if (!this._patchGate.tryClaim(patchId)) return\n const scene = this.scene as any\n if (!scene) {\n notifyError(new Error('Scene not initialized'))\n return\n }\n\n const hasReplace = (patch.ops || []).some((op: SceneEditOp) => op.op === 'replace')\n if (hasReplace) {\n this.applyPatchWholesale(patch, patchId)\n return\n }\n\n try {\n const missed: SceneEditOp[] = []\n // 각 op 의 inverse — dispatcher 가 적용 직전/직후 scene 상태로 계산해 반환.\n // 누적했다가 onBoardEditRevert 가 역순 in-place 적용으로 복원.\n const inverseOps: SceneEditOp[] = []\n const normalize = (c: any) => this.normalizeComponent(c)\n\n for (const op of patch.ops as SceneEditOp[]) {\n const r = dispatchSceneEditOp(scene, op, { normalize })\n if (r.applied) {\n inverseOps.push(...r.inverseOps)\n } else {\n missed.push(op)\n }\n }\n\n // patch 단위로 inverse 보관 — Revert 시 역순 적용\n if (patchId && inverseOps.length > 0) {\n this.patchInverses.set(patchId, inverseOps)\n }\n\n if (missed.length > 0) {\n const missedDesc = missed\n .map((op: any) => {\n if (op.op === 'modify' || op.op === 'remove') return `refid=${op.refid}`\n if (op.op === 'modifyScene') return 'modifyBoard (scene root unavailable)'\n return op.op\n })\n .join(', ')\n notify(\n 'warn',\n `AI 가 ${missed.length}개의 변경을 시도했지만 적용되지 않았습니다: ${missedDesc}`\n )\n }\n } catch (ex) {\n notifyError(ex)\n }\n }\n\n /**\n * 'replace' op 적용 — scene 통째로 재생성 (undo 히스토리 초기화).\n *\n * AI 가 보드 전체 재구성을 요청한 경우. 사용자에게 history 손실 안내.\n * board-import 데이터 wholesale 적용 등 드문 케이스에 한정.\n *\n * Revert 지원 — replace 직전 보드 model 을 inverse 로 보관 (또 다른 replace).\n */\n private applyPatchWholesale(patch: SceneEditPatch, patchId?: string) {\n try {\n const baseBoard = this.getLiveBoard()\n const inverseOps: SceneEditOp[] = baseBoard\n ? [{ op: 'replace', model: JSON.parse(JSON.stringify(baseBoard)) }]\n : []\n const report = applyScenePatchVerbose(baseBoard, patch)\n const next = report.model as any\n if (report.applied.length === 0) return\n const normalized = (next.components || []).map((c: any) => this.normalizeComponent(c))\n this.model = {\n ...(baseBoard || {}),\n ...(next.width !== undefined && { width: next.width }),\n ...(next.height !== undefined && { height: next.height }),\n components: normalized\n }\n if (patchId && inverseOps.length > 0) {\n this.patchInverses.set(patchId, inverseOps)\n }\n notify('info', '보드 전체가 교체되어 실행 취소(undo) 히스토리가 초기화되었습니다.')\n } catch (ex) {\n notifyError(ex)\n }\n }\n\n // ── C2: board-patch 실시간 구독 (원격 편집을 이 화면에 반영) ─────────────────────\n private async _subscribeBoardPatches(boardId: string) {\n this._unsubscribeBoardPatches()\n try {\n this._patchSub = await subscribe(\n {\n query: gql`\n subscription ($boardId: String!) {\n boardPatchActivity(boardId: $boardId) {\n id\n opsJson\n source\n summary\n }\n }\n `,\n variables: { boardId }\n },\n { next: ({ data }: any) => this._onRemotePatch(data?.boardPatchActivity) }\n )\n } catch (ex) {\n // 구독 실패 시 협업만 비활성 — 로컬 편집은 정상.\n notifyError(ex)\n }\n }\n\n private _unsubscribeBoardPatches() {\n try {\n this._patchSub?.unsubscribe()\n } catch {\n /* ignore */\n }\n this._patchSub = undefined\n }\n\n /**\n * 원격 patch 도착 — apply-once 게이트 통과 시 in-place 적용. 자기발신 echo 는 게이트가 차단\n * (로컬 onSceneEditPatch 가 이미 같은 patchId 를 claim). 원격분은 revert 인버스 미보관(프로토타입).\n */\n private _onRemotePatch(entry: any) {\n if (!entry?.id) return\n if (!this._patchGate.tryClaim(entry.id)) return\n // server PatchEntry.opsJson 은 GraphQLJSON — 이미 parsed SceneEditOp[] 로 도착(추가 parse 불필요).\n const ops: SceneEditOp[] = Array.isArray(entry.opsJson) ? entry.opsJson : []\n if (!ops.length) return\n const scene = this.scene as any\n if (!scene) return // scene 준비 전 도착분 드롭 (프로토타입 — 큐잉 미지원)\n\n const patch: SceneEditPatch = { ops, summary: entry.summary, confidence: 0 } as SceneEditPatch\n if (ops.some(op => op.op === 'replace')) {\n this.applyPatchWholesale(patch)\n this._syncedModel = this.getLiveBoard() // baseline 동기 — 원격 변경 재캡처 방지\n return\n }\n const normalize = (c: any) => this.normalizeComponent(c)\n for (const op of ops) {\n // echo 안전(멱등): 이미 존재하는 refid 의 add 는 skip. 내 직접편집 echo 가 게이트 claim\n // 보다 먼저 도착해도 중복 생성 안 됨. (modify/remove 는 본래 멱등)\n if (\n op.op === 'add' &&\n (op as any).component?.refid != null &&\n findSceneComponent(scene, { refid: (op as any).component.refid })\n ) {\n continue\n }\n try {\n dispatchSceneEditOp(scene, op, { normalize })\n } catch (ex) {\n notifyError(ex)\n }\n }\n this._syncedModel = this.getLiveBoard() // 원격 변경을 baseline 에 반영 (다음 저장서 재캡처 방지)\n }\n\n /**\n * 채팅에서 board-edit-revert 도착 — 누적된 inverse 를 역순 in-place 적용.\n *\n * - 메모리상 patchInverses Map 만 본다. 페이지 reload 후엔 inverse 가 없어\n * 되돌릴 수 없음 (사용자에게 안내).\n * - 성공 시 서버 revertPatch mutation 호출 → PatchEntry.reverted=true 영속.\n * - in-place 적용이라 undo/dirty/selection 보존 (chatViaTools 의 모든 강점 그대로).\n */\n private onBoardEditRevert = async (e: CustomEvent) => {\n const { patchId } = e.detail || {}\n if (!patchId) return\n const inverses = this.patchInverses.get(patchId)\n if (!inverses || inverses.length === 0) {\n notify(\n 'warn',\n '이 변경은 자동 되돌릴 수 없습니다 (페이지 새로고침 이후 적용된 변경은 메모리에 inverse 가 없습니다).'\n )\n return\n }\n\n const scene = this.scene as any\n if (!scene) {\n notifyError(new Error('Scene not initialized'))\n return\n }\n\n try {\n // 역순 적용 — 마지막 op 부터 되돌림. 단일 patch 안에서도 순서 의미 있음\n // (예: add 후 modify 한 시퀀스를 되돌리려면 modify(원본) 후 remove)\n const reversed = [...inverses].reverse()\n const reverseFakePatch: SceneEditPatch = {\n ops: reversed,\n summary: 'revert',\n confidence: 1\n }\n // hasReplace 면 wholesale, 그렇지 않으면 in-place — 일반 onSceneEditPatch 와 동일\n const hasReplace = reversed.some(op => op.op === 'replace')\n if (hasReplace) {\n this.applyPatchWholesale(reverseFakePatch)\n } else {\n // in-place 직접 적용 — 새 inverse 누적은 안 함 (revert 의 revert 는 redo, 별개 기능)\n this.applyInverseOpsInPlace(scene, reversed)\n }\n\n this.patchInverses.delete(patchId)\n await this.recordRevertOnServer(patchId)\n } catch (ex) {\n notifyError(ex)\n }\n }\n\n /**\n * inverse op 시퀀스를 things-scene 위에 in-place 적용 (snapshot/undo 보존).\n * dispatcher 재사용 — inverse 누적은 무시 (revert 의 revert 는 redo, 별개 기능).\n */\n private applyInverseOpsInPlace(scene: any, ops: SceneEditOp[]): void {\n const normalize = (c: any) => this.normalizeComponent(c)\n for (const op of ops) {\n dispatchSceneEditOp(scene, op, { normalize })\n }\n }\n\n /** 서버 PatchEntry.reverted=true 영속 — fail 해도 UI 는 이미 되돌렸으니 warn 만. */\n private async recordRevertOnServer(patchId: string): Promise<void> {\n try {\n await client.mutate({ mutation: REVERT_PATCH_MUTATION, variables: { patchId } })\n } catch (e: any) {\n console.warn('[board-modeller] revertPatch server persist failed:', e?.message ?? e)\n }\n }\n\n /**\n * AI 가 ephemeral scene action (selection / view / mode) 을 실행하라고 요청.\n *\n * scene-edit-patch 와 별개 채널 — 모델 변경 X, undo 영향 X, dirty flag 무관.\n * things-scene API 직접 호출. 잘못된 action / 누락된 컴포넌트는 console.warn 만.\n */\n private onSceneActionExecute = (e: CustomEvent) => {\n const { actions } = e.detail || {}\n if (!Array.isArray(actions) || actions.length === 0) return\n const scene = this.scene as any\n if (!scene) return\n\n let modeChanged = false\n for (const action of actions) {\n try {\n dispatchSceneAction(scene, action)\n if (action?.action === 'setSceneMode') modeChanged = true\n } catch (ex: any) {\n console.warn('[board-modeller] action execute failed:', action, ex?.message ?? ex)\n }\n }\n // setSceneMode 가 있었으면 page 의 reactive mode 도 동기 (Lit re-render 트리거)\n if (modeChanged) this.mode = scene.mode\n }\n\n /**\n * AI 가 만든 컴포넌트를 things-scene 이 기대하는 완전한 형태로 normalize.\n * BoardModeller 에 등록된 template.model (default 값) 위에 AI 응답을 덮어쓴다.\n * 이 단계 없이 things-scene 에 넣으면 필수 속성 누락 시 render 에서 crash 가능\n * (예: gauge-circle 의 value 가 undefined → toString() TypeError).\n */\n private normalizeComponent(c: any): any {\n if (!c || typeof c !== 'object' || typeof c.type !== 'string') return c\n const template = this.findTemplateByType(c.type)\n if (!template || !template.model) return c\n return mergeDefaultsDeep(template.model, c)\n }\n\n private findTemplateByType(type: string): any {\n for (const group of BoardModeller.groups || []) {\n for (const t of group.templates || []) {\n if (t && t.type === type) return t\n }\n }\n return undefined\n }\n\n async updated(changes) {\n if (changes.has('boardId')) {\n try {\n /* The same rule as the board's own save door (board-service): a domain owner edits without a role. */\n if (await hasPrivilege({ privilege: 'mutation', category: 'board', domainOwnerGranted: true })) {\n this.refresh()\n // C2: 보드 변경 시 그 보드의 실시간 patch 구독 (이전 보드 구독은 해제).\n if (this.boardId) this._subscribeBoardPatches(this.boardId)\n else this._unsubscribeBoardPatches()\n } else {\n this.boardId = null\n this.model = null\n this.modeller?.close()\n this._unsubscribeBoardPatches()\n }\n } catch {\n this.boardId = null\n this.model = null\n this.modeller?.close()\n this._unsubscribeBoardPatches()\n }\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this._unsubscribeBoardPatches()\n clearAssistantSurface(this)\n }\n\n /**\n * This board, told to the framework's AI dock (design/ai/shared-dock.md §3). The dock owns the\n * conversation - sessions, modes, the manager - and hands the chat's scene edits back to this page.\n * Decided 2026-09-25: the modeller no longer carries its own \"AI\" button and panel; the band's forum\n * button opens the same dock as every other screen.\n */\n private provideAssistantBoard() {\n if (!this.boardId) return\n const boardId = this.boardId\n provideAssistantSurface(this, {\n key: `board:${boardId}`,\n subject: 'board',\n icon: 'dashboard',\n label: () => this.boardName || i18next.t('text.ai_assistant'),\n detail: () => i18next.t('label.board', { defaultValue: 'board' }),\n anchor: () => ({ anchorType: 'board', anchorId: boardId }),\n sessionChanged: sessionId => (this.chatSessionId = sessionId || undefined),\n board: {\n chatEndpoint: 'boardAIChat',\n currentBoard: () => this.model,\n boardProvider: () => this.getLiveBoard(),\n selectedRefids: () => this.extractSelectedRefids(),\n knownTypes: () => this.knownTypes,\n categories: () => this.knownCategories,\n componentSchemas: () => this.componentSchemas,\n searchProvider: this.searchSceneForMention,\n applyPatch: (detail: any) => {\n /* The modeller tells the person which ops missed itself, so the dock is told none to repeat. */\n this.onSceneEditPatch(new CustomEvent('scene-edit-patch', { detail }))\n return { applied: 0, missed: 0 }\n },\n revertPatch: (patchId: string) => this.onBoardEditRevert(new CustomEvent('board-edit-revert', { detail: { patchId } })),\n applyAction: (detail: any) => this.onSceneActionExecute(new CustomEvent('scene-action-execute', { detail }))\n }\n })\n }\n\n pageUpdated(changes, lifecycle) {\n if (this.active) {\n getModellerToolbarMode().then(mode => (this.toolbarMode = mode))\n }\n\n if (this.active) {\n this.boardId = lifecycle.resourceId\n } else {\n clearAssistantSurface(this)\n this.boardId = null\n this.board = null\n this.model = null\n this.preparing = false\n this.modeller?.close()\n this._unsubscribeBoardPatches()\n this.updateContext()\n }\n }\n\n render() {\n const oops = !this.preparing && !this.model && this.oopsNote\n\n return html`\n <div class=\"modeller-area\">\n ${oops\n ? html`<ox-oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></ox-oops-note>`\n : html`\n <ox-board-modeller\n .boardName=${this.boardName || ''}\n .contextualToolbar=${this.toolbarMode !== 'toolbar'}\n .contextualToolbarPlacement=${this.toolbarMode === 'docked' ? 'docked' : 'floating'}\n .mode=${this.mode}\n .loadTracker=${this._loadTracker}\n @mode-changed=${e => {\n this.mode = e.detail.value\n }}\n .model=${this.model}\n @model-changed=${e => {\n this.model = e.detail.value\n }}\n .scene=${this.scene}\n @scene-changed=${e => {\n this.scene = e.detail.value\n }}\n .selected=${this.selected}\n @selected-changed=${e => {\n this.selected = e.detail.value\n }}\n .provider=${provider}\n @save-model=${e => this.saveBoard()}\n .componentGroupList=${this.componentGroupList}\n .fonts=${this._fontCtrl.fonts}\n .hideProperty=${this.hideProperty}\n >\n </ox-board-modeller>\n `}\n ${this.scene && boardPlacementProvider()\n ? html`<board-placement-tray .boardId=${this.boardId} .scene=${this.scene}></board-placement-tray>`\n : nothing}\n </div>\n `\n }\n\n async updateBoard() {\n try {\n this.preparing = true\n\n const { id, name, description, groupId } = this.board\n const model = JSON.stringify(this.scene.model)\n\n await client.mutate({\n mutation: gql`\n mutation UpdateBoard($id: String!, $patch: BoardPatch!) {\n updateBoard(id: $id, patch: $patch) {\n id\n }\n }\n `,\n variables: {\n id,\n patch: { name, description, model, groupId }\n },\n context: gqlContext()\n })\n\n notify('info', i18next.t('text.saved'))\n } catch (ex) {\n notifyError(ex)\n } finally {\n this.preparing = false\n }\n\n this.updateContext()\n }\n\n async saveBoard() {\n await this.updateBoard()\n this.modeller?.preserve()\n // C3: 저장 후(이산적·사용자 의도) 직접편집을 ops 로 캡처해 방송. best-effort —\n // 실패해도 저장 자체엔 영향 없음(이미 완료). (라이브 per-edit 동기화는 C3c 후보.)\n this._captureDirectEdits()\n }\n\n /**\n * C3: 마지막 동기 모델 → 현재 모델 diff 를 recordDirectPatch 로 기록(=같은 board 구독자 방송).\n * 반환된 patchId 를 게이트에 claim → 자기발신 echo skip. baseline 갱신.\n * sessionId 없으면(AI 세션 미연결) skip — 협업 비활성, 편집은 정상.\n */\n private async _captureDirectEdits() {\n try {\n if (!this.chatSessionId) return\n const current = this.getLiveBoard()\n if (!current) return\n if (!this._syncedModel) {\n this._syncedModel = current // 첫 저장 = baseline 확립 (이전 상태 미상이라 방송 안 함)\n return\n }\n const ops = diffBoardModel(this._syncedModel, current)\n this._syncedModel = current\n if (ops.length === 0) return\n\n const res = await client.mutate({\n mutation: gql`\n mutation RecordDirectPatch($sessionId: String!, $ops: JSON!, $summary: String) {\n recordDirectPatch(sessionId: $sessionId, ops: $ops, summary: $summary) {\n id\n }\n }\n `,\n variables: { sessionId: this.chatSessionId, ops, summary: `직접 편집 ${ops.length}건` },\n context: gqlContext()\n })\n const id = res?.data?.recordDirectPatch?.id\n if (id) this._patchGate.tryClaim(id) // 내 직접편집의 broadcast echo 차단\n } catch (ex) {\n notifyError(ex)\n }\n }\n\n async canDeactivate(): Promise<boolean> {\n if (this.modeller?.hasUnpreservedChanges()) {\n return await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('prompt.sure to navigate away?'),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n }\n\n return true\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"board-modeller-page.js","sourceRoot":"","sources":["../../client/pages/board-modeller-page.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,yBAAyB,CAAA;AAChC,OAAO,qCAAqC,CAAA;AAC5C,OAAO,eAAe,CAAA;AACtB,OAAO,0BAA0B,CAAA;AAEjC,OAAO,GAAG,MAAM,aAAa,CAAA;AA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AI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;YACtC,OAAO,KAAK,CAAA;QACd,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;;AA54B2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAwB;AACvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAwB;AAElC;IAAhB,KAAK,EAAE;;sDAAwD;AACpC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAkB;AAClB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;mDAAmB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CAAkB;AAChB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;uDAA+B;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAkB;AAClB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;6DAAkD;AACjD;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;yDAAoB;AACjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;oDAAoB;AAmMpB;IAA3B,KAAK,CAAC,mBAAmB,CAAC;8BAAY,aAAa;mDAAA;AA3QzC,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;;GACxB,iBAAiB,CAy8B7B","sourcesContent":["import '@material/web/icon/icon.js'\nimport 'things-scene-components'\nimport '@operato/board/ox-board-modeller.js'\nimport '@operato/oops'\nimport '@things-factory/board-ai'\n\nimport gql from 'graphql-tag'\nimport { getModellerToolbarMode, ModellerToolbarMode } from '../setting-let/board-modeller-setting-let.js'\nimport { css, html, nothing } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { BoardModeller } from '@operato/board/ox-board-modeller.js'\nimport { LoadTracker, SceneSearchEngine } from '@hatiolab/things-scene'\nimport { OxPropertyEditor } from '@operato/property-editor'\nimport { PageView, FontController, UnsavedDraftController } from '@operato/shell'\nimport { getPathInfo } from '@operato/utils'\nimport { auth, hasPrivilege } from '@things-factory/auth-base/dist-client/index.js'\nimport {\n applyScenePatchVerbose,\n dispatchSceneAction,\n dispatchSceneEditOp,\n findSceneComponent,\n type SceneEditOp,\n type SceneEditPatch\n} from '@operato/scene-ops'\nimport { client, gqlContext, subscribe } from '@operato/graphql'\nimport {\n clearAssistantSurface,\n provideAssistantSurface\n} from '@things-factory/ai-assistant/dist-client/index.js'\nimport { i18next } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\nimport { provider } from '@operato/board/board-provider.js'\nimport '../board-placement-tray.js' // 배치 팔레트 오버레이(호스트-등록 provider 있을 때만 표시)\nimport { boardPlacementProvider } from '@operato/board/board-placement-palette.js'\nimport components from 'things-scene-components-with-tools'\nimport { notify, notifyError } from '../utils/notify-helper.js'\nimport { PatchApplyGate } from '../utils/patch-apply-gate.js'\nimport { diffBoardModel } from '../utils/board-model-diff.js'\n\nexport { findSceneComponent }\n\n/** 서버 PatchEntry.reverted=true 플래그 영속용 mutation. */\nconst REVERT_PATCH_MUTATION = gql`\n mutation RevertPatch($patchId: String!) {\n revertPatch(patchId: $patchId)\n }\n`\n\n/**\n * default 위에 override 를 깊게 merge.\n * - override 의 키 값이 undefined 가 아닌 경우 우선 적용\n * - override 의 nested object 는 default 와 deep merge\n * - array / primitive 는 override 가 그대로 우선\n */\nfunction mergeDefaultsDeep(defaults: any, override: any): any {\n if (defaults === null || defaults === undefined) return override\n if (override === null || override === undefined) return defaults\n if (typeof defaults !== 'object' || typeof override !== 'object') return override\n if (Array.isArray(defaults) || Array.isArray(override)) return override\n\n const out: any = { ...defaults }\n for (const key of Object.keys(override)) {\n const dv = (defaults as any)[key]\n const ov = (override as any)[key]\n if (\n dv !== null &&\n ov !== null &&\n typeof dv === 'object' &&\n typeof ov === 'object' &&\n !Array.isArray(dv) &&\n !Array.isArray(ov)\n ) {\n out[key] = mergeDefaultsDeep(dv, ov)\n } else if (ov !== undefined) {\n out[key] = ov\n }\n }\n return out\n}\n\n@customElement('board-modeller-page')\nexport class BoardModellerPage extends PageView {\n constructor() {\n super()\n\n components.forEach(({ templates = [], groups = [] }) => {\n groups.forEach(group => BoardModeller.registerGroup(group))\n BoardModeller.registerTemplate(templates)\n })\n\n /* 컴포넌트에서 정의된 에디터들을 MODELLER_EDITORS에 등록 */\n const addedEditors = {}\n for (const component in components) {\n let { editors } = components[component]\n\n editors &&\n editors.forEach(editor => {\n let { type, element } = editor\n\n addedEditors[type] = element\n })\n }\n\n OxPropertyEditor.register(addedEditors)\n }\n\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: row;\n\n overflow: hidden;\n position: relative;\n /* The modeller's own layers (the save button is z-index 1000) stay inside the page - the AI dock opens over it. */\n isolation: isolate;\n }\n\n .modeller-area {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n position: relative;\n }\n\n ox-board-modeller {\n flex: 1;\n }\n\n ox-oops-note {\n display: block;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n\n `\n ]\n\n @property({ type: String }) boardId?: string | null\n @property({ type: String }) boardName?: string = ''\n /* Read from the user's board-modeller setting each time the page is shown. */\n @state() private toolbarMode: ModellerToolbarMode = 'contextual'\n @property({ type: Object }) model: any = null\n @property({ type: Array }) selected: any = []\n @property({ type: Number }) mode?: number = 1\n @property({ type: Boolean }) hideProperty?: boolean = false\n @property({ type: String }) overlay?: string | null = null\n @property({ type: Object }) scene: any = null\n @property({ type: Array }) componentGroupList?: any[] = BoardModeller.groups\n @property({ type: Array }) propertyEditor: any\n @property({ type: Boolean }) preparing?: boolean\n\n /**\n * The AI conversation open for this board - the framework's dock owns it (design/ai/shared-dock.md) and tells\n * this page through the board surface's `sessionChanged`. Direct edits are recorded under it (C3).\n */\n private chatSessionId?: string\n\n /**\n * 적용된 patch 별 inverse op 시퀀스 — Revert 기능용.\n *\n * Map<patchId, inverseOps[]>: 각 patch 적용 시점에 계산해 저장. revert 클릭\n * 시 역순 in-place 적용. 페이지 reload 시 손실 — reload 후 revert 시도는\n * notify 로 안내 (메모리 외 영속은 별개 작업).\n */\n private patchInverses = new Map<string, SceneEditOp[]>()\n\n // C2 실시간 공동편집 — apply-once 게이트(echo/순서 무관 dedup) + board-patch 구독.\n private _patchGate = new PatchApplyGate()\n private _patchSub?: { unsubscribe: () => void | Promise<void> }\n // C3 직접편집 캡처 — 마지막으로 동기화된(서버/타참여자가 아는) 모델. diff 의 baseline.\n private _syncedModel: any = null\n\n /** 모델러에 등록된 컴포넌트 type 목록 — chat 호출 시 LLM 에 전달 (lazy cache) */\n private _knownTypesCache?: string[]\n /** 등록된 type 의 group 분류 — categories 로 LLM 에 전달 */\n private _knownCategoriesCache?: string[]\n\n private get knownTypes(): string[] {\n if (!this._knownTypesCache) {\n const types = new Set<string>()\n for (const group of BoardModeller.groups || []) {\n for (const t of group.templates || []) {\n if (t && typeof t.type === 'string') types.add(t.type)\n }\n }\n this._knownTypesCache = Array.from(types).sort()\n }\n return this._knownTypesCache\n }\n\n private get knownCategories(): string[] {\n if (!this._knownCategoriesCache) {\n const cats = new Set<string>()\n for (const group of BoardModeller.groups || []) {\n for (const t of group.templates || []) {\n if (t && typeof t.group === 'string') cats.add(t.group)\n }\n }\n this._knownCategoriesCache = Array.from(cats).sort()\n }\n return this._knownCategoriesCache\n }\n\n /**\n * type 별 유효 속성 스킴 — LLM 이 정확한 컴포넌트를 만들도록 (lazy cache).\n *\n * 핵심: 좌표 표현은 type 마다 다르다 (left/top vs cx/cy vs points 등).\n * 따라서 OMIT 하지 않고 `geometryKeys` 로 별도 노출 → LLM 이 type 별 좌표 키 사용 가능.\n */\n private _componentSchemasCache?: Array<{\n type: string\n description?: string\n group?: string\n /** template.model 의 좌표/크기 관련 키들 — type 별 다름 */\n geometryKeys?: string[]\n /** 좌표 외 type 특화 속성 (default 값 또는 nested 키 목록) */\n properties?: Record<string, any>\n }>\n\n private get componentSchemas() {\n if (!this._componentSchemasCache) {\n const out: Array<{\n type: string\n description?: string\n group?: string\n geometryKeys?: string[]\n properties?: Record<string, any>\n }> = []\n const NON_PROPS = new Set(['type', 'id', 'name', 'class'])\n // 좌표/크기/경로 관련 키들 — type 마다 다른 조합으로 사용\n const GEOMETRY_KEYS = new Set([\n 'left',\n 'top',\n 'right',\n 'bottom',\n 'x',\n 'y',\n 'cx',\n 'cy',\n 'width',\n 'height',\n 'rx',\n 'ry',\n 'radius',\n 'rotation',\n 'translate',\n 'scale',\n 'points',\n 'path',\n 'vertices',\n 'verticles',\n 'startX',\n 'startY',\n 'endX',\n 'endY',\n 'startPoint',\n 'endPoint'\n ])\n for (const group of BoardModeller.groups || []) {\n for (const t of group.templates || []) {\n if (!t || typeof t.type !== 'string') continue\n const properties: Record<string, any> = {}\n const geometryKeys: string[] = []\n const model: any = t.model || {}\n for (const key of Object.keys(model)) {\n if (NON_PROPS.has(key)) continue\n if (GEOMETRY_KEYS.has(key)) {\n geometryKeys.push(key)\n continue\n }\n const v = model[key]\n if (v && typeof v === 'object' && !Array.isArray(v)) {\n properties[key] = Object.fromEntries(\n Object.keys(v)\n .slice(0, 8)\n .map(k => [k, null])\n )\n } else if (Array.isArray(v)) {\n properties[key] = []\n } else {\n properties[key] = v\n }\n }\n out.push({\n type: t.type,\n description: t.description || undefined,\n group: t.group || undefined,\n geometryKeys: geometryKeys.length > 0 ? geometryKeys : undefined,\n properties: Object.keys(properties).length > 0 ? properties : undefined\n })\n }\n }\n this._componentSchemasCache = out\n }\n return this._componentSchemasCache\n }\n\n private board: any = null\n /** When the board was last saved, as the server said (ADR-0098) - the next save must find it unchanged. */\n private savedAt: string | null = null\n /** A draft was put back and not saved yet; the scene's own count of unsaved steps starts from it. */\n private restoredDraft = false\n /** The save a restored draft began from - the next save goes out against it, not the newer one. */\n private draftBase: string | null = null\n /*\n * The edit kept as a draft in this browser, offered back when the board opens (ADR-0098). No leave\n * question at reload - only where drafts cannot be kept does the controller bring the browser's back.\n */\n private drafts = new UnsavedDraftController<string>(this, {\n address: () => {\n const user = (auth.credential as any)?.id\n return this.boardId && user\n ? { user, domain: getPathInfo(location.pathname).domain || '', screen: 'board-modeller', target: this.boardId }\n : undefined\n },\n snapshot: () =>\n this.unsaved() && this.scene?.model\n ? { value: JSON.stringify(this.scene.model), base: this.draftBase ?? this.savedAt }\n : undefined,\n savedRevision: () => this.savedAt,\n restore: (value, base) => {\n this.model = JSON.parse(value)\n this.restoredDraft = true\n this.draftBase = base == null ? null : String(base)\n }\n })\n private _loadTracker?: LoadTracker\n\n /** Something is not saved: an edit since the last save, or a draft put back and not saved yet. */\n private unsaved(): boolean {\n return this.restoredDraft || !!this.modeller?.hasUnpreservedChanges()\n }\n\n /* The scene's history says when the edit changed - the draft follows it. */\n private _draftScene: any = null\n private _onEdit = () => this.drafts.changed()\n private _watchScene(scene: any) {\n if (this._draftScene === scene) return\n const events = ['execute', 'undo', 'redo']\n for (const event of events) this._draftScene?.commander?.off?.(event, this._onEdit, this)\n this._draftScene = scene\n for (const event of events) scene?.commander?.on?.(event, this._onEdit, this)\n }\n private _fontCtrl = new FontController(this)\n @query('ox-board-modeller') modeller?: BoardModeller\n\n get context() {\n return {\n title: this.board ? this.boardName : this.preparing ? 'Fetching board...' : '',\n help: 'board-modeller/modeller',\n widebleed: true,\n /* No title row: the canvas is the subject here, the name is in the browser tab and the\n * property panel already. Same call figure-modeller-page.ts makes; the title itself stays\n * because the tab and the document title read it. */\n heading: false\n }\n }\n\n get oopsNote() {\n return {\n icon: 'color_lens',\n title: i18next.t('title.no board to design'),\n description: i18next.t('text.no board to design')\n }\n }\n\n async refresh() {\n if (!this.boardId) {\n this.board = null\n this.model = null\n\n return\n }\n try {\n // 이전 보드 완전히 클리어\n this.board = null\n this.model = null\n this._loadTracker = new LoadTracker()\n this._loadTracker.setPhase('fetch')\n this.preparing = true\n this.updateContext()\n\n const response = await client.query({\n query: gql`\n query FetchBoardById($id: String!) {\n board(id: $id) {\n id\n name\n model\n updatedAt\n }\n }\n `,\n variables: { id: this.boardId },\n context: gqlContext()\n })\n\n this._loadTracker?.setPhase('parse')\n\n const board = response.data.board\n\n if (!board) {\n this.board = null\n throw new Error('board not found')\n }\n\n this.board = {\n ...board,\n model: JSON.parse(board.model)\n }\n\n this.boardName = this.board.name\n this.model = {\n ...this.board.model\n }\n this.savedAt = board.updatedAt ?? null\n this.restoredDraft = false\n this.draftBase = null\n\n /* An edit kept from before a reload or a closed tab is offered back once the saved board is here. */\n this.updateComplete.then(() => this.drafts.offer())\n\n /* Another board is another conversation - the dock reopens for the new surface. */\n this.chatSessionId = undefined\n this.provideAssistantBoard()\n } catch (ex) {\n notifyError(ex)\n } finally {\n this.preparing = false\n this.updateContext()\n }\n }\n\n\n /**\n * 모델러의 selected (things-scene Component 인스턴스 배열) 에서 refid 추출.\n *\n * refid 는 things-scene 이 모든 컴포넌트에 자동 발급하는 universal numeric handle.\n * AI 의 selection 표현은 항상 refid 기반 (id 는 데이터 바인딩 이름이며 unique 가\n * 아니라 targeting 에 부적합).\n */\n private extractSelectedRefids(): number[] {\n const sel = this.selected || []\n return sel\n .map((c: any) => {\n if (!c || typeof c.get !== 'function') return null\n const refid = c.get('refid')\n return typeof refid === 'number' && Number.isFinite(refid) ? refid : null\n })\n .filter((x: number | null): x is number => x !== null)\n }\n\n /**\n * AI 채팅 mention popup (`#`) 검색 위임 — things-scene SceneSearchEngine 으로 wrap.\n *\n * F-key Finder 와 동일한 검색 룰 (id → name → tag → type → class → text → data → property)\n * 을 그대로 mention popup 에 재사용. 컴포넌트 트리를 직접 순회하므로 model JSON 으로\n * 변환할 필요 없음 — 일관성 + 성능 이점.\n *\n * 반환 구조 (FilterResult) 는 chat 의 mention-popup 표시 모델. host 는 things-scene\n * Component 에서 refid/id/type/tag/class/text 를 뽑아 candidate 로 채워 넘긴다.\n */\n private searchSceneForMention = (() => {\n const engine = new SceneSearchEngine()\n return (query: string): any[] => {\n const root = (this.scene as any)?.root\n if (!root) return []\n const results = engine.search(root, query)\n return results.map(r => {\n const c: any = r.component\n const refid = typeof c.get === 'function' ? c.get('refid') : undefined\n const id = typeof c.get === 'function' ? c.get('id') : undefined\n const type = typeof c.get === 'function' ? c.get('type') : undefined\n const tag = typeof c.get === 'function' ? c.get('tag') : undefined\n const cls = typeof c.get === 'function' ? c.get('class') : undefined\n const text = typeof c.get === 'function' ? c.get('text') : undefined\n return {\n candidate: {\n refid: typeof refid === 'number' ? refid : undefined,\n label: id || type || 'unknown',\n type: typeof type === 'string' ? type : 'unknown',\n id: typeof id === 'string' && id ? id : undefined,\n tag: typeof tag === 'string' && tag ? tag : undefined,\n class: typeof cls === 'string' && cls ? cls : undefined,\n text: typeof text === 'string' && text ? text : undefined\n },\n matchType: r.matchType,\n matchValue: r.matchValue\n }\n })\n }\n })()\n\n /**\n * 라이브 보드 모델 — things-scene 캔버스가 들고 있는 가장 최신 상태의 deep clone.\n *\n * 사용자 수작업 편집은 scene.model 에만 반영되고 this.model property 에는 자동\n * 동기화되지 않는다. AI 한테 보드 상태를 넘기거나 patch 를 적용할 때는 반드시\n * 이쪽을 쓴다.\n *\n * id 와 refid 는 별개 필드 — 컴포넌트는 model.id (선택, 사용자/AI 가 명시 설정)\n * 와 model.refid (필수, things-scene 자동 발급) 를 둘 다 가질 수 있고 AI 가\n * 양쪽을 구별해서 다룬다 (tool 인자가 분리됨). 따라서 여기서는 model 을 mutate\n * 하지 않고 raw deep clone 만 반환.\n */\n private getLiveBoard(): any {\n const sceneModel = (this.scene as any)?.model\n if (sceneModel) {\n return JSON.parse(JSON.stringify(sceneModel))\n }\n return this.model\n }\n\n /**\n * 채팅에서 patch 도착 — things-scene 에 in-place 적용.\n *\n * 핵심: `this.model = next` 로 모델을 통째 교체하면 ox-scene-viewer 가 scene 을\n * dispose → 재생성 → undo 히스토리/dirty 플래그가 모두 초기화된다.\n * 따라서 일반 add/modify/remove 는 scene 의 in-place mutation API 로 적용 →\n * commander 가 자동으로 snapshot push → CMD+Z 와 저장 안내 팝업이 정상 동작.\n *\n * 'replace' op (보드 전체 교체) 만은 부득이 wholesale 경로로 빠진다 — 이 경우는\n * 사용자에게 명시적으로 안내 후 진행.\n */\n private onSceneEditPatch = (e: CustomEvent) => {\n const { patch, patchId } = e.detail || {}\n if (!patch) return\n // C2: 같은 patch 를 이 클라이언트에서 1회만. 원격 구독이 먼저 적용했으면 로컬 낙관적 적용 skip.\n if (!this._patchGate.tryClaim(patchId)) return\n const scene = this.scene as any\n if (!scene) {\n notifyError(new Error('Scene not initialized'))\n return\n }\n\n const hasReplace = (patch.ops || []).some((op: SceneEditOp) => op.op === 'replace')\n if (hasReplace) {\n this.applyPatchWholesale(patch, patchId)\n return\n }\n\n try {\n const missed: SceneEditOp[] = []\n // 각 op 의 inverse — dispatcher 가 적용 직전/직후 scene 상태로 계산해 반환.\n // 누적했다가 onBoardEditRevert 가 역순 in-place 적용으로 복원.\n const inverseOps: SceneEditOp[] = []\n const normalize = (c: any) => this.normalizeComponent(c)\n\n for (const op of patch.ops as SceneEditOp[]) {\n const r = dispatchSceneEditOp(scene, op, { normalize })\n if (r.applied) {\n inverseOps.push(...r.inverseOps)\n } else {\n missed.push(op)\n }\n }\n\n // patch 단위로 inverse 보관 — Revert 시 역순 적용\n if (patchId && inverseOps.length > 0) {\n this.patchInverses.set(patchId, inverseOps)\n }\n\n if (missed.length > 0) {\n const missedDesc = missed\n .map((op: any) => {\n if (op.op === 'modify' || op.op === 'remove') return `refid=${op.refid}`\n if (op.op === 'modifyScene') return 'modifyBoard (scene root unavailable)'\n return op.op\n })\n .join(', ')\n notify(\n 'warn',\n `AI 가 ${missed.length}개의 변경을 시도했지만 적용되지 않았습니다: ${missedDesc}`\n )\n }\n } catch (ex) {\n notifyError(ex)\n }\n }\n\n /**\n * 'replace' op 적용 — scene 통째로 재생성 (undo 히스토리 초기화).\n *\n * AI 가 보드 전체 재구성을 요청한 경우. 사용자에게 history 손실 안내.\n * board-import 데이터 wholesale 적용 등 드문 케이스에 한정.\n *\n * Revert 지원 — replace 직전 보드 model 을 inverse 로 보관 (또 다른 replace).\n */\n private applyPatchWholesale(patch: SceneEditPatch, patchId?: string) {\n try {\n const baseBoard = this.getLiveBoard()\n const inverseOps: SceneEditOp[] = baseBoard\n ? [{ op: 'replace', model: JSON.parse(JSON.stringify(baseBoard)) }]\n : []\n const report = applyScenePatchVerbose(baseBoard, patch)\n const next = report.model as any\n if (report.applied.length === 0) return\n const normalized = (next.components || []).map((c: any) => this.normalizeComponent(c))\n this.model = {\n ...(baseBoard || {}),\n ...(next.width !== undefined && { width: next.width }),\n ...(next.height !== undefined && { height: next.height }),\n components: normalized\n }\n if (patchId && inverseOps.length > 0) {\n this.patchInverses.set(patchId, inverseOps)\n }\n notify('info', '보드 전체가 교체되어 실행 취소(undo) 히스토리가 초기화되었습니다.')\n } catch (ex) {\n notifyError(ex)\n }\n }\n\n // ── C2: board-patch 실시간 구독 (원격 편집을 이 화면에 반영) ─────────────────────\n private async _subscribeBoardPatches(boardId: string) {\n this._unsubscribeBoardPatches()\n try {\n this._patchSub = await subscribe(\n {\n query: gql`\n subscription ($boardId: String!) {\n boardPatchActivity(boardId: $boardId) {\n id\n opsJson\n source\n summary\n }\n }\n `,\n variables: { boardId }\n },\n { next: ({ data }: any) => this._onRemotePatch(data?.boardPatchActivity) }\n )\n } catch (ex) {\n // 구독 실패 시 협업만 비활성 — 로컬 편집은 정상.\n notifyError(ex)\n }\n }\n\n private _unsubscribeBoardPatches() {\n try {\n this._patchSub?.unsubscribe()\n } catch {\n /* ignore */\n }\n this._patchSub = undefined\n }\n\n /**\n * 원격 patch 도착 — apply-once 게이트 통과 시 in-place 적용. 자기발신 echo 는 게이트가 차단\n * (로컬 onSceneEditPatch 가 이미 같은 patchId 를 claim). 원격분은 revert 인버스 미보관(프로토타입).\n */\n private _onRemotePatch(entry: any) {\n if (!entry?.id) return\n if (!this._patchGate.tryClaim(entry.id)) return\n // server PatchEntry.opsJson 은 GraphQLJSON — 이미 parsed SceneEditOp[] 로 도착(추가 parse 불필요).\n const ops: SceneEditOp[] = Array.isArray(entry.opsJson) ? entry.opsJson : []\n if (!ops.length) return\n const scene = this.scene as any\n if (!scene) return // scene 준비 전 도착분 드롭 (프로토타입 — 큐잉 미지원)\n\n const patch: SceneEditPatch = { ops, summary: entry.summary, confidence: 0 } as SceneEditPatch\n if (ops.some(op => op.op === 'replace')) {\n this.applyPatchWholesale(patch)\n this._syncedModel = this.getLiveBoard() // baseline 동기 — 원격 변경 재캡처 방지\n return\n }\n const normalize = (c: any) => this.normalizeComponent(c)\n for (const op of ops) {\n // echo 안전(멱등): 이미 존재하는 refid 의 add 는 skip. 내 직접편집 echo 가 게이트 claim\n // 보다 먼저 도착해도 중복 생성 안 됨. (modify/remove 는 본래 멱등)\n if (\n op.op === 'add' &&\n (op as any).component?.refid != null &&\n findSceneComponent(scene, { refid: (op as any).component.refid })\n ) {\n continue\n }\n try {\n dispatchSceneEditOp(scene, op, { normalize })\n } catch (ex) {\n notifyError(ex)\n }\n }\n this._syncedModel = this.getLiveBoard() // 원격 변경을 baseline 에 반영 (다음 저장서 재캡처 방지)\n }\n\n /**\n * 채팅에서 board-edit-revert 도착 — 누적된 inverse 를 역순 in-place 적용.\n *\n * - 메모리상 patchInverses Map 만 본다. 페이지 reload 후엔 inverse 가 없어\n * 되돌릴 수 없음 (사용자에게 안내).\n * - 성공 시 서버 revertPatch mutation 호출 → PatchEntry.reverted=true 영속.\n * - in-place 적용이라 undo/dirty/selection 보존 (chatViaTools 의 모든 강점 그대로).\n */\n private onBoardEditRevert = async (e: CustomEvent) => {\n const { patchId } = e.detail || {}\n if (!patchId) return\n const inverses = this.patchInverses.get(patchId)\n if (!inverses || inverses.length === 0) {\n notify(\n 'warn',\n '이 변경은 자동 되돌릴 수 없습니다 (페이지 새로고침 이후 적용된 변경은 메모리에 inverse 가 없습니다).'\n )\n return\n }\n\n const scene = this.scene as any\n if (!scene) {\n notifyError(new Error('Scene not initialized'))\n return\n }\n\n try {\n // 역순 적용 — 마지막 op 부터 되돌림. 단일 patch 안에서도 순서 의미 있음\n // (예: add 후 modify 한 시퀀스를 되돌리려면 modify(원본) 후 remove)\n const reversed = [...inverses].reverse()\n const reverseFakePatch: SceneEditPatch = {\n ops: reversed,\n summary: 'revert',\n confidence: 1\n }\n // hasReplace 면 wholesale, 그렇지 않으면 in-place — 일반 onSceneEditPatch 와 동일\n const hasReplace = reversed.some(op => op.op === 'replace')\n if (hasReplace) {\n this.applyPatchWholesale(reverseFakePatch)\n } else {\n // in-place 직접 적용 — 새 inverse 누적은 안 함 (revert 의 revert 는 redo, 별개 기능)\n this.applyInverseOpsInPlace(scene, reversed)\n }\n\n this.patchInverses.delete(patchId)\n await this.recordRevertOnServer(patchId)\n } catch (ex) {\n notifyError(ex)\n }\n }\n\n /**\n * inverse op 시퀀스를 things-scene 위에 in-place 적용 (snapshot/undo 보존).\n * dispatcher 재사용 — inverse 누적은 무시 (revert 의 revert 는 redo, 별개 기능).\n */\n private applyInverseOpsInPlace(scene: any, ops: SceneEditOp[]): void {\n const normalize = (c: any) => this.normalizeComponent(c)\n for (const op of ops) {\n dispatchSceneEditOp(scene, op, { normalize })\n }\n }\n\n /** 서버 PatchEntry.reverted=true 영속 — fail 해도 UI 는 이미 되돌렸으니 warn 만. */\n private async recordRevertOnServer(patchId: string): Promise<void> {\n try {\n await client.mutate({ mutation: REVERT_PATCH_MUTATION, variables: { patchId } })\n } catch (e: any) {\n console.warn('[board-modeller] revertPatch server persist failed:', e?.message ?? e)\n }\n }\n\n /**\n * AI 가 ephemeral scene action (selection / view / mode) 을 실행하라고 요청.\n *\n * scene-edit-patch 와 별개 채널 — 모델 변경 X, undo 영향 X, dirty flag 무관.\n * things-scene API 직접 호출. 잘못된 action / 누락된 컴포넌트는 console.warn 만.\n */\n private onSceneActionExecute = (e: CustomEvent) => {\n const { actions } = e.detail || {}\n if (!Array.isArray(actions) || actions.length === 0) return\n const scene = this.scene as any\n if (!scene) return\n\n let modeChanged = false\n for (const action of actions) {\n try {\n dispatchSceneAction(scene, action)\n if (action?.action === 'setSceneMode') modeChanged = true\n } catch (ex: any) {\n console.warn('[board-modeller] action execute failed:', action, ex?.message ?? ex)\n }\n }\n // setSceneMode 가 있었으면 page 의 reactive mode 도 동기 (Lit re-render 트리거)\n if (modeChanged) this.mode = scene.mode\n }\n\n /**\n * AI 가 만든 컴포넌트를 things-scene 이 기대하는 완전한 형태로 normalize.\n * BoardModeller 에 등록된 template.model (default 값) 위에 AI 응답을 덮어쓴다.\n * 이 단계 없이 things-scene 에 넣으면 필수 속성 누락 시 render 에서 crash 가능\n * (예: gauge-circle 의 value 가 undefined → toString() TypeError).\n */\n private normalizeComponent(c: any): any {\n if (!c || typeof c !== 'object' || typeof c.type !== 'string') return c\n const template = this.findTemplateByType(c.type)\n if (!template || !template.model) return c\n return mergeDefaultsDeep(template.model, c)\n }\n\n private findTemplateByType(type: string): any {\n for (const group of BoardModeller.groups || []) {\n for (const t of group.templates || []) {\n if (t && t.type === type) return t\n }\n }\n return undefined\n }\n\n async updated(changes) {\n if (changes.has('boardId')) {\n try {\n /* The same rule as the board's own save door (board-service): a domain owner edits without a role. */\n if (await hasPrivilege({ privilege: 'mutation', category: 'board', domainOwnerGranted: true })) {\n this.refresh()\n // C2: 보드 변경 시 그 보드의 실시간 patch 구독 (이전 보드 구독은 해제).\n if (this.boardId) this._subscribeBoardPatches(this.boardId)\n else this._unsubscribeBoardPatches()\n } else {\n this.boardId = null\n this.model = null\n this.modeller?.close()\n this._unsubscribeBoardPatches()\n }\n } catch {\n this.boardId = null\n this.model = null\n this.modeller?.close()\n this._unsubscribeBoardPatches()\n }\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this._unsubscribeBoardPatches()\n clearAssistantSurface(this)\n }\n\n /**\n * This board, told to the framework's AI dock (design/ai/shared-dock.md §3). The dock owns the\n * conversation - sessions, modes, the manager - and hands the chat's scene edits back to this page.\n * Decided 2026-09-25: the modeller no longer carries its own \"AI\" button and panel; the band's forum\n * button opens the same dock as every other screen.\n */\n private provideAssistantBoard() {\n if (!this.boardId) return\n const boardId = this.boardId\n provideAssistantSurface(this, {\n key: `board:${boardId}`,\n subject: 'board',\n icon: 'dashboard',\n label: () => this.boardName || i18next.t('text.ai_assistant'),\n detail: () => i18next.t('label.board', { defaultValue: 'board' }),\n anchor: () => ({ anchorType: 'board', anchorId: boardId }),\n sessionChanged: sessionId => (this.chatSessionId = sessionId || undefined),\n board: {\n chatEndpoint: 'boardAIChat',\n currentBoard: () => this.model,\n boardProvider: () => this.getLiveBoard(),\n selectedRefids: () => this.extractSelectedRefids(),\n knownTypes: () => this.knownTypes,\n categories: () => this.knownCategories,\n componentSchemas: () => this.componentSchemas,\n searchProvider: this.searchSceneForMention,\n applyPatch: (detail: any) => {\n /* The modeller tells the person which ops missed itself, so the dock is told none to repeat. */\n this.onSceneEditPatch(new CustomEvent('scene-edit-patch', { detail }))\n return { applied: 0, missed: 0 }\n },\n revertPatch: (patchId: string) => this.onBoardEditRevert(new CustomEvent('board-edit-revert', { detail: { patchId } })),\n applyAction: (detail: any) => this.onSceneActionExecute(new CustomEvent('scene-action-execute', { detail }))\n }\n })\n }\n\n pageUpdated(changes, lifecycle) {\n if (this.active) {\n getModellerToolbarMode().then(mode => (this.toolbarMode = mode))\n }\n\n if (this.active) {\n this.boardId = lifecycle.resourceId\n } else {\n clearAssistantSurface(this)\n this.boardId = null\n this.board = null\n this.model = null\n this.preparing = false\n this.modeller?.close()\n this._unsubscribeBoardPatches()\n this.updateContext()\n }\n }\n\n render() {\n const oops = !this.preparing && !this.model && this.oopsNote\n\n return html`\n <div class=\"modeller-area\">\n ${oops\n ? html`<ox-oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></ox-oops-note>`\n : html`\n <ox-board-modeller\n .boardName=${this.boardName || ''}\n .contextualToolbar=${this.toolbarMode !== 'toolbar'}\n .contextualToolbarPlacement=${this.toolbarMode === 'docked' ? 'docked' : 'floating'}\n .mode=${this.mode}\n .loadTracker=${this._loadTracker}\n @mode-changed=${e => {\n this.mode = e.detail.value\n }}\n .model=${this.model}\n @model-changed=${e => {\n this.model = e.detail.value\n }}\n .scene=${this.scene}\n @scene-changed=${e => {\n this.scene = e.detail.value\n this._watchScene(this.scene)\n }}\n .selected=${this.selected}\n @selected-changed=${e => {\n this.selected = e.detail.value\n }}\n .provider=${provider}\n @save-model=${e => this.saveBoard()}\n .componentGroupList=${this.componentGroupList}\n .fonts=${this._fontCtrl.fonts}\n .hideProperty=${this.hideProperty}\n >\n </ox-board-modeller>\n `}\n ${this.scene && boardPlacementProvider()\n ? html`<board-placement-tray .boardId=${this.boardId} .scene=${this.scene}></board-placement-tray>`\n : nothing}\n </div>\n `\n }\n\n /** Saves the board; true when the server took it. A failure is told to the person and answered false. */\n async updateBoard(): Promise<boolean> {\n try {\n this.preparing = true\n\n const { id, name, description, groupId } = this.board\n const model = JSON.stringify(this.scene.model)\n /* Saved only over the save this edit began from (ADR-0098); someone else's newer save is refused. */\n const expectedUpdatedAt = this.draftBase ?? this.savedAt\n\n const response = await client.mutate({\n mutation: gql`\n mutation UpdateBoard($id: String!, $patch: BoardPatch!) {\n updateBoard(id: $id, patch: $patch) {\n id\n updatedAt\n }\n }\n `,\n variables: {\n id,\n patch: { name, description, model, groupId, ...(expectedUpdatedAt ? { expectedUpdatedAt } : {}) }\n },\n context: gqlContext()\n })\n\n /*\n * A refusal (saved elsewhere since) arrives as an error, already told to the person by the client's\n * error link - not told again here. Not saved: the draft stays, nothing below runs.\n */\n if ((response as any).errors?.length) return false\n this.savedAt = (response as any).data?.updateBoard?.updatedAt ?? this.savedAt\n this.restoredDraft = false\n this.draftBase = null\n await this.drafts.settled()\n\n notify('info', i18next.t('text.saved'))\n return true\n } catch (ex) {\n notifyError(ex)\n return false\n } finally {\n this.preparing = false\n this.updateContext()\n }\n }\n\n async saveBoard() {\n /*\n * Marked saved only when it was. preserve() ran after a failed save too, so the modeller counted the\n * edit as kept and leaving the page no longer asked - the edit was lost without a word.\n */\n if (!(await this.updateBoard())) return\n this.modeller?.preserve()\n // C3: 저장 후(이산적·사용자 의도) 직접편집을 ops 로 캡처해 방송. best-effort —\n // 실패해도 저장 자체엔 영향 없음(이미 완료). (라이브 per-edit 동기화는 C3c 후보.)\n this._captureDirectEdits()\n }\n\n /**\n * C3: 마지막 동기 모델 → 현재 모델 diff 를 recordDirectPatch 로 기록(=같은 board 구독자 방송).\n * 반환된 patchId 를 게이트에 claim → 자기발신 echo skip. baseline 갱신.\n * sessionId 없으면(AI 세션 미연결) skip — 협업 비활성, 편집은 정상.\n */\n private async _captureDirectEdits() {\n try {\n if (!this.chatSessionId) return\n const current = this.getLiveBoard()\n if (!current) return\n if (!this._syncedModel) {\n this._syncedModel = current // 첫 저장 = baseline 확립 (이전 상태 미상이라 방송 안 함)\n return\n }\n const ops = diffBoardModel(this._syncedModel, current)\n this._syncedModel = current\n if (ops.length === 0) return\n\n const res = await client.mutate({\n mutation: gql`\n mutation RecordDirectPatch($sessionId: String!, $ops: JSON!, $summary: String) {\n recordDirectPatch(sessionId: $sessionId, ops: $ops, summary: $summary) {\n id\n }\n }\n `,\n variables: { sessionId: this.chatSessionId, ops, summary: `직접 편집 ${ops.length}건` },\n context: gqlContext()\n })\n const id = res?.data?.recordDirectPatch?.id\n if (id) this._patchGate.tryClaim(id) // 내 직접편집의 broadcast echo 차단\n } catch (ex) {\n notifyError(ex)\n }\n }\n\n async canDeactivate(): Promise<boolean> {\n if (this.unsaved()) {\n const leave = await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('prompt.sure to navigate away?'),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n /* Leaving without saving, chosen: nothing to keep (ADR-0098 decision 3). */\n if (leave) await this.drafts.settled()\n return leave\n }\n\n return true\n }\n}\n"]}
|