@jini-ai/admin 0.7.3-next.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/core/i18n-common-base.d.ts +443 -1
  3. package/dist/core/i18n-common.js +1 -36
  4. package/dist/core/i18n-types.d.ts +8 -0
  5. package/dist/core/i18n-types.js +2 -0
  6. package/dist/core/manifest/rules.js +1 -2
  7. package/dist/pages/PageEditorChrome.js +1 -1
  8. package/dist/pages/hooks/page-editor-actions.hooks.d.ts +2 -2
  9. package/dist/pages/hooks/page-editor-load.hooks.d.ts +1 -1
  10. package/dist/pages/hooks/page-editor-preview.hooks.d.ts +3 -3
  11. package/dist/pages/hooks/page-editor-recovery.hooks.d.ts +2 -2
  12. package/dist/pages/hooks/page-editor-recovery.hooks.js +1 -1
  13. package/dist/pages/hooks/page-editor-workspace.hooks.d.ts +4 -4
  14. package/dist/pages/lib/page-preview-youtube.js +1 -3
  15. package/dist/pages/lib/prettify-html.js +1 -1
  16. package/dist/pages/page-editor-i18n.d.ts +191 -1
  17. package/dist/pages/page-editor-i18n.js +2 -2
  18. package/dist/pages/page-route-rules.d.ts +3 -2
  19. package/dist/pages/page-route-rules.js +3 -2
  20. package/dist/react/kit-chat-component-types.d.ts +17 -1
  21. package/dist/react/kit-chat-types.d.ts +2 -0
  22. package/dist/screens/auth/auth-i18n.js +1 -1
  23. package/dist/screens/consent/consent-i18n.js +1 -1
  24. package/dist/screens/content-analysis/content-analysis-i18n-rows-rtl-asia.d.ts +2 -1
  25. package/dist/screens/content-analysis/content-analysis-i18n.d.ts +3 -1
  26. package/dist/screens/content-analysis/content-analysis-i18n.js +3 -7
  27. package/dist/screens/email/email-tabs-i18n.d.ts +2 -1
  28. package/dist/screens/email/email-tabs-i18n.js +1 -9
  29. package/dist/screens/media/MediaEditPanel.js +2 -1
  30. package/dist/screens/media/MediaGenerationFacts.d.ts +8 -0
  31. package/dist/screens/media/MediaGenerationFacts.js +10 -0
  32. package/dist/screens/media/hooks/use-media.hooks.js +4 -1
  33. package/dist/screens/media/media-i18n/media-addons-i18n.js +21 -21
  34. package/dist/screens/media/rules.d.ts +7 -0
  35. package/dist/screens/media/rules.js +12 -1
  36. package/dist/screens/menus/hooks/use-menu-editor.hooks.js +1 -1
  37. package/dist/screens/plugins/PluginLists.d.ts +3 -3
  38. package/dist/screens/plugins/PluginLists.js +10 -8
  39. package/dist/screens/plugins/rules.js +4 -10
  40. package/dist/screens/routines/Routines.hooks.js +3 -2
  41. package/dist/screens/sites/AllSitesTab.js +1 -2
  42. package/dist/screens/sites/use-local-sites.hooks.js +4 -3
  43. package/dist/screens/skills/SkillInstallConfirmation.d.ts +1 -1
  44. package/dist/screens/skills/SkillInstallConfirmation.js +9 -4
  45. package/dist/screens/skills/skill-failure.js +4 -1
  46. package/dist/screens/skills/skill-upload.d.ts +10 -0
  47. package/dist/screens/skills/skill-upload.js +27 -9
  48. package/dist/screens/skills/skills-page-dictionary.js +1 -8
  49. package/dist/screens/storage/hooks/use-storage.hooks.js +2 -1
  50. package/dist/screens/storage/storage-screen-bindings.js +1 -1
  51. package/dist/screens/taxonomy/TaxonomyTermList.js +2 -13
  52. package/dist/screens/taxonomy/TermPicker.js +8 -24
  53. package/dist/screens/taxonomy/hooks/use-merge-term-section.hooks.js +0 -2
  54. package/dist/screens/taxonomy/hooks/use-term-detail-panel.hooks.js +0 -2
  55. package/dist/screens/webmcp/webmcp-i18n.js +1 -1
  56. package/dist/security/controllers/root-key-reveal.js +3 -2
  57. package/dist/security/controllers/shared-keys.controller.js +3 -2
  58. package/dist/security/credential-forms.rules.js +4 -1
  59. package/dist/security/host/AccessTokensGroups.js +1 -1
  60. package/dist/security/host/hooks/access-token-actions.d.ts +1 -1
  61. package/dist/security/host/hooks/access-token-actions.js +10 -7
  62. package/dist/security/host/hooks/access-token-add-actions.js +1 -1
  63. package/dist/security/host/hooks/access-token-groups.hooks.js +6 -4
  64. package/dist/security/host/hooks/access-token-refresh.hooks.d.ts +1 -1
  65. package/dist/security/host/hooks/access-token-refresh.hooks.js +4 -3
  66. package/dist/security/host/hooks/access-token-replace-actions.js +1 -1
  67. package/dist/security/host/hooks/access-token-stores.hooks.d.ts +19 -24
  68. package/dist/security/host/hooks/access-token-stores.hooks.js +7 -0
  69. package/dist/security/host/hooks/use-access-tokens.hooks.d.ts +2 -0
  70. package/dist/shell/components/AssistantDock/DockChatPane.d.ts +6 -3
  71. package/dist/shell/components/AssistantDock/DockChatPane.js +5 -2
  72. package/dist/shell/components/AssistantDock/DockCleanupHeader.d.ts +25 -14
  73. package/dist/shell/components/AssistantDock/DockCleanupHeader.js +9 -5
  74. package/dist/shell/components/AssistantDock/DockHeader.d.ts +6 -6
  75. package/dist/shell/components/AssistantDock/DockHeader.js +1 -1
  76. package/dist/shell/components/AssistantDock/assistant-dock-i18n/chat-pane-es-id-de.js +18 -0
  77. package/dist/shell/components/AssistantDock/assistant-dock-i18n/chat-pane-hi-ur-bn.js +18 -0
  78. package/dist/shell/components/AssistantDock/assistant-dock-i18n/chat-pane-hu-fr-uk.js +18 -0
  79. package/dist/shell/components/AssistantDock/assistant-dock-i18n/chat-pane-ja-ko-pl.js +18 -0
  80. package/dist/shell/components/AssistantDock/assistant-dock-i18n/chat-pane-ru-fa-ar.js +18 -0
  81. package/dist/shell/components/AssistantDock/assistant-dock-i18n/chat-pane-tr-th-it.js +18 -0
  82. package/dist/shell/components/AssistantDock/assistant-dock-i18n/chat-pane-zh-cn-zh-tw-pt-br.js +18 -0
  83. package/dist/shell/components/AssistantDock/dock-pane-props.d.ts +4 -1
  84. package/dist/shell/components/AssistantDock/dock-pane-props.js +4 -4
  85. package/dist/shell/components/AssistantDock/hooks/execution-config.hooks.js +3 -1
  86. package/dist/shell/hooks/assistant-chats-port.hooks.d.ts +2 -0
  87. package/dist/shell/hooks/use-conversation-deep-link.js +3 -1
  88. package/dist/shell/hooks/use-desktop-view-release.hooks.js +2 -2
  89. package/dist/shell/lib/addons-routes.js +3 -3
  90. package/dist/shell/lib/browser-stream.js +8 -8
  91. package/dist/shell/lib/descriptor-i18n.js +2 -2
  92. package/dist/sites/transfer/use-export-password.hooks.js +1 -2
  93. package/dist/widgets/react/components/WidgetInstanceNotices.d.ts +1 -1
  94. package/dist/widgets/react/components/WidgetInstanceNotices.js +0 -2
  95. package/dist/widgets/react/hooks/use-widget-instance-editor.hooks.js +1 -1
  96. package/package.json +9 -9
  97. package/src/screens/email/email.css +1 -1
  98. package/src/themes/default/admin.css +3 -0
