@nextclaw/ui 0.12.20-beta.0 → 0.12.20-beta.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 +19 -0
- package/dist/assets/api-BcqDx0tm.js +15 -0
- package/dist/assets/app-manager-provider-DVYBjif-.js +1 -0
- package/dist/assets/{app-navigation.config-BORqHkbN.js → app-navigation.config-BOVDFMnp.js} +1 -1
- package/dist/assets/{channels-list-page-sISO_4Yj.js → channels-list-page-CsoI4OJm.js} +2 -2
- package/dist/assets/{chat-ChCu7LQD.js → chat-ahMH_i_K.js} +6 -6
- package/dist/assets/chat-page-BxlXY-MB.js +1 -0
- package/dist/assets/chunk-JZWAC4HX-u4uYphxM.js +3 -0
- package/dist/assets/{desktop-update-config-BfJ5iSeY.js → desktop-update-config-CD6-2PfI.js} +1 -1
- package/dist/assets/{dialog-B-CXiFPZ.js → dialog-csshWetU.js} +1 -1
- package/dist/assets/{dist-DYVfg3q5.js → dist-Bl94Ahwx.js} +1 -1
- package/dist/assets/{es2015-BXroVnPi.js → es2015-JCM5-KtW.js} +1 -1
- package/dist/assets/index-CM-57d8J.js +2 -0
- package/dist/assets/index-D8MKmXtO.css +1 -0
- package/dist/assets/marketplace-page-DJGDpTAo.js +1 -0
- package/dist/assets/{marketplace-page-C9oZ01rM.js → marketplace-page-DxlxHCFm.js} +2 -2
- package/dist/assets/{mcp-marketplace-page-DuEixgSs.js → mcp-marketplace-page-5UjYRWOR.js} +2 -2
- package/dist/assets/mcp-marketplace-page-C1XaHZZO.js +1 -0
- package/dist/assets/{model-config-mfhqEZBG.js → model-config-PccJ9XyH.js} +1 -1
- package/dist/assets/{notice-card-CozHB03G.js → notice-card-CCgk6FvF.js} +1 -1
- package/dist/assets/{popover-CPUPma-w.js → popover-YAsxDBhY.js} +1 -1
- package/dist/assets/{provider-scoped-model-input-CL9sti2I.js → provider-scoped-model-input-CzpF7cug.js} +1 -1
- package/dist/assets/{providers-list-HPmL2akJ.js → providers-list-8qDMER8o.js} +1 -1
- package/dist/assets/remote-D4TtLPAp.js +1 -0
- package/dist/assets/runtime-config-page-DWJHrV7H.js +1 -0
- package/dist/assets/{search-config-Bcnk9VlL.js → search-config-D3a65l3r.js} +1 -1
- package/dist/assets/{secrets-config-Dde-5Y1w.js → secrets-config-CoMlR_7i.js} +2 -2
- package/dist/assets/{select-BELPuXLW.js → select-DIZrwsKU.js} +1 -1
- package/dist/assets/{sessions-config-page-CG49_0Z6.js → sessions-config-page-QjH5tgjr.js} +2 -2
- package/dist/assets/{setting-row-D5DtT6Ny.js → setting-row-DiQyrE81.js} +1 -1
- package/dist/assets/{tag-chip-D9BWWgYg.js → tag-chip-C3wDBe_-.js} +1 -1
- package/dist/assets/theme-provider-W704JWF8.js +1 -0
- package/dist/assets/{tooltip-CI0rpNee.js → tooltip-Dq5Xehpk.js} +1 -1
- package/dist/assets/use-config-BQJjq1mP.js +1 -0
- package/dist/assets/{use-confirm-dialog-hbynwWf2.js → use-confirm-dialog-DBoV5n5P.js} +1 -1
- package/dist/assets/{use-infinite-scroll-loader-Cw5qQr3-.js → use-infinite-scroll-loader-JAicqVC5.js} +1 -1
- package/dist/assets/{use-viewport-layout-CWHVDC6z.js → use-viewport-layout-BX3XqzJ4.js} +1 -1
- package/dist/index.html +17 -17
- package/package.json +8 -6
- package/src/app/hooks/use-realtime-query-bridge.ts +5 -5
- package/src/features/channels/components/config/channel-form.tsx +3 -3
- package/src/features/chat/hooks/use-ncp-chat-page-data.ts +7 -6
- package/src/features/chat/pages/ncp-chat-page.test.ts +22 -8
- package/src/features/chat/utils/chat-session-preference-governance.utils.test.tsx +114 -0
- package/src/features/chat/utils/chat-session-preference-governance.utils.ts +30 -36
- package/src/shared/components/common/brand-header.test.tsx +7 -2
- package/src/shared/components/common/brand-header.tsx +34 -4
- package/src/shared/lib/api/index.ts +12 -12
- package/src/shared/lib/api/ncp-session.test.ts +17 -18
- package/src/shared/lib/api/raw-client.utils.ts +3 -126
- package/src/shared/lib/api/services/agents.service.ts +18 -0
- package/src/shared/lib/api/services/channel-auth.service.ts +21 -0
- package/src/shared/lib/api/{client.ts → services/client.service.ts} +45 -1
- package/src/shared/lib/api/services/config.service.ts +171 -0
- package/src/shared/lib/api/services/marketplace.service.ts +66 -0
- package/src/shared/lib/api/services/mcp-marketplace.service.ts +70 -0
- package/src/shared/lib/api/services/ncp-attachments.service.ts +14 -0
- package/src/shared/lib/api/services/ncp-session.service.ts +39 -0
- package/src/shared/lib/api/services/remote.service.ts +50 -0
- package/src/shared/lib/api/services/runtime-control.service.ts +18 -0
- package/src/shared/lib/api/services/runtime-update.service.ts +26 -0
- package/src/shared/lib/api/services/server-path.service.ts +16 -0
- package/src/shared/lib/transport/index.ts +1 -0
- package/src/shared/lib/transport/local-transport.service.ts +24 -4
- package/src/shared/lib/transport/remote-transport.service.ts +1 -1
- package/src/shared/lib/transport/request-raw-api-response.utils.ts +133 -0
- package/src/shared/lib/transport/transport.types.ts +8 -2
- package/dist/assets/api-C412zuay.js +0 -15
- package/dist/assets/app-manager-provider-Cm-KiZZG.js +0 -1
- package/dist/assets/chat-page-BCaNZJGT.js +0 -1
- package/dist/assets/chunk-JZWAC4HX-DvbcIVPf.js +0 -3
- package/dist/assets/index-CUmk8xFK.css +0 -1
- package/dist/assets/index-CqPDhosM.js +0 -2
- package/dist/assets/marketplace-page-C8uaWkfd.js +0 -1
- package/dist/assets/mcp-marketplace-page-rNqr6ZpD.js +0 -1
- package/dist/assets/remote-oDlAdgVA.js +0 -1
- package/dist/assets/runtime-config-page-BCshTAAE.js +0 -1
- package/dist/assets/theme-provider-DeBrTglS.js +0 -1
- package/dist/assets/use-config-CrWZ_TSF.js +0 -1
- package/src/shared/lib/api/agents.ts +0 -34
- package/src/shared/lib/api/channel-auth.ts +0 -35
- package/src/shared/lib/api/config.ts +0 -362
- package/src/shared/lib/api/marketplace.ts +0 -156
- package/src/shared/lib/api/mcp-marketplace.ts +0 -138
- package/src/shared/lib/api/ncp-attachments.ts +0 -41
- package/src/shared/lib/api/ncp-session.ts +0 -78
- package/src/shared/lib/api/remote.ts +0 -86
- package/src/shared/lib/api/runtime-control.ts +0 -34
- package/src/shared/lib/api/runtime-update.service.ts +0 -50
- package/src/shared/lib/api/server-path.ts +0 -46
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,n as r,p as i,t as a,u as o}from"./i18n-C5Mibli1.js";import{
|
|
2
|
-
`).trim()}function W({message:e}){let t=H(e.role),n=t===`user`,i=U(e);return(0,V.jsx)(`div`,{className:o(`flex w-full mb-6`,n?`justify-end`:`justify-start`),children:(0,V.jsxs)(`div`,{className:o(`max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm`,n?`bg-primary text-white rounded-tr-sm`:`bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50`),children:[(0,V.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:n?(0,V.jsx)(g,{className:`w-4 h-4 text-primary-100`}):(0,V.jsx)(f,{className:`w-4 h-4 text-gray-400`})}),(0,V.jsxs)(`div`,{className:`flex-1 space-y-1 overflow-x-hidden`,children:[(0,V.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 mb-2`,children:[(0,V.jsx)(`span`,{className:o(`font-semibold text-xs capitalize`,n?`text-primary-50`:`text-gray-900`),children:t}),(0,V.jsx)(`span`,{className:o(`text-[10px]`,n?`text-primary-200`:`text-gray-400`),children:r(e.timestamp)})]}),(0,V.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-relaxed text-[15px]`,children:i||`-`})]})]})})}function G(e){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(e.session.label||``),[c,u]=(0,B.useState)(e.session.preferredModel||``);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>r(e=>!e),className:o(`h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold`,n?`bg-gray-100 text-gray-900`:`hover:bg-gray-50 hover:text-gray-900`),children:[(0,V.jsx)(D,{className:`w-3.5 h-3.5 mr-1.5`}),t(`sessionsMetadata`)]}),n?(0,V.jsxs)(`div`,{className:`flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in`,children:[(0,V.jsx)(l,{placeholder:t(`sessionsLabelPlaceholder`),value:i,onChange:e=>a(e.target.value),className:`h-8 text-sm bg-white`}),(0,V.jsx)(l,{placeholder:t(`sessionsModelPlaceholder`),value:c,onChange:e=>u(e.target.value),className:`h-8 text-sm bg-white`}),(0,V.jsx)(s,{size:`sm`,onClick:()=>{e.onSave({label:i,preferredModel:c}),r(!1)},className:`h-8 px-4 shrink-0 shadow-none`,disabled:e.isPending,children:t(`sessionsSaveMeta`)})]}):null]})}function K(){return(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white`,children:[(0,V.jsx)(`div`,{className:`w-20 h-20 bg-gray-50 rounded-3xl flex items-center justify-center mb-6 border border-gray-100 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.02)] rotate-3`,children:(0,V.jsx)(z,{className:`h-8 w-8 text-gray-300 -rotate-3`})}),(0,V.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 mb-2`,children:t(`sessionsNoSelectionTitle`)}),(0,V.jsx)(`p`,{className:`text-sm text-center max-w-sm leading-relaxed`,children:t(`sessionsNoSelectionDescription`)})]})}function q(e){let n=j(e.sessionKey,300),r=k(),i=A(),{confirm:a,ConfirmDialog:o}=L();return(0,V.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200`,children:[r.isPending||i.isPending?(0,V.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20`,children:(0,V.jsx)(`div`,{className:`h-full bg-primary animate-pulse w-1/3 rounded-r-full`})}):null,e.sessionKey&&e.session&&e.summary&&e.channelLabel?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`shrink-0 border-b border-gray-100 bg-white px-4 py-4 z-10 space-y-4 sm:px-8 sm:py-5`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,V.jsx)(`div`,{className:`h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0`,children:(0,V.jsx)(E,{className:`h-6 w-6`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5 mb-1.5`,children:[(0,V.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 tracking-tight`,children:e.session.label?.trim()||e.session.key.split(`:`).pop()||e.session.key}),(0,V.jsx)(`span`,{className:`text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest`,children:e.channelLabel}),e.summary.status===`running`?(0,V.jsx)(h,{status:`running`,className:`h-4 w-4`}):null]}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70`,title:e.sessionKey,children:e.sessionKey})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,V.jsx)(G,{session:e.session,isPending:r.isPending,onSave:t=>{e.sessionKey&&r.mutate({sessionId:e.sessionKey,data:{label:t.label.trim()||null,preferredModel:t.preferredModel.trim()||null}})}},e.session.key),(0,V.jsx)(s,{variant:`outline`,size:`sm`,onClick:async()=>{e.sessionKey&&await a({title:t(`sessionsDeleteConfirm`)+`?`,variant:`destructive`,confirmLabel:t(`sessionsDeleteConfirm`)})&&i.mutate({sessionId:e.sessionKey},{onSuccess:()=>e.onClearSelection()})},className:`h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500`,children:t(`delete`)})]})]})}),(0,V.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 relative [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full sm:p-6`,children:[n.isLoading?(0,V.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10`,children:(0,V.jsxs)(`div`,{className:`flex flex-col items-center gap-3 animate-pulse`,children:[(0,V.jsx)(T,{className:`w-6 h-6 text-primary animate-spin`}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-gray-500`,children:t(`sessionsHistoryLoading`)})]})}):null,n.error?(0,V.jsx)(`div`,{className:`text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm`,children:n.error.message}):null,!n.isLoading&&n.data?.messages.length===0?(0,V.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-gray-400`,children:[(0,V.jsx)(p,{className:`w-12 h-12 mb-3 text-gray-300`}),(0,V.jsx)(`p`,{className:`text-sm`,children:t(`sessionsEmpty`)})]}):null,(0,V.jsx)(`div`,{className:`max-w-3xl mx-auto`,children:(n.data?.messages??[]).map(e=>(0,V.jsx)(W,{message:e},e.id))})]})]}):(0,V.jsx)(K,{}),(0,V.jsx)(o,{})]})}var J=`__unknown_channel__`;function Y(e){let t=e.indexOf(`:`);return t<=0?J:e.slice(0,t).trim()||J}function X(e){return e===J?t(`sessionsUnknownChannel`):e}function Z(e){return(0,V.jsxs)(`button`,{onClick:e.onSelect,className:o(`w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group`,e.isSelected?`bg-brand-50 border border-brand-100/50`:`bg-transparent border border-transparent hover:bg-gray-50/80`),children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between mb-1.5`,children:[(0,V.jsx)(`div`,{className:o(`font-semibold truncate pr-2 flex-1 text-sm`,e.isSelected?`text-brand-800`:`text-gray-900`),children:_(e.session)}),(0,V.jsx)(`div`,{className:o(`text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize`,e.isSelected?`bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]`:`bg-gray-100 text-gray-500`),children:e.channelLabel})]}),(0,V.jsxs)(`div`,{className:o(`flex items-center text-xs justify-between mt-2 font-medium`,e.isSelected?`text-brand-600/80`:`text-gray-400`),children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:e.summary.status===`running`?(0,V.jsx)(h,{status:`running`}):null}),(0,V.jsx)(R,{className:`w-3.5 h-3.5 opacity-70`}),(0,V.jsx)(`span`,{className:`truncate max-w-[100px]`,children:a(e.summary.updatedAt)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(p,{className:`w-3.5 h-3.5 opacity-70`}),(0,V.jsx)(`span`,{children:e.summary.messageCount})]})]})]})}function Q(){let{isMobile:e}=O(),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(null),[d,f]=(0,B.useState)(`all`),p=M({limit:100}),h=(0,B.useMemo)(()=>p.data?.sessions??[],[p.data?.sessions]),g=(0,B.useMemo)(()=>y(h),[h]),_=(0,B.useMemo)(()=>new Map(h.map(e=>[e.sessionId,e])),[h]),E=(0,B.useMemo)(()=>g.filter(e=>d!==`all`&&Y(e.key)!==d?!1:v(e,n)),[n,d,g]),D=(0,B.useMemo)(()=>{let e=new Set;for(let t of g)e.add(Y(t.key));return Array.from(e).sort((e,t)=>e===J?1:t===J?-1:e.localeCompare(t))},[g]),k=i&&_.has(i)?i:null,A=(0,B.useMemo)(()=>g.find(e=>e.key===k)??null,[k,g]),j=k?_.get(k)??null:null,L=A?X(Y(A.key)):null;return(0,V.jsxs)(u,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,V.jsx)(c,{title:t(`sessionsPageTitle`),description:t(`sessionsPageDescription`)}),(0,V.jsxs)(F,{className:`xl:min-h-0`,mobileView:e?k?`detail`:`list`:void 0,onMobileBack:()=>a(null),mobileListLabel:t(`sessionsPageTitle`),children:[(0,V.jsxs)(N,{className:`xl:w-[320px] xl:flex-none`,children:[(0,V.jsxs)(P,{className:`space-y-3 px-4 py-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`span`,{className:`text-[11px] font-semibold text-gray-400 uppercase tracking-wider`,children:[g.length,` `,t(`sessionsListTitle`)]}),(0,V.jsx)(s,{variant:`ghost`,size:`icon`,className:`h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>p.refetch(),children:(0,V.jsx)(T,{className:o(`h-3.5 w-3.5`,p.isFetching&&`animate-spin`)})})]}),(0,V.jsxs)(w,{value:d,onValueChange:f,children:[(0,V.jsx)(x,{className:`w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700`,children:(0,V.jsx)(b,{placeholder:t(`sessionsAllChannels`)})}),(0,V.jsxs)(S,{className:`rounded-xl shadow-lg border-gray-100 max-w-[280px]`,children:[(0,V.jsx)(C,{value:`all`,className:`rounded-lg text-xs`,children:t(`sessionsAllChannels`)}),D.map(e=>(0,V.jsx)(C,{value:e,className:`rounded-lg text-xs truncate pr-6`,children:X(e)},e))]})]}),(0,V.jsxs)(`div`,{className:`relative w-full`,children:[(0,V.jsx)(m,{className:`h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400`}),(0,V.jsx)(l,{value:n,onChange:e=>r(e.target.value),placeholder:t(`sessionsSearchPlaceholder`),className:`pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs`})]})]}),(0,V.jsx)(I,{className:`space-y-1 p-3 pb-10`,children:p.isLoading?(0,V.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:t(`sessionsLoading`)}):E.length===0?(0,V.jsxs)(`div`,{className:`text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4`,children:[(0,V.jsx)(z,{className:`w-8 h-8 mx-auto mb-2 text-gray-300`}),t(`sessionsEmpty`)]}):E.map(e=>{let t=_.get(e.key);return t?(0,V.jsx)(Z,{session:e,summary:t,channelLabel:X(Y(e.key)),isSelected:k===e.key,onSelect:()=>a(e.key)},e.key):null})})]}),(0,V.jsx)(q,{sessionKey:k,session:A,summary:j,channelLabel:L,onClearSelection:()=>a(null)})]})]})}export{Q as SessionsConfig};
|
|
1
|
+
import{_ as e,i as t,m as n,n as r,p as i,t as a,u as o}from"./i18n-C5Mibli1.js";import{At as s,Dt as c,Ot as l,jt as u}from"./api-BcqDx0tm.js";import{t as d}from"./createLucideIcon-BZkY6emz.js";import{_ as f,m as p}from"./theme-provider-W704JWF8.js";import{t as m}from"./search-vChioOoe.js";import{F as h,L as g,O as _,d as v,u as y}from"./chat-ahMH_i_K.js";import{a as b,i as x,n as S,r as C,t as w}from"./select-DIZrwsKU.js";import{t as T}from"./refresh-cw-BxojR62w.js";import{t as E}from"./hash-zajSTDXZ.js";import{t as D}from"./settings-CiRChctQ.js";import{t as O}from"./use-viewport-layout-BX3XqzJ4.js";import{S as k,c as A,f as j,m as M}from"./use-config-BQJjq1mP.js";import{a as N,c as P,i as F,o as I}from"./config-split-page-BMRGuCJQ.js";import{t as L}from"./use-confirm-dialog-DBoV5n5P.js";var R=d(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),z=d(`Inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),B=e(n(),1),V=i();function H(e){return e===`service`?`system`:e===`tool`?`tool`:e}function U(e){let t=[];for(let n of e.parts){if(n.type===`text`||n.type===`rich-text`||n.type===`reasoning`){t.push(n.text);continue}if(n.type!==`tool-invocation`)continue;let e=n.toolName?.trim()?`[${n.toolName.trim()}]`:`[tool]`;if(n.state===`result`&&typeof n.result==`string`&&n.result.trim()){t.push(`${e} ${n.result.trim()}`);continue}t.push(e)}return t.join(`
|
|
2
|
+
`).trim()}function W({message:e}){let t=H(e.role),n=t===`user`,i=U(e);return(0,V.jsx)(`div`,{className:o(`flex w-full mb-6`,n?`justify-end`:`justify-start`),children:(0,V.jsxs)(`div`,{className:o(`max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm`,n?`bg-primary text-white rounded-tr-sm`:`bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50`),children:[(0,V.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:n?(0,V.jsx)(g,{className:`w-4 h-4 text-primary-100`}):(0,V.jsx)(f,{className:`w-4 h-4 text-gray-400`})}),(0,V.jsxs)(`div`,{className:`flex-1 space-y-1 overflow-x-hidden`,children:[(0,V.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 mb-2`,children:[(0,V.jsx)(`span`,{className:o(`font-semibold text-xs capitalize`,n?`text-primary-50`:`text-gray-900`),children:t}),(0,V.jsx)(`span`,{className:o(`text-[10px]`,n?`text-primary-200`:`text-gray-400`),children:r(e.timestamp)})]}),(0,V.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-relaxed text-[15px]`,children:i||`-`})]})]})})}function G(e){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(e.session.label||``),[c,l]=(0,B.useState)(e.session.preferredModel||``);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>r(e=>!e),className:o(`h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold`,n?`bg-gray-100 text-gray-900`:`hover:bg-gray-50 hover:text-gray-900`),children:[(0,V.jsx)(D,{className:`w-3.5 h-3.5 mr-1.5`}),t(`sessionsMetadata`)]}),n?(0,V.jsxs)(`div`,{className:`flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in`,children:[(0,V.jsx)(s,{placeholder:t(`sessionsLabelPlaceholder`),value:i,onChange:e=>a(e.target.value),className:`h-8 text-sm bg-white`}),(0,V.jsx)(s,{placeholder:t(`sessionsModelPlaceholder`),value:c,onChange:e=>l(e.target.value),className:`h-8 text-sm bg-white`}),(0,V.jsx)(u,{size:`sm`,onClick:()=>{e.onSave({label:i,preferredModel:c}),r(!1)},className:`h-8 px-4 shrink-0 shadow-none`,disabled:e.isPending,children:t(`sessionsSaveMeta`)})]}):null]})}function K(){return(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white`,children:[(0,V.jsx)(`div`,{className:`w-20 h-20 bg-gray-50 rounded-3xl flex items-center justify-center mb-6 border border-gray-100 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.02)] rotate-3`,children:(0,V.jsx)(z,{className:`h-8 w-8 text-gray-300 -rotate-3`})}),(0,V.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 mb-2`,children:t(`sessionsNoSelectionTitle`)}),(0,V.jsx)(`p`,{className:`text-sm text-center max-w-sm leading-relaxed`,children:t(`sessionsNoSelectionDescription`)})]})}function q(e){let n=j(e.sessionKey,300),r=k(),i=A(),{confirm:a,ConfirmDialog:o}=L();return(0,V.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200`,children:[r.isPending||i.isPending?(0,V.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20`,children:(0,V.jsx)(`div`,{className:`h-full bg-primary animate-pulse w-1/3 rounded-r-full`})}):null,e.sessionKey&&e.session&&e.summary&&e.channelLabel?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`shrink-0 border-b border-gray-100 bg-white px-4 py-4 z-10 space-y-4 sm:px-8 sm:py-5`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,V.jsx)(`div`,{className:`h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0`,children:(0,V.jsx)(E,{className:`h-6 w-6`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5 mb-1.5`,children:[(0,V.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 tracking-tight`,children:e.session.label?.trim()||e.session.key.split(`:`).pop()||e.session.key}),(0,V.jsx)(`span`,{className:`text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest`,children:e.channelLabel}),e.summary.status===`running`?(0,V.jsx)(h,{status:`running`,className:`h-4 w-4`}):null]}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70`,title:e.sessionKey,children:e.sessionKey})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,V.jsx)(G,{session:e.session,isPending:r.isPending,onSave:t=>{e.sessionKey&&r.mutate({sessionId:e.sessionKey,data:{label:t.label.trim()||null,preferredModel:t.preferredModel.trim()||null}})}},e.session.key),(0,V.jsx)(u,{variant:`outline`,size:`sm`,onClick:async()=>{e.sessionKey&&await a({title:t(`sessionsDeleteConfirm`)+`?`,variant:`destructive`,confirmLabel:t(`sessionsDeleteConfirm`)})&&i.mutate({sessionId:e.sessionKey},{onSuccess:()=>e.onClearSelection()})},className:`h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500`,children:t(`delete`)})]})]})}),(0,V.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 relative [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full sm:p-6`,children:[n.isLoading?(0,V.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10`,children:(0,V.jsxs)(`div`,{className:`flex flex-col items-center gap-3 animate-pulse`,children:[(0,V.jsx)(T,{className:`w-6 h-6 text-primary animate-spin`}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-gray-500`,children:t(`sessionsHistoryLoading`)})]})}):null,n.error?(0,V.jsx)(`div`,{className:`text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm`,children:n.error.message}):null,!n.isLoading&&n.data?.messages.length===0?(0,V.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-gray-400`,children:[(0,V.jsx)(p,{className:`w-12 h-12 mb-3 text-gray-300`}),(0,V.jsx)(`p`,{className:`text-sm`,children:t(`sessionsEmpty`)})]}):null,(0,V.jsx)(`div`,{className:`max-w-3xl mx-auto`,children:(n.data?.messages??[]).map(e=>(0,V.jsx)(W,{message:e},e.id))})]})]}):(0,V.jsx)(K,{}),(0,V.jsx)(o,{})]})}var J=`__unknown_channel__`;function Y(e){let t=e.indexOf(`:`);return t<=0?J:e.slice(0,t).trim()||J}function X(e){return e===J?t(`sessionsUnknownChannel`):e}function Z(e){return(0,V.jsxs)(`button`,{onClick:e.onSelect,className:o(`w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group`,e.isSelected?`bg-brand-50 border border-brand-100/50`:`bg-transparent border border-transparent hover:bg-gray-50/80`),children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between mb-1.5`,children:[(0,V.jsx)(`div`,{className:o(`font-semibold truncate pr-2 flex-1 text-sm`,e.isSelected?`text-brand-800`:`text-gray-900`),children:y(e.session)}),(0,V.jsx)(`div`,{className:o(`text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize`,e.isSelected?`bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]`:`bg-gray-100 text-gray-500`),children:e.channelLabel})]}),(0,V.jsxs)(`div`,{className:o(`flex items-center text-xs justify-between mt-2 font-medium`,e.isSelected?`text-brand-600/80`:`text-gray-400`),children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:e.summary.status===`running`?(0,V.jsx)(h,{status:`running`}):null}),(0,V.jsx)(R,{className:`w-3.5 h-3.5 opacity-70`}),(0,V.jsx)(`span`,{className:`truncate max-w-[100px]`,children:a(e.summary.updatedAt)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(p,{className:`w-3.5 h-3.5 opacity-70`}),(0,V.jsx)(`span`,{children:e.summary.messageCount})]})]})]})}function Q(){let{isMobile:e}=O(),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(null),[d,f]=(0,B.useState)(`all`),p=M({limit:100}),h=(0,B.useMemo)(()=>p.data?.sessions??[],[p.data?.sessions]),g=(0,B.useMemo)(()=>_(h),[h]),y=(0,B.useMemo)(()=>new Map(h.map(e=>[e.sessionId,e])),[h]),E=(0,B.useMemo)(()=>g.filter(e=>d!==`all`&&Y(e.key)!==d?!1:v(e,n)),[n,d,g]),D=(0,B.useMemo)(()=>{let e=new Set;for(let t of g)e.add(Y(t.key));return Array.from(e).sort((e,t)=>e===J?1:t===J?-1:e.localeCompare(t))},[g]),k=i&&y.has(i)?i:null,A=(0,B.useMemo)(()=>g.find(e=>e.key===k)??null,[k,g]),j=k?y.get(k)??null:null,L=A?X(Y(A.key)):null;return(0,V.jsxs)(l,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,V.jsx)(c,{title:t(`sessionsPageTitle`),description:t(`sessionsPageDescription`)}),(0,V.jsxs)(F,{className:`xl:min-h-0`,mobileView:e?k?`detail`:`list`:void 0,onMobileBack:()=>a(null),mobileListLabel:t(`sessionsPageTitle`),children:[(0,V.jsxs)(N,{className:`xl:w-[320px] xl:flex-none`,children:[(0,V.jsxs)(P,{className:`space-y-3 px-4 py-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`span`,{className:`text-[11px] font-semibold text-gray-400 uppercase tracking-wider`,children:[g.length,` `,t(`sessionsListTitle`)]}),(0,V.jsx)(u,{variant:`ghost`,size:`icon`,className:`h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>p.refetch(),children:(0,V.jsx)(T,{className:o(`h-3.5 w-3.5`,p.isFetching&&`animate-spin`)})})]}),(0,V.jsxs)(w,{value:d,onValueChange:f,children:[(0,V.jsx)(x,{className:`w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700`,children:(0,V.jsx)(b,{placeholder:t(`sessionsAllChannels`)})}),(0,V.jsxs)(S,{className:`rounded-xl shadow-lg border-gray-100 max-w-[280px]`,children:[(0,V.jsx)(C,{value:`all`,className:`rounded-lg text-xs`,children:t(`sessionsAllChannels`)}),D.map(e=>(0,V.jsx)(C,{value:e,className:`rounded-lg text-xs truncate pr-6`,children:X(e)},e))]})]}),(0,V.jsxs)(`div`,{className:`relative w-full`,children:[(0,V.jsx)(m,{className:`h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400`}),(0,V.jsx)(s,{value:n,onChange:e=>r(e.target.value),placeholder:t(`sessionsSearchPlaceholder`),className:`pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs`})]})]}),(0,V.jsx)(I,{className:`space-y-1 p-3 pb-10`,children:p.isLoading?(0,V.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:t(`sessionsLoading`)}):E.length===0?(0,V.jsxs)(`div`,{className:`text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4`,children:[(0,V.jsx)(z,{className:`w-8 h-8 mx-auto mb-2 text-gray-300`}),t(`sessionsEmpty`)]}):E.map(e=>{let t=y.get(e.key);return t?(0,V.jsx)(Z,{session:e,summary:t,channelLabel:X(Y(e.key)),isSelected:k===e.key,onSelect:()=>a(e.key)},e.key):null})})]}),(0,V.jsx)(q,{sessionKey:k,session:A,summary:j,channelLabel:L,onClearSelection:()=>a(null)})]})]})}export{Q as SessionsConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,m as t,p as n,u as r}from"./i18n-C5Mibli1.js";import{
|
|
1
|
+
import{_ as e,m as t,p as n,u as r}from"./i18n-C5Mibli1.js";import{Mt as i}from"./api-BcqDx0tm.js";var a=e(t(),1),o=n(),s=i(`flex items-start justify-between gap-4 rounded-xl border p-4`,{variants:{tone:{default:`border-gray-200 bg-white`,muted:`border-gray-200 bg-gray-50`}},defaultVariants:{tone:`default`}}),c=a.forwardRef(({className:e,tone:t,title:n,description:i,control:a,children:c,...l},u)=>(0,o.jsxs)(`div`,{ref:u,className:r(s({tone:t}),e),...l,children:[(0,o.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,o.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:n}),i?(0,o.jsx)(`p`,{className:`text-sm leading-6 text-gray-500`,children:i}):null,c]}),a?(0,o.jsx)(`div`,{className:`shrink-0`,children:a}):null]}));c.displayName=`SettingRow`;export{c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,m as t,p as n,u as r}from"./i18n-C5Mibli1.js";import{
|
|
1
|
+
import{_ as e,m as t,p as n,u as r}from"./i18n-C5Mibli1.js";import{Mt as i}from"./api-BcqDx0tm.js";var a=e(t(),1),o=n(),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{_ as e,i as t,m as n,p as r,u as i}from"./i18n-C5Mibli1.js";import{Ct as a,Et as o,Ft as s,St as c,Tt as l,bt as u,ft as d,ht as f,jt as p,pt as m,wt as ee,yt as h}from"./api-BcqDx0tm.js";import{r as g}from"./chunk-JZWAC4HX-u4uYphxM.js";import{t as _}from"./createLucideIcon-BZkY6emz.js";import{i as v,n as y,t as b}from"./select-DIZrwsKU.js";import{n as x,t as te}from"./refresh-cw-BxojR62w.js";import{t as ne}from"./x-DpTzXQcX.js";import{t as re}from"./use-config-BQJjq1mP.js";import{n as ie,r as ae,t as oe}from"./popover-YAsxDBhY.js";var se=_(`AlarmClock`,[[`circle`,{cx:`12`,cy:`13`,r:`8`,key:`3y4lt7`}],[`path`,{d:`M12 9v4l2 2`,key:`1c63tq`}],[`path`,{d:`M5 3 2 6`,key:`18tl5t`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.38 18.7 4 21`,key:`17xu3x`}],[`path`,{d:`M17.64 18.67 20 21`,key:`kv2oe2`}]]),ce=_(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),le=_(`BrainCircuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),ue=_(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),de=_(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),fe=_(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),pe=_(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),me=_(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]),S=`nextclaw.ui.theme`,he=[{value:`warm`,labelKey:`themeWarm`},{value:`cool`,labelKey:`themeCool`}],C=`warm`,w=!1,T=new Set;function E(e){return e===`warm`||e===`cool`}function D(e){typeof document>`u`||document.documentElement.setAttribute(`data-theme`,e)}function O(){if(typeof window>`u`)return`warm`;try{let e=window.localStorage.getItem(S);if(E(e))return e}catch{}return`warm`}function k(){return w||=(C=O(),D(C),!0),C}function A(){return w?C:k()}function j(e){if(k(),e!==C){if(C=e,D(C),typeof window<`u`)try{window.localStorage.setItem(S,C)}catch{}T.forEach(e=>e(C))}}function M(e){return T.add(e),()=>{T.delete(e)}}var N=r(),P={healthy:`bg-emerald-500 shadow-[0_0_0_3px_rgba(16,185,129,0.14)]`,attention:`bg-amber-400 shadow-[0_0_0_3px_rgba(251,191,36,0.16)]`,inactive:`bg-gray-300 shadow-[0_0_0_3px_rgba(156,163,175,0.12)]`};function F(){let e=f(),n=e.actionLabel===t(`runtimeStatusRestartAction`),r=async()=>{if(n)try{let e=await h.runRuntimeControlAction(`restart-service`);s.success(e.message)}catch(e){let n=e instanceof Error?e.message:t(`runtimeControlActionFailed`);s.error(`${t(`runtimeControlActionFailed`)}: ${n}`)}};return(0,N.jsxs)(oe,{children:[(0,N.jsx)(ae,{asChild:!0,children:(0,N.jsx)(`button`,{type:`button`,className:`inline-flex items-center justify-center rounded-full p-0.5 transition-transform hover:scale-105`,"aria-label":e.title,title:e.title,"data-testid":`runtime-status-entry`,children:(0,N.jsx)(`span`,{className:i(`h-2.5 w-2.5 rounded-full`,P[e.tone])})})}),(0,N.jsxs)(ie,{align:`start`,sideOffset:10,className:`w-[290px] space-y-3 rounded-2xl border border-gray-200 bg-white p-4`,children:[(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:e.title}),(0,N.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:e.description})]}),e.reasonLines.length>0?(0,N.jsx)(`div`,{className:`space-y-2`,children:e.reasonLines.map(e=>(0,N.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-900`,children:e},e))}):null,e.actionLabel?(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 pt-1`,children:[(0,N.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:t(`runtimeStatusActionHint`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>void r(),disabled:e.isBusy,className:`text-sm font-semibold text-sky-600 transition-colors hover:text-sky-700 disabled:text-gray-400`,children:e.isBusy?t(`runtimeStatusRestartingAction`):e.actionLabel})]}):null]})]})}var I=e(n(),1);function L({className:e,suffix:t}){let{data:n}=re(),r=n?.name??`NextClaw`,i=n?.productVersion?.trim(),a=i?`v${i}`:null,o=t??(0,N.jsx)(F,{});return(0,N.jsxs)(`div`,{className:e??`flex items-center gap-2.5`,children:[(0,N.jsx)(`div`,{className:`h-7 w-7 rounded-lg overflow-hidden flex items-center justify-center`,children:(0,N.jsx)(`img`,{src:`/logo.svg`,alt:r,className:`h-full w-full object-contain`})}),(0,N.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,N.jsx)(`span`,{className:`shrink-0 text-[15px] font-semibold tracking-[-0.01em] text-gray-800`,children:r}),a?(0,N.jsx)(R,{versionLabel:a}):null]}),(0,N.jsx)(ge,{}),o?(0,N.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:o}):null]})]})}function R({versionLabel:e}){let[t,n]=(0,I.useState)(!1);return(0,N.jsxs)(`span`,{className:`relative min-w-0 flex-1`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),onFocus:()=>n(!0),onBlur:()=>n(!1),children:[(0,N.jsx)(`span`,{tabIndex:0,"aria-label":e,className:`block min-w-0 truncate text-[13px] font-medium text-gray-500 outline-none`,children:e}),t?(0,N.jsx)(`span`,{className:`pointer-events-none absolute left-0 top-full z-[var(--z-tooltip)] mt-1 w-max max-w-none whitespace-nowrap rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md`,children:e}):null]})}function ge(){let{supported:e,busyAction:n,snapshot:r}=m();return!e||!r?null:r.status===`downloading`||r.status===`blocked`||r.status===`failed`?(0,N.jsx)(_e,{snapshot:r}):r.status===`downloaded`?(0,N.jsx)(`button`,{type:`button`,className:i(`inline-flex h-5 shrink-0 items-center rounded-full px-2 text-[11px] font-semibold leading-none ring-1 transition-colors`,z(r.status)),disabled:n===`applying`,onClick:()=>void d.applyDownloadedUpdate(),children:t(n===`applying`?`desktopUpdatesInlineApplying`:`desktopUpdatesInlineReady`)}):r.status===`update-available`?(0,N.jsx)(`button`,{type:`button`,className:i(`inline-flex h-5 shrink-0 items-center rounded-full px-2 text-[11px] font-semibold leading-none ring-1 transition-colors`,z(r.status)),disabled:n===`downloading`,onClick:()=>void d.downloadUpdate(),children:t(n===`downloading`?`desktopUpdatesInlineDownloading`:`desktopUpdatesInlineDownload`)}):null}function _e({snapshot:e}){let n=ve(e);return n?(0,N.jsx)(`span`,{className:i(`inline-flex h-5 shrink-0 items-center rounded-full px-2 text-[11px] font-semibold leading-none ring-1 transition-colors`,z(e.status)),title:t(`updates`),children:n}):null}function ve(e){if(e.status===`downloading`){let n=e.progress?.percent;return n==null?t(`desktopUpdatesInlineDownloading`):t(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(n))}return e.status===`downloaded`?t(`desktopUpdatesInlineReady`):e.status===`update-available`?t(`desktopUpdatesInlineDownload`):e.status===`blocked`||e.status===`failed`?t(`desktopUpdatesInlineAttention`):null}function z(e){return e===`downloaded`?`bg-emerald-50 text-emerald-700 ring-emerald-100 hover:bg-emerald-100 disabled:opacity-70`:e===`blocked`||e===`failed`?`bg-red-50 text-red-700 ring-red-100`:`bg-amber-50 text-amber-700 ring-amber-100 hover:bg-amber-100 disabled:opacity-70`}var ye={default:{row:`gap-3 px-3 py-2.5 text-[14px]`,icon:`h-[17px] w-[17px]`,value:`text-xs`,gap:`gap-3`},compact:{row:`gap-2.5 px-3 py-2 text-[13px]`,icon:`h-4 w-4`,value:`text-[11px]`,gap:`gap-2.5`}};function B(e){return ye[e]}function be({to:e,label:t,icon:n,density:r=`default`,className:a}){let o=B(r);return(0,N.jsx)(g,{to:e,className:({isActive:e})=>i(`group flex w-full items-center rounded-xl font-medium transition-colors duration-base`,o.row,e?`bg-gray-200 text-gray-900 shadow-sm`:`text-gray-600 hover:bg-gray-200/60 hover:text-gray-900`,a),children:({isActive:e})=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(n,{className:i(o.icon,`transition-colors`,e?`text-gray-900`:`text-gray-500 group-hover:text-gray-800`)}),(0,N.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:t})]})})}function xe({label:e,icon:t,onClick:n,density:r=`default`,className:a,labelClassName:o,trailing:s,trailingClassName:c,testId:l,trailingTestId:u}){let d=B(r);return(0,N.jsxs)(`button`,{type:`button`,onClick:n,className:i(`flex w-full items-center rounded-xl font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,d.row,a),"data-testid":l,children:[(0,N.jsx)(t,{className:i(d.icon,`shrink-0 text-gray-400`)}),(0,N.jsx)(`span`,{className:i(`min-w-0 flex-1 text-left`,o),children:e}),s?(0,N.jsx)(`span`,{className:i(`shrink-0 text-gray-500`,d.value,c),"data-testid":u,children:s}):null]})}function Se({label:e,icon:t,value:n,valueLabel:r,onValueChange:a,density:o=`default`,children:s}){let c=B(o);return(0,N.jsxs)(b,{value:n,onValueChange:a,children:[(0,N.jsxs)(v,{className:i(`h-auto w-full rounded-xl border-0 bg-transparent font-medium text-gray-600 shadow-none hover:bg-gray-200/60 focus:ring-0`,c.row),children:[(0,N.jsxs)(`div`,{className:i(`flex min-w-0 items-center`,c.gap),children:[(0,N.jsx)(t,{className:i(c.icon,`text-gray-400`)}),(0,N.jsx)(`span`,{className:`text-left`,children:e})]}),(0,N.jsx)(`span`,{className:i(`ml-auto text-gray-500`,c.value),children:r})]}),(0,N.jsx)(y,{children:s})]})}var V=`nextclaw-pwa-install-banner-dismissed`,H=`nextclaw-pwa-install-banner-dismissed-until`;function U(){let e=G();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:we(e):!1}function Ce(){let e=G();e?.setItem(V,`1`),e?.removeItem(H)}function W(){let e=G();e?.removeItem(V),e?.removeItem(H)}function G(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function we(e){let t=e.getItem(H);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(H),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(V,`1`),!0)}function K(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:U(),updateAvailable:!1,registrationFailed:!1}}var q=u(()=>K()),J=`nextclaw-pwa-dev-sw-reset`,Y=new class{constructor(){this.started=!1,this.registration=null,this.reloadWhenControllerChanges=!1,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{let e=await navigator.serviceWorker.register(`/sw.js`);this.registration=e,this.bindRegistration(e),navigator.serviceWorker.addEventListener(`controllerchange`,this.handleControllerChange),await this.syncUpdateAvailability()}catch{q.setState({registrationFailed:!0})}}},this.syncUpdateAvailability=async()=>{if(typeof window>`u`||!(`serviceWorker`in navigator)||typeof navigator.serviceWorker.getRegistration!=`function`){q.setState({updateAvailable:!1});return}let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;q.setState({updateAvailable:this.shouldSurfaceUpdate(e)})},this.applyUpdate=async()=>{let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;if(!e){window.location.reload();return}e.waiting||await e.update();let t=e.waiting;if(!t){window.location.reload();return}this.reloadWhenControllerChanges=!0,t.postMessage({type:`SKIP_WAIT`})},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(navigator.serviceWorker.removeEventListener(`controllerchange`,this.handleControllerChange),this.started=!1,this.registration=null,this.reloadWhenControllerChanges=!1)},this.bindRegistration=e=>{e.addEventListener(`updatefound`,()=>{let t=e.installing;t&&t.addEventListener(`statechange`,()=>{t.state===`installed`&&this.syncUpdateAvailability()})})},this.handleControllerChange=()=>{this.reloadWhenControllerChanges&&(this.reloadWhenControllerChanges=!1,window.location.reload())},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.shouldSurfaceUpdate=e=>!e?.waiting||!navigator.serviceWorker.controller?!1:q.getState().installability===`installed`,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));if(e.length===0){this.clearDevResetMarker();return}if(await Promise.all(e.map(async e=>await e.unregister())),await this.clearNextClawCaches(),navigator.serviceWorker.controller&&!this.hasDevResetMarker()){this.setDevResetMarker(),window.location.reload();return}this.clearDevResetMarker()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))},this.hasDevResetMarker=()=>{try{return window.sessionStorage.getItem(J)===`1`}catch{return!1}},this.setDevResetMarker=()=>{try{window.sessionStorage.setItem(J,`1`)}catch{}},this.clearDevResetMarker=()=>{try{window.sessionStorage.removeItem(J)}catch{}}}},X=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),q.setState(K())},this.refreshState=()=>{let e=this.resolveInstallability();q.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:U()})),Y.syncUpdateAvailability()},this.dismissInstallPrompt=()=>{Ce(),q.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let n=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,n.outcome===`accepted`?(W(),this.refreshState(),s.success(t(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,W(),q.setState({dismissedInstallPrompt:!0}),s.success(t(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}};function Te(){let e=q(e=>e.installability);return(0,N.jsx)(`span`,{className:i(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:Ee(e)})}function Ee(e){return t(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function De(e,n,r){return t(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&n===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:r===`insecure-context`?`pwaInstallCardInsecureContext`:r===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function Oe(){let e=q(e=>e.installability),n=q(e=>e.installMethod),r=q(e=>e.blockedReason);return(0,N.jsxs)(c,{children:[(0,N.jsxs)(l,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(o,{children:t(`pwaInstallTitle`)}),(0,N.jsx)(ee,{children:t(`pwaInstallDescription`)})]}),(0,N.jsx)(Te,{})]}),(0,N.jsxs)(a,{className:`space-y-4`,children:[(0,N.jsx)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50/90 p-4`,children:(0,N.jsx)(`p`,{className:`text-sm leading-6 text-gray-700`,children:De(e,n,r)})}),e===`available`&&n===`prompt`?(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,N.jsxs)(p,{type:`button`,className:`gap-2`,onClick:()=>{X.promptInstall()},children:[(0,N.jsx)(x,{className:`h-4 w-4`}),t(`pwaInstallAction`)]}),(0,N.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`pwaInstallPromptHint`)})]}):null,e===`available`&&n===`manual`?(0,N.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl border border-dashed border-gray-300 bg-white p-4`,children:[(0,N.jsx)(pe,{className:`mt-0.5 h-4 w-4 text-gray-500`}),(0,N.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:t(`pwaInstallManualHint`)})]}):null]})]})}function ke(){let e=q(e=>e.installability),n=q(e=>e.installMethod),r=q(e=>e.dismissedInstallPrompt);return e!==`available`||n!==`prompt`||r?null:(0,N.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:t(`pwaInstallBannerTitle`)}),(0,N.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:t(`pwaInstallBannerDescription`)})]}),(0,N.jsx)(`button`,{type:`button`,"aria-label":t(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600`,onClick:()=>{X.dismissInstallPrompt()},children:(0,N.jsx)(ne,{className:`h-4 w-4`})})]}),(0,N.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,N.jsxs)(p,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{X.promptInstall()},children:[(0,N.jsx)(x,{className:`h-4 w-4`}),t(`pwaInstallAction`)]}),(0,N.jsx)(p,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{X.dismissInstallPrompt()},children:t(`pwaInstallDismiss`)})]})]})}function Z(){let e=q(e=>e.updateAvailable),n=q(e=>e.installability);return!e||n!==`installed`?null:(0,N.jsxs)(`div`,{className:`fixed top-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,N.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:t(`pwaUpdateBannerTitle`)}),(0,N.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:t(`pwaUpdateBannerDescription`)})]})}),(0,N.jsx)(`div`,{className:`mt-4`,children:(0,N.jsxs)(p,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Y.applyUpdate()},children:[(0,N.jsx)(te,{className:`h-4 w-4`}),t(`pwaUpdateAction`)]})})]})}var Q=!1;function Ae(){Q||typeof window>`u`||(Q=!0,X.start(),Y.start())}var je={warm:`#F9F8F5`,cool:`#F8FAFB`},Me=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=je[e];this.updateThemeMeta(t),this.updateSurfaceBackgrounds(t),document.documentElement.style.colorScheme=`light`},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let e=document.documentElement.getAttribute(`data-theme`)===`cool`?`cool`:`warm`;this.syncTheme(e)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},$=(0,I.createContext)(null);function Ne({children:e}){let[t,n]=(0,I.useState)(()=>k());(0,I.useEffect)(()=>{Me.syncTheme(t)},[t]),(0,I.useEffect)(()=>M(e=>{n(e)}),[]);let r=(0,I.useCallback)(e=>{j(e),n(A())},[]),i=(0,I.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,N.jsx)($.Provider,{value:i,children:e})}function Pe(){let e=(0,I.useContext)($);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}export{ce as _,Oe as a,be as c,he as d,me as f,le as g,ue as h,ke as i,Se as l,de as m,Pe as n,Z as o,fe as p,Ae as r,xe as s,Ne as t,L as u,se as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,m as t,p as n,u as r}from"./i18n-C5Mibli1.js";import{_ as i,c as a,d as o,f as s,g as c,h as l,i as u,o as d,u as f}from"./es2015-
|
|
1
|
+
import{_ as e,m as t,p as n,u as r}from"./i18n-C5Mibli1.js";import{_ as i,c as a,d as o,f as s,g as c,h as l,i as u,o as d,u as f}from"./es2015-JCM5-KtW.js";import{t as p}from"./dist-Bl94Ahwx.js";import{C as m,E as h,S as g,T as _,w as v,x as y}from"./select-DIZrwsKU.js";var b=e(t(),1),x=n(),[S,C]=l(`Tooltip`,[h]),w=h(),T=`TooltipProvider`,E=700,D=`tooltip.open`,[O,k]=S(T),A=e=>{let{__scopeTooltip:t,delayDuration:n=E,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=b.useRef(!0),s=b.useRef(!1),c=b.useRef(0);return b.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,x.jsx)(O,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:b.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:b.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};A.displayName=T;var j=`Tooltip`,[ee,M]=S(j),N=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:c,delayDuration:l}=e,u=k(j,e.__scopeTooltip),d=w(t),[f,p]=b.useState(null),m=s(),h=b.useRef(0),g=c??u.disableHoverableContent,v=l??u.delayDuration,y=b.useRef(!1),[S,C]=o({prop:r,defaultProp:i??!1,onChange:e=>{e?(u.onOpen(),document.dispatchEvent(new CustomEvent(D))):u.onClose(),a?.(e)},caller:j}),T=b.useMemo(()=>S?y.current?`delayed-open`:`instant-open`:`closed`,[S]),E=b.useCallback(()=>{window.clearTimeout(h.current),h.current=0,y.current=!1,C(!0)},[C]),O=b.useCallback(()=>{window.clearTimeout(h.current),h.current=0,C(!1)},[C]),A=b.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,C(!0),h.current=0},v)},[v,C]);return b.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]),(0,x.jsx)(_,{...d,children:(0,x.jsx)(ee,{scope:t,contentId:m,open:S,stateAttribute:T,trigger:f,onTriggerChange:p,onTriggerEnter:b.useCallback(()=>{u.isOpenDelayedRef.current?A():E()},[u.isOpenDelayedRef,A,E]),onTriggerLeave:b.useCallback(()=>{g?O():(window.clearTimeout(h.current),h.current=0)},[O,g]),onOpen:E,onClose:O,disableHoverableContent:g,children:n})})};N.displayName=j;var P=`TooltipTrigger`,F=b.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,o=M(P,n),s=k(P,n),l=w(n),u=c(t,b.useRef(null),o.onTriggerChange),d=b.useRef(!1),f=b.useRef(!1),p=b.useCallback(()=>d.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener(`pointerup`,p),[p]),(0,x.jsx)(g,{asChild:!0,...l,children:(0,x.jsx)(a.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:i(e.onPointerMove,e=>{e.pointerType!==`touch`&&!f.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:i(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:i(e.onPointerDown,()=>{o.open&&o.onClose(),d.current=!0,document.addEventListener(`pointerup`,p,{once:!0})}),onFocus:i(e.onFocus,()=>{d.current||o.onOpen()}),onBlur:i(e.onBlur,o.onClose),onClick:i(e.onClick,o.onClose)})})});F.displayName=P;var I=`TooltipPortal`,[L,R]=S(I,{forceMount:void 0}),z=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=M(I,t);return(0,x.jsx)(L,{scope:t,forceMount:n,children:(0,x.jsx)(p,{present:n||a.open,children:(0,x.jsx)(u,{asChild:!0,container:i,children:r})})})};z.displayName=I;var B=`TooltipContent`,V=b.forwardRef((e,t)=>{let n=R(B,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=M(B,e.__scopeTooltip);return(0,x.jsx)(p,{present:r||o.open,children:o.disableHoverableContent?(0,x.jsx)(K,{side:i,...a,ref:t}):(0,x.jsx)(H,{side:i,...a,ref:t})})}),H=b.forwardRef((e,t)=>{let n=M(B,e.__scopeTooltip),r=k(B,e.__scopeTooltip),i=b.useRef(null),a=c(t,i),[o,s]=b.useState(null),{trigger:l,onClose:u}=n,d=i.current,{onPointerInTransitChange:f}=r,p=b.useCallback(()=>{s(null),f(!1)},[f]),m=b.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=re(r,ne(r,n.getBoundingClientRect())),a=ie(t.getBoundingClientRect());s(oe([...i,...a])),f(!0)},[f]);return b.useEffect(()=>()=>p(),[p]),b.useEffect(()=>{if(l&&d){let e=e=>m(e,d),t=e=>m(e,l);return l.addEventListener(`pointerleave`,e),d.addEventListener(`pointerleave`,t),()=>{l.removeEventListener(`pointerleave`,e),d.removeEventListener(`pointerleave`,t)}}},[l,d,m,p]),b.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=l?.contains(t)||d?.contains(t),i=!ae(n,o);r?p():i&&(p(),u())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[l,d,o,u,p]),(0,x.jsx)(K,{...e,ref:a})}),[U,W]=S(j,{isInside:!1}),G=f(`TooltipContent`),K=b.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=M(B,n),l=w(n),{onClose:u}=c;return b.useEffect(()=>(document.addEventListener(D,u),()=>document.removeEventListener(D,u)),[u]),b.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,x.jsx)(d,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,x.jsxs)(v,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,x.jsx)(G,{children:r}),(0,x.jsx)(U,{scope:n,isInside:!0,children:(0,x.jsx)(y,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});V.displayName=B;var q=`TooltipArrow`,te=b.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=w(n);return W(q,n).isInside?null:(0,x.jsx)(m,{...i,...r,ref:t})});te.displayName=q;function ne(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function re(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ie(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function ae(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function oe(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),se(t)}function se(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var J=A,Y=N,X=F,Z=z,Q=V,ce=J,le=Y,ue=X,$=b.forwardRef(({className:e,sideOffset:t=4,...n},i)=>(0,x.jsx)(Z,{children:(0,x.jsx)(Q,{ref:i,sideOffset:t,className:r(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));$.displayName=Q.displayName;export{Q as a,Y as c,ue as i,X as l,$ as n,Z as o,ce as r,J as s,le as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./i18n-C5Mibli1.js";import{$ as t,B as n,Bt as r,F as i,Ft as a,G as o,H as s,I as c,It as l,J as u,K as d,L as f,Lt as p,M as m,N as h,P as g,Q as _,R as v,U as y,W as b,X as x,Y as S,Z as C,_ as w,f as T,g as E,h as D,m as O,p as k,q as A,v as j,z as ee}from"./api-BcqDx0tm.js";function M(){return p({queryKey:[`config`],queryFn:f,staleTime:3e4,refetchOnWindowFocus:!0})}function N(){return p({queryKey:[`app-meta`],queryFn:c,staleTime:1/0})}function P(){return p({queryKey:[`config-meta`],queryFn:v,staleTime:1/0})}function F(){return p({queryKey:[`config-schema`],queryFn:ee,staleTime:1/0})}function I(){let t=r();return l({mutationFn:S,onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),a.success(e(`configSaved`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function L(){let t=r();return l({mutationFn:({data:e})=>_(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function R(){let t=r();return l({mutationFn:({provider:e,data:t})=>x(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),a.success(e(`configSaved`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function z(){let t=r();return l({mutationFn:({data:e})=>m(e??{}),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),a.success(e(`configSaved`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function B(){let t=r();return l({mutationFn:({provider:e})=>g(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),a.success(e(`configSaved`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function V(){return l({mutationFn:({provider:e,data:t})=>A(e,t)})}function H(){return l({mutationFn:({provider:e,data:t})=>d(e,t)})}function U(){return l({mutationFn:({provider:e,data:t})=>y(e,t)})}function W(){return l({mutationFn:({provider:e})=>s(e)})}function G(){let t=r();return l({mutationFn:({channel:e,data:t})=>u(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),a.success(e(`configSavedApplying`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function K(){let t=r();return l({mutationFn:({data:e})=>C(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function q(){let n=r();return l({mutationFn:({data:e})=>t(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`config`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function J(){return l({mutationFn:({actionId:e,data:t})=>i(e,t),onError:t=>{a.error(e(`error`)+`: `+t.message)}})}function Y(e){return p({queryKey:[`ncp-sessions`,e?.limit??null],queryFn:()=>w(e),staleTime:5e3,retry:!1})}function X(e,t=200){return p({queryKey:[`ncp-session-messages`,e,t],queryFn:()=>D(e,t),enabled:!!e,staleTime:5e3,retry:!1})}function Z(e){return p({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>E(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Q(){let t=r();return l({mutationFn:({sessionId:e})=>O(e),onSuccess:(n,r)=>{T(t,r.sessionId),t.removeQueries({queryKey:[`ncp-session-messages`,r.sessionId]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function $(){let t=r();return l({mutationFn:({sessionId:e,data:t})=>j(e,t),onSuccess:n=>{k(t,n),t.invalidateQueries({queryKey:[`ncp-session-skills`,n.sessionId]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function te(e={all:!0}){return p({queryKey:[`cron`,e],queryFn:()=>n(e),staleTime:1e4})}function ne(){let t=r();return l({mutationFn:({id:e})=>h(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function re(){let t=r();return l({mutationFn:({id:e,enabled:t})=>o(e,{enabled:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function ie(){let t=r();return l({mutationFn:({id:e,force:t})=>b(e,{force:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}export{R as C,q as E,$ as S,L as T,H as _,z as a,G as b,Q as c,W as d,X as f,ie as g,U as h,F as i,B as l,Y as m,M as n,te as o,Z as p,P as r,ne as s,N as t,J as u,V as v,K as w,I as x,re as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r}from"./i18n-C5Mibli1.js";import{
|
|
1
|
+
import{_ as e,i as t,m as n,p as r}from"./i18n-C5Mibli1.js";import{jt as i}from"./api-BcqDx0tm.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./dialog-csshWetU.js";var d=e(n(),1),f=r(),p=({open:e,onOpenChange:n,title:r,description:d,confirmLabel:p=t(`confirm`),cancelLabel:m=t(`cancel`),variant:h=`default`,onConfirm:g,onCancel:_})=>(0,f.jsx)(u,{open:e,onOpenChange:n,children:(0,f.jsxs)(s,{className:`[&>:last-child]:hidden`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,f.jsxs)(a,{children:[(0,f.jsx)(c,{children:r}),d?(0,f.jsx)(l,{children:d}):null]}),(0,f.jsxs)(o,{className:`gap-2 sm:gap-0`,children:[(0,f.jsx)(i,{type:`button`,variant:`outline`,onClick:()=>{_(),n(!1)},children:m}),(0,f.jsx)(i,{type:`button`,variant:h===`destructive`?`destructive`:`default`,onClick:()=>{g(),n(!1)},children:p})]})]})}),m={open:!1,title:``,description:``,confirmLabel:t(`confirm`),cancelLabel:t(`cancel`),variant:`default`,resolve:null};function h(){let[e,n]=(0,d.useState)(m),r=(0,d.useCallback)(e=>new Promise(r=>{n({open:!0,title:e.title,description:e.description??``,confirmLabel:e.confirmLabel??t(`confirm`),cancelLabel:e.cancelLabel??t(`cancel`),variant:e.variant??`default`,resolve:e=>{r(e),n(e=>({...e,open:!1,resolve:null}))}})}),[]),i=(0,d.useCallback)(e=>{n(t=>(!e&&t.resolve&&t.resolve(!1),{...t,open:e,resolve:e?t.resolve:null}))},[]);return{confirm:r,ConfirmDialog:(0,d.useCallback)(()=>(0,f.jsx)(p,{open:e.open,onOpenChange:i,title:e.title,description:e.description||void 0,confirmLabel:e.confirmLabel,cancelLabel:e.cancelLabel,variant:e.variant,onConfirm:()=>e.resolve?.(!0),onCancel:()=>e.resolve?.(!1)}),[e,i])}}export{h as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r}from"./i18n-C5Mibli1.js";import{
|
|
1
|
+
import{_ as e,i as t,m as n,p as r}from"./i18n-C5Mibli1.js";import{Ht as i,Rt as a,Ut as o,Vt as s,Wt as c}from"./api-BcqDx0tm.js";import{t as l}from"./createLucideIcon-BZkY6emz.js";import{a as u,i as d,n as f,r as p,t as m}from"./select-DIZrwsKU.js";import{t as h}from"./skeleton-CFQRIUzt.js";var g=class extends c{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:o()})}getOptimisticResult(e){return e.behavior=o(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:a,isRefetching:o,isError:c,isRefetchError:l}=r,u=n.fetchMeta?.fetchMore?.direction,d=c&&u===`forward`,f=a&&u===`forward`,p=c&&u===`backward`,m=a&&u===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:s(t,n.data),hasPreviousPage:i(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:o&&!f&&!m}}};function _(e,t){return a(e,g,t)}var v=l(`PackageSearch`,[[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}],[`circle`,{cx:`18.5`,cy:`15.5`,r:`2.5`,key:`b5zd12`}],[`path`,{d:`M20.27 17.27 22 19`,key:`1l4muz`}]]);function y(e){if(!e||e.pages.length===0)return;let t=e.pages.flatMap(e=>e.items);return{...e.pages[e.pages.length-1],items:t,pages:e.pages,loadedItems:t.length,loadedPages:e.pages.length}}var b=r();function x({scope:e,searchText:n,searchPlaceholder:r,sort:i,onSearchTextChange:a,onSortChange:o}){return(0,b.jsx)(`div`,{className:`mb-4`,children:(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,b.jsx)(v,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,b.jsx)(`input`,{value:n,onChange:e=>a(e.target.value),placeholder:r,className:`h-9 w-full rounded-xl border border-gray-200/80 pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`})]}),e===`all`&&(0,b.jsxs)(m,{value:i,onValueChange:e=>o(e),children:[(0,b.jsx)(d,{className:`h-9 w-[150px] shrink-0 rounded-lg`,children:(0,b.jsx)(u,{})}),(0,b.jsxs)(f,{children:[(0,b.jsx)(p,{value:`relevance`,children:t(`marketplaceSortRelevance`)}),(0,b.jsx)(p,{value:`updated`,children:t(`marketplaceSortUpdated`)})]})]})]})})}function S({count:e}){return(0,b.jsx)(b.Fragment,{children:Array.from({length:e},(e,t)=>(0,b.jsx)(`article`,{className:`rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm`,children:(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-3.5`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-3`,children:[(0,b.jsx)(h,{className:`h-10 w-10 shrink-0 rounded-xl`}),(0,b.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2 pt-0.5`,children:[(0,b.jsx)(h,{className:`h-4 w-32 max-w-[70%]`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(h,{className:`h-3 w-12`}),(0,b.jsx)(h,{className:`h-3 w-24`})]}),(0,b.jsx)(h,{className:`h-3 w-full`})]})]}),(0,b.jsx)(h,{className:`h-8 w-20 shrink-0 rounded-xl`})]})},`marketplace-skeleton-${t}`))})}function C({hasMore:e,loading:n,sentinelRef:r}){return!e&&!n?null:(0,b.jsxs)(`div`,{className:`py-4`,children:[e&&(0,b.jsx)(`div`,{ref:r,className:`h-1 w-full`,"aria-hidden":`true`}),n&&(0,b.jsx)(`div`,{"data-testid":`marketplace-loading-more`,className:`pt-3 text-center text-xs text-gray-500`,children:t(`loading`)})]})}function w(e){let t=e.trim().toLowerCase().replace(/_/g,`-`),n=[t,t.split(`-`)[0],`en`];return Array.from(new Set(n.filter(Boolean)))}function T(e){return e.trim().toLowerCase().replace(/_/g,`-`)}function E(e,t,n){if(e){let t=Object.entries(e).map(([e,t])=>({locale:T(e),text:typeof t==`string`?t.trim():``})).filter(e=>e.text.length>0);if(t.length>0){let e=new Map(t.map(e=>[e.locale,e.text]));for(let t of n){let n=T(t),r=e.get(n);if(r)return r}for(let e of n){let n=T(e).split(`-`)[0];if(!n)continue;let r=t.find(e=>e.locale===n||e.locale.startsWith(`${n}-`));if(r)return r.text}return t[0]?.text??``}}return t?.trim()??``}function D(e,t){if(!e)return``;for(let n of t)if(T(n).split(`-`)[0]===`zh`&&e.descriptionZh?.trim())return e.descriptionZh.trim();return e.description?.trim()?e.description.trim():e.descriptionZh?.trim()?e.descriptionZh.trim():``}var O=e(n(),1),k=160;function A(e){let t=(0,O.useRef)(null),n=(0,O.useRef)(null),r=(0,O.useRef)(e.onLoadMore),i=(0,O.useRef)(!1);return(0,O.useEffect)(()=>{r.current=e.onLoadMore},[e.onLoadMore]),(0,O.useEffect)(()=>{e.disabled&&(i.current=!1)},[e.disabled]),(0,O.useEffect)(()=>{let a=t.current,o=n.current,s=e.thresholdPx??k;if(e.disabled||!a||!o)return;let c=()=>{i.current||e.disabled||(i.current=!0,Promise.resolve(r.current()).finally(()=>{i.current=!1}))},l=()=>{o.getBoundingClientRect().top-a.getBoundingClientRect().bottom<=s&&c()};if(typeof IntersectionObserver==`function`){let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&c()},{root:a,rootMargin:`0px 0px ${s}px 0px`});return e.observe(o),l(),()=>{e.disconnect()}}return a.addEventListener(`scroll`,l,{passive:!0}),l(),()=>{a.removeEventListener(`scroll`,l)}},[e.disabled,e.thresholdPx,e.watchValue]),{containerRef:t,sentinelRef:n}}export{x as a,y as c,E as i,_ as l,w as n,C as o,D as r,S as s,A as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,m as t}from"./i18n-C5Mibli1.js";import{
|
|
1
|
+
import{_ as e,m as t}from"./i18n-C5Mibli1.js";import{bt as n}from"./api-BcqDx0tm.js";function r(e){return typeof e!=`number`||!Number.isFinite(e)?`desktop`:e<=767?`mobile`:`desktop`}function i(){let e=typeof window>`u`?null:window.innerWidth??null;return{mode:r(e),width:e}}var a=n(()=>i()),o=new class{constructor(){this.consumerCount=0,this.started=!1,this.attach=()=>(this.consumerCount+=1,this.consumerCount===1&&this.start(),()=>{this.consumerCount=Math.max(0,this.consumerCount-1),this.consumerCount===0&&this.stop()}),this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`resize`,this.handleViewportChange),window.addEventListener(`orientationchange`,this.handleViewportChange),this.syncFromWindow())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`resize`,this.handleViewportChange),window.removeEventListener(`orientationchange`,this.handleViewportChange),this.started=!1)},this.getSnapshot=()=>a.getState(),this.resetForTests=()=>{this.consumerCount=0,this.stop(),a.setState(i())},this.handleViewportChange=()=>{this.syncFromWindow()},this.syncFromWindow=()=>{if(typeof window>`u`)return;let e=window.innerWidth??null;a.setState({width:e,mode:r(e)})}}},s=e(t(),1);function c(){(0,s.useEffect)(()=>o.attach(),[]);let e=a(e=>e.mode);return{mode:e,isMobile:e===`mobile`,isDesktop:e===`desktop`}}export{o as n,c as t};
|
package/dist/index.html
CHANGED
|
@@ -78,21 +78,21 @@
|
|
|
78
78
|
})();
|
|
79
79
|
</script>
|
|
80
80
|
<title>NextClaw</title>
|
|
81
|
-
<script type="module" crossorigin src="/assets/index-
|
|
81
|
+
<script type="module" crossorigin src="/assets/index-CM-57d8J.js"></script>
|
|
82
82
|
<link rel="modulepreload" crossorigin href="/assets/i18n-C5Mibli1.js">
|
|
83
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
84
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
83
|
+
<link rel="modulepreload" crossorigin href="/assets/chunk-JZWAC4HX-u4uYphxM.js">
|
|
84
|
+
<link rel="modulepreload" crossorigin href="/assets/api-BcqDx0tm.js">
|
|
85
|
+
<link rel="modulepreload" crossorigin href="/assets/es2015-JCM5-KtW.js">
|
|
85
86
|
<link rel="modulepreload" crossorigin href="/assets/createLucideIcon-BZkY6emz.js">
|
|
86
|
-
<link rel="modulepreload" crossorigin href="/assets/select-
|
|
87
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
87
|
+
<link rel="modulepreload" crossorigin href="/assets/select-DIZrwsKU.js">
|
|
88
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-Bl94Ahwx.js">
|
|
88
89
|
<link rel="modulepreload" crossorigin href="/assets/x-DpTzXQcX.js">
|
|
89
|
-
<link rel="modulepreload" crossorigin href="/assets/dialog-
|
|
90
|
-
<link rel="modulepreload" crossorigin href="/assets/popover-
|
|
91
|
-
<link rel="modulepreload" crossorigin href="/assets/tooltip-
|
|
90
|
+
<link rel="modulepreload" crossorigin href="/assets/dialog-csshWetU.js">
|
|
91
|
+
<link rel="modulepreload" crossorigin href="/assets/popover-YAsxDBhY.js">
|
|
92
|
+
<link rel="modulepreload" crossorigin href="/assets/tooltip-Dq5Xehpk.js">
|
|
92
93
|
<link rel="modulepreload" crossorigin href="/assets/refresh-cw-BxojR62w.js">
|
|
93
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
94
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
95
|
-
<link rel="modulepreload" crossorigin href="/assets/theme-provider-DeBrTglS.js">
|
|
94
|
+
<link rel="modulepreload" crossorigin href="/assets/use-config-BQJjq1mP.js">
|
|
95
|
+
<link rel="modulepreload" crossorigin href="/assets/theme-provider-W704JWF8.js">
|
|
96
96
|
<link rel="modulepreload" crossorigin href="/assets/search-vChioOoe.js">
|
|
97
97
|
<link rel="modulepreload" crossorigin href="/assets/book-open-DgLqYpNY.js">
|
|
98
98
|
<link rel="modulepreload" crossorigin href="/assets/external-link-Sw3ah_JD.js">
|
|
@@ -107,17 +107,17 @@
|
|
|
107
107
|
<link rel="modulepreload" crossorigin href="/assets/doc-browser-context-DfLHAWbG.js">
|
|
108
108
|
<link rel="modulepreload" crossorigin href="/assets/doc-browser-CzCV73NJ.js">
|
|
109
109
|
<link rel="modulepreload" crossorigin href="/assets/doc-browser-BUlCkZo2.js">
|
|
110
|
-
<link rel="modulepreload" crossorigin href="/assets/use-viewport-layout-
|
|
110
|
+
<link rel="modulepreload" crossorigin href="/assets/use-viewport-layout-BX3XqzJ4.js">
|
|
111
111
|
<link rel="modulepreload" crossorigin href="/assets/logo-badge-BQgKnVtz.js">
|
|
112
112
|
<link rel="modulepreload" crossorigin href="/assets/skeleton-CFQRIUzt.js">
|
|
113
|
-
<link rel="modulepreload" crossorigin href="/assets/chat-
|
|
113
|
+
<link rel="modulepreload" crossorigin href="/assets/chat-ahMH_i_K.js">
|
|
114
114
|
<link rel="modulepreload" crossorigin href="/assets/key-round-CnI1mc9F.js">
|
|
115
115
|
<link rel="modulepreload" crossorigin href="/assets/message-square-D6Z4NwpG.js">
|
|
116
|
-
<link rel="modulepreload" crossorigin href="/assets/app-navigation.config-
|
|
117
|
-
<link rel="modulepreload" crossorigin href="/assets/notice-card-
|
|
116
|
+
<link rel="modulepreload" crossorigin href="/assets/app-navigation.config-BOVDFMnp.js">
|
|
117
|
+
<link rel="modulepreload" crossorigin href="/assets/notice-card-CCgk6FvF.js">
|
|
118
118
|
<link rel="modulepreload" crossorigin href="/assets/status-dot-Dv_hiUVa.js">
|
|
119
|
-
<link rel="modulepreload" crossorigin href="/assets/app-manager-provider-
|
|
120
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
119
|
+
<link rel="modulepreload" crossorigin href="/assets/app-manager-provider-DVYBjif-.js">
|
|
120
|
+
<link rel="stylesheet" crossorigin href="/assets/index-D8MKmXtO.css">
|
|
121
121
|
</head>
|
|
122
122
|
|
|
123
123
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/ui",
|
|
3
|
-
"version": "0.12.20-beta.
|
|
3
|
+
"version": "0.12.20-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,12 +28,14 @@
|
|
|
28
28
|
"tailwind-merge": "^2.5.4",
|
|
29
29
|
"zod": "^3.23.8",
|
|
30
30
|
"zustand": "^5.0.2",
|
|
31
|
-
"@nextclaw/
|
|
32
|
-
"@nextclaw/
|
|
31
|
+
"@nextclaw/client-sdk": "0.1.1-beta.2",
|
|
32
|
+
"@nextclaw/kernel": "0.1.2-beta.2",
|
|
33
33
|
"@nextclaw/ncp": "0.5.6-beta.0",
|
|
34
|
-
"@nextclaw/
|
|
35
|
-
"@nextclaw/
|
|
36
|
-
"@nextclaw/agent-chat": "0.
|
|
34
|
+
"@nextclaw/agent-chat": "0.1.11-beta.0",
|
|
35
|
+
"@nextclaw/server": "0.12.13-beta.2",
|
|
36
|
+
"@nextclaw/agent-chat-ui": "0.3.13-beta.0",
|
|
37
|
+
"@nextclaw/ncp-react": "0.4.26-beta.1",
|
|
38
|
+
"@nextclaw/ncp-http-agent-client": "0.3.18-beta.1"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@testing-library/react": "^16.3.0",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
|
-
import { applyNcpSessionRealtimeEvent } from '@/shared/lib/api';
|
|
2
|
+
import { applyNcpSessionRealtimeEvent, nextclawClient } from '@/shared/lib/api';
|
|
3
3
|
import { systemStatusManager } from '@/features/system-status';
|
|
4
|
-
import { appClient } from '@/shared/lib/transport';
|
|
5
4
|
import type { QueryClient } from '@tanstack/react-query';
|
|
5
|
+
import type { NextClawRealtimeEvent } from '@nextclaw/client-sdk';
|
|
6
6
|
|
|
7
7
|
function shouldInvalidateConfigQuery(configPath: string) {
|
|
8
8
|
const normalized = configPath.trim().toLowerCase();
|
|
@@ -41,7 +41,7 @@ function handleRealtimeEvent(
|
|
|
41
41
|
shouldResyncSessions: boolean;
|
|
42
42
|
clearShouldResyncSessions: () => void;
|
|
43
43
|
markShouldResyncSessions: () => void;
|
|
44
|
-
event:
|
|
44
|
+
event: NextClawRealtimeEvent;
|
|
45
45
|
}
|
|
46
46
|
): void {
|
|
47
47
|
const {
|
|
@@ -88,7 +88,7 @@ export function useRealtimeQueryBridge(queryClient?: QueryClient) {
|
|
|
88
88
|
const shouldResyncSessionsRef = useRef(false);
|
|
89
89
|
|
|
90
90
|
useEffect(() => {
|
|
91
|
-
return
|
|
91
|
+
return nextclawClient.realtime.subscribe((event) =>
|
|
92
92
|
handleRealtimeEvent({
|
|
93
93
|
queryClient,
|
|
94
94
|
shouldResyncSessions: shouldResyncSessionsRef.current,
|
|
@@ -100,6 +100,6 @@ export function useRealtimeQueryBridge(queryClient?: QueryClient) {
|
|
|
100
100
|
},
|
|
101
101
|
event,
|
|
102
102
|
})
|
|
103
|
-
);
|
|
103
|
+
).close;
|
|
104
104
|
}, [queryClient]);
|
|
105
105
|
}
|
|
@@ -5,7 +5,7 @@ import { toast } from 'sonner';
|
|
|
5
5
|
import { LogoBadge } from '@/shared/components/common/logo-badge';
|
|
6
6
|
import { Button } from '@/shared/components/ui/button';
|
|
7
7
|
import { StatusDot } from '@/shared/components/ui/status-dot';
|
|
8
|
-
import {
|
|
8
|
+
import { nextclawClient } from '@/shared/lib/api';
|
|
9
9
|
import { useConfig, useConfigMeta, useConfigSchema, useExecuteConfigAction, useUpdateChannel } from '@/shared/hooks/use-config';
|
|
10
10
|
import type { ConfigActionManifest, ConfigUiHints } from '@/shared/lib/api';
|
|
11
11
|
import { ChannelFormFieldsSection } from '@/features/channels/components/channel-form-fields-section';
|
|
@@ -77,7 +77,7 @@ function ensureChannelApplySubscription() {
|
|
|
77
77
|
if (channelApplyUnsubscribe) {
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
channelApplyUnsubscribe =
|
|
80
|
+
channelApplyUnsubscribe = nextclawClient.realtime.subscribe((event) => {
|
|
81
81
|
if (event.type !== 'channel.config.apply-status') {
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
@@ -90,7 +90,7 @@ function ensureChannelApplySubscription() {
|
|
|
90
90
|
: { status: 'failed', message: event.payload.message }
|
|
91
91
|
);
|
|
92
92
|
channelApplyListeners.forEach((listener) => listener());
|
|
93
|
-
});
|
|
93
|
+
}).close;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
function subscribeChannelApplyStore(listener: () => void) {
|
|
@@ -6,8 +6,7 @@ import { sessionMatchesQuery } from '@/features/chat/utils/chat-session-display.
|
|
|
6
6
|
import { adaptNcpSessionSummaries } from '@/features/chat/utils/ncp-session-adapter.utils';
|
|
7
7
|
import { useChatSessionTypeState } from '@/features/chat/hooks/use-chat-session-type-state';
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
resolveRecentSessionPreferredModel,
|
|
9
|
+
resolveRecentSessionPreferredValue,
|
|
11
10
|
useSyncSelectedModel,
|
|
12
11
|
useSyncSelectedThinking
|
|
13
12
|
} from '@/features/chat/utils/chat-session-preference-governance.utils';
|
|
@@ -83,19 +82,21 @@ function useRecentSessionPreferences(params: {
|
|
|
83
82
|
const { sessions, sessionKey, sessionType } = params;
|
|
84
83
|
const recentSessionPreferredModel = useMemo(
|
|
85
84
|
() =>
|
|
86
|
-
|
|
85
|
+
resolveRecentSessionPreferredValue<string>({
|
|
87
86
|
sessions,
|
|
88
87
|
selectedSessionKey: sessionKey,
|
|
89
|
-
sessionType
|
|
88
|
+
sessionType,
|
|
89
|
+
readPreference: (session) => session.preferredModel?.trim() || undefined
|
|
90
90
|
}),
|
|
91
91
|
[sessionKey, sessionType, sessions]
|
|
92
92
|
);
|
|
93
93
|
const recentSessionPreferredThinking = useMemo(
|
|
94
94
|
() =>
|
|
95
|
-
|
|
95
|
+
resolveRecentSessionPreferredValue<ThinkingLevel>({
|
|
96
96
|
sessions,
|
|
97
97
|
selectedSessionKey: sessionKey,
|
|
98
|
-
sessionType
|
|
98
|
+
sessionType,
|
|
99
|
+
readPreference: (session) => session.preferredThinking ?? undefined
|
|
99
100
|
}),
|
|
100
101
|
[sessionKey, sessionType, sessions]
|
|
101
102
|
);
|
|
@@ -2,8 +2,7 @@ import { describe, expect, it } from 'vitest';
|
|
|
2
2
|
import type { SessionEntryView, ThinkingLevel } from '@/shared/lib/api';
|
|
3
3
|
import type { ChatModelOption } from '@/features/chat/types/chat-input.types';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
resolveRecentSessionPreferredThinking,
|
|
5
|
+
resolveRecentSessionPreferredValue,
|
|
7
6
|
resolveSelectedModelValue,
|
|
8
7
|
resolveSelectedThinkingLevelValue
|
|
9
8
|
} from '@/features/chat/utils/chat-session-preference-governance.utils';
|
|
@@ -25,6 +24,18 @@ const modelOptions: ChatModelOption[] = [
|
|
|
25
24
|
modelLabel: 'gpt-5',
|
|
26
25
|
providerLabel: 'OpenAI',
|
|
27
26
|
thinkingCapability: null
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: 'minimax/MiniMax-M2.7',
|
|
30
|
+
modelLabel: 'MiniMax-M2.7',
|
|
31
|
+
providerLabel: 'MiniMax',
|
|
32
|
+
thinkingCapability: null
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
value: 'deepseek/deepseek-v4-flash',
|
|
36
|
+
modelLabel: 'deepseek-v4-flash',
|
|
37
|
+
providerLabel: 'DeepSeek',
|
|
38
|
+
thinkingCapability: null
|
|
28
39
|
}
|
|
29
40
|
];
|
|
30
41
|
|
|
@@ -270,10 +281,11 @@ describe('resolveRecentSessionPreferredModel', () => {
|
|
|
270
281
|
];
|
|
271
282
|
|
|
272
283
|
expect(
|
|
273
|
-
|
|
284
|
+
resolveRecentSessionPreferredValue<string>({
|
|
274
285
|
sessions,
|
|
275
286
|
selectedSessionKey: 'draft',
|
|
276
|
-
sessionType: 'codex'
|
|
287
|
+
sessionType: 'codex',
|
|
288
|
+
readPreference: (session) => session.preferredModel?.trim() || undefined
|
|
277
289
|
})
|
|
278
290
|
).toBe('openai/gpt-5');
|
|
279
291
|
});
|
|
@@ -300,10 +312,11 @@ describe('resolveRecentSessionPreferredModel', () => {
|
|
|
300
312
|
];
|
|
301
313
|
|
|
302
314
|
expect(
|
|
303
|
-
|
|
315
|
+
resolveRecentSessionPreferredValue<string>({
|
|
304
316
|
sessions,
|
|
305
317
|
selectedSessionKey: 'codex-current',
|
|
306
|
-
sessionType: 'codex'
|
|
318
|
+
sessionType: 'codex',
|
|
319
|
+
readPreference: (session) => session.preferredModel?.trim() || undefined
|
|
307
320
|
})
|
|
308
321
|
).toBe('anthropic/claude-sonnet-4');
|
|
309
322
|
});
|
|
@@ -384,10 +397,11 @@ describe('resolveRecentSessionPreferredThinking', () => {
|
|
|
384
397
|
];
|
|
385
398
|
|
|
386
399
|
expect(
|
|
387
|
-
|
|
400
|
+
resolveRecentSessionPreferredValue<ThinkingLevel>({
|
|
388
401
|
sessions,
|
|
389
402
|
selectedSessionKey: 'draft',
|
|
390
|
-
sessionType: 'codex'
|
|
403
|
+
sessionType: 'codex',
|
|
404
|
+
readPreference: (session) => session.preferredThinking ?? undefined
|
|
391
405
|
})
|
|
392
406
|
).toBe('high');
|
|
393
407
|
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { act, renderHook, waitFor } from '@testing-library/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import type { ChatModelOption } from '@/features/chat/types/chat-input.types';
|
|
5
|
+
import { useSyncSelectedModel } from '@/features/chat/utils/chat-session-preference-governance.utils';
|
|
6
|
+
|
|
7
|
+
const modelOptions: ChatModelOption[] = [
|
|
8
|
+
{
|
|
9
|
+
value: 'minimax/MiniMax-M2.7',
|
|
10
|
+
modelLabel: 'MiniMax-M2.7',
|
|
11
|
+
providerLabel: 'MiniMax',
|
|
12
|
+
thinkingCapability: null
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
value: 'deepseek/deepseek-v4-flash',
|
|
16
|
+
modelLabel: 'deepseek-v4-flash',
|
|
17
|
+
providerLabel: 'DeepSeek',
|
|
18
|
+
thinkingCapability: null
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
value: 'openai/gpt-5',
|
|
22
|
+
modelLabel: 'gpt-5',
|
|
23
|
+
providerLabel: 'OpenAI',
|
|
24
|
+
thinkingCapability: null
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
type HookProps = {
|
|
29
|
+
fallbackPreferredModel?: string;
|
|
30
|
+
defaultModel: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
describe('useSyncSelectedModel', () => {
|
|
34
|
+
it('replaces an auto-selected global default with the later-arriving recent same-runtime model for a fresh draft session', async () => {
|
|
35
|
+
const initialProps: HookProps = {
|
|
36
|
+
fallbackPreferredModel: undefined,
|
|
37
|
+
defaultModel: 'minimax/MiniMax-M2.7'
|
|
38
|
+
};
|
|
39
|
+
const { result, rerender } = renderHook(
|
|
40
|
+
(props: HookProps) => {
|
|
41
|
+
const [selectedModel, setSelectedModel] = useState('');
|
|
42
|
+
useSyncSelectedModel({
|
|
43
|
+
modelOptions,
|
|
44
|
+
selectedSessionKey: 'draft-session',
|
|
45
|
+
selectedSessionExists: false,
|
|
46
|
+
fallbackPreferredModel: props.fallbackPreferredModel,
|
|
47
|
+
defaultModel: props.defaultModel,
|
|
48
|
+
setSelectedModel
|
|
49
|
+
});
|
|
50
|
+
return selectedModel;
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
initialProps
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
await waitFor(() => {
|
|
58
|
+
expect(result.current).toBe('minimax/MiniMax-M2.7');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
rerender({
|
|
62
|
+
fallbackPreferredModel: 'deepseek/deepseek-v4-flash',
|
|
63
|
+
defaultModel: 'minimax/MiniMax-M2.7'
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
await waitFor(() => {
|
|
67
|
+
expect(result.current).toBe('deepseek/deepseek-v4-flash');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('does not override a manual model selection when recent same-runtime model data arrives later', async () => {
|
|
72
|
+
const initialProps: HookProps = {
|
|
73
|
+
fallbackPreferredModel: undefined,
|
|
74
|
+
defaultModel: 'minimax/MiniMax-M2.7'
|
|
75
|
+
};
|
|
76
|
+
const { result, rerender } = renderHook(
|
|
77
|
+
(props: HookProps) => {
|
|
78
|
+
const [selectedModel, setSelectedModel] = useState('');
|
|
79
|
+
useSyncSelectedModel({
|
|
80
|
+
modelOptions,
|
|
81
|
+
selectedSessionKey: 'draft-session',
|
|
82
|
+
selectedSessionExists: false,
|
|
83
|
+
fallbackPreferredModel: props.fallbackPreferredModel,
|
|
84
|
+
defaultModel: props.defaultModel,
|
|
85
|
+
setSelectedModel
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
selectedModel,
|
|
89
|
+
setSelectedModel
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
initialProps
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
await waitFor(() => {
|
|
98
|
+
expect(result.current.selectedModel).toBe('minimax/MiniMax-M2.7');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
act(() => {
|
|
102
|
+
result.current.setSelectedModel('openai/gpt-5');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
rerender({
|
|
106
|
+
fallbackPreferredModel: 'deepseek/deepseek-v4-flash',
|
|
107
|
+
defaultModel: 'minimax/MiniMax-M2.7'
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
await waitFor(() => {
|
|
111
|
+
expect(result.current.selectedModel).toBe('openai/gpt-5');
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|