@teammy/server 0.1.1 → 0.1.3
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/README.md +2 -2
- package/dist/main.js +442 -101
- package/dist/web/assets/Assistant-CpCuE2gu.css +1 -0
- package/dist/web/assets/Assistant-D5WOntPC.js +1 -0
- package/dist/web/assets/Dashboard-C6aBw_W-.css +1 -0
- package/dist/web/assets/Dashboard-CKFP7yNR.js +1 -0
- package/dist/web/assets/Files-yA3LmJcB.js +1 -0
- package/dist/web/assets/{Markdown-D-FafgUB.js → Markdown-DD5hV21X.js} +4 -4
- package/dist/web/assets/Sessions-6CSHCq6e.js +1 -0
- package/dist/web/assets/WorkspaceTree-CeHWFFYr.js +1 -0
- package/dist/web/assets/file-links-Qi15HqFr.js +1 -0
- package/dist/web/assets/index-B-MqU_88.css +1 -0
- package/dist/web/assets/index-DC8a4uzu.js +66 -0
- package/dist/web/index.html +2 -3
- package/package.json +1 -1
- package/dist/web/assets/Assistant-B712NOqs.js +0 -1
- package/dist/web/assets/Assistant-DULVRmR1.css +0 -1
- package/dist/web/assets/Dashboard-BMek5kfz.js +0 -1
- package/dist/web/assets/Dashboard-C7EDndZA.css +0 -1
- package/dist/web/assets/Files-BQ1LdKKa.js +0 -1
- package/dist/web/assets/Sessions-11r38zLA.js +0 -1
- package/dist/web/assets/WorkspaceTree-C406dC60.js +0 -1
- package/dist/web/assets/file-links-DTDtI322.js +0 -1
- package/dist/web/assets/index-B02ttZKr.js +0 -12
- package/dist/web/assets/index-C_jc0zVK.css +0 -1
- package/dist/web/assets/project-context-ClIYZ2Zu.js +0 -55
package/dist/web/index.html
CHANGED
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
<meta name="theme-color" content="#161615" />
|
|
7
7
|
<title>Teammy 工作台</title>
|
|
8
8
|
<link rel="icon" type="image/png" href="./assets/teammy-favicon-BiDvlPj2.png" />
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
10
|
-
<link rel="
|
|
11
|
-
<link rel="stylesheet" crossorigin href="./assets/index-C_jc0zVK.css">
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-DC8a4uzu.js"></script>
|
|
10
|
+
<link rel="stylesheet" crossorigin href="./assets/index-B-MqU_88.css">
|
|
12
11
|
</head>
|
|
13
12
|
<body>
|
|
14
13
|
<div id="root" data-teammy-ui-version="11"></div>
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{at as e,et as t,f as n,m as r,ot as i,r as a,tt as o,u as s,w as c,x as l,y as u}from"./project-context-ClIYZ2Zu.js";import{c as d,i as f,n as p,r as m,t as h}from"./index-B02ttZKr.js";import{t as g}from"./Markdown-D-FafgUB.js";var _=e(),v=u(),y=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),b=e=>e.replace(/[#*_`>]/g,``).replace(/\s+/g,` `).trim();function x({mine:e=!1,author:t,time:n,children:r}){return(0,v.jsx)(`div`,{className:`assistant-bubble-row ${e?`mine`:``}`,children:(0,v.jsxs)(`div`,{className:`assistant-bubble`,children:[(0,v.jsxs)(`div`,{className:`assistant-bubble-meta`,children:[(0,v.jsx)(`span`,{children:t}),(0,v.jsx)(`time`,{dateTime:n,children:y(n)})]}),r]})})}function S({me:e}){let{projectId:u,request:S}=a(),w=(0,_.useCallback)(e=>S(`agents/outbox`,m,{signal:e}),[S]),T=l(w,3e3),[E,D]=(0,_.useState)(),[O,k]=(0,_.useState)(`instant`),[A,j]=(0,_.useState)(),[M,N]=(0,_.useState)(``),[P,F]=(0,_.useState)(!1),[I,L]=(0,_.useState)(``),R=(0,_.useRef)(null),z=(0,_.useRef)(!0),B=(T.data?.messages??[]).filter(e=>e.box===`debug`).reverse(),V=T.data?.messages.find(e=>e.id===(O===`debug`?A:O)),H=B.filter(e=>!e.readAt).map(e=>e.id).join(`,`);(0,_.useEffect)(()=>{O===`debug`&&H&&Promise.all(H.split(`,`).map(e=>S(`agents/outbox/${e}/read`,f,{method:`POST`}))).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),T.reload()}).catch(e=>L(c(e)))},[O,H,S,T.reload]),(0,_.useEffect)(()=>{let e=new EventSource(i(`/api/v1/projects/${encodeURIComponent(u)}/agents/chat/events`));e.addEventListener(`snapshot`,e=>{try{D(h.parse(JSON.parse(e.data))),L(``)}catch(e){L(c(e))}}),e.addEventListener(`run`,e=>{let t=p.parse(JSON.parse(e.data));D(e=>e&&{...e,runs:e.runs.some(e=>e.id===t.id)?e.runs:[...e.runs,t]})});for(let t of[`delta`,`reset`,`state`])e.addEventListener(t,e=>{let n=JSON.parse(e.data);D(e=>e&&{...e,runs:e.runs.map(e=>e.id===n.id?{...e,answer:t===`delta`?e.answer+(n.text??``):t===`reset`?``:n.answer??e.answer,state:n.state??e.state,error:n.error===void 0?e.error:n.error}:e)})});return()=>e.close()},[u]),(0,_.useEffect)(()=>{z.current&&R.current?.scrollIntoView({block:`end`})},[O,E?.runs,V?.recipients,B.length]);function U(){window.dispatchEvent(new Event(`teammy:outbox`)),T.reload()}async function W(e){if(z.current=!0,k(e),N(``),L(``),j(void 0),e!==`instant`&&e!==`debug`)try{await S(`agents/outbox/${e}/read`,f,{method:`POST`}),U()}catch(e){L(c(e))}}async function G(e){e.preventDefault();let n=M.trim();if(n&&!P){F(!0),L(``);try{if(O===`instant`){let e=await S(`agents/chat`,p,{method:`POST`,body:{text:n}});D(t=>t&&{...t,runs:t.runs.some(t=>t.id===e.id)?t.runs:[...t.runs,e]})}else await S(`agents/outbox/${V.id}/reply`,o({taskId:t()}),{method:`POST`,body:{body:n}}),U(),j(void 0);N(``)}catch(e){L(c(e))}finally{F(!1)}}}let K=O===`instant`||!!V&&!V.archivedAt&&!V.recipients.find(t=>t.userId===e)?.reply;return(0,v.jsxs)(`div`,{className:`split-layout assistant-layout`,"data-testid":`assistant-page`,children:[(0,v.jsxs)(`aside`,{className:`assistant-list`,"aria-label":`消息列表`,children:[(0,v.jsx)(`header`,{className:`assistant-list-heading`,children:(0,v.jsx)(`h1`,{children:`消息`})}),(0,v.jsxs)(`div`,{className:`assistant-message-scroll`,children:[!!B.length&&(0,v.jsxs)(`button`,{type:`button`,"data-testid":`debug-outbox`,className:`assistant-message-item ${O===`debug`?`selected`:``}`,onClick:()=>void W(`debug`),children:[(0,v.jsx)(`span`,{className:`assistant-message-dot ${H?`unread`:``}`}),(0,v.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,v.jsx)(`strong`,{children:`运行提醒`}),(0,v.jsx)(`span`,{children:b(B.at(-1).body)})]})]}),T.data?.messages.filter(e=>e.box!==`debug`).sort((e,t)=>Number(!!e.archivedAt)-Number(!!t.archivedAt)).map(e=>(0,v.jsxs)(`button`,{type:`button`,"data-testid":`outbox-${e.id}`,className:`assistant-message-item ${e.archivedAt?`archived`:``} ${O===e.id?`selected`:``}`,onClick:()=>void W(e.id),children:[(0,v.jsx)(`span`,{className:`assistant-message-dot ${e.readAt?``:`unread`}`}),(0,v.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,v.jsx)(`strong`,{children:b(e.body)}),(0,v.jsxs)(`time`,{dateTime:e.createdAt,children:[new Date(e.createdAt).toLocaleDateString([],{month:`numeric`,day:`numeric`}),` `,y(e.createdAt)]})]})]},e.id))]}),(0,v.jsx)(r,{error:!0,children:T.error}),(0,v.jsx)(`footer`,{className:`assistant-entry-footer`,children:(0,v.jsxs)(d,{className:`assistant-launcher`,"aria-pressed":O===`instant`,onClick:()=>void W(`instant`),"data-testid":`assistant-launcher`,children:[(0,v.jsx)(n,{}),(0,v.jsx)(`strong`,{className:`assistant-launcher-copy`,children:`与提百事聊聊`})]})})]}),(0,v.jsxs)(`section`,{className:`assistant-thread`,"aria-label":O===`instant`?`提百事对话`:`消息内容`,children:[(0,v.jsx)(`header`,{className:`assistant-thread-heading`,children:(0,v.jsx)(`h2`,{children:O===`instant`?`提百事`:O===`debug`?`运行提醒`:`项目消息`})}),(0,v.jsxs)(`div`,{className:`assistant-transcript`,role:`log`,"aria-live":`polite`,"data-testid":`assistant-transcript`,onScroll:e=>{let t=e.currentTarget;z.current=t.scrollHeight-t.scrollTop-t.clientHeight<100},children:[O===`instant`?E?.runs.length?E.runs.map(t=>(0,v.jsxs)(`div`,{className:`assistant-turn`,children:[(0,v.jsx)(x,{mine:!0,author:e,time:t.createdAt,children:(0,v.jsx)(`div`,{className:`markdown`,children:(0,v.jsx)(g,{children:t.text})})}),(0,v.jsxs)(x,{author:`提百事`,time:t.createdAt,children:[t.answer&&(0,v.jsx)(`div`,{className:`markdown`,children:(0,v.jsx)(g,{children:t.answer})}),[`queued`,`running`].includes(t.state)&&(0,v.jsxs)(`span`,{className:`assistant-typing`,"aria-label":`正在回答`,children:[(0,v.jsx)(`i`,{}),(0,v.jsx)(`i`,{}),(0,v.jsx)(`i`,{})]}),t.state===`failed`&&(0,v.jsx)(r,{error:!0,children:t.error||`本次回答未完成。`})]})]},t.id)):(0,v.jsxs)(`div`,{className:`assistant-empty`,children:[(0,v.jsx)(n,{}),(0,v.jsx)(`p`,{children:`有什么项目问题想聊聊?`})]}):O===`debug`?B.map(t=>(0,v.jsx)(C,{item:t,me:e,onReply:!t.archivedAt&&!t.recipients.find(t=>t.userId===e)?.reply?()=>{j(t.id),N(``),L(``)}:void 0},t.id)):V&&(0,v.jsx)(C,{item:V,me:e}),(0,v.jsx)(`div`,{ref:R})]}),(0,v.jsx)(r,{error:!0,children:I}),K&&O!==`instant`&&(0,v.jsx)(`p`,{className:`assistant-reply-hint`,id:`assistant-reply-hint`,children:O===`debug`?`回复运行提醒:${b(V.body).split(`诊断码`)[0]}。发送后将作为新的后台输入。`:`回应「提百事」的问题。注意:只能发送一条消息,发送后「提百事」会恢复工作。`}),K?(0,v.jsxs)(`form`,{className:`assistant-composer`,onSubmit:e=>void G(e),children:[(0,v.jsx)(`textarea`,{value:M,onChange:e=>N(e.target.value),"aria-label":O===`instant`?`向提百事提问`:`回复消息`,"aria-describedby":O===`instant`?void 0:`assistant-reply-hint`,placeholder:O===`instant`?`问问提百事…`:`回复…`,rows:2,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,v.jsx)(`button`,{className:`primary assistant-send`,type:`submit`,disabled:P||!M.trim(),"aria-label":`发送`,children:(0,v.jsx)(s,{name:`send`})})]}):O!==`debug`&&V&&(0,v.jsxs)(`div`,{className:`assistant-archived`,children:[(0,v.jsx)(s,{name:`archive`}),`已归档`]})]})]})}function C({item:e,me:t,onReply:n}){return(0,v.jsxs)(`div`,{"data-testid":`outbox-thread-${e.id}`,children:[(0,v.jsxs)(x,{author:e.box===`debug`?`运行提醒`:`提百事`,time:e.createdAt,children:[(0,v.jsx)(`div`,{className:`markdown`,children:(0,v.jsx)(g,{children:e.body})}),n&&(0,v.jsx)(`button`,{type:`button`,className:`assistant-debug-reply`,onClick:n,children:`回复`})]}),[...e.recipients].filter(e=>e.reply).sort((e,t)=>e.reply.createdAt.localeCompare(t.reply.createdAt)).map(e=>(0,v.jsx)(x,{mine:e.userId===t,author:e.userId,time:e.reply.createdAt,children:(0,v.jsx)(`div`,{className:`markdown`,children:(0,v.jsx)(g,{children:e.reply.body})})},e.userId))]})}export{S as Assistant};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
main#main[data-page=assistant]{height:100dvh;padding:0}.assistant-layout{grid-template-columns:var(--pane-width) minmax(0, 1fr);height:100%;min-height:0}.assistant-list{border-right:1px solid var(--color-line);background:var(--color-surface);flex-direction:column;min-height:0;display:flex}.assistant-list-heading,.assistant-thread-heading{border-bottom:1px solid var(--color-line);flex:0 0 76px;justify-content:space-between;align-items:center;padding:0 24px;display:flex}.assistant-list-heading h1{margin:0;font-size:20px}.assistant-thread-heading h2{margin:0;font-size:17px}.assistant-message-scroll{flex:1;min-height:0;overflow-y:auto}.assistant-message-item{border:0;border-bottom:1px solid var(--color-line);text-align:left;width:100%;color:var(--color-text);background:0 0;border-radius:0;align-items:center;gap:12px;padding:20px 24px;display:flex}.assistant-message-item:hover{background:var(--color-hover)}.assistant-message-item.selected{background:var(--color-soft)}.assistant-message-item.archived{color:var(--color-muted)}.assistant-message-item.archived strong{font-weight:400}.assistant-entry-footer{border-top:1px solid var(--color-line);background:var(--color-surface);flex-shrink:0}.assistant-launcher{width:100%;min-height:76px;color:var(--color-text);text-align:center;background:0 0;border:0;border-radius:0;justify-content:center;align-items:center;margin:0;padding:0 24px;display:flex}.assistant-launcher:hover{background:var(--color-hover)}.assistant-launcher:focus-visible{outline-offset:-4px}.assistant-launcher .selection-content{padding:12px 18px}.assistant-launcher .mascot{flex-shrink:0;width:31.5px;height:47.7px}.assistant-launcher-copy{white-space:nowrap;font-size:16px}.assistant-message-copy{flex-direction:column;gap:6px;min-width:0;display:flex}.assistant-message-copy strong,.assistant-message-copy>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.assistant-message-copy strong{font-size:var(--text-base);font-weight:600}.assistant-message-copy>span,.assistant-message-copy time{font-size:var(--text-xs);color:var(--color-muted)}.assistant-message-dot{border-radius:50%;flex:0 0 7px;width:7px;height:7px}.assistant-message-dot.unread{background:var(--brand-orange)}.assistant-thread{background:var(--color-canvas);flex-direction:column;min-width:0;min-height:0;display:flex}.assistant-transcript{flex:1;min-height:0;padding:28px clamp(20px,4vw,64px);overflow-y:auto}.assistant-bubble-row{margin:0 0 24px;display:flex}.assistant-bubble-row.mine{justify-content:flex-end}.assistant-bubble{border-radius:4px var(--radius-lg) var(--radius-lg);background:var(--color-soft);overflow-wrap:anywhere;min-width:100px;max-width:min(88%,800px);padding:14px 18px}.assistant-bubble-row.mine .assistant-bubble{background:var(--color-accent-soft);border-radius:var(--radius-lg) 4px var(--radius-lg) var(--radius-lg)}.assistant-bubble-meta{font-size:var(--text-xs);color:var(--color-muted);align-items:baseline;gap:16px;margin-bottom:8px;display:flex}.assistant-debug-reply{font-size:var(--text-xs);background:var(--color-surface);margin-top:12px;padding:4px 10px}.assistant-bubble .markdown>:first-child{margin-top:0}.assistant-bubble .markdown>:last-child{margin-bottom:0}.assistant-bubble .markdown{font-size:var(--text-base);line-height:1.75}.assistant-bubble pre{max-width:100%;overflow-x:auto}.assistant-composer{background:var(--color-surface);border:1px solid var(--color-line);border-radius:var(--radius-lg);align-items:flex-end;gap:12px;margin:0 28px 28px;padding:12px;display:flex}.assistant-reply-hint{font-size:var(--text-xs);color:var(--color-muted);margin:0 28px 10px;line-height:1.7}.assistant-composer:focus-within{border-color:var(--color-muted)}.assistant-composer textarea{box-shadow:none;resize:vertical;background:0 0;border:0;flex:1;min-height:56px;max-height:220px;padding:8px}.assistant-composer textarea:focus{box-shadow:none;outline:none}.assistant-send{flex:0 0 40px;place-items:center;width:40px;height:40px;padding:0;display:grid}.assistant-empty{height:100%;min-height:240px;color:var(--color-muted);flex-direction:column;justify-content:center;align-items:center;gap:20px;display:flex}.assistant-empty .mascot{width:96px;height:144px}.assistant-empty p{margin:0}.assistant-archived{color:var(--color-muted);font-size:var(--text-sm);justify-content:center;align-items:center;gap:8px;padding:24px;display:flex}.assistant-thread>.notice{margin:0 28px 12px}.assistant-typing{gap:5px;padding:8px 0;display:inline-flex}.assistant-typing i{background:var(--color-muted);border-radius:50%;width:5px;height:5px;animation:1.4s infinite assistant-pulse}.assistant-typing i:nth-child(2){animation-delay:.15s}.assistant-typing i:nth-child(3){animation-delay:.3s}@keyframes assistant-pulse{0%,70%,to{opacity:.35}35%{opacity:1}}@media (prefers-reduced-motion:reduce){.assistant-typing i{animation:none}}@media (width<=900px){.assistant-layout{grid-template-columns:240px minmax(0,1fr)}.assistant-message-item{padding:16px}.assistant-composer{margin:0 16px 16px}.assistant-reply-hint{margin:0 16px 10px}.assistant-launcher{padding:0 12px}.assistant-bubble{max-width:96%}}@media (width<=600px){.assistant-layout{grid-template-columns:150px minmax(0,1fr)}.assistant-list-heading,.assistant-thread-heading{padding:0 12px}.assistant-launcher{padding:0 4px}.assistant-launcher .selection-content{padding:12px 6px}.assistant-launcher .selection-inner{gap:4px}.assistant-launcher-copy{font-size:12px}.assistant-transcript{padding:16px 10px}.assistant-composer{gap:4px;margin:0 8px 12px;padding:6px}.assistant-reply-hint{margin:0 8px 10px}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{at as e,b as t,d as n,h as r,l as i,m as a,ot as o,p as s,r as c,s as l,u,v as d,w as f,x as p,y as m}from"./project-context-ClIYZ2Zu.js";import{l as h,u as g}from"./index-B02ttZKr.js";import{t as _}from"./project-links-XbF78Bal.js";import"./file-links-DTDtI322.js";var v=e(),y=m(),b=[{status:`planned`,label:`计划`},{status:`in_progress`,label:`进行中`},{status:`in_review`,label:`待验收`},{status:`completed`,label:`已完成`},{status:null,label:`未明确`}];function x({members:e}){let{request:t}=c(),n=(0,v.useCallback)(e=>t(`tasks`,h,{signal:e}),[t]),i=p(n,3e3),[o,s]=(0,v.useState)(),u=i.data,d=u?.members.some(e=>[`queued`,`running`].includes(e.status)),f=new Map(e.map(e=>[e.id,e.displayName||e.id]));return(0,y.jsxs)(`div`,{className:`task-board`,children:[(0,y.jsx)(r,{title:`工作看板`}),(0,y.jsx)(`span`,{className:`sr-only`,role:`status`,children:d?`正在整理工作区`:i.loading&&!u?`正在读取任务`:``}),(0,y.jsx)(a,{error:!0,children:i.error}),(0,y.jsx)(`section`,{className:`task-board-lanes`,"aria-label":`任务进度`,"data-testid":`progress-board`,children:b.filter(e=>e.status!==null||u?.tasks.some(e=>e.status===null)).map(e=>{let t=u?.tasks.filter(t=>t.status===e.status)??[];return(0,y.jsxs)(`section`,{className:`task-lane`,"aria-label":e.label,"data-stage":e.status??`unknown`,children:[(0,y.jsxs)(`h2`,{children:[(0,y.jsx)(`span`,{className:`lane-dot`}),e.label,(0,y.jsx)(l,{children:u?t.length:`—`})]}),(0,y.jsx)(`div`,{className:`task-lane-content`,children:t.length?t.map(e=>(0,y.jsx)(S,{task:e,names:f,onEdit:()=>s(e),onSaved:()=>void i.reload()},e.id)):(0,y.jsx)(`p`,{className:`task-lane-empty`,children:i.error&&!u?`读取失败`:u?`暂无任务`:`读取中…`})})]},e.label)})}),o&&(0,y.jsx)(w,{task:o,onClose:()=>s(void 0),onSaved:()=>{s(void 0),i.reload()}},o.id)]})}function S({task:e,names:r,onEdit:i,onSaved:s}){let{projectId:l,request:p}=c(),m=t(),[h,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(``);async function w(){if(!h){b(!0),S(``);try{await p(`tasks/${e.id}/correction`,g,{method:`PATCH`,signal:m,body:{needsConfirmation:!1}}),m.aborted||s()}catch(e){m.aborted||S(f(e))}finally{b(!1)}}}return(0,y.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,y.jsxs)(`summary`,{className:`task-card-heading`,"data-testid":`task-toggle`,children:[(0,y.jsx)(`h3`,{children:e.title}),(0,y.jsxs)(`span`,{className:`task-card-meta`,children:[(0,y.jsx)(`small`,{children:r.get(e.owner)??e.owner}),e.needsConfirmation&&(0,y.jsxs)(`span`,{className:`task-confirmation`,"data-testid":`task-confirmation`,children:[(0,y.jsx)(u,{name:`attention`,size:`small`}),`需要确认`]})]})]}),(0,y.jsx)(n,{icon:`edit`,className:`task-card-edit`,label:`纠正任务:${e.title}`,"data-testid":`task-correct`,disabled:h,onClick:i}),(0,y.jsxs)(`div`,{className:`task-card-details`,children:[e.corrected&&!e.needsConfirmation&&(0,y.jsx)(`small`,{children:`已确认`}),e.needsReview&&(0,y.jsx)(`p`,{children:`本次整理未能明确对应,请核对来源。`}),(0,y.jsx)(`h4`,{children:`目标`}),(0,y.jsx)(`p`,{children:e.goal?(0,y.jsx)(C,{value:e.goal,names:r}):`目标未明确`}),(0,y.jsx)(`h4`,{children:`当前进展`}),(0,y.jsx)(`p`,{className:`task-progress`,children:(0,y.jsx)(C,{value:e.progress,names:r})}),(0,y.jsx)(`div`,{className:`task-card-sources`,children:e.sources.map(t=>(0,y.jsxs)(`a`,{"data-testid":`task-source`,href:o(_(l,e.owner,t.path)),children:[(0,y.jsx)(u,{name:`file`,size:`small`}),(0,y.jsx)(`span`,{children:t.path})]},t.path))}),e.syncedAt&&(0,y.jsxs)(`small`,{children:[`资料同步于 `,(0,y.jsx)(d,{value:e.syncedAt})]}),e.needsConfirmation&&(0,y.jsxs)(`div`,{className:`task-card-confirm`,children:[(0,y.jsx)(a,{error:!0,children:x}),(0,y.jsx)(`button`,{className:`primary`,"data-testid":`task-confirm-save`,disabled:h,onClick:()=>void w(),children:h?`正在保存…`:`保存`})]})]})]})}function C({value:e,names:t}){return e.split(/(@[a-z][a-z0-9_-]*)/gi).map((e,n)=>e.startsWith(`@`)&&t.has(e.slice(1))?(0,y.jsx)(`mark`,{className:`task-mention`,children:e},n):e)}function w({task:e,onClose:n,onSaved:r}){let{request:o}=c(),l=t(),[u,d]=(0,v.useState)(e.title),[p,m]=(0,v.useState)(e.status??``),[h,_]=(0,v.useState)(e.goal??``),[x,S]=(0,v.useState)(e.progress),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(``),D={...u===e.title?{}:{title:u},...p===(e.status??``)?{}:{status:p||null},...h===(e.goal??``)?{}:{goal:h||null},...x===e.progress?{}:{progress:x},...e.needsConfirmation?{needsConfirmation:!1}:{}};async function O(t=!1){if(!(C||!t&&!Object.keys(D).length)){w(!0),E(``);try{await o(`tasks/${e.id}/correction`,g,{method:t?`DELETE`:`PATCH`,signal:l,...t?{}:{body:D}}),l.aborted||r()}catch(e){l.aborted||E(f(e))}finally{w(!1)}}}return(0,y.jsx)(s,{id:`task-correction`,title:`纠正任务`,onClose:n,children:(0,y.jsxs)(`form`,{className:`stack`,"aria-busy":C,onSubmit:e=>{e.preventDefault(),O()},children:[(0,y.jsx)(i,{id:`task-title`,label:`标题`,children:(0,y.jsx)(`input`,{value:u,required:!0,onChange:e=>d(e.target.value)})}),(0,y.jsxs)(`fieldset`,{className:`task-status-field`,disabled:C,children:[(0,y.jsx)(`legend`,{children:`状态`}),(0,y.jsx)(`div`,{className:`task-status-options`,"data-testid":`task-status`,children:b.filter(e=>e.status!==null).map(e=>(0,y.jsxs)(`label`,{className:`task-status-choice`,children:[(0,y.jsx)(`input`,{type:`radio`,name:`task-status`,value:e.status,checked:p===e.status,onChange:()=>m(e.status)}),(0,y.jsx)(`span`,{children:e.label})]},e.status))})]}),(0,y.jsx)(i,{id:`task-goal`,label:`目标`,children:(0,y.jsx)(`textarea`,{value:h,onChange:e=>_(e.target.value)})}),(0,y.jsx)(i,{id:`task-progress`,label:`当前进展`,children:(0,y.jsx)(`textarea`,{value:x,onChange:e=>S(e.target.value)})}),(0,y.jsx)(a,{error:!0,children:T}),(0,y.jsxs)(`div`,{className:`row wrap`,children:[(0,y.jsx)(`button`,{type:`submit`,className:`primary`,disabled:C||!Object.keys(D).length,"data-testid":`task-correction-save`,children:`保存`}),e.corrected&&(0,y.jsx)(`button`,{type:`button`,disabled:C,"data-testid":`task-correction-reset`,onClick:()=>void O(!0),children:`恢复自动结果`})]})]})})}function T({members:e}){return(0,y.jsx)(x,{members:e})}export{T as Dashboard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.task-board{min-width:0}.task-board .page-header{margin-bottom:40px}.task-board-lanes{grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));align-items:start;gap:24px;margin-bottom:32px;display:grid}.task-lane{min-width:0}.task-lane h2{font-size:var(--text-base);border-bottom:1px solid var(--color-line);align-items:center;gap:10px;padding:0 0 16px;font-weight:600;display:flex}.task-lane .count{margin-left:auto}.task-lane-content{flex-direction:column;gap:12px;padding-top:16px;display:flex}.lane-dot{border:1.5px solid var(--color-muted);border-radius:50%;width:8px;height:8px}.task-lane[data-stage=in_progress] .lane-dot{border-color:var(--brand-orange);background:var(--brand-orange)}.task-lane[data-stage=in_review] .lane-dot{border-color:var(--brand-black);background:var(--brand-black)}.task-lane[data-stage=completed] .lane-dot{border-color:var(--color-muted);background:var(--color-muted)}.task-lane-empty{font-size:var(--text-xs);color:var(--color-muted);padding:44px 0}.task-card{border:1px solid var(--color-line);border-radius:var(--radius-md);background:var(--color-surface);overflow-wrap:anywhere;min-width:0;position:relative}.task-card>.task-card-heading{border-radius:inherit;padding:16px;list-style:none;position:relative}.task-card-heading::-webkit-details-marker{display:none}.task-card-heading:hover{background:var(--color-soft)}.task-card[open]>.task-card-heading{padding-right:48px}.task-card-meta{flex-wrap:wrap;align-items:center;gap:8px;margin-top:8px;display:flex}.task-confirmation{border-radius:var(--radius-sm);background:var(--color-accent-soft);color:var(--brand-orange);font-size:calc(var(--text-xs) - 1px);align-items:center;gap:3px;padding:0 4px;font-weight:400;line-height:18px;display:inline-flex}.task-confirmation .icon{width:12px;height:12px}.task-card-confirm{flex-direction:column;align-items:flex-end;gap:8px;margin-top:16px;display:flex}.task-card-confirm button{min-height:32px;font-size:var(--text-xs);padding:4px 12px}.task-status-field legend{font-size:var(--text-sm);margin-bottom:8px;font-weight:600}.task-status-options{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;display:grid}.task-status-choice{cursor:pointer;position:relative}.task-status-choice input{opacity:0;width:100%;height:100%;min-height:0;cursor:inherit;position:absolute;inset:0}.task-status-choice span{border:1px solid var(--color-line);border-radius:var(--radius-md);background:var(--color-surface);min-height:36px;font-size:var(--text-sm);justify-content:center;align-items:center;font-weight:550;display:flex}.task-status-choice:hover span{background:var(--color-soft)}.task-status-choice input:checked+span{border-color:var(--brand-black);background:var(--brand-black);color:var(--color-on-dark)}.task-status-choice input:focus-visible+span{outline:2px solid var(--brand-orange);outline-offset:3px}.task-status-choice input:disabled+span{opacity:.45;cursor:default}.task-card-heading h3{font-size:var(--text-base);font-weight:650;line-height:1.55}.task-card-edit{opacity:0;pointer-events:none;position:absolute;top:10px;right:8px}.task-card[open]:hover>.task-card-edit{opacity:1;pointer-events:auto}.task-card[open]:has(:focus-visible)>.task-card-edit{opacity:1;pointer-events:auto}.task-progress{font-size:var(--text-sm);white-space:pre-wrap;line-height:1.85}.task-card small{color:var(--color-muted);font-size:var(--text-xs)}.task-card-details{padding:0 16px 16px}.task-card-details h4{font-size:var(--text-xs);margin:16px 0 4px;font-weight:600}.task-card-details p{font-size:var(--text-sm);margin:0}.task-card-sources{flex-direction:column;align-items:flex-start;gap:8px;margin:16px 0;display:flex}.task-card-sources a{text-align:left;overflow-wrap:anywhere;max-width:100%;font-size:var(--text-xs);min-height:28px;color:var(--color-muted);justify-content:flex-start;gap:8px;padding:4px 0;text-decoration:none;display:inline-flex}.task-card-sources a:hover{color:var(--color-link);text-decoration:underline}.task-mention{border-radius:var(--radius-sm);background:var(--color-accent-soft);color:inherit;padding:0 2px}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{G as e,S as t,_ as n,at as r,c as i,d as a,k as o,m as s,ot as c,r as l,u,x as d,y as f}from"./project-context-ClIYZ2Zu.js";import{a as p,o as m,s as h}from"./index-B02ttZKr.js";import{t as g}from"./Markdown-D-FafgUB.js";import{t as _}from"./project-links-XbF78Bal.js";import{t as v}from"./file-links-DTDtI322.js";import{n as y,t as b}from"./WorkspaceTree-C406dC60.js";var x=r(),S=f();function C(e,t){let n=t.split(`/`).slice(0,-1);return n.map((t,r)=>y(e,n.slice(0,r+1).join(`/`))).concat(y(e,``))}function w({members:n,me:r,onRefresh:u}){let{api:f,projectId:g}=l(),[w,E]=(0,x.useState)(()=>{let t=new URLSearchParams(location.search),r=t.get(`owner`),i=e.safeParse(t.get(`path`));return r&&(r===`_project`||n.some(e=>e.id===r))&&i.success&&!m(i.data)?{owner:r,path:i.data}:void 0}),[D,O]=(0,x.useState)(()=>new Set(w?C(w.owner,w.path):[y(r,``)])),[k,A]=(0,x.useState)(()=>w?{...w,kind:`file`}:void 0),[j,M]=(0,x.useState)(0),[N,P]=(0,x.useState)(()=>{let e=new URLSearchParams(location.search);return!w&&(e.has(`owner`)||e.has(`path`))?`文件链接不完整或目标已不可用。`:``}),F=(0,x.useCallback)(async e=>{if(w)try{return{owner:w.owner,...await f.file(w.owner,w.path,void 0,e)}}catch(e){throw e instanceof t&&e.code===`FILE_NOT_FOUND`?Error(`找不到这个文件,可能已被删除或移动。`):e}},[w?.owner,w?.path,j]),I=d(F),L=I.data?.owner===w?.owner&&I.data?.file.path===w?.path?I.data:void 0;function R(e,t){let n=t.split(`/`).filter(Boolean);O(t=>{let r=new Set(t);for(let t=0;t<=n.length;t++)r.add(y(e,n.slice(0,t).join(`/`)));return r})}function z(e,t){P(``),R(e,t.split(`/`).slice(0,-1).join(`/`)),E({owner:e,path:t}),A({owner:e,path:t,kind:`file`}),history.replaceState(null,``,c(_(g,e,t)))}function B(e){if(!w)return!1;let t=v(w.owner===`_project`?w.path:`${w.owner}/${w.path}`,e);if(!t)return!/^[a-z][a-z0-9+.-]*:/i.test(e)&&!e.startsWith(`//`)&&(P(`该链接超出工作区,请在原仓库查看。`),!0);if(m(t.path))return P(`配置文件不在文件浏览中显示。`),!0;let[r,...i]=t.path.split(`/`),a=n.some(e=>e.id===r),o=a?r:p,s=a?i.join(`/`):t.path;return P(``),t.directory?(R(o,s),A({owner:o,path:s,kind:`directory`})):o===w.owner&&s===w.path?t.anchor&&[...document.querySelectorAll(`.markdown h1,.markdown h2,.markdown h3,.markdown h4`)].find(e=>e.textContent?.trim().toLowerCase().replace(/\s+/g,`-`)===t.anchor.toLowerCase())?.scrollIntoView({block:`center`}):z(o,s),!0}return(0,S.jsxs)(`div`,{className:`split-layout file-explorer`,"data-testid":`file-browser`,children:[(0,S.jsxs)(`aside`,{className:`file-tree-pane`,"aria-label":`文件资源管理器`,children:[(0,S.jsx)(h,{title:`文件`,icon:`files`,children:(0,S.jsx)(a,{icon:`refresh`,label:`刷新文件`,"data-testid":`files-refresh`,onClick:()=>{P(``),M(e=>e+1),u()}})}),(0,S.jsx)(b,{members:n,expanded:D,selected:k,revealed:!I.loading&&!I.error&&L?{owner:L.owner,path:L.file.path,file:L.file}:void 0,onSelect:z,onToggle:(e,t)=>{A({owner:e,path:t,kind:`directory`}),O(n=>{let r=new Set(n),i=y(e,t);return r.has(i)?r.delete(i):r.add(i),r})}},j)]}),(0,S.jsx)(`section`,{className:`file-detail`,"data-testid":`file-preview`,"data-owner-id":w?.owner,"data-file-path":w?.path,"aria-label":o.filePreview,children:w?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(s,{error:!0,children:N||!I.loading&&I.error}),I.error&&(0,S.jsx)(`button`,{className:`file-entry-retry`,"data-testid":`files-retry`,onClick:()=>void I.reload(),children:o.retry}),I.loading?(0,S.jsx)(`p`,{className:`preview-body`,role:`status`,children:o.loading}):!I.error&&L&&(0,S.jsx)(T,{owner:L.owner,file:L.file,onLink:B},`${L.owner}:${L.file.path}:${L.file.sha256}`)]}):N?(0,S.jsx)(s,{error:!0,children:N}):(0,S.jsx)(i,{mascot:!0,title:`从一份资料开始`,description:o.pickFile})})]})}function T({owner:e,file:t,onLink:r}){let{readTextBlob:i,blobUrl:c}=l(),[f,p]=(0,x.useState)(!1),m=t.size>524288,h=/\.(md|markdown)$/i.test(t.path),_=(0,x.useCallback)(e=>m?Promise.resolve(void 0):i(t,e),[t.sha256,t.size,m]),v=d(_);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`header`,{className:`file-detail-header`,children:[(0,S.jsxs)(`span`,{className:`file-detail-path`,title:`${e===`_project`?`workspaces`:e}/${t.path}`,children:[(0,S.jsxs)(`span`,{children:[e===`_project`?`workspaces`:e,` / `]}),t.path]}),(0,S.jsxs)(n,{label:`文件操作`,children:[h&&(0,S.jsx)(a,{icon:f?`preview`:`code`,label:f?`切换为预览`:`切换为原文`,"data-testid":`file-toggle-raw`,"aria-pressed":f,onClick:()=>p(!f)}),(0,S.jsx)(`a`,{className:`icon-button`,"data-testid":`file-download`,"aria-label":o.download,title:o.download,href:c(t.sha256),download:t.path.split(`/`).at(-1),children:(0,S.jsx)(u,{name:`download`})})]})]}),m?(0,S.jsx)(`div`,{className:`empty`,children:(0,S.jsx)(`p`,{children:o.previewLarge})}):v.error?(0,S.jsxs)(`div`,{className:`preview-body`,children:[(0,S.jsx)(s,{error:!0,children:v.error}),(0,S.jsx)(`button`,{"data-testid":`file-preview-retry`,onClick:()=>void v.reload(),children:o.retry})]}):v.loading?(0,S.jsx)(`p`,{className:`preview-body`,role:`status`,children:o.loading}):(0,S.jsx)(`div`,{className:`preview-body`,children:h&&!f?(0,S.jsx)(`article`,{className:`markdown`,"data-testid":`file-content`,"data-format":`markdown`,children:(0,S.jsx)(g,{onLink:r,children:v.data??``})}):(0,S.jsx)(`pre`,{className:`raw`,"data-testid":`file-content`,"data-format":`text`,children:v.data})})]})}export{w as Files};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,J as t,K as n,O as r,S as i,W as a,X as o,Y as s,Z as c,at as l,b as u,c as d,d as f,et as p,it as m,k as h,m as g,nt as _,ot as v,q as y,r as b,rt as x,tt as S,u as C,v as w,w as T,x as E,y as D}from"./project-context-ClIYZ2Zu.js";import{c as O,s as k}from"./index-B02ttZKr.js";import{n as A,r as j,t as M}from"./Markdown-D-FafgUB.js";import{n as N}from"./project-links-XbF78Bal.js";import{i as P,r as F}from"./WorkspaceTree-C406dC60.js";var I=l(),L=s([`overview`,`handoff`]),R=S({title:_().trim().min(1),summary:_().trim().min(1)}).strict(),z=S({markdown:_().trim().min(1)}).strict(),B=R.extend({sourceRevision:y,sourceHash:n,generatedAt:_(),stale:c()}),V=S({kind:L,status:s([`absent`,`queued`,`running`,`succeeded`,`failed`]),available:c(),currentRevision:y,sourceRevision:y.nullable(),stale:c(),result:x([R,z]).nullable(),generatedAt:_().nullable(),error:_().nullable()}),H=s([`claude-code`,`codex`,`cursor`,`pi`,`dsh`]),U=S({formatVersion:e(1),adapterVersion:e(1),agent:H,nativeId:_().min(1).max(512),cwd:_().min(1).max(4096),messages:o(S({id:_().min(1).max(1024),role:s([`user`,`assistant`]),text:_().min(1),source:_().min(1).max(1024)}).strict())}).strict().refine(e=>new Set(e.messages.map(e=>e.id)).size===e.messages.length,`Duplicate message IDs.`);S({operationId:m(),sessionKey:n,parentRevision:y,blob:a}).strict();var W=S({owner:t,sessionKey:n,agent:H,nativeId:_(),cwd:_(),title:_(),revision:y,updatedAt:_(),messageCount:p().int().nonnegative(),blob:a,overview:B.optional()}),G=S({sessions:o(W),nextCursor:y.nullable()}),K=S({totalSessions:p().int().nonnegative(),totalMessages:p().int().nonnegative(),memberCount:p().int().nonnegative(),updatedAt:_().nullable()});S({owner:t.optional(),sessionKey:n.optional()}).strict().refine(e=>!e.sessionKey||!!e.owner,`A session scope requires an owner.`);var q=S({matches:o(S({owner:t,sessionKey:n,revision:y,messageId:_(),role:s([`user`,`assistant`]),snippet:_(),title:_()})),nextCursor:y.nullable()}),J=S({owner:t,key:n,revision:y.refine(e=>e>0).optional(),messageId:_().min(1).optional()});function Y(e){let t=new URLSearchParams(e);if(![`owner`,`sessionKey`,`revision`,`messageId`].some(e=>t.has(e)))return{};let n=J.safeParse({owner:t.get(`owner`),key:t.get(`sessionKey`),...t.has(`revision`)?{revision:Number(t.get(`revision`))}:{},...t.has(`messageId`)?{messageId:t.get(`messageId`)}:{}});return n.success?{target:n.data}:{error:`对话链接不完整或已损坏。`}}var X=D();function Z({members:e,refresh:t,selected:n,onOwner:r,onSession:i}){let[a,o]=(0,I.useState)(()=>new Set(n?.key?[n.owner]:[])),[s,c]=(0,I.useState)(e[0]?.id??``);return(0,X.jsx)(`div`,{role:`tree`,"aria-label":`成员对话`,"data-testid":`session-tree`,onKeyDown:F,children:[...e].sort((e,t)=>P(e.displayName,t.displayName)||P(e.id,t.id)).map(e=>(0,X.jsxs)(`div`,{role:`none`,children:[(0,X.jsxs)(O,{type:`button`,role:`treeitem`,"aria-level":1,"aria-expanded":a.has(e.id),"aria-selected":n?.owner===e.id&&!n.key,className:`tree-item tree-folder`,style:{"--tree-level":1},tabIndex:s===e.id?0:-1,"data-testid":`session-owner`,"data-owner-id":e.id,onFocus:()=>c(e.id),onClick:()=>{o(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),r(e.id)},leading:(0,X.jsx)(`span`,{className:`tree-chevron ${a.has(e.id)?`expanded`:``}`,children:(0,X.jsx)(C,{name:`chevron`,size:`small`})}),children:[(0,X.jsx)(C,{name:`files`}),(0,X.jsx)(`span`,{className:`tree-name`,title:e.id,children:e.displayName})]}),a.has(e.id)&&(0,X.jsx)(Q,{owner:e.id,selected:n,onSession:i,focused:s,onFocus:c},`${e.id}/${t}`)]},e.id))})}function Q({owner:e,selected:t,onSession:n,focused:i,onFocus:a}){let{request:o}=b(),s=(0,I.useCallback)(t=>o(`sessions?${new URLSearchParams({owner:e,limit:`50`,order:`title`})}`,G,{signal:t}),[e,o]),c=E(s,15e3),[l,u]=(0,I.useState)(),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(``),h=(0,I.useRef)(null);(0,I.useEffect)(()=>()=>h.current?.abort(),[]);let _=l?l.nextCursor:c.data?.nextCursor;return(0,X.jsxs)(`div`,{role:`group`,"aria-busy":c.loading||d,children:[(0,X.jsx)(g,{error:!0,children:c.error||p}),c.error&&(0,X.jsx)(`button`,{onClick:()=>void c.reload(),children:`重试`}),c.loading&&!c.data&&(0,X.jsx)(`span`,{className:`tree-status`,role:`status`,children:`正在加载…`}),[...new Map([...l?.sessions??[],...c.data?.sessions??[]].map(e=>[e.sessionKey,e])).values()].sort((e,t)=>P(e.title,t.title)||P(e.sessionKey,t.sessionKey)).map(o=>(0,X.jsxs)(O,{type:`button`,role:`treeitem`,"aria-level":2,"aria-selected":t?.owner===e&&t.key===o.sessionKey,className:`tree-item`,style:{"--tree-level":2},tabIndex:i===`${e}/${o.sessionKey}`?0:-1,"data-testid":`session-row`,"data-owner-id":e,"data-session-key":o.sessionKey,title:r(o.title||o.nativeId),onFocus:()=>a(`${e}/${o.sessionKey}`),onClick:()=>n({owner:e,key:o.sessionKey,title:o.title||o.nativeId}),leading:(0,X.jsx)(`span`,{className:`tree-chevron`}),children:[(0,X.jsx)(C,{name:`sessions`}),(0,X.jsx)(`span`,{className:`tree-name`,children:r(o.title||o.nativeId)})]},o.sessionKey)),_!=null&&(0,X.jsx)(`button`,{className:`tree-action`,"data-testid":`session-tree-more`,disabled:d,onClick:async()=>{f(!0),m(``);let t=new AbortController;h.current=t;try{let n=await o(`sessions?${new URLSearchParams({owner:e,after:String(_),limit:`50`,order:`title`})}`,G,{signal:t.signal});u(e=>({sessions:[...e?.sessions??[],...n.sessions],nextCursor:n.nextCursor}))}catch(e){t.signal.aborted||m(T(e))}finally{t.signal.aborted||f(!1)}},children:`加载更多`})]})}function $({info:e}){let[t,n]=(0,I.useState)(!1);return(0,X.jsxs)(`details`,{className:`session-handoff`,onToggle:e=>n(e.currentTarget.open),children:[(0,X.jsx)(`summary`,{children:`交接说明`}),t&&(0,X.jsx)(ee,{info:e})]})}function ee({info:e}){let{request:t}=b(),n=`sessions/${encodeURIComponent(e.owner)}/${e.sessionKey}`,r=(0,I.useCallback)(e=>t(`${n}/analysis/handoff`,V,{signal:e}),[t,n]),i=E(r,5e3),a=u(),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(``),d=i.data,f=o||d?.status===`queued`||d?.status===`running`,p=d?.result&&`markdown`in d.result?d.result.markdown:void 0;return(0,X.jsxs)(`div`,{className:`stack`,"data-testid":`session-handoff`,children:[(0,X.jsx)(g,{error:!0,children:c||i.error}),d&&(0,X.jsxs)(`div`,{className:`inline-actions`,children:[(!p||d.stale)&&(0,X.jsx)(`button`,{"data-testid":`session-handoff-generate`,disabled:f||!d.available,onClick:async()=>{s(!0),l(``);try{await t(`${n}/handoff`,V,{method:`POST`,signal:a}),await i.reload()}catch(e){a.aborted||l(T(e))}finally{a.aborted||s(!1)}},children:f?`正在整理…`:d.status===`failed`?`重新生成`:p?`更新交接说明`:`生成交接说明`}),!d.available&&(0,X.jsx)(`small`,{children:`请先配置项目模型接入点`}),d.status===`failed`&&(0,X.jsx)(`small`,{children:`整理未完成,可重试`}),d.stale&&(0,X.jsx)(`small`,{children:`对话已有新内容`}),d.currentRevision!==e.revision&&(0,X.jsx)(`small`,{children:`交接说明使用最新对话;当前阅读的是历史原文`})]}),p&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`small`,{children:[`基于版本 `,d.sourceRevision,` · `,(0,X.jsx)(w,{value:d.generatedAt})]}),(0,X.jsx)(`div`,{className:`markdown`,"data-testid":`session-handoff-body`,children:(0,X.jsx)(M,{children:p})})]})]})}function te({members:e}){let{request:t,projectId:n}=b(),i=(0,I.useCallback)(e=>t(`sessions/stats`,K,{signal:e}),[t]),a=E(i,!0),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,p]=(0,I.useState)(0),[m]=(0,I.useState)(()=>Y(location.search)),[_,y]=(0,I.useState)(m.target),[x,S]=(0,I.useState)(m.target),[C,w]=(0,I.useState)(m.error??``),[T,D]=(0,I.useState)(``),O=(0,I.useRef)(null),A=_?.key?_.title?`搜索对话:${r(_.title)}`:`搜索当前对话`:_?`搜索:${e.find(e=>e.id===_.owner)?.displayName??_.owner} 的对话内容`:``,j=()=>{y(void 0),D(``),M(),O.current?.focus()};function M(){if(!x?.messageId)return;let{messageId:e,...t}=x;S(t),history.replaceState(null,``,v(N(n,t.owner,t.key,t)))}let P=(0,I.useCallback)(e=>{y(t=>t?.owner===e.owner&&t.key===e.sessionKey&&t.title!==e.title?{...t,title:e.title}:t)},[]);(0,I.useEffect)(()=>{let e=()=>{let e=Y(location.search);S(e.target),y(e.target),w(e.error??``),l(``),s(``),D(``)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let F=(e,t=``)=>{S(e),y(e),l(``),D(t),w(``),history.replaceState(null,``,v(N(n,e.owner,e.key,e)))};return(0,X.jsxs)(`div`,{className:`split-layout file-explorer session-explorer`,children:[(0,X.jsxs)(`section`,{className:`file-tree-pane`,"aria-label":`${h.sessions}目录`,children:[(0,X.jsx)(k,{title:h.sessions,icon:`sessions`,count:(0,X.jsx)(`span`,{"data-testid":`session-total`,children:a.data?.totalSessions??`—`}),children:(0,X.jsx)(f,{icon:`refresh`,label:`刷新${h.sessions}`,"data-testid":`sessions-refresh`,disabled:a.loading,onClick:()=>{a.reload(),p(e=>e+1)}})}),(0,X.jsx)(g,{error:!0,children:a.error}),(0,X.jsx)(Z,{members:e,refresh:u,selected:_,onOwner:e=>{y({owner:e}),S(void 0),l(``),D(``),w(``),history.replaceState(null,``,v(`/projects/${encodeURIComponent(n)}/sessions`))},onSession:F})]}),(0,X.jsxs)(`section`,{className:`session-reader`,"aria-label":`对话内容与搜索`,children:[(0,X.jsx)(`div`,{className:`session-reader-content`,children:C?(0,X.jsx)(g,{error:!0,children:C}):c?(0,X.jsx)(ne,{query:c,refresh:u,scope:{..._?{owner:_.owner}:{},..._?.key?{sessionKey:_.key}:{}},onSelect:e=>F(e,c)},`${c}/${_?.owner??``}/${_?.key??``}`):x?(0,X.jsx)(re,{selection:x,highlight:T,onLoaded:P,onLatest:()=>F({owner:x.owner,key:x.key})},`${x.owner}/${x.key}/${x.revision}/${u}`):(0,X.jsx)(d,{mascot:!0,title:`选择对话开始阅读`,description:`也可以在下方搜索对话内容。`})}),(0,X.jsxs)(`form`,{className:`session-search-dock`,"data-testid":`session-search-form`,onSubmit:e=>{e.preventDefault(),l(o.trim()),D(``),w(``),p(e=>e+1)},children:[_&&(0,X.jsxs)(`button`,{type:`button`,className:`search-scope-chip`,"data-testid":`session-search-scope`,title:`清除搜索范围`,"aria-label":`清除范围:${A}`,onClick:j,children:[(0,X.jsx)(`span`,{className:`scope-label`,children:A}),(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`×`})]}),(0,X.jsxs)(`div`,{className:`session-search-input-row`,children:[(0,X.jsx)(`input`,{ref:O,"aria-label":`搜索对话`,"data-testid":`session-query`,value:o,maxLength:500,placeholder:`搜索对话内容`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Backspace`&&!o&&_&&(e.preventDefault(),j())}}),(c||o||T)&&(0,X.jsx)(f,{icon:`close`,label:`清空搜索`,"data-testid":`session-search-clear`,onClick:()=>{s(``),l(``),D(``),M(),O.current?.focus()}}),(0,X.jsx)(f,{icon:`search`,type:`submit`,label:`搜索`,"data-testid":`session-search`,disabled:!o.trim()})]})]})]})]})}function ne({query:e,refresh:t,scope:n,onSelect:i}){let{request:a}=b(),[o,s]=(0,I.useState)(0),c=(0,I.useCallback)(t=>a(`sessions/search?${new URLSearchParams({q:e,after:String(o),limit:`30`,...n.owner?{owner:n.owner}:{},...n.sessionKey?{sessionKey:n.sessionKey}:{}})}`,q,{signal:t}),[a,e,o,t,n.owner,n.sessionKey]),l=E(c);return(0,X.jsxs)(`section`,{className:`session-results stack`,"aria-label":`搜索结果`,"aria-busy":l.loading,children:[(0,X.jsx)(g,{error:!0,children:l.error}),l.error&&(0,X.jsx)(`button`,{onClick:()=>void l.reload(),children:`重试`}),l.loading&&(0,X.jsx)(`p`,{role:`status`,children:`正在搜索…`}),!l.loading&&l.data?.matches.map(t=>(0,X.jsxs)(`button`,{className:`session-item`,"data-testid":`session-match`,"data-message-id":t.messageId,onClick:()=>i({owner:t.owner,key:t.sessionKey,revision:t.revision,messageId:t.messageId,title:t.title}),children:[(0,X.jsx)(`strong`,{children:r(t.title)}),(0,X.jsxs)(`small`,{children:[t.owner,` · `,t.role===`user`?`用户`:`助手`]}),(0,X.jsx)(`span`,{className:`session-excerpt`,children:(0,X.jsx)(A,{value:j(t.snippet,e),query:e})})]},`${t.owner}:${t.sessionKey}:${t.revision}:${t.messageId}`)),!l.loading&&l.data?.matches.length===0&&(0,X.jsx)(`p`,{className:`empty`,children:`没有找到匹配的对话`}),l.data?.nextCursor!=null&&(0,X.jsx)(`button`,{"data-testid":`sessions-next`,disabled:l.loading,onClick:()=>s(l.data.nextCursor),children:`下一页`}),o>0&&(0,X.jsx)(`button`,{disabled:l.loading,onClick:()=>s(0),children:`返回第一页`})]})}function re({selection:e,highlight:t,onLoaded:n,onLatest:r}){let{request:a}=b(),o=(0,I.useCallback)(async t=>{try{return await a(`sessions/${encodeURIComponent(e.owner)}/${e.key}${e.revision===void 0?``:`?revision=${e.revision}`}`,W,{signal:t})}catch(e){throw e instanceof i&&e.code===`SESSION_NOT_FOUND`?Error(`找不到这条对话或引用的版本,原链接可能已失效。`):e}},[a,e.owner,e.key,e.revision]),s=E(o,5e3);return(0,I.useEffect)(()=>{s.data&&n(s.data)},[s.data,n]),(0,X.jsxs)(`section`,{className:`session-conversation stack`,"data-testid":`session-detail`,children:[(0,X.jsx)(g,{error:!0,children:s.error}),s.error&&(0,X.jsx)(`button`,{onClick:()=>void s.reload(),children:`重试`}),s.loading&&!s.data&&(0,X.jsx)(`p`,{role:`status`,children:`正在读取对话…`}),s.data&&(0,X.jsx)(ie,{info:s.data,messageId:e.messageId,highlight:t,pinned:e.revision!==void 0,onLatest:r},s.data.blob.sha256)]})}function ie({info:e,messageId:t,highlight:n,pinned:i,onLatest:a}){let{readTextBlob:o,projectId:s}=b(),c=(0,I.useCallback)(async t=>U.parse(JSON.parse(await o(e.blob,t))),[e.blob.sha256,e.blob.size]),l=E(c),u=(0,I.useRef)(null);return(0,I.useEffect)(()=>{l.data&&t&&u.current?.scrollIntoView({block:`center`})},[l.data,t]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`header`,{className:`conversation-header`,children:[(0,X.jsx)(`h2`,{className:`session-title`,children:r(e.title||e.nativeId)}),(0,X.jsxs)(`p`,{children:[e.owner,` · `,e.agent,` · `,e.messageCount,` 条消息`]}),(0,X.jsxs)(`small`,{children:[(0,X.jsx)(w,{value:e.updatedAt}),i&&(0,X.jsxs)(X.Fragment,{children:[` `,`· 引用版本 `,e.revision,` ·`,` `,(0,X.jsx)(`a`,{href:v(N(s,e.owner,e.sessionKey)),onClick:e=>{e.preventDefault(),a()},children:`查看最新`})]})]}),e.overview&&(0,X.jsx)(`p`,{"data-testid":`session-summary`,children:e.overview.summary}),e.overview?.stale&&(0,X.jsx)(`small`,{children:`摘要待更新`})]}),(0,X.jsx)($,{info:e}),(0,X.jsx)(g,{error:!0,children:l.error}),l.error&&(0,X.jsx)(`button`,{onClick:()=>void l.reload(),children:`重新读取`}),l.loading&&(0,X.jsx)(`p`,{role:`status`,children:`正在读取对话…`}),l.data&&(0,X.jsxs)(X.Fragment,{children:[t&&!l.data.messages.some(e=>e.id===t)&&(0,X.jsx)(g,{children:`该版本中找不到引用的消息,已打开对话原文。`}),(0,X.jsx)(`div`,{className:`session-messages`,children:l.data.messages.map(e=>(0,X.jsxs)(`article`,{className:`session-message ${e.role} ${e.id===t?`matched`:``}`,"data-testid":`session-message`,"data-message-id":e.id,ref:e.id===t?u:void 0,children:[(0,X.jsx)(`div`,{className:`message-role`,children:e.role===`user`?`用户`:`助手`}),(0,X.jsx)(`div`,{className:`markdown`,children:(0,X.jsx)(M,{highlight:n,children:e.text})})]},e.id))})]})]})}export{te as Sessions};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{at as e,m as t,r as n,u as r,w as i,x as a,y as o}from"./project-context-ClIYZ2Zu.js";import{a as s,c,o as l}from"./index-B02ttZKr.js";var u=e(),d=new Intl.Collator(`zh-CN`,{numeric:!0,sensitivity:`base`});function f(e,t){return d.compare(e,t)||(e<t?-1:+(e>t))}var p=o();function m(e){let t=e.target.closest(`[role="treeitem"]`);if(!t)return;let n=[...e.currentTarget.querySelectorAll(`[role="treeitem"]`)],r=n.indexOf(t),i=Number(t.getAttribute(`aria-level`)),a;switch(e.key){case`ArrowDown`:a=n[r+1];break;case`ArrowUp`:a=n[r-1];break;case`Home`:a=n[0];break;case`End`:a=n.at(-1);break;case`ArrowRight`:t.getAttribute(`aria-expanded`)===`false`?t.click():Number(n[r+1]?.getAttribute(`aria-level`))>i&&(a=n[r+1]);break;case`ArrowLeft`:t.getAttribute(`aria-expanded`)===`true`?t.click():a=n.slice(0,r).reverse().find(e=>Number(e.getAttribute(`aria-level`))<i);break;default:return}e.preventDefault(),a?.focus()}var h=(e,t)=>`${e}/${t}`,g=e=>({"--tree-level":e});function _({members:e,...t}){let[n,r]=(0,u.useState)(`folder:${h(e[0]?.id??``,``)}`);return(0,p.jsx)(`div`,{role:`tree`,"aria-label":`工作区文件`,"data-testid":`workspace-tree`,onKeyDown:m,children:(0,p.jsx)(y,{owner:s,path:``,level:1,members:e,context:{...t,focused:n,onFocus:r}})})}function v({owner:e,path:t,level:n,context:i}){let a=i.expanded.has(h(e,t)),o=`folder:${h(e,t)}`;return(0,p.jsxs)(`div`,{role:`none`,children:[(0,p.jsxs)(c,{type:`button`,role:`treeitem`,className:`tree-item tree-folder`,style:g(n),"aria-label":t||e,"aria-level":n,"aria-expanded":a,"aria-selected":i.selected?.kind===`directory`&&i.selected.owner===e&&i.selected.path===t,tabIndex:i.focused===o?0:-1,"data-testid":`directory-row`,"data-owner-id":e,"data-directory-path":t,onFocus:()=>i.onFocus(o),onClick:()=>i.onToggle(e,t),leading:(0,p.jsx)(`span`,{className:`tree-chevron ${a?`expanded`:``}`,children:(0,p.jsx)(r,{name:`chevron`,size:`small`})}),children:[(0,p.jsx)(r,{name:`files`}),(0,p.jsx)(`span`,{className:`tree-name`,children:t.split(`/`).at(-1)||e})]}),a&&(0,p.jsx)(y,{owner:e,path:t,level:n+1,context:i})]})}function y({owner:e,path:o,level:s,context:d,members:m=[]}){let{api:_}=n(),y=(0,u.useCallback)(t=>_.tree(e,o,void 0,``,t),[e,o]),b=a(y),[x,S]=(0,u.useState)(),[C,w]=(0,u.useState)(!1),[T,E]=(0,u.useState)(``),D=(0,u.useRef)(null);(0,u.useEffect)(()=>()=>D.current?.abort(),[]);let O=x?x.nextCursor:b.data?.nextCursor;async function k(){if(!O||!b.data||C)return;w(!0),E(``);let t=new AbortController;D.current=t;try{let n=await _.tree(e,o,b.data.revision,O,t.signal);t.signal.aborted||S({...n,entries:[...x?.entries??[],...n.entries]})}catch(e){t.signal.aborted||E(i(e))}finally{t.signal.aborted||w(!1)}}let A=[...(b.data?.entries??[]).filter(e=>!l(e.path)),...(x?.entries??[]).filter(e=>!l(e.path))],j=d.revealed;if(j?.owner===e&&!l(j.path)&&(!o||j.path.startsWith(o+`/`))){let e=o?j.path.slice(o.length+1):j.path,t=e.indexOf(`/`),n=t<0?j.path:[o,e.slice(0,t)].filter(Boolean).join(`/`);A.some(e=>e.path===n)||A.push(t<0?{...j.file,kind:`file`}:{kind:`directory`,path:n})}let M=[...A.map(t=>({...t,owner:e})),...m.map(e=>({kind:`directory`,path:``,owner:e.id}))].sort((e,t)=>e.kind===t.kind?f(e.path.split(`/`).at(-1)||e.owner,t.path.split(`/`).at(-1)||t.owner):e.kind===`directory`?-1:1);return(0,p.jsxs)(`div`,{role:`group`,"aria-label":h(e===`_project`?`workspaces`:e,o),"aria-busy":b.loading||C,children:[b.loading&&(0,p.jsx)(`p`,{className:`tree-status`,role:`status`,children:`正在加载…`}),(0,p.jsx)(t,{error:!0,children:b.error||T}),b.error&&(0,p.jsx)(`button`,{className:`tree-action`,onClick:()=>void b.reload(),children:`重试`}),M.map(t=>t.kind===`directory`?(0,p.jsx)(v,{owner:t.owner,path:t.path,level:s,context:d},h(t.owner,t.path)):(0,p.jsxs)(c,{type:`button`,role:`treeitem`,className:`tree-item`,style:g(s),"aria-label":t.path,"aria-level":s,"aria-selected":d.selected?.kind===`file`&&d.selected.owner===e&&d.selected.path===t.path,tabIndex:d.focused===`file:${h(e,t.path)}`?0:-1,"data-testid":`file-row`,"data-owner-id":e,"data-file-path":t.path,onFocus:()=>d.onFocus(`file:${h(e,t.path)}`),onClick:()=>d.onSelect(e,t.path),leading:(0,p.jsx)(`span`,{className:`tree-chevron`}),children:[(0,p.jsx)(r,{name:`file`}),(0,p.jsx)(`span`,{className:`tree-name`,children:t.path.split(`/`).at(-1)})]},t.path)),O&&(0,p.jsx)(`button`,{className:`tree-action`,"data-testid":`files-load-more`,disabled:C,onClick:()=>void k(),children:C?`正在加载…`:`加载更多`})]})}export{f as i,h as n,m as r,_ as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{G as e}from"./project-context-ClIYZ2Zu.js";function t(t,n){if(!n||/^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(n))return null;try{let r=n.split(/[?#]/,1)[0],i=r?t.split(`/`).slice(0,-1):t.split(`/`);for(let e of r.split(`/`)){let t=decodeURIComponent(e);if(t&&t!==`.`){if(t===`..`){if(!i.length)return null;i.pop()}else{if(t.includes(`/`)||t.includes(`\\`))return null;i.push(t)}}}return{path:i.length?e.parse(i.join(`/`)):``,directory:r.endsWith(`/`),anchor:n.includes(`#`)?decodeURIComponent(n.slice(n.indexOf(`#`)+1)):``}}catch{return null}}export{t};
|