@teammy/server 0.2.18 → 0.2.19
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/dist/main.js +461 -233
- package/dist/web/assets/Assistant-BAhJ1B8n.js +1 -0
- package/dist/web/assets/{Computers-DAf8sobH.css → Computers-CBnQX-2p.css} +1 -1
- package/dist/web/assets/Computers-hHQYztG9.js +13 -0
- package/dist/web/assets/{Conversation-DN9pVRsf.js → Conversation-Bdsoobmv.js} +1 -1
- package/dist/web/assets/{Dashboard-B0Dj-KMg.js → Dashboard-De-8jlcE.js} +1 -1
- package/dist/web/assets/Dropdown-Dh9Q9fSi.js +55 -0
- package/dist/web/assets/{Files-B-iLyRvj.js → Files-DYc1q61J.js} +1 -1
- package/dist/web/assets/{Help-B21pS1RH.js → Help-DHZAzK6c.js} +13 -6
- package/dist/web/assets/{Markdown-Bh1l6OQM.js → Markdown-Gk89fXoh.js} +2 -2
- package/dist/web/assets/{MessageComposer-D9vqKUX5.js → MessageComposer-DFvWZibH.js} +1 -1
- package/dist/web/assets/{ResourceLibrary-qg568G4m.js → ResourceLibrary-DYwZzWyh.js} +3 -3
- package/dist/web/assets/{TerminalPane-hEQVsy4e.js → TerminalPane-ZhM38vie.js} +1 -1
- package/dist/web/assets/{WorkspaceTree-BMZWhAXJ.js → WorkspaceTree-yST2ByxM.js} +1 -1
- package/dist/web/assets/{file-links-DvISesr0.js → file-links-CtHFx6cd.js} +1 -1
- package/dist/web/assets/index-CWjsEUUy.js +10 -0
- package/dist/web/assets/{task-links-BeRoF5ff.js → task-links-ArhNpuGG.js} +1 -1
- package/dist/web/downloads/teammy-inbox-skill.zip +0 -0
- package/dist/web/downloads/teammy-skill.zip +0 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/Assistant-CfsrbTdh.js +0 -1
- package/dist/web/assets/Computers-CdwUaH3q.js +0 -13
- package/dist/web/assets/Dropdown-Cz5xKbpV.js +0 -55
- package/dist/web/assets/index-_W-pw3aC.js +0 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,C as t,Ct as n,E as r,St as i,T as a,c as o,ct as s,d as c,dt as l,ft as u,gt as d,k as f,l as p,p as m,pt as h,st as g,u as ee,vt as te,w as ne,x as re}from"./Dropdown-Dh9Q9fSi.js";import{A as _,D as ie,E as v,I as y,N as ae,O as oe,T as se,i as ce,j as le,k as ue,z as de}from"./index-CWjsEUUy.js";import{t as fe}from"./Markdown-Gk89fXoh.js";import{i as pe,n as me,r as he,t as ge}from"./Conversation-Bdsoobmv.js";import{t as _e}from"./MessageComposer-DFvWZibH.js";var b=i(),x=a(),ve=h({topics:g(h({id:d(),title:d(),summary:d(),author:d(),replies:u(),unread:s(),createdAt:d(),updatedAt:d(),delivery:h({available:s(),connected:s(),state:d(),error:d().nullable()})}))}),ye=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),S=e=>e.replace(/[#*_`>]/g,``).replace(/\s+/g,` `).trim();function C({me:i,mode:a=`messages`}){let{projectId:u,request:g}=de(),C=ne(),xe=t(u,i,`${a}-selection`),w=t(u,i,`${a}-drafts`),Se=(0,b.useCallback)(e=>g(`agents/outbox`,ue,{signal:e}),[g]),T=re(Se,3e3,t(u,i,`outbox`)),Ce=(0,b.useCallback)(async e=>a===`messages`?g(`agents/chats`,se,{signal:e}):{chats:(await g(`channels/topics`,ve,{signal:e})).topics.map(e=>({...e,kind:`matter`,state:null}))},[g,a]),E=re(Ce,3e3,t(u,i,a,`chats`)),[D,we]=(0,b.useState)(()=>{let e=new URLSearchParams(location.search),t=e.get(`chat`);return t?`chat:${t}`:e.get(`message`)??C?.get(xe)??``}),O=D.startsWith(`chat:`)?D.slice(5):``,k=!D||!!O,[A,j]=(0,b.useState)(()=>C?.get(t(u,i,`chat`,O))),M=A?.id===O?A:C?.get(t(u,i,`chat`,O)),N=E.data?.chats.find(e=>e.id===O),P=N&&`delivery`in N?N.delivery:void 0,[Te,F]=(0,b.useState)(),[I,L]=(0,b.useState)(()=>C?.get(w)??{}),Ee=I[D]??``,De=e=>L(t=>({...t,[D]:e})),[R,z]=(0,b.useState)(!1),[B,V]=(0,b.useState)(!1),[Oe,ke]=(0,b.useState)(!1),[Ae,H]=(0,b.useState)(!1),[U,je]=(0,b.useState)(``),[Me,Ne]=(0,b.useState)(``),Pe=(0,b.useRef)(e()),[Fe,W]=(0,b.useState)(``),[Ie,G]=(0,b.useState)(``),K=(0,b.useRef)(new Map),Le=(0,b.useRef)(null),q=(0,b.useRef)(!0),J=(0,b.useRef)(D);J.current=D,(0,b.useEffect)(()=>{A&&C?.set(t(u,i,`chat`,A.id),A)},[C,u,i,A]),(0,b.useEffect)(()=>{C?.set(w,I)},[C,w,I]);function Y(e){J.current=e,we(e),C?.set(xe,e);let t=new URL(location.href);e.startsWith(`chat:`)?t.searchParams.set(`chat`,e.slice(5)):t.searchParams.delete(`chat`),e&&!e.startsWith(`chat:`)&&e!==`debug`?t.searchParams.set(`message`,e):t.searchParams.delete(`message`),history.replaceState(history.state,``,t)}(0,b.useEffect)(()=>{!D&&E.data?.chats.length&&Y(`chat:${E.data.chats[0].id}`)},[D,E.data]);let X=(T.data?.messages??[]).filter(e=>a===`messages`&&e.box===`debug`).reverse(),Z=T.data?.messages.find(e=>e.id===(D===`debug`?Te:D));(0,b.useEffect)(()=>{D!==`debug`&&Z?.conversationId&&Y(`chat:${Z.conversationId}`)},[D,Z?.conversationId]);let Q=X.filter(e=>!e.readAt).map(e=>e.id).join(`,`);(0,b.useEffect)(()=>{Z&&!Z.readAt&&D!==`debug`&&g(`agents/outbox/${Z.id}/read`,_,{method:`POST`}).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),T.reload()}).catch(e=>W(f(e)))},[Z?.id,Z?.readAt,D,g,T.reload]),(0,b.useEffect)(()=>{D===`debug`&&Q&&Promise.all(Q.split(`,`).map(e=>g(`agents/outbox/${e}/read`,_,{method:`POST`}))).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),T.reload()}).catch(e=>W(f(e)))},[D,Q,g,T.reload]),(0,b.useEffect)(()=>{if(G(``),!O)return;let e=!0,o=-1,s=!1,c=new AbortController,l=t=>{!e||t.id!==O||t.cursor<o||(o=t.cursor,s=!0,t.redirect?Y(`chat:${t.redirect}`):t.entry===`channel`&&a!==`channels`?location.replace(n(`/projects/${u}/channels?chat=${t.id}`)):(j(t),G(``)))};g(`agents/chats/${O}`,v,{signal:c.signal}).then(l).catch(n=>{e&&!c.signal.aborted&&(n instanceof r&&[401,403,404].includes(n.status)&&(C?.delete(t(u,i,`chat`,O)),j(e=>e?.id===O?void 0:e)),s||G(f(n)))});let p=t=>{let n=Number(t.lastEventId);return!e||!Number.isSafeInteger(n)||n<=o?!1:(o=n,!0)},m=new EventSource(n(`/api/v1/projects/${encodeURIComponent(u)}/agents/chats/${encodeURIComponent(O)}/events`));m.addEventListener(`snapshot`,t=>{if(e)try{l(v.parse(JSON.parse(t.data)))}catch(e){G(f(e))}}),m.onerror=()=>{e&&G(`对话连接中断,正在重新连接…`)},m.addEventListener(`context`,e=>{if(!p(e))return;let t=v.pick({kind:!0,title:!0,status:!0,visibility:!0,participants:!0,pending:!0,hold:!0,redirect:!0}).parse(JSON.parse(e.data));t.redirect?Y(`chat:${t.redirect}`):j(e=>e?.id===O?{...e,...t,cursor:o}:e)}),m.addEventListener(`message`,e=>{if(!p(e))return;let t=ie.parse(JSON.parse(e.data));j(n=>n?.id===O?{...n,readCursor:Math.max(n.readCursor,t.seq),cursor:Math.max(n.cursor,Number(e.lastEventId)||0),messages:[...n.messages.filter(e=>e.id!==t.id),t].sort((e,t)=>e.seq-t.seq)}:n)}),m.addEventListener(`message_removed`,e=>{if(!p(e))return;let{id:t}=h({id:d()}).parse(JSON.parse(e.data));j(e=>e?.id===O?{...e,cursor:o,messages:e.messages.filter(e=>e.id!==t)}:e)}),m.addEventListener(`run`,e=>{if(!p(e))return;let t=oe.parse(JSON.parse(e.data));j(n=>n?.id===O?{...n,cursor:Math.max(n.cursor,Number(e.lastEventId)||0),runs:n.runs.some(e=>e.id===t.id)?n.runs:[...n.runs,t]}:n)});for(let e of[`delta`,`reset`,`state`])m.addEventListener(e,t=>{if(!p(t))return;let n=JSON.parse(t.data);j(r=>r?.id===O?{...r,cursor:Math.max(r.cursor,Number(t.lastEventId)||0),messages:r.messages.map(t=>t.runId!==n.id||t.role!==`assistant`?t:{...t,body:e===`delta`?t.body+(n.text??``):e===`reset`?``:n.answer??t.body,state:n.state??t.state}),runs:r.runs.map(t=>t.id===n.id?{...t,answer:e===`delta`?t.answer+(n.text??``):e===`reset`?``:n.answer??t.answer,state:n.state??t.state,error:n.error===void 0?t.error:n.error}:t)}:r)});return()=>{e=!1,c.abort(),m.close()}},[u,O,i,g,C]),(0,b.useEffect)(()=>{if(!M||M.id!==O)return;let e=()=>{document.visibilityState===`visible`&&g(`agents/chats/${O}/read`,h({ok:s()}),{method:`POST`,body:{cursor:M.readCursor}}).then(()=>{E.reload(),window.dispatchEvent(new Event(`teammy:outbox`))}).catch(e=>W(f(e)))},t=setTimeout(e,300);return document.addEventListener(`visibilitychange`,e),()=>{clearTimeout(t),document.removeEventListener(`visibilitychange`,e)}},[O,M?.readCursor,M?.kind,g]),(0,b.useEffect)(()=>{q.current&&Le.current?.scrollIntoView({block:`end`})},[D,A?.messages,Z?.recipients,X.length]);function Re(){window.dispatchEvent(new Event(`teammy:outbox`)),T.reload()}async function $(e){if(q.current=!0,Y(e),W(``),F(void 0),e.startsWith(`chat:`)||e===`debug`)return;let t=T.data?.messages.find(t=>t.id===e)?.conversationId;if(t)Y(`chat:${t}`);else try{await g(`agents/outbox/${e}/read`,_,{method:`POST`}),Re()}catch(e){W(f(e))}}async function ze(){if(!B){V(!0),W(``);try{let e=await g(`agents/chats`,v,{method:`POST`});j(e),await $(`chat:${e.id}`),E.reload()}catch(e){W(f(e))}finally{V(!1)}}}async function Be(t){t.preventDefault();let n=Ee.trim();if(!n||R||B)return;z(!0),W(``);let r=K.current.get(D);r&&r.text===n||(r={text:n,id:e()},K.current.set(D,r));try{if(k){let e=r.target??O;if(!e){let t=await g(`agents/chats`,v,{method:`POST`});e=t.id,r.target=e,K.current.set(`chat:${e}`,r),L(t=>({...t,[`chat:${e}`]:n})),J.current===D&&(j(t),Y(`chat:${e}`))}let t=await g(`agents/chats/${e}`,oe.extend({conversationId:d().optional()}),{method:`POST`,body:{text:n,requestId:r.id}});t.conversationId&&t.conversationId!==e&&(J.current===D||J.current===`chat:${e}`)&&Y(`chat:${t.conversationId}`),j(n=>n?.id===e?{...n,runs:n.runs.some(e=>e.id===t.id)?n.runs:[...n.runs,t]}:n),E.reload()}else{let e=await g(`agents/outbox/${Z.id}/reply`,h({conversationId:d()}),{method:`POST`,body:{body:n,requestId:r.id}});Re(),J.current===D&&Y(`chat:${e.conversationId}`),E.reload(),F(void 0)}K.current.delete(D),r.target&&K.current.delete(`chat:${r.target}`),L(e=>({...e,[D]:``,...r.target?{[`chat:${r.target}`]:``}:{}}))}catch(e){W(f(e))}finally{z(!1)}}let Ve=a===`channels`?he:ge,He=k&&!M?.closed&&(a!==`channels`||!!O)||!!Z&&!Z.archivedAt,Ue=k&&!M&&(!!O||!E.data);return(0,x.jsxs)(me,{className:a===`channels`?`channel-layout`:``,testId:`assistant-page`,label:k?`Tim对话`:`消息内容`,navigation:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(ae,{title:a===`channels`?`频道`:`对话`,children:(0,x.jsxs)(`div`,{className:`assistant-list-actions`,children:[(0,x.jsx)(p,{className:`assistant-new-chat`,icon:`clear`,label:`清除未读`,disabled:Oe,onClick:()=>{ke(!0),W(``),g(`communication/read`,h({ok:l(!0)}),{method:`POST`,body:{scope:a}}).then(async()=>{window.dispatchEvent(new Event(`teammy:outbox`)),await Promise.all([E.reload(),T.reload()])}).catch(e=>W(f(e))).finally(()=>ke(!1))}}),(0,x.jsx)(p,{className:`assistant-new-chat`,icon:`plus`,label:a===`channels`?`发表话题`:`新建对话`,disabled:B,onClick:()=>a===`channels`?H(!0):void ze(),"data-testid":`assistant-launcher`})]})}),(0,x.jsxs)(`div`,{className:`assistant-message-scroll`,children:[E.loading&&!E.data&&(0,x.jsx)(`p`,{className:`assistant-list-status`,role:`status`,children:`加载中…`}),E.data?.chats.map(e=>(0,x.jsxs)(`button`,{type:`button`,"data-testid":`assistant-chat-${e.id}`,className:`assistant-message-item assistant-chat-item ${O===e.id?`selected`:``}`,"aria-pressed":O===e.id,onClick:()=>void $(`chat:${e.id}`),children:[(0,x.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,x.jsx)(y,{selected:O===e.id,children:(0,x.jsx)(`strong`,{children:e.title})}),a===`channels`&&`summary`in e&&(0,x.jsx)(`span`,{className:`topic-preview`,children:S(String(e.summary)).slice(0,140)}),(0,x.jsxs)(`time`,{dateTime:e.updatedAt,children:[new Date(e.updatedAt).toLocaleDateString([],{month:`numeric`,day:`numeric`}),` `,ye(e.updatedAt)]})]}),(0,x.jsx)(`span`,{className:`assistant-message-dot ${e.unread||a!==`channels`&&(e.state===`running`||e.state===`queued`)?`unread`:``}`})]},e.id)),!!X.length&&(0,x.jsxs)(`button`,{type:`button`,"data-testid":`debug-outbox`,className:`assistant-message-item ${D===`debug`?`selected`:``}`,onClick:()=>void $(`debug`),children:[(0,x.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,x.jsx)(y,{selected:D===`debug`,children:(0,x.jsx)(`strong`,{children:`运行提醒`})}),(0,x.jsx)(`span`,{children:S(X.at(-1).body)})]}),(0,x.jsx)(`span`,{className:`assistant-message-dot ${Q?`unread`:``}`})]}),T.data?.messages.filter(e=>a===`messages`&&e.box!==`debug`&&!e.conversationId).sort((e,t)=>Number(!!e.archivedAt)-Number(!!t.archivedAt)).map(e=>(0,x.jsxs)(`button`,{type:`button`,"data-testid":`outbox-${e.id}`,className:`assistant-message-item ${e.archivedAt?`archived`:``} ${D===e.id?`selected`:``}`,onClick:()=>void $(e.id),children:[(0,x.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,x.jsx)(y,{selected:D===e.id,children:(0,x.jsx)(`strong`,{children:S(e.body)})}),(0,x.jsxs)(`time`,{dateTime:e.createdAt,children:[new Date(e.createdAt).toLocaleDateString([],{month:`numeric`,day:`numeric`}),` `,ye(e.createdAt)]})]}),(0,x.jsx)(`span`,{className:`assistant-message-dot ${e.readAt?``:`unread`}`})]},e.id))]}),(0,x.jsx)(m,{error:!0,children:T.error||E.error})]}),children:[Ae&&(0,x.jsxs)(c,{id:`new-topic`,title:`发表话题`,onClose:()=>H(!1),children:[(0,x.jsx)(_e,{inset:!0,plain:!0,value:Me,onChange:Ne,label:`正文`,placeholder:`开始一个话题…`,sendLabel:`发表话题`,sendDisabled:R||!U.trim(),heading:(0,x.jsx)(`input`,{className:`topic-title`,"aria-label":`标题`,placeholder:`标题`,required:!0,value:U,onChange:e=>je(e.target.value)}),onSubmit:t=>{t.preventDefault(),z(!0),W(``),g(`channels/topics`,v,{method:`POST`,body:{id:Pe.current,title:U,body:Me}}).then(t=>{j(t),Y(`chat:${t.id}`),H(!1),je(``),Ne(``),Pe.current=e(),E.reload()}).catch(e=>W(f(e))).finally(()=>z(!1))}}),(0,x.jsx)(m,{error:!0,children:Fe})]}),(0,x.jsx)(le,{title:(0,x.jsx)(`h2`,{children:k?N?.title??M?.title??(O?`无标题`:`Tim`):D===`debug`?`运行提醒`:`项目消息`}),actions:(0,x.jsxs)(x.Fragment,{children:[a===`channels`&&O&&(0,x.jsx)(ce,{conversation:O}),a!==`channels`&&M?.kind===`matter`&&(0,x.jsxs)(`span`,{className:`assistant-participants`,title:M.participants?.join(`、`),children:[M.visibility===`project`?`项目共享 · `:``,M.participants?.join(`、`)]}),a===`channels`&&P?.available&&(P.state===`web`||P.state===`cancelled`||!P.connected)&&(0,x.jsx)(p,{icon:`send`,label:`发布到企业微信频道`,disabled:R,onClick:()=>{z(!0),g(`channels/topics/${O}/publish`,te(),{method:`POST`}).then(()=>E.reload()).catch(e=>W(f(e))).finally(()=>z(!1))}})]})}),a===`channels`&&(0,x.jsx)(m,{error:!0,children:P?.error}),a!==`channels`&&M?.kind===`matter`&&(M.hold||M.pending||M.status===`completed`)&&(0,x.jsx)(`div`,{className:`assistant-matter-state`,role:`status`,children:M.hold?`${M.hold.scope===`all`?`已暂停`:`暂缓修改`} · ${M.hold.reason}`:M.pending?`待确认 · ${M.pending.members.join(`、`)}:${M.pending.question}`:`已完成`}),(0,x.jsxs)(pe,{"data-testid":`assistant-transcript`,onScroll:e=>{let t=e.currentTarget;q.current=t.scrollHeight-t.scrollTop-t.clientHeight<100},children:[k?Ue?(0,x.jsxs)(`div`,{className:`assistant-empty`,"data-testid":`assistant-loading`,children:[(0,x.jsx)(ee,{}),(0,x.jsx)(`p`,{role:`status`,children:Ie||E.error?`暂时无法加载对话`:`加载中…`})]}):M?.messages.length?M.messages.filter(e=>e.body||[`queued`,`running`,`failed`].includes(e.state)).map(e=>(0,x.jsx)(`div`,{className:`assistant-turn`,children:(0,x.jsxs)(Ve,{mine:e.role===`user`&&e.author===i,author:`${e.role===`assistant`?`Tim`:e.author}${e.source===`wecom`?` · 企业微信`:``}`,time:e.createdAt,children:[e.body&&(0,x.jsx)(`div`,{className:`markdown`,children:(0,x.jsx)(fe,{children:e.body})}),e.role===`assistant`&&[`queued`,`running`].includes(e.state)&&(0,x.jsxs)(`span`,{className:`assistant-typing`,"aria-label":`正在回答`,children:[(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{})]}),e.state===`failed`&&(0,x.jsx)(m,{error:!0,children:M.runs.find(t=>t.id===e.runId)?.error||`本次回答未完成。`})]})},e.id)):(0,x.jsxs)(`div`,{className:`assistant-empty`,children:[(0,x.jsx)(ee,{}),(0,x.jsx)(`p`,{children:`有什么项目问题想聊聊?`})]}):!T.data&&T.loading?(0,x.jsx)(`div`,{className:`assistant-empty`,children:(0,x.jsx)(`p`,{role:`status`,children:`加载中…`})}):D===`debug`?X.map(e=>(0,x.jsx)(be,{item:e,onReply:e.archivedAt?void 0:()=>{F(e.id),De(``),W(``)}},e.id)):Z&&(0,x.jsx)(be,{item:Z}),(0,x.jsx)(`div`,{ref:Le})]}),(0,x.jsx)(m,{error:!0,children:Fe||(k?Ie:``)}),He?(0,x.jsx)(_e,{value:Ee,onChange:De,onSubmit:e=>void Be(e),disabled:B,sendDisabled:R||Ue,label:k?`向Tim提问`:`回复消息`}):D!==`debug`&&Z&&(0,x.jsxs)(`div`,{className:`assistant-archived`,children:[(0,x.jsx)(o,{name:`archive`}),`已归档`]})]})}function be({item:e,onReply:t}){return(0,x.jsx)(`div`,{"data-testid":`outbox-thread-${e.id}`,children:(0,x.jsxs)(ge,{author:e.box===`debug`?`运行提醒`:`Tim`,time:e.createdAt,children:[(0,x.jsx)(`div`,{className:`markdown`,children:(0,x.jsx)(fe,{children:e.body})}),t&&(0,x.jsx)(`button`,{type:`button`,className:`assistant-debug-reply`,onClick:t,children:`回复`})]})})}export{C as Assistant};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.combobox-field{position:relative}.combobox-field input{text-overflow:ellipsis;padding-right:44px}.combobox-field .icon-button{color:var(--color-muted);position:absolute;top:50%;right:6px;transform:translateY(-50%)}.combobox-popup{z-index:10;border:1px solid var(--color-line);border-radius:var(--radius-md);background:var(--color-surface);box-shadow:var(--shadow-menu);flex-direction:column;padding:5px;display:flex;position:fixed}.combobox-popup [role=listbox]{min-height:0;overflow:auto}button.combobox-option{border-radius:var(--radius-sm);text-align:left;border:0;gap:12px;width:100%;min-height:42px;padding:8px 10px;font-weight:400}.combobox-option.active,.combobox-option[aria-selected=true]{background:var(--color-hover)}.combobox-option-copy{flex-direction:column;flex:1;min-width:0;display:flex}.combobox-option-copy>*{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.combobox-option-copy small,.combobox-option-detail,.combobox-message{color:var(--color-muted);font-size:var(--text-xs)}.combobox-option-detail{flex-shrink:0}.combobox-message{margin:0;padding:10px}.combobox-footer{justify-content:flex-end;align-items:center;gap:8px;padding:4px 4px 0;display:flex}.native-history{flex-direction:column;gap:20px;display:flex}.native-history-input-row{align-items:center;gap:10px;display:flex}.native-history>small{font-size:var(--text-xs)}button.native-history-more{min-height:30px;font-size:var(--text-xs);color:var(--color-muted);border:0;padding:3px 8px}.native-history-input-row .combobox{flex:1;min-width:0}.session-images{flex-wrap:wrap;gap:8px;padding:6px 0;display:flex}.session-image{width:112px;position:relative}.session-image-preview{border:1px solid var(--color-line);background:var(--color-soft);width:112px;height:88px;color:var(--color-muted);border-radius:8px;place-items:center;padding:0;display:grid;overflow:hidden}.session-image-preview img{object-fit:cover;width:100%;height:100%;display:block}.session-image-remove,.session-image-status{background:var(--color-surface);width:24px;height:24px;min-height:24px;color:var(--color-muted);border:0;border-radius:50%;place-items:center;padding:3px;display:grid;position:absolute}.session-image-remove{top:4px;right:4px}.session-image-status{top:60px;left:4px}.session-image-status[role=status] .icon{animation:1.2s linear infinite image-upload-spin}@keyframes image-upload-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.session-image-status[role=status] .icon{animation:none}}.session-image-error{color:var(--color-muted);font-size:var(--text-xs);overflow-wrap:anywhere;padding-top:4px;display:block}.session-image-file{display:none}.composer-attachments{flex-shrink:0}.composer-menu.composer-attachments .dropdown-trigger{background:0 0;border-radius:50%;width:32px;height:32px;padding:7px}.composer-menu.composer-attachments .dropdown-menu{width:180px}.composer-menu.composer-attachments .dropdown-menu [role=menuitem]{justify-content:flex-start;gap:8px}#session-image-lightbox{width:min(1100px,94vw);max-width:94vw}#session-image-lightbox .dialog-header{margin-bottom:var(--space-3);gap:4px}#session-image-lightbox .dialog-header h2{text-overflow:ellipsis;white-space:nowrap;min-width:0;font-size:var(--text-sm);flex:1;overflow:hidden}.session-image-viewer{outline:none;min-width:0}.file-preview-text,.file-preview-document,.session-image-viewer .html-preview{max-height:70dvh;overflow:auto}.file-preview-document,.session-image-viewer .html-preview{border:0;width:100%;height:70dvh}.file-preview-text{padding:8px}.file-preview-text .raw{white-space:pre-wrap;overflow-wrap:anywhere}.file-preview-text mark{background:var(--color-soft);color:inherit;outline:1px solid var(--color-line)}.file-preview-empty{color:var(--color-muted);text-align:center;padding:32px 0}.computer-file-link,.markdown .computer-file-link{min-height:0;color:inherit;font:inherit;text-align:inherit;text-decoration:underline;-webkit-text-decoration-color:var(--color-muted);text-decoration-color:var(--color-muted);text-underline-offset:3px;overflow-wrap:anywhere;cursor:pointer;background:0 0;border:0;border-radius:0;padding:0;display:inline}#session-image-lightbox .dialog-header small{white-space:nowrap;color:var(--color-muted)}#session-image-lightbox .dialog-header .icon-button{flex-shrink:0;place-items:center;width:30px;height:30px;min-height:30px;padding:6px;display:grid}#session-image-lightbox .dialog-header .icon{stroke-width:1.8px}.session-image-previous .icon{transform:rotate(180deg)}.session-image-stage{background:var(--color-soft);border-radius:8px;justify-content:center;align-items:center;height:min(70dvh,760px);min-height:160px;display:flex;overflow:auto}.session-image-stage img{object-fit:contain;width:auto;max-width:100%;height:auto;max-height:100%}.session-image-stage.original-size{display:block}.session-image-stage.original-size img{max-width:none;max-height:none;margin:auto;display:block}.session-file{width:auto;max-width:100%}.session-file-name{border:1px solid var(--color-line);background:var(--color-soft);max-width:100%;color:inherit;border-radius:8px;align-items:center;gap:6px;padding:6px 10px;display:flex}.session-file-name span,.session-image-unavailable span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.session-file:has(.session-image-remove) .session-file-name{padding-right:32px}.session-file .session-image-status{top:3px;left:2px}.session-image-unavailable{font-size:var(--text-xs);align-content:center;gap:2px;padding:4px}.execution-status{color:var(--color-muted);vertical-align:middle;align-items:center;display:inline-flex}.execution-status.is-spinning svg{animation:1.2s linear infinite execution-status-spin}@keyframes execution-status-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.execution-status.is-spinning svg{animation:none}}.tool-details{min-width:0;color:var(--color-muted);font-size:var(--text-sm);margin:10px 0}.tool-summary{cursor:pointer;align-items:center;gap:8px;min-height:32px;padding:6px 0;list-style:none;display:flex}.tool-details>summary::-webkit-details-marker{display:none}.tool-summary>.icon{flex-shrink:0;width:12px;height:12px}.tool-details[open]>.tool-summary>.icon,.tool-summary[aria-expanded=true]>.icon{transform:rotate(90deg)}.tool-details-label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.tool-details-status{font-size:var(--text-xs);flex-shrink:0;gap:6px;display:flex}.tool-details pre{border-left:1px solid var(--color-line);background:var(--color-soft);border-radius:0 var(--radius-sm) var(--radius-sm) 0;white-space:pre-wrap;overflow-wrap:anywhere;max-height:320px;font-size:var(--text-xs);margin:4px 0 14px 20px;padding:12px 16px;line-height:1.65;overflow:auto}.computer-messages{width:100%;max-width:820px;margin:0 auto}.computer-user-entry{margin:16px 0}.computer-user-entry .assistant-bubble-row{margin-bottom:0}.computer-message-actions{opacity:0;justify-content:flex-end;gap:4px;padding-top:4px;transition:opacity .12s;display:flex}.computer-user-entry:hover .computer-message-actions,.computer-user-entry:focus-within .computer-message-actions{opacity:1}.computer-message-actions .icon-button,.computer-message-edit-footer .icon-button{width:28px;height:28px;min-height:28px;color:var(--color-muted);padding:6px}.computer-message-actions .icon{width:14px;height:14px}.computer-user-entry.editing .assistant-bubble{width:min(100%,640px)}.computer-message-edit textarea{resize:none;background:var(--color-surface);width:100%;min-height:40px;max-height:240px;line-height:1.7}.computer-message-edit-footer{align-items:center;gap:6px;margin-top:8px;display:flex}.computer-message-edit-footer small{color:var(--color-muted);font-size:var(--text-xs);margin-right:auto}@media (hover:none){.computer-message-actions{opacity:1}}.computer-agent-message{overflow-wrap:anywhere;min-width:0;margin:24px 0}.question-bubble:empty{display:none}.question-bubble{border-radius:var(--radius-lg)}.computer-agent-message .markdown{font-size:var(--text-base);line-height:1.8}.computer-agent-message .markdown>:first-child{margin-top:0}.computer-agent-message .markdown>:last-child{margin-bottom:0}.computer-agent-message .markdown :is(h1,h2){font-size:18px}.computer-agent-message .markdown :is(h3,h4,h5,h6){font-size:var(--text-base)}.computer-agent-message .markdown pre{max-width:100%;overflow-x:auto}.computer-commentary{margin:20px 0}.computer-tool-group>button{width:100%;color:inherit;font:inherit;text-align:start;background:0 0;border:0;justify-content:flex-start}.computer-tool-group>button:hover{color:var(--color-text)}.computer-tool-list{border-inline-start:1px solid var(--color-line);margin-inline-start:6px;padding-inline-start:12px}.computer-tool-list .computer-tool{margin:0}.computer-divider{color:var(--color-muted);font-size:var(--text-xs);text-align:center;align-items:center;gap:14px;margin:28px 0;line-height:1.6;display:flex}.computer-divider:before,.computer-divider:after{content:"";border-top:1px solid var(--color-line);flex:1;min-width:16px}.computer-divider>span{overflow-wrap:anywhere;max-width:80%}.inline-reply{width:clamp(180px, var(--reply-width,180px), 600px);border:1px solid var(--color-line);border-radius:var(--radius-sm);background:0 0;align-items:flex-end;gap:4px;max-width:100%;padding:3px 6px;display:flex}.inline-reply:focus-within{border-color:var(--color-input-focus)}.inline-reply textarea{width:100%;min-width:0;min-height:28px;max-height:180px;font-size:var(--text-sm);resize:none;box-shadow:none;background:0 0;border:0;padding:3px 2px;line-height:22px}.inline-reply textarea:focus{box-shadow:none;outline:none}.inline-reply-send{background:0 0;border:0;flex:0 0 26px;place-items:center;width:26px;height:28px;min-height:28px;padding:3px;display:grid}.native-question{grid-template-columns:minmax(0,1fr);gap:12px;min-width:0;display:grid}.native-question>*{min-width:0}.native-question-pending{border:1px solid color-mix(in srgb, var(--brand-orange) 13%, var(--color-line));border-radius:var(--radius-lg);background:color-mix(in srgb, var(--color-accent-soft) 20%, var(--color-surface));padding:14px 16px;box-shadow:0 2px 7px #16161508}.native-async-answer{color:var(--color-muted);font-size:var(--text-sm)}.native-question-part{grid-template-columns:minmax(0,1fr);justify-items:start;gap:8px;min-width:0;display:grid}.native-question-part>p{color:var(--color-text);font-size:var(--text-base);margin:0}.question-options,.question-actions{flex-wrap:wrap;align-items:stretch;gap:8px;max-width:100%;display:flex}.question-options button,.question-actions>button{min-height:var(--control-height);margin:0;line-height:20px}.question-options button{text-align:left;min-width:0;max-width:100%;height:36px;min-height:36px;font-size:var(--text-sm);white-space:nowrap;flex-shrink:1;justify-content:flex-start;align-items:center;gap:6px;padding:6px 10px;font-weight:400;display:flex}.question-options button[aria-pressed=true]{border-color:var(--brand-orange);background:var(--color-accent-soft);color:var(--color-link)}.question-option-description,.question-option-separator{color:var(--color-muted);font-size:inherit}.question-option-description{text-overflow:ellipsis;min-width:0;overflow:hidden}.question-option-separator{flex-shrink:0}.question-option-label{flex-shrink:0;align-items:center;gap:8px;max-width:100%;display:flex;overflow:hidden}.question-check{border:1px solid;border-radius:3px;flex:0 0 14px;justify-content:center;align-items:center;width:14px;height:14px;display:inline-flex}.question-check .icon{width:12px;height:12px}.question-response,.question-result{align-items:baseline;gap:6px;display:flex}.question-response span{white-space:pre-wrap;overflow-wrap:anywhere}.question-result{color:var(--color-muted);font-size:var(--text-xs)}.question-response .icon,.question-result .icon{width:12px;height:12px;color:var(--color-muted);flex-shrink:0}.native-approval-row{flex-wrap:wrap;align-items:flex-start;gap:8px 16px;display:flex}.native-approval-details{flex:240px;margin:0}.native-approval-options{align-items:center;gap:8px;display:flex}.native-approval-options button{min-width:64px;min-height:32px;font-size:var(--text-xs);white-space:nowrap;border-radius:999px;padding:4px 12px;line-height:22px}.native-approval-options button span{font-variant-numeric:tabular-nums;margin-left:2px}.native-approval-row>.question-result{align-self:center}@media (pointer:coarse){.native-approval-options button{min-height:44px}}.native-plan{border:1px solid var(--color-line);border-radius:12px;gap:16px;padding:18px 20px}.native-plan-heading{color:var(--color-muted);font-size:var(--text-sm);align-items:center;gap:8px;display:flex}.native-plan-content{overscroll-behavior:contain;scrollbar-width:thin;min-height:0;max-height:min(480px,50dvh);overflow:auto}.native-plan .markdown :is(h1,h2){font-size:var(--text-lg);margin:18px 0 10px}.native-plan .markdown>:first-child{margin-top:0}.native-plan-history summary{cursor:pointer;color:var(--color-muted)}.native-plan-history[open] summary{margin-bottom:16px}.native-plan-actions{grid-template-columns:repeat(3,minmax(0,1fr));grid-auto-rows:1fr;width:min(100%,360px);display:grid}.native-plan-actions-expanded{grid-template-columns:repeat(2,minmax(0,1fr))}.native-plan-actions>button{min-width:0;padding:10px 8px}.native-plan-note{font-size:var(--text-xs);margin-top:-8px;line-height:1.6}.native-plan-feedback{gap:10px;display:grid}.native-plan-feedback label{font-size:var(--text-sm);gap:6px;display:grid}.native-plan-feedback textarea{width:100%;min-height:96px;font-size:var(--text-base)}.native-plan-feedback-actions{grid-template-columns:repeat(2,minmax(0,1fr));width:min(100%,280px);display:grid}.native-plan-feedback-actions>button{min-width:0;padding:10px 8px}@media (width<=600px){.native-plan{padding:12px}.native-plan-content{max-height:240px}}.composer-menu .dropdown-trigger{height:30px;min-height:30px;font-size:var(--text-xs);color:var(--color-muted);background:var(--color-soft);border-radius:18px;align-items:center;gap:4px;max-width:min(190px,100%);padding:5px 9px;display:flex}.composer-menu .dropdown-trigger>span{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.composer-menu .dropdown-trigger:hover,.composer-menu .dropdown-trigger[aria-expanded=true]{color:var(--color-text);background:var(--color-hover)}.composer-commands .dropdown-trigger{background:var(--color-soft);border-radius:50%;justify-content:center;width:30px;padding:6px}.composer-menu .dropdown-menu{--dropdown-max-height:45dvh;width:300px;max-width:calc(100vw - var(--sidebar-width) - 32px);max-height:45dvh;top:auto;bottom:calc(100% + 12px)}.composer-menu .dropdown-menu [role=menuitem]{font-size:var(--text-sm);justify-content:space-between;gap:12px;padding:10px}.composer-option-copy{text-align:left;flex-direction:column;gap:3px;min-width:0;display:flex}.composer-option-copy small,.composer-menu-heading small{font-size:var(--text-xs);color:var(--color-muted);font-weight:400}.composer-menu code{color:var(--color-muted);background:0 0;font-size:11px}.composer-menu-heading{font-size:var(--text-sm);justify-content:space-between;gap:12px;padding:8px 10px;display:flex}@media (width<=600px){.composer-menu .dropdown-menu{width:calc(100vw - var(--sidebar-width) - 16px);max-width:none}.composer-menu .dropdown-trigger{max-width:min(140px,100%)}}.composer-choice{flex:0 auto;min-width:0}.composer-commands{flex-shrink:0}.composer-commands .icon{width:17px;height:17px}.composer-commands .dropdown-menu{width:640px}.composer-commands .dropdown-menu [role=menuitem]{padding:8px 10px}.composer-command-row{align-items:center;gap:20px;width:100%;min-width:0;display:flex}.composer-command-name{flex:0 190px;min-width:0}.composer-command-row small{min-width:0;color:var(--color-muted);font-weight:400;font-size:var(--text-xs);flex:1}.composer-command-row>*{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}@media (width<=600px){.composer-commands .dropdown-menu{width:calc(100vw - var(--sidebar-width) - 16px)}.composer-command-name{flex-basis:42%}.composer-command-row{gap:10px}}.composer-option-copy small{text-overflow:ellipsis;white-space:nowrap;max-width:260px;overflow:hidden}@media (width<=600px){.computers-layout .message-composer-actions{flex-wrap:wrap;row-gap:8px}.computers-layout .message-composer-footer{align-items:flex-end}}.computer-panel{border-bottom:1px solid var(--color-line);max-height:55vh;padding:16px 24px;overflow:auto}.computer-control-status{margin:0;padding:4px 24px;font-size:12px}@media (width<=760px){.computer-panel{padding:12px}}.computer-tree .tree-name{flex:1}.computer-panel{flex-shrink:0}.computers-layout dialog .computer-panel{border:0;max-height:70dvh;padding:0}.computer-create-menu .dropdown-trigger{place-items:center;width:32px;height:32px;padding:4px;display:grid}.computer-create-menu .dropdown-menu{width:180px;left:auto;right:0}.session-rename{min-height:0;font:inherit;font-weight:inherit;text-align:left;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:0;border-radius:0;max-width:100%;padding:0;display:block;overflow:hidden}.session-rename:hover{color:var(--color-muted);background:0 0}.session-title-form{flex:1;min-width:0;margin-right:16px}.session-title-form input{width:100%}.computers-layout :is(.message-composer,.computer-question-shortcut){align-self:center;width:calc(100% - 56px);max-width:844px}.computer-question-shortcut{flex:none;margin-bottom:4px}.computer-question-shortcut button{min-height:28px;color:var(--color-muted);font-size:var(--text-xs);background:0 0;border:0;align-items:center;gap:6px;padding:2px 4px;font-weight:400;display:inline-flex}.computer-question-shortcut button:hover{background:var(--color-soft)}.computer-question-shortcut .icon{stroke-width:1.6px;width:14px;height:14px}.computers-layout .message-composer :is(.message-composer-actions,.session-images) .icon>*{vector-effect:non-scaling-stroke;stroke-width:1.6px}@media (width<=900px){.computers-layout :is(.message-composer,.computer-question-shortcut){width:calc(100% - 32px)}}@media (width<=600px){.computers-layout :is(.message-composer,.computer-question-shortcut){width:calc(100% - 16px)}}.computer-session-copy{flex-direction:column;flex:1;align-items:flex-start;gap:3px;min-width:0;padding:3px 0;display:flex}.computer-session-copy .tree-name{max-width:100%}.computer-session-copy time{color:var(--color-muted);font-size:var(--text-xs);font-weight:400;line-height:1.3}.computer-tree-row{align-items:center;min-width:0;display:flex}.computer-tree-row>.tree-item{flex:1;min-width:0}.computer-tree-action.icon-button{opacity:0;width:26px;height:26px;min-height:26px;color:var(--color-muted);margin-right:4px;padding:5px}.computer-tree-action.pinned,.computer-tree-row:hover>.computer-tree-action,.computer-tree-row:focus-within>.computer-tree-action{opacity:1}@media (hover:none){.computer-tree-action.icon-button{opacity:1}}.computer-session-row>.tree-item{flex:0 auto;width:auto;max-width:calc(100% - 28px)}.computer-session-pin.icon-button{align-self:flex-start;width:24px;height:24px;min-height:24px;margin:9px 0 0 -8px;padding:6px}.computer-session-pin .icon{width:12px;height:12px}.computer-session-pin:hover{color:var(--color-text)}.computer-navigation{flex-shrink:0;padding:4px}.computer-create-options{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.computer-create-options>button:not(.primary){color:var(--color-muted);background:0 0;border-color:#0000;padding-inline:8px}.computer-create-options>.primary{margin-left:auto}@media (width<=680px){.computers-layout{grid-template-rows:clamp(140px,32dvh,280px) minmax(0,1fr)}}.computer-create-scope{font-size:var(--text-sm);margin:0}
|
|
1
|
+
.combobox-field{position:relative}.combobox-field input{text-overflow:ellipsis;padding-right:44px}.combobox-field .icon-button{color:var(--color-muted);position:absolute;top:50%;right:6px;transform:translateY(-50%)}.combobox-popup{z-index:10;border:1px solid var(--color-line);border-radius:var(--radius-md);background:var(--color-surface);box-shadow:var(--shadow-menu);flex-direction:column;padding:5px;display:flex;position:fixed}.combobox-popup [role=listbox]{min-height:0;overflow:auto}button.combobox-option{border-radius:var(--radius-sm);text-align:left;border:0;gap:12px;width:100%;min-height:42px;padding:8px 10px;font-weight:400}.combobox-option.active,.combobox-option[aria-selected=true]{background:var(--color-hover)}.combobox-option-copy{flex-direction:column;flex:1;min-width:0;display:flex}.combobox-option-copy>*{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.combobox-option-copy small,.combobox-option-detail,.combobox-message{color:var(--color-muted);font-size:var(--text-xs)}.combobox-option-detail{flex-shrink:0}.combobox-message{margin:0;padding:10px}.combobox-footer{justify-content:flex-end;align-items:center;gap:8px;padding:4px 4px 0;display:flex}.native-history{flex-direction:column;gap:20px;display:flex}.native-history-input-row{align-items:center;gap:10px;display:flex}.native-history>small{font-size:var(--text-xs)}button.native-history-more{min-height:30px;font-size:var(--text-xs);color:var(--color-muted);border:0;padding:3px 8px}.native-history-input-row .combobox{flex:1;min-width:0}.session-images{flex-wrap:wrap;gap:8px;padding:6px 0;display:flex}.session-image{width:112px;position:relative}.session-image-preview{border:1px solid var(--color-line);background:var(--color-soft);width:112px;height:88px;color:var(--color-muted);border-radius:8px;place-items:center;padding:0;display:grid;overflow:hidden}.session-image-preview img{object-fit:cover;width:100%;height:100%;display:block}.session-image-remove,.session-image-status{background:var(--color-surface);width:24px;height:24px;min-height:24px;color:var(--color-muted);border:0;border-radius:50%;place-items:center;padding:3px;display:grid;position:absolute}.session-image-remove{top:4px;right:4px}.session-image-status{top:60px;left:4px}.session-image-status[role=status] .icon{animation:1.2s linear infinite image-upload-spin}@keyframes image-upload-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.session-image-status[role=status] .icon{animation:none}}.session-image-error{color:var(--color-muted);font-size:var(--text-xs);overflow-wrap:anywhere;padding-top:4px;display:block}.session-image-file{display:none}.composer-attachments{flex-shrink:0}.composer-menu.composer-attachments .dropdown-trigger{background:0 0;border-radius:50%;width:32px;height:32px;padding:7px}.composer-menu.composer-attachments .dropdown-menu{width:180px}.composer-menu.composer-attachments .dropdown-menu [role=menuitem]{justify-content:flex-start;gap:8px}#session-image-lightbox{width:min(1100px,94vw);max-width:94vw}#session-image-lightbox .dialog-header{margin-bottom:var(--space-3);gap:4px}#session-image-lightbox .dialog-header h2{text-overflow:ellipsis;white-space:nowrap;min-width:0;font-size:var(--text-sm);flex:1;overflow:hidden}.session-image-viewer{outline:none;min-width:0}.file-preview-text,.file-preview-document,.session-image-viewer .html-preview{max-height:70dvh;overflow:auto}.file-preview-document,.session-image-viewer .html-preview{border:0;width:100%;height:70dvh}.file-preview-text{padding:8px}.file-preview-text .raw{white-space:pre-wrap;overflow-wrap:anywhere}.file-preview-text mark{background:var(--color-soft);color:inherit;outline:1px solid var(--color-line)}.file-preview-empty{color:var(--color-muted);text-align:center;padding:32px 0}.computer-file-link,.markdown .computer-file-link{min-height:0;color:inherit;font:inherit;text-align:inherit;text-decoration:underline;-webkit-text-decoration-color:var(--color-muted);text-decoration-color:var(--color-muted);text-underline-offset:3px;overflow-wrap:anywhere;cursor:pointer;background:0 0;border:0;border-radius:0;padding:0;display:inline}#session-image-lightbox .dialog-header small{white-space:nowrap;color:var(--color-muted)}#session-image-lightbox .dialog-header .icon-button{flex-shrink:0;place-items:center;width:30px;height:30px;min-height:30px;padding:6px;display:grid}#session-image-lightbox .dialog-header .icon{stroke-width:1.8px}.session-image-previous .icon{transform:rotate(180deg)}.session-image-stage{background:var(--color-soft);border-radius:8px;justify-content:center;align-items:center;height:min(70dvh,760px);min-height:160px;display:flex;overflow:auto}.session-image-stage img{object-fit:contain;width:auto;max-width:100%;height:auto;max-height:100%}.session-image-stage.original-size{display:block}.session-image-stage.original-size img{max-width:none;max-height:none;margin:auto;display:block}.session-file{width:auto;max-width:100%}.session-file-name{border:1px solid var(--color-line);background:var(--color-soft);max-width:100%;color:inherit;border-radius:8px;align-items:center;gap:6px;padding:6px 10px;display:flex}.session-file-name span,.session-image-unavailable span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.session-file:has(.session-image-remove) .session-file-name{padding-right:32px}.session-file .session-image-status{top:3px;left:2px}.session-image-unavailable{font-size:var(--text-xs);align-content:center;gap:2px;padding:4px}.execution-status{color:var(--color-muted);vertical-align:middle;align-items:center;display:inline-flex}.execution-status.is-spinning svg{animation:1.2s linear infinite execution-status-spin}@keyframes execution-status-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.execution-status.is-spinning svg{animation:none}}.tool-details{min-width:0;color:var(--color-muted);font-size:var(--text-sm);margin:10px 0}.tool-summary{cursor:pointer;align-items:center;gap:8px;min-height:32px;padding:6px 0;list-style:none;display:flex}.tool-details>summary::-webkit-details-marker{display:none}.tool-summary>.icon{flex-shrink:0;width:12px;height:12px}.tool-details[open]>.tool-summary>.icon,.tool-summary[aria-expanded=true]>.icon{transform:rotate(90deg)}.tool-details-label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.tool-details-status{font-size:var(--text-xs);flex-shrink:0;gap:6px;display:flex}.tool-details pre{border-left:1px solid var(--color-line);background:var(--color-soft);border-radius:0 var(--radius-sm) var(--radius-sm) 0;white-space:pre-wrap;overflow-wrap:anywhere;max-height:320px;font-size:var(--text-xs);margin:4px 0 14px 20px;padding:12px 16px;line-height:1.65;overflow:auto}.computer-messages{width:100%;max-width:820px;margin:0 auto}.computer-user-entry{margin:16px 0}.computer-user-entry .assistant-bubble-row{margin-bottom:0}.computer-message-actions{opacity:0;justify-content:flex-end;gap:4px;padding-top:4px;transition:opacity .12s;display:flex}.computer-user-entry:hover .computer-message-actions,.computer-user-entry:focus-within .computer-message-actions{opacity:1}.computer-message-actions .icon-button,.computer-message-edit-footer .icon-button{width:28px;height:28px;min-height:28px;color:var(--color-muted);padding:6px}.computer-message-actions .icon{width:14px;height:14px}.computer-user-entry.editing .assistant-bubble{width:min(100%,640px)}.computer-message-edit textarea{resize:none;background:var(--color-surface);width:100%;min-height:40px;max-height:240px;line-height:1.7}.computer-message-edit-footer{align-items:center;gap:6px;margin-top:8px;display:flex}.computer-message-edit-footer small{color:var(--color-muted);font-size:var(--text-xs);margin-right:auto}@media (hover:none){.computer-message-actions{opacity:1}}.computer-agent-message{overflow-wrap:anywhere;min-width:0;margin:24px 0}.question-bubble:empty{display:none}.question-bubble{border-radius:var(--radius-lg)}.computer-agent-message .markdown{font-size:var(--text-base);line-height:1.8}.computer-agent-message .markdown>:first-child{margin-top:0}.computer-agent-message .markdown>:last-child{margin-bottom:0}.computer-agent-message .markdown :is(h1,h2){font-size:18px}.computer-agent-message .markdown :is(h3,h4,h5,h6){font-size:var(--text-base)}.computer-agent-message .markdown pre{max-width:100%;overflow-x:auto}.computer-commentary{margin:20px 0}.computer-tool-group>button{width:100%;color:inherit;font:inherit;text-align:start;background:0 0;border:0;justify-content:flex-start}.computer-tool-group>button:hover{color:var(--color-text)}.computer-tool-list{border-inline-start:1px solid var(--color-line);margin-inline-start:6px;padding-inline-start:12px}.computer-tool-list .computer-tool{margin:0}.computer-divider{color:var(--color-muted);font-size:var(--text-xs);text-align:center;align-items:center;gap:14px;margin:28px 0;line-height:1.6;display:flex}.computer-divider:before,.computer-divider:after{content:"";border-top:1px solid var(--color-line);flex:1;min-width:16px}.computer-divider>span{overflow-wrap:anywhere;max-width:80%}.inline-reply{width:clamp(180px, var(--reply-width,180px), 600px);border:1px solid var(--color-line);border-radius:var(--radius-sm);background:0 0;align-items:flex-end;gap:4px;max-width:100%;padding:3px 6px;display:flex}.inline-reply:focus-within{border-color:var(--color-input-focus)}.inline-reply textarea{width:100%;min-width:0;min-height:28px;max-height:180px;font-size:var(--text-sm);resize:none;box-shadow:none;background:0 0;border:0;padding:3px 2px;line-height:22px}.inline-reply textarea:focus{box-shadow:none;outline:none}.inline-reply-send{background:0 0;border:0;flex:0 0 26px;place-items:center;width:26px;height:28px;min-height:28px;padding:3px;display:grid}.native-question{grid-template-columns:minmax(0,1fr);gap:12px;min-width:0;display:grid}.native-question>*{min-width:0}.native-question-pending{border:1px solid color-mix(in srgb, var(--brand-orange) 13%, var(--color-line));border-radius:var(--radius-lg);background:color-mix(in srgb, var(--color-accent-soft) 20%, var(--color-surface));padding:14px 16px;box-shadow:0 2px 7px #16161508}.native-async-answer{color:var(--color-muted);font-size:var(--text-sm)}.native-question-part{grid-template-columns:minmax(0,1fr);justify-items:start;gap:8px;min-width:0;display:grid}.native-question-part>p{color:var(--color-text);font-size:var(--text-base);margin:0}.question-options,.question-actions{flex-wrap:wrap;align-items:stretch;gap:8px;max-width:100%;display:flex}.question-options button,.question-actions>button{min-height:var(--control-height);margin:0;line-height:20px}.question-options button{text-align:left;min-width:0;max-width:100%;height:36px;min-height:36px;font-size:var(--text-sm);white-space:nowrap;flex-shrink:1;justify-content:flex-start;align-items:center;gap:6px;padding:6px 10px;font-weight:400;display:flex}.question-options button[aria-pressed=true]{border-color:var(--brand-orange);background:var(--color-accent-soft);color:var(--color-link)}.question-option-description,.question-option-separator{color:var(--color-muted);font-size:inherit}.question-option-description{text-overflow:ellipsis;min-width:0;overflow:hidden}.question-option-separator{flex-shrink:0}.question-option-label{flex-shrink:0;align-items:center;gap:8px;max-width:100%;display:flex;overflow:hidden}.question-check{border:1px solid;border-radius:3px;flex:0 0 14px;justify-content:center;align-items:center;width:14px;height:14px;display:inline-flex}.question-check .icon{width:12px;height:12px}.question-response,.question-result{align-items:baseline;gap:6px;display:flex}.question-response span{white-space:pre-wrap;overflow-wrap:anywhere}.question-result{color:var(--color-muted);font-size:var(--text-xs)}.question-response .icon,.question-result .icon{width:12px;height:12px;color:var(--color-muted);flex-shrink:0}.native-approval-row{flex-wrap:wrap;align-items:flex-start;gap:8px 16px;display:flex}.native-approval-details{flex:240px;margin:0}.native-approval-options{align-items:center;gap:8px;display:flex}.native-approval-options button{min-width:64px;min-height:32px;font-size:var(--text-xs);white-space:nowrap;border-radius:999px;padding:4px 12px;line-height:22px}.native-approval-options button span{font-variant-numeric:tabular-nums;margin-left:2px}.native-approval-row>.question-result{align-self:center}@media (pointer:coarse){.native-approval-options button{min-height:44px}}.native-plan{border:1px solid var(--color-line);border-radius:12px;gap:16px;padding:18px 20px}.native-plan-heading{color:var(--color-muted);font-size:var(--text-sm);align-items:center;gap:8px;display:flex}.native-plan-content{overscroll-behavior:contain;scrollbar-width:thin;min-height:0;max-height:min(480px,50dvh);overflow:auto}.native-plan .markdown :is(h1,h2){font-size:var(--text-lg);margin:18px 0 10px}.native-plan .markdown>:first-child{margin-top:0}.native-plan-history summary{cursor:pointer;color:var(--color-muted)}.native-plan-history[open] summary{margin-bottom:16px}.native-plan-actions{grid-template-columns:repeat(3,minmax(0,1fr));grid-auto-rows:1fr;width:min(100%,360px);display:grid}.native-plan-actions-expanded{grid-template-columns:repeat(2,minmax(0,1fr))}.native-plan-actions>button{min-width:0;padding:10px 8px}.native-plan-note{font-size:var(--text-xs);margin-top:-8px;line-height:1.6}.native-plan-feedback{gap:10px;display:grid}.native-plan-feedback label{font-size:var(--text-sm);gap:6px;display:grid}.native-plan-feedback textarea{width:100%;min-height:96px;font-size:var(--text-base)}.native-plan-feedback-actions{grid-template-columns:repeat(2,minmax(0,1fr));width:min(100%,280px);display:grid}.native-plan-feedback-actions>button{min-width:0;padding:10px 8px}@media (width<=600px){.native-plan{padding:12px}.native-plan-content{max-height:240px}}.composer-menu .dropdown-trigger{height:30px;min-height:30px;font-size:var(--text-xs);color:var(--color-muted);background:var(--color-soft);border-radius:18px;align-items:center;gap:4px;max-width:min(190px,100%);padding:5px 9px;display:flex}.composer-menu .dropdown-trigger>span{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.composer-menu .dropdown-trigger:hover,.composer-menu .dropdown-trigger[aria-expanded=true]{color:var(--color-text);background:var(--color-hover)}.composer-commands .dropdown-trigger{background:var(--color-soft);border-radius:50%;justify-content:center;width:30px;padding:6px}.composer-menu .dropdown-menu{--dropdown-max-height:45dvh;width:300px;max-width:calc(100vw - var(--sidebar-width) - 32px);max-height:45dvh;top:auto;bottom:calc(100% + 12px)}.composer-menu .dropdown-menu [role=menuitem]{font-size:var(--text-sm);justify-content:space-between;gap:12px;padding:10px}.composer-option-copy{text-align:left;flex-direction:column;gap:3px;min-width:0;display:flex}.composer-option-copy small,.composer-menu-heading small{font-size:var(--text-xs);color:var(--color-muted);font-weight:400}.composer-menu code{color:var(--color-muted);background:0 0;font-size:11px}.composer-menu-heading{font-size:var(--text-sm);justify-content:space-between;gap:12px;padding:8px 10px;display:flex}@media (width<=600px){.composer-menu .dropdown-menu{width:calc(100vw - var(--sidebar-width) - 16px);max-width:none}.composer-menu .dropdown-trigger{max-width:min(140px,100%)}}.composer-choice{flex:0 auto;min-width:0}.composer-commands{flex-shrink:0}.composer-commands .icon{width:17px;height:17px}.composer-commands .dropdown-menu{width:640px}.composer-commands .dropdown-menu [role=menuitem]{padding:8px 10px}.composer-command-row{align-items:center;gap:20px;width:100%;min-width:0;display:flex}.composer-command-name{flex:0 190px;min-width:0}.composer-command-row small{min-width:0;color:var(--color-muted);font-weight:400;font-size:var(--text-xs);flex:1}.composer-command-row>*{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}@media (width<=600px){.composer-commands .dropdown-menu{width:calc(100vw - var(--sidebar-width) - 16px)}.composer-command-name{flex-basis:42%}.composer-command-row{gap:10px}}.composer-option-copy small{text-overflow:ellipsis;white-space:nowrap;max-width:260px;overflow:hidden}@media (width<=600px){.computers-layout .message-composer-actions{flex-wrap:wrap;row-gap:8px}.computers-layout .message-composer-footer{align-items:flex-end}}.computer-panel{border-bottom:1px solid var(--color-line);max-height:55vh;padding:16px 24px;overflow:auto}.computer-control-status{margin:0;padding:4px 24px;font-size:12px}@media (width<=760px){.computer-panel{padding:12px}}.computer-tree .tree-name{flex:1}.computer-panel{flex-shrink:0}.computers-layout dialog .computer-panel{border:0;max-height:70dvh;padding:0}.computer-create-menu .dropdown-trigger{place-items:center;width:32px;height:32px;padding:4px;display:grid}.computer-create-menu .dropdown-menu{width:180px;left:auto;right:0}.session-rename{min-height:0;font:inherit;font-weight:inherit;text-align:left;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:0;border-radius:0;max-width:100%;padding:0;display:block;overflow:hidden}.session-rename:hover{color:var(--color-muted);background:0 0}.session-title-form{flex:1;min-width:0;margin-right:16px}.session-title-form input{width:100%}.computers-layout :is(.message-composer,.computer-question-shortcut){align-self:center;width:calc(100% - 56px);max-width:844px}.computer-question-shortcut{flex:none;margin-bottom:4px}.computer-question-shortcut button{min-height:28px;color:var(--color-muted);font-size:var(--text-xs);background:0 0;border:0;align-items:center;gap:6px;padding:2px 4px;font-weight:400;display:inline-flex}.computer-question-shortcut button:hover{background:var(--color-soft)}.computer-question-shortcut .icon{stroke-width:1.6px;width:14px;height:14px}.computers-layout .message-composer :is(.message-composer-actions,.session-images) .icon>*{vector-effect:non-scaling-stroke;stroke-width:1.6px}@media (width<=900px){.computers-layout :is(.message-composer,.computer-question-shortcut){width:calc(100% - 32px)}}@media (width<=600px){.computers-layout :is(.message-composer,.computer-question-shortcut){width:calc(100% - 16px)}}.computer-session-copy{flex-direction:column;flex:1;align-items:flex-start;gap:3px;min-width:0;padding:3px 0;display:flex}.computer-session-copy .tree-name{max-width:100%}.computer-session-copy time{color:var(--color-muted);font-size:var(--text-xs);font-weight:400;line-height:1.3}.computer-tree-row{align-items:center;min-width:0;display:flex}.computer-tree-row>.tree-item{flex:1;min-width:0}.computer-tree-action.icon-button{opacity:0;width:26px;height:26px;min-height:26px;color:var(--color-muted);margin-right:4px;padding:5px}.computer-tree-action.pinned,.computer-tree-row:hover>.computer-tree-action,.computer-tree-row:focus-within>.computer-tree-action{opacity:1}@media (hover:none){.computer-tree-action.icon-button{opacity:1}}.computer-session-row>.tree-item{flex:0 auto;width:auto;max-width:calc(100% - 28px)}.computer-session-pin.icon-button{align-self:flex-start;width:24px;height:24px;min-height:24px;margin:9px 0 0 -8px;padding:6px}.computer-session-pin .icon{width:12px;height:12px}.computer-session-pin:hover{color:var(--color-text)}.computer-navigation{flex-shrink:0;padding:4px}.computer-create-options{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.computer-create-options>button:not(.primary){color:var(--color-muted);background:0 0;border-color:#0000;padding-inline:8px}.computer-create-options>.primary{margin-left:auto}@media (width<=680px){.computers-layout{grid-template-rows:clamp(140px,32dvh,280px) minmax(0,1fr)}}.computer-create-scope{font-size:var(--text-sm);margin:0}.computer-older{color:var(--color-muted);font:inherit;font-size:var(--text-xs);cursor:pointer;background:0 0;border:0;margin:0 auto 16px;padding:4px 10px;display:block}.computer-older:hover{color:var(--color-text)}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TerminalPane-ZhM38vie.js","./Dropdown-Dh9Q9fSi.js","./index-CWjsEUUy.js","./index-u6KD7Soy.css","./Markdown-Gk89fXoh.js","./task-links-ArhNpuGG.js","./TerminalPane-BrSy-0jI.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{A as e,C as t,Ct as n,E as r,Q as i,St as a,T as o,c as s,ct as c,d as l,dt as u,ft as d,gt as f,k as p,l as m,lt as h,ot as g,p as _,pt as v,st as y,t as b,v as x,vt as S,w as C,x as w}from"./Dropdown-Dh9Q9fSi.js";import{B as T,C as E,F as D,N as O,R as k,_ as A,a as j,b as M,c as ee,d as N,f as te,g as P,h as F,j as ne,l as re,m as ie,o as ae,p as oe,s as se,t as ce,u as le,v as ue,w as de,x as fe,y as pe,z as me}from"./index-CWjsEUUy.js";import{i as he,t as I}from"./Markdown-Gk89fXoh.js";import{a as ge,i as _e,n as ve,t as L}from"./Conversation-Bdsoobmv.js";import{n as ye,t as be}from"./MessageComposer-DFvWZibH.js";import{l as xe,r as Se}from"./WorkspaceTree-yST2ByxM.js";var R=a(),z=o();function Ce({title:e,busy:t,onSave:n}){let[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(e);return r?(0,z.jsx)(`form`,{className:`session-title-form`,onSubmit:t=>{t.preventDefault(),a.trim()&&a.trim()!==e&&n(a.trim()),i(!1)},children:(0,z.jsx)(`input`,{autoFocus:!0,"aria-label":`会话标题`,value:a,disabled:t,onChange:e=>o(e.target.value),onBlur:()=>i(!1),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),i(!1))}})}):(0,z.jsx)(`h2`,{children:(0,z.jsx)(`button`,{type:`button`,className:`session-rename`,title:`重命名会话`,"aria-label":`重命名会话:${e}`,onClick:()=>{o(e),i(!0)},children:e})})}var we=v({id:f().uuid(),directory:f(),title:f(),cwd:f(),createdAt:f(),state:g([`running`,`exited`]),exitCode:d().nullable()}),B={id:f().uuid(),directory:f().min(1).max(200)},Te={cols:d().int().min(2).max(500),rows:d().int().min(1).max(300)};h(`type`,[v({type:u(`create`),...B,...Te,title:f().trim().min(1).max(160)}),v({type:u(`attach`),...B}),v({type:u(`detach`),...B}),v({type:u(`input`),...B,data:f().max(65536)}),v({type:u(`resize`),...B,...Te}),v({type:u(`rename`),...B,title:f().trim().min(1).max(160)}),v({type:u(`close`),...B})]);var Ee=h(`type`,[v({type:u(`size`),id:f(),...Te}),v({type:u(`inventory`),directories:y(f()),terminals:y(we)}),v({type:u(`snapshot`),id:f(),data:f(),cols:d(),rows:d(),seq:d()}),v({type:u(`output`),id:f(),data:f(),seq:d()}),v({type:u(`result`),id:f(),operation:f(),error:f().optional()})]);function De(e,t){let r=(0,R.useRef)(null),i=(0,R.useRef)(new Set),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)([]),[l,u]=(0,R.useState)([]);(0,R.useEffect)(()=>{if(!t)return;let a=!1,s,l,d=()=>{let t=new URL(n(`/api/v1/projects/${encodeURIComponent(e)}/web/terminals`),location.origin);t.protocol=t.protocol===`https:`?`wss:`:`ws:`,l=new WebSocket(t),r.current=l,l.onmessage=e=>{let t=Ee.safeParse(JSON.parse(e.data));if(!t.success||a)return;let n=t.data;n.type===`inventory`&&(u(n.terminals),c(n.directories),o(!0));for(let e of i.current)e(n)},l.onclose=()=>{o(!1),c([]),a||(s=setTimeout(d,2e3))}};return d(),()=>{a=!0,clearTimeout(s),l?.close(),r.current=null}},[e,t]);let d=(0,R.useCallback)(e=>(i.current.add(e),()=>{i.current.delete(e)}),[]),f=(0,R.useCallback)(e=>{if(r.current?.readyState!==WebSocket.OPEN)throw Error(`终端连接已断开,输入未发送。`);r.current.send(JSON.stringify(e))},[]);return{connected:a,directories:s,terminals:l,subscribe:d,send:f,request:(0,R.useCallback)(e=>new Promise((t,n)=>{let r=setTimeout(()=>{i(),n(Error(`暂未收到结果,请检查连接;操作不会自动重发。`))},15e3),i=d(a=>{a.type===`result`&&a.id===e.id&&a.operation===e.type&&(clearTimeout(r),i(),a.error?n(Error(a.error)):t())});try{f(e)}catch(e){clearTimeout(r),i(),n(e)}}),[f,d])}}v({provider:te,cursor:f().optional(),session:F.optional()});var Oe=v({id:F,title:f(),cwd:f(),updatedAt:f().datetime().nullable(),active:c().default(!1)}),ke=v({sessions:y(Oe),nextCursor:f().nullable()}),Ae=v({command:P,history:ke.nullable()});function je(e,t=Date.now()){if(!e)return``;let n=new Date(e),r=Math.max(0,t-n.getTime());return Number.isFinite(r)?r<36e5?`${Math.floor(r/6e4)}min`:r<864e5?`${Math.floor(r/36e5)}h`:r<=6048e5?`${Math.floor(r/864e5)}day`:`${String(n.getFullYear()).slice(-2)}/${String(n.getMonth()+1).padStart(2,`0`)}/${String(n.getDate()).padStart(2,`0`)}`:``}function Me({id:e,label:t,value:n,onChange:r,options:i,placeholder:a,loading:o=!1,disabled:s=!1,empty:c=`没有匹配的选项。`,footer:l}){let[u,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)(``),[h,g]=(0,R.useState)(),_=(0,R.useRef)(null),v=(0,R.useRef)(null),y=(0,R.useRef)(null),b=i.find(e=>e.value===n),x=b?``:n.trim().toLocaleLowerCase(),S=i.filter(e=>`${e.label} ${e.value}`.toLocaleLowerCase().includes(x)),C=S.filter(e=>!e.disabled),w=S.findIndex(e=>e.value===f);(0,R.useEffect)(()=>p(``),[n]),(0,R.useEffect)(()=>{if(!u)return;let e=e=>{_.current?.contains(e.target)||d(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[u]),(0,R.useLayoutEffect)(()=>{if(!u)return;let e=()=>{let e=v.current?.getBoundingClientRect();if(!e)return;let t=innerHeight-e.bottom-16,n=e.top-16,r=t<220&&n>t;g({left:e.left,width:e.width,top:r?void 0:e.bottom+6,bottom:r?innerHeight-e.top+6:void 0,maxHeight:Math.min(320,r?n:t)})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[u]),(0,R.useEffect)(()=>{u&&w>=0&&document.getElementById(`${e}-option-${w}`)?.scrollIntoView({block:`nearest`})},[u,w,e]);function T(e){e.disabled||(r(e.value),d(!1),y.current?.focus())}return(0,z.jsxs)(`div`,{className:`combobox`,ref:_,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||d(!1)},onKeyDown:e=>{e.key===`Escape`&&u&&(e.preventDefault(),e.stopPropagation(),d(!1),y.current?.focus())},children:[(0,z.jsxs)(`div`,{className:`combobox-field`,ref:v,children:[(0,z.jsx)(`input`,{id:e,ref:y,role:`combobox`,"aria-label":t,"aria-autocomplete":`list`,"aria-expanded":u,"aria-controls":`${e}-list`,"aria-activedescendant":u&&w>=0?`${e}-option-${w}`:void 0,autoComplete:`off`,disabled:s,value:b?.label??n,title:b?.value,placeholder:a,onClick:()=>d(!0),onChange:e=>{r(e.target.value),d(!0)},onKeyDown:e=>{if([`ArrowDown`,`ArrowUp`].includes(e.key)){e.preventDefault(),d(!0);let t=C.findIndex(e=>e.value===f),n=t<0?e.key===`ArrowDown`?0:C.length-1:(t+(e.key===`ArrowDown`?1:-1)+C.length)%C.length;p(C[n]?.value??``)}else e.key===`Enter`&&u&&w>=0?(e.preventDefault(),T(S[w])):e.key===`Tab`&&d(!1)}}),(0,z.jsx)(m,{icon:u?`chevronUp`:`chevronDown`,label:`${u?`收起`:`展开`}${t}`,disabled:s,"aria-expanded":u,"aria-controls":`${e}-list`,onClick:()=>{d(!u),y.current?.focus()}})]}),u&&(0,z.jsxs)(`div`,{className:`combobox-popup`,style:h,children:[(0,z.jsxs)(`div`,{id:`${e}-list`,role:`listbox`,"aria-label":t,"aria-busy":o,children:[S.map((t,r)=>(0,z.jsxs)(`button`,{id:`${e}-option-${r}`,type:`button`,role:`option`,"aria-selected":t.value===n,disabled:t.disabled,tabIndex:-1,className:`combobox-option ${t.value===f?`active`:``}`,title:`${t.label} · ${t.value}`,onMouseDown:e=>e.preventDefault(),onClick:()=>T(t),children:[(0,z.jsxs)(`span`,{className:`combobox-option-copy`,children:[(0,z.jsx)(`span`,{children:t.label}),t.description&&(0,z.jsx)(`small`,{children:t.description})]}),t.detail&&(0,z.jsx)(`span`,{className:`combobox-option-detail`,children:t.detail})]},t.value)),o&&(0,z.jsx)(`p`,{className:`combobox-message`,role:`status`,children:`正在读取…`}),!o&&!S.length&&(0,z.jsx)(`p`,{className:`combobox-message`,children:c})]}),l&&(0,z.jsx)(`div`,{className:`combobox-footer`,children:l})]})]})}function Ne({directory:t,provider:n,providers:r,sessions:i,request:a,onClose:o,onImport:s}){let[c,u]=(0,R.useState)(n),[d,f]=(0,R.useState)([]),[h,g]=(0,R.useState)(null),[v,y]=(0,R.useState)(``),[b,x]=(0,R.useState)(null),[S,C]=(0,R.useState)(``),w=(0,R.useRef)(null),T=e=>i.find(t=>!t.hidden&&t.provider===c&&(t.nativeSession??t.resumeSession)===e);async function E(n,r){let i=e();for(await a(`web/local-agents/${t}/history`,P,{method:`POST`,signal:r,body:{id:i,argument:JSON.stringify({provider:c,...n})}});!r.aborted;){let e=await a(`web/local-agents/${t}/history/${i}`,Ae,{signal:r});if(e.command.state===`succeeded`&&e.history)return{...e.history,id:i};if(![`queued`,`running`].includes(e.command.state))throw Error(e.command.error||`读取历史会话失败。`);await new Promise(e=>{let t=()=>{clearTimeout(n),r.removeEventListener(`abort`,t),e()},n=setTimeout(t,1e3);r.addEventListener(`abort`,t,{once:!0})})}throw new DOMException(`Aborted`,`AbortError`)}async function D(n,r,i){let o=T(n.id)??await a(`web/local-agents/${t}/sessions`,ie,{method:`POST`,signal:i,body:{id:e(),title:n.title,provider:c,resumeSession:n.id,historyRequest:r}});i.aborted||s(o)}async function O(e,t){w.current?.abort();let n=new AbortController;w.current=n,x(e),C(``);try{await t(n.signal)}catch(e){n.signal.aborted||C(p(e))}finally{n.signal.aborted||x(null)}}let k=e=>O(`list`,async t=>{let n=await E(e?{cursor:e}:{},t);t.aborted||(f(t=>{let r=[...e?t:[],...n.sessions.map(e=>({...e,requestId:n.id}))];return[...new Map(r.map(e=>[e.id,e])).values()].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``))}),g(n.nextCursor))});(0,R.useEffect)(()=>(f([]),g(null),y(``),k(),()=>w.current?.abort()),[c,t,a]);let A=d.find(e=>e.id===v),j=b===`import`;return(0,z.jsx)(l,{id:`computer-import-session`,title:`导入历史会话`,onClose:o,children:(0,z.jsxs)(`form`,{className:`native-history`,onSubmit:e=>{e.preventDefault(),O(`import`,async e=>{let t=v.trim(),n=T(t);if(n)return s(n);if(A)return D(A,A.requestId,e);let r=await E({session:t},e),i=r.sessions.find(e=>e.id===t);if(!i)throw Error(`找不到此目录中的会话。`);await D(i,r.id,e)})},children:[(0,z.jsx)(ae,{label:`历史会话 Agent`,value:c,onChange:u,providers:[n,...r],disabled:j}),(0,z.jsxs)(`div`,{className:`field`,children:[(0,z.jsx)(`label`,{htmlFor:`native-history-session`,children:`Session`}),(0,z.jsxs)(`div`,{className:`native-history-input-row`,children:[(0,z.jsx)(Me,{id:`native-history-session`,label:`历史会话`,value:v,onChange:y,placeholder:`选择会话或输入 ID`,disabled:j,loading:b===`list`,empty:v?`未找到匹配会话,可直接输入 Session ID。`:`此目录暂无历史会话,可输入 Session ID。`,options:d.map(e=>({value:e.id,label:e.title,description:e.id,detail:T(e.id)?`已接入`:e.active?`工作中`:je(e.updatedAt),disabled:e.active&&!T(e.id)})),footer:(0,z.jsxs)(z.Fragment,{children:[h&&(0,z.jsx)(`button`,{className:`native-history-more`,type:`button`,disabled:!!b,onClick:()=>void k(h),children:`加载更多`}),(0,z.jsx)(m,{icon:`refresh`,label:`刷新历史会话`,disabled:!!b,onClick:()=>void k()})]})},c),(0,z.jsx)(`button`,{type:`submit`,disabled:j||!F.safeParse(v.trim()).success||!!A?.active&&!T(A.id),children:j?`正在导入…`:T(v.trim())?`打开`:`导入`})]})]}),(0,z.jsx)(_,{error:!0,children:S}),(0,z.jsx)(`small`,{className:`muted`,children:`请先退出原终端会话。`})]})})}var V={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`,avif:`image/avif`,bmp:`image/bmp`,ico:`image/x-icon`,svg:`image/svg+xml`};function Pe(e,t){let n=e.toLowerCase().split(`.`).at(-1)??``;return t&&Object.values(V).includes(t)?t:Object.hasOwn(V,n)?V[n]:n===`pdf`?`application/pdf`:/^(md|markdown|mdown)$/.test(n)?`text/markdown`:/^html?$/.test(n)?`text/html`:/^(txt|log|csv|tsv|jsonl?|ndjson|ya?ml|toml|ini|cfg|conf|xml|sql|diff|patch|sh|bash|zsh|fish|py|js|jsx|mjs|cjs|ts|tsx|css|scss|vue|svelte|go|rs|c|cc|cpp|h|hpp|java|kt|swift|rb|lua|r|tex|rst|properties|env|lock)$/.test(n)||/^(readme|license|makefile|dockerfile|cmakelists\.txt|\.gitignore)$/i.test(e)?`text/plain`:``}async function Fe(e,t){let n=e.body.getReader(),r=[],i=0,a=(t??0)>de;try{for(;;){let{done:e,value:t}=await n.read();if(e)break;let o=Math.min(t.length,de-i);if(r.push(t.slice(0,o)),i+=o,o<t.length||a&&i===524288){a=!0;break}}}finally{await n.cancel(),n.releaseLock()}return{blob:new Blob(r),truncated:a}}async function Ie(e,t,n,r){let i=e.previewUrl??e.url;if(i.startsWith(`data:`)&&t.startsWith(`image/`))return{format:t,preview:i,download:i};if(!t&&!e.previewUrl)return{format:``};let a=await fetch(i,{credentials:`same-origin`,cache:`no-store`,signal:n});if(!a.ok)throw Error((await a.json().catch(()=>null))?.error?.message??`文件暂不可用。`);if(!t)return await a.body?.cancel(),{format:``};if(t.startsWith(`text/`)){let n=a.headers.get(`X-Teammy-File-Size`)??a.headers.get(`Content-Length`),{blob:i,truncated:o}=await Fe(a,n===null?e.size:Number(n)),s=o?void 0:r(i.slice(0,i.size,`application/octet-stream`)),c;try{c=new TextDecoder(`utf-8`,{fatal:!0}).decode(await i.arrayBuffer(),{stream:o})}catch{return{format:``,download:s}}return c.includes(`\0`)?{format:``,download:s}:{format:t,text:c,truncated:o,download:s}}let o=await a.blob();if(t===`image/svg+xml`)return{format:t,preview:`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(await o.text()),download:r(o.slice(0,o.size,`application/octet-stream`))};if(t===`application/pdf`&&(navigator.pdfViewerEnabled===!1||await o.slice(0,5).text()!==`%PDF-`))return{format:``,download:r(o.slice(0,o.size,`application/octet-stream`))};let s=r(o.slice(0,o.size,t));return{format:t,preview:s,download:s}}function Le({file:e,onClose:t,gallery:n}){let[r,i]=(0,R.useState)(),[a,o]=(0,R.useState)(``),[c,u]=(0,R.useState)(!1),d=(0,R.useRef)(null),f=(0,R.useRef)(null),h=Pe(e.name,e.mimeType),{name:g,url:v,previewUrl:y,size:b}=e;(0,R.useEffect)(()=>{let e=new AbortController,t;return i(void 0),o(``),u(!1),Ie({name:g,url:v,previewUrl:y,size:b},h,e.signal,n=>(e.signal.throwIfAborted(),t=URL.createObjectURL(n),t)).then(t=>{e.signal.aborted||i(t)}).catch(t=>{e.signal.aborted||o(p(t))}),d.current?.focus(),()=>{e.abort(),t&&URL.revokeObjectURL(t)}},[v,b,y,g,h]),(0,R.useEffect)(()=>{f.current?.scrollIntoView({block:`center`})},[r,e.line]);let x=e.line&&r?.text!==void 0?r.text.split(`
|
|
3
|
+
`):null,S=(e.line??1)-1,C=h.startsWith(`image/`);return(0,z.jsx)(l,{id:`session-image-lightbox`,title:e.name,label:C?`图片预览`:`文件预览`,onClose:t,onKeyDown:e=>{n&&[`ArrowLeft`,`ArrowRight`].includes(e.key)&&(e.preventDefault(),n.move(e.key===`ArrowLeft`?-1:1))},actions:(0,z.jsxs)(z.Fragment,{children:[n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(m,{icon:`chevron`,className:`session-image-previous`,label:`上一张图片`,onClick:()=>n.move(-1)}),(0,z.jsxs)(`small`,{children:[n.index+1,` / `,n.count]}),(0,z.jsx)(m,{icon:`chevron`,label:`下一张图片`,onClick:()=>n.move(1)})]}),C&&r?.format&&(0,z.jsx)(m,{icon:c?`zoomOut`:`zoomIn`,label:c?`适合窗口`:`原始尺寸`,"aria-pressed":c,onClick:()=>u(!c)}),(0,z.jsx)(`a`,{className:`icon-button`,href:a?void 0:r?.download??e.url,"aria-disabled":!!a,download:e.name,"aria-label":`下载文件`,title:`下载文件`,children:(0,z.jsx)(s,{name:`download`})})]}),children:(0,z.jsx)(`div`,{ref:d,tabIndex:-1,className:`session-image-viewer`,children:a?(0,z.jsx)(_,{error:!0,children:a}):r?r.format?C?(0,z.jsx)(`div`,{className:`session-image-stage`+(c?` original-size`:``),children:(0,z.jsx)(`img`,{src:r.preview,alt:e.name,onError:()=>i({format:``,download:r.download})})}):r.format===`application/pdf`?(0,z.jsx)(`iframe`,{className:`file-preview-document`,src:r.preview,title:e.name+` 预览`}):r.format===`text/html`&&!e.line?(0,z.jsx)(xe,{name:e.name,url:e.url}):(0,z.jsxs)(`div`,{className:`file-preview-text`,children:[r.format===`text/markdown`&&!e.line?(0,z.jsx)(`article`,{className:`markdown`,children:(0,z.jsx)(I,{children:r.text??``})}):(0,z.jsx)(`pre`,{className:`raw`,children:x&&S<x.length?(0,z.jsxs)(z.Fragment,{children:[S>0&&x.slice(0,S).join(`
|
|
4
|
+
`)+`
|
|
5
|
+
`,(0,z.jsx)(`mark`,{ref:f,children:x[S]||` `}),x.length>S+1?`
|
|
6
|
+
`+x.slice(S+1).join(`
|
|
7
|
+
`):``]}):r.text}),r.truncated&&(0,z.jsx)(`small`,{children:`仅显示文件开头,可下载完整文件。`})]}):(0,z.jsx)(`p`,{className:`file-preview-empty`,children:`暂不支持预览此文件。`}):(0,z.jsx)(`p`,{role:`status`,children:`正在读取文件…`})})})}var Re=[],ze=`image/png,image/jpeg,image/webp`;function Be(e){if(`image/png,image/jpeg,image/webp`.split(`,`).includes(e.type))return e.type;if(e.type&&e.type!==`application/octet-stream`)return null;let t=e.name.split(`.`).at(-1)?.toLowerCase();return t===`png`?`image/png`:t===`jpg`||t===`jpeg`?`image/jpeg`:t===`webp`?`image/webp`:null}var Ve=class{sessions=new Map;listeners=new Set;uploads=new Map;get=e=>this.sessions.get(e)??Re;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));set(e,t){this.sessions.set(e,t);for(let e of this.listeners)e()}patch(e,t,n){this.set(e,this.get(e).map(e=>e.id===t?{...e,...n}:e))}add(t,n,r,i=!1){if(!t||!n.length)return;if(n.length+this.get(t).length>4)return i?`每条消息最多添加 4 张图片。`:`每条消息最多添加 4 个附件。`;if(Array.from(n).some(e=>i&&(!Be(e)||!e.size)||e.size>fe))return i?`请选择不超过 2 GB 的 PNG、JPEG 或 WebP 图片。`:`每个附件最多 2 GB。`;let a=Array.from(n,t=>({id:e(),name:t.name.slice(0,200)||`附件`,imageOnly:i,file:t,state:`uploading`}));this.set(t,[...this.get(t),...a]);for(let e of a)this.upload(t,e.id,r)}remove(e,t){this.uploads.get(t)?.abort(),this.uploads.delete(t),this.set(e,this.get(e).filter(e=>e.id!==t))}async upload(e,t,n){let a=this.get(e).find(e=>e.id===t);if(!a?.file||this.uploads.has(t))return;let o=new AbortController;this.uploads.set(t,o),this.patch(e,t,{state:`uploading`,error:``});try{let r=a.file,s=`web/local-agent-sessions/${e}/attachments/${t}`,l;if(r.size>5242880){for(let l=a.uploaded??0;l<r.size;l+=M){let a=r.slice(l,l+M);await n(`${s}/parts/${l/M}?size=${r.size}`,v({ok:c()}),{method:`POST`,signal:o.signal,timeoutMs:i,body:a}),this.patch(e,t,{uploaded:l+a.size})}l=await n(`${s}/finish`,E,{method:`POST`,signal:o.signal,timeoutMs:i,body:{name:a.name,size:r.size,imageOnly:a.imageOnly}})}else{let s=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(String(n.result)),n.onerror=()=>t(Error(`附件读取失败。`)),n.onabort=()=>t(Error(`附件读取已取消。`)),o.signal.addEventListener(`abort`,()=>n.abort(),{once:!0}),n.readAsDataURL(r)});if(o.signal.aborted)return;Be(r)&&this.patch(e,t,{preview:s}),l=await n(`web/local-agent-sessions/${e}/${a.imageOnly?`images`:`attachments`}`,E,{method:`POST`,signal:o.signal,timeoutMs:i,body:{id:t,name:a.name,data:s.split(`,`,2)[1]}})}o.signal.aborted||this.set(e,this.get(e).map(e=>e.id===t?{id:t,name:l.name,state:`ready`,attachment:l,imageOnly:e.imageOnly}:e))}catch(n){o.signal.aborted||this.patch(e,t,{state:`failed`,error:p(n),...n instanceof r&&n.code===`ATTACHMENT_INCOMPLETE`?{uploaded:0}:{}})}finally{this.uploads.get(t)===o&&this.uploads.delete(t)}}},He=(e,t,r,i=!1)=>n(`/api/v1/projects/${encodeURIComponent(e)}/local-agent/sessions/${encodeURIComponent(t)}/${i?`attachments`:`images`}/${encodeURIComponent(r)}`);function Ue({images:e,remove:t,retry:n,disabled:r=!1}){let[i,a]=(0,R.useState)(),[o,c]=(0,R.useState)([]),l=e.find(e=>e.id===i),u=e.filter(e=>!e.file&&!o.includes(e.id)),d=u.findIndex(e=>e.id===i);return e.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`session-images`,children:e.map(e=>(0,z.jsxs)(`div`,{className:`session-image${e.file?` session-file`:``}`,children:[e.file?(0,z.jsxs)(`button`,{type:`button`,className:`session-file-name`,title:e.name,"aria-label":`预览附件 ${e.name}`,disabled:!e.url||e.state===`uploading`||e.state===`failed`,onClick:()=>a(e.id),children:[(0,z.jsx)(s,{name:`attachment`,size:`small`}),(0,z.jsx)(`span`,{children:e.name})]}):o.includes(e.id)?(0,z.jsxs)(`button`,{type:`button`,className:`session-image-preview session-image-unavailable`,title:`重新读取图片`,onClick:()=>c(t=>t.filter(t=>t!==e.id)),children:[(0,z.jsx)(s,{name:`refresh`,size:`small`}),(0,z.jsx)(`span`,{children:e.name}),(0,z.jsx)(`small`,{children:`图片暂不可用`})]}):(0,z.jsx)(`button`,{type:`button`,className:`session-image-preview`,"aria-label":`预览图片 ${e.name}`,title:e.name,disabled:!e.url,onClick:()=>a(e.id),children:e.url?(0,z.jsx)(`img`,{src:e.url,alt:e.name,loading:`lazy`,onError:()=>c(t=>[...t,e.id])}):(0,z.jsx)(s,{name:`image`})}),e.state===`uploading`&&(0,z.jsx)(`span`,{className:`session-image-status`,role:`status`,"aria-label":`正在上传 ${e.name}`,children:(0,z.jsx)(s,{name:`loading`,size:`small`})}),e.state===`failed`&&(0,z.jsx)(`button`,{type:`button`,className:`session-image-status`,"aria-label":`重试上传 ${e.name}`,title:e.error,disabled:r,onClick:()=>n?.(e.id),children:(0,z.jsx)(s,{name:`refresh`,size:`small`})}),t&&(0,z.jsx)(`button`,{type:`button`,className:`session-image-remove`,"aria-label":`移除${e.file?`附件`:`图片`} ${e.name}`,disabled:r,onClick:()=>t(e.id),children:(0,z.jsx)(s,{name:`close`,size:`small`})}),e.state===`failed`&&(0,z.jsx)(`small`,{className:`session-image-error`,children:e.error})]},e.id))}),l&&(0,z.jsx)(Le,{file:l,onClose:()=>a(void 0),gallery:d>=0&&u.length>1?{index:d,count:u.length,move:e=>a(u[(d+e+u.length)%u.length]?.id)}:void 0},l.id)]}):null}function We({images:e,url:t}){return(0,z.jsx)(Ue,{images:e.map(e=>({...e,file:e.mimeType===`application/octet-stream`,url:t(e.id)}))})}function Ge(e,n,r){let i=C(),a=t(n,`computer-attachment-uploads`),o=(0,R.useMemo)(()=>{let e=i?.get(a)??new Ve;return i?.set(a,e),e},[i,a]),c=(0,R.useSyncExternalStore)(o.subscribe,()=>o.get(e)),[l,u]=(0,R.useState)(``),d=(0,R.useRef)(null),f=(0,R.useRef)(null),m=`${n}:${e}`,h=(0,R.useRef)(m);h.current=m,(0,R.useEffect)(()=>u(``),[e,n]);let g=c.flatMap(e=>e.attachment?[e.attachment]:[]),v=c.some(e=>e.state===`uploading`),y=t=>He(n,e,t,!0),x=(t,n=!1)=>u(o.add(e,t,r,n)??``);async function w(){try{let e=await navigator.clipboard.read(),t=[];for(let n of e){let e=n.types.find(e=>ze.split(`,`).includes(e));if(e){let r=await n.getType(e);t.push(new File([r],`剪贴板-${t.length+1}.${e.split(`/`)[1]}`,{type:e}))}}if(h.current!==m)return;t.length?x(t,!0):u(`剪贴板中没有可用的图片。`)}catch(e){h.current===m&&u(e instanceof DOMException&&e.name===`NotAllowedError`?`无法读取剪贴板,请在输入框中粘贴图片或选择图片文件。`:p(e))}}return{files:g,busy:v,count:c.length,failed:c.some(e=>e.state===`failed`),add:x,clear:()=>{for(let t of g)o.remove(e,t.id)},picker:(t,n)=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`input`,{ref:f,type:`file`,className:`session-image-file`,multiple:!0,"aria-label":`选择附件`,disabled:t,onChange:e=>{e.target.files&&x(e.target.files),e.target.value=``}}),n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`input`,{ref:d,type:`file`,className:`session-image-file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,"aria-label":`选择图片`,disabled:t,onChange:e=>{e.target.files&&x(e.target.files,!0),e.target.value=``}}),(0,z.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`添加图片`,title:`添加图片,也可粘贴或拖入`,disabled:t,onClick:()=>d.current?.click(),children:(0,z.jsx)(s,{name:`image`,size:`small`})})]}),(0,z.jsx)(b,{id:`session-attachments`,triggerId:`session-attachments-trigger`,label:`附件`,placement:`top`,className:`composer-menu composer-attachments`,routeKey:e,disabled:t,trigger:(0,z.jsx)(s,{name:`attachment`,size:`small`}),children:e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{e(),f.current?.click()},children:[(0,z.jsx)(s,{name:`attachment`,size:`small`}),`选择文件`]}),n&&typeof navigator.clipboard?.read==`function`&&(0,z.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{e(),w()},children:[(0,z.jsx)(s,{name:`paste`,size:`small`}),`粘贴图片`]})]})})]}),preview:t=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Ue,{images:c.map(e=>({id:e.id,name:e.name,mimeType:e.attachment?.mimeType??e.file?.type,url:e.attachment?y(e.id):e.preview??``,size:e.attachment?.size??e.file?.size??0,file:e.attachment?e.attachment.mimeType===`application/octet-stream`:!!e.file&&(e.file.size>5242880||!Be(e.file)),state:e.state,...e.error?{error:e.error}:{}})),disabled:t,remove:t=>{o.remove(e,t),r(`web/local-agent-sessions/${e}/attachments/${t}`,S(),{method:`DELETE`}).catch(()=>{})},retry:t=>void o.upload(e,t,r)}),(0,z.jsx)(_,{error:!0,children:l})]})}}var Ke={offered:{label:`待本地接收`,icon:`clock`},received:{label:`待本地接收`,icon:`clock`},queued:{label:`排队中`,icon:`clock`},dispatching:{label:`正在连接`,icon:`loading`,spinning:!0},running:{label:`执行中`,icon:`loading`,spinning:!0},cancelled:{label:`已撤回`,icon:`close`},interrupted:{label:`已停止`,icon:`stop`},failed:{label:`未能执行`,icon:`warning`},human_routed:{label:`未送达本地`,icon:`warning`},uncertain:{label:`需要核对`,icon:`warning`}};function qe({state:e,error:t}){let n=Ke[e];if(!n)return null;let r=t?`${n.label}:${t}`:n.label;return(0,z.jsx)(`span`,{className:`execution-status${n.spinning?` is-spinning`:``}`,role:`img`,"aria-label":r,title:r,children:(0,z.jsx)(s,{name:n.icon,size:`small`})})}function Je({message:e}){return!e.queue||e.queue.state===`running`?null:(0,z.jsx)(qe,{state:e.queue.state,error:e.queue.error})}function Ye(e,t,i,a){let[o,s]=(0,R.useState)(),c=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!t)return;let o=new AbortController,{signal:l}=o,u=`web/local-agent-sessions/${encodeURIComponent(t)}`,d=new URLSearchParams(location.search).get(`question`),f,m,h=!1,g=!1,_=Promise.resolve(),v=(e=``)=>{l.aborted||s({session:t,...f?{data:f}:{},error:e,loadingOlder:h})},y=e=>i(u+(Object.keys(e).length?`?`+new URLSearchParams(e):``),oe,{signal:l}),b=e=>(_=_.then(async()=>{if(!l.aborted)try{await e()}catch(e){e instanceof r&&[401,403,404].includes(e.status)&&(f=void 0),g=!0,v(p(e))}}),_),x=e=>b(async()=>{if(e!==void 0&&f&&f.cursor>=e&&!g)return;let t=m,n=await y(t===void 0?!f&&d?{question:d}:{}:{from:String(t)});l.aborted||(f&&!a(!1)&&S(!1),m!==t&&m!==void 0&&n.olderBefore!==null&&n.olderBefore>m&&(n=await y({from:String(m)})),!f&&d&&(m=n.olderBefore??1),f=n,g=!1,v())});function S(e){e&&!h?m=void 0:f&&m===void 0&&(m=f.olderBefore??1)}function C(){f?.olderBefore&&!h&&(S(!1),h=!0,v(),b(async()=>{try{if(!f?.olderBefore)return;let e=await y({before:String(f.olderBefore)}),t=e.olderBefore??1,n=e.cursor===f.cursor?{...f,messages:[...e.messages,...f.messages],olderBefore:e.olderBefore}:await y({from:String(t)});if(l.aborted)return;a(!0),m=t,f=n,g=!1}finally{h=!1,v()}}))}c.current={reload:()=>x(),older:C,follow:S,reveal:e=>b(async()=>{if(!f?.olderBefore||e>=f.olderBefore)return;let t=await y({from:String(e)});m=e,f=t,g=!1,v()})},x();let w=new EventSource(n(`/api/v1/projects/${encodeURIComponent(e)}/${u}/events?updates=1`)),T=e=>{document.hidden||x(Number(e.lastEventId))};w.addEventListener(`change`,T),w.addEventListener(`snapshot`,T);let E=setInterval(()=>{!document.hidden&&(g||w.readyState!==EventSource.OPEN)&&x()},15e3),D=()=>{document.hidden||x()};return document.addEventListener(`visibilitychange`,D),()=>{o.abort(),c.current=null,w.close(),clearInterval(E),document.removeEventListener(`visibilitychange`,D)}},[t,e,i,a]);let l=(0,R.useCallback)(()=>c.current?.reload()??Promise.resolve(),[]),u=(0,R.useCallback)(()=>c.current?.older(),[]),d=(0,R.useCallback)(e=>c.current?.follow(e),[]),f=(0,R.useCallback)(e=>c.current?.reveal(e)??Promise.resolve(),[]);return{...o?.session===t?o:void 0,reload:l,older:u,follow:d,reveal:f}}function H({message:t,images:n,status:r,rewind:i,onFile:a}){let o=i?.commands.find(e=>e.kind===`rewind`&&[`queued`,`running`,`uncertain`].includes(e.state)&&JSON.parse(e.argument).messageId===t.id),[c,l]=(0,R.useState)(!!o),[u,d]=(0,R.useState)(o?JSON.parse(o.argument).body:t.body),[f,h]=(0,R.useState)(!1),[g,v]=(0,R.useState)(``),[y,b]=(0,R.useState)(!1),[S,C]=(0,R.useState)(),w=(0,R.useRef)(void 0),T=ye(u);(0,R.useLayoutEffect)(()=>{c&&T.current&&(T.current.style.height=`0px`,T.current.style.height=`${T.current.scrollHeight}px`)},[c]);let E=i?.commands.find(e=>e.id===S?.id)??S??o,D=y||E&&[`queued`,`running`].includes(E.state),O=i?.available&&t.source===`web_session`&&t.id.startsWith(`input:`)&&(!t.queue||[`handled`,`interrupted`].includes(t.queue.state));async function k(){if(!i||D||!u.trim())return;let n=JSON.stringify({messageId:t.id,body:u.trim(),expectedLastMessage:i.expectedLastMessage});(E&&[`failed`,`uncertain`].includes(E.state)||w.current?.argument!==n)&&(w.current={id:e(),argument:n}),b(!0),v(``);try{let e=await i.request(`web/local-agent-sessions/${i.session}/commands`,P,{method:`POST`,body:{id:w.current.id,kind:`rewind`,argument:w.current.argument}});C(e),i.refresh()}catch(e){v(p(e))}finally{b(!1)}}return(0,z.jsxs)(`div`,{className:`computer-user-entry${c?` editing`:``}`,children:[(0,z.jsxs)(L,{mine:!0,author:`你`,time:t.createdAt,children:[n,c?(0,z.jsxs)(`form`,{className:`computer-message-edit`,onSubmit:e=>{e.preventDefault(),k()},children:[(0,z.jsx)(`textarea`,{ref:T,"aria-label":`编辑历史消息`,value:u,onChange:e=>d(e.target.value),disabled:!!D,autoFocus:!0,rows:1}),(0,z.jsxs)(`div`,{className:`computer-message-edit-footer`,children:[(0,z.jsx)(`small`,{children:`替换此后的对话,保留工作区文件`}),(0,z.jsx)(m,{icon:`close`,label:`取消编辑`,disabled:!!D,onClick:()=>{l(!1),v(``),d(t.body)}}),(0,z.jsx)(`button`,{type:`submit`,className:`message-send primary`,"aria-label":D?`正在回退`:`从此处继续`,title:D?`正在回退`:`从此处继续`,disabled:!!D||!u.trim(),children:(0,z.jsx)(s,{name:D?`loading`:`send`,size:`small`})})]}),(0,z.jsx)(_,{error:!0,children:g||(E&&[`failed`,`uncertain`].includes(E.state)?E.error:``)})]}):(0,z.jsx)(`div`,{className:`markdown`,children:(0,z.jsx)(I,{onFile:a,children:t.body})}),!c&&r]}),!c&&(0,z.jsxs)(`div`,{className:`computer-message-actions`,children:[(0,z.jsx)(m,{icon:f?`check`:`copy`,label:f?`已复制`:`复制消息`,onClick:()=>{x(t.body).then(()=>h(!0)).catch(e=>v(p(e)))}}),O&&(0,z.jsx)(m,{icon:`edit`,label:`编辑并从此处继续`,onClick:()=>{d(t.body),l(!0)}})]}),!c&&(0,z.jsx)(_,{error:!0,children:g})]})}function Xe({label:e,meta:t,children:n,className:r=``,onToggle:i}){return(0,z.jsxs)(`details`,{className:`tool-details ${r}`,onToggle:i,children:[(0,z.jsxs)(`summary`,{className:`tool-summary`,title:e,children:[(0,z.jsx)(s,{name:`chevron`,size:`small`}),(0,z.jsx)(`span`,{className:`tool-details-label`,children:e}),t&&(0,z.jsx)(`span`,{className:`tool-details-status`,children:t})]}),n]})}function U(e){if(e<1e3)return`不到 1 秒`;let t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return[r?`${r} 小时`:``,n%60?`${n%60} 分`:``,t%60?`${t%60} 秒`:``].filter(Boolean).join(` `)}function W({children:e}){return(0,z.jsx)(`div`,{className:`computer-divider`,children:(0,z.jsx)(`span`,{children:e})})}function Ze({message:e}){let t=e.state===`succeeded`?`已工作`:e.state===`interrupted`?`已停止`:e.state===`failed`?`执行失败`:`需要核对`;return(0,z.jsxs)(W,{children:[t,e.activity?.durationMs===void 0?``:` · ${U(e.activity.durationMs)}`]})}var Qe={offered:`待本地接收`,pending:`待投递`,human_routed:`未送达本地`,failed:`失败`,uncertain:`需要核对`};function $e(e){let t=[];for(let n of e)if(n.role===`assistant`&&n.activity?.kind===`tool`&&!n.question){let e=t.at(-1);Array.isArray(e)&&e[0].activity?.turnId===n.activity.turnId?e.push(n):t.push([n])}else t.push(n);return t}function G({text:e,onFile:t}){let n=[],r=0;if(t)for(let{start:i,end:a,link:o}of he(e))n.push(e.slice(r,i),(0,z.jsx)(`button`,{type:`button`,className:`computer-file-link`,onClick:()=>t(o),children:e.slice(i,a)},i)),r=a;return(0,z.jsxs)(`pre`,{children:[n,e.slice(r)]})}function K({call:e,onFile:t,visible:n,onOpen:r}){let[i,a]=(0,R.useState)(!1);return(0,z.jsx)(Xe,{className:`computer-tool`,onToggle:e=>{let t=e.currentTarget.open;a(t),r?.(t)},label:e.activity?.label??`工具调用`,meta:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(qe,{state:e.state}),e.activity?.durationMs!==void 0&&(0,z.jsx)(`span`,{children:U(e.activity.durationMs)})]}),children:i&&n&&(0,z.jsx)(G,{text:e.body,onFile:t})})}function q({calls:e,onFile:t}){let n=(0,R.useId)(),[r,i]=(0,R.useState)(!1),a=e.length>1,o=[`failed`,`uncertain`,`interrupted`].find(t=>e.some(e=>e.state===t));return(0,z.jsxs)(`div`,{className:a?`tool-details computer-tool-group`:void 0,children:[a&&(0,z.jsxs)(`button`,{type:`button`,className:`tool-summary`,"aria-expanded":r,"aria-controls":n,onClick:()=>i(!r),children:[(0,z.jsx)(s,{name:`chevron`,size:`small`}),e.length,` 次工具调用`,o&&(0,z.jsx)(qe,{state:o}),e.some(e=>e.state===`running`)&&(0,z.jsx)(qe,{state:`running`})]}),(0,z.jsx)(`div`,{id:n,className:a?`computer-tool-list`:void 0,hidden:a&&!r,children:e.map(e=>(0,z.jsx)(K,{call:e,onFile:t,visible:!a||r,onOpen:a?void 0:i},e.id))})]})}function et({messages:e,renderQuestion:t,imageUrl:n,renderQueue:r,rewind:i,onFile:a}){let o=new Map(e.filter(e=>e.activity?.kind===`turn`).map(e=>[e.activity.turnId,e])),s=new Map,c=new Set(e.flatMap(e=>{let t=e.question?.planSource;return t?[JSON.stringify([t.turnId,t.itemId])]:[]})),l=new Set(e.flatMap(e=>{let t=e.activity;return t?.kind===`commentary`&&c.has(JSON.stringify([t.turnId,t.itemId]))?[JSON.stringify([t.turnId,e.body])]:[]}));for(let t of e)t.activity?.kind===`answer`&&s.set(t.activity.turnId,t.id);let u=e.filter(({activity:e,body:t})=>e?.kind!==`commentary`||!c.has(JSON.stringify([e.turnId,e.itemId]))&&!l.has(JSON.stringify([e.turnId,t]))),d=(0,R.useRef)({keys:new Map,next:0}),f=new Map,p=new Set,m=d.current.next,h=$e(u);for(let e of h){if(!Array.isArray(e))continue;let t;for(let n of e){if(t=d.current.keys.get(n.id),t!==void 0&&!p.has(t))break;t=void 0}t??=m++,p.add(t);for(let n of e)f.set(n.id,t)}return(0,R.useLayoutEffect)(()=>{d.current={keys:f,next:m}}),(0,z.jsx)(`div`,{className:`computer-messages`,children:h.map(e=>{if(Array.isArray(e))return(0,z.jsx)(q,{calls:e,onFile:a},`tools:${f.get(e[0].id)}`);let c=e.activity;if(e.role===`system`)return(0,z.jsx)(W,{children:e.body},e.id);if(c?.kind===`turn`)return s.has(c.turnId)?null:(0,z.jsx)(Ze,{message:e},e.id);if(e.role===`user`)return(0,z.jsx)(H,{message:e,rewind:i,onFile:a,images:n&&(e.attachments??e.images)?.length?(0,z.jsx)(We,{images:e.attachments??e.images,url:t=>n(t,!!e.attachments)}):null,status:e.queue&&r?r(e):Qe[e.state]&&(0,z.jsx)(ge,{label:Qe[e.state],state:e.state})},e.id);let l=c?.kind===`answer`&&s.get(c.turnId)===e.id?o.get(c.turnId):void 0;return(0,z.jsxs)(R.Fragment,{children:[l&&(0,z.jsx)(Ze,{message:l}),(0,z.jsx)(`article`,{id:e.question?`computer-question-${e.question.id}`:void 0,tabIndex:e.question?-1:void 0,className:`computer-agent-message ${c?.kind===`commentary`?`computer-commentary`:``} ${e.question?`question-bubble`:``}`,children:e.question?t(e.question):(0,z.jsx)(`div`,{className:`markdown`,children:(0,z.jsx)(I,{onFile:a,children:e.body})})})]},e.id)})})}function J({disabled:e,onSend:t,initialValue:n=``,placeholder:r}){let[i,a]=(0,R.useState)(n),[o,c]=(0,R.useState)(!!n),l=`其他回答`,u=(0,R.useRef)(null),d=(0,R.useCallback)(e=>{if(!u.current)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.font=getComputedStyle(e).font;let n=Math.max(...(i||`${l}…`).split(`
|
|
8
|
+
`).map(e=>t.measureText(e).width));u.current.style.setProperty(`--reply-width`,`${Math.ceil(n+(o?52:26))}px`)},[i,o,l]),f=ye(i,d);return(0,z.jsxs)(`form`,{ref:u,className:`inline-reply${o?` active`:``}`,onFocus:()=>c(!0),onBlur:e=>{!i&&!e.currentTarget.contains(e.relatedTarget)&&c(!1)},onSubmit:n=>{n.preventDefault(),!e&&i.trim()&&t(i.trim()).then(e=>{e&&a(``)})},children:[(0,z.jsx)(`textarea`,{ref:f,rows:1,"aria-label":`自定义回答`,placeholder:r??`${l}…`,value:i,disabled:e,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),!e&&i.trim()&&t.currentTarget.form?.requestSubmit())}}),o&&(0,z.jsx)(`button`,{className:`inline-reply-send`,type:`submit`,disabled:e||!i.trim(),"aria-label":`发送${l}`,title:`发送${l}`,children:(0,z.jsx)(s,{name:`send`,size:`small`})})]})}function tt({question:t,session:n,request:r,refresh:i}){let[a,o]=(0,R.useState)({}),[l,u]=(0,R.useState)({}),[d,f]=(0,R.useState)(``),[m,h]=(0,R.useState)(!1),[g,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(``),C=(0,R.useRef)(null),w=(0,R.useRef)(!1),T=(0,R.useRef)(void 0);(0,R.useEffect)(()=>{if(t.state!==`pending`||w.current||!C.current)return;let e=!1,i=()=>{if(!e||document.visibilityState!==`visible`||!C.current)return;let i=C.current.getBoundingClientRect();i.bottom>0&&i.top<innerHeight&&r(`web/local-agent-sessions/${n}/questions/${t.id}/presented`,v({ok:c()}),{method:`POST`}).then(()=>{w.current=!0,window.dispatchEvent(new Event(`teammy:outbox`))}).catch(e=>f(p(e)))},a=new IntersectionObserver(t=>{e=t.some(e=>e.isIntersecting),i()});return a.observe(C.current),document.addEventListener(`visibilitychange`,i),()=>{a.disconnect(),document.removeEventListener(`visibilitychange`,i)}},[t.id,t.state,n,r]);async function E(a){let o=JSON.stringify(a);T.current?.fingerprint!==o&&(T.current={fingerprint:o,value:{...a,id:e()}}),h(!0),f(``);try{return await r(`web/local-agent-sessions/${n}/questions/${t.id}/answers`,S(),{method:`POST`,body:T.current.value}),T.current=void 0,i(),!0}catch(e){return f(p(e)),!1}finally{h(!1)}}let[D,O]=(0,R.useState)(Date.now);(0,R.useEffect)(()=>{if(!t.approval||t.state!==`pending`||t.autoApproveAt==null)return;O(Date.now());let e=setInterval(()=>O(Date.now()),1e3);return()=>clearInterval(e)},[t.approval,t.state,t.autoApproveAt]);let k=t.autoApprove!==!1&&t.autoApproveAt!=null?Math.max(0,Math.ceil((t.autoApproveAt-D)/1e3)):null,A=t.response,j=t.state===`answered`,M=[`expired`,`cancelled`].includes(t.state),ee=[`human_routed`,`failed`,`handled`].includes(t.submissionState??``)&&!j,N=pe(t),te=t.kind===`plan`,P=t.actions?.find(e=>e.id===A?.actionId),F=M?`已过期`:t.state===`uncertain`||t.submissionState===`uncertain`?`需核对`:j?te?P?.label??`已处理`:t.approval?A?.decision===!0?`已允许`:A?.decision===!1?`已拒绝`:`已处理`:P?P.label:A?``:`已回答`:ee?`请重新提交`:A?`正在提交`:``,ne=M||A?.decision===!1||ee?`close`:j?`check`:`clock`,re=t.questions.length>1||t.questions.some(e=>e.multiSelect),ie=(e=a)=>E({body:t.questions.length===1?e[t.questions[0].id]||(l[t.questions[0].id]??[]).join(`、`):JSON.stringify(e),...t.kind||t.questions.some(e=>e.multiSelect)?{answers:e}:{},...t.questions.some(e=>e.multiSelect)?{selections:l}:{}});if(t.delivery===`async`&&(j||M)){let e=j&&A?t.questions.flatMap(e=>[...A.selections?.[e.id]??[],A.answers[e.id]].filter(Boolean)):[];return e.length?(0,z.jsxs)(`div`,{className:`question-response native-async-answer`,children:[(0,z.jsx)(s,{name:`check`,size:`small`}),(0,z.jsx)(`span`,{children:e.join(`
|
|
9
|
+
`)})]}):null}return(0,z.jsxs)(`div`,{className:`native-question ${te?`native-plan`:``} ${N?`native-question-pending`:``}`,ref:C,children:[te?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`native-plan-heading`,children:[(0,z.jsx)(s,{name:`file`,size:`small`}),(0,z.jsx)(`span`,{children:`实施计划`})]}),N?(0,z.jsx)(`div`,{className:`native-plan-content markdown`,children:(0,z.jsx)(I,{children:t.plan??``})}):(0,z.jsxs)(`details`,{className:`native-plan-history markdown`,children:[(0,z.jsx)(`summary`,{children:`查看计划`}),(0,z.jsx)(I,{children:t.plan??``})]}),N&&(0,z.jsxs)(z.Fragment,{children:[!g&&(0,z.jsx)(`div`,{className:`question-actions native-plan-actions ${t.actions&&t.actions.length>3?`native-plan-actions-expanded`:``}`,children:t.actions?.map(e=>(0,z.jsx)(`button`,{type:`button`,disabled:m,title:e.description,className:e.id===`implement`?`primary`:``,onClick:()=>e.id===`revise`?y(!0):void E({body:e.label,actionId:e.id}),children:e.label},e.id))}),!g&&t.actions?.find(e=>e.id===`implement`)?.description&&(0,z.jsxs)(`small`,{className:`native-plan-note muted`,children:[`开始实施:`,t.actions.find(e=>e.id===`implement`).description]}),g&&(0,z.jsxs)(`form`,{className:`native-plan-feedback`,onSubmit:e=>{e.preventDefault(),E({body:b,actionId:`revise`})},children:[(0,z.jsxs)(`label`,{children:[`修改意见`,(0,z.jsx)(`textarea`,{autoFocus:!0,value:b,onChange:e=>x(e.target.value),placeholder:`说明希望调整的部分,Agent 将修改后再次请求确认`})]}),(0,z.jsxs)(`div`,{className:`question-actions native-plan-feedback-actions`,children:[(0,z.jsx)(`button`,{className:`primary`,disabled:m||!b.trim(),children:`提交修改意见`}),(0,z.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>y(!1),children:`返回计划`})]})]})]}),!N&&A?.actionId===`revise`&&A.answers.feedback&&(0,z.jsx)(`div`,{className:`question-response`,children:A.answers.feedback})]}):t.approval?(0,z.jsxs)(`div`,{className:`native-approval-row`,children:[(0,z.jsx)(Xe,{className:`native-approval-details`,label:t.questions.map(e=>e.text.split(`
|
|
10
|
+
`).filter(Boolean).slice(0,2).join(` · `)).join(` · `),children:(0,z.jsx)(`pre`,{children:t.questions.map(e=>e.text).join(`
|
|
11
|
+
|
|
12
|
+
`)})}),N?(0,z.jsxs)(`div`,{className:`native-approval-options`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`primary`,disabled:m,"aria-label":`允许`,title:k===null?void 0:`倒计时结束后自动允许本次操作`,onClick:()=>void E({body:`允许`,decision:!0}),children:[`允许`,k!==null&&(0,z.jsxs)(`span`,{"aria-hidden":`true`,children:[`(`,k,`s)`]})]}),(0,z.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>void E({body:`拒绝`,decision:!1}),children:`拒绝`})]}):F&&(0,z.jsxs)(`small`,{className:`question-result`,children:[(0,z.jsx)(s,{name:ne,size:`small`}),F]})]}):(0,z.jsxs)(z.Fragment,{children:[t.questions.map(e=>(0,z.jsxs)(`div`,{className:`native-question-part`,children:[(0,z.jsx)(`p`,{children:e.text}),N&&(0,z.jsx)(`div`,{className:`question-options ${Object.values(e.descriptions??{}).some(Boolean)?`question-options-described`:``}`,children:e.options.map(t=>(0,z.jsxs)(`button`,{type:`button`,disabled:m,"aria-pressed":e.multiSelect?l[e.id]?.includes(t)??!1:a[e.id]===t,onClick:()=>{if(e.multiSelect){u(n=>({...n,[e.id]:n[e.id]?.includes(t)?n[e.id].filter(e=>e!==t):[...n[e.id]??[],t]}));return}let n={...a,[e.id]:t};o(n),re||ie(n)},children:[(0,z.jsxs)(`span`,{className:`question-option-label`,children:[e.multiSelect&&(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`question-check`,children:l[e.id]?.includes(t)&&(0,z.jsx)(s,{name:`check`,size:`small`})}),t]}),e.descriptions?.[t]&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`question-option-separator`,"aria-hidden":`true`,children:`|`}),(0,z.jsx)(`span`,{className:`question-option-description`,title:e.descriptions[t],children:e.descriptions[t]})]})]},t))}),e.freeText&&N&&(0,z.jsx)(J,{initialValue:e.initialValue,placeholder:e.placeholder,disabled:m,onSend:async t=>{let n={...a,[e.id]:t};return o(n),re?!0:ie(n)}}),N&&re&&a[e.id]&&!e.options.includes(a[e.id])&&(0,z.jsx)(`small`,{children:a[e.id]}),!N&&!t.approval&&(A?.answers[e.id]||A?.selections?.[e.id]?.length)&&(0,z.jsxs)(`div`,{className:`question-response`,children:[(0,z.jsx)(s,{name:j?`check`:`clock`,size:`small`}),(0,z.jsx)(`span`,{children:[...A.selections?.[e.id]??[],A.answers[e.id]].filter(Boolean).join(`、`)})]})]},e.id)),N&&t.actions?.length&&(0,z.jsx)(`div`,{className:`question-actions`,children:t.actions.map(e=>(0,z.jsx)(`button`,{disabled:m,onClick:()=>void E({body:e.label,actionId:e.id}),children:e.label},e.id))}),N&&re&&(0,z.jsx)(`div`,{className:`question-actions`,children:(0,z.jsx)(`button`,{disabled:m||t.questions.some(e=>!a[e.id]?.trim()&&!l[e.id]?.length),onClick:()=>void ie(),children:`回答`})})]}),F&&(!t.approval||te)&&(0,z.jsxs)(`small`,{className:`question-result`,children:[(0,z.jsx)(s,{name:ne,size:`small`}),F]}),(0,z.jsx)(_,{error:!0,children:d})]})}function nt({session:t,active:n,commands:r,request:i,refresh:a,onError:o}){let[c,l]=(0,R.useState)(!1),[u,d]=(0,R.useState)(),f=(0,R.useRef)(void 0),m=r.find(e=>e.id===u?.id)??u,h=c||m&&[`queued`,`running`].includes(m.state)||r.some(e=>e.kind===`stop`&&[`queued`,`running`].includes(e.state));if(!n&&!h)return null;async function g(){if(!h){f.current??=e(),l(!0),o(``);try{let e=await i(`web/local-agent-sessions/${t}/commands`,P,{method:`POST`,body:{id:f.current,kind:`stop`}});d(e),f.current=void 0,a()}catch(e){o(p(e))}finally{l(!1)}}}return(0,z.jsxs)(`button`,{type:`button`,className:`message-stop`,"aria-label":h?`正在停止`:`停止当前轮`,title:h?`正在停止`:`停止当前轮`,disabled:!!h,onClick:()=>void g(),children:[(0,z.jsx)(`span`,{className:`message-stop-ring`,"aria-hidden":`true`}),(0,z.jsx)(s,{name:`stop`,size:`small`})]})}var Y={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`,ultra:`极致`,none:`无`,off:`关闭`};function X({id:e,label:t,current:n,options:r,disabled:i,onSelect:a}){let o=r.find(e=>e.value===n);return(0,z.jsx)(b,{id:`${e}-menu`,triggerId:e,placement:`top`,className:`composer-menu composer-choice`,label:`选择${t}`,disabled:i,routeKey:n,trigger:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{title:`${t}:${o?.label??n}`,children:o?.shortLabel??o?.label??n}),(0,z.jsx)(s,{name:`chevronDown`,size:`small`})]}),children:e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`composer-menu-heading`,children:t}),r.map(t=>(0,z.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":t.label,onClick:()=>{e(),a(t.value)},children:[(0,z.jsxs)(`span`,{className:`composer-option-copy`,children:[(0,z.jsx)(`span`,{children:t.label}),t.description&&(0,z.jsx)(`small`,{children:t.description})]}),t.value===n&&(0,z.jsx)(s,{name:`check`,size:`small`})]},t.value))]})})}function rt({session:e,models:t,busy:n,available:r,online:i,commands:a,controls:o,draft:c,onInsert:l,onConfig:u}){let[d,f]=(0,R.useState)(!1);(0,R.useEffect)(()=>{/^[/$]([^\s]*)$/.exec(c)?f(!0):f(!1)},[c]);let p=e.config.model??e.effectiveConfig?.model,m=t.find(e=>e.id===p||e.resolvedModel===p)??(e.config.model?void 0:t.find(e=>e.isDefault)),h=n||!r,g=e.provider===`claude`,_=e.provider===`cursor`,v=e.provider===`pi`,y=o??A(e.provider),x=m?.effortLabel??`思考强度`,S=e=>m?.effortLabel?e:Y[e]??e,C=e.appliedRevision===e.revision?e.effectiveConfig?.mode:void 0,w=t.find(e=>e.isDefault)?.id??(e.config.model?null:e.effectiveConfig?.model),T=t.find(e=>e.id===w)?.name??w,E=e=>g?e.replace(/^Claude\s+/,``):e,D=[{value:``,label:T?`默认 · ${T}`:t.length?`默认模型`:`模型未获取`,shortLabel:T?E(T):t.length?`默认模型`:`模型`},...t.map(e=>({value:e.id,label:e.name,shortLabel:E(e.name)}))];e.config.model&&!t.some(t=>t.id===e.config.model)&&D.push({value:e.config.model,label:e.config.model,shortLabel:E(e.config.model)});let O=m?.id===e.effectiveConfig?.model?e.effectiveConfig?.effort:m?.defaultEffort,k=[{value:``,label:O?`默认 · ${S(O)}`:`默认${x}`,shortLabel:O?S(O):m?.effortLabel??`强度`},...(m?.efforts??[]).map(e=>({value:e,label:S(e)}))];return e.config.effort&&!k.some(t=>t.value===e.config.effort)&&k.push({value:e.config.effort,label:S(e.config.effort)}),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(b,{id:`session-commands`,triggerId:`session-command-trigger`,label:`命令与 Skills`,placement:`top`,className:`composer-menu composer-commands`,routeKey:e.id,trigger:(0,z.jsx)(s,{name:`command`,size:`small`}),open:d,onOpenChange:f,focusFirst:!1,disabled:h||!i,children:e=>(0,z.jsxs)(z.Fragment,{children:[[...a].sort((e,t)=>e.name.localeCompare(t.name,`en`)).map(t=>(0,z.jsx)(`button`,{type:`button`,role:`menuitem`,title:[t.description,t.path].filter(Boolean).join(`
|
|
13
|
+
`),onClick:()=>{e(),l(t)},children:(0,z.jsxs)(`span`,{className:`composer-command-row`,children:[(0,z.jsxs)(`span`,{className:`composer-command-name`,children:[t.prefix??(t.kind===`skill`?`$`:`/`),t.name]}),(0,z.jsx)(`small`,{children:t.description})]})},`${t.kind}:${t.path??t.name}`)),!a.length&&(0,z.jsx)(`div`,{className:`composer-menu-heading`,children:`尚未获取命令`})]})}),(0,z.jsx)(X,{id:`session-model`,label:`模型`,current:e.config.model??``,options:D,disabled:h,onSelect:n=>{let r=t.find(e=>e.id===n);u({...e.config,model:n||null,..._?{options:{}}:{},effort:e.config.effort&&r?.efforts.includes(e.config.effort)?e.config.effort:null})}}),(!_&&!v&&e.provider!==`opencode`||(m?.efforts.length??0)>0||!!e.config.effort)&&(0,z.jsx)(X,{id:`session-effort`,label:x,current:e.config.effort??``,options:k,disabled:h,onSelect:t=>u({...e.config,effort:t||null})}),m?.options?.map(t=>(0,z.jsx)(X,{id:`session-option-${t.id}`,label:t.name,current:e.config.options?.[t.id]??``,options:[{value:``,label:`默认 · ${t.choices.find(e=>e.value===t.defaultValue)?.label??t.defaultValue}`},...t.choices],disabled:h,onSelect:n=>{let r={...e.config.options};n?r[t.id]=n:delete r[t.id],u({...e.config,options:r})}},t.id)),y.map(t=>(0,z.jsx)(X,{id:t.key===`mode`&&!g?`session-mode`:`session-permission`,label:t.label,current:t.key===`mode`?C??e.config.mode??t.defaultValue:e.config.permission,options:t.choices,disabled:h,onSelect:n=>u(t.key===`mode`?{...e.config,mode:n||void 0}:{...e.config,permission:n})},t.key))]})}var it=(0,R.lazy)(()=>ce(()=>import(`./TerminalPane-ZhM38vie.js`),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url)),at=v({ok:c()}),ot={idle:`空闲`,working:`工作中`,waiting:`等待回答`,queued:`等待执行`,uncertain:`需要核对`,human:`人工处理`,offered:`待本地接收`,accepted:`本地已接手`,human_routed:`未送达本地`,pending:`待投递`,sent:`已发送`,succeeded:`已完成`,running:`进行中`,failed:`失败`};function st(e){return{width:e.clientWidth,height:e.clientHeight,top:e.scrollHeight-e.clientHeight}}function Z({navigate:e,memberId:t}){let{request:n,projectId:r}=me(),i=(0,R.useCallback)(e=>n(`web/local-agent-settings`,N,{signal:e}),[n]),a=w(i,3e4);return(0,R.useEffect)(()=>{let e=()=>void a.reload();return window.addEventListener(`teammy:local-access`,e),()=>window.removeEventListener(`teammy:local-access`,e)},[a.reload]),a.error?(0,z.jsx)(_,{error:!0,children:a.error}):a.data?(0,z.jsx)(Q,{localAvailable:a.data.accessible,navigate:e,memberId:t},`${r}/${t}`):null}function Q({localAvailable:r,navigate:i,memberId:a}){let o=me(),c=C(),u=t(o.projectId,a,`computer-selection`),d=t(o.projectId,a,`computer-drafts`),f=c?.get(u),[h,g]=(0,R.useState)(()=>new Set),[v,y]=(0,R.useState)(()=>({project:o.projectId,directory:new URLSearchParams(location.search).get(`directory`)??f?.directory??``,session:new URLSearchParams(location.search).get(`session`)??(new URLSearchParams(location.search).has(`terminal`)?``:f?.session??``),terminal:new URLSearchParams(location.search).get(`terminal`)??(new URLSearchParams(location.search).has(`session`)?``:f?.terminal??``)})),[x,E]=(0,R.useState)(``),[A,M]=(0,R.useState)(!1),[N,P]=(0,R.useState)(!1),[F,ae]=(0,R.useState)(()=>c?.get(d)??{}),oe=F[v.session]??``,ce=e=>ae(t=>({...t,[v.session]:typeof e==`function`?e(t[v.session]??``):e}));(0,R.useEffect)(()=>{c?.set(d,F)},[c,d,F]);let[de,fe]=(0,R.useState)(``),[he,I]=(0,R.useState)(!1),[L,ye]=(0,R.useState)(`codex`),[xe,we]=(0,R.useState)(!1),[B,Te]=(0,R.useState)(``),[Ee,Oe]=(0,R.useState)(),[ke,Ae]=(0,R.useState)(Date.now);(0,R.useEffect)(()=>{let e=setInterval(()=>Ae(Date.now()),6e4);return()=>clearInterval(e)},[]);let Me=(0,R.useRef)(null),V=(0,R.useRef)(!0),Fe=(0,R.useRef)(null),Ie=(0,R.useCallback)(e=>{let t=st(e),n=Fe.current,r=n&&(t.width!==n.width||t.height!==n.height);return(V.current&&r?Math.min(n.top,t.top):t.top)-e.scrollTop<96},[]),Re=(0,R.useCallback)(e=>{e.scrollTop=e.scrollHeight,Fe.current=st(e)},[]),ze=(0,R.useRef)(null),Be=(0,R.useCallback)(e=>{let t=Me.current;if(!t)return!0;if(Ie(t)||(V.current=!1),!e||V.current)return V.current;let n=t.getBoundingClientRect().top,r=Array.from(t.querySelectorAll(`.computer-messages > :not(.computer-tool-group), .computer-tool-group > .tool-summary, .computer-tool-group .computer-tool`)).find(e=>{let t=e.getBoundingClientRect();return t.height>0&&t.bottom>n});return ze.current={...r?{node:r}:{},offset:r?.getBoundingClientRect().top??0,top:t.scrollTop,height:t.scrollHeight},!1},[Ie]),Ve=(0,R.useRef)(new URLSearchParams(location.search).get(`question`)),Ue=(0,R.useRef)(null),We=(0,R.useRef)(void 0),Ke=(0,R.useRef)(e()),qe=(0,R.useCallback)(async e=>r?(await o.request(`web/local-agent-computers`,re,{signal:e})).computers.map(e=>({...e,project:o.projectId})):[],[o,r]),H=w(qe,3e3),Xe=(H.data??[]).flatMap(e=>e.directories.map(t=>({c:e,d:t,label:le(H.data??[],e,t)}))).sort((e,t)=>e.label.localeCompare(t.label)),U=H.data?.find(e=>e.project===v.project&&e.directories.some(e=>e.id===v.directory)),W=De(o.projectId,r),Ze=W.terminals.find(e=>e.id===v.terminal),Qe=(0,R.useRef)(Ze);Ze&&(Qe.current=Ze);let $e=Ze??(Qe.current?.id===v.terminal?Qe.current:void 0),G=U?.directories.find(e=>e.id===v.directory),K=H.data?.find(e=>e.directories.some(e=>e.id===B))??U,q=K?.directories.find(e=>e.id===B)??G;k(v.project);let J=(0,R.useCallback)((e,t,n)=>k(v.project).request(e,t,n),[v.project]),Y=Ge(v.session,v.project,J),X=Ye(v.project,r?v.session:``,J,Be),Z=X.data;(0,R.useLayoutEffect)(()=>{V.current=!0,Fe.current=null,Ue.current=null,ze.current=null},[v.project,v.session]);let Q=Z?.session,ct=Z?.pendingQuestions??Z?.messages.flatMap(({question:e,seq:t})=>e?.delivery===`async`&&pe(e)?[{id:e.id,seq:t}]:[])??[];function lt(e){let t=Me.current,n=document.getElementById(`computer-question-${e}`);return!t||!n||!t.contains(n)||!n.getClientRects().length?!1:(V.current=!1,Ue.current=e,t.scrollTop+=n.getBoundingClientRect().top-t.getBoundingClientRect().top-16,n.focus({preventScroll:!0}),!0)}(0,R.useLayoutEffect)(()=>{if(!Q||!Me.current)return;let e=Me.current;if(Ve.current){let e=Ve.current;if(lt(e)){Ve.current=null,ze.current=null;return}}let t=ze.current;ze.current=null,t&&!V.current?t.node&&e.contains(t.node)?e.scrollTop+=t.node.getBoundingClientRect().top-t.offset:e.scrollTop=t.top+e.scrollHeight-t.height:V.current&&Re(e)},[Q?.id,G?.id,Z,Re]),(0,R.useLayoutEffect)(()=>{let e=Me.current;if(!e||!Q)return;let t=new ResizeObserver(()=>{V.current&&Ie(e)&&Re(e)});return t.observe(e),()=>t.disconnect()},[Q?.id,G?.id,Ie,Re]),(0,R.useEffect)(()=>{U?.online===!1&&X.reload()},[U?.online,X.reload]);let ut=(0,R.useRef)(Z?.messages);(0,R.useLayoutEffect)(()=>{ut.current=Z?.messages},[Z?.messages]);let dt=(0,R.useCallback)(({path:e,line:t})=>{let r=e.split(`/`).at(-1),i=/\/\.workspace\/\.teammy-attachments\/([0-9a-f-]{36})\/[^/]+$/i.exec(e);if(!v.terminal&&Q&&i){let e=ut.current?.flatMap(e=>e.attachments??[]).find(e=>e.id===i[1]);Oe({...e,name:e?.name??r,line:t,url:He(v.project,Q.id,i[1],!0)});return}let a=v.terminal?$e?.directory:Q?.executionDirectory??Q?.directory;if(!a)return;let o=n(`/api/v1/projects/${encodeURIComponent(v.project)}/web/local-agents/${encodeURIComponent(a)}/file?${new URLSearchParams({path:e})}`),s=Pe(r);Oe({name:r,line:t,url:o,previewUrl:o+(s.startsWith(`text/`)?`&view=text`:s?``:`&view=info`)})},[v.project,v.terminal,Q?.directory,Q?.executionDirectory,Q?.id,$e?.directory]),ft=U?.capabilities.includes(`local-sessions-v1`),$=(e,t,n=``,r=``)=>{Oe(void 0),y({project:e,directory:t,session:n,terminal:r}),c?.set(u,{directory:t,session:n,terminal:r}),I(!1),we(!1),E(``);let i=new URL(location.href);(v.session!==n||r)&&(i.searchParams.delete(`question`),Ve.current=null),i.searchParams.delete(`view`),i.searchParams.delete(`section`),i.searchParams.set(`directory`,t),r?i.searchParams.set(`terminal`,r):i.searchParams.delete(`terminal`),n?i.searchParams.set(`session`,n):i.searchParams.delete(`session`),e===o.projectId&&history.replaceState(null,``,i)};(0,R.useEffect)(()=>{let e=H.data?.find(e=>e.sessions.some(e=>e.id===v.session))??H.data?.find(e=>e.directories.length);if(!v.directory&&e?.directories.length){let t=e.directories[0],n=e.sessions.find(e=>e.id===v.session);$(e.project,n?.directory??t.id,n?.id??t.defaultSession??e.sessions.find(e=>e.directory===t.id)?.id)}},[H.data]),(0,R.useEffect)(()=>{if(!Q)return;let e=()=>{document.visibilityState===`visible`&&J(`web/local-agent-sessions/${Q.id}/read`,at,{method:`POST`}).catch(e=>E(p(e)))};return e(),document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Q?.id,Z?.messages.at(-1)?.seq,J]);async function pt(e){M(!0),E(``);try{await e(),await Promise.all([X.reload(),H.reload()])}catch(e){E(p(e))}finally{M(!1)}}function mt(e,t){return pt(async()=>{if(await o.request(`web/local-agent-sessions/${e.id}/metadata`,ie,{method:`PUT`,body:{expectedRevision:e.metadataRevision,...t}}),t.hidden&&v.session===e.id){let t=U?.sessions.find(t=>t.directory===e.directory&&t.id!==e.id&&!t.hidden);$(v.project,e.directory,t?.id)}})}function ht(e){let t=new URLSearchParams({tab:`connect`,directory:e,session:v.session});i(`/projects/${o.projectId}/settings?${t}`)}function gt(t=v.directory){let n=H.data?.find(e=>e.directories.some(e=>e.id===t))??U,r=n?.directories.find(e=>e.id===t)??n?.directories[0];!r||!n?P(!0):(Ke.current=e(),Te(r.id),I(!0),ye(r.provider),E(``))}let[_t,vt]=(0,R.useState)(null);(0,R.useEffect)(()=>vt(null),[Q?.id]);let yt=U?.catalogs.find(e=>e.provider===(Q?.provider??`codex`)&&(Q?.cwd?e.cwd===Q.cwd:e.directory===(Q?.executionDirectory??Q?.directory))),bt=yt?.commands??[],xt=yt?.models??U?.providers.find(e=>e.id===Q?.provider)?.models??(Q?.provider===`codex`?U?.models??[]:[]),St=xt.find(e=>e.id===(Q?.config.model??Q?.effectiveConfig?.model)||!!e.resolvedModel&&e.resolvedModel===(Q?.config.model??Q?.effectiveConfig?.model))??(Q?.config.model?void 0:xt.find(e=>e.isDefault)),Ct=!!U?.capabilities.includes(`local-agent-attachments-v1`),wt=!!St?.images&&!!U?.capabilities.includes(`local-agent-images-v1`),Tt=Q?.state===`working`&&!Z?.commands.some(e=>e.kind===`stop`&&[`queued`,`running`].includes(e.state)),Et=Q?.provider===`cursor`&&U?.capabilities.includes(`local-agent-steer-v1`),Dt=!U?.capabilities.includes(`local-agent-steer-v1`)&&(Q?.provider===`cursor`||Q?.provider===`claude`);function Ot(t){let n=oe.trim();if(!Q||!n&&!Y.files.length)return;let r=Y.files.map(e=>e.id),i=wt?Y.files.filter(e=>e.mimeType!==`application/octet-stream`).map(e=>e.id):[],a=_t?.path&&n.startsWith(`$${_t.name}`)?[{name:_t.name,path:_t.path}]:void 0,o=JSON.stringify({session:Q.id,body:n,skills:a,attachments:r,images:i,delivery:t});We.current?.fingerprint!==o&&(We.current={fingerprint:o,id:e()});let s=We.current;pt(async()=>{await J(`web/local-agent-sessions/${Q.id}/messages`,S(),{method:`POST`,body:{id:s.id,body:n,delivery:t,...i.length?{images:i}:{},...r.length?{attachments:r}:{},...a?{skills:a}:{}}}),ce(e=>e.trim()===n?``:e),vt(null),Y.clear(),We.current===s&&(We.current=void 0)})}let kt=(0,R.useMemo)(()=>(0,z.jsx)(et,{onFile:dt,messages:Q?Z.messages:[],rewind:Q?{session:Q.id,available:!!Z?.canRewind&&Q.state===`idle`&&!Q.archived,expectedLastMessage:Z?.messages.at(-1)?.id??``,commands:Z?.commands??[],request:J,refresh:X.reload}:void 0,imageUrl:(e,t)=>He(v.project,Q.id,e,t),renderQueue:e=>(0,z.jsx)(Je,{message:e}),renderQuestion:e=>(0,z.jsx)(tt,{question:e,session:Q.id,request:J,refresh:X.reload})}),[Q,Z,J,X.reload,v.project,dt]);return(0,z.jsxs)(ve,{className:`computers-layout`,testId:`computers-page`,label:`本地会话`,tree:!0,navigation:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(O,{title:`电脑`}),(0,z.jsx)(`div`,{className:`assistant-message-scroll computer-tree`,role:`tree`,"aria-label":`目录与会话`,onKeyDown:Se,children:Xe.map(({c:e,d:t,label:n})=>{let r=`${e.project}/${t.id}`,i=!h.has(r);return(0,z.jsxs)(`div`,{role:`none`,children:[(0,z.jsxs)(`div`,{className:`computer-tree-row`,role:`none`,children:[(0,z.jsxs)(D,{className:`tree-item tree-folder`,role:`treeitem`,"aria-level":1,"aria-expanded":i,style:{"--tree-level":1},leading:(0,z.jsx)(`span`,{className:`tree-chevron ${i?`expanded`:``}`,children:(0,z.jsx)(s,{name:`chevron`,size:`small`})}),onClick:()=>{v.directory!==t.id&&$(e.project,t.id,t.defaultSession??e.sessions.find(e=>e.directory===t.id)?.id),g(e=>{let t=new Set(e);return i?t.add(r):t.delete(r),t})},children:[(0,z.jsx)(s,{name:`files`}),(0,z.jsx)(`span`,{className:`tree-name`,title:n,children:n})]}),(0,z.jsx)(m,{icon:`plus`,label:`新建会话:${n}`,className:`computer-tree-action`,onClick:()=>gt(t.id)})]}),i&&(0,z.jsxs)(`div`,{role:`group`,children:[W.terminals.filter(e=>e.directory===t.id).map(n=>(0,z.jsx)(`div`,{className:`computer-tree-row computer-session-row computer-terminal-row`,role:`none`,children:(0,z.jsxs)(D,{className:`tree-item`,role:`treeitem`,"aria-level":2,"aria-selected":v.terminal===n.id,style:{"--tree-level":2},leading:(0,z.jsx)(`span`,{className:`tree-chevron`}),onClick:()=>$(e.project,t.id,``,n.id),children:[(0,z.jsx)(s,{name:`command`}),(0,z.jsxs)(`span`,{className:`computer-session-copy`,children:[(0,z.jsx)(`span`,{className:`tree-name`,children:n.title}),(0,z.jsx)(`time`,{dateTime:n.createdAt,children:n.state===`exited`?`已退出`:je(n.createdAt,ke)})]})]})},n.id)),e.sessions.filter(e=>e.directory===t.id).map(n=>(0,z.jsxs)(`div`,{className:`computer-tree-row computer-session-row`,role:`none`,children:[(0,z.jsxs)(D,{className:`tree-item`,role:`treeitem`,"aria-level":2,"aria-selected":v.session===n.id&&v.project===e.project,style:{"--tree-level":2},leading:(0,z.jsx)(`span`,{className:`tree-chevron`,children:(0,z.jsx)(`span`,{className:`assistant-message-dot ${n.unread?`unread`:``}`})}),title:`${n.title} · ${ue[n.provider]}`,onClick:()=>$(e.project,t.id,n.id),children:[(0,z.jsx)(ee,{provider:n.provider}),(0,z.jsxs)(`span`,{className:`computer-session-copy`,children:[(0,z.jsx)(`span`,{className:`tree-name`,children:n.title}),(0,z.jsx)(`time`,{dateTime:n.updatedAt,title:new Date(n.updatedAt).toLocaleString(),children:je(n.updatedAt,ke)})]})]}),(0,z.jsx)(m,{icon:`link`,className:`computer-tree-action computer-session-pin${n.pinned?` pinned`:``}`,label:`${n.pinned?`取消自动接单`:`开启自动接单`}:${n.title}`,"aria-pressed":n.pinned,tooltip:n.pinned?`取消自动接单`:`开启自动接单`,disabled:A||n.archived,onClick:()=>void mt(n,{pinned:!n.pinned})}),n.archived?(0,z.jsx)(`span`,{title:`已归档`,role:`img`,"aria-label":`已归档`,children:(0,z.jsx)(s,{name:`archive`,size:`small`})}):n.state!==`idle`&&(0,z.jsx)(ge,{state:n.state,label:ot[n.state]??n.state})]},n.id))]})]},t.id)})}),(0,z.jsx)(_,{error:!0,children:H.error})]}),children:[N&&(0,z.jsx)(j,{onClose:()=>P(!1)}),xe&&K&&q&&(0,z.jsx)(Ne,{directory:q.id,provider:q.provider,providers:K.providers.map(e=>e.id),sessions:K.sessions,request:J,onClose:()=>we(!1),onImport:e=>{$(v.project,e.directory,e.id),H.reload()}}),he&&q&&(0,z.jsx)(l,{id:`computer-new-session`,title:`新建会话`,onClose:()=>I(!1),children:(0,z.jsxs)(`form`,{className:`computer-panel stack`,onSubmit:t=>{t.preventDefault(),pt(async()=>{if(L===`terminal`){let t=Ke.current;await W.request({type:`create`,id:t,directory:q.id,title:de.trim(),cols:100,rows:28}),Ke.current=e(),fe(``),$(v.project,q.id,``,t);return}let t=await J(`web/local-agents/${q.id}/sessions`,ie,{method:`POST`,body:{id:Ke.current,title:de,provider:L}});Ke.current=e(),I(!1),fe(``),$(v.project,q.id,t.id)})},children:[Xe.length>1?(0,z.jsx)(T,{title:`执行目录`,children:(0,z.jsx)(`select`,{"aria-label":`执行目录`,disabled:A,value:q.id,onChange:e=>{Te(e.target.value),ye(Xe.find(({d:t})=>t.id===e.target.value)?.d.provider??`codex`)},children:Xe.map(({d:e,label:t})=>(0,z.jsx)(`option`,{value:e.id,children:t},e.id))})}):(0,z.jsxs)(`p`,{className:`muted computer-create-scope`,children:[`目录:`,q.name]}),(0,z.jsxs)(`label`,{children:[`会话名称`,(0,z.jsx)(`input`,{autoFocus:!0,required:!0,disabled:A,placeholder:`会话名称`,value:de,onChange:e=>fe(e.target.value)})]}),(0,z.jsx)(se,{label:`会话类型`,value:L,onChange:ye,disabled:A,providers:te.options.filter(e=>e===`codex`||(e===`claude`?K?.capabilities.includes(`local-agent-providers-v1`):K?.providers.some(t=>t.id===e))),terminal:W.directories.includes(q.id)}),L===`terminal`&&(0,z.jsx)(`p`,{className:`muted computer-create-scope`,children:`在此目录启动本机 Shell,使用本机用户权限。`}),K?.providers.find(e=>e.id===L)?.error&&(0,z.jsx)(_,{children:K.providers.find(e=>e.id===L).error}),(0,z.jsx)(_,{error:!0,children:x}),(0,z.jsxs)(`div`,{className:`computer-create-options`,children:[L!==`terminal`&&(0,z.jsx)(`button`,{type:`button`,disabled:!K?.online||!K.capabilities.includes(`local-agent-history-v1`),onClick:()=>{I(!1),we(!0)},children:`导入历史会话`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{I(!1),P(!0)},children:`接入目录`}),(0,z.jsx)(`button`,{className:`primary`,disabled:A||!de.trim()||(L===`terminal`?!W.directories.includes(q.id):!ft),children:`创建`})]})]})}),Ee&&(0,z.jsx)(Le,{file:Ee,onClose:()=>Oe(void 0)},Ee.url),v.terminal?$e?(0,z.jsx)(R.Suspense,{fallback:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ne,{title:$e.title}),(0,z.jsx)(`div`,{className:`assistant-empty`,children:`正在打开终端…`})]}),children:(0,z.jsx)(it,{terminal:$e,onFile:dt,connection:W,onClosed:()=>$(v.project,v.directory)},$e.id)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ne,{title:`终端`}),(0,z.jsx)(`div`,{className:`assistant-empty`,children:W.connected?`终端已结束或电脑已重启,请新建终端。`:`正在连接终端…`})]}):G?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ne,{title:Q?(0,z.jsx)(Ce,{title:Q.title,busy:A,onSave:e=>mt(Q,{title:e})},Q.id):(0,z.jsx)(`h2`,{children:G.name}),actions:(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(b,{id:`computer-session-menu`,triggerId:`computer-session-actions`,label:`会话操作`,trigger:(0,z.jsx)(s,{name:`more`}),className:`computer-create-menu`,routeKey:Q?.id??``,disabled:!Q,children:e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{role:`menuitem`,disabled:A,onClick:()=>{e(),Q&&mt(Q,{hidden:!0})},children:`隐藏会话`}),(0,z.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),ht(G.id)},children:`连接专用群`}),(0,z.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),ht(G.id)},children:`执行位置`})]})})})}),!ft&&(0,z.jsx)(_,{children:`升级客户端后可使用多个会话和网页对话。`}),(0,z.jsxs)(_e,{ref:Me,onWheel:e=>{e.deltaY<0&&e.currentTarget.scrollTop<=0&&Z?.olderBefore&&(V.current=!1,X.older())},onScroll:e=>{let t=e.currentTarget,n=Ie(t);n&&!V.current&&(Fe.current=st(t)),V.current=n,X.follow(V.current),!V.current&&t.scrollTop<100&&Z?.olderBefore&&X.older()},"aria-label":`本地会话记录`,children:[Z?.olderBefore&&(0,z.jsx)(`button`,{type:`button`,className:`computer-older`,disabled:X.loadingOlder,onClick:()=>{V.current=!1,X.older()},children:X.loadingOlder?`正在加载…`:`加载更早消息`}),kt,Z&&!Z.messages.length&&!Z.olderBefore&&(0,z.jsx)(`div`,{className:`assistant-empty`,children:Q?.resumeSession?`已接入原生会话,发送消息继续。`:`在当前目录开始一段对话。`})]}),Z?.commands.filter(e=>e.state!==`succeeded`&&![`diff`,`history`,`rewind`].includes(e.kind)&&!(e.kind===`stop`&&[`queued`,`running`].includes(e.state))).slice(-3).map(e=>(0,z.jsxs)(`p`,{className:`computer-control-status`,role:`status`,children:[e.kind===`stop`?`停止`:e.kind,` · `,ot[e.state]??e.state,e.error?`:${e.error}`:``]},e.id)),(0,z.jsx)(_,{error:!0,children:x||X.error||Q?.error}),ct.length>0&&(0,z.jsx)(`div`,{className:`computer-question-shortcut`,children:(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{let e=(ct.findIndex(e=>e.id===Ue.current)+1)%ct.length,t=ct[e];lt(t.id)||(V.current=!1,Ve.current=t.id,X.reveal(t.seq))},children:[(0,z.jsx)(s,{name:`question`,size:`small`}),`有 `,ct.length,` 个问题等待你的确认`]})}),Q&&(0,z.jsx)(be,{value:oe,onChange:ce,label:`向本地 Agent 发送消息`,sendLabel:Tt?Et?`中断并发送`:Dt?`加入队列`:`插话`:`发送`,onQueue:[`working`,`waiting`].includes(Q.state)&&U?.capabilities.includes(`local-agent-queue-v1`)?()=>Ot(`queue`):void 0,placeholder:Q.archived?`会话已归档`:`输入消息…`,disabled:Q.archived||!ft,sendDisabled:A||Y.busy||Y.failed||Y.count>0&&!Ct||Z?.commands.some(e=>e.kind===`rewind`&&[`queued`,`running`,`uncertain`].includes(e.state)),attachments:(0,z.jsxs)(z.Fragment,{children:[Y.preview(A),Y.files.some(e=>e.mimeType!==`application/octet-stream`)&&!wt&&(0,z.jsx)(_,{children:`当前模型将通过本地文件路径接收图片。`})]}),hasAttachments:Y.count>0,onFiles:Ct&&!A?e=>void Y.add(e):void 0,beforeSend:(0,z.jsx)(nt,{session:Q.id,active:[`working`,`waiting`].includes(Q.state),commands:Z?.commands??[],request:J,refresh:X.reload,onError:E},Q.id),actions:(0,z.jsxs)(z.Fragment,{children:[Ct?Y.picker(A||!ft,wt):wt?(0,z.jsx)(`span`,{title:`更新开发机客户端后可添加附件`,children:(0,z.jsx)(`button`,{type:`button`,className:`icon-button`,disabled:!0,"aria-label":`更新开发机客户端后可添加附件`,children:(0,z.jsx)(s,{name:`attachment`,size:`small`})})}):null,(0,z.jsx)(rt,{session:Q,models:xt,busy:A,available:!!ft,online:!!U?.online,commands:bt,controls:yt?.controls,draft:oe,onInsert:e=>{vt(e.kind===`skill`?e:null),ce(`${e.prefix??(e.kind===`skill`?`$`:`/`)}${e.name} `),requestAnimationFrame(()=>document.querySelector(`.message-composer textarea`)?.focus())},onConfig:e=>{pt(()=>J(`web/local-agent-sessions/${Q.id}/settings`,ie,{method:`PUT`,body:{expectedRevision:Q.revision,config:e}}))}})]}),onSubmit:()=>Ot(`auto`)})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ne,{title:`本地会话`}),(0,z.jsxs)(`div`,{className:`assistant-empty`,children:[`尚未登记本地执行目录。`,(0,z.jsx)(`button`,{onClick:()=>P(!0),children:`接入目录`})]})]})]})}export{Z as Computers,Ce as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{T as e}from"./Dropdown-
|
|
1
|
+
import{T as e}from"./Dropdown-Dh9Q9fSi.js";import{P as t}from"./index-CWjsEUUy.js";var n=e();function r({navigation:e,children:r,className:i=``,tree:a=!1,label:o,testId:s}){return(0,n.jsx)(t,{className:`assistant-layout conversation-layout ${i}`,"data-testid":s,navigation:(0,n.jsx)(`aside`,{className:`assistant-list ${a?`file-tree-pane`:``}`,"aria-label":`${o}列表`,children:e}),children:(0,n.jsx)(`section`,{className:`assistant-thread`,"aria-label":o,children:r})})}function i({mine:e=!1,author:t,time:r,children:i,className:a=``,ref:o,...s}){return(0,n.jsx)(`div`,{...s,ref:o,className:`assistant-bubble-row ${e?`mine`:``} ${a}`,children:(0,n.jsxs)(`div`,{className:`assistant-bubble`,children:[(0,n.jsxs)(`div`,{className:`assistant-bubble-meta`,children:[(0,n.jsx)(`span`,{children:t}),r&&(0,n.jsx)(`time`,{dateTime:r,children:new Date(r).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),i]})})}function a({label:e,state:t=`idle`}){return(0,n.jsx)(`span`,{className:`conversation-status state-${t}`,role:`img`,"aria-label":e,title:e})}function o({author:e,time:t,children:r}){return(0,n.jsxs)(`article`,{className:`conversation-post assistant-bubble`,children:[(0,n.jsxs)(`header`,{className:`assistant-bubble-meta`,children:[(0,n.jsx)(`strong`,{children:e}),t&&(0,n.jsx)(`time`,{dateTime:t,children:new Date(t).toLocaleString(`zh-CN`,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})})]}),r]})}function s({ref:e,...t}){return(0,n.jsx)(`div`,{role:`log`,"aria-live":`polite`,...t,ref:e,className:`assistant-transcript`})}export{a,s as i,r as n,o as r,i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{At as e,C as t,Ct as n,Dt as r,Ot as i,St as a,T as o,_ as s,a as c,b as l,c as u,d,k as f,l as p,m,p as h,r as g,s as _,t as v,v as y,x as b,y as x}from"./Dropdown-Cz5xKbpV.js";import{B as S,R as C,V as w}from"./index-_W-pw3aC.js";import{n as T,o as E,r as D,t as O}from"./task-links-BeRoF5ff.js";import"./file-links-DvISesr0.js";var k=i(((e,t)=>{t.exports=typeof process==`object`&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),A=i(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),j=i(((e,t)=>{var{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=A(),a=k();e=t.exports={};var o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),M=i(((e,t)=>{var n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),N=i(((e,t)=>{var n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),P=i(((e,t)=>{var n=k(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=A(),{safeRe:a,t:o}=j(),s=M(),{compareIdentifiers:c}=N(),l=(e,t)=>{let n=t.split(`.`);if(n.length>e.length)return!1;for(let t=0;t<n.length;t++)if(c(e[t],n[t])!==0)return!1;return!0};t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);this.prerelease=l[4]?l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e!==i)return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e!==i)return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];if(n===!1&&(r=[t]),l(this.prerelease,t)){let e=this.prerelease[t.split(`.`).length];isNaN(e)&&(this.prerelease=r)}else this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),F=i(((e,t)=>{var n=P();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),I=a(),L=e(F(),1),R=o();function z({className:e=``,...t}){return(0,R.jsx)(`button`,{type:`button`,...t,className:`pill-control ${e}`})}function B({className:e=``,...t}){return(0,R.jsx)(v,{...t,className:`pill-menu ${e}`})}var V=[{value:`time`,label:`按时间`,icon:`clock`},{value:`owner`,label:`按用户`,icon:`members`}];function H(e){e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),history.pushState(null,``,e.currentTarget.href),window.dispatchEvent(new PopStateEvent(`popstate`)))}var U=[{status:`planned`,label:`计划`},{status:`in_progress`,label:`进行中`},{status:`in_review`,label:`待验收`},{status:`completed`,label:`已完成`},{status:null,label:`未明确`}];function W({members:e,project:r,memberId:i}){let{request:a,projectId:o}=C(),s=`teammy-board-mine:${i}:${o}`,[l,d]=(0,I.useState)(()=>{try{return localStorage.getItem(s)===`true`}catch{return!1}}),f=`teammy-board-order:${i}:${o}`,[p,_]=(0,I.useState)(()=>{try{return localStorage.getItem(f)===`owner`?`owner`:`time`}catch{return`time`}}),v=V.find(e=>e.value===p),y=(0,I.useCallback)(e=>a(`tasks`,S,{signal:e}),[a]),x=b(y,3e3,t(o,`tasks`)),[w,T]=(0,I.useState)(),[E,D]=(0,I.useState)(!1),[k,A]=(0,I.useState)(Date.now);(0,I.useEffect)(()=>{let e=setInterval(()=>A(Date.now()),6e4);return()=>clearInterval(e)},[]);let j=x.data,M=O(location.href),N=j?.tasks.filter(e=>!l||e.owner===i)??[],P=new Set(e.map(e=>e.id));return(0,R.jsxs)(`div`,{className:`task-board`,children:[(0,R.jsx)(m,{title:r?.projectName.trim()?`${r.projectName.trim()}|工作看板`:`工作看板`,description:r?.description.trim()||``,children:(0,R.jsxs)(`div`,{className:`task-board-brand`,children:[(0,R.jsx)(`a`,{className:`task-board-home`,"data-testid":`home-link`,href:n(`/projects`),onClick:H,"aria-label":`项目主页`,"data-tooltip":`项目主页`,children:(0,R.jsx)(g,{})}),e.some(e=>e.id===i&&e.bound)&&(0,R.jsx)(G,{memberId:i})]})}),(0,R.jsxs)(`div`,{className:`task-board-toolbar`,role:`group`,"aria-label":`看板筛选与排序`,children:[(0,R.jsxs)(z,{"aria-pressed":l,"data-testid":`task-board-mine`,onClick:()=>{let e=!l;d(e),D(!1);try{localStorage.setItem(s,String(e))}catch{}},children:[(0,R.jsx)(u,{name:l?`enable`:`account`,size:`small`}),`只看我的`]}),(0,R.jsx)(B,{id:`task-board-sort-menu`,triggerId:`task-board-sort`,label:`任务排序:${v.label}`,routeKey:p,trigger:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(u,{name:v.icon,size:`small`}),(0,R.jsx)(`span`,{children:v.label}),(0,R.jsx)(u,{name:`chevronDown`,size:`small`})]}),children:e=>V.map(t=>(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":t.label,onClick:()=>{e(),_(t.value),D(!1);try{localStorage.setItem(f,t.value)}catch{}},children:[(0,R.jsx)(u,{name:t.icon,size:`small`}),(0,R.jsx)(`span`,{children:t.label}),p===t.value&&(0,R.jsx)(u,{name:`check`,size:`small`})]},t.value))})]}),(0,R.jsx)(h,{error:!0,children:x.error}),(0,R.jsx)(`section`,{className:`task-board-lanes`,"aria-label":`任务进度`,"data-testid":`progress-board`,children:U.filter(e=>e.status!==null||N.some(e=>e.status===null)).map(e=>{let t=N.filter(t=>t.status===e.status);t.sort((t,n)=>(p===`owner`?t.owner.localeCompare(n.owner,`en`,{numeric:!0}):0)||(e.status===`completed`?n.statusSince.localeCompare(t.statusSince):t.statusSince.localeCompare(n.statusSince))||t.id.localeCompare(n.id));let n=e.status===`completed`&&!E?t.slice(0,5):t;return(0,R.jsxs)(`section`,{className:`task-lane`,"aria-label":e.label,"data-stage":e.status??`unknown`,children:[(0,R.jsxs)(`h2`,{children:[(0,R.jsx)(`span`,{className:`lane-dot`}),e.label,(0,R.jsx)(c,{children:j?t.length:`—`})]}),(0,R.jsxs)(`div`,{className:`task-lane-content`,children:[t.length?n.map(e=>(0,R.jsx)(K,{task:e,number:j?.taskNumbers[e.id],memberIds:P,now:k,onEdit:()=>T(e),onSaved:()=>void x.reload()},e.id)):(0,R.jsx)(`p`,{className:`task-lane-empty`,children:x.error&&!j?`读取失败`:j?`暂无任务`:`读取中…`}),e.status===`completed`&&t.length>5&&(0,R.jsxs)(`button`,{type:`button`,className:`task-lane-expand`,"aria-expanded":E,onClick:()=>D(!E),children:[(0,R.jsx)(u,{name:E?`chevronUp`:`chevronDown`,size:`small`}),E?`收起`:`展开其余 ${t.length-5} 项`]})]})]},e.label)})}),M&&(0,R.jsx)(J,{project:o,id:M.id,memberIds:P,onClose:()=>{let e=new URL(location.href);e.searchParams.delete(`task`),history.replaceState(history.state,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}}),w&&(0,R.jsx)(Z,{task:w,onClose:()=>T(void 0),onSaved:()=>{T(void 0),x.reload()}},w.id)]})}function G({memberId:e}){let{api:t,projectId:n}=C(),i=b(t.devices,!0),a=x();if(!i.data||!a.data||i.error||a.error)return null;let o=(0,L.default)(a.data.version),[s]=i.data.devices.filter(t=>t.memberId===e&&t.bound).map(e=>(0,L.default)(e.status?.clientVersion)).filter(e=>e!==null).sort((e,t)=>e.compare(t));if(!s||!o||s.compare(o)>=0)return null;let c=a.data.versions.filter(e=>{let t=(0,L.default)(e);return t&&(!t.prerelease.length||e===o.raw)&&t.compare(s)>0&&t.compare(o)<=0}).length;return(0,R.jsx)(`p`,{className:`task-board-update${c>5?` overdue`:``}`,children:(0,R.jsxs)(`a`,{href:r(n,`settings/client-maintenance.md`,`#升级与修复`),onClick:H,children:[(0,R.jsx)(u,{name:`attention`,size:`small`}),(0,R.jsxs)(`span`,{children:[`客户端待更新 `,s.raw,` → `,o.raw,c>10&&`,您完全不更新是吗:(`]})]})})}function K({task:e,number:t,memberIds:n,onEdit:r,onSaved:i,now:a}){let{request:o}=C(),s=l(),[c,d]=(0,I.useState)(!1),[m,g]=(0,I.useState)(``);async function _(){if(!c){d(!0),g(``);try{await o(`tasks/${e.id}/correction`,w,{method:`PATCH`,signal:s,body:{needsConfirmation:!1,expectedRevision:e.revision}}),s.aborted||i()}catch(e){s.aborted||g(f(e))}finally{d(!1)}}}return(0,R.jsxs)(`details`,{className:`task-card`,"data-testid":`task-card`,"data-task-id":e.id,"data-owner":e.owner,"data-status":e.status??`unknown`,children:[(0,R.jsxs)(`summary`,{className:`task-card-heading`,"data-testid":`task-toggle`,children:[(0,R.jsxs)(`h3`,{children:[t!==void 0&&(0,R.jsxs)(`span`,{className:`task-card-number`,children:[`#`,t]}),(0,R.jsx)(`span`,{className:`task-card-title`,children:e.title})]}),(0,R.jsxs)(`span`,{className:`task-card-meta`,children:[(0,R.jsx)(`small`,{title:e.owner,children:e.owner}),e.needsConfirmation&&(0,R.jsxs)(`span`,{className:`task-confirmation`,"data-testid":`task-confirmation`,children:[(0,R.jsx)(u,{name:`attention`,size:`small`}),`需要确认`]}),e.status!==`completed`&&(0,R.jsx)(Y,{since:e.statusSince,now:a})]})]}),(0,R.jsx)(p,{icon:`edit`,className:`task-card-edit`,label:`纠正任务:${e.title}`,"data-testid":`task-correct`,disabled:c,onClick:r}),(0,R.jsxs)(`div`,{className:`task-card-details`,children:[(0,R.jsx)(q,{task:e,memberIds:n}),e.needsConfirmation&&(0,R.jsxs)(`div`,{className:`task-card-confirm`,children:[(0,R.jsx)(h,{error:!0,children:m}),(0,R.jsx)(`button`,{className:`primary`,"data-testid":`task-confirm-save`,disabled:c,onClick:()=>void _(),children:c?`正在保存…`:`保存`})]})]})]})}function q({task:e,memberIds:t}){let{projectId:r}=C(),[i,a]=(0,I.useState)(``);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`h4`,{children:`目标`}),(0,R.jsx)(`p`,{children:e.goal?(0,R.jsx)(X,{value:e.goal,memberIds:t}):`目标未明确`}),(0,R.jsx)(`h4`,{children:`当前进展`}),(0,R.jsx)(`p`,{className:`task-progress`,children:(0,R.jsx)(X,{value:e.progress,memberIds:t})}),(0,R.jsx)(`div`,{className:`task-card-sources`,children:e.sources.map(t=>(0,R.jsxs)(`a`,{"data-testid":`task-source`,href:n(t.kind===`material`?`/projects/${r}/materials?id=${t.materialId}&revision=${t.revision}`:D(r,e.owner,t.path)),children:[(0,R.jsx)(u,{name:`file`,size:`small`}),(0,R.jsx)(`span`,{children:t.path})]},t.path))}),(0,R.jsxs)(`div`,{className:`task-card-footer`,children:[e.syncedAt&&(0,R.jsxs)(`small`,{children:[`资料同步于 `,(0,R.jsx)(s,{value:e.syncedAt})]}),(0,R.jsx)(`span`,{role:`status`,children:i}),(0,R.jsx)(p,{icon:`link`,label:`复制任务链接`,onBlur:()=>a(``),onClick:async()=>{try{await y(new URL(n(E(r,e.id)),location.origin).href),a(`已复制`)}catch{a(`复制失败`)}}})]})]})}function J({project:e,id:t,memberIds:n,onClose:r}){let{data:i,error:a}=T(e,t,!0);return(0,R.jsxs)(d,{id:`shared-task`,title:i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`task-card-number`,children:[`#`,i.number]}),` `,i.task.title]}):`任务`,onClose:r,children:[(0,R.jsx)(h,{error:!0,children:a}),i?(0,R.jsxs)(`div`,{className:`task-card-details`,children:[(0,R.jsxs)(`small`,{children:[i.task.owner,` · `,U.find(e=>e.status===i.task.status)?.label,!i.active&&` · 已归档`]}),(0,R.jsx)(q,{task:i.task,memberIds:n},t)]}):!a&&(0,R.jsx)(`p`,{role:`status`,children:`读取中…`})]})}function Y({since:e,now:t}){let n=Math.max(0,t-Date.parse(e)),r=Math.floor(n/6e4),i=r<1?`刚刚`:r<60?`${r} 分钟`:r<1440?`${Math.floor(r/60)} 小时`:`${Math.floor(r/1440)} 天`;return(0,R.jsxs)(`span`,{className:`task-age${n>6048e5?` stale`:``}`,"data-testid":`task-age`,title:`进入当前状态:${new Date(e).toLocaleString(`zh-CN`)}`,"aria-label":`当前状态停留 ${i}`,children:[(0,R.jsx)(u,{name:`clock`,size:`small`}),i]})}function X({value:e,memberIds:t}){return e.split(/(@[a-z][a-z0-9_-]*)/gi).map((e,n)=>e.startsWith(`@`)&&t.has(e.slice(1))?(0,R.jsx)(`mark`,{className:`task-mention`,children:e},n):e)}function Z({task:e,onClose:t,onSaved:n}){let{request:r}=C(),i=l(),[a,o]=(0,I.useState)(e.title),[s,c]=(0,I.useState)(e.status??``),[u,p]=(0,I.useState)(e.goal??``),[m,g]=(0,I.useState)(e.progress),[v,y]=(0,I.useState)(!1),[b,x]=(0,I.useState)(``),S={...a===e.title?{}:{title:a},...s===(e.status??``)?{}:{status:s||null},...u===(e.goal??``)?{}:{goal:u||null},...m===e.progress?{}:{progress:m},...e.needsConfirmation?{needsConfirmation:!1}:{}};async function T(){if(!v&&Object.keys(S).length){y(!0),x(``);try{await r(`tasks/${e.id}/correction`,w,{method:`PATCH`,signal:i,body:{...S,expectedRevision:e.revision}}),i.aborted||n()}catch(e){i.aborted||x(f(e))}finally{y(!1)}}}return(0,R.jsx)(d,{id:`task-correction`,title:`纠正任务`,onClose:t,children:(0,R.jsxs)(`form`,{className:`stack`,"aria-busy":v,onSubmit:e=>{e.preventDefault(),T()},children:[(0,R.jsx)(_,{id:`task-title`,label:`标题`,children:(0,R.jsx)(`input`,{value:a,required:!0,onChange:e=>o(e.target.value)})}),(0,R.jsxs)(`fieldset`,{className:`task-status-field`,disabled:v,children:[(0,R.jsx)(`legend`,{children:`状态`}),(0,R.jsx)(`div`,{className:`task-status-options`,"data-testid":`task-status`,children:U.filter(e=>e.status!==null).map(e=>(0,R.jsxs)(`label`,{className:`task-status-choice`,children:[(0,R.jsx)(`input`,{type:`radio`,name:`task-status`,value:e.status,checked:s===e.status,onChange:()=>c(e.status)}),(0,R.jsx)(`span`,{children:e.label})]},e.status))}),(0,R.jsx)(`small`,{children:`待验收:任务成果已提交,等待验收或最终确认。`})]}),(0,R.jsx)(_,{id:`task-goal`,label:`目标`,children:(0,R.jsx)(`textarea`,{value:u,onChange:e=>p(e.target.value)})}),(0,R.jsx)(_,{id:`task-progress`,label:`当前进展`,children:(0,R.jsx)(`textarea`,{value:m,onChange:e=>g(e.target.value)})}),(0,R.jsx)(h,{error:!0,children:b}),(0,R.jsx)(`div`,{className:`row wrap`,children:(0,R.jsx)(`button`,{type:`submit`,className:`primary`,disabled:v||!Object.keys(S).length,"data-testid":`task-correction-save`,children:`保存`})})]})})}function Q({members:e,config:t,memberId:n}){return(0,R.jsx)(W,{members:e,project:t,memberId:n})}export{Q as Dashboard};
|
|
1
|
+
import{At as e,C as t,Ct as n,Dt as r,Ot as i,St as a,T as o,_ as s,a as c,b as l,c as u,d,k as f,l as p,m,p as h,r as g,s as _,t as v,v as y,x as b,y as x}from"./Dropdown-Dh9Q9fSi.js";import{H as S,V as C,z as w}from"./index-CWjsEUUy.js";import{n as T,o as E,r as D,t as O}from"./task-links-ArhNpuGG.js";import"./file-links-CtHFx6cd.js";var k=i(((e,t)=>{t.exports=typeof process==`object`&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),A=i(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),j=i(((e,t)=>{var{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=A(),a=k();e=t.exports={};var o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),M=i(((e,t)=>{var n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),N=i(((e,t)=>{var n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),P=i(((e,t)=>{var n=k(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=A(),{safeRe:a,t:o}=j(),s=M(),{compareIdentifiers:c}=N(),l=(e,t)=>{let n=t.split(`.`);if(n.length>e.length)return!1;for(let t=0;t<n.length;t++)if(c(e[t],n[t])!==0)return!1;return!0};t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);this.prerelease=l[4]?l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e!==i)return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e!==i)return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];if(n===!1&&(r=[t]),l(this.prerelease,t)){let e=this.prerelease[t.split(`.`).length];isNaN(e)&&(this.prerelease=r)}else this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),F=i(((e,t)=>{var n=P();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),I=a(),L=e(F(),1),R=o();function z({className:e=``,...t}){return(0,R.jsx)(`button`,{type:`button`,...t,className:`pill-control ${e}`})}function B({className:e=``,...t}){return(0,R.jsx)(v,{...t,className:`pill-menu ${e}`})}var V=[{value:`time`,label:`按时间`,icon:`clock`},{value:`owner`,label:`按用户`,icon:`members`}];function H(e){e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),history.pushState(null,``,e.currentTarget.href),window.dispatchEvent(new PopStateEvent(`popstate`)))}var U=[{status:`planned`,label:`计划`},{status:`in_progress`,label:`进行中`},{status:`in_review`,label:`待验收`},{status:`completed`,label:`已完成`},{status:null,label:`未明确`}];function W({members:e,project:r,memberId:i}){let{request:a,projectId:o}=w(),s=`teammy-board-mine:${i}:${o}`,[l,d]=(0,I.useState)(()=>{try{return localStorage.getItem(s)===`true`}catch{return!1}}),f=`teammy-board-order:${i}:${o}`,[p,_]=(0,I.useState)(()=>{try{return localStorage.getItem(f)===`owner`?`owner`:`time`}catch{return`time`}}),v=V.find(e=>e.value===p),y=(0,I.useCallback)(e=>a(`tasks`,C,{signal:e}),[a]),x=b(y,3e3,t(o,`tasks`)),[S,T]=(0,I.useState)(),[E,D]=(0,I.useState)(!1),[k,A]=(0,I.useState)(Date.now);(0,I.useEffect)(()=>{let e=setInterval(()=>A(Date.now()),6e4);return()=>clearInterval(e)},[]);let j=x.data,M=O(location.href),N=j?.tasks.filter(e=>!l||e.owner===i)??[],P=new Set(e.map(e=>e.id));return(0,R.jsxs)(`div`,{className:`task-board`,children:[(0,R.jsx)(m,{title:r?.projectName.trim()?`${r.projectName.trim()}|工作看板`:`工作看板`,description:r?.description.trim()||``,children:(0,R.jsxs)(`div`,{className:`task-board-brand`,children:[(0,R.jsx)(`a`,{className:`task-board-home`,"data-testid":`home-link`,href:n(`/projects`),onClick:H,"aria-label":`项目主页`,"data-tooltip":`项目主页`,children:(0,R.jsx)(g,{})}),e.some(e=>e.id===i&&e.bound)&&(0,R.jsx)(G,{memberId:i})]})}),(0,R.jsxs)(`div`,{className:`task-board-toolbar`,role:`group`,"aria-label":`看板筛选与排序`,children:[(0,R.jsxs)(z,{"aria-pressed":l,"data-testid":`task-board-mine`,onClick:()=>{let e=!l;d(e),D(!1);try{localStorage.setItem(s,String(e))}catch{}},children:[(0,R.jsx)(u,{name:l?`enable`:`account`,size:`small`}),`只看我的`]}),(0,R.jsx)(B,{id:`task-board-sort-menu`,triggerId:`task-board-sort`,label:`任务排序:${v.label}`,routeKey:p,trigger:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(u,{name:v.icon,size:`small`}),(0,R.jsx)(`span`,{children:v.label}),(0,R.jsx)(u,{name:`chevronDown`,size:`small`})]}),children:e=>V.map(t=>(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":t.label,onClick:()=>{e(),_(t.value),D(!1);try{localStorage.setItem(f,t.value)}catch{}},children:[(0,R.jsx)(u,{name:t.icon,size:`small`}),(0,R.jsx)(`span`,{children:t.label}),p===t.value&&(0,R.jsx)(u,{name:`check`,size:`small`})]},t.value))})]}),(0,R.jsx)(h,{error:!0,children:x.error}),(0,R.jsx)(`section`,{className:`task-board-lanes`,"aria-label":`任务进度`,"data-testid":`progress-board`,children:U.filter(e=>e.status!==null||N.some(e=>e.status===null)).map(e=>{let t=N.filter(t=>t.status===e.status);t.sort((t,n)=>(p===`owner`?t.owner.localeCompare(n.owner,`en`,{numeric:!0}):0)||(e.status===`completed`?n.statusSince.localeCompare(t.statusSince):t.statusSince.localeCompare(n.statusSince))||t.id.localeCompare(n.id));let n=e.status===`completed`&&!E?t.slice(0,5):t;return(0,R.jsxs)(`section`,{className:`task-lane`,"aria-label":e.label,"data-stage":e.status??`unknown`,children:[(0,R.jsxs)(`h2`,{children:[(0,R.jsx)(`span`,{className:`lane-dot`}),e.label,(0,R.jsx)(c,{children:j?t.length:`—`})]}),(0,R.jsxs)(`div`,{className:`task-lane-content`,children:[t.length?n.map(e=>(0,R.jsx)(K,{task:e,number:j?.taskNumbers[e.id],memberIds:P,now:k,onEdit:()=>T(e),onSaved:()=>void x.reload()},e.id)):(0,R.jsx)(`p`,{className:`task-lane-empty`,children:x.error&&!j?`读取失败`:j?`暂无任务`:`读取中…`}),e.status===`completed`&&t.length>5&&(0,R.jsxs)(`button`,{type:`button`,className:`task-lane-expand`,"aria-expanded":E,onClick:()=>D(!E),children:[(0,R.jsx)(u,{name:E?`chevronUp`:`chevronDown`,size:`small`}),E?`收起`:`展开其余 ${t.length-5} 项`]})]})]},e.label)})}),M&&(0,R.jsx)(J,{project:o,id:M.id,memberIds:P,onClose:()=>{let e=new URL(location.href);e.searchParams.delete(`task`),history.replaceState(history.state,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}}),S&&(0,R.jsx)(Z,{task:S,onClose:()=>T(void 0),onSaved:()=>{T(void 0),x.reload()}},S.id)]})}function G({memberId:e}){let{api:t,projectId:n}=w(),i=b(t.devices,!0),a=x();if(!i.data||!a.data||i.error||a.error)return null;let o=(0,L.default)(a.data.version),[s]=i.data.devices.filter(t=>t.memberId===e&&t.bound).map(e=>(0,L.default)(e.status?.clientVersion)).filter(e=>e!==null).sort((e,t)=>e.compare(t));if(!s||!o||s.compare(o)>=0)return null;let c=a.data.versions.filter(e=>{let t=(0,L.default)(e);return t&&(!t.prerelease.length||e===o.raw)&&t.compare(s)>0&&t.compare(o)<=0}).length;return(0,R.jsx)(`p`,{className:`task-board-update${c>5?` overdue`:``}`,children:(0,R.jsxs)(`a`,{href:r(n,`settings/client-maintenance.md`,`#升级与修复`),onClick:H,children:[(0,R.jsx)(u,{name:`attention`,size:`small`}),(0,R.jsxs)(`span`,{children:[`客户端待更新 `,s.raw,` → `,o.raw]})]})})}function K({task:e,number:t,memberIds:n,onEdit:r,onSaved:i,now:a}){let{request:o}=w(),s=l(),[c,d]=(0,I.useState)(!1),[m,g]=(0,I.useState)(``);async function _(){if(!c){d(!0),g(``);try{await o(`tasks/${e.id}/correction`,S,{method:`PATCH`,signal:s,body:{needsConfirmation:!1,expectedRevision:e.revision}}),s.aborted||i()}catch(e){s.aborted||g(f(e))}finally{d(!1)}}}return(0,R.jsxs)(`details`,{className:`task-card`,"data-testid":`task-card`,"data-task-id":e.id,"data-owner":e.owner,"data-status":e.status??`unknown`,children:[(0,R.jsxs)(`summary`,{className:`task-card-heading`,"data-testid":`task-toggle`,children:[(0,R.jsxs)(`h3`,{children:[t!==void 0&&(0,R.jsxs)(`span`,{className:`task-card-number`,children:[`#`,t]}),(0,R.jsx)(`span`,{className:`task-card-title`,children:e.title})]}),(0,R.jsxs)(`span`,{className:`task-card-meta`,children:[(0,R.jsx)(`small`,{title:e.owner,children:e.owner}),e.needsConfirmation&&(0,R.jsxs)(`span`,{className:`task-confirmation`,"data-testid":`task-confirmation`,children:[(0,R.jsx)(u,{name:`attention`,size:`small`}),`需要确认`]}),e.status!==`completed`&&(0,R.jsx)(Y,{since:e.statusSince,now:a})]})]}),(0,R.jsx)(p,{icon:`edit`,className:`task-card-edit`,label:`纠正任务:${e.title}`,"data-testid":`task-correct`,disabled:c,onClick:r}),(0,R.jsxs)(`div`,{className:`task-card-details`,children:[(0,R.jsx)(q,{task:e,memberIds:n}),e.needsConfirmation&&(0,R.jsxs)(`div`,{className:`task-card-confirm`,children:[(0,R.jsx)(h,{error:!0,children:m}),(0,R.jsx)(`button`,{className:`primary`,"data-testid":`task-confirm-save`,disabled:c,onClick:()=>void _(),children:c?`正在保存…`:`保存`})]})]})]})}function q({task:e,memberIds:t}){let{projectId:r}=w(),[i,a]=(0,I.useState)(``);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`h4`,{children:`目标`}),(0,R.jsx)(`p`,{children:e.goal?(0,R.jsx)(X,{value:e.goal,memberIds:t}):`目标未明确`}),(0,R.jsx)(`h4`,{children:`当前进展`}),(0,R.jsx)(`p`,{className:`task-progress`,children:(0,R.jsx)(X,{value:e.progress,memberIds:t})}),(0,R.jsx)(`div`,{className:`task-card-sources`,children:e.sources.map(t=>(0,R.jsxs)(`a`,{"data-testid":`task-source`,href:n(t.kind===`material`?`/projects/${r}/materials?id=${t.materialId}&revision=${t.revision}`:D(r,e.owner,t.path)),children:[(0,R.jsx)(u,{name:`file`,size:`small`}),(0,R.jsx)(`span`,{children:t.path})]},t.path))}),(0,R.jsxs)(`div`,{className:`task-card-footer`,children:[e.syncedAt&&(0,R.jsxs)(`small`,{children:[`资料同步于 `,(0,R.jsx)(s,{value:e.syncedAt})]}),(0,R.jsx)(`span`,{role:`status`,children:i}),(0,R.jsx)(p,{icon:`link`,label:`复制任务链接`,onBlur:()=>a(``),onClick:async()=>{try{await y(new URL(n(E(r,e.id)),location.origin).href),a(`已复制`)}catch{a(`复制失败`)}}})]})]})}function J({project:e,id:t,memberIds:n,onClose:r}){let{data:i,error:a}=T(e,t,!0);return(0,R.jsxs)(d,{id:`shared-task`,title:i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`task-card-number`,children:[`#`,i.number]}),` `,i.task.title]}):`任务`,onClose:r,children:[(0,R.jsx)(h,{error:!0,children:a}),i?(0,R.jsxs)(`div`,{className:`task-card-details`,children:[(0,R.jsxs)(`small`,{children:[i.task.owner,` · `,U.find(e=>e.status===i.task.status)?.label,!i.active&&` · 已归档`]}),(0,R.jsx)(q,{task:i.task,memberIds:n},t)]}):!a&&(0,R.jsx)(`p`,{role:`status`,children:`读取中…`})]})}function Y({since:e,now:t}){let n=Math.max(0,t-Date.parse(e)),r=Math.floor(n/6e4),i=r<1?`刚刚`:r<60?`${r} 分钟`:r<1440?`${Math.floor(r/60)} 小时`:`${Math.floor(r/1440)} 天`;return(0,R.jsxs)(`span`,{className:`task-age${n>6048e5?` stale`:``}`,"data-testid":`task-age`,title:`进入当前状态:${new Date(e).toLocaleString(`zh-CN`)}`,"aria-label":`当前状态停留 ${i}`,children:[(0,R.jsx)(u,{name:`clock`,size:`small`}),i]})}function X({value:e,memberIds:t}){return e.split(/(@[a-z][a-z0-9_-]*)/gi).map((e,n)=>e.startsWith(`@`)&&t.has(e.slice(1))?(0,R.jsx)(`mark`,{className:`task-mention`,children:e},n):e)}function Z({task:e,onClose:t,onSaved:n}){let{request:r}=w(),i=l(),[a,o]=(0,I.useState)(e.title),[s,c]=(0,I.useState)(e.status??``),[u,p]=(0,I.useState)(e.goal??``),[m,g]=(0,I.useState)(e.progress),[v,y]=(0,I.useState)(!1),[b,x]=(0,I.useState)(``),C={...a===e.title?{}:{title:a},...s===(e.status??``)?{}:{status:s||null},...u===(e.goal??``)?{}:{goal:u||null},...m===e.progress?{}:{progress:m},...e.needsConfirmation?{needsConfirmation:!1}:{}};async function T(){if(!v&&Object.keys(C).length){y(!0),x(``);try{await r(`tasks/${e.id}/correction`,S,{method:`PATCH`,signal:i,body:{...C,expectedRevision:e.revision}}),i.aborted||n()}catch(e){i.aborted||x(f(e))}finally{y(!1)}}}return(0,R.jsx)(d,{id:`task-correction`,title:`纠正任务`,onClose:t,children:(0,R.jsxs)(`form`,{className:`stack`,"aria-busy":v,onSubmit:e=>{e.preventDefault(),T()},children:[(0,R.jsx)(_,{id:`task-title`,label:`标题`,children:(0,R.jsx)(`input`,{value:a,required:!0,onChange:e=>o(e.target.value)})}),(0,R.jsxs)(`fieldset`,{className:`task-status-field`,disabled:v,children:[(0,R.jsx)(`legend`,{children:`状态`}),(0,R.jsx)(`div`,{className:`task-status-options`,"data-testid":`task-status`,children:U.filter(e=>e.status!==null).map(e=>(0,R.jsxs)(`label`,{className:`task-status-choice`,children:[(0,R.jsx)(`input`,{type:`radio`,name:`task-status`,value:e.status,checked:s===e.status,onChange:()=>c(e.status)}),(0,R.jsx)(`span`,{children:e.label})]},e.status))}),(0,R.jsx)(`small`,{children:`待验收:任务成果已提交,等待验收或最终确认。`})]}),(0,R.jsx)(_,{id:`task-goal`,label:`目标`,children:(0,R.jsx)(`textarea`,{value:u,onChange:e=>p(e.target.value)})}),(0,R.jsx)(_,{id:`task-progress`,label:`当前进展`,children:(0,R.jsx)(`textarea`,{value:m,onChange:e=>g(e.target.value)})}),(0,R.jsx)(h,{error:!0,children:b}),(0,R.jsx)(`div`,{className:`row wrap`,children:(0,R.jsx)(`button`,{type:`submit`,className:`primary`,disabled:v||!Object.keys(C).length,"data-testid":`task-correction-save`,children:`保存`})})]})})}function Q({members:e,config:t,memberId:n}){return(0,R.jsx)(W,{members:e,project:t,memberId:n})}export{Q as Dashboard};
|