@nextclaw/ui 0.19.0 → 0.19.2
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.
- package/CHANGELOG.md +14 -0
- package/dist/assets/{api-Cyxp93Fn.js → api-BH6Oslx4.js} +3 -3
- package/dist/assets/{appearance-settings-page-DsMl931U.js → appearance-settings-page-zhgfcGgW.js} +1 -1
- package/dist/assets/{book-open-Cl5CzL0g.js → book-open-DGTS6oEO.js} +1 -1
- package/dist/assets/{channels-list-page-D_B7JGoZ.js → channels-list-page-3D5lhZoT.js} +2 -2
- package/dist/assets/chat-page-BXu3hnOK.js +1 -0
- package/dist/assets/{config-split-page-C-YVl2mf.js → config-split-page-B55XD_ZY.js} +1 -1
- package/dist/assets/{confirm-dialog-Bz3ieDQ5.js → confirm-dialog-BCCreI_f.js} +1 -1
- package/dist/assets/{desktop-update-config-DO051-QG.js → desktop-update-config-Blol-Umu.js} +1 -1
- package/dist/assets/{dist-CDPl8mm7.js → dist-BYSUQaO2.js} +1 -1
- package/dist/assets/{dist-HFDWY6-K.js → dist-IRWcJpfm.js} +1 -1
- package/dist/assets/doc-browser-BExPq1Hk.js +1 -0
- package/dist/assets/{doc-browser-D6H_nPzO.js → doc-browser-D8rNrWHk.js} +1 -1
- package/dist/assets/{doc-browser-context-BKwz_j44.js → doc-browser-context-DjTbIbQc.js} +1 -1
- package/dist/assets/{form-actions-BUZOCfPR.js → form-actions-C8hazgNP.js} +1 -1
- package/dist/assets/index-Btj8yN4T.css +1 -0
- package/dist/assets/index-CHcGqqBe.js +109 -0
- package/dist/assets/loader-circle-C75DUmmm.js +1 -0
- package/dist/assets/mcp-marketplace-page-CIMRYgOY.js +9 -0
- package/dist/assets/mcp-marketplace-page-D2NlhG1k.js +1 -0
- package/dist/assets/model-config-page-ChR-ENjp.js +1 -0
- package/dist/assets/{navigation-link-CDMYpkVv.js → navigation-link-kGAcL2N2.js} +1 -1
- package/dist/assets/plus-TzSIMKWW.js +1 -0
- package/dist/assets/privacy-settings-page-v9LTFvJe.js +1 -0
- package/dist/assets/{provider-scoped-model-input-C2iUtZi7.js → provider-scoped-model-input-DiSpKSk0.js} +1 -1
- package/dist/assets/providers-config-page-BvXa03cp.js +1 -0
- package/dist/assets/{react-B7Paq2b3.js → react-Dwvp5yeX.js} +1 -1
- package/dist/assets/{refresh-cw-XrnNVwuQ.js → refresh-cw-C_oj_h_s.js} +1 -1
- package/dist/assets/remote-BgYduCQR.js +1 -0
- package/dist/assets/rotate-cw-BT8HxlcB.js +1 -0
- package/dist/assets/{runtime-config-page-BVO9B8Ns.js → runtime-config-page-BuYof2Ty.js} +1 -1
- package/dist/assets/{save-_nSNAYQu.js → save-BZE6H02N.js} +1 -1
- package/dist/assets/{search-0OTHFRMx.js → search-C7Tj40kC.js} +1 -1
- package/dist/assets/{search-config-page-BwyeUjKt.js → search-config-page-CQTJOsOf.js} +1 -1
- package/dist/assets/{secrets-config-page-2O-TzroJ.js → secrets-config-page-B__VLAEQ.js} +2 -2
- package/dist/assets/security-config-CtJqaPVL.js +1 -0
- package/dist/assets/{select-BZHvnwQB.js → select-fZ5tifar.js} +1 -1
- package/dist/assets/{settings-2-CM_PvDNk.js → settings-2-BHGgNlOH.js} +1 -1
- package/dist/assets/skeleton-CJLc1CWn.js +1 -0
- package/dist/assets/{tag-chip-Ce53PMTL.js → tag-chip-CwYZcRoe.js} +1 -1
- package/dist/assets/x-BMl7cucN.js +1 -0
- package/dist/index.html +20 -20
- package/package.json +3 -3
- package/src/app/configs/app-navigation.config.ts +6 -0
- package/src/app/index.tsx +8 -0
- package/src/features/panel-apps/components/__tests__/panel-app-list-item.test.tsx +24 -12
- package/src/features/panel-apps/components/__tests__/panel-app-main-sidebar-nav.test.tsx +51 -0
- package/src/features/panel-apps/components/__tests__/panel-app-toolbar.test.tsx +59 -5
- package/src/features/panel-apps/components/panel-app-list-item.tsx +5 -18
- package/src/features/panel-apps/components/panel-app-main-sidebar-menu-item.tsx +37 -0
- package/src/features/panel-apps/components/panel-app-main-sidebar-nav.tsx +71 -20
- package/src/features/panel-apps/components/panel-app-toolbar.tsx +18 -38
- package/src/features/panel-apps/components/panel-apps-list.tsx +0 -9
- package/src/features/panel-apps/utils/panel-app-doc-browser.utils.tsx +2 -2
- package/src/features/right-panel-resources/index.ts +1 -0
- package/src/features/right-panel-resources/utils/__tests__/right-panel-resource-uri.utils.test.ts +12 -0
- package/src/features/right-panel-resources/utils/right-panel-resource-uri.utils.ts +8 -0
- package/src/features/settings/pages/__tests__/privacy-settings-page.test.tsx +33 -0
- package/src/features/settings/pages/privacy-settings-page.tsx +83 -0
- package/src/shared/components/doc-browser/__tests__/doc-browser.test.tsx +26 -0
- package/src/shared/hooks/use-config.ts +21 -1
- package/src/shared/lib/api/types.ts +13 -0
- package/src/shared/lib/api/utils/config.utils.ts +8 -0
- package/src/shared/lib/i18n/locales/en-US/core.json +19 -0
- package/src/shared/lib/i18n/locales/zh-CN/core.json +19 -0
- package/dist/assets/chat-page-D3ZeULTv.js +0 -1
- package/dist/assets/doc-browser-CWhs0JQN.js +0 -1
- package/dist/assets/index-DR3GLGme.css +0 -1
- package/dist/assets/index-j6DBnvlr.js +0 -109
- package/dist/assets/loader-circle-s65a4ZzL.js +0 -1
- package/dist/assets/mcp-marketplace-page-BJvzGt7h.js +0 -9
- package/dist/assets/mcp-marketplace-page-EpFHeJzw.js +0 -1
- package/dist/assets/model-config-page-CBoh0DVh.js +0 -1
- package/dist/assets/plus-XDIkqpkt.js +0 -1
- package/dist/assets/providers-config-page-DX1pISTo.js +0 -1
- package/dist/assets/remote-D_7_OGoj.js +0 -1
- package/dist/assets/rotate-cw-BhIWpLaU.js +0 -1
- package/dist/assets/security-config-BgIIrg1s.js +0 -1
- package/dist/assets/skeleton-Bv4MMbH7.js +0 -1
- package/dist/assets/x-CCjWN5ys.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./dist-
|
|
1
|
+
import{c as e}from"./dist-IRWcJpfm.js";var t=e(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Pt as e}from"./index-CHcGqqBe.js";export{e as RemoteAccessPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e}from"./dist-IRWcJpfm.js";var t=e(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,a as r}from"./react-B7Paq2b3.js";import{$t as i,Ht as a,Kt as o,Pt as s,Qt as c,Wt as l,Xt as u,Zt as d,in as f,ln as p,qt as m,rn as h}from"./api-Cyxp93Fn.js";import{g}from"./mcp-marketplace-page-BJvzGt7h.js";import{a as _,i as v,n as y,r as b,t as x}from"./select-BZHvnwQB.js";import{t as S}from"./loader-circle-s65a4ZzL.js";import{t as C}from"./plus-XDIkqpkt.js";import{t as ee}from"./rotate-cw-BhIWpLaU.js";import{t as w}from"./save-_nSNAYQu.js";import{Bt as T,It as E,Lt as D,P as O,_ as k,c as A,f as te,l as j}from"./index-j6DBnvlr.js";import{t as M}from"./form-actions-BUZOCfPR.js";var N=e(n(),1),P=t(),F={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},I={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},L={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function R(e){return r(F[e]??`runtimeControlUnavailable`)}function z(e){return r(I[e]??`runtimeControlServiceUnknown`)}function B(e){return r(L[e.environment])}function V(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function H(e){return e?[{action:`start-service`,capability:e.canStartService,label:r(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:r(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:r(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:r(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function U(e){let{busy:t,icon:n}=e;return t?(0,P.jsx)(S,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,P.jsx)(T,{className:`mr-2 h-4 w-4`}):n===`square`?(0,P.jsx)(D,{className:`mr-2 h-4 w-4`}):(0,P.jsx)(ee,{className:`mr-2 h-4 w-4`})}function W(){let{busy:e,busyAction:t,controlView:n,errorMessage:i,pendingRestart:s,visibleLifecycle:l,visibleMessage:u,visibleServiceState:h}=a(),g=H(n??void 0),_=async e=>{let t=V(n,e);if(!t?.available){p.error(m(t?.reasonIfUnavailable)??r(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(r(`runtimeControlStopServiceConfirm`))))try{let t=await o.runRuntimeControlAction(e);p.success(m(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);p.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}},v=async()=>{if(!n?.canRestartApp.available){p.error(m(n?.canRestartApp.reasonIfUnavailable)??r(`runtimeRestartAppUnavailable`));return}if(window.confirm(r(`runtimeControlRestartAppConfirm`)))try{let e=await o.runRuntimeControlAction(`restart-app`);p.success(m(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);p.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}};return(0,P.jsx)(c,{title:r(`runtimeControlTitle`),description:r(`runtimeControlDescription`),children:(0,P.jsxs)(d,{children:[(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:z(h)}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n?B(n):r(`runtimeControlLoading`)})]}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:R(l)}),n?.managementHint?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m(n.managementHint)}):null,i&&!e?(0,P.jsx)(`p`,{className:`text-sm text-amber-700`,children:i}):null]}),s?(0,P.jsxs)(`div`,{className:`space-y-3 bg-amber-50/75 p-4 dark:bg-amber-950/20`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:r(`runtimeControlPendingRestartTitle`)}),(0,P.jsx)(`p`,{className:`text-sm text-amber-800`,children:r(`runtimeControlPendingRestartDescription`)}),s.changedPaths.length>0?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:r(`runtimeControlPendingRestartPaths`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:s.changedPaths.map(e=>(0,P.jsx)(`span`,{className:`rounded-full bg-background/80 px-2.5 py-1 text-xs text-amber-800 dark:text-amber-300`,children:e},e))})]}):null]}):null,(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:g.map(n=>(0,P.jsxs)(f,{type:`button`,variant:n.variant??`default`,onClick:()=>{if(n.action===`restart-app`){v();return}_(n.action)},disabled:!n.capability.available||e,children:[(0,P.jsx)(U,{icon:n.icon,busy:t===n.action}),n.label]},n.action))}),g.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m(e.capability.reasonIfUnavailable)},`${e.action}-reason`))]})]})})}function G(e){let{description:t,title:n}=e;return(0,P.jsx)(g,{tone:`neutral`,title:n,description:t})}function K(e){let{children:t}=e;return(0,P.jsx)(c,{title:r(`runtimePresenceTitle`),description:r(`runtimePresenceDescription`),children:(0,P.jsx)(d,{children:t})})}function ne(){let e=l().runtimeControlView?.environment,t=j(e=>e.supported),n=j(e=>e.initialized),i=j(e=>e.busyAction),a=j(e=>e.snapshot);return(0,N.useEffect)(()=>{if(e===`desktop-embedded`){A.start();return}A.markUnsupported()},[e]),e===`desktop-embedded`?(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(g,{tone:`neutral`,title:r(`runtimePresenceBehaviorLabel`),description:a?.closeToBackground?r(`runtimePresenceBehaviorBackground`):r(`runtimePresenceBehaviorQuit`),className:`rounded-xl`})}),!n||t&&!a?(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:r(`runtimePresenceLoading`)}):null,a?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(u,{title:r(`runtimePresenceCloseToBackground`),description:r(`runtimePresenceCloseToBackgroundHelp`),control:(0,P.jsx)(s,{id:`runtime-presence-close-background`,"aria-label":r(`runtimePresenceCloseToBackground`),checked:a.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{A.updatePreferences({closeToBackground:e})}})}),(0,P.jsx)(u,{title:r(`runtimePresenceLaunchAtLogin`),description:a.supportsLaunchAtLogin?r(`runtimePresenceLaunchAtLoginHelp`):a.launchAtLoginReason??r(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,P.jsx)(s,{id:`runtime-presence-launch-login`,"aria-label":r(`runtimePresenceLaunchAtLogin`),checked:a.launchAtLogin,disabled:!a.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{A.updatePreferences({launchAtLogin:e})}})})]}):null]}):e===`managed-local-service`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceManagedLocalTitle`),description:r(`runtimePresenceManagedLocalDescription`)})})}):e===`self-hosted-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceSelfHostedTitle`),description:r(`runtimePresenceSelfHostedDescription`)})})}):e===`shared-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceSharedTitle`),description:r(`runtimePresenceSharedDescription`)})})}):(0,P.jsx)(K,{children:(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:r(`runtimePresenceLoading`)})})}function q(){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(W,{}),(0,P.jsx)(ne,{}),(0,P.jsx)(te,{})]})}var J={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function Y(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function X(){return{agentId:``,match:{channel:``,accountId:``}}}function Z(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:J,configText:JSON.stringify(J,null,2)}}function re(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}}function ie(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function Q(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ae(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(re),bindings:(e.bindings??[]).map(ie),runtimeEntries:Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)})),dmScope:e.session?.dmScope??`per-channel-peer`,defaultContextTokens:e.agents.defaults.contextTokens??2e5,defaultEngine:e.agents.defaults.engine??`native`}}function oe(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}function $(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(r(`agentIdRequiredError`).replace(`{index}`,String(t)));return oe(e)}),n=t.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0)throw Error(`${r(`duplicateAgentId`)}: ${n[0]}`);let i=e.bindings.map((t,n)=>{let i=t.agentId.trim(),a=t.match.channel.trim(),o=t.match.accountId?.trim()??``,s=t.match.peer?.kind,c=t.match.peer?.id?.trim()??``;if(!i)throw Error(r(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!e.knownAgentIds.has(i))throw Error(`${r(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${i}`);if(!a)throw Error(r(`bindingChannelRequired`).replace(`{index}`,String(n)));let l={agentId:i,match:{channel:a}};if(o&&(l.match.accountId=o),s){if(!c)throw Error(r(`bindingPeerIdRequired`).replace(`{index}`,String(n)));l.match.peer={kind:s,id:c}}return l}),a=e.runtimeEntries.reduce((e,t,n)=>{let i=t.id.trim(),a=t.type.trim();if(!i)throw Error(r(`runtimeEntryIdRequired`).replace(`{index}`,String(n)));if(!a)throw Error(r(`runtimeEntryTypeRequired`).replace(`{id}`,i));if(e[i])throw Error(`${r(`runtimeEntryDuplicate`)}: ${i}`);let o=t.configText.trim()?JSON.parse(t.configText):{};if(o&&(typeof o!=`object`||Array.isArray(o)))throw Error(r(`runtimeEntryConfigObjectRequired`).replace(`{id}`,i));return e[i]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:a,config:o??{}},e},{});return{companion:{enabled:e.companionEnabled},agents:{defaults:{contextTokens:Math.max(1e3,e.defaultContextTokens),engine:e.defaultEngine.trim()||`native`},list:t,runtimes:{entries:a}},bindings:i,session:{dmScope:e.dmScope}}}function se({agents:e,onAddAgent:t,onRemoveAgent:n,onSetDefaultAgent:i,onUpdateAgent:a}){return(0,P.jsx)(c,{title:r(`agentList`),description:r(`agentListHelp`),actions:(0,P.jsxs)(f,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(C,{className:`mr-2 h-4 w-4`}),r(`addAgent`)]}),children:(0,P.jsx)(d,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(h,{value:e.id,onChange:e=>a(t,{id:e.target.value}),placeholder:r(`agentIdPlaceholder`)}),(0,P.jsx)(h,{value:e.workspace??``,onChange:e=>a(t,{workspace:e.target.value}),placeholder:r(`workspaceOverridePlaceholder`)}),(0,P.jsx)(h,{value:e.model??``,onChange:e=>a(t,{model:e.target.value}),placeholder:r(`modelOverridePlaceholder`)}),(0,P.jsx)(h,{value:e.runtime??e.engine??``,onChange:e=>a(t,{runtime:e.target.value}),placeholder:r(`engineOverridePlaceholder`)}),(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,P.jsx)(h,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>a(t,{contextTokens:Q(e.target.value)}),placeholder:r(`contextTokensPlaceholder`)}),(0,P.jsx)(h,{type:`number`,min:1,value:e.maxToolIterations??``,onChange:e=>a(t,{maxToolIterations:Q(e.target.value)}),placeholder:r(`maxToolsPlaceholder`)})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(s,{checked:!!e.default,onCheckedChange:e=>i(t,e)}),(0,P.jsx)(`span`,{children:r(`defaultAgent`)})]}),(0,P.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(t),children:[(0,P.jsx)(E,{className:`h-4 w-4 mr-1`}),r(`remove`)]})]})]},`${t}-${e.id}`))})})}function ce({bindings:e,onAddBinding:t,onRemoveBinding:n,onUpdateBinding:i}){return(0,P.jsx)(c,{title:r(`bindings`),description:r(`bindingsHelp`),actions:(0,P.jsxs)(f,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(C,{className:`mr-2 h-4 w-4`}),r(`addBinding`)]}),children:(0,P.jsx)(d,{children:e.map((e,t)=>{let a=e.match.peer?.kind??``;return(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,P.jsx)(h,{value:e.agentId,onChange:n=>i(t,{...e,agentId:n.target.value}),placeholder:r(`targetAgentIdPlaceholder`)}),(0,P.jsx)(h,{value:e.match.channel,onChange:n=>i(t,{...e,match:{...e.match,channel:n.target.value}}),placeholder:r(`channelPlaceholder`)}),(0,P.jsx)(h,{value:e.match.accountId??``,onChange:n=>i(t,{...e,match:{...e.match,accountId:n.target.value}}),placeholder:r(`accountIdOptionalPlaceholder`)}),(0,P.jsxs)(x,{value:a||`__none__`,onValueChange:n=>{let r=n===`__none__`?``:n;i(t,r?{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}}:{...e,match:{...e.match,peer:void 0}})},children:[(0,P.jsx)(v,{children:(0,P.jsx)(_,{})}),(0,P.jsxs)(y,{children:[(0,P.jsx)(b,{value:`__none__`,children:r(`peerKindOptional`)}),(0,P.jsx)(b,{value:`direct`,children:r(`peerKindDirect`)}),(0,P.jsx)(b,{value:`group`,children:r(`peerKindGroup`)}),(0,P.jsx)(b,{value:`channel`,children:r(`peerKindChannel`)})]})]}),(0,P.jsx)(h,{value:e.match.peer?.id??``,onChange:n=>i(t,{...e,match:{...e.match,peer:a?{kind:a,id:n.target.value}:void 0}}),placeholder:r(`peerIdPlaceholder`)})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(t),children:[(0,P.jsx)(E,{className:`h-4 w-4 mr-1`}),r(`remove`)]})})]},`${t}-${e.agentId}`)})})})}function le({entries:e,onAddEntry:t,onRemoveEntry:n,onUpdateEntry:i}){return(0,P.jsx)(c,{title:r(`runtimeEntries`),description:r(`runtimeEntriesHelp`),actions:(0,P.jsxs)(f,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(C,{className:`mr-2 h-4 w-4`}),r(`addRuntimeEntry`)]}),children:(0,P.jsx)(d,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(h,{value:e.id,onChange:e=>i(t,{id:e.target.value}),placeholder:r(`runtimeEntryIdPlaceholder`)}),(0,P.jsx)(h,{value:e.label??``,onChange:e=>i(t,{label:e.target.value}),placeholder:r(`runtimeEntryLabelPlaceholder`)}),(0,P.jsx)(h,{value:e.type,onChange:e=>i(t,{type:e.target.value}),placeholder:r(`runtimeEntryTypePlaceholder`)}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg bg-background/65 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:r(`enabled`)}),(0,P.jsx)(s,{checked:e.enabled!==!1,onCheckedChange:e=>i(t,{enabled:e})})]})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:r(`runtimeEntryConfigJson`)}),(0,P.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm`,value:e.configText,onChange:e=>i(t,{configText:e.target.value}),spellCheck:!1})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(f,{type:`button`,variant:`outline`,onClick:()=>n(t),children:[(0,P.jsx)(E,{className:`mr-2 h-4 w-4`}),r(`delete`)]})})]},`${t}-${e.id||`runtime-entry`}`))})})}var ue=[{value:`main`,labelKey:`dmScopeMain`},{value:`per-peer`,labelKey:`dmScopePerPeer`},{value:`per-channel-peer`,labelKey:`dmScopePerChannelPeer`},{value:`per-account-channel-peer`,labelKey:`dmScopePerAccountChannelPeer`}];function de({companionEnabled:e,defaultContextTokens:t,defaultEngine:n,dmScope:i,onCompanionEnabledChange:a,onDefaultContextTokensChange:o,onDefaultEngineChange:l,onDmScopeChange:f}){return(0,P.jsx)(c,{title:r(`dmScope`),description:r(`dmScopeHelp`),children:(0,P.jsxs)(d,{children:[(0,P.jsx)(u,{title:r(`runtimeCompanionEnabled`),description:r(`runtimeCompanionEnabledHelp`),control:(0,P.jsx)(s,{checked:e,onCheckedChange:a})}),(0,P.jsx)(u,{title:r(`defaultContextTokens`),description:r(`defaultContextTokensHelp`),control:(0,P.jsx)(h,{type:`number`,min:1e3,step:1e3,value:t,onChange:e=>o(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3)),className:`w-36`})}),(0,P.jsx)(u,{title:r(`defaultEngine`),description:r(`defaultEngineHelp`),control:(0,P.jsx)(h,{value:n,onChange:e=>l(e.target.value),placeholder:r(`defaultEnginePlaceholder`),className:`w-56`})}),(0,P.jsx)(u,{title:r(`dmScope`),control:(0,P.jsxs)(x,{value:i,onValueChange:e=>f(e),children:[(0,P.jsx)(v,{className:`w-56`,children:(0,P.jsx)(_,{})}),(0,P.jsx)(y,{children:ue.map(e=>(0,P.jsx)(b,{value:e.value,children:r(e.labelKey)},e.value))})]})})]})})}function fe({config:e,updateRuntime:t}){let n=(0,N.useMemo)(()=>ae(e),[e]),[a,o]=(0,N.useState)(n.agents),[s,c]=(0,N.useState)(n.bindings),[l,u]=(0,N.useState)(n.runtimeEntries),[d,m]=(0,N.useState)(n.dmScope),[h,g]=(0,N.useState)(n.companionEnabled),[_,v]=(0,N.useState)(n.defaultContextTokens),[y,b]=(0,N.useState)(n.defaultEngine),x=(0,N.useMemo)(()=>{let e=new Set([`main`]);return a.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[a]);return(0,P.jsxs)(i,{title:r(`runtimePageTitle`),description:r(`runtimePageDescription`),children:[(0,P.jsx)(q,{}),(0,P.jsx)(de,{companionEnabled:h,dmScope:d,defaultContextTokens:_,defaultEngine:y,onCompanionEnabledChange:g,onDmScopeChange:m,onDefaultContextTokensChange:v,onDefaultEngineChange:b}),(0,P.jsx)(le,{entries:l,onUpdateEntry:(e,t)=>u(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>u(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>u(e=>[...e,Z()])}),(0,P.jsx)(se,{agents:a,onUpdateAgent:(e,t)=>{o(n=>n.map((n,r)=>r===e?{...n,...t}:n))},onRemoveAgent:e=>o(t=>t.filter((t,n)=>n!==e)),onAddAgent:()=>o(e=>[...e,Y()]),onSetDefaultAgent:(e,t)=>o(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t))}),(0,P.jsx)(ce,{bindings:s,onUpdateBinding:(e,t)=>{c(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>c(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>c(e=>[...e,X()])}),(0,P.jsx)(M,{children:(0,P.jsxs)(f,{type:`button`,size:`sm`,onClick:()=>{try{let e=$({companionEnabled:h,agents:a,bindings:s,runtimeEntries:l,dmScope:d,defaultContextTokens:_,defaultEngine:y,knownAgentIds:x});t.mutate({data:e})}catch(e){p.error(e instanceof Error?e.message:String(e))}},disabled:t.isPending,children:[(0,P.jsx)(w,{className:`mr-1.5 h-3.5 w-3.5`}),t.isPending?r(`saving`):r(`saveRuntimeSettings`)]})})]})}function pe(){let{data:e,isLoading:t}=k(),n=O();return t||!e?(0,P.jsx)(i,{title:r(`runtimePageTitle`),description:r(`runtimePageDescription`),children:(0,P.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`runtimeLoading`)})}):(0,P.jsx)(fe,{config:e,updateRuntime:n})}export{pe as RuntimeConfig};
|
|
1
|
+
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,a as r}from"./react-Dwvp5yeX.js";import{$t as i,Ft as a,Gt as o,Jt as s,Qt as c,Ut as l,Zt as u,an as d,en as f,in as p,qt as m,un as h}from"./api-BH6Oslx4.js";import{g}from"./mcp-marketplace-page-CIMRYgOY.js";import{a as _,i as v,n as y,r as b,t as x}from"./select-fZ5tifar.js";import{t as S}from"./loader-circle-C75DUmmm.js";import{t as C}from"./plus-TzSIMKWW.js";import{t as ee}from"./rotate-cw-BT8HxlcB.js";import{t as w}from"./save-BZE6H02N.js";import{F as T,Lt as E,Rt as D,Vt as O,_ as k,c as A,f as te,l as j}from"./index-CHcGqqBe.js";import{t as M}from"./form-actions-C8hazgNP.js";var N=e(n(),1),P=t(),F={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},I={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},L={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function R(e){return r(F[e]??`runtimeControlUnavailable`)}function z(e){return r(I[e]??`runtimeControlServiceUnknown`)}function B(e){return r(L[e.environment])}function V(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function H(e){return e?[{action:`start-service`,capability:e.canStartService,label:r(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:r(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:r(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:r(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function U(e){let{busy:t,icon:n}=e;return t?(0,P.jsx)(S,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,P.jsx)(O,{className:`mr-2 h-4 w-4`}):n===`square`?(0,P.jsx)(D,{className:`mr-2 h-4 w-4`}):(0,P.jsx)(ee,{className:`mr-2 h-4 w-4`})}function W(){let{busy:e,busyAction:t,controlView:n,errorMessage:a,pendingRestart:o,visibleLifecycle:u,visibleMessage:f,visibleServiceState:p}=l(),g=H(n??void 0),_=async e=>{let t=V(n,e);if(!t?.available){h.error(s(t?.reasonIfUnavailable)??r(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(r(`runtimeControlStopServiceConfirm`))))try{let t=await m.runRuntimeControlAction(e);h.success(s(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);h.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}},v=async()=>{if(!n?.canRestartApp.available){h.error(s(n?.canRestartApp.reasonIfUnavailable)??r(`runtimeRestartAppUnavailable`));return}if(window.confirm(r(`runtimeControlRestartAppConfirm`)))try{let e=await m.runRuntimeControlAction(`restart-app`);h.success(s(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);h.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}};return(0,P.jsx)(i,{title:r(`runtimeControlTitle`),description:r(`runtimeControlDescription`),children:(0,P.jsxs)(c,{children:[(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:z(p)}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n?B(n):r(`runtimeControlLoading`)})]}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:R(u)}),n?.managementHint?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(n.managementHint)}):null,a&&!e?(0,P.jsx)(`p`,{className:`text-sm text-amber-700`,children:a}):null]}),o?(0,P.jsxs)(`div`,{className:`space-y-3 bg-amber-50/75 p-4 dark:bg-amber-950/20`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:r(`runtimeControlPendingRestartTitle`)}),(0,P.jsx)(`p`,{className:`text-sm text-amber-800`,children:r(`runtimeControlPendingRestartDescription`)}),o.changedPaths.length>0?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:r(`runtimeControlPendingRestartPaths`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.changedPaths.map(e=>(0,P.jsx)(`span`,{className:`rounded-full bg-background/80 px-2.5 py-1 text-xs text-amber-800 dark:text-amber-300`,children:e},e))})]}):null]}):null,(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:g.map(n=>(0,P.jsxs)(d,{type:`button`,variant:n.variant??`default`,onClick:()=>{if(n.action===`restart-app`){v();return}_(n.action)},disabled:!n.capability.available||e,children:[(0,P.jsx)(U,{icon:n.icon,busy:t===n.action}),n.label]},n.action))}),g.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(e.capability.reasonIfUnavailable)},`${e.action}-reason`))]})]})})}function G(e){let{description:t,title:n}=e;return(0,P.jsx)(g,{tone:`neutral`,title:n,description:t})}function K(e){let{children:t}=e;return(0,P.jsx)(i,{title:r(`runtimePresenceTitle`),description:r(`runtimePresenceDescription`),children:(0,P.jsx)(c,{children:t})})}function ne(){let e=o().runtimeControlView?.environment,t=j(e=>e.supported),n=j(e=>e.initialized),i=j(e=>e.busyAction),s=j(e=>e.snapshot);return(0,N.useEffect)(()=>{if(e===`desktop-embedded`){A.start();return}A.markUnsupported()},[e]),e===`desktop-embedded`?(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(g,{tone:`neutral`,title:r(`runtimePresenceBehaviorLabel`),description:s?.closeToBackground?r(`runtimePresenceBehaviorBackground`):r(`runtimePresenceBehaviorQuit`),className:`rounded-xl`})}),!n||t&&!s?(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:r(`runtimePresenceLoading`)}):null,s?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(u,{title:r(`runtimePresenceCloseToBackground`),description:r(`runtimePresenceCloseToBackgroundHelp`),control:(0,P.jsx)(a,{id:`runtime-presence-close-background`,"aria-label":r(`runtimePresenceCloseToBackground`),checked:s.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{A.updatePreferences({closeToBackground:e})}})}),(0,P.jsx)(u,{title:r(`runtimePresenceLaunchAtLogin`),description:s.supportsLaunchAtLogin?r(`runtimePresenceLaunchAtLoginHelp`):s.launchAtLoginReason??r(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,P.jsx)(a,{id:`runtime-presence-launch-login`,"aria-label":r(`runtimePresenceLaunchAtLogin`),checked:s.launchAtLogin,disabled:!s.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{A.updatePreferences({launchAtLogin:e})}})})]}):null]}):e===`managed-local-service`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceManagedLocalTitle`),description:r(`runtimePresenceManagedLocalDescription`)})})}):e===`self-hosted-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceSelfHostedTitle`),description:r(`runtimePresenceSelfHostedDescription`)})})}):e===`shared-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceSharedTitle`),description:r(`runtimePresenceSharedDescription`)})})}):(0,P.jsx)(K,{children:(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:r(`runtimePresenceLoading`)})})}function q(){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(W,{}),(0,P.jsx)(ne,{}),(0,P.jsx)(te,{})]})}var J={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function Y(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function X(){return{agentId:``,match:{channel:``,accountId:``}}}function Z(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:J,configText:JSON.stringify(J,null,2)}}function re(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}}function ie(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function Q(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ae(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(re),bindings:(e.bindings??[]).map(ie),runtimeEntries:Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)})),dmScope:e.session?.dmScope??`per-channel-peer`,defaultContextTokens:e.agents.defaults.contextTokens??2e5,defaultEngine:e.agents.defaults.engine??`native`}}function oe(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}function $(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(r(`agentIdRequiredError`).replace(`{index}`,String(t)));return oe(e)}),n=t.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0)throw Error(`${r(`duplicateAgentId`)}: ${n[0]}`);let i=e.bindings.map((t,n)=>{let i=t.agentId.trim(),a=t.match.channel.trim(),o=t.match.accountId?.trim()??``,s=t.match.peer?.kind,c=t.match.peer?.id?.trim()??``;if(!i)throw Error(r(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!e.knownAgentIds.has(i))throw Error(`${r(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${i}`);if(!a)throw Error(r(`bindingChannelRequired`).replace(`{index}`,String(n)));let l={agentId:i,match:{channel:a}};if(o&&(l.match.accountId=o),s){if(!c)throw Error(r(`bindingPeerIdRequired`).replace(`{index}`,String(n)));l.match.peer={kind:s,id:c}}return l}),a=e.runtimeEntries.reduce((e,t,n)=>{let i=t.id.trim(),a=t.type.trim();if(!i)throw Error(r(`runtimeEntryIdRequired`).replace(`{index}`,String(n)));if(!a)throw Error(r(`runtimeEntryTypeRequired`).replace(`{id}`,i));if(e[i])throw Error(`${r(`runtimeEntryDuplicate`)}: ${i}`);let o=t.configText.trim()?JSON.parse(t.configText):{};if(o&&(typeof o!=`object`||Array.isArray(o)))throw Error(r(`runtimeEntryConfigObjectRequired`).replace(`{id}`,i));return e[i]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:a,config:o??{}},e},{});return{companion:{enabled:e.companionEnabled},agents:{defaults:{contextTokens:Math.max(1e3,e.defaultContextTokens),engine:e.defaultEngine.trim()||`native`},list:t,runtimes:{entries:a}},bindings:i,session:{dmScope:e.dmScope}}}function se({agents:e,onAddAgent:t,onRemoveAgent:n,onSetDefaultAgent:o,onUpdateAgent:s}){return(0,P.jsx)(i,{title:r(`agentList`),description:r(`agentListHelp`),actions:(0,P.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(C,{className:`mr-2 h-4 w-4`}),r(`addAgent`)]}),children:(0,P.jsx)(c,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(p,{value:e.id,onChange:e=>s(t,{id:e.target.value}),placeholder:r(`agentIdPlaceholder`)}),(0,P.jsx)(p,{value:e.workspace??``,onChange:e=>s(t,{workspace:e.target.value}),placeholder:r(`workspaceOverridePlaceholder`)}),(0,P.jsx)(p,{value:e.model??``,onChange:e=>s(t,{model:e.target.value}),placeholder:r(`modelOverridePlaceholder`)}),(0,P.jsx)(p,{value:e.runtime??e.engine??``,onChange:e=>s(t,{runtime:e.target.value}),placeholder:r(`engineOverridePlaceholder`)}),(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,P.jsx)(p,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>s(t,{contextTokens:Q(e.target.value)}),placeholder:r(`contextTokensPlaceholder`)}),(0,P.jsx)(p,{type:`number`,min:1,value:e.maxToolIterations??``,onChange:e=>s(t,{maxToolIterations:Q(e.target.value)}),placeholder:r(`maxToolsPlaceholder`)})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(a,{checked:!!e.default,onCheckedChange:e=>o(t,e)}),(0,P.jsx)(`span`,{children:r(`defaultAgent`)})]}),(0,P.jsxs)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(t),children:[(0,P.jsx)(E,{className:`h-4 w-4 mr-1`}),r(`remove`)]})]})]},`${t}-${e.id}`))})})}function ce({bindings:e,onAddBinding:t,onRemoveBinding:n,onUpdateBinding:a}){return(0,P.jsx)(i,{title:r(`bindings`),description:r(`bindingsHelp`),actions:(0,P.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(C,{className:`mr-2 h-4 w-4`}),r(`addBinding`)]}),children:(0,P.jsx)(c,{children:e.map((e,t)=>{let i=e.match.peer?.kind??``;return(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,P.jsx)(p,{value:e.agentId,onChange:n=>a(t,{...e,agentId:n.target.value}),placeholder:r(`targetAgentIdPlaceholder`)}),(0,P.jsx)(p,{value:e.match.channel,onChange:n=>a(t,{...e,match:{...e.match,channel:n.target.value}}),placeholder:r(`channelPlaceholder`)}),(0,P.jsx)(p,{value:e.match.accountId??``,onChange:n=>a(t,{...e,match:{...e.match,accountId:n.target.value}}),placeholder:r(`accountIdOptionalPlaceholder`)}),(0,P.jsxs)(x,{value:i||`__none__`,onValueChange:n=>{let r=n===`__none__`?``:n;a(t,r?{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}}:{...e,match:{...e.match,peer:void 0}})},children:[(0,P.jsx)(v,{children:(0,P.jsx)(_,{})}),(0,P.jsxs)(y,{children:[(0,P.jsx)(b,{value:`__none__`,children:r(`peerKindOptional`)}),(0,P.jsx)(b,{value:`direct`,children:r(`peerKindDirect`)}),(0,P.jsx)(b,{value:`group`,children:r(`peerKindGroup`)}),(0,P.jsx)(b,{value:`channel`,children:r(`peerKindChannel`)})]})]}),(0,P.jsx)(p,{value:e.match.peer?.id??``,onChange:n=>a(t,{...e,match:{...e.match,peer:i?{kind:i,id:n.target.value}:void 0}}),placeholder:r(`peerIdPlaceholder`)})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(t),children:[(0,P.jsx)(E,{className:`h-4 w-4 mr-1`}),r(`remove`)]})})]},`${t}-${e.agentId}`)})})})}function le({entries:e,onAddEntry:t,onRemoveEntry:n,onUpdateEntry:o}){return(0,P.jsx)(i,{title:r(`runtimeEntries`),description:r(`runtimeEntriesHelp`),actions:(0,P.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(C,{className:`mr-2 h-4 w-4`}),r(`addRuntimeEntry`)]}),children:(0,P.jsx)(c,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(p,{value:e.id,onChange:e=>o(t,{id:e.target.value}),placeholder:r(`runtimeEntryIdPlaceholder`)}),(0,P.jsx)(p,{value:e.label??``,onChange:e=>o(t,{label:e.target.value}),placeholder:r(`runtimeEntryLabelPlaceholder`)}),(0,P.jsx)(p,{value:e.type,onChange:e=>o(t,{type:e.target.value}),placeholder:r(`runtimeEntryTypePlaceholder`)}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg bg-background/65 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:r(`enabled`)}),(0,P.jsx)(a,{checked:e.enabled!==!1,onCheckedChange:e=>o(t,{enabled:e})})]})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:r(`runtimeEntryConfigJson`)}),(0,P.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm`,value:e.configText,onChange:e=>o(t,{configText:e.target.value}),spellCheck:!1})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(d,{type:`button`,variant:`outline`,onClick:()=>n(t),children:[(0,P.jsx)(E,{className:`mr-2 h-4 w-4`}),r(`delete`)]})})]},`${t}-${e.id||`runtime-entry`}`))})})}var ue=[{value:`main`,labelKey:`dmScopeMain`},{value:`per-peer`,labelKey:`dmScopePerPeer`},{value:`per-channel-peer`,labelKey:`dmScopePerChannelPeer`},{value:`per-account-channel-peer`,labelKey:`dmScopePerAccountChannelPeer`}];function de({companionEnabled:e,defaultContextTokens:t,defaultEngine:n,dmScope:o,onCompanionEnabledChange:s,onDefaultContextTokensChange:l,onDefaultEngineChange:d,onDmScopeChange:f}){return(0,P.jsx)(i,{title:r(`dmScope`),description:r(`dmScopeHelp`),children:(0,P.jsxs)(c,{children:[(0,P.jsx)(u,{title:r(`runtimeCompanionEnabled`),description:r(`runtimeCompanionEnabledHelp`),control:(0,P.jsx)(a,{checked:e,onCheckedChange:s})}),(0,P.jsx)(u,{title:r(`defaultContextTokens`),description:r(`defaultContextTokensHelp`),control:(0,P.jsx)(p,{type:`number`,min:1e3,step:1e3,value:t,onChange:e=>l(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3)),className:`w-36`})}),(0,P.jsx)(u,{title:r(`defaultEngine`),description:r(`defaultEngineHelp`),control:(0,P.jsx)(p,{value:n,onChange:e=>d(e.target.value),placeholder:r(`defaultEnginePlaceholder`),className:`w-56`})}),(0,P.jsx)(u,{title:r(`dmScope`),control:(0,P.jsxs)(x,{value:o,onValueChange:e=>f(e),children:[(0,P.jsx)(v,{className:`w-56`,children:(0,P.jsx)(_,{})}),(0,P.jsx)(y,{children:ue.map(e=>(0,P.jsx)(b,{value:e.value,children:r(e.labelKey)},e.value))})]})})]})})}function fe({config:e,updateRuntime:t}){let n=(0,N.useMemo)(()=>ae(e),[e]),[i,a]=(0,N.useState)(n.agents),[o,s]=(0,N.useState)(n.bindings),[c,l]=(0,N.useState)(n.runtimeEntries),[u,p]=(0,N.useState)(n.dmScope),[m,g]=(0,N.useState)(n.companionEnabled),[_,v]=(0,N.useState)(n.defaultContextTokens),[y,b]=(0,N.useState)(n.defaultEngine),x=(0,N.useMemo)(()=>{let e=new Set([`main`]);return i.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[i]);return(0,P.jsxs)(f,{title:r(`runtimePageTitle`),description:r(`runtimePageDescription`),children:[(0,P.jsx)(q,{}),(0,P.jsx)(de,{companionEnabled:m,dmScope:u,defaultContextTokens:_,defaultEngine:y,onCompanionEnabledChange:g,onDmScopeChange:p,onDefaultContextTokensChange:v,onDefaultEngineChange:b}),(0,P.jsx)(le,{entries:c,onUpdateEntry:(e,t)=>l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>l(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>l(e=>[...e,Z()])}),(0,P.jsx)(se,{agents:i,onUpdateAgent:(e,t)=>{a(n=>n.map((n,r)=>r===e?{...n,...t}:n))},onRemoveAgent:e=>a(t=>t.filter((t,n)=>n!==e)),onAddAgent:()=>a(e=>[...e,Y()]),onSetDefaultAgent:(e,t)=>a(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t))}),(0,P.jsx)(ce,{bindings:o,onUpdateBinding:(e,t)=>{s(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>s(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>s(e=>[...e,X()])}),(0,P.jsx)(M,{children:(0,P.jsxs)(d,{type:`button`,size:`sm`,onClick:()=>{try{let e=$({companionEnabled:m,agents:i,bindings:o,runtimeEntries:c,dmScope:u,defaultContextTokens:_,defaultEngine:y,knownAgentIds:x});t.mutate({data:e})}catch(e){h.error(e instanceof Error?e.message:String(e))}},disabled:t.isPending,children:[(0,P.jsx)(w,{className:`mr-1.5 h-3.5 w-3.5`}),t.isPending?r(`saving`):r(`saveRuntimeSettings`)]})})]})}function pe(){let{data:e,isLoading:t}=k(),n=T();return t||!e?(0,P.jsx)(f,{title:r(`runtimePageTitle`),description:r(`runtimePageDescription`),children:(0,P.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`runtimeLoading`)})}):(0,P.jsx)(fe,{config:e,updateRuntime:n})}export{pe as RuntimeConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./dist-
|
|
1
|
+
import{c as e}from"./dist-IRWcJpfm.js";var t=e(`Save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./dist-
|
|
1
|
+
import{c as e}from"./dist-IRWcJpfm.js";var t=e(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),n=e(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]);export{t as n,n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,a as r}from"./react-
|
|
1
|
+
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,a as r}from"./react-Dwvp5yeX.js";import{t as i}from"./navigation-link-kGAcL2N2.js";import{an as a,en as o,in as s,rn as c}from"./api-BH6Oslx4.js";import{a as l,i as u,n as d,r as f,t as p}from"./select-fZ5tifar.js";import{t as m}from"./search-C7Tj40kC.js";import{Gt as h,I as g,_,g as v,v as y}from"./index-CHcGqqBe.js";import{t as b}from"./form-actions-C8hazgNP.js";import{a as x,c as S,l as C,n as w,o as T,r as E,s as D,t as O}from"./config-split-page-B55XD_ZY.js";var k=e(n(),1),A=t(),j=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],M=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],N=[{value:`true`,label:`enabled`},{value:`false`,label:`disabled`}],P={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`,exa:`searchProviderExaDescription`};function F(e){return{activeProvider:e.provider,enabledProviders:e.enabledProviders,maxResults:String(e.defaults.maxResults),providers:{bocha:{apiKey:``,baseUrl:e.providers.bocha.baseUrl,summary:!!e.providers.bocha.summary,freshness:e.providers.bocha.freshness??`noLimit`},tavily:{apiKey:``,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth??`basic`,includeAnswer:!!e.providers.tavily.includeAnswer},brave:{apiKey:``,baseUrl:e.providers.brave.baseUrl},exa:{apiKey:``,baseUrl:e.providers.exa.baseUrl}}}}function I(e){return{provider:e.activeProvider,enabledProviders:e.enabledProviders,defaults:{maxResults:Number(e.maxResults)||10},providers:{bocha:{apiKey:e.providers.bocha.apiKey||void 0,baseUrl:e.providers.bocha.baseUrl,summary:e.providers.bocha.summary,freshness:e.providers.bocha.freshness},tavily:{apiKey:e.providers.tavily.apiKey||void 0,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth,includeAnswer:e.providers.tavily.includeAnswer},brave:{apiKey:e.providers.brave.apiKey||void 0,baseUrl:e.providers.brave.baseUrl},exa:{apiKey:e.providers.exa.apiKey||void 0,baseUrl:e.providers.exa.baseUrl}}}}function L(e){let{label:t,value:n,onChange:r,placeholder:i,type:a=`text`,inputMode:o}=e;return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(c,{children:t}),(0,A.jsx)(s,{type:a,value:n,onChange:e=>r(e.target.value),placeholder:i,inputMode:o,className:`rounded-xl`})]})}function R(e){let{label:t,value:n,options:i,onChange:a}=e;return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(c,{children:t}),(0,A.jsxs)(p,{value:n,onValueChange:a,children:[(0,A.jsx)(u,{className:`rounded-xl`,children:(0,A.jsx)(l,{})}),(0,A.jsx)(d,{children:i.map(e=>(0,A.jsx)(f,{value:e.value,children:r(e.label)},e.value))})]})]})}function z({docsUrl:e}){return e?(0,A.jsx)(i,{href:e,external:!0,children:r(`searchProviderOpenDocs`)}):null}function B(e){let{draft:t,provider:n,search:i,selectedDocsUrl:a,updateProviderDraft:o}=e;if(n===`bocha`){let{bocha:e}=t.providers;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:r(`apiKey`),value:e.apiKey,onChange:e=>o(`bocha`,{apiKey:e}),placeholder:i.providers.bocha.apiKeyMasked||r(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:r(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>o(`bocha`,{baseUrl:e})}),(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:r(`searchProviderSummary`),value:e.summary?`true`:`false`,options:N,onChange:e=>o(`bocha`,{summary:e===`true`})}),(0,A.jsx)(R,{label:r(`searchProviderFreshness`),value:e.freshness,options:j,onChange:e=>o(`bocha`,{freshness:e})})]}),(0,A.jsx)(z,{docsUrl:a??`https://open.bocha.cn`})]})}if(n===`tavily`){let{tavily:e}=t.providers;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:r(`apiKey`),value:e.apiKey,onChange:e=>o(`tavily`,{apiKey:e}),placeholder:i.providers.tavily.apiKeyMasked||r(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:r(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>o(`tavily`,{baseUrl:e})}),(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:r(`searchProviderSearchDepth`),value:e.searchDepth,options:M,onChange:e=>o(`tavily`,{searchDepth:e})}),(0,A.jsx)(R,{label:r(`searchProviderIncludeAnswer`),value:e.includeAnswer?`true`:`false`,options:N,onChange:e=>o(`tavily`,{includeAnswer:e===`true`})})]}),(0,A.jsx)(z,{docsUrl:a})]})}let s=t.providers[n],c=i.providers[n];return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:r(`apiKey`),value:s.apiKey,onChange:e=>o(n,{apiKey:e}),placeholder:c.apiKeyMasked||r(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:r(`searchProviderBaseUrl`),value:s.baseUrl,onChange:e=>o(n,{baseUrl:e})}),(0,A.jsx)(z,{docsUrl:a})]})}function V(e){let{draft:t,providers:n,search:i,selectedProvider:a,onSelect:o}=e;return(0,A.jsxs)(C,{children:[(0,A.jsx)(S,{className:`px-4 py-4`,children:(0,A.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:r(`searchChannels`)})}),(0,A.jsx)(T,{className:`space-y-2 p-3`,children:n.map(e=>{let n=i.providers[e.name],s=t.enabledProviders.includes(e.name);return(0,A.jsx)(O,{onClick:()=>o(e.name),active:a===e.name,className:`p-3`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:e.displayName}),(0,A.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-muted-foreground`,children:r(P[e.name])})]}),(0,A.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,A.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:n.apiKeySet?r(`searchStatusConfigured`):r(`searchStatusNeedsSetup`)}),s?(0,A.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:r(`searchProviderActivated`)}):null]})]})},e.name)})})]})}function H(e){let{initialDraft:t,providers:n,search:i,onSubmit:o,isPending:s}=e,{isMobile:c}=v(),[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(t),p=l&&n.some(e=>e.name===l)?l:c?null:i.provider,g=n.find(e=>e.name===p)??null,_=p?i.providers[p]:null,y=p?d.enabledProviders.includes(p):!1,C=_?.docsUrl??g?.docsUrl;return(0,A.jsxs)(x,{className:`md:min-h-0`,compactView:l?`detail`:`list`,onMobileBack:()=>u(null),mobileListLabel:r(`searchPageTitle`),children:[(0,A.jsx)(V,{draft:d,providers:n,search:i,selectedProvider:p??i.provider,onSelect:u}),g?(0,A.jsx)(w,{children:(0,A.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o(d)},className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsx)(S,{className:`px-5 py-4`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-primary-foreground`,children:(0,A.jsx)(m,{className:`h-5 w-5`})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:g.displayName}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(P[g.name])})]})]}),(0,A.jsx)(a,{type:`button`,variant:y?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=y?d.enabledProviders.filter(e=>e!==p):p?[...d.enabledProviders,p]:d.enabledProviders,t={...d,enabledProviders:e};f(t),o(t)},children:r(y?`searchProviderDeactivate`:`searchProviderActivate`)})]})}),(0,A.jsxs)(T,{className:`space-y-5 px-5 py-4`,children:[(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:r(`searchActiveProvider`),value:d.activeProvider,options:n.map(e=>({value:e.name,label:e.displayName})),onChange:e=>f({...d,activeProvider:e})}),(0,A.jsx)(L,{label:r(`searchDefaultMaxResults`),value:d.maxResults,onChange:e=>f({...d,maxResults:e}),inputMode:`numeric`})]}),(0,A.jsx)(B,{draft:d,provider:p,search:i,selectedDocsUrl:C,updateProviderDraft:(e,t)=>{f(n=>({...n,providers:{...n.providers,[e]:{...n.providers[e],...t}}}))}})]}),(0,A.jsx)(D,{children:(0,A.jsx)(b,{children:(0,A.jsxs)(a,{type:`submit`,size:`sm`,disabled:s,children:[(0,A.jsx)(h,{className:`mr-1.5 h-3.5 w-3.5`}),r(s?`saving`:`saveChanges`)]})})})]})}):(0,A.jsx)(E,{children:(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`searchNoProviderSelected`)})})]})}function U(){let{data:e}=_(),{data:t}=y(),n=g(),i=t?.search??[],a=e?.search;return!a||i.length===0?(0,A.jsx)(o,{title:r(`searchPageTitle`),description:r(`searchPageDescription`),layout:`split`,children:(0,A.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`loading`)})}):(0,A.jsx)(o,{title:r(`searchPageTitle`),description:r(`searchPageDescription`),layout:`split`,children:(0,A.jsx)(H,{initialDraft:F(a),providers:i,search:a,onSubmit:e=>n.mutate({data:I(e)}),isPending:n.isPending},JSON.stringify(a))})}export{U as SearchConfigPage};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,a as r}from"./react-
|
|
1
|
+
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,a as r}from"./react-Dwvp5yeX.js";import{$t as i,Ft as a,Qt as o,Zt as s,an as c,en as l,in as u,un as d}from"./api-BH6Oslx4.js";import{a as f,i as p,n as m,r as h,t as g}from"./select-fZ5tifar.js";import{t as _}from"./plus-TzSIMKWW.js";import{t as v}from"./save-BZE6H02N.js";import{L as y,Lt as b,_ as x}from"./index-CHcGqqBe.js";import{t as S}from"./form-actions-C8hazgNP.js";var C=e(n(),1),w=[`env`,`file`,`exec`];function T(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function E(){return{path:``,source:`env`,provider:``,id:``}}function D(e,t){return t.source===`env`?{...T(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...T(e),source:`file`,path:t.path}:{...T(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
|
|
2
2
|
`),cwd:t.cwd??``,timeoutMs:t.timeoutMs??5e3}}function O(e){return e.source===`env`?{source:`env`,...e.prefix.trim()?{prefix:e.prefix.trim()}:{}}:e.source===`file`?{source:`file`,path:e.path.trim(),format:`json`}:{source:`exec`,command:e.command.trim(),args:e.argsText.split(`
|
|
3
|
-
`).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(e.timeoutMs||5e3))}}function k(e){return e?{enabled:!!e.enabled,defaultEnv:e.defaults.env??``,defaultFile:e.defaults.file??``,defaultExec:e.defaults.exec??``,providers:Object.entries(e.providers).map(([e,t])=>D(e,t)),refs:Object.entries(e.refs).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}))}:{enabled:!0,defaultEnv:``,defaultFile:``,defaultExec:``,providers:[],refs:[]}}function A(e){let t={};for(let[n,i]of e.providers.entries()){let e=i.alias.trim();if(!e)throw Error(`${r(`providerAlias`)} #${n+1} ${r(`isRequired`)}`);if(t[e])throw Error(`${r(`providerAlias`)}: ${e} (${r(`duplicate`)})`);if(i.source===`file`&&!i.path.trim())throw Error(`${r(`secretFilePath`)} #${n+1} ${r(`isRequired`)}`);if(i.source===`exec`&&!i.command.trim())throw Error(`${r(`secretExecCommand`)} #${n+1} ${r(`isRequired`)}`);t[e]=O(i)}let n={};for(let[i,a]of e.refs.entries()){let e=a.path.trim(),o=a.id.trim();if(!e)throw Error(`${r(`secretConfigPath`)} #${i+1} ${r(`isRequired`)}`);if(!o)throw Error(`${r(`secretId`)} #${i+1} ${r(`isRequired`)}`);let s=a.provider.trim();if(s&&!t[s])throw Error(`${r(`secretProviderAlias`)}: ${s} ${r(`notFound`)}`);n[e]={source:a.source,...s?{provider:s}:{},id:o}}return{enabled:e.enabled,defaultEnv:e.defaultEnv.trim(),defaultFile:e.defaultFile.trim(),defaultExec:e.defaultExec.trim(),providers:Object.entries(t).map(([e,t])=>D(e,t)),refs:Object.entries(n).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}))}}function j(e){return{enabled:e.enabled,defaults:{env:e.defaultEnv||null,file:e.defaultFile||null,exec:e.defaultExec||null},providers:Object.fromEntries(e.providers.map(e=>[e.alias.trim(),O(e)]).filter(([e])=>e)),refs:Object.fromEntries(e.refs.map(e=>[e.path.trim(),{source:e.source,...e.provider.trim()?{provider:e.provider.trim()}:{},id:e.id.trim()}]).filter(([e,t])=>e&&t.id))}}var M=t();function N(e){let{defaultEnv:t,defaultFile:n,defaultExec:i,providerAliases:a,onChange:o}=e;return(0,M.jsx)(M.Fragment,{children:[{label:r(`defaultEnvProvider`),value:t,key:`defaultEnv`},{label:r(`defaultFileProvider`),value:n,key:`defaultFile`},{label:r(`defaultExecProvider`),value:i,key:`defaultExec`}].map(e=>(0,M.jsx)(s,{title:e.label,control:(0,M.jsxs)(g,{value:e.value||`__none__`,onValueChange:t=>o(e.key,t===`__none__`?``:t),children:[(0,M.jsx)(p,{className:`w-56`,children:(0,M.jsx)(f,{placeholder:r(`noneOption`)})}),(0,M.jsxs)(m,{children:[(0,M.jsx)(h,{value:`__none__`,children:r(`noneOption`)}),a.map(e=>(0,M.jsx)(h,{value:e,children:e},e))]})]})},e.key))})}function P(e){let{providers:t,onUpdate:n,onRemove:
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(e.timeoutMs||5e3))}}function k(e){return e?{enabled:!!e.enabled,defaultEnv:e.defaults.env??``,defaultFile:e.defaults.file??``,defaultExec:e.defaults.exec??``,providers:Object.entries(e.providers).map(([e,t])=>D(e,t)),refs:Object.entries(e.refs).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}))}:{enabled:!0,defaultEnv:``,defaultFile:``,defaultExec:``,providers:[],refs:[]}}function A(e){let t={};for(let[n,i]of e.providers.entries()){let e=i.alias.trim();if(!e)throw Error(`${r(`providerAlias`)} #${n+1} ${r(`isRequired`)}`);if(t[e])throw Error(`${r(`providerAlias`)}: ${e} (${r(`duplicate`)})`);if(i.source===`file`&&!i.path.trim())throw Error(`${r(`secretFilePath`)} #${n+1} ${r(`isRequired`)}`);if(i.source===`exec`&&!i.command.trim())throw Error(`${r(`secretExecCommand`)} #${n+1} ${r(`isRequired`)}`);t[e]=O(i)}let n={};for(let[i,a]of e.refs.entries()){let e=a.path.trim(),o=a.id.trim();if(!e)throw Error(`${r(`secretConfigPath`)} #${i+1} ${r(`isRequired`)}`);if(!o)throw Error(`${r(`secretId`)} #${i+1} ${r(`isRequired`)}`);let s=a.provider.trim();if(s&&!t[s])throw Error(`${r(`secretProviderAlias`)}: ${s} ${r(`notFound`)}`);n[e]={source:a.source,...s?{provider:s}:{},id:o}}return{enabled:e.enabled,defaultEnv:e.defaultEnv.trim(),defaultFile:e.defaultFile.trim(),defaultExec:e.defaultExec.trim(),providers:Object.entries(t).map(([e,t])=>D(e,t)),refs:Object.entries(n).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}))}}function j(e){return{enabled:e.enabled,defaults:{env:e.defaultEnv||null,file:e.defaultFile||null,exec:e.defaultExec||null},providers:Object.fromEntries(e.providers.map(e=>[e.alias.trim(),O(e)]).filter(([e])=>e)),refs:Object.fromEntries(e.refs.map(e=>[e.path.trim(),{source:e.source,...e.provider.trim()?{provider:e.provider.trim()}:{},id:e.id.trim()}]).filter(([e,t])=>e&&t.id))}}var M=t();function N(e){let{defaultEnv:t,defaultFile:n,defaultExec:i,providerAliases:a,onChange:o}=e;return(0,M.jsx)(M.Fragment,{children:[{label:r(`defaultEnvProvider`),value:t,key:`defaultEnv`},{label:r(`defaultFileProvider`),value:n,key:`defaultFile`},{label:r(`defaultExecProvider`),value:i,key:`defaultExec`}].map(e=>(0,M.jsx)(s,{title:e.label,control:(0,M.jsxs)(g,{value:e.value||`__none__`,onValueChange:t=>o(e.key,t===`__none__`?``:t),children:[(0,M.jsx)(p,{className:`w-56`,children:(0,M.jsx)(f,{placeholder:r(`noneOption`)})}),(0,M.jsxs)(m,{children:[(0,M.jsx)(h,{value:`__none__`,children:r(`noneOption`)}),a.map(e=>(0,M.jsx)(h,{value:e,children:e},e))]})]})},e.key))})}function P(e){let{providers:t,onUpdate:n,onRemove:a,onAdd:s}=e;return(0,M.jsx)(i,{title:r(`secretProvidersTitle`),description:r(`secretProvidersDescription`),actions:(0,M.jsxs)(c,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,children:[(0,M.jsx)(_,{className:`mr-2 h-4 w-4`}),r(`addSecretProvider`)]}),children:(0,M.jsx)(o,{children:t.map((e,t)=>(0,M.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,M.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-3`,children:[(0,M.jsx)(u,{value:e.alias,onChange:e=>n(t,{alias:e.target.value}),placeholder:r(`providerAlias`)}),(0,M.jsxs)(g,{value:e.source,onValueChange:e=>n(t,{source:e}),children:[(0,M.jsx)(p,{children:(0,M.jsx)(f,{})}),(0,M.jsx)(m,{children:w.map(e=>(0,M.jsx)(h,{value:e,children:e},e))})]}),(0,M.jsxs)(c,{type:`button`,variant:`outline`,onClick:()=>a(t),children:[(0,M.jsx)(b,{className:`mr-2 h-4 w-4`}),r(`removeProvider`)]})]}),e.source===`env`?(0,M.jsx)(u,{value:e.prefix,onChange:e=>n(t,{prefix:e.target.value}),placeholder:r(`envPrefix`)}):null,e.source===`file`?(0,M.jsx)(u,{value:e.path,onChange:e=>n(t,{path:e.target.value}),placeholder:r(`secretFilePath`)}):null,e.source===`exec`?(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(u,{value:e.command,onChange:e=>n(t,{command:e.target.value}),placeholder:r(`secretExecCommand`)}),(0,M.jsx)(`textarea`,{className:`min-h-[84px] w-full rounded-lg border border-input bg-background px-3 py-2 font-mono text-xs`,value:e.argsText,onChange:e=>n(t,{argsText:e.target.value}),placeholder:r(`secretExecArgs`)}),(0,M.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 md:grid-cols-2`,children:[(0,M.jsx)(u,{value:e.cwd,onChange:e=>n(t,{cwd:e.target.value}),placeholder:r(`secretExecCwd`)}),(0,M.jsx)(u,{type:`number`,min:1,value:e.timeoutMs,onChange:e=>n(t,{timeoutMs:Number.parseInt(e.target.value,10)||5e3}),placeholder:r(`secretExecTimeoutMs`)})]})]}):null]},`provider-${t}`))})})}function F(e){let{refs:t,providerAliases:n,onUpdate:a,onRemove:s,onAdd:l}=e;return(0,M.jsx)(i,{title:r(`secretRefsTitle`),description:r(`secretRefsDescription`),actions:(0,M.jsxs)(c,{type:`button`,variant:`ghost`,size:`sm`,onClick:l,children:[(0,M.jsx)(_,{className:`mr-2 h-4 w-4`}),r(`addSecretRef`)]}),children:(0,M.jsx)(o,{children:t.map((e,t)=>(0,M.jsx)(`div`,{className:`space-y-3 p-4`,children:(0,M.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,M.jsx)(u,{value:e.path,onChange:e=>a(t,{path:e.target.value}),placeholder:r(`secretConfigPath`)}),(0,M.jsx)(u,{value:e.id,onChange:e=>a(t,{id:e.target.value}),placeholder:r(`secretId`)}),(0,M.jsxs)(g,{value:e.source,onValueChange:e=>a(t,{source:e}),children:[(0,M.jsx)(p,{children:(0,M.jsx)(f,{})}),(0,M.jsx)(m,{children:w.map(e=>(0,M.jsx)(h,{value:e,children:e},e))})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,M.jsxs)(g,{value:e.provider||`__none__`,onValueChange:e=>a(t,{provider:e===`__none__`?``:e}),children:[(0,M.jsx)(p,{children:(0,M.jsx)(f,{placeholder:r(`secretProviderAlias`)})}),(0,M.jsxs)(m,{children:[(0,M.jsx)(h,{value:`__none__`,children:r(`noneOption`)}),n.map(e=>(0,M.jsx)(h,{value:e,children:e},e))]})]}),(0,M.jsx)(c,{type:`button`,variant:`outline`,onClick:()=>s(t),children:(0,M.jsx)(b,{className:`h-4 w-4`})})]})]})},`ref-${t}`))})})}function I(e){let{initialState:t,isPending:n,onSubmit:u}=e,[f,p]=(0,C.useState)(t),m=(0,C.useMemo)(()=>{let e=f.providers.map(e=>e.alias.trim()).filter(Boolean);return Array.from(new Set(e))},[f.providers]);return(0,M.jsxs)(l,{title:r(`secretsPageTitle`),description:r(`secretsPageDescription`),children:[(0,M.jsx)(i,{title:r(`secrets`),description:r(`secretsEnabledHelp`),children:(0,M.jsxs)(o,{children:[(0,M.jsx)(s,{title:r(`enabled`),description:r(`secretsEnabledHelp`),control:(0,M.jsx)(a,{checked:f.enabled,onCheckedChange:e=>p(t=>({...t,enabled:e}))})}),(0,M.jsx)(N,{defaultEnv:f.defaultEnv,defaultFile:f.defaultFile,defaultExec:f.defaultExec,providerAliases:m,onChange:(e,t)=>p(n=>({...n,[e]:t}))})]})}),(0,M.jsx)(P,{providers:f.providers,onUpdate:(e,t)=>{p(n=>({...n,providers:n.providers.map((n,r)=>r===e?{...n,...t}:n)}))},onRemove:e=>p(t=>({...t,providers:t.providers.filter((t,n)=>n!==e)})),onAdd:()=>p(e=>({...e,providers:[...e.providers,T()]}))}),(0,M.jsx)(F,{refs:f.refs,providerAliases:m,onUpdate:(e,t)=>{p(n=>({...n,refs:n.refs.map((n,r)=>r===e?{...n,...t}:n)}))},onRemove:e=>p(t=>({...t,refs:t.refs.filter((t,n)=>n!==e)})),onAdd:()=>p(e=>({...e,refs:[...e.refs,E()]}))}),(0,M.jsx)(S,{children:(0,M.jsxs)(c,{type:`button`,size:`sm`,onClick:()=>{try{u(A(f))}catch(e){d.error(e instanceof Error?e.message:String(e))}},disabled:n,children:[(0,M.jsx)(v,{className:`mr-1.5 h-3.5 w-3.5`}),r(n?`saving`:`save`)]})})]})}function L(){let{data:e,isLoading:t}=x(),n=y();return t?(0,M.jsx)(l,{title:r(`secretsPageTitle`),description:r(`secretsPageDescription`),children:(0,M.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`loading`)})}):(0,M.jsx)(I,{initialState:k(e?.secrets),isPending:n.isPending,onSubmit:e=>n.mutate({data:j(e)})},JSON.stringify(e?.secrets??null))}export{L as SecretsConfigPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jt as e}from"./api-BH6Oslx4.js";export{e as SecurityConfig};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r,V as i}from"./react-
|
|
1
|
+
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r,V as i}from"./react-Dwvp5yeX.js";import{_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,n as h,o as g,p as _,r as v,s as y,u as b,x,y as S}from"./dist-IRWcJpfm.js";var C=e(n(),1),w=t(),T=`focusScope.autoFocusOnMount`,E=`focusScope.autoFocusOnUnmount`,D={bubbles:!1,cancelable:!0},O=`FocusScope`,k=C.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[c,d]=C.useState(null),f=l(i),p=l(a),m=C.useRef(null),h=s(t,e=>d(e)),g=C.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;C.useEffect(()=>{if(r){let e=function(e){if(g.paused||!c)return;let t=e.target;c.contains(t)?m.current=t:P(m.current,{select:!0})},t=function(e){if(g.paused||!c)return;let t=e.relatedTarget;t!==null&&(c.contains(t)||P(m.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&P(c)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,g.paused]),C.useEffect(()=>{if(c){F.add(g);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(T,D);c.addEventListener(T,f),c.dispatchEvent(t),t.defaultPrevented||(A(L(ee(c)),{select:!0}),document.activeElement===e&&P(c))}return()=>{c.removeEventListener(T,f),setTimeout(()=>{let t=new CustomEvent(E,D);c.addEventListener(E,p),c.dispatchEvent(t),t.defaultPrevented||P(e??document.body,{select:!0}),c.removeEventListener(E,p),F.remove(g)},0)}}},[c,f,p,g]);let _=C.useCallback(e=>{if(!n&&!r||g.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=j(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&P(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&P(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,g.paused]);return(0,w.jsx)(u.div,{tabIndex:-1,...o,ref:h,onKeyDown:_})});k.displayName=O;function A(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(P(r,{select:t}),document.activeElement!==n)return}function j(e){let t=ee(e);return[te(t,e),te(t.reverse(),e)]}function ee(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function te(e,t){for(let n of e)if(!M(n,{upTo:t}))return n}function M(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function N(e){return e instanceof HTMLInputElement&&`select`in e}function P(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&N(e)&&t&&e.select()}}var F=ne();function ne(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=I(e,t),e.unshift(t)},remove(t){e=I(e,t),e[0]?.resume()}}}function I(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function L(e){return e.filter(e=>e.tagName!==`A`)}var R=0;function re(){C.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??ie()),document.body.insertAdjacentElement(`beforeend`,e[1]??ie()),R++,()=>{R===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),R--}},[])}function ie(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var z=function(){return z=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},z.apply(this,arguments)};function ae(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function oe(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var B=`right-scroll-bar-position`,V=`width-before-scroll-bar`,se=`with-scroll-bars-hidden`,ce=`--removed-body-scroll-bar-size`;function le(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function ue(e,t){var n=(0,C.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var de=typeof window<`u`?C.useLayoutEffect:C.useEffect,fe=new WeakMap;function pe(e,t){var n=ue(t||null,function(t){return e.forEach(function(e){return le(e,t)})});return de(function(){var t=fe.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||le(e,null)}),i.forEach(function(e){r.has(e)||le(e,a)})}fe.set(n,e)},[e]),n}function me(e){return e}function he(e,t){t===void 0&&(t=me);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function ge(e){e===void 0&&(e={});var t=he(null);return t.options=z({async:!0,ssr:!1},e),t}var _e=function(e){var t=e.sideCar,n=ae(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return C.createElement(r,z({},n))};_e.isSideCarExport=!0;function ve(e,t){return e.useMedium(t),_e}var ye=ge(),be=function(){},xe=C.forwardRef(function(e,t){var n=C.useRef(null),r=C.useState({onScrollCapture:be,onWheelCapture:be,onTouchMoveCapture:be}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=ae(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=pe([n,t]),w=z(z({},b),i);return C.createElement(C.Fragment,null,u&&C.createElement(x,{sideCar:ye,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?C.cloneElement(C.Children.only(s),z(z({},w),{ref:S})):C.createElement(v,z({},w,{className:c,ref:S}),s))});xe.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},xe.classNames={fullWidth:V,zeroRight:B};var Se,Ce=function(){if(Se)return Se;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function we(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Ce();return t&&e.setAttribute(`nonce`,t),e}function Te(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ee(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var De=function(){var e=0,t=null;return{add:function(n){e==0&&(t=we())&&(Te(t,n),Ee(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Oe=function(){var e=De();return function(t,n){C.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ke=function(){var e=Oe();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Ae={left:0,top:0,right:0,gap:0},je=function(e){return parseInt(e||``,10)||0},Me=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[je(n),je(r),je(i)]},Ne=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Ae;var t=Me(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Pe=ke(),H=`data-scroll-locked`,Fe=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
2
2
|
.${se} {
|
|
3
3
|
overflow: hidden ${r};
|
|
4
4
|
padding-right: ${s}px ${r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./dist-
|
|
1
|
+
import{c as e}from"./dist-IRWcJpfm.js";var t=e(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,L as t}from"./react-Dwvp5yeX.js";var n=e();function r({className:e,...r}){return(0,n.jsx)(`div`,{className:t(`animate-pulse rounded-md bg-slate-200`,e),...r})}export{r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r}from"./react-
|
|
1
|
+
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r}from"./react-Dwvp5yeX.js";import{sn as i}from"./api-BH6Oslx4.js";var a=e(n(),1),o=t(),s=i(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,{variants:{tone:{subtle:`border-gray-200 bg-gray-50 text-gray-600`,neutral:`border-gray-200 bg-white text-gray-600`,success:`border-emerald-200 bg-emerald-50 text-emerald-700`,warning:`border-amber-200 bg-amber-50 text-amber-800`,danger:`border-rose-200 bg-rose-50 text-rose-600`,info:`border-primary/20 bg-primary/10 text-primary`}},defaultVariants:{tone:`subtle`}}),c=a.forwardRef(({className:e,tone:t,...n},i)=>(0,o.jsx)(`span`,{ref:i,className:r(s({tone:t}),e),...n}));c.displayName=`TagChip`;export{c as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e}from"./dist-IRWcJpfm.js";var t=e(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);export{t};
|
package/dist/index.html
CHANGED
|
@@ -194,30 +194,30 @@
|
|
|
194
194
|
})();
|
|
195
195
|
</script>
|
|
196
196
|
<title>NextClaw</title>
|
|
197
|
-
<script type="module" crossorigin src="/assets/index-
|
|
197
|
+
<script type="module" crossorigin src="/assets/index-CHcGqqBe.js"></script>
|
|
198
198
|
<link rel="modulepreload" crossorigin href="/assets/chunk-DseTPa7n.js">
|
|
199
199
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-D4M6sveU.js">
|
|
200
|
-
<link rel="modulepreload" crossorigin href="/assets/react-
|
|
201
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
202
|
-
<link rel="modulepreload" crossorigin href="/assets/select-
|
|
203
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
204
|
-
<link rel="modulepreload" crossorigin href="/assets/api-
|
|
205
|
-
<link rel="modulepreload" crossorigin href="/assets/x-
|
|
206
|
-
<link rel="modulepreload" crossorigin href="/assets/confirm-dialog-
|
|
207
|
-
<link rel="modulepreload" crossorigin href="/assets/search-
|
|
208
|
-
<link rel="modulepreload" crossorigin href="/assets/book-open-
|
|
200
|
+
<link rel="modulepreload" crossorigin href="/assets/react-Dwvp5yeX.js">
|
|
201
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-IRWcJpfm.js">
|
|
202
|
+
<link rel="modulepreload" crossorigin href="/assets/select-fZ5tifar.js">
|
|
203
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-BYSUQaO2.js">
|
|
204
|
+
<link rel="modulepreload" crossorigin href="/assets/api-BH6Oslx4.js">
|
|
205
|
+
<link rel="modulepreload" crossorigin href="/assets/x-BMl7cucN.js">
|
|
206
|
+
<link rel="modulepreload" crossorigin href="/assets/confirm-dialog-BCCreI_f.js">
|
|
207
|
+
<link rel="modulepreload" crossorigin href="/assets/search-C7Tj40kC.js">
|
|
208
|
+
<link rel="modulepreload" crossorigin href="/assets/book-open-DGTS6oEO.js">
|
|
209
209
|
<link rel="modulepreload" crossorigin href="/assets/host-capabilities-D9C4CBK5.js">
|
|
210
|
-
<link rel="modulepreload" crossorigin href="/assets/navigation-link-
|
|
211
|
-
<link rel="modulepreload" crossorigin href="/assets/plus-
|
|
212
|
-
<link rel="modulepreload" crossorigin href="/assets/refresh-cw-
|
|
210
|
+
<link rel="modulepreload" crossorigin href="/assets/navigation-link-kGAcL2N2.js">
|
|
211
|
+
<link rel="modulepreload" crossorigin href="/assets/plus-TzSIMKWW.js">
|
|
212
|
+
<link rel="modulepreload" crossorigin href="/assets/refresh-cw-C_oj_h_s.js">
|
|
213
213
|
<link rel="modulepreload" crossorigin href="/assets/middleware-B3k-TSmZ.js">
|
|
214
|
-
<link rel="modulepreload" crossorigin href="/assets/doc-browser-context-
|
|
215
|
-
<link rel="modulepreload" crossorigin href="/assets/doc-browser-
|
|
216
|
-
<link rel="modulepreload" crossorigin href="/assets/loader-circle-
|
|
217
|
-
<link rel="modulepreload" crossorigin href="/assets/tag-chip-
|
|
218
|
-
<link rel="modulepreload" crossorigin href="/assets/skeleton-
|
|
219
|
-
<link rel="modulepreload" crossorigin href="/assets/mcp-marketplace-page-
|
|
220
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
214
|
+
<link rel="modulepreload" crossorigin href="/assets/doc-browser-context-DjTbIbQc.js">
|
|
215
|
+
<link rel="modulepreload" crossorigin href="/assets/doc-browser-D8rNrWHk.js">
|
|
216
|
+
<link rel="modulepreload" crossorigin href="/assets/loader-circle-C75DUmmm.js">
|
|
217
|
+
<link rel="modulepreload" crossorigin href="/assets/tag-chip-CwYZcRoe.js">
|
|
218
|
+
<link rel="modulepreload" crossorigin href="/assets/skeleton-CJLc1CWn.js">
|
|
219
|
+
<link rel="modulepreload" crossorigin href="/assets/mcp-marketplace-page-CIMRYgOY.js">
|
|
220
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Btj8yN4T.css">
|
|
221
221
|
</head>
|
|
222
222
|
|
|
223
223
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/ui",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"zod": "^3.23.8",
|
|
36
36
|
"zustand": "^5.0.2",
|
|
37
37
|
"@nextclaw/agent-chat": "0.3.14",
|
|
38
|
-
"@nextclaw/ncp": "0.8.0",
|
|
39
38
|
"@nextclaw/agent-chat-ui": "0.7.0",
|
|
39
|
+
"@nextclaw/client-sdk": "0.7.1",
|
|
40
|
+
"@nextclaw/ncp": "0.8.0",
|
|
40
41
|
"@nextclaw/ncp-react": "0.5.22",
|
|
41
42
|
"@nextclaw/ncp-http-agent-client": "0.4.19",
|
|
42
|
-
"@nextclaw/client-sdk": "0.7.0",
|
|
43
43
|
"@nextclaw/ncp-toolkit": "0.6.20",
|
|
44
44
|
"@nextclaw/shared": "0.4.25"
|
|
45
45
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LucideIcon } from "lucide-react";
|
|
2
2
|
import {
|
|
3
|
+
Activity,
|
|
3
4
|
Bot,
|
|
4
5
|
BrainCircuit,
|
|
5
6
|
AlarmClock,
|
|
@@ -155,6 +156,11 @@ export function getSettingsNavItems(
|
|
|
155
156
|
label: translate("security"),
|
|
156
157
|
icon: Shield,
|
|
157
158
|
},
|
|
159
|
+
{
|
|
160
|
+
target: "/privacy",
|
|
161
|
+
label: translate("privacy"),
|
|
162
|
+
icon: Activity,
|
|
163
|
+
},
|
|
158
164
|
{
|
|
159
165
|
target: "/search",
|
|
160
166
|
label: translate("searchChannels"),
|
package/src/app/index.tsx
CHANGED
|
@@ -62,6 +62,10 @@ const SecretsConfigPage = lazy(async () => ({
|
|
|
62
62
|
default: (await import("@/features/settings/pages/secrets-config-page"))
|
|
63
63
|
.SecretsConfigPage,
|
|
64
64
|
}));
|
|
65
|
+
const PrivacySettingsPage = lazy(async () => ({
|
|
66
|
+
default: (await import("@/features/settings/pages/privacy-settings-page"))
|
|
67
|
+
.PrivacySettingsPage,
|
|
68
|
+
}));
|
|
65
69
|
const RemoteAccessPage = lazy(async () => ({
|
|
66
70
|
default: (await import("@/features/remote")).RemoteAccessPage,
|
|
67
71
|
}));
|
|
@@ -166,6 +170,10 @@ const protectedRouteDefinitions: ProtectedRouteDefinition[] = [
|
|
|
166
170
|
path: "/security",
|
|
167
171
|
element: createLazyElement(<SecurityConfigPage />),
|
|
168
172
|
},
|
|
173
|
+
{
|
|
174
|
+
path: "/privacy",
|
|
175
|
+
element: createLazyElement(<PrivacySettingsPage />),
|
|
176
|
+
},
|
|
169
177
|
{
|
|
170
178
|
path: "/secrets",
|
|
171
179
|
element: createLazyElement(<SecretsConfigPage />),
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
4
|
import { PanelAppListItem } from '@/features/panel-apps/components/panel-app-list-item';
|
|
5
5
|
|
|
6
|
+
const mainSidebarMutation = vi.hoisted(() => ({
|
|
7
|
+
isPending: false,
|
|
8
|
+
mutate: vi.fn(),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
vi.mock('@/features/panel-apps/hooks/use-panel-apps', () => ({
|
|
12
|
+
useUpdatePanelAppPreferences: () => mainSidebarMutation,
|
|
13
|
+
}));
|
|
14
|
+
|
|
6
15
|
const baseEntry = {
|
|
7
16
|
id: 'demo',
|
|
8
17
|
appId: 'demo',
|
|
@@ -22,17 +31,20 @@ const baseEntry = {
|
|
|
22
31
|
};
|
|
23
32
|
|
|
24
33
|
describe('PanelAppListItem', () => {
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
mainSidebarMutation.isPending = false;
|
|
36
|
+
mainSidebarMutation.mutate.mockReset();
|
|
37
|
+
});
|
|
38
|
+
|
|
25
39
|
it('keeps panel app metadata compact below the icon-title row', () => {
|
|
26
40
|
const { container } = render(
|
|
27
41
|
<PanelAppListItem
|
|
28
42
|
deletePending={false}
|
|
29
43
|
entry={baseEntry}
|
|
30
44
|
favoritePending={false}
|
|
31
|
-
mainSidebarPending={false}
|
|
32
45
|
onDelete={vi.fn()}
|
|
33
46
|
onOpen={vi.fn()}
|
|
34
47
|
onToggleFavorite={vi.fn()}
|
|
35
|
-
onToggleMainSidebar={vi.fn()}
|
|
36
48
|
/>,
|
|
37
49
|
);
|
|
38
50
|
|
|
@@ -48,11 +60,9 @@ describe('PanelAppListItem', () => {
|
|
|
48
60
|
deletePending={false}
|
|
49
61
|
entry={baseEntry}
|
|
50
62
|
favoritePending={false}
|
|
51
|
-
mainSidebarPending={false}
|
|
52
63
|
onDelete={onDelete}
|
|
53
64
|
onOpen={vi.fn()}
|
|
54
65
|
onToggleFavorite={vi.fn()}
|
|
55
|
-
onToggleMainSidebar={vi.fn()}
|
|
56
66
|
/>,
|
|
57
67
|
);
|
|
58
68
|
|
|
@@ -69,39 +79,41 @@ describe('PanelAppListItem', () => {
|
|
|
69
79
|
|
|
70
80
|
it('keeps main-sidebar placement in the low-frequency more-actions menu', async () => {
|
|
71
81
|
const user = userEvent.setup();
|
|
72
|
-
const onToggleMainSidebar = vi.fn();
|
|
73
82
|
const { rerender } = render(
|
|
74
83
|
<PanelAppListItem
|
|
75
84
|
deletePending={false}
|
|
76
85
|
entry={baseEntry}
|
|
77
86
|
favoritePending={false}
|
|
78
|
-
mainSidebarPending={false}
|
|
79
87
|
onDelete={vi.fn()}
|
|
80
88
|
onOpen={vi.fn()}
|
|
81
89
|
onToggleFavorite={vi.fn()}
|
|
82
|
-
onToggleMainSidebar={onToggleMainSidebar}
|
|
83
90
|
/>,
|
|
84
91
|
);
|
|
85
92
|
|
|
86
93
|
expect(screen.queryByRole('button', { name: 'Add to main sidebar' })).toBeNull();
|
|
87
94
|
await user.click(screen.getByRole('button', { name: 'More panel app actions' }));
|
|
88
95
|
await user.click(screen.getByRole('button', { name: 'Add to main sidebar' }));
|
|
89
|
-
expect(
|
|
96
|
+
expect(mainSidebarMutation.mutate).toHaveBeenCalledWith({
|
|
97
|
+
id: 'demo',
|
|
98
|
+
preferences: { mainSidebar: true },
|
|
99
|
+
});
|
|
90
100
|
|
|
91
101
|
rerender(
|
|
92
102
|
<PanelAppListItem
|
|
93
103
|
deletePending={false}
|
|
94
104
|
entry={{ ...baseEntry, mainSidebar: true }}
|
|
95
105
|
favoritePending={false}
|
|
96
|
-
mainSidebarPending={false}
|
|
97
106
|
onDelete={vi.fn()}
|
|
98
107
|
onOpen={vi.fn()}
|
|
99
108
|
onToggleFavorite={vi.fn()}
|
|
100
|
-
onToggleMainSidebar={onToggleMainSidebar}
|
|
101
109
|
/>,
|
|
102
110
|
);
|
|
103
111
|
expect(screen.queryByRole('button', { name: 'Remove from main sidebar' })).toBeNull();
|
|
104
112
|
await user.click(screen.getByRole('button', { name: 'More panel app actions' }));
|
|
105
|
-
|
|
113
|
+
await user.click(screen.getByRole('button', { name: 'Remove from main sidebar' }));
|
|
114
|
+
expect(mainSidebarMutation.mutate).toHaveBeenLastCalledWith({
|
|
115
|
+
id: 'demo',
|
|
116
|
+
preferences: { mainSidebar: false },
|
|
117
|
+
});
|
|
106
118
|
});
|
|
107
119
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
2
3
|
import { MemoryRouter } from "react-router-dom";
|
|
3
4
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
5
|
import {
|
|
@@ -9,10 +10,15 @@ import type { PanelAppEntryView } from "@/shared/lib/api";
|
|
|
9
10
|
|
|
10
11
|
const mocks = vi.hoisted(() => ({
|
|
11
12
|
entries: [] as PanelAppEntryView[],
|
|
13
|
+
mutate: vi.fn(),
|
|
12
14
|
}));
|
|
13
15
|
|
|
14
16
|
vi.mock("@/features/panel-apps/hooks/use-panel-apps", () => ({
|
|
15
17
|
usePanelApps: () => ({ data: { entries: mocks.entries } }),
|
|
18
|
+
useUpdatePanelAppPreferences: () => ({
|
|
19
|
+
isPending: false,
|
|
20
|
+
mutate: mocks.mutate,
|
|
21
|
+
}),
|
|
16
22
|
}));
|
|
17
23
|
|
|
18
24
|
function createEntry(overrides: Partial<PanelAppEntryView> = {}): PanelAppEntryView {
|
|
@@ -38,6 +44,7 @@ function createEntry(overrides: Partial<PanelAppEntryView> = {}): PanelAppEntryV
|
|
|
38
44
|
describe("PanelAppMainSidebarNav", () => {
|
|
39
45
|
beforeEach(() => {
|
|
40
46
|
mocks.entries = [];
|
|
47
|
+
mocks.mutate.mockReset();
|
|
41
48
|
});
|
|
42
49
|
|
|
43
50
|
it("projects only manually added apps in persisted order", () => {
|
|
@@ -71,6 +78,50 @@ describe("PanelAppMainSidebarNav", () => {
|
|
|
71
78
|
expect(screen.queryByText("Hidden")).toBeNull();
|
|
72
79
|
});
|
|
73
80
|
|
|
81
|
+
it("removes an expanded entry from its hover actions without nesting the button in the link", async () => {
|
|
82
|
+
const user = userEvent.setup();
|
|
83
|
+
mocks.entries = [
|
|
84
|
+
createEntry({ appId: "publisher.todo", mainSidebar: true, title: "Todo" }),
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
render(
|
|
88
|
+
<MemoryRouter initialEntries={["/apps/panel/publisher.todo"]}>
|
|
89
|
+
<PanelAppMainSidebarNav isCollapsed={false} />
|
|
90
|
+
</MemoryRouter>,
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const link = screen.getByRole("link", { name: "Todo" });
|
|
94
|
+
const menuButton = screen.getByRole("button", {
|
|
95
|
+
name: "More panel app actions: Todo",
|
|
96
|
+
});
|
|
97
|
+
expect(link.contains(menuButton)).toBe(false);
|
|
98
|
+
expect(menuButton.className).toContain("group-hover/panel-app:opacity-100");
|
|
99
|
+
|
|
100
|
+
await user.click(menuButton);
|
|
101
|
+
await user.click(screen.getByRole("button", { name: "Remove from main sidebar" }));
|
|
102
|
+
|
|
103
|
+
expect(mocks.mutate).toHaveBeenCalledWith({
|
|
104
|
+
id: "demo",
|
|
105
|
+
preferences: { mainSidebar: false },
|
|
106
|
+
});
|
|
107
|
+
expect(link.getAttribute("aria-current")).toBe("page");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("keeps the collapsed rail as one navigation target", () => {
|
|
111
|
+
mocks.entries = [
|
|
112
|
+
createEntry({ appId: "publisher.todo", mainSidebar: true, title: "Todo" }),
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
render(
|
|
116
|
+
<MemoryRouter>
|
|
117
|
+
<PanelAppMainSidebarNav isCollapsed />
|
|
118
|
+
</MemoryRouter>,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
expect(screen.getByRole("link", { name: "Todo" })).toBeTruthy();
|
|
122
|
+
expect(screen.queryByRole("button", { name: "More panel app actions: Todo" })).toBeNull();
|
|
123
|
+
});
|
|
124
|
+
|
|
74
125
|
it("renders no section when no app was manually added", () => {
|
|
75
126
|
const { container } = render(
|
|
76
127
|
<MemoryRouter>
|