@@ -103,13 +103,24 @@ export function describeMediaHtmlAttributeError({ error, locale, translate }, _o
103
103
  }
104
104
  return t("'{attribute}' is not an allowed HTML attribute.").replace(ATTRIBUTE_PLACEHOLDER, () => error.attribute);
105
105
  }
106
+ /** Trusted fallback only when the browser supplied no diagnostic; browser errors stay private. */
107
+ export class MediaFileReadFailure extends Error {
108
+ messageKey = "failed to read file";
109
+ constructor({ cause }, _optional = {}) {
110
+ super("failed to read file", { cause });
111
+ this.name = "MediaFileReadFailure";
112
+ }
113
+ }
106
114
  /** Reads a browser `File` into a base64 string (no data: URL prefix).
107
115
  * @param optional.createReader - Builds the reader; defaults to the browser's `FileReader`. */
108
116
  export function readFileAsBase64({ file }, optional = {}) {
109
117
  const createReader = optional.createReader ?? (() => new FileReader());
110
118
  return new Promise((resolve, reject) => {
111
119
  const reader = createReader();
112
- reader.onerror = () => reject(reader.error ?? new Error("failed to read file"));
120
+ reader.onerror = () => {
121
+ const cause = reader.error;
122
+ reject(cause ?? new MediaFileReadFailure({ cause }));
123
+ };
113
124
  reader.onload = () => {
114
125
  const result = String(reader.result ?? "");
115
126
  const commaIndex = result.indexOf(",");
@@ -118,7 +118,7 @@ export function useMenuEditor({ menuId, dependencies: { port, navigate, t, kit,
118
118
  const { menu, title, slug, items, mode, html, original } = state;
119
119
  const pageChoices = useMenuPageChoices({ port, items, useFetchQuery });
120
120
  useMenuLoadEffect({ menuId, isNew, state, loader, navigate, kit });
121
- const { confirmLeave } = useDirtyGuard({ current: { title, slug, items, mode, html }, original }, { host: window, translate: (key) => key });
121
+ const { confirmLeave } = useDirtyGuard({ current: { title, slug, items, mode, html }, original }, { host: window, translate: t });
122
122
  const activeMenuIdRef = useActiveMenuIdRef({ menuId });
123
123
  const { save, saving } = useMenuSave({ state, menuId, isNew, activeMenuIdRef, port, navigate, t, kit, pageChoices });
124
124
  const copyHtmlEmbed = useMenuCopyEmbed({ state, menuId, activeMenuIdRef, clipboard, t, kit });
@@ -17,9 +17,9 @@ export declare function InstalledPluginRows({ hooks, deps, kit, plugins, control
17
17
  /** The Downloaded tab's own row list. Every row carries Remove (confirm-gated, see this file's own
18
18
  * header), usable only when {@link pluginRemoveBlocker} finds no reason `PLUGIN_UNINSTALL` would
19
19
  * refuse; otherwise it is disabled and described by the matching section note. A disabled row
20
- * also gets a direct, unconfirmed Enable. Before the 2026-09-10 fix there was no control anywhere
21
- * on this screen to re-enable a plugin once disabled — including a quarantined one — short of
22
- * removing and reinstalling it.
20
+ * also gets a direct, unconfirmed Enable when the shared activation rule admits it. Before the
21
+ * 2026-09-10 fix there was no control anywhere on this screen to re-enable a plugin once disabled
22
+ * — including a quarantined one — short of removing and reinstalling it.
23
23
  *
24
24
  * Enable is offered regardless of `source`: unlike Remove (irreversibly destructive for a real
25
25
  * on-disk artifact, so a built-in row's Remove stays honestly disabled), turning a plugin back on
@@ -16,9 +16,9 @@ export function InstalledPluginRows({ hooks, deps, kit, plugins, controller, exp
16
16
  /** The Downloaded tab's own row list. Every row carries Remove (confirm-gated, see this file's own
17
17
  * header), usable only when {@link pluginRemoveBlocker} finds no reason `PLUGIN_UNINSTALL` would
18
18
  * refuse; otherwise it is disabled and described by the matching section note. A disabled row
19
- * also gets a direct, unconfirmed Enable. Before the 2026-09-10 fix there was no control anywhere
20
- * on this screen to re-enable a plugin once disabled — including a quarantined one — short of
21
- * removing and reinstalling it.
19
+ * also gets a direct, unconfirmed Enable when the shared activation rule admits it. Before the
20
+ * 2026-09-10 fix there was no control anywhere on this screen to re-enable a plugin once disabled
21
+ * — including a quarantined one — short of removing and reinstalling it.
22
22
  *
23
23
  * Enable is offered regardless of `source`: unlike Remove (irreversibly destructive for a real
24
24
  * on-disk artifact, so a built-in row's Remove stays honestly disabled), turning a plugin back on
@@ -33,8 +33,7 @@ export function DownloadedPluginRows({ hooks, deps, kit, plugins, controller, ex
33
33
  if (handle === undefined)
34
34
  throw new Error(`plugin ${plugin.id} has no row handle`);
35
35
  const removeBlocker = pluginRemoveBlocker(plugin);
36
- const busy = rowSavingId === plugin.id;
37
- const action = DownloadedPluginAction({ plugin, t, locale, onToggleEnabled, onRequestRemove, removeBlocker, busy, deps, kit });
36
+ const action = DownloadedPluginAction({ plugin, t, locale, onToggleEnabled, onRequestRemove, removeBlocker, rowSavingId, deps, kit });
38
37
  return (_jsx(PluginRow, { useAdminLocaleHook: useAdminLocale, plugin: plugin, t: t, expanded: expandedIds.has(plugin.id), onToggleExpanded: () => onToggleExpanded({ id: plugin.id }), agentHandleBase: handle, onInspect: () => controller.onInspectPlugin(plugin.id), ...(plugin.providerSettings ? { onSettings: () => controller.onOpenSettings(plugin.id) } : {}), action: action }, plugin.id));
39
38
  }) }));
40
39
  }
@@ -83,10 +82,13 @@ export const PLUGINS_TAB_PANELS = {
83
82
  add: AddPanel,
84
83
  marketplace: MarketplacePanel,
85
84
  };
86
- function DownloadedPluginAction({ plugin, t, locale, onToggleEnabled, onRequestRemove, removeBlocker, busy, deps, kit }, _optional = {}) {
87
- const { pluginRemoveAriaLabel, pluginToggleAriaLabel } = deps;
85
+ function DownloadedPluginAction({ plugin, t, locale, onToggleEnabled, onRequestRemove, removeBlocker, rowSavingId, deps, kit }, _optional = {}) {
86
+ const { pluginRemoveAriaLabel, pluginToggleAriaLabel, pluginToggleControl } = deps;
88
87
  const { PluginTrashIcon } = kit;
89
- return (_jsxs(_Fragment, { children: [plugin.enabled ? null : (_jsx("button", { type: "button", disabled: busy, onClick: () => onToggleEnabled(plugin), "aria-label": pluginToggleAriaLabel({ plugin, locale }), children: t("Enable") })), _jsx("button", { type: "button", className: "jini-plugin-icon-btn", disabled: removeBlocker !== null || busy, onClick: () => onRequestRemove(plugin), "aria-label": pluginRemoveAriaLabel({ plugin, locale }), "aria-describedby": removeBlocker ? PLUGINS_REMOVE_NOTE_IDS[removeBlocker] : undefined, children: _jsx(PluginTrashIcon, {}) })] }));
88
+ // Downloaded must honor the same activation admission as Installed; invalid packages stay inspectable and removable.
89
+ const control = pluginToggleControl({ plugin, rowSavingId, locale });
90
+ const busy = rowSavingId === plugin.id;
91
+ return (_jsxs(_Fragment, { children: [plugin.enabled || !control.visible ? null : (_jsx("button", { type: "button", disabled: busy || control.disabled, onClick: () => onToggleEnabled(plugin), "aria-label": pluginToggleAriaLabel({ plugin, locale }), children: t("Enable") })), _jsx("button", { type: "button", className: "jini-plugin-icon-btn", disabled: removeBlocker !== null || busy, onClick: () => onRequestRemove(plugin), "aria-label": pluginRemoveAriaLabel({ plugin, locale }), "aria-describedby": removeBlocker ? PLUGINS_REMOVE_NOTE_IDS[removeBlocker] : undefined, children: _jsx(PluginTrashIcon, {}) })] }));
90
92
  }
91
93
  function installedPluginRow({ plugin, controller, expandedIds, onToggleExpanded, focusPluginId, handle, control, t, locale, onToggleEnabled, useAdminLocale, pluginToggleAriaLabel, kit }, _optional = {}) {
92
94
  const { PluginRow } = kit;
@@ -435,24 +435,18 @@ function createAgentPluginDisableRules({ productName, translate: t, agentPluginD
435
435
  * @complexity Time/space: O(1) — one ternary, no iteration.
436
436
  */
437
437
  function buildAgentPluginDisableConfirmCopy(params, { translate = (key) => key } = {}) {
438
- const copy = disableConfirmCopy(params, translate);
438
+ const copy = disableConfirmCopy({ params, translate });
439
439
  // Advisory, like the server's own warning: turning it off still goes ahead if confirmed.
440
440
  if (!params.requiredBy?.length)
441
441
  return copy;
442
442
  return { ...copy, dependents: `${translate("Other enabled plugins rely on it:")} ${params.requiredBy.map((warning) => agentPluginWarningText({ warning, translate })).join("; ")}` };
443
443
  }
444
444
  /** The title and body of {@link buildAgentPluginDisableConfirmCopy}. @complexity O(1). */
445
- function disableConfirmCopy(params, translate) {
445
+ function disableConfirmCopy({ params, translate }, _optional = {}) {
446
446
  const bundledFact = params.origin === "operator-installed" ? "You added this package. Turning it off keeps its files and memory." : `This package ships with ${productName} — it can't be deleted outright, only turned off.`;
447
- if (params.variant === "remove") {
448
- return {
449
- title: `Turn off ${params.name}?`,
450
- body: translate("This turns it off: its skills stop reaching the assistant on the next run, and it drops off the Installed tab. ") +
451
- `${translate("It stays right here on Downloaded and can be enabled again any time.")} ${translate(bundledFact)}`,
452
- };
453
- }
447
+ // Both tabs retain switched-off packages, so either control describes the same reversible change.
454
448
  return {
455
- title: `Disable ${params.name} for this site?`,
449
+ title: params.variant === "remove" ? `Turn off ${params.name}?` : `Disable ${params.name} for this site?`,
456
450
  body: `${translate("Its skills stop reaching the assistant on the next run. The package stays on disk and can be enabled again.")} ${translate(bundledFact)}`,
457
451
  };
458
452
  }
@@ -47,21 +47,22 @@ export function useRoutinesController({ api, visible, focus, timers }, _optional
47
47
  // On a stale write the list is reloaded and the write is NOT sent again: the owner must look first.
48
48
  const write = useCallback(async ({ id, deleting, op }) => {
49
49
  setBusyId(id);
50
+ let ok = false;
50
51
  try {
51
52
  await op();
52
53
  setNotice(null);
53
54
  await refresh();
54
- return true;
55
+ ok = true;
55
56
  }
56
57
  catch (error) {
57
58
  setNotice(noticeFor({ error, deleting }));
58
59
  if (error instanceof RoutinesApiError && error.stale)
59
60
  await refresh();
60
- return false;
61
61
  }
62
62
  finally {
63
63
  setBusyId(null);
64
64
  }
65
+ return ok;
65
66
  }, [refresh]);
66
67
  const save = useCallback(({ draft, row }) => (row === null
67
68
  ? write({ id: "new", deleting: false, op: () => api.create({ draft }) })
@@ -77,9 +77,8 @@ function SitesGrid(props) {
77
77
  oldest: t("Oldest"),
78
78
  name: t("A-Z"),
79
79
  } }), list.visible.length === 0 ? _jsx("p", { className: "jini-sites-empty-lead", children: t("Every site is hidden. Open Hidden to bring one back.") }) : null, _jsx("div", { className: "jini-sites-grid", role: "group", "aria-label": t("Sites"), children: list.visible.map(({ site }) => {
80
+ // The visible list is drawn from the same sites used to build the row handles.
80
81
  const handle = handleOf.get(site.name);
81
- if (handle === undefined)
82
- throw new Error(`site ${site.name} has no card handle`);
83
82
  return _jsx(SiteCardView, { site: site, snapshot: props.snapshot, handle: handle, switchingEnabled: props.switchingEnabled, activatingName: props.activatingName, onActivate: props.onActivate, localSites: props.localSites, list: list, bindings: props, t: t }, site.name);
84
83
  }) })] }));
85
84
  }
@@ -19,11 +19,12 @@ function localActionAllowed({ action, canSwitchNow, enabled, deleteChecked, stop
19
19
  }
20
20
  /** The confirmation body. Stop on the serving site names who takes over and warns about a chat,
21
21
  * so a hand-over never cuts a chat off silently. @complexity O(1). */
22
- function localActionConfirmMessage({ action, name, stopServing, t, deps }) {
22
+ function localActionConfirmMessage({ action, name, stopServing, stopServingTarget, t, deps }) {
23
23
  const message = t(deps.confirmKeys[action]);
24
24
  if (action !== "stop-serving")
25
25
  return message;
26
- const named = interpolate({ template: message, vars: { name, target: stopServing?.target ?? "" } });
26
+ // localActionAllowed admitted Stop only with an available, non-null hand-over target.
27
+ const named = interpolate({ template: message, vars: { name, target: stopServingTarget } });
27
28
  return stopServing?.chatRunning ? `${named} ${t(deps.servingChatWarningKey)}` : named;
28
29
  }
29
30
  /** Whether the host accepted Switch now and is restarting, rather than only saving the default. */
@@ -75,7 +76,7 @@ export function useLocalSites({ port, snapshot, t, deps }, { confirm = nativeCon
75
76
  setBusyName(name);
76
77
  setError(null);
77
78
  try {
78
- if (isConfirmable(action, deps.confirmKeys) && !(await confirm({ message: localActionConfirmMessage({ action, name, stopServing, t, deps }), action })))
79
+ if (isConfirmable(action, deps.confirmKeys) && !(await confirm({ message: localActionConfirmMessage({ action, name, stopServing, stopServingTarget, t, deps }), action })))
79
80
  return;
80
81
  const result = await port.manageLocalSite({ name, action, confirmed: true, checked: checked[name] === true });
81
82
  applyLocalSiteActionResult({ action, name, stopServingTarget }, result, handleSwitchResult);
@@ -6,5 +6,5 @@ export declare function SkillInstallConfirmation({ install, locale, hooks, failu
6
6
  hooks: SkillInstallConfirmationHooks;
7
7
  failureHost: SkillFailureHost;
8
8
  classNames: SkillDialogClassNames;
9
- }): import("react").JSX.Element | null;
9
+ }, _optional?: {}): import("react").JSX.Element | null;
10
10
  //# sourceMappingURL=SkillInstallConfirmation.d.ts.map
@@ -4,14 +4,19 @@ import { agentHandle } from "@jini-ai/core/agent-handles";
4
4
  import { ErrorNotice } from "../../react/kit.js";
5
5
  import { skillFailure } from "./skill-failure.js";
6
6
  /** `locale` is the caller's admin locale (the dock and the Skills page each resolve one); English when omitted. */
7
- export function SkillInstallConfirmation({ install, locale = "en", hooks, failureHost, classNames: cx }) {
7
+ export function SkillInstallConfirmation({ install, locale = "en", hooks, failureHost, classNames: cx }, _optional = {}) {
8
8
  const confirmation = hooks.useSkillInstallConfirmation(install);
9
9
  const tr = createSkillInstallConfirmationTranslator({ locale });
10
- const failure = install.error ? skillFailure({ ...failureHost, error: install.cause ?? new Error(install.error), message: install.error, t: tr }) : null;
10
+ const describeFailure = (message) => skillFailure({ ...failureHost, error: install.cause ?? new Error(message), message, t: tr });
11
11
  // A read failure has no confirmation dialog. Keep it in a compact, dismissible row;
12
12
  // a bare notice inherits the dock's flex: 1 rule and consumes half the transcript.
13
- if (!install.pending)
14
- return install.error ? (_jsxs("div", { className: `${cx.noticeError} jini-skills-install-error`, role: "alert", children: [failure ? _jsx(ErrorNotice, { failure: failure, t: tr, role: "status", className: "jini-skills-install-details" }) : null, _jsx("button", { type: "button", className: cx.buttonSecondary, onClick: install.cancel, "aria-label": tr("Dismiss"), children: tr("Dismiss") })] })) : null;
13
+ if (!install.pending) {
14
+ if (!install.error)
15
+ return null;
16
+ const failure = describeFailure(install.error);
17
+ return (_jsxs("div", { className: `${cx.noticeError} jini-skills-install-error`, role: "alert", children: [_jsx(ErrorNotice, { failure: failure, t: tr, role: "status", className: "jini-skills-install-details" }), _jsx("button", { type: "button", className: cx.buttonSecondary, onClick: install.cancel, "aria-label": tr("Dismiss"), children: tr("Dismiss") })] }));
18
+ }
19
+ const failure = install.error ? describeFailure(install.error) : null;
15
20
  return (_jsx("div", { className: cx.dialogBackdrop, onClick: install.cancel, children: _jsxs("div", { ref: confirmation.dialogRef, className: `${cx.dialog} jini-skills-confirm-dialog`, role: "dialog", "aria-modal": "true", "aria-label": tr("Install skill"), "aria-busy": install.busy, onClick: confirmation.onDialogClick, children: [_jsx("h2", { children: tr("Install skill?") }), _jsx("p", { className: "jini-skills-confirm-source", children: tr(confirmation.source) }), _jsx("p", { children: tr("Review instructions from sources you trust. Installation runs no code.") }), failure ? _jsx(ErrorNotice, { failure: failure, t: tr }) : null, _jsxs("span", { className: cx.editorActions, children: [_jsx("button", { type: "button", className: cx.buttonSecondary, disabled: install.busy, onClick: install.cancel, ...agentHandle({ handle: "skills-install-cancel" }, { role: "button", label: tr("Cancel") }), children: tr("Cancel") }), _jsx("button", { type: "button", className: cx.buttonPrimary, disabled: install.busy, onClick: confirmation.onConfirm, ...agentHandle({ handle: "skills-install-confirm" }, { role: "button", label: tr("Confirm install") }), children: tr("Confirm install") })] })] }) }));
16
21
  }
17
22
  //# sourceMappingURL=SkillInstallConfirmation.js.map
@@ -1,5 +1,6 @@
1
1
  import { formatUserFacingError } from "@jini-ai/core";
2
2
  import {} from '@jini-ai/core/text';
3
+ import { SkillUploadFailure } from "./skill-upload.js";
3
4
  /** Format Skills failures at the admin disclosure boundary, preserving the server incident ID.
4
5
  * @param input Original failure, operation fallback and the current feature translator, plus the host's
5
6
  * transport error class, its error describer and its product redaction options (bound by the host).
@@ -8,7 +9,9 @@ import {} from '@jini-ai/core/text';
8
9
  * @example skillFailure({ error, message: "Could not load skills.", t });
9
10
  */
10
11
  export function skillFailure({ error, message, t, ApiError, describeApiError, redactionOptions }, _options = {}) {
11
- return formatUserFacingError({ message: t(describeApiError({ e: error, fallback: message })),
12
+ // Trust the producer's bounded key, never a browser Error.message that happens to match it.
13
+ const key = error instanceof SkillUploadFailure ? error.messageKey : describeApiError({ e: error, fallback: message });
14
+ return formatUserFacingError({ message: t(key),
12
15
  action: t("Reload skills before trying the change again."), step: "skills", cause: error }, { ...redactionOptions,
13
16
  ...(error instanceof ApiError && typeof error.body?.errorId === "string" ? { errorId: error.body.errorId } : {}) });
14
17
  }
@@ -1,4 +1,14 @@
1
1
  import type { SkillInstallPayload } from "@jini-ai/core/contracts/site/skill-install";
2
+ /** Only these local validation/read keys may bypass the host's private-error fallback. */
3
+ export type SkillUploadMessageKey = "Choose up to 256 files, 8 MiB total." | "Choose a skill folder, ZIP, or SKILL.md." | "Skill upload has no first file." | "Could not read skill files.";
4
+ /** Keeps the browser cause for details while selecting fixed, translatable guidance. */
5
+ export declare class SkillUploadFailure extends Error {
6
+ readonly messageKey: SkillUploadMessageKey;
7
+ constructor({ messageKey, cause }: {
8
+ messageKey: SkillUploadMessageKey;
9
+ cause?: unknown;
10
+ }, _optional?: {});
11
+ }
2
12
  /** The picker and chat drops use identical byte encoding and preserve folder-relative paths. */
3
13
  export declare function prepareSkillUpload({ files }: {
4
14
  files: readonly File[];
@@ -1,23 +1,41 @@
1
1
  const MAX_BYTES = 8 * 1024 * 1024;
2
- async function base64(file) {
3
- const buffer = await file.arrayBuffer().catch(cause => { throw new Error("Could not read skill files.", { cause }); });
2
+ /** Keeps the browser cause for details while selecting fixed, translatable guidance. */
3
+ export class SkillUploadFailure extends Error {
4
+ messageKey;
5
+ constructor({ messageKey, cause }, _optional = {}) {
6
+ super(messageKey, { cause });
7
+ this.name = "SkillUploadFailure";
8
+ this.messageKey = messageKey;
9
+ }
10
+ }
11
+ async function base64({ file }, _optional = {}) {
12
+ const buffer = await file.arrayBuffer().catch((cause) => {
13
+ throw new SkillUploadFailure({ messageKey: "Could not read skill files.", cause });
14
+ });
4
15
  const bytes = new Uint8Array(buffer);
5
16
  const chunks = [];
6
17
  for (let offset = 0; offset < bytes.length; offset += 8192)
7
18
  chunks.push(String.fromCharCode(...bytes.subarray(offset, offset + 8192)));
8
19
  return btoa(chunks.join(""));
9
20
  }
10
- /** The picker and chat drops use identical byte encoding and preserve folder-relative paths. */
11
- export async function prepareSkillUpload({ files }, { paths } = {}) {
21
+ function firstUploadFile({ files }, _optional = {}) {
12
22
  if (!files.length || files.length > 256 || files.reduce((n, f) => n + f.size, 0) > MAX_BYTES)
13
- throw new Error("Choose up to 256 files, 8 MiB total.");
23
+ throw new SkillUploadFailure({ messageKey: "Choose up to 256 files, 8 MiB total." });
14
24
  const firstFile = files[0];
15
25
  if (!firstFile)
16
- throw new Error("Skill upload has no first file.");
26
+ throw new SkillUploadFailure({ messageKey: "Skill upload has no first file." });
27
+ return firstFile;
28
+ }
29
+ function uploadFilePath({ file, path }, _optional = {}) {
30
+ return path ?? (file.relativePath || file.webkitRelativePath || file.name);
31
+ }
32
+ /** The picker and chat drops use identical byte encoding and preserve folder-relative paths. */
33
+ export async function prepareSkillUpload({ files }, { paths } = {}) {
34
+ const firstFile = firstUploadFile({ files });
17
35
  if (files.length === 1 && firstFile.name.toLowerCase().endsWith(".zip"))
18
- return { archiveBase64: await base64(firstFile) };
36
+ return { archiveBase64: await base64({ file: firstFile }) };
19
37
  if (!files.some(f => f.name === "SKILL.md"))
20
- throw new Error("Choose a skill folder, ZIP, or SKILL.md.");
21
- return { files: await Promise.all(files.map(async (file, index) => ({ path: paths?.[index] ?? (file.relativePath || file.webkitRelativePath || file.name), contentBase64: await base64(file) }))) };
38
+ throw new SkillUploadFailure({ messageKey: "Choose a skill folder, ZIP, or SKILL.md." });
39
+ return { files: await Promise.all(files.map(async (file, index) => ({ path: uploadFilePath({ file, path: paths?.[index] }), contentBase64: await base64({ file }) }))) };
22
40
  }
23
41
  //# sourceMappingURL=skill-upload.js.map
@@ -1,7 +1,3 @@
1
- /** Skills page copy, in the same fixed key order for every locale in the admin picker.
2
- * Product names, /sk, SKILL.md and {name} placeholders intentionally remain literal.
3
- * Language quality requires review by speakers; these entries establish translation coverage.
4
- */
5
1
  const KEYS = [
6
2
  "Skills", "Add-Ons", "Skills sections", "Instructions for your assistant. Type /sk in chat to use one.",
7
3
  "Loading skills…", "No skills installed yet", "Add a GitHub skill or upload files to get started.", "Add a skill", "Installed skills",
@@ -248,9 +244,6 @@ const ROWS = {
248
244
  };
249
245
  /** Fixed, feature-local dictionary assembly; no requests, user collections or per-render work. */
250
246
  export const SKILLS_PAGE_DICT = Object.fromEntries(Object.entries(ROWS).map(([locale, values]) => [locale, Object.fromEntries(KEYS.map((key, index) => {
251
- const value = values[index];
252
- if (value === undefined)
253
- throw new Error(`skills dictionary ${locale} is missing ${key}`);
254
- return [key, value];
247
+ return [key, values[index]];
255
248
  }))]));
256
249
  //# sourceMappingURL=skills-page-dictionary.js.map
@@ -35,7 +35,8 @@ function summarize({ live, locale, t }) {
35
35
  return {};
36
36
  const swept = policies.flatMap(policy => (policy.status === "swept" ? [policy.result.freedBytes] : []));
37
37
  const failed = policies.flatMap(policy => (policy.status === "failed" ? [policy.message] : []));
38
- const freed = swept.includes(null) ? null : swept.reduce((sum, bytes) => sum + (bytes ?? 0), 0);
38
+ const measured = swept.filter((bytes) => bytes !== null);
39
+ const freed = measured.length === swept.length ? measured.reduce((sum, bytes) => sum + bytes, 0) : null;
39
40
  return { freed: formatBytes({ bytes: freed, locale, t }), ...(failed.length === 0 ? {} : { failures: failed.join("; ") }) };
40
41
  }
41
42
  function lastPassLabel({ report, locale, t }) {
@@ -13,7 +13,7 @@ export function createStorageReporter({ deps }, _optional = {}) {
13
13
  export function bindStorageScreen({ hooks, kit, deps }, _optional = {}) {
14
14
  const { Button } = kit;
15
15
  /** `StoragePanel`'s kit takes a DOM-shaped button (`onClick`); this admin's kit Button presses via `onPress`. */
16
- function KitButton({ onClick, children, type = "button", disabled }) {
16
+ function KitButton({ onClick, children, type, disabled }) {
17
17
  return _jsx(Button, { type: type === "submit" ? "submit" : "button", disabled: disabled === true, onPress: () => { onClick?.(undefined); }, children: children });
18
18
  }
19
19
  function storageCopy({ locale }) {
@@ -65,7 +65,7 @@ export function namespaceList({ taxonomies, ...context }) {
65
65
  // built above via the identical `flatMap` order.
66
66
  const groupTermHandles = termHandles.slice(termHandleIndex, termHandleIndex + group.terms.length);
67
67
  termHandleIndex += group.terms.length;
68
- return (_jsx(TaxonomyGroup, { group: group, menuHandle: handleAt({ list: taxonomyMenuHandles, index: groupIndex }), newTermFormBase: handleAt({ list: newTermFormBases, index: groupIndex }), termHandles: groupTermHandles, context: context }, group.taxonomy.id));
68
+ return (_jsx(TaxonomyGroup, { group: group, menuHandle: taxonomyMenuHandles[groupIndex], newTermFormBase: newTermFormBases[groupIndex], termHandles: groupTermHandles, context: context }, group.taxonomy.id));
69
69
  }) }));
70
70
  }
71
71
  /** One taxonomy's card: its header, its blocked-delete notices, its term rows and its add-term form. */
@@ -78,7 +78,7 @@ function TaxonomyGroup({ group, menuHandle, newTermFormBase, termHandles, contex
78
78
  kept: an explicit `list` role formally expects `listitem`-family children, and each
79
79
  row below is now `role="button"` (see that comment), so an explicit `role="list"`
80
80
  here would assert a parent/child relationship that no longer holds. */
81
- _jsx("ul", { className: "jini-settings-row-list jini-taxonomy-term-list", children: group.terms.map((term, index) => (_jsx(TaxonomyTermRow, { group: group, term: term, byId: byId, termHandle: handleAt({ list: termHandles, index }), context: context }, term.id))) })), deleteState.deleteTermBlocked && byId.has(deleteState.deleteTermBlocked.termId) ? (_jsxs("p", { className: "jini-notice jini-notice-error", role: "alert", children: [t("Can't delete"), " \"", byId.get(deleteState.deleteTermBlocked.termId)?.name, "\":", " ", deleteState.deleteTermBlocked.state.message] })) : null, _jsx(NewTermForm, { taxonomy: group, onCreated: context.load, agentBase: newTermFormBase, t: t, useNewTermFormHook: context.parts.useNewTermFormHook })] }));
81
+ _jsx("ul", { className: "jini-settings-row-list jini-taxonomy-term-list", children: group.terms.map((term, index) => (_jsx(TaxonomyTermRow, { group: group, term: term, byId: byId, termHandle: termHandles[index], context: context }, term.id))) })), deleteState.deleteTermBlocked && byId.has(deleteState.deleteTermBlocked.termId) ? (_jsxs("p", { className: "jini-notice jini-notice-error", role: "alert", children: [t("Can't delete"), " \"", byId.get(deleteState.deleteTermBlocked.termId)?.name, "\":", " ", deleteState.deleteTermBlocked.state.message] })) : null, _jsx(NewTermForm, { taxonomy: group, onCreated: context.load, agentBase: newTermFormBase, t: t, useNewTermFormHook: context.parts.useNewTermFormHook })] }));
82
82
  }
83
83
  /** A group's name, its "Copy HTML embed" button and its "Delete taxonomy" row menu. */
84
84
  function TaxonomyGroupHeader({ group, menuHandle, context }) {
@@ -155,15 +155,4 @@ function selectOnActivationKey({ event, select }) {
155
155
  select();
156
156
  }
157
157
  }
158
- /**
159
- * One row's entry of a handle list built over the same rows; a gap would be a bug, so it throws.
160
- * @param required - The handle list and the row's index in it.
161
- * @returns That row's handle.
162
- */
163
- function handleAt({ list, index }) {
164
- const handle = list[index];
165
- if (handle === undefined)
166
- throw new Error(`taxonomy list row ${index} has no agent handle`);
167
- return handle;
168
- }
169
158
  //# sourceMappingURL=TaxonomyTermList.js.map
@@ -53,18 +53,9 @@ function buildTermPickerHandles({ taxonomies }) {
53
53
  search: buildAgentListHandles({ prefix: "term-picker-search", ids: taxonomyIds }),
54
54
  });
55
55
  return {
56
- term: (termId) => {
57
- const handle = termHandleById.get(termId);
58
- if (handle === undefined)
59
- throw new Error(`taxonomy term ${termId} has no picker handle`);
60
- return handle;
61
- },
62
- row: (groupIndex) => {
63
- const handles = rowHandles[groupIndex];
64
- if (handles === undefined)
65
- throw new Error(`taxonomy row ${groupIndex} has no picker handles`);
66
- return handles;
67
- },
56
+ // Lookups render only terms and taxonomy rows from the same input used to build both lists.
57
+ term: (termId) => termHandleById.get(termId),
58
+ row: (groupIndex) => rowHandles[groupIndex],
68
59
  };
69
60
  }
70
61
  /**
@@ -74,20 +65,13 @@ function buildTermPickerHandles({ taxonomies }) {
74
65
  */
75
66
  function zipRowHandles(lists) {
76
67
  return lists.addInput.map((_handle, index) => ({
77
- addInput: handleAt({ list: lists.addInput, index }),
78
- addTrigger: handleAt({ list: lists.addTrigger, index }),
79
- addButton: handleAt({ list: lists.addButton, index }),
80
- more: handleAt({ list: lists.more, index }),
81
- search: handleAt({ list: lists.search, index }),
68
+ addInput: lists.addInput[index],
69
+ addTrigger: lists.addTrigger[index],
70
+ addButton: lists.addButton[index],
71
+ more: lists.more[index],
72
+ search: lists.search[index],
82
73
  }));
83
74
  }
84
- /** One row's entry of a handle list; every list is as long as the taxonomy list, so a gap is a bug. */
85
- function handleAt({ list, index }) {
86
- const handle = list[index];
87
- if (handle === undefined)
88
- throw new Error(`taxonomy row ${index} has no picker handle`);
89
- return handle;
90
- }
91
75
  /** One taxonomy row: its legend, its checklist, its add controls and its create error. */
92
76
  function TermPickerGroup({ taxonomy, terms, groupIndex, picker, handles, useTermListRevealHook, SuggestInput }) {
93
77
  const id = taxonomy.id;
@@ -128,8 +128,6 @@ function useMergeTermState({ options, port }) {
128
128
  // Same deps as the pre-migration effect ([term.id]) — the three mutation objects are
129
129
  // intentionally excluded, same reasoning as `use-term-detail-panel.hooks.ts`'s identical effect.
130
130
  useEffect(() => {
131
- if (activeTermIdRef.current !== term.id)
132
- return;
133
131
  setIntoTermId("");
134
132
  setStep("idle");
135
133
  setPlan(null);
@@ -30,8 +30,6 @@ export function useTermDetailPanel({ options, port, locale, kit }, _optional = {
30
30
  // `renameMutation` intentionally excluded — same deps as the pre-migration effect
31
31
  // ([term.id, term.name]); including the mutation object would re-run this on every status change.
32
32
  useEffect(() => {
33
- if (activeTermIdRef.current !== term.id)
34
- return;
35
33
  setNewName(term.name);
36
34
  setMessage(null);
37
35
  setError(null);
@@ -52,5 +52,5 @@ const confirmLabels = {
52
52
  "ur": "تصدیق کریں",
53
53
  "bn": "নিশ্চিত করুন"
54
54
  };
55
- export const WEBMCP_DICT = Object.fromEntries(Object.entries(translations).map(([locale, values]) => [locale, { ...Object.fromEntries(WEBMCP_KEYS.map((key, index) => [key, values[index]])), Confirm: confirmLabels[locale] ?? "Confirm" }]));
55
+ export const WEBMCP_DICT = Object.fromEntries(Object.entries(translations).map(([locale, values]) => [locale, { ...Object.fromEntries(WEBMCP_KEYS.map((key, index) => [key, values[index]])), Confirm: confirmLabels[locale] }]));
56
56
  //# sourceMappingURL=webmcp-i18n.js.map
@@ -29,18 +29,19 @@ export function createRootKeyReveal({ api, store, allowed }, { failureText, clip
29
29
  return false;
30
30
  const mine = ++ticket;
31
31
  store.set({ patch: { revealing: true, revealError: null } });
32
+ let ok = false;
32
33
  try {
33
- return settle({ mine, reply: await port({}, { signal: store.signal }) });
34
+ ok = settle({ mine, reply: await port({}, { signal: store.signal }) });
34
35
  }
35
36
  catch (error) {
36
37
  if (mine === ticket)
37
38
  store.set({ patch: { revealError: failureText(error) } });
38
- return false;
39
39
  }
40
40
  finally {
41
41
  if (mine === ticket)
42
42
  store.set({ patch: { revealing: false } });
43
43
  }
44
+ return ok;
44
45
  }
45
46
  /** A denied clipboard is silent: the value stays on screen to copy by hand. */
46
47
  async function copy(_required = {}, _optional = {}) {
@@ -42,20 +42,21 @@ export function createSharedKeysController({ port, permissions = [] }, { onGrant
42
42
  return false;
43
43
  busy = true;
44
44
  store.set({ patch: { pending: true, failure: null, results: [] } });
45
+ let ok = false;
45
46
  try {
46
47
  const results = await port.grant({ sourceSiteId: SHARED_KEYS_SOURCE, ids: [key.id], overwrite: false }, { signal: store.signal });
47
48
  onGranted?.();
48
49
  store.set({ patch: { results } });
49
- return true;
50
+ ok = true;
50
51
  }
51
52
  catch {
52
53
  store.set({ patch: { failure: 'grant' } });
53
- return false;
54
54
  }
55
55
  finally {
56
56
  busy = false;
57
57
  store.set({ patch: { pending: false } });
58
58
  }
59
+ return ok;
59
60
  }
60
61
  return {
61
62
  getSnapshot: store.getSnapshot, subscribe: store.subscribe, open, grant, grantable,
@@ -47,7 +47,10 @@ export function worksForChoices({ providers, value }, _optional = {}) {
47
47
  }
48
48
  /** Source control has no compatibility list; publish and custom rows send `worksFor` only when it changed. */
49
49
  export function worksForPart({ draft, saved }, _optional = {}) {
50
- return draft.kind !== 'source-control' && worksForChanged({ draft: draft.worksFor, saved }) ? { worksFor: [...(draft.worksFor ?? [])] } : {};
50
+ const worksFor = draft.worksFor;
51
+ if (draft.kind === 'source-control' || worksFor === undefined)
52
+ return {};
53
+ return worksForChanged({ draft: worksFor, saved }) ? { worksFor: [...worksFor] } : {};
51
54
  }
52
55
  /** A custom create: no top-level `username` (it travels in `connection`), and `additionalHosts` only when any were typed. */
53
56
  export function customCreateFields({ draft }, _optional = {}) {
@@ -83,7 +83,7 @@ function ProviderGroup({ bindings, group, controller }) {
83
83
  return (_jsxs("section", { className: "access-tokens-provider-group", ...agentHandle({ handle: `security-access-tokens-group-${group.info.kind}-${agentHandleSegment({ value: group.info.providerId })}` }, {
84
84
  role: "region",
85
85
  label: providerGroupHandleLabel({ info: group.info, connectedCount: group.rows.length }),
86
- }), children: [_jsxs("h3", { className: "access-tokens-provider-heading", children: [_jsx("span", { translate: "no", children: group.info.label }), _jsxs("span", { className: "access-tokens-provider-purpose", children: [" \u00B7 ", providerGroupSubtitleKeys({ info: group.info, copy: ACCESS_TOKEN_PROVIDER_COPY }).map(controller.t).join(" · ")] })] }), group.info.unlisted ? _jsx("p", { className: "field-hint", children: controller.t("Its plugin is off or missing. You can still remove saved tokens.") }) : null, group.rows.map((row) => (_jsx(TokenRow, { bindings: bindings, state: row, info: group.info, controller: controller, groupRowCount: group.rows.length, t: controller.t }, row.row.id))), !hasRows && !group.addForm.visible ? _jsx(NotConnectedRow, { bindings: bindings, ref: ref, label: group.info.label, onConnect: () => controller.openAddForm(ref), t: controller.t }) : null, group.addForm.visible ? _jsx(AddTokenForm, { bindings: bindings, info: group.info, state: group.addForm, controller: controller, t: controller.t }) : null, hasRows && !group.addForm.visible && acceptsAnotherToken(group.info) ? _jsx(AddAnotherButton, { ref: ref, label: group.info.label, controller: controller, t: controller.t }) : null] }));
86
+ }), children: [_jsxs("h3", { className: "access-tokens-provider-heading", children: [_jsx("span", { translate: "no", children: group.info.label }), _jsxs("span", { className: "access-tokens-provider-purpose", children: [" \u00B7 ", providerGroupSubtitleKeys({ info: group.info, copy: ACCESS_TOKEN_PROVIDER_COPY }).map(controller.t).join(" · ")] })] }), group.stale ? _jsx("p", { className: "field-hint", role: "status", children: controller.t("Stale inventory. Showing the last successful load.") }) : null, group.info.unlisted ? _jsx("p", { className: "field-hint", children: controller.t("Its plugin is off or missing. You can still remove saved tokens.") }) : null, group.rows.map((row) => (_jsx(TokenRow, { bindings: bindings, state: row, info: group.info, controller: controller, groupRowCount: group.rows.length, t: controller.t }, row.row.id))), !hasRows && !group.addForm.visible ? _jsx(NotConnectedRow, { bindings: bindings, ref: ref, label: group.info.label, onConnect: () => controller.openAddForm(ref), t: controller.t }) : null, group.addForm.visible ? _jsx(AddTokenForm, { bindings: bindings, info: group.info, state: group.addForm, controller: controller, t: controller.t }) : null, hasRows && !group.addForm.visible && acceptsAnotherToken(group.info) ? _jsx(AddAnotherButton, { ref: ref, label: group.info.label, controller: controller, t: controller.t }) : null] }));
87
87
  }
88
88
  function AddAnotherButton({ ref, label, controller, t: translate }) {
89
89
  return (_jsxs("button", { type: "button", className: "link-button access-tokens-add-another", onClick: () => controller.openAddForm(ref), ...agentHandle({ handle: `security-access-tokens-add-${ref.kind}-${agentHandleSegment({ value: ref.providerId })}` }, { role: "button", label: `Add another ${label} token` }), children: [translate("Add another"), " ", _jsx("span", { translate: "no", children: label }), " ", translate("token")] }));
@@ -37,7 +37,7 @@ export declare function mergeCredential({ context, kind, result, isNew }: {
37
37
  * fallback (`row.name`), which this now matches. Username joined this same fallback on 2026-09-01:
38
38
  * once a custom row can carry a saved {@link AccessTokenRow.username}, touching Token first (before
39
39
  * ever touching Username) would otherwise blank a saved username out of the draft the identical way
40
- * it used to blank Name. @complexity O(1). */
40
+ * it used to blank Name. @complexity O(n) for n saved rows. */
41
41
  export declare function setExistingField({ context, rowId, patch }: {
42
42
  context: AccessTokenActionContext;
43
43
  rowId: string;
@@ -33,11 +33,11 @@ export function mergeCredential({ context, kind, result, isNew }, _optional = {}
33
33
  const { setPublishCredentials, setSourceControlCredentials } = context.stores;
34
34
  if (kind === "publish") {
35
35
  const row = result;
36
- setPublishCredentials((prev) => ({ status: "ok", rows: mergeRaw({ list: prev.rows ?? [], result: row, isNew }) }));
36
+ setPublishCredentials((prev) => ({ ...prev, status: "ok", rows: mergeRaw({ list: prev.rows ?? [], result: row, isNew }) }));
37
37
  }
38
38
  else {
39
39
  const row = result;
40
- setSourceControlCredentials((prev) => ({ status: "ok", rows: mergeRaw({ list: prev.rows ?? [], result: row, isNew }) }));
40
+ setSourceControlCredentials((prev) => ({ ...prev, status: "ok", rows: mergeRaw({ list: prev.rows ?? [], result: row, isNew }) }));
41
41
  }
42
42
  }
43
43
  async function refetchStore({ context, kind }, _optional = {}) {
@@ -56,13 +56,17 @@ async function refetchStore({ context, kind }, _optional = {}) {
56
56
  * fallback (`row.name`), which this now matches. Username joined this same fallback on 2026-09-01:
57
57
  * once a custom row can carry a saved {@link AccessTokenRow.username}, touching Token first (before
58
58
  * ever touching Username) would otherwise blank a saved username out of the draft the identical way
59
- * it used to blank Name. @complexity O(1). */
59
+ * it used to blank Name. @complexity O(n) for n saved rows. */
60
60
  export function setExistingField({ context, rowId, patch }, _optional = {}) {
61
61
  const deps = context.args.deps;
62
62
  const { locale } = context.args;
63
63
  const { credentialDraftError } = deps;
64
64
  const { setExistingDrafts, setExistingBusy } = context.drafts;
65
65
  const { rows } = context;
66
+ const persistedRow = rows?.find((r) => r.id === rowId);
67
+ // Before the stores arrive there is no metadata to seed; a blank draft would hide the saved name.
68
+ if (!persistedRow)
69
+ return;
66
70
  const token = patch.token;
67
71
  if (token !== undefined)
68
72
  setExistingBusy(prev => ({ ...prev, [rowId]: { saving: prev[rowId]?.saving ?? false, error: credentialDraftError({ value: token }, { locale }) } }));
@@ -70,8 +74,7 @@ export function setExistingField({ context, rowId, patch }, _optional = {}) {
70
74
  const existing = prev[rowId];
71
75
  if (existing)
72
76
  return { ...prev, [rowId]: { ...existing, ...patch } };
73
- const persistedRow = rows?.find((r) => r.id === rowId);
74
- return { ...prev, [rowId]: { ...blankDraft(), name: persistedRow?.name ?? "", username: persistedRow?.username ?? "", worksFor: persistedRow?.worksFor ?? [], ...patch } };
77
+ return { ...prev, [rowId]: { ...blankDraft(), name: persistedRow.name, username: persistedRow.username ?? "", worksFor: persistedRow.worksFor ?? [], ...patch } };
75
78
  });
76
79
  }
77
80
  /** Removes a saved row, now with real error handling (Terra audit MEDIUM finding, 2026-08-19):
@@ -120,9 +123,9 @@ function applyPromotedDefault({ context, kind, result }, _optional = {}) {
120
123
  const { withPromotedDefault } = deps;
121
124
  const { setPublishCredentials, setSourceControlCredentials } = context.stores;
122
125
  if (kind === "publish")
123
- setPublishCredentials((prev) => ({ status: "ok", rows: withPromotedDefault({ credentials: prev.rows ?? [], promoted: result }) }));
126
+ setPublishCredentials((prev) => ({ ...prev, status: "ok", rows: withPromotedDefault({ credentials: prev.rows ?? [], promoted: result }) }));
124
127
  else
125
- setSourceControlCredentials((prev) => ({ status: "ok", rows: withPromotedDefault({ credentials: prev.rows ?? [], promoted: result }) }));
128
+ setSourceControlCredentials((prev) => ({ ...prev, status: "ok", rows: withPromotedDefault({ credentials: prev.rows ?? [], promoted: result }) }));
126
129
  }
127
130
  /** Best-effort re-read after a promotion the server already confirmed — same shape and reasoning as
128
131
  * `use-publish-credentials.hooks.ts`'s `reconcileCredentials`: a failure here is swallowed because