@dsmm/dsmm 0.3.13 → 0.3.14

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.
@@ -79,11 +79,12 @@ export function hasExplicitModelOverride(roleId, doc) {
79
79
  return true;
80
80
  return false;
81
81
  }
82
- export function ProfileModelsDialog({ open, onClose, state, actions, disabled, document: doc, isInvalidProjection, triggerRef, targetRoleId, targetField, onTargetLocated, onJumpToJsonc, t, }) {
82
+ export function ProfileModelsDialog({ open, onClose, state, actions, disabled, document: doc, isInvalidProjection, triggerRef, targetRoleId, targetField, onTargetLocated, onJumpToJsonc, canSave: canSaveProp, t, }) {
83
83
  const prefix = useId();
84
84
  const [searchQuery, setSearchQuery] = useState("");
85
85
  const [filterExplicitOnly, setFilterExplicitOnly] = useState(false);
86
86
  const pendingFallbackFocusRef = useRef(null);
87
+ const dialogTopBarRef = useRef(null);
87
88
  const wasOpenRef = useRef(open);
88
89
  useEffect(() => {
89
90
  if (wasOpenRef.current && !open) {
@@ -226,6 +227,8 @@ export function ProfileModelsDialog({ open, onClose, state, actions, disabled, d
226
227
  const roles = state.snapshot?.roles ?? [];
227
228
  const effectiveDisabled = disabled || isInvalidProjection || doc === null;
228
229
  const baseline = state.snapshot?.editorDefaults;
230
+ const canSave = canSaveProp ?? (!disabled && !isInvalidProjection && doc !== null && state.dirty && state.snapshot !== null && state.invalidFields.length === 0);
231
+ const isSaveLocked = (state.dirty || state.invalidFields.length > 0) && !disabled && doc !== null && state.snapshot !== null && (state.invalidFields.length > 0 || Boolean(isInvalidProjection));
229
232
  const filteredRoles = roles.filter((role) => {
230
233
  if (searchQuery.trim()) {
231
234
  const q = searchQuery.trim().toLowerCase();
@@ -240,7 +243,39 @@ export function ProfileModelsDialog({ open, onClose, state, actions, disabled, d
240
243
  }
241
244
  return true;
242
245
  });
243
- return (_jsxs(Modal, { open: open, onClose: onClose, title: t("modelsDialogTitle"), description: t("modelsDialogDesc"), closeLabel: t("cancel"), className: "dsmm-profile-models-dialog", contentClassName: "dsmm-profile-models-dialog-content", onKeyDownCapture: handleKeyDownCapture, children: [_jsxs("div", { className: "dsmm-models-filter-bar dsmm-dialog-filter-bar", children: [_jsx("div", { className: "dsmm-field dsmm-filter-search", children: _jsx(Input, { id: `${prefix}-role-search`, className: "dsmm-input", type: "search", value: searchQuery, placeholder: t("searchRolesPlaceholder"), disabled: effectiveDisabled, onChange: (e) => setSearchQuery(e.currentTarget.value), "data-dsmm-role-search": true, "data-modal-autofocus": true }) }), _jsxs("label", { className: "dsmm-filter-label dsmm-filter-override-toggle", children: [_jsx("input", { type: "checkbox", checked: filterExplicitOnly, disabled: effectiveDisabled, onChange: (e) => setFilterExplicitOnly(e.currentTarget.checked), "data-dsmm-filter-overrides": true }), _jsx("span", { children: t("filterExplicitOverrides") })] })] }), state.issue !== null && (_jsxs("div", { className: "dsmm-issue dsmm-dialog-issue", role: "region", "aria-label": t("savedInventory"), children: [_jsx("p", { className: "dsmm-dialog-issue-title", children: t(issueKey(state.issue)) }), _jsx(IssueDetails, { issue: state.issue, t: t }), onJumpToJsonc && (_jsx("div", { className: "dsmm-dialog-issue-action", children: _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onJumpToJsonc, children: t("jumpToJsonc") }) }))] })), doc === null && (_jsxs("div", { className: "dsmm-structured-invalid", "data-dsmm-structured-invalid": true, children: [_jsx("p", { children: t("rawInvalid") }), _jsx("p", { className: "dsmm-hint", children: t("rawInvalidFormDisabled") }), onJumpToJsonc && (_jsx(Button, { type: "button", variant: "outline", onClick: onJumpToJsonc, children: t("viewConfiguration") }))] })), doc !== null && (_jsxs("div", { className: "dsmm-roles-list dsmm-dialog-roles-list", children: [filteredRoles.length === 0 && (_jsx("p", { className: "dsmm-hint dsmm-no-roles", children: t("noMatchingRoles") })), filteredRoles.map((role) => {
246
+ useEffect(() => {
247
+ if (!open)
248
+ return;
249
+ const el = dialogTopBarRef.current;
250
+ if (!el)
251
+ return;
252
+ const parent = el.closest(".dsmm-profile-models-dialog-content");
253
+ const update = () => {
254
+ const height = el.offsetHeight;
255
+ if (parent) {
256
+ parent.style.setProperty("--dsmm-dialog-bar-offset", `${height}px`);
257
+ }
258
+ };
259
+ update();
260
+ if (typeof ResizeObserver !== "undefined") {
261
+ const ro = new ResizeObserver(update);
262
+ ro.observe(el);
263
+ return () => {
264
+ ro.disconnect();
265
+ if (parent) {
266
+ parent.style.removeProperty("--dsmm-dialog-bar-offset");
267
+ }
268
+ };
269
+ }
270
+ return () => {
271
+ if (parent) {
272
+ parent.style.removeProperty("--dsmm-dialog-bar-offset");
273
+ }
274
+ };
275
+ }, [open, state.dirty, isSaveLocked, state.busy]);
276
+ return (_jsxs(Modal, { open: open, onClose: onClose, title: t("modelsDialogTitle"), description: t("modelsDialogDesc"), closeLabel: t("cancel"), className: "dsmm-profile-models-dialog", contentClassName: "dsmm-profile-models-dialog-content", onKeyDownCapture: handleKeyDownCapture, children: [_jsxs("div", { ref: dialogTopBarRef, className: "dsmm-dialog-top-bar", children: [_jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: !canSave, onClick: () => { void actions.save(); }, children: t(state.busy === "save" ? "saving" : "save") }), _jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: t("cancel") })] }), state.busy === "save" ? (_jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: t("saving") })) : state.dirty ? (_jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: t("dirty") })) : null, isSaveLocked && (_jsx("div", { className: "dsmm-save-lock-reason", role: "status", children: _jsx("span", { className: "dsmm-save-lock-text", children: isInvalidProjection
277
+ ? t("rawInvalid")
278
+ : t("saveLockedReason", { count: state.invalidFields.length }) }) }))] }), _jsxs("div", { className: "dsmm-models-filter-bar dsmm-dialog-filter-bar", children: [_jsx("div", { className: "dsmm-field dsmm-filter-search", children: _jsx(Input, { id: `${prefix}-role-search`, className: "dsmm-input", type: "search", value: searchQuery, placeholder: t("searchRolesPlaceholder"), disabled: effectiveDisabled, onChange: (e) => setSearchQuery(e.currentTarget.value), "data-dsmm-role-search": true, "data-modal-autofocus": true }) }), _jsxs("label", { className: "dsmm-filter-label dsmm-filter-override-toggle", children: [_jsx("input", { type: "checkbox", checked: filterExplicitOnly, disabled: effectiveDisabled, onChange: (e) => setFilterExplicitOnly(e.currentTarget.checked), "data-dsmm-filter-overrides": true }), _jsx("span", { children: t("filterExplicitOverrides") })] })] }), state.issue !== null && (_jsxs("div", { className: "dsmm-issue dsmm-dialog-issue", role: "region", "aria-label": t("savedInventory"), children: [_jsx("p", { className: "dsmm-dialog-issue-title", children: t(issueKey(state.issue)) }), _jsx(IssueDetails, { issue: state.issue, t: t }), onJumpToJsonc && (_jsx("div", { className: "dsmm-dialog-issue-action", children: _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onJumpToJsonc, children: t("jumpToJsonc") }) }))] })), doc === null && (_jsxs("div", { className: "dsmm-structured-invalid", "data-dsmm-structured-invalid": true, children: [_jsx("p", { children: t("rawInvalid") }), _jsx("p", { className: "dsmm-hint", children: t("rawInvalidFormDisabled") }), onJumpToJsonc && (_jsx(Button, { type: "button", variant: "outline", onClick: onJumpToJsonc, children: t("viewConfiguration") }))] })), doc !== null && (_jsxs("div", { className: "dsmm-roles-list dsmm-dialog-roles-list", children: [filteredRoles.length === 0 && (_jsx("p", { className: "dsmm-hint dsmm-no-roles", children: t("noMatchingRoles") })), filteredRoles.map((role) => {
244
279
  const policy = doc.roleRouting[role.id] ?? {};
245
280
  const rolePath = ["settings", "roleRouting", role.id];
246
281
  const isOrchestrator = role.id === "dsmm-orchestrator";
@@ -42,6 +42,7 @@ export function ProfilesSection(props) {
42
42
  const hadConfirmation = useRef(false);
43
43
  const initiatorRef = useRef(null);
44
44
  const dialogInitiatorRef = useRef(null);
45
+ const saveBarRef = useRef(null);
45
46
  const orchestratorRef = useRef(null);
46
47
  const sessionScopeRef = useRef(null);
47
48
  const [modelsDialogOpen, setModelsDialogOpen] = useState(false);
@@ -68,6 +69,7 @@ export function ProfilesSection(props) {
68
69
  }
69
70
  const basicDoc = structuredDoc ?? (lastValidBasicDocRef.current !== null && lastValidBasicDocRef.current.id === editor?.id && lastValidBasicDocRef.current.epoch === state.editorEpoch ? lastValidBasicDocRef.current.doc : null);
70
71
  const rawInvalid = editor !== null && structuredDoc === null;
72
+ const canSave = !editorDisabled && state.dirty && snapshot !== null && state.invalidFields.length === 0 && !rawInvalid;
71
73
  function focusJsonc(location) {
72
74
  if (advancedRef.current !== null) {
73
75
  advancedRef.current.open = true;
@@ -183,6 +185,34 @@ export function ProfilesSection(props) {
183
185
  else if (snapshot?.selectedId !== null && snapshot?.selectedId !== undefined)
184
186
  selection = t("appliedProfile", { id: snapshot.selectedId, revision: t(configurationVersionState(snapshot.sourceRevision)) });
185
187
  const notice = state.notice === null ? "" : t(state.notice.key === "reset" ? "resetDone" : state.notice.key, { id: state.notice.id });
188
+ useEffect(() => {
189
+ const el = saveBarRef.current;
190
+ if (!el)
191
+ return;
192
+ const parent = el.closest(".dsmm-editor");
193
+ const update = () => {
194
+ const height = el.offsetHeight;
195
+ if (parent) {
196
+ parent.style.setProperty("--dsmm-save-bar-offset", `${height}px`);
197
+ }
198
+ };
199
+ update();
200
+ if (typeof ResizeObserver !== "undefined") {
201
+ const ro = new ResizeObserver(update);
202
+ ro.observe(el);
203
+ return () => {
204
+ ro.disconnect();
205
+ if (parent) {
206
+ parent.style.removeProperty("--dsmm-save-bar-offset");
207
+ }
208
+ };
209
+ }
210
+ return () => {
211
+ if (parent) {
212
+ parent.style.removeProperty("--dsmm-save-bar-offset");
213
+ }
214
+ };
215
+ }, [editor?.id, state.dirty, state.invalidFields.length, rawInvalid, invalid]);
186
216
  const warnings = editor === null ? [] : draftWarnings(editor.content);
187
217
  return _jsxs("section", { className: "dsmm-profiles dsmm-named-profiles", "aria-label": t("title"), "aria-busy": state.busy !== null, children: [readOnly && _jsx("p", { role: "status", className: "dsmm-hint", children: t("readOnlyOrigin") }), _jsx("h2", { children: t("title") }), _jsx("p", { className: "dsmm-hint", children: t("description") }), _jsxs("div", { className: "dsmm-browse-row", children: [snapshot !== null && _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-select`, children: t("editorSelect") }), _jsxs("select", { ref: selectRef, id: `${prefix}-select`, disabled: disabled, value: editor?.revision == null ? "" : editor.id, onChange: (event) => { initiatorRef.current = event.currentTarget; if (event.currentTarget.value)
188
218
  void props.open(event.currentTarget.value); }, children: [_jsx("option", { value: "", children: t(editor?.revision === null ? "newDraft" : "choose") }), snapshot.profiles.map((profile, index) => _jsxs("option", { value: profile.id, children: [profile.label?.trim() ? `${profile.label} (${profile.id})` : profile.id, profile.error === undefined ? "" : ` — ${t("invalidProfile", { id: profile.id })}`, profile.warnings?.length ? ` — ${t("warningProfile")}` : ""] }, `${index}:${profile.id}`))] })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || snapshot === null, onClick: (event) => { initiatorRef.current = event.currentTarget; void props.create(); }, children: t("new") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: (event) => { initiatorRef.current = event.currentTarget; void props.refresh(); }, children: t(state.busy === "refresh" ? "refreshing" : "refresh") })] }), editor !== null && _jsx("p", { className: "dsmm-badge", "data-dsmm-editor-state": state.invalidFields.length > 0 || invalid || rawInvalid ? "invalid" : state.dirty ? "dirty" : readOnly ? "readonly" : "ready", children: t(editor.refreshRequired ? "savedRefreshRequired" : state.invalidFields.length > 0 || invalid || rawInvalid ? "validation" : state.dirty ? "dirty" : applied ? "savedApplied" : relationship === "unknown" ? "savedRelationshipUnknown" : "savedNotApplied") })] }), snapshot?.profiles.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("empty") }), snapshot !== null && snapshot.profiles.some(profile => profile.error !== undefined || profile.warnings?.length) && _jsx("ul", { className: "dsmm-profile-list", "aria-label": t("savedInventory"), children: snapshot.profiles.filter(profile => profile.error !== undefined || profile.warnings?.length).map((profile, index) => _jsxs("li", { children: [_jsx("p", { children: profile.label?.trim() ? `${profile.label} (${profile.id})` : profile.id }), _jsx(ProfileWarnings, { warnings: profile.warnings, t: t }), profile.error !== undefined && _jsx(IssueDetails, { issue: profile.error, t: t })] }, `${index}:${profile.id}`)) }), state.pendingEditor !== null && _jsxs("div", { className: "dsmm-confirm", role: "group", "aria-labelledby": `${prefix}-confirm`, onKeyDown: (event) => { if (event.key === "Escape") {
@@ -195,22 +225,7 @@ export function ProfilesSection(props) {
195
225
  }
196
226
  const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
197
227
  sessionScopeRef.current?.scrollIntoView({ behavior: reducedMotion ? "auto" : "smooth" });
198
- }, children: t("locateSessionScope") })] }), _jsx(SessionScopeFeedback, { state: state, t: t }), _jsxs("details", { ref: moreActionsRef, className: "dsmm-more-actions", open: moreActionsOpenRef.current || undefined, onToggle: e => { moreActionsOpenRef.current = e.currentTarget.open; }, children: [_jsx("summary", { children: t("moreActions") }), _jsxs("div", { children: [_jsxs("div", { children: [_jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || !reconcilable || (snapshot?.selectedId === null && !selectionConflict), onClick: () => { void props.reset(); }, children: t(state.busy === "reset" ? "resetting" : "reset") }), _jsx("p", { className: "dsmm-hint", children: t("futureResetHint") })] }), _jsx("div", { ref: sessionScopeRef, children: _jsx(SessionScope, { state: state, actions: props, t: t, showFeedback: false }) })] })] })] }), editor === null && _jsx("p", { className: "dsmm-hint", children: t("noEditor") }), editor !== null && _jsxs("div", { className: "dsmm-editor", children: [warnings.length > 0 && _jsxs("div", { children: [_jsx("p", { children: t("draftWarnings") }), _jsx(ProfileWarnings, { warnings: warnings, t: t })] }), editor.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("savedWarnings") }), _jsx(ProfileWarnings, { warnings: editor.warnings, t: t })] }) : null, _jsxs("div", { className: "dsmm-catalog", children: [state.catalogUnavailable && _jsx("p", { className: "dsmm-hint", children: t("catalogUnavailable") }), state.catalog?.failures.map((failure) => _jsx("p", { className: "dsmm-hint", children: t("catalogFailure", { name: failure.name, id: failure.id }) }, failure.id)), _jsx(Button, { type: "button", variant: "outline", disabled: state.catalogBusy, onClick: () => { void props.refreshCatalog(); }, children: t(state.catalogBusy ? "catalogRefreshing" : "catalogRefresh") })] }), _jsxs("div", { className: "dsmm-basic-settings", "data-dsmm-basic-settings": true, children: [structuredDoc === null && (_jsxs("div", { className: "dsmm-structured-invalid", "data-dsmm-structured-invalid": true, children: [_jsx("p", { children: t("rawInvalid") }), _jsx("p", { className: "dsmm-hint", children: t("rawInvalidFormDisabled") }), _jsx(Button, { type: "button", variant: "outline", onClick: () => {
199
- if (advancedRef.current !== null) {
200
- advancedRef.current.open = true;
201
- jsoncOpenRef.current = true;
202
- }
203
- const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
204
- editorRef.current?.scrollIntoView({ behavior: reducedMotion ? "auto" : "smooth" });
205
- editorRef.current?.focus();
206
- }, children: t("viewConfiguration") })] })), basicDoc !== null && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-label`, children: t("profileLabel") }), _jsx(Input, { ref: labelRef, id: `${prefix}-label`, className: "dsmm-input", value: basicDoc.label ?? "", disabled: editorDisabled || structuredDoc === null, onChange: (event) => props.editPath(["label"], event.currentTarget.value) }), _jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || structuredDoc === null || basicDoc.label === undefined, onClick: () => props.editPath(["label"], undefined), children: t("omitLabel") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-id`, children: t("profileId") }), _jsx(Input, { ref: inputRef, id: `${prefix}-id`, className: "dsmm-input", value: editor.id, disabled: editorDisabled || structuredDoc === null || editor.revision !== null, "aria-invalid": idInvalid || undefined, "aria-describedby": `${prefix}-id-hint${idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editId(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-id-hint`, className: "dsmm-hint", children: t("idHint") })] }), _jsxs("div", { ref: orchestratorRef, className: "dsmm-field", id: `${prefix}-orchestrator-primary`, children: [_jsx("label", { htmlFor: `${prefix}-orch-mode`, children: t("orchestratorModel") }), _jsx("p", { className: "dsmm-hint", children: t("orchestratorModelDesc") }), _jsxs("select", { id: `${prefix}-orch-mode`, disabled: editorDisabled || structuredDoc === null || !hasOrchestrator, "aria-describedby": !hasOrchestrator ? `${prefix}-orch-unavailable` : undefined, value: basicDoc.roleRouting["dsmm-orchestrator"]?.primary === undefined ? "inherit" : "explicit", onChange: (event) => props.editPath(["settings", "roleRouting", "dsmm-orchestrator", "primary"], event.currentTarget.value === "inherit" ? undefined : { provider: "", model: "" }), children: [_jsx("option", { value: "inherit", children: t("inheritRoute") }), _jsx("option", { value: "explicit", children: t("configuredRoute") })] }), !hasOrchestrator && _jsx("p", { className: "dsmm-hint", id: `${prefix}-orch-unavailable`, children: t("orchestratorUnavailable") }), basicDoc.roleRouting["dsmm-orchestrator"]?.primary !== undefined && (_jsx(RouteFields, { t: t, value: basicDoc.roleRouting["dsmm-orchestrator"].primary, path: ["settings", "roleRouting", "dsmm-orchestrator", "primary"], naturalLabels: true, catalog: state.catalog, disabled: editorDisabled || structuredDoc === null || !hasOrchestrator, edit: props.editPath, editRoute: props.editRoute })), _jsx("p", { className: "dsmm-hint", children: t("effortChangeHint") })] }), _jsxs("div", { className: "dsmm-field dsmm-configure-models-field", children: [_jsx("label", { children: t("configureAllAgentModels") }), _jsx("p", { className: "dsmm-hint", children: t("modelsDialogDesc") }), _jsx("div", { children: _jsx(Button, { type: "button", variant: "outline", className: "dsmm-open-models-dialog-btn", disabled: editorDisabled || structuredDoc === null, onClick: (event) => {
207
- dialogInitiatorRef.current = event.currentTarget;
208
- setModelsDialogOpen(true);
209
- }, children: t("configureAllAgentModels") }) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-locale`, children: t("businessLocale") }), _jsxs("select", { id: `${prefix}-locale`, value: String(basicDoc.settings.locale ?? ""), disabled: editorDisabled || structuredDoc === null, "aria-describedby": `${prefix}-locale-hint`, onChange: (event) => props.editPath(["settings", "locale"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inheritLocale") }), typeof basicDoc.settings.locale === "string" && !DSMM_LOCALES.includes(basicDoc.settings.locale) && (_jsx("option", { value: basicDoc.settings.locale, children: t("unsupportedLocale") })), DSMM_LOCALES.map((locale) => (_jsx("option", { value: locale, children: locale }, locale)))] }), _jsx("p", { id: `${prefix}-locale-hint`, className: "dsmm-hint", children: t("localeHint") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-active`, children: t("defaultActive") }), _jsxs("select", { id: `${prefix}-active`, disabled: editorDisabled || structuredDoc === null, value: basicDoc.settings.defaultActive === undefined ? "" : String(basicDoc.settings.defaultActive), onChange: (event) => props.editPath(["settings", "defaultActive"], event.currentTarget.value === "" ? undefined : event.currentTarget.value === "true"), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "true", children: t("enabled") }), _jsx("option", { value: "false", children: t("disabled") })] }), _jsx("p", { className: "dsmm-hint", children: t("activeHint") })] })] }))] }, `basic:${state.editorEpoch}`), _jsxs("details", { ref: advancedSettingsRef, className: "dsmm-advanced-settings", open: advancedOpenRef.current || undefined, onToggle: e => { advancedOpenRef.current = e.currentTarget.open; }, children: [_jsx("summary", { children: t("advancedSettings") }), _jsx("div", { children: _jsx(AdvancedSettings, { state: state, actions: props, disabled: editorDisabled, document: basicDoc, isInvalidProjection: rawInvalid, t: t }) })] }, `advanced-settings:${state.editorEpoch}`), _jsxs("details", { ref: advancedRef, className: "dsmm-advanced", open: jsoncOpenRef.current || undefined, onToggle: e => { jsoncOpenRef.current = e.currentTarget.open; }, children: [_jsx("summary", { children: t("configuration") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-content`, children: t("configuration") }), _jsx("textarea", { ref: editorRef, id: `${prefix}-content`, rows: 12, spellCheck: false, value: editor.content, readOnly: readOnly, disabled: editorDisabled, "aria-invalid": rawInvalid || (invalid && !idInvalid) || undefined, "aria-describedby": `${prefix}-content-hint ${prefix}-structural-hint${invalid && !idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editContent(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-content-hint`, className: "dsmm-hint", children: t("configurationHint") }), _jsx("p", { id: `${prefix}-structural-hint`, className: "dsmm-hint", children: t("structuralHint") })] })] }, `advanced:${state.editorEpoch}`), _jsx(ProfileModelsDialog, { open: modelsDialogOpen, onClose: () => closeModelsDialog("trigger"), state: state, actions: props, disabled: editorDisabled, document: basicDoc, isInvalidProjection: rawInvalid, targetRoleId: targetRole, targetField: targetRoleField, onTargetLocated: () => {
210
- handledValidation.current = state.validationEpoch;
211
- setTargetRole(null);
212
- setTargetRoleField(null);
213
- }, onJumpToJsonc: () => closeModelsDialog("jsonc"), t: t }), _jsxs("div", { className: "dsmm-save-bar", children: [(() => {
228
+ }, children: t("locateSessionScope") })] }), _jsx(SessionScopeFeedback, { state: state, t: t }), _jsxs("details", { ref: moreActionsRef, className: "dsmm-more-actions", open: moreActionsOpenRef.current || undefined, onToggle: e => { moreActionsOpenRef.current = e.currentTarget.open; }, children: [_jsx("summary", { children: t("moreActions") }), _jsxs("div", { children: [_jsxs("div", { children: [_jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || !reconcilable || (snapshot?.selectedId === null && !selectionConflict), onClick: () => { void props.reset(); }, children: t(state.busy === "reset" ? "resetting" : "reset") }), _jsx("p", { className: "dsmm-hint", children: t("futureResetHint") })] }), _jsx("div", { ref: sessionScopeRef, children: _jsx(SessionScope, { state: state, actions: props, t: t, showFeedback: false }) })] })] })] }), editor === null && _jsx("p", { className: "dsmm-hint", children: t("noEditor") }), editor !== null && _jsxs("div", { className: "dsmm-editor", children: [_jsxs("div", { ref: saveBarRef, className: "dsmm-save-bar", children: [_jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: !canSave, onClick: () => { void props.save(); }, children: t(state.busy === "save" ? "saving" : "save") }), _jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || (!state.dirty && state.invalidFields.length === 0), onClick: (event) => { initiatorRef.current = event.currentTarget; props.discard(); }, children: t("discard") }), editor.revision !== null && !state.dirty && _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: (event) => { initiatorRef.current = event.currentTarget; void props.reload(); }, children: t("reload") }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.busy === "refresh" && snapshot === null ? t("loading") : state.busy === "read" ? t("reading") : notice })] }), (() => {
214
229
  const isSaveLocked = (state.dirty || state.invalidFields.length > 0) && !editorDisabled && snapshot !== null && (state.invalidFields.length > 0 || rawInvalid || invalid);
215
230
  if (!isSaveLocked)
216
231
  return null;
@@ -274,6 +289,21 @@ export function ProfilesSection(props) {
274
289
  }
275
290
  }, children: t("jumpToJsonc") }));
276
291
  })()] })] }));
277
- })(), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: editorDisabled || !state.dirty || snapshot === null || state.invalidFields.length > 0 || rawInvalid, onClick: () => { void props.save(); }, children: t(state.busy === "save" ? "saving" : "save") }), _jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || (!state.dirty && state.invalidFields.length === 0), onClick: (event) => { initiatorRef.current = event.currentTarget; props.discard(); }, children: t("discard") }), editor.revision !== null && !state.dirty && _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: (event) => { initiatorRef.current = event.currentTarget; void props.reload(); }, children: t("reload") })] })] })] }), state.issue !== null && !modelsDialogOpen && _jsxs("div", { className: "dsmm-issue", id: `${prefix}-issue`, role: "alert", children: [_jsx("p", { children: t(issueKey(state.issue)) }), _jsx(IssueDetails, { issue: state.issue, t: t })] }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.busy === "refresh" && snapshot === null ? t("loading") : state.busy === "read" ? t("reading") : notice })] });
292
+ })()] }), warnings.length > 0 && _jsxs("div", { children: [_jsx("p", { children: t("draftWarnings") }), _jsx(ProfileWarnings, { warnings: warnings, t: t })] }), editor.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("savedWarnings") }), _jsx(ProfileWarnings, { warnings: editor.warnings, t: t })] }) : null, _jsxs("div", { className: "dsmm-catalog", children: [state.catalogUnavailable && _jsx("p", { className: "dsmm-hint", children: t("catalogUnavailable") }), state.catalog?.failures.map((failure) => _jsx("p", { className: "dsmm-hint", children: t("catalogFailure", { name: failure.name, id: failure.id }) }, failure.id)), _jsx(Button, { type: "button", variant: "outline", disabled: state.catalogBusy, onClick: () => { void props.refreshCatalog(); }, children: t(state.catalogBusy ? "catalogRefreshing" : "catalogRefresh") })] }), _jsxs("div", { className: "dsmm-basic-settings", "data-dsmm-basic-settings": true, children: [structuredDoc === null && (_jsxs("div", { className: "dsmm-structured-invalid", "data-dsmm-structured-invalid": true, children: [_jsx("p", { children: t("rawInvalid") }), _jsx("p", { className: "dsmm-hint", children: t("rawInvalidFormDisabled") }), _jsx(Button, { type: "button", variant: "outline", onClick: () => {
293
+ if (advancedRef.current !== null) {
294
+ advancedRef.current.open = true;
295
+ jsoncOpenRef.current = true;
296
+ }
297
+ const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
298
+ editorRef.current?.scrollIntoView({ behavior: reducedMotion ? "auto" : "smooth" });
299
+ editorRef.current?.focus();
300
+ }, children: t("viewConfiguration") })] })), basicDoc !== null && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-label`, children: t("profileLabel") }), _jsx(Input, { ref: labelRef, id: `${prefix}-label`, className: "dsmm-input", value: basicDoc.label ?? "", disabled: editorDisabled || structuredDoc === null, onChange: (event) => props.editPath(["label"], event.currentTarget.value) }), _jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || structuredDoc === null || basicDoc.label === undefined, onClick: () => props.editPath(["label"], undefined), children: t("omitLabel") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-id`, children: t("profileId") }), _jsx(Input, { ref: inputRef, id: `${prefix}-id`, className: "dsmm-input", value: editor.id, disabled: editorDisabled || structuredDoc === null || editor.revision !== null, "aria-invalid": idInvalid || undefined, "aria-describedby": `${prefix}-id-hint${idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editId(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-id-hint`, className: "dsmm-hint", children: t("idHint") })] }), _jsxs("div", { ref: orchestratorRef, className: "dsmm-field", id: `${prefix}-orchestrator-primary`, children: [_jsx("label", { htmlFor: `${prefix}-orch-mode`, children: t("orchestratorModel") }), _jsx("p", { className: "dsmm-hint", children: t("orchestratorModelDesc") }), _jsxs("select", { id: `${prefix}-orch-mode`, disabled: editorDisabled || structuredDoc === null || !hasOrchestrator, "aria-describedby": !hasOrchestrator ? `${prefix}-orch-unavailable` : undefined, value: basicDoc.roleRouting["dsmm-orchestrator"]?.primary === undefined ? "inherit" : "explicit", onChange: (event) => props.editPath(["settings", "roleRouting", "dsmm-orchestrator", "primary"], event.currentTarget.value === "inherit" ? undefined : { provider: "", model: "" }), children: [_jsx("option", { value: "inherit", children: t("inheritRoute") }), _jsx("option", { value: "explicit", children: t("configuredRoute") })] }), !hasOrchestrator && _jsx("p", { className: "dsmm-hint", id: `${prefix}-orch-unavailable`, children: t("orchestratorUnavailable") }), basicDoc.roleRouting["dsmm-orchestrator"]?.primary !== undefined && (_jsx(RouteFields, { t: t, value: basicDoc.roleRouting["dsmm-orchestrator"].primary, path: ["settings", "roleRouting", "dsmm-orchestrator", "primary"], naturalLabels: true, catalog: state.catalog, disabled: editorDisabled || structuredDoc === null || !hasOrchestrator, edit: props.editPath, editRoute: props.editRoute })), _jsx("p", { className: "dsmm-hint", children: t("effortChangeHint") })] }), _jsxs("div", { className: "dsmm-field dsmm-configure-models-field", children: [_jsx("label", { children: t("configureAllAgentModels") }), _jsx("p", { className: "dsmm-hint", children: t("modelsDialogDesc") }), _jsx("div", { children: _jsx(Button, { type: "button", variant: "outline", className: "dsmm-open-models-dialog-btn", disabled: editorDisabled || structuredDoc === null, onClick: (event) => {
301
+ dialogInitiatorRef.current = event.currentTarget;
302
+ setModelsDialogOpen(true);
303
+ }, children: t("configureAllAgentModels") }) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-locale`, children: t("businessLocale") }), _jsxs("select", { id: `${prefix}-locale`, value: String(basicDoc.settings.locale ?? ""), disabled: editorDisabled || structuredDoc === null, "aria-describedby": `${prefix}-locale-hint`, onChange: (event) => props.editPath(["settings", "locale"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inheritLocale") }), typeof basicDoc.settings.locale === "string" && !DSMM_LOCALES.includes(basicDoc.settings.locale) && (_jsx("option", { value: basicDoc.settings.locale, children: t("unsupportedLocale") })), DSMM_LOCALES.map((locale) => (_jsx("option", { value: locale, children: locale }, locale)))] }), _jsx("p", { id: `${prefix}-locale-hint`, className: "dsmm-hint", children: t("localeHint") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-active`, children: t("defaultActive") }), _jsxs("select", { id: `${prefix}-active`, disabled: editorDisabled || structuredDoc === null, value: basicDoc.settings.defaultActive === undefined ? "" : String(basicDoc.settings.defaultActive), onChange: (event) => props.editPath(["settings", "defaultActive"], event.currentTarget.value === "" ? undefined : event.currentTarget.value === "true"), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "true", children: t("enabled") }), _jsx("option", { value: "false", children: t("disabled") })] }), _jsx("p", { className: "dsmm-hint", children: t("activeHint") })] })] }))] }, `basic:${state.editorEpoch}`), _jsxs("details", { ref: advancedSettingsRef, className: "dsmm-advanced-settings", open: advancedOpenRef.current || undefined, onToggle: e => { advancedOpenRef.current = e.currentTarget.open; }, children: [_jsx("summary", { children: t("advancedSettings") }), _jsx("div", { children: _jsx(AdvancedSettings, { state: state, actions: props, disabled: editorDisabled, document: basicDoc, isInvalidProjection: rawInvalid, t: t }) })] }, `advanced-settings:${state.editorEpoch}`), _jsxs("details", { ref: advancedRef, className: "dsmm-advanced", open: jsoncOpenRef.current || undefined, onToggle: e => { jsoncOpenRef.current = e.currentTarget.open; }, children: [_jsx("summary", { children: t("configuration") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-content`, children: t("configuration") }), _jsx("textarea", { ref: editorRef, id: `${prefix}-content`, rows: 12, spellCheck: false, value: editor.content, readOnly: readOnly, disabled: editorDisabled, "aria-invalid": rawInvalid || (invalid && !idInvalid) || undefined, "aria-describedby": `${prefix}-content-hint ${prefix}-structural-hint${invalid && !idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editContent(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-content-hint`, className: "dsmm-hint", children: t("configurationHint") }), _jsx("p", { id: `${prefix}-structural-hint`, className: "dsmm-hint", children: t("structuralHint") })] })] }, `advanced:${state.editorEpoch}`), _jsx(ProfileModelsDialog, { open: modelsDialogOpen, onClose: () => closeModelsDialog("trigger"), state: state, actions: props, disabled: editorDisabled, document: basicDoc, isInvalidProjection: rawInvalid, targetRoleId: targetRole, targetField: targetRoleField, onTargetLocated: () => {
304
+ handledValidation.current = state.validationEpoch;
305
+ setTargetRole(null);
306
+ setTargetRoleField(null);
307
+ }, onJumpToJsonc: () => closeModelsDialog("jsonc"), canSave: canSave, t: t })] }), state.issue !== null && !modelsDialogOpen && _jsxs("div", { className: "dsmm-issue", id: `${prefix}-issue`, role: "alert", children: [_jsx("p", { children: t(issueKey(state.issue)) }), _jsx(IssueDetails, { issue: state.issue, t: t })] }), editor === null && _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.busy === "refresh" && snapshot === null ? t("loading") : state.busy === "read" ? t("reading") : notice })] });
278
308
  }
279
309
  //# sourceMappingURL=ProfilesSection.js.map
@@ -31,7 +31,7 @@ function menuIssue(issue) {
31
31
  export function SessionScopeFeedback({ state, t }) {
32
32
  const session = state.session;
33
33
  const status = state.sessionNotice === null ? "" : t(state.sessionNotice === "mode-on" ? "headerModeOn" : state.sessionNotice === "mode-off" ? "headerModeOff" : state.sessionNotice === "applied-with-model" ? "sessionAppliedWithModel" : state.sessionNotice === "applied" ? "sessionApplied" : "sessionResetDone");
34
- return _jsxs("div", { "data-dsmm-session-feedback": true, children: [session?.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("admissionWarnings") }), _jsx(ProfileWarnings, { warnings: session.warnings, t: t })] }) : null, state.dirty && _jsx("p", { className: "dsmm-hint", children: t("sessionDirty") }), (session?.refreshRequired || session?.selection.refreshRequired) && _jsx("p", { role: "status", children: t("sessionCommittedRefresh") }), state.sessionUnconfirmed && _jsx("p", { role: "status", children: t("sessionUnconfirmedRefresh") }), state.sessionIssue !== null && _jsxs(_Fragment, { children: [_jsx("p", { role: "alert", children: state.sessionIssue.source === "profile-model" ? t(state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed")
34
+ return _jsxs("div", { "data-dsmm-session-feedback": true, children: [session?.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("admissionWarnings") }), _jsx(ProfileWarnings, { warnings: session.warnings, t: t })] }) : null, state.dirty && _jsx("p", { className: "dsmm-hint", children: t("sessionDirty") }), (session?.refreshRequired || session?.selection.refreshRequired) && _jsx("p", { role: "status", children: t("sessionCommittedRefresh") }), state.sessionUnconfirmed && _jsx("p", { role: "status", children: t(state.sessionIssue?.code === "blank-identity-unconfirmed" ? "sessionPreparationUnknown" : "sessionUnconfirmedRefresh") }), state.sessionIssue !== null && _jsxs(_Fragment, { children: [_jsx("p", { role: "alert", children: state.sessionIssue.source === "profile-model" ? t(state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed")
35
35
  : state.sessionIssue.code === "conflict" ? t("sessionConflict")
36
36
  : ["busy", "maintenance", "disposed", "not-owned"].includes(state.sessionIssue.code) ? t("sessionBusy", { reason: state.sessionIssue.code })
37
37
  : t(state.sessionIssue.code === "validation" ? "validation" : "sessionUnavailable") }), _jsx(IssueDetails, { issue: state.sessionIssue, t: t })] }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.sessionBusy === "read" ? t("reading") : status })] });
@@ -54,7 +54,11 @@ export function SessionScope({ state, actions, t, compact = false, showFeedback
54
54
  catch {
55
55
  binding = undefined;
56
56
  }
57
- return _jsxs("div", { className: "dsmm-session-scope", "aria-busy": state.sessionBusy !== null, "data-dsmm-session-scope": true, children: [!compact && _jsx("h3", { children: t("sessionScope") }), state.currentSessionId === null ? _jsx("p", { className: "dsmm-hint", children: t("sessionChooseWorkspace") }) : _jsxs(_Fragment, { children: [labels !== null && _jsx("p", { "data-dsmm-session-state": true, children: labels.admitted }), labels !== null && !compact && _jsx("p", { className: "dsmm-hint", "data-dsmm-session-future-default": true, children: labels.futureDefault }), session === null && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: t("sessionUnavailable") }), session !== null && !allowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: capabilityReason(session.applyOverlayUnavailableReason, t) }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }), _jsxs("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onChange: (event) => { if (current())
57
+ return _jsxs("div", { className: "dsmm-session-scope", "aria-busy": state.sessionBusy !== null, "data-dsmm-session-scope": true, children: [!compact && _jsx("h3", { children: t("sessionScope") }), state.currentSessionId === null ? _jsxs(_Fragment, { children: [_jsx("p", { className: "dsmm-hint", children: t(state.sessionPreparationAvailable ? "sessionChooseWorkspace" : "sessionPreparationUnavailable") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-workspace`, children: t("sessionWorkspace") }), _jsxs("select", { id: `${prefix}-workspace`, value: state.sessionWorkspaceId ?? "", disabled: !state.sessionPreparationAvailable || disabled, onChange: event => { if (current())
58
+ void actions.chooseSessionWorkspace(event.currentTarget.value); }, children: [_jsx("option", { value: "", children: t("sessionWorkspacePlaceholder") }), state.sessionWorkspaces.map(workspace => _jsx("option", { value: workspace.id, children: workspace.label }, workspace.id))] })] }), state.sessionWorkspaces.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("sessionNoWorkspaces") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }), _jsxs("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: !state.sessionPreparationAvailable || disabled || state.sessionUnconfirmed, onChange: event => { if (current())
59
+ actions.chooseSessionProfile(event.currentTarget.value || null); }, children: [_jsx("option", { value: "", children: t("sessionBaseline") }), state.snapshot?.profiles.map(profile => _jsx("option", { value: profile.id, disabled: !isConfigRevision(profile.revision) || profile.error !== undefined, children: profile.label?.trim() || profile.id }, profile.id))] })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: !state.sessionPreparationAvailable || disabled || state.sessionUnconfirmed || state.snapshot === null, onClick: () => { if (current())
60
+ void actions.applySession(); }, children: t("sessionPrepare") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.sessionBusy !== null || state.busy !== null || state.pendingEditor !== null, onClick: () => { if (current())
61
+ void actions.refreshSession(); }, children: t("sessionRefresh") })] })] }) : _jsxs(_Fragment, { children: [labels !== null && _jsx("p", { "data-dsmm-session-state": true, children: labels.admitted }), labels !== null && !compact && _jsx("p", { className: "dsmm-hint", "data-dsmm-session-future-default": true, children: labels.futureDefault }), session === null && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: t("sessionUnavailable") }), session !== null && !allowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: capabilityReason(session.applyOverlayUnavailableReason, t) }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }), _jsxs("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onChange: (event) => { if (current())
58
62
  actions.chooseSessionProfile(event.currentTarget.value || null); }, children: [_jsx("option", { value: "", children: t("sessionBaseline") }), state.sessionChoice !== null && selected === undefined && _jsx("option", { value: state.sessionChoice, children: state.sessionChoice }), state.snapshot?.profiles.map((profile) => _jsxs("option", { value: profile.id, disabled: !isConfigRevision(profile.revision) || profile.error !== undefined, children: [profile.label?.trim() || profile.id, profileWarnings(profile.warnings).length ? ` — ${t("warningProfile")}` : ""] }, profile.id))] })] }), !compact && _jsxs(_Fragment, { children: [_jsx("p", { className: "dsmm-hint", id: `${prefix}-model-hint`, children: t("useSessionProfileModelDesc") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !modelAllowed, "aria-describedby": `${prefix}-model-hint${!modelAllowed ? ` ${prefix}-model-reason` : ""}`, onClick: () => { if (current())
59
63
  void actions.useSessionProfileModel(); }, children: t("headerUseCurrentModel") }), !modelAllowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-model-reason`, children: capabilityReason(session?.selectModelUnavailableReason, t) }), session !== null && _jsxs("details", { children: [_jsx("summary", { children: t("technicalDetails") }), _jsxs("div", { className: "dsmm-availability", children: [_jsx("p", { children: binding === undefined ? t("bindingUnknown") : t("bindingState", { binding: binding.binding, ready: t(binding.deliveryFenceReady ? "enabled" : "disabled"), restart: t(binding.restartRequired ? "enabled" : "disabled") }) }), binding?.reason !== undefined && _jsx("p", { children: t("bindingReason", { reason: binding.reason }) })] }), session.roles !== undefined && _jsxs("details", { children: [_jsx("summary", { children: t("admittedRoles") }), session.roles.map(role => _jsxs("div", { className: "dsmm-availability", children: [_jsx("p", { children: role.id }), _jsx(RoleAvailability, { value: role, t: t })] }, role.id))] }), session.rolePolicy !== undefined && _jsx("p", { "data-dsmm-session-policy": true, children: t("roleState", { route: session.rolePolicy.route === undefined ? t("inheritRoute") : `${session.rolePolicy.route.provider}/${session.rolePolicy.route.model}${session.rolePolicy.route.reasoningEffort === undefined ? "" : ` (${session.rolePolicy.route.reasoningEffort})`}`, strategy: session.rolePolicy.strategy, retries: session.rolePolicy.retries, failures: session.rolePolicy.rateLimitFailures, switches: session.rolePolicy.switches, delay: session.rolePolicy.totalDelayMs }) })] })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed || (state.sessionChoice !== null && !isConfigRevision(selected?.revision)), "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onClick: () => { if (current())
60
64
  void actions.applySession(); }, children: t(state.sessionBusy === "apply" ? "sessionApplying" : "sessionApply") }), !compact && _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onClick: () => { if (current())
@@ -81,10 +85,11 @@ export function SessionProfiles(props) {
81
85
  const unavailable = id === null || committing || state.busy !== null || state.sessionUnconfirmed || session === null || session.refreshRequired === true || session.selection.refreshRequired === true;
82
86
  const profileDisabled = unavailable || state.pendingEditor !== null || state.dirty || state.invalidFields.length > 0
83
87
  || session === null || !writableSelectionVersion(session.selection.selectionRevision);
84
- const disabled = profileDisabled || session?.canApplyOverlay !== true || session?.applyOverlayUnavailableReason === "new-session-required" || state.snapshot === null;
88
+ const sessionlessDisabled = !state.sessionPreparationAvailable || committing || state.busy !== null || state.sessionUnconfirmed || state.pendingEditor !== null || state.dirty || state.invalidFields.length > 0 || state.snapshot === null;
89
+ const disabled = id === null ? sessionlessDisabled : profileDisabled || session?.canApplyOverlay !== true || session?.applyOverlayUnavailableReason === "new-session-required" || state.snapshot === null;
85
90
  let feedback = "";
86
91
  if (state.sessionUnconfirmed)
87
- feedback = t("sessionUnconfirmedRefresh");
92
+ feedback = t(state.sessionIssue?.code === "blank-identity-unconfirmed" ? "sessionPreparationUnknown" : "sessionUnconfirmedRefresh");
88
93
  else if (session?.refreshRequired || session?.selection.refreshRequired)
89
94
  feedback = t("sessionCommittedRefresh");
90
95
  else if (state.sessionIssue !== null)
@@ -97,7 +102,7 @@ export function SessionProfiles(props) {
97
102
  else if (state.dirty || state.invalidFields.length > 0 || state.pendingEditor !== null)
98
103
  feedback = t("headerDraft");
99
104
  else if (id === null)
100
- feedback = t("sessionChooseWorkspace");
105
+ feedback = t(!state.sessionPreparationAvailable ? "sessionPreparationUnavailable" : state.sessionWorkspaceId === null ? "sessionChooseWorkspace" : "sessionPrepareHint");
101
106
  else if (session === null || state.snapshot === null)
102
107
  feedback = t("headerUnavailable");
103
108
  else if (state.sessionNotice !== null)
@@ -125,6 +130,13 @@ export function SessionProfiles(props) {
125
130
  entries.push({ id: admission.selectedId, label: `${admission.selectedId} — ${t("headerSavedUnavailable")}`, disabled: true });
126
131
  if (unknownCaptured)
127
132
  entries.push({ id: "__dsmm_captured_default__", label: t("headerCaptured"), disabled: true });
133
+ if (id === null) {
134
+ entries.push({ type: "separator", id: "@workspace-separator" }, { type: "label", id: "@workspace-heading", text: state.sessionPreparationPending ? t("sessionPendingProfile", { profile: profiles.find(profile => profile.id === state.sessionChoice)?.label?.trim() || state.sessionChoice || t("sessionBaseline") }) : t("sessionWorkspace") });
135
+ for (const workspace of state.sessionWorkspaces)
136
+ entries.push({ id: `@workspace:${workspace.id}`, label: `${workspace.id === state.sessionWorkspaceId ? "✓ " : ""}${workspace.label}`, disabled: !state.sessionPreparationAvailable || state.dirty || state.invalidFields.length > 0 || state.pendingEditor !== null || state.busy !== null });
137
+ if (state.sessionWorkspaces.length === 0)
138
+ entries.push({ type: "label", id: "@no-workspaces", text: t("sessionNoWorkspaces") });
139
+ }
128
140
  entries.push({ type: "separator", id: "@keep-separator" }, { type: "label", id: "@keep-heading", text: t("headerCompactProfiles") }, { id: "", label: t("sessionBaseline"), disabled });
129
141
  if (session !== null && (session.canApplyOverlay !== true || session.applyOverlayUnavailableReason === "new-session-required"))
130
142
  entries.push({ type: "label", id: "@overlay-reason", text: capabilityReason(session.applyOverlayUnavailableReason, t) });
@@ -141,13 +153,17 @@ export function SessionProfiles(props) {
141
153
  if (value === "@refresh") {
142
154
  if (committing || state.busy !== null)
143
155
  return;
144
- void (async () => { await props.refresh(); if (id !== null && props.readProfileView().currentSessionId === id && props.readProfileView().sessionViewEpoch === state.sessionViewEpoch)
156
+ void (async () => { await props.refresh(); if (props.readProfileView().currentSessionId === id && props.readProfileView().sessionViewEpoch === state.sessionViewEpoch)
145
157
  await props.refreshSession(); })();
146
158
  }
147
159
  else {
148
160
  const row = entries.find((entry) => entry.id === value && !("type" in entry));
149
161
  if (row === undefined || !("disabled" in row) || row.disabled)
150
162
  return;
163
+ if (value.startsWith("@workspace:")) {
164
+ void props.chooseSessionWorkspace(value.slice("@workspace:".length));
165
+ return;
166
+ }
151
167
  if (value === "@mode") {
152
168
  if (mode !== undefined)
153
169
  void props.setDeepwork(!mode.active);
@@ -157,6 +173,8 @@ export function SessionProfiles(props) {
157
173
  else {
158
174
  props.chooseSessionProfile(value || null);
159
175
  void props.applySession();
176
+ if (id === null && state.sessionWorkspaceId === null)
177
+ return;
160
178
  }
161
179
  }
162
180
  setOpenFor(undefined);
@@ -259,8 +259,8 @@ export declare const childrenLocaleZh: {
259
259
  pending: string;
260
260
  yes: string;
261
261
  no: string;
262
- activity: string;
263
262
  runtime: string;
263
+ activity: string;
264
264
  refresh: string;
265
265
  images: string;
266
266
  title: string;
@@ -2,13 +2,14 @@ import type { RemoteResult } from "@deepseek-ai/dsh-typert-protocol";
2
2
  import type { HostObservable } from "@deepseek-ai/dsh-client-ui-slots";
3
3
  import type { ConnectionGenerationState } from "@deepseek-ai/dsh-client-connection/client";
4
4
  import type { ComposerBlocks } from "@deepseek-ai/dsh-client-ui-conversation/client";
5
- import type { SessionEventSource } from "@deepseek-ai/dsh-api-session-controller/client";
5
+ import type { SessionEventSource, SessionSnapshot } from "@deepseek-ai/dsh-api-session-controller/client";
6
6
  import type { ModelDirectoryState } from "@deepseek-ai/dsh-client-ui-model-selection/client";
7
7
  import type { DsmmProfilesRemote } from "../profile-remote.js";
8
8
  import type { ProfileDiagnostic, ProfileDiagnosticCode, ProfileDiagnosticLocation, ProfileErrorInfo, ProfileReadResult, ProfileSnapshot } from "../profile-types.js";
9
9
  import type { SessionProfileSnapshot } from "../profile-types.js";
10
10
  import type { ModelCatalog, SessionSelectModelRequest, SessionSelectModelValue } from "@deepseek-ai/dsh-api-session-controller";
11
11
  import type { JsonPath } from "./structured.js";
12
+ import type { ProfileBlankNative, ProfileWorkspace } from "./profile-blank.js";
12
13
  export interface ProfileEditor {
13
14
  id: string;
14
15
  content: string;
@@ -48,6 +49,10 @@ export interface ProfilesViewSnapshot {
48
49
  sessionUnconfirmed: boolean;
49
50
  session: SessionProfileSnapshot | null;
50
51
  sessionChoice: string | null;
52
+ sessionWorkspaces: readonly ProfileWorkspace[];
53
+ sessionWorkspaceId: string | null;
54
+ sessionPreparationAvailable: boolean;
55
+ sessionPreparationPending: boolean;
51
56
  sessionBusy: "read" | "apply" | "reset" | "mode" | null;
52
57
  sessionIssue: ProfilesIssue | null;
53
58
  sessionNotice: "applied" | "reset" | "applied-with-model" | "mode-on" | "mode-off" | null;
@@ -75,6 +80,7 @@ export interface ProfilesActions {
75
80
  refreshCatalog(): Promise<void>;
76
81
  refreshSession(): Promise<void>;
77
82
  chooseSessionProfile(id: string | null): void;
83
+ chooseSessionWorkspace(id: string): Promise<void>;
78
84
  applySession(options?: SessionApplyOptions): Promise<void>;
79
85
  resetSession(): Promise<void>;
80
86
  setDeepwork(active: boolean): Promise<void>;
@@ -107,6 +113,9 @@ export declare class ProfilesController {
107
113
  private generation;
108
114
  private disposed;
109
115
  private sessionGeneration;
116
+ private blankNative;
117
+ private stopWorkspaces;
118
+ private preparation;
110
119
  private pendingSessionSelections;
111
120
  private connection;
112
121
  private connectionBaseline;
@@ -129,6 +138,9 @@ export declare class ProfilesController {
129
138
  private modelEventsWatermark;
130
139
  private modeEventsWatermark;
131
140
  private modeRefreshPending;
141
+ private sessionSource;
142
+ private sessionSourceId;
143
+ private stopSessionSource;
132
144
  private stopModelEvents;
133
145
  private modelInteraction;
134
146
  private modelInteractionSessionId;
@@ -144,11 +156,21 @@ export declare class ProfilesController {
144
156
  dispose(): void;
145
157
  bindConnection(source: ConnectionGenerationState | null): void;
146
158
  private connectionCurrent;
159
+ attachBlankNative(native: ProfileBlankNative | null): void;
160
+ private releasePreparation;
161
+ private cancelPreparation;
162
+ private chooseSessionWorkspace;
163
+ private preparationOwned;
164
+ private preparationCurrent;
165
+ private preparationConfirmed;
166
+ private openPrepared;
167
+ private prepareSession;
147
168
  attachComposerBlocks(blocks: ComposerBlocks | null, reason?: () => string): void;
148
169
  private releaseComposerBlock;
149
170
  private syncComposerBlock;
150
171
  attachModelSelector(remote: ProfileModelSelectorRemote | null): void;
151
172
  attachModelSelectionSource(sessionId: string | null, source: HostObservable<unknown> | null): void;
173
+ attachSessionSource(sessionId: string | null, source: HostObservable<SessionSnapshot> | null): void;
152
174
  attachModelEventSource(sessionId: string | null, source: SessionEventSource | null): void;
153
175
  attachModelInteractionSource(sessionId: string | null, source: ModelInteractionSource | null): void;
154
176
  attachCatalog(remote: ModelCatalogRemote | null): void;