branch-lens 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/dist/cli.js +5620 -3272
- package/dist/cpuWorker.js +1988 -0
- package/dist/launcher.d.ts +68 -15
- package/dist/launcher.js +6966 -4617
- package/dist/web/assets/AiAnnotator-CCj1dKr0.js +1 -0
- package/dist/web/assets/ChronicleStage-Cznb0SLP.js +30 -0
- package/dist/web/assets/CodeDiffStage-BAkeoFAz.js +3 -0
- package/dist/web/assets/CodexSessionBindingFields-DkR0bGRW.js +1 -0
- package/dist/web/assets/CompareStage-6mAMGmE9.js +2 -0
- package/dist/web/assets/CompareStage-DMkd60zd.css +1 -0
- package/dist/web/assets/DoctorChecklist-cmvmLa4s.js +1 -0
- package/dist/web/assets/ExecutionTraceView-BuKMTJLz.js +1 -0
- package/dist/web/assets/LiquidSelect-BcHivJrw.js +1 -0
- package/dist/web/assets/LogDrawer-hywJ_5f2.js +1 -0
- package/dist/web/assets/{PrDraftModal-DpkvQrsw.js → PrDraftModal-CKdIoZTF.js} +2 -12
- package/dist/web/assets/ResponsiveMatrixStage-IZfS6JC4.js +1 -0
- package/dist/web/assets/RouteBar-CbnzrFM4.js +1 -0
- package/dist/web/assets/SafeMarkdownBody-DAg3yHJ5.js +1 -0
- package/dist/web/assets/SettingsModal-CfMz0_4F.js +4 -0
- package/dist/web/assets/{TaskComposer-EPlw68x5.js → TaskComposer-CO8tCqFg.js} +5 -5
- package/dist/web/assets/TaskPanel--8Ima6hX.js +5 -0
- package/dist/web/assets/VerificationSummaryCard-D5fnYeAl.js +1 -0
- package/dist/web/assets/VerificationView-OYxRYOMD.js +1 -0
- package/dist/web/assets/WelcomeDoctorView-DCmfWMhg.js +1 -0
- package/dist/web/assets/annotate-Cnu9ugkR.css +1 -0
- package/dist/web/assets/doctor-BvSbLVK8.css +1 -0
- package/dist/web/assets/index-B76NgI6o.css +1 -0
- package/dist/web/assets/index-CuRBE0Be.js +3 -0
- package/dist/web/assets/logs-_ws1o3oK.css +1 -0
- package/dist/web/assets/pickedElement-DWJDcr9q.js +1 -0
- package/dist/web/assets/settings-DaDpE3K8.css +1 -0
- package/dist/web/assets/stageCache-nD7q31wP.js +1 -0
- package/dist/web/assets/tasks-BYC2JuuF.css +1 -0
- package/dist/web/assets/vendor-icons-BeN0on9X.js +371 -0
- package/dist/web/assets/vendor-markdown-COdlM-u6.js +14 -0
- package/dist/web/assets/vendor-react-CIotE-6Q.js +49 -0
- package/dist/web/index.html +9 -2
- package/package.json +1 -1
- package/dist/web/assets/AiAnnotator-zRRz7Hd_.js +0 -21
- package/dist/web/assets/ChronicleStage-DU21HBDf.js +0 -30
- package/dist/web/assets/CodeDiffStage-DAhgBZQK.js +0 -23
- package/dist/web/assets/CodexSessionBindingFields-DiO2jbce.js +0 -1
- package/dist/web/assets/CompareStage-BJ8Jwxc8.js +0 -37
- package/dist/web/assets/DoctorChecklist-C6zhApVB.js +0 -11
- package/dist/web/assets/ExecutionTraceView-BJm89dCg.js +0 -21
- package/dist/web/assets/ResponsiveMatrixStage-Df2JDBnc.js +0 -6
- package/dist/web/assets/RouteBar-DgHUPTd-.js +0 -1
- package/dist/web/assets/SafeMarkdownBody-CqB1wBws.js +0 -14
- package/dist/web/assets/SettingsModal-BUP_V44u.js +0 -9
- package/dist/web/assets/VerificationView-CQZlUjOa.js +0 -1
- package/dist/web/assets/WelcomeDoctorView-Cdemm1Gq.js +0 -6
- package/dist/web/assets/book-open-J84boHt9.js +0 -6
- package/dist/web/assets/chevron-up-BNxyonTB.js +0 -6
- package/dist/web/assets/external-link-BOTi_FMk.js +0 -6
- package/dist/web/assets/git-commit-horizontal-fzBJ5V7a.js +0 -11
- package/dist/web/assets/index-DOHn8ygK.js +0 -254
- package/dist/web/assets/index-_5gNstnt.css +0 -1
- package/dist/web/assets/info-kubeg88y.js +0 -6
- package/dist/web/assets/pickedElement-p10cew5p.js +0 -11
- package/dist/web/assets/search-CZutG0ij.js +0 -6
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
* @license lucide-react v0.503.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const se=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],ae=_("download",se);/**
|
|
7
|
-
* @license lucide-react v0.503.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const te=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],re=_("hard-drive",te),ne={annotated:"红框标注",diff:"像素差异",base:"改前原版",target:"改后新版"},le={frontend:"前端",backend:"后端",config:"配置",test:"测试",other:"其他"},ie=/^\/api\/assets\/(?:[\w-]+\/)*[\w-]+\.png$/;function ce(a){return ie.test(a)||a.startsWith("data:image/png;base64,")}function oe(a,n){const i=n.replace(/[\r\n]+/g," ").trim();if(!i||!a.startsWith("# "))return a;const o=a.indexOf(`
|
|
1
|
+
import{r as c,j as e}from"./vendor-react-CIotE-6Q.js";import{u as O,k as L,q as W,S as q,s as H,b as z,c as K}from"./index-CuRBE0Be.js";import{T as G,s as J,C as A,j as Y,D as Q,J as V,F as X,a as Z,K as ee,L as se}from"./vendor-icons-BeN0on9X.js";const ae={annotated:"红框标注",diff:"像素差异",base:"改前原版",target:"改后新版"},te={frontend:"前端",backend:"后端",config:"配置",test:"测试",other:"其他"},re=/^\/api\/assets\/(?:[\w-]+\/)*[\w-]+\.png$/;function ne(a){return re.test(a)||a.startsWith("data:image/png;base64,")}function le(a,n){const i=n.replace(/[\r\n]+/g," ").trim();if(!i||!a.startsWith("# "))return a;const o=a.indexOf(`
|
|
12
2
|
`);return o===-1?`# ${i}`:`# ${i}${a.slice(o)}`}function $(a,n){const i=a.replace(/[\r\n]+/g," ").trim();return!i||n.trimStart().startsWith("# ")?n:`# ${i}
|
|
13
3
|
|
|
14
|
-
${n}`}function de(a){return`pr-draft-${((a==null?void 0:a.taskId)||(a==null?void 0:a.targetRef)||"draft").toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)||"draft"}.md`}const xe=({open:a,request:n,onClose:i})=>{const o=O(s=>s.pushToast),[x,b]=c.useState("edit"),[f,y]=c.useState(!1),[g,j]=c.useState(!1),[M,h]=c.useState(null),[r,k]=c.useState(null),[N,m]=c.useState(""),[v,p]=c.useState(""),[w,R]=c.useState(null),[D,S]=c.useState(!1),u=c.useRef(0),E=c.useRef(n);E.current=n;const T=n?JSON.stringify([n.taskId??"",n.baseRef??"",n.targetRef??"",n.annotationCacheKey??"",n.includeDiffExplain??!0]):"",P=c.useCallback(async()=>{const s=E.current;if(!s)return;const t=++u.current;y(!0),h(null),R(null),S(!1);try{const l=await L.generatePrDraft({...s,includeDiffExplain:s.includeDiffExplain??!0,saveArtifact:!1});if(t!==u.current)return;k(l),m(l.title),p(l.markdown),R(l.savedPath??null)}catch(l){if(t!==u.current)return;h(l instanceof Error?l.message:String(l))}finally{t===u.current&&y(!1)}},[]);c.useEffect(()=>{if(!a||!T){u.current+=1,y(!1),j(!1);return}b("edit"),k(null),m(""),p(""),P()},[a,T,P]);const F=s=>{m(s),p(t=>oe(t,s))},U=async()=>{const s=$(N,v);if(!s.trim())return;await Z(s)?(S(!0),setTimeout(()=>S(!1),2e3),o({tone:"success",title:"已复制 PR Markdown",detail:"可直接粘贴到 GitHub / GitLab PR 描述框。",durationMs:3500})):o({tone:"warning",title:"复制失败",detail:"当前环境不支持自动写入剪贴板,请手动全选复制。",durationMs:4e3})},I=async()=>{const s=E.current;if(!(!s||g)){j(!0),h(null);try{const t=await L.generatePrDraft({...s,includeDiffExplain:s.includeDiffExplain??!0,saveArtifact:!0});R(t.savedPath??null),r||(k(t),m(t.title),p(t.markdown)),o({tone:"success",title:"已保存为本地 .md",detail:t.savedPath?`文件位置:${t.savedPath}`:"已保存至本地 PR 产物目录。",durationMs:6e3})}catch(t){const l=t instanceof Error?t.message:String(t);h(l),o({tone:"warning",title:"保存本地 .md 失败",detail:l,durationMs:5e3})}finally{j(!1)}}},H=()=>{const s=$(N,v);if(!s.trim())return;const t=new Blob([s],{type:"text/markdown;charset=utf-8"}),l=URL.createObjectURL(t),d=document.createElement("a");d.href=l,d.download=de(r),d.style.display="none",document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(l)},C=!f&&!!r,B=e.jsxs("div",{className:"w-full flex items-center justify-between gap-3 flex-wrap",children:[e.jsx("button",{type:"button",onClick:i,className:"sheet-btn text-xs",children:"关闭"}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",disabled:!C,onClick:()=>void U(),className:"sheet-btn text-xs disabled:opacity-40",children:[D?e.jsx(z,{size:12}):e.jsx(X,{size:12}),e.jsx("span",{children:D?"已复制":"复制 Markdown"})]}),e.jsxs("button",{type:"button",disabled:!C||g,onClick:()=>void I(),className:"sheet-btn text-xs disabled:opacity-40",children:[e.jsx(re,{size:12}),e.jsx("span",{children:g?"保存中…":"保存为本地 .md"})]}),e.jsxs("button",{type:"button",disabled:!C,onClick:H,className:"sheet-btn sheet-btn-primary text-xs disabled:opacity-40",children:[e.jsx(ae,{size:12}),e.jsx("span",{children:"下载 .md"})]})]})]});return e.jsx(W,{open:a,title:"PR 产物预览与导出",onClose:i,maxWidthClass:"max-w-4xl",headerExtra:r?e.jsxs("span",{className:"mono text-[11px] px-2 py-0.5 rounded truncate",style:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair)"},children:[r.baseRef," ← ",r.targetRef]}):void 0,footer:B,children:e.jsxs("div",{className:"space-y-4 text-xs","data-pr-draft-modal":"true",children:[f&&e.jsxs("div",{className:"py-12 flex flex-col items-center justify-center gap-2.5",children:[e.jsx("div",{className:"bl-spinner"}),e.jsx("span",{style:{color:"var(--muted)"},children:"正在汇总改动文件、视觉验收与 AI 讲解…"})]}),M&&!f&&e.jsxs("div",{role:"alert",className:"p-3 rounded-lg flex items-center justify-between gap-3",style:{background:"var(--redline-soft, var(--accent-soft))",border:"1px solid var(--redline, var(--accent))",color:"var(--redline, var(--accent))"},children:[e.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[e.jsx(q,{size:14,className:"shrink-0 mt-0.5"}),e.jsx("span",{className:"break-words",children:M})]}),e.jsxs("button",{type:"button",onClick:()=>void P(),className:"sheet-btn text-xs shrink-0",children:[e.jsx(G,{size:12}),e.jsx("span",{children:"重试"})]})]}),r&&!f&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-3 rounded-lg space-y-2",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mono text-[11.5px]",children:[e.jsxs("span",{className:"font-semibold",style:{color:"var(--ink)"},children:[r.baseRef," ← ",r.targetRef]}),r.taskId&&e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10.5px]",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:["任务 #",r.taskId]})]}),e.jsxs("span",{className:"mono text-[11px]",style:{color:"var(--muted)"},children:[r.changedFiles.length," 个文件"]})]}),r.verificationSummary&&e.jsx("div",{className:"text-[11.5px] leading-relaxed whitespace-pre-line pt-1.5",style:{borderTop:"1px dashed var(--hair)",color:"var(--muted)"},"data-pr-verification-summary":"true",children:r.verificationSummary})]}),w&&e.jsxs("div",{role:"status","data-pr-saved-path":w,className:"p-2.5 rounded-lg flex items-center gap-2 text-[11.5px]",style:{background:"var(--diff-add-bg)",color:"var(--diff-add-ink)",border:"1px solid var(--hair)"},children:[e.jsx(z,{size:13,className:"shrink-0"}),e.jsxs("span",{className:"mono break-all select-all",children:["已保存至:",w]})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"caps",children:"PR 标题"}),e.jsx("input",{type:"text","aria-label":"PR 标题",value:N,onChange:s=>F(s.target.value),className:"sheet-input w-full h-9 text-[13px] font-medium",placeholder:"输入 PR 标题…"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{role:"tablist","aria-label":"PR Markdown 视图切换",className:"bl-surface-tabs inline-flex items-center gap-1",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":x==="edit","data-active":x==="edit"?"true":void 0,onClick:()=>b("edit"),className:"bl-surface-tab",children:[e.jsx(K,{size:12}),e.jsx("span",{children:"源码编辑"})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":x==="preview","data-active":x==="preview"?"true":void 0,onClick:()=>b("preview"),className:"bl-surface-tab",children:[e.jsx(J,{size:12}),e.jsx("span",{children:"安全预览"})]})]}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--faint)"},children:"预览经 SafeMarkdown 消毒渲染"})]}),x==="edit"?e.jsx("textarea",{"aria-label":"PR Markdown 内容",value:v,onChange:s=>p(s.target.value),rows:14,className:"w-full p-3 mono text-[11.5px] leading-relaxed rounded-lg outline-none resize-y",style:{background:"var(--bg)",border:"1px solid var(--hair-strong)",color:"var(--ink)"}}):e.jsx("div",{"data-pr-markdown-preview":"true",className:"p-3.5 rounded-lg max-h-[340px] overflow-y-auto",style:{background:"var(--bg)",border:"1px solid var(--hair-strong)"},children:e.jsx(Y,{content:v})})]}),r.assets.length>0&&e.jsxs("div",{className:"space-y-2","data-pr-assets":"true",children:[e.jsx("div",{className:"flex items-center justify-between gap-2",children:e.jsxs("span",{className:"caps",children:["视觉对比截图资产(",r.assets.length,")"]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2.5",children:r.assets.map(s=>{const t=ce(s.url),l=t?Q(s.url):"";return e.jsxs("div",{"data-pr-asset-kind":s.kind,className:"rounded-lg overflow-hidden flex flex-col",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[t?e.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"block relative aspect-[16/10] overflow-hidden group",style:{borderBottom:"1px solid var(--hair)",background:"var(--bg)"},title:"在新标签页查看大图",children:[e.jsx("img",{src:l,alt:s.label,className:"w-full h-full object-cover object-top block"}),e.jsx("span",{className:"absolute right-2 top-2 p-1 rounded opacity-0 group-hover:opacity-100 transition-opacity",style:{background:"rgba(15, 23, 42, 0.65)",color:"#fff"},children:e.jsx(ee,{size:11})})]}):e.jsx("div",{className:"aspect-[16/10] flex items-center justify-center text-[11px] px-3 text-center",style:{borderBottom:"1px solid var(--hair)",color:"var(--faint)"},children:"不可信截图地址已拦截"}),e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-[11.5px] truncate",children:s.label}),e.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded shrink-0",style:{background:"var(--bg)",color:"var(--muted)",border:"1px solid var(--hair)"},children:ne[s.kind]??s.kind})]}),s.filePath&&e.jsx("div",{className:"mono text-[10.5px] truncate select-all",style:{color:"var(--faint)"},title:s.filePath,children:s.filePath})]})]},`${s.kind}-${s.url}`)})})]}),r.changedFiles.length>0&&e.jsxs("details",{className:"rounded-lg p-2.5",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[e.jsxs("summary",{className:"cursor-pointer select-none flex items-center gap-1.5 font-medium text-[11.5px]",children:[e.jsx(V,{size:12,style:{color:"var(--accent)"}}),e.jsxs("span",{children:["改动文件清单(",r.changedFiles.length," 个文件)"]})]}),e.jsx("ul",{className:"mt-2 space-y-1 max-h-[180px] overflow-y-auto mono text-[11px]",children:r.changedFiles.map(s=>e.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",style:{borderTop:"1px solid var(--hair)"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"px-1 rounded text-[10px] shrink-0",style:{background:"var(--bg)",color:"var(--muted)"},children:s.category?le[s.category]:s.isFrontend?"前端":"其他"}),e.jsx("span",{className:"shrink-0",style:{color:"var(--faint)"},children:s.status}),e.jsx("span",{className:"truncate",style:{color:"var(--ink)"},children:s.path})]}),e.jsxs("span",{className:"shrink-0 text-[10.5px]",children:[e.jsxs("span",{style:{color:"var(--diff-add-ink)"},children:["+",s.additions]})," / ",e.jsxs("span",{style:{color:"var(--redline, var(--accent))"},children:["-",s.deletions]})]})]},`${s.status}-${s.path}`))})]})]})]})})},fe=()=>{const a=A(i=>i.prDraftRequest),n=A(i=>i.closePrDraft);return e.jsx(xe,{open:!!a,request:a,onClose:n})};export{xe as PrDraftModal,fe as PrDraftModalHost};
|
|
4
|
+
${n}`}function ie(a){return`pr-draft-${((a==null?void 0:a.taskId)||(a==null?void 0:a.targetRef)||"draft").toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)||"draft"}.md`}const ce=({open:a,request:n,onClose:i})=>{const o=O(s=>s.pushToast),[x,b]=c.useState("edit"),[f,g]=c.useState(!1),[j,y]=c.useState(!1),[D,h]=c.useState(null),[r,k]=c.useState(null),[N,m]=c.useState(""),[v,p]=c.useState(""),[w,R]=c.useState(null),[T,S]=c.useState(!1),u=c.useRef(0),C=c.useRef(n);C.current=n;const M=n?JSON.stringify([n.taskId??"",n.baseRef??"",n.targetRef??"",n.annotationCacheKey??"",n.includeDiffExplain??!0]):"",E=c.useCallback(async()=>{const s=C.current;if(!s)return;const t=++u.current;g(!0),h(null),R(null),S(!1);try{const l=await L.generatePrDraft({...s,includeDiffExplain:s.includeDiffExplain??!0,saveArtifact:!1});if(t!==u.current)return;k(l),m(l.title),p(l.markdown),R(l.savedPath??null)}catch(l){if(t!==u.current)return;h(l instanceof Error?l.message:String(l))}finally{t===u.current&&g(!1)}},[]);c.useEffect(()=>{if(!a||!M){u.current+=1,g(!1),y(!1);return}b("edit"),k(null),m(""),p(""),E()},[a,M,E]);const F=s=>{m(s),p(t=>le(t,s))},U=async()=>{const s=$(N,v);if(!s.trim())return;await K(s)?(S(!0),setTimeout(()=>S(!1),2e3),o({tone:"success",title:"已复制 PR Markdown",detail:"可直接粘贴到 GitHub / GitLab PR 描述框。",durationMs:3500})):o({tone:"warning",title:"复制失败",detail:"当前环境不支持自动写入剪贴板,请手动全选复制。",durationMs:4e3})},_=async()=>{const s=C.current;if(!(!s||j)){y(!0),h(null);try{const t=await L.generatePrDraft({...s,includeDiffExplain:s.includeDiffExplain??!0,saveArtifact:!0});R(t.savedPath??null),r||(k(t),m(t.title),p(t.markdown)),o({tone:"success",title:"已保存为本地 .md",detail:t.savedPath?`文件位置:${t.savedPath}`:"已保存至本地 PR 产物目录。",durationMs:6e3})}catch(t){const l=t instanceof Error?t.message:String(t);h(l),o({tone:"warning",title:"保存本地 .md 失败",detail:l,durationMs:5e3})}finally{y(!1)}}},I=()=>{const s=$(N,v);if(!s.trim())return;const t=new Blob([s],{type:"text/markdown;charset=utf-8"}),l=URL.createObjectURL(t),d=document.createElement("a");d.href=l,d.download=ie(r),d.style.display="none",document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(l)},P=!f&&!!r,B=e.jsxs("div",{className:"w-full flex items-center justify-between gap-3 flex-wrap",children:[e.jsx("button",{type:"button",onClick:i,className:"sheet-btn text-xs",children:"关闭"}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",disabled:!P,onClick:()=>void U(),className:"sheet-btn text-xs disabled:opacity-40",children:[T?e.jsx(A,{size:12}):e.jsx(Z,{size:12}),e.jsx("span",{children:T?"已复制":"复制 Markdown"})]}),e.jsxs("button",{type:"button",disabled:!P||j,onClick:()=>void _(),className:"sheet-btn text-xs disabled:opacity-40",children:[e.jsx(ee,{size:12}),e.jsx("span",{children:j?"保存中…":"保存为本地 .md"})]}),e.jsxs("button",{type:"button",disabled:!P,onClick:I,className:"sheet-btn sheet-btn-primary text-xs disabled:opacity-40",children:[e.jsx(se,{size:12}),e.jsx("span",{children:"下载 .md"})]})]})]});return e.jsx(W,{open:a,title:"PR 产物预览与导出",onClose:i,maxWidthClass:"max-w-4xl",headerExtra:r?e.jsxs("span",{className:"mono text-[11px] px-2 py-0.5 rounded truncate",style:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair)"},children:[r.baseRef," ← ",r.targetRef]}):void 0,footer:B,children:e.jsxs("div",{className:"space-y-4 text-xs","data-pr-draft-modal":"true",children:[f&&e.jsxs("div",{className:"py-12 flex flex-col items-center justify-center gap-2.5",children:[e.jsx("div",{className:"bl-spinner"}),e.jsx("span",{style:{color:"var(--muted)"},children:"正在汇总改动文件、视觉验收与 AI 讲解…"})]}),D&&!f&&e.jsxs("div",{role:"alert",className:"p-3 rounded-lg flex items-center justify-between gap-3",style:{background:"var(--redline-soft, var(--accent-soft))",border:"1px solid var(--redline, var(--accent))",color:"var(--redline, var(--accent))"},children:[e.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[e.jsx(G,{size:14,className:"shrink-0 mt-0.5"}),e.jsx("span",{className:"break-words",children:D})]}),e.jsxs("button",{type:"button",onClick:()=>void E(),className:"sheet-btn text-xs shrink-0",children:[e.jsx(J,{size:12}),e.jsx("span",{children:"重试"})]})]}),r&&!f&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-3 rounded-lg space-y-2",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mono text-[11.5px]",children:[e.jsxs("span",{className:"font-semibold",style:{color:"var(--ink)"},children:[r.baseRef," ← ",r.targetRef]}),r.taskId&&e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10.5px]",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:["任务 #",r.taskId]})]}),e.jsxs("span",{className:"mono text-[11px]",style:{color:"var(--muted)"},children:[r.changedFiles.length," 个文件"]})]}),r.verificationSummary&&e.jsx("div",{className:"text-[11.5px] leading-relaxed whitespace-pre-line pt-1.5",style:{borderTop:"1px dashed var(--hair)",color:"var(--muted)"},"data-pr-verification-summary":"true",children:r.verificationSummary})]}),w&&e.jsxs("div",{role:"status","data-pr-saved-path":w,className:"p-2.5 rounded-lg flex items-center gap-2 text-[11.5px]",style:{background:"var(--diff-add-bg)",color:"var(--diff-add-ink)",border:"1px solid var(--hair)"},children:[e.jsx(A,{size:13,className:"shrink-0"}),e.jsxs("span",{className:"mono break-all select-all",children:["已保存至:",w]})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"caps",children:"PR 标题"}),e.jsx("input",{type:"text","aria-label":"PR 标题",value:N,onChange:s=>F(s.target.value),className:"sheet-input w-full h-9 text-[13px] font-medium",placeholder:"输入 PR 标题…"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{role:"tablist","aria-label":"PR Markdown 视图切换",className:"bl-surface-tabs inline-flex items-center gap-1",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":x==="edit","data-active":x==="edit"?"true":void 0,onClick:()=>b("edit"),className:"bl-surface-tab",children:[e.jsx(Y,{size:12}),e.jsx("span",{children:"源码编辑"})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":x==="preview","data-active":x==="preview"?"true":void 0,onClick:()=>b("preview"),className:"bl-surface-tab",children:[e.jsx(Q,{size:12}),e.jsx("span",{children:"安全预览"})]})]}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--faint)"},children:"预览经 SafeMarkdown 消毒渲染"})]}),x==="edit"?e.jsx("textarea",{"aria-label":"PR Markdown 内容",value:v,onChange:s=>p(s.target.value),rows:14,className:"w-full p-3 mono text-[11.5px] leading-relaxed rounded-lg outline-none resize-y",style:{background:"var(--bg)",border:"1px solid var(--hair-strong)",color:"var(--ink)"}}):e.jsx("div",{"data-pr-markdown-preview":"true",className:"p-3.5 rounded-lg max-h-[340px] overflow-y-auto",style:{background:"var(--bg)",border:"1px solid var(--hair-strong)"},children:e.jsx(q,{content:v})})]}),r.assets.length>0&&e.jsxs("div",{className:"space-y-2","data-pr-assets":"true",children:[e.jsx("div",{className:"flex items-center justify-between gap-2",children:e.jsxs("span",{className:"caps",children:["视觉对比截图资产(",r.assets.length,")"]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2.5",children:r.assets.map(s=>{const t=ne(s.url),l=t?H(s.url):"";return e.jsxs("div",{"data-pr-asset-kind":s.kind,className:"rounded-lg overflow-hidden flex flex-col",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[t?e.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"block relative aspect-[16/10] overflow-hidden group",style:{borderBottom:"1px solid var(--hair)",background:"var(--bg)"},title:"在新标签页查看大图",children:[e.jsx("img",{src:l,alt:s.label,className:"w-full h-full object-cover object-top block"}),e.jsx("span",{className:"absolute right-2 top-2 p-1 rounded opacity-0 group-hover:opacity-100 transition-opacity",style:{background:"rgba(15, 23, 42, 0.65)",color:"#fff"},children:e.jsx(V,{size:11})})]}):e.jsx("div",{className:"aspect-[16/10] flex items-center justify-center text-[11px] px-3 text-center",style:{borderBottom:"1px solid var(--hair)",color:"var(--faint)"},children:"不可信截图地址已拦截"}),e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-[11.5px] truncate",children:s.label}),e.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded shrink-0",style:{background:"var(--bg)",color:"var(--muted)",border:"1px solid var(--hair)"},children:ae[s.kind]??s.kind})]}),s.filePath&&e.jsx("div",{className:"mono text-[10.5px] truncate select-all",style:{color:"var(--faint)"},title:s.filePath,children:s.filePath})]})]},`${s.kind}-${s.url}`)})})]}),r.changedFiles.length>0&&e.jsxs("details",{className:"rounded-lg p-2.5",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[e.jsxs("summary",{className:"cursor-pointer select-none flex items-center gap-1.5 font-medium text-[11.5px]",children:[e.jsx(X,{size:12,style:{color:"var(--accent)"}}),e.jsxs("span",{children:["改动文件清单(",r.changedFiles.length," 个文件)"]})]}),e.jsx("ul",{className:"mt-2 space-y-1 max-h-[180px] overflow-y-auto mono text-[11px]",children:r.changedFiles.map(s=>e.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",style:{borderTop:"1px solid var(--hair)"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"px-1 rounded text-[10px] shrink-0",style:{background:"var(--bg)",color:"var(--muted)"},children:s.category?te[s.category]:s.isFrontend?"前端":"其他"}),e.jsx("span",{className:"shrink-0",style:{color:"var(--faint)"},children:s.status}),e.jsx("span",{className:"truncate",style:{color:"var(--ink)"},children:s.path})]}),e.jsxs("span",{className:"shrink-0 text-[10.5px]",children:[e.jsxs("span",{style:{color:"var(--diff-add-ink)"},children:["+",s.additions]})," / ",e.jsxs("span",{style:{color:"var(--redline, var(--accent))"},children:["-",s.deletions]})]})]},`${s.status}-${s.path}`))})]})]})]})})},pe=()=>{const a=z(i=>i.prDraftRequest),n=z(i=>i.closePrDraft);return e.jsx(ce,{open:!!a,request:a,onClose:n})};export{ce as PrDraftModal,pe as PrDraftModalHost};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,j as t}from"./vendor-react-CIotE-6Q.js";import{V as xe,v as Q,a as k,x as ue,k as pe,s as I,b as me}from"./index-CuRBE0Be.js";import{b as he,m as f}from"./stageCache-nD7q31wP.js";import{Q as fe,s as ge,T as Z,af as ve,J as be,e as je}from"./vendor-icons-BeN0on9X.js";const ye=[{id:"mobile",label:"手机"},{id:"tablet",label:"平板"},{id:"desktop",label:"桌面"},{id:"laptop",label:"笔记本"}],ee=ye.map(({id:x,label:a})=>{const o=xe.find(m=>m.id===x);return{id:x,label:a,width:o.width,height:o.height}}),te=["mobile","tablet","desktop"],Ne=[],se=6,R=12,we=[{id:"annotated",label:"红框标注"},{id:"diff",label:"像素差异"},{id:"target",label:"改后新版"},{id:"base",label:"改前原版"}];function V(x){const a=x.trim();return!a||a.startsWith("//")?"/":a.startsWith("/")?a:`/${a}`}function ke(x,a){switch(a){case"diff":return I(x.diffImageUrl);case"target":return I(x.targetImageUrl);case"base":return I(x.baseImageUrl);default:return I(x.annotatedImageUrl)}}const Me=({branches:x,baseRef:a,targetRef:o,route:m,compareTargets:g,allRoutes:W=Ne,onJumpToViewport:re})=>{const L=Q(e=>e.annotateProgress),O=Q(e=>e.setAnnotateProgress),ae=k(e=>{var s;return((s=e.config)==null?void 0:s.chromePath)===null}),U=k(e=>{var s;return((s=e.repo)==null?void 0:s.repoHash)??null}),z=k(e=>{var s,r;return a?((r=(s=e.repo)==null?void 0:s.branches.find(n=>n.ref===a))==null?void 0:r.sha)??null:null}),B=k(e=>{var s,r;return o?((r=(s=e.repo)==null?void 0:s.branches.find(n=>n.ref===o))==null?void 0:r.sha)??null:null}),c=i.useMemo(()=>he(U,a,o,z,B),[U,a,o,z,B]),K=i.useRef(c);K.current=c;const v=i.useMemo(()=>{const e=new Map,s=(r,n)=>{const l=V(r);e.has(l)||e.set(l,{route:l,label:n||l})};s(m||"/",m||"/");for(const r of g)s(r.route,r.label);for(const r of W)s(r.resolvedRoute,r.label);return Array.from(e.values())},[m,g,W]),h=i.useMemo(()=>{var r;const e=[V(m||"/")],s=(r=g[0])!=null&&r.route?V(g[0].route):null;return s&&!e.includes(s)&&e.push(s),e},[m,g]),[u,S]=i.useState(()=>{const e=c?f.get(c):void 0;return e!=null&&e.selectedRoutes.length?e.selectedRoutes:h}),[$,D]=i.useState(()=>{const e=c?f.get(c):void 0;return e!=null&&e.selectedViewportIds.length?e.selectedViewportIds:te}),[C,q]=i.useState(()=>{const e=c?f.get(c):void 0;return(e==null?void 0:e.layer)??"annotated"}),[E,_]=i.useState(!1),[X,T]=i.useState(null),[p,P]=i.useState(()=>{const e=c?f.get(c):void 0;return(e==null?void 0:e.result)??null}),b=i.useRef(0),F=i.useRef(`${a??""}::${o??""}::${c??""}`);i.useEffect(()=>{const e=`${a??""}::${o??""}::${c??""}`;if(F.current===e)return;F.current=e,b.current+=1,_(!1),T(null);const s=c?f.get(c):void 0;s?(P(s.result),S(s.selectedRoutes.length>0?s.selectedRoutes:h),D(s.selectedViewportIds.length>0?s.selectedViewportIds:te),q(s.layer)):(P(null),S(h))},[a,o,c,h]),i.useEffect(()=>{S(e=>{if(e.length===0)return h;const s=e.filter(r=>v.some(n=>n.route===r));return s.length===e.length?e:s.length>0?s:h})},[v,h]);const M=i.useMemo(()=>ee.filter(e=>$.includes(e.id)),[$]),j=u.length*M.length,y=!a||!o?"请先选择原版 A 与对比 B 分支":u.length===0||M.length===0?"请至少选择 1 条路由与 1 个视口":u.length>se?`单次最多选择 ${se} 条路由(当前 ${u.length} 条)`:j>R?`单次最多生成 ${R} 格(当前 ${j} 格),请减少路由或视口`:null,A=!E&&!y,ne=e=>{S(s=>s.includes(e)?s.filter(r=>r!==e):[...s,e])},le=e=>{D(s=>s.includes(e)?s.filter(r=>r!==e):[...s,e])},H=async e=>{if(!A||!a||!o)return;const s=++b.current,r=K.current,n=[...u],l=[...$];_(!0),T(null),O(`准备抓取 ${j} 个响应式矩阵格子…`);try{const d=await pe.runResponsiveMatrix({baseRef:a,targetRef:o,routes:u,viewports:M,forceRefresh:e});if(s!==b.current)return;P(d),r&&f.set(r,{result:d,selectedRoutes:n,selectedViewportIds:l,layer:C})}catch(d){if(s!==b.current)return;T(d instanceof Error?d.message:String(d))}finally{s===b.current&&(_(!1),O(""))}},ie=e=>{var Y,G,J;const s=e.annotation;if(!s)return;const r=((Y=k.getState().repo)==null?void 0:Y.branches)??[],n=((G=x.find(w=>w.isCurrent&&!w.isWorkingTree))==null?void 0:G.ref)||((J=r.find(w=>w.isCurrent&&!w.isWorkingTree))==null?void 0:J.ref)||"";let l="",d=!1;o==="__working__"?n?l=n:(l="",d=!0):l=o||"";const N=a&&a!=="__working__"?a:void 0,de=N&&N!==l?N:void 0;me.getState().openComposer({sourceRef:l,...d?{requireExplicitSourceRef:!0}:{},annotationCacheKey:s.cacheKey,regions:s.regions,route:e.route,viewport:{width:e.viewport.width,height:e.viewport.height},compareWith:de,defaultTitle:`修复响应式问题(${e.route} · ${e.viewport.label})`})},oe=i.useMemo(()=>{const e=new Map;for(const s of(p==null?void 0:p.cells)??[])e.set(`${s.route}::${s.viewport.id}`,s);return e},[p]),ce=i.useMemo(()=>new Map(v.map(e=>[e.route,e.label])),[v]);return t.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden","data-matrix-stage":"true",children:[t.jsxs("div",{className:"px-6 py-3 shrink-0 space-y-2.5 text-xs",style:{borderBottom:"1px solid var(--hair)",background:"var(--surface)"},children:[t.jsxs("div",{className:"flex items-start gap-2.5 flex-wrap",children:[t.jsx("span",{className:"caps shrink-0 pt-1",children:"路由多选(1–6)"}),t.jsx("div",{className:"flex items-center gap-1.5 flex-wrap flex-1 min-w-0",children:v.map(e=>{const s=u.includes(e.route);return t.jsxs("button",{type:"button","aria-pressed":s,"data-matrix-route":e.route,onClick:()=>ne(e.route),className:"inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full transition-colors text-[11.5px]",style:{background:s?"var(--accent-soft)":"transparent",color:s?"var(--accent)":"var(--ink)",border:`1px solid ${s?"var(--accent)":"var(--hair-strong)"}`,fontWeight:s?600:450},children:[e.label!==e.route&&t.jsx("span",{children:e.label}),t.jsx("span",{className:"mono text-[10.5px] opacity-80",children:e.route})]},e.route)})})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:"caps shrink-0",children:"视口断点"}),ee.map(e=>{const s=$.includes(e.id);return t.jsxs("button",{type:"button","aria-pressed":s,"data-matrix-viewport":e.id,onClick:()=>le(e.id),className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full transition-colors text-[11.5px]",style:{background:s?"var(--accent-soft)":"transparent",color:s?"var(--accent)":"var(--ink)",border:`1px solid ${s?"var(--accent)":"var(--hair-strong)"}`,fontWeight:s?600:450},children:[t.jsx("span",{children:e.label}),t.jsxs("span",{className:"mono text-[10px] opacity-75",children:[e.width,"×",e.height]})]},e.id)}),t.jsxs("span",{className:"mono text-[11px] px-2 py-0.5 rounded","data-matrix-combo-count":j,style:{background:y?"var(--redline-soft, var(--accent-soft))":"var(--bg)",color:y?"var(--redline, var(--accent))":"var(--muted)",border:"1px solid var(--hair)"},children:[u.length," 路由 × ",M.length," 视口 = ",j,"/",R," 格"]})]}),t.jsxs("div",{className:"flex items-center gap-2.5 flex-wrap",children:[t.jsx("div",{className:"inline-flex items-center gap-1",role:"group","aria-label":"矩阵图面切换",children:we.map(e=>{const s=C===e.id;return t.jsx("button",{type:"button","aria-pressed":s,"data-matrix-layer":e.id,onClick:()=>q(e.id),className:"bl-card-action text-[11.5px]",style:{color:s?"var(--accent)":"var(--muted)",fontWeight:s?600:450},children:e.label},e.id)})}),t.jsxs("button",{type:"button",disabled:!A,onClick:()=>void H(!1),className:"sheet-btn sheet-btn-primary text-xs py-1 px-3 disabled:opacity-40",children:[t.jsx(fe,{size:12}),t.jsx("span",{children:E?"抓取中…":"生成响应式矩阵"})]}),t.jsxs("button",{type:"button",disabled:!A,onClick:()=>void H(!0),className:"sheet-btn text-xs py-1 px-2.5 disabled:opacity-40",title:"忽略缓存,强制重新截图与分析全部选中格子",children:[t.jsx(ge,{size:12,className:E?"animate-spin":void 0}),t.jsx("span",{children:"强制重抓"})]})]})]}),ae&&t.jsx(ue,{context:"matrix"}),y&&t.jsxs("div",{role:"status",className:"text-[11.5px] flex items-center gap-1.5",style:{color:"var(--redline, var(--accent))"},children:[t.jsx(Z,{size:12}),t.jsx("span",{children:y})]}),E&&L&&t.jsxs("div",{role:"status",className:"text-[11.5px] mono flex items-center gap-2",style:{color:"var(--accent)"},children:[t.jsx("span",{className:"bl-picker-dot","aria-hidden":"true"}),t.jsx("span",{children:L})]}),X&&t.jsx("div",{role:"alert",className:"p-2 rounded-lg text-[11.5px]",style:{background:"var(--redline-soft, var(--accent-soft))",color:"var(--redline, var(--accent))"},children:X})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-auto p-5",children:p?t.jsx("div",{className:"bl-matrix-table-wrap overflow-x-auto",children:t.jsxs("table",{className:"bl-matrix-table w-full border-collapse text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:"bl-matrix-th text-left px-3 py-2 w-[180px] align-bottom",style:{color:"var(--muted)"},children:t.jsx("span",{className:"caps",children:"路由 \\ 视口"})}),p.viewports.map(e=>t.jsx("th",{className:"bl-matrix-th text-left px-3 py-2 min-w-[260px]",children:t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("span",{className:"font-semibold",style:{color:"var(--ink)"},children:e.label}),t.jsxs("span",{className:"mono text-[11px]",style:{color:"var(--muted)"},children:[e.width,"×",e.height]})]})},e.id))]})}),t.jsx("tbody",{children:p.routes.map(e=>{const s=ce.get(e);return t.jsxs("tr",{children:[t.jsxs("th",{className:"bl-matrix-rowhead text-left px-3 py-3 align-top",children:[t.jsx("div",{className:"mono font-semibold text-[12px] break-all",style:{color:"var(--ink)"},children:e}),s&&s!==e&&t.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--muted)"},children:s})]}),p.viewports.map(r=>{const n=oe.get(`${e}::${r.id}`);if(!n)return t.jsx("td",{className:"bl-matrix-td p-2.5 align-top",children:t.jsx("div",{className:"text-[11px]",style:{color:"var(--faint)"},children:"无结果"})},r.id);if(n.status==="error"||!n.annotation)return t.jsx("td",{"data-matrix-cell":`${e}::${r.id}`,"data-cell-status":"error",className:"bl-matrix-td p-2.5 align-top",children:t.jsxs("div",{className:"bl-matrix-cell-card p-3 space-y-1.5",style:{borderColor:"var(--redline, var(--accent))",background:"var(--redline-soft, var(--accent-soft))"},children:[t.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-[11.5px]",style:{color:"var(--redline, var(--accent))"},children:[t.jsx(Z,{size:13,className:"shrink-0"}),t.jsx("span",{children:"抓取失败"})]}),t.jsx("div",{className:"text-[11px] leading-relaxed break-words",style:{color:"var(--ink)"},children:n.error||"该视口截图分析失败"})]})},r.id);const l=n.annotation,d=ke(l,C),N=`${(l.totalDiffRatio*100).toFixed(2)}%`;return t.jsx("td",{"data-matrix-cell":`${e}::${r.id}`,"data-cell-status":"ok",className:"bl-matrix-td p-2.5 align-top",children:t.jsxs("div",{className:"bl-matrix-cell-card overflow-hidden flex flex-col",children:[t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"block relative aspect-[16/10] overflow-hidden group",style:{background:"var(--surface)",borderBottom:"1px solid var(--hair)"},title:"在新标签页查看大图",children:[t.jsx("img",{src:d,alt:`${n.route} ${r.label} ${C}`,className:"w-full h-full object-cover object-top block transition-transform duration-300 group-hover:scale-[1.02]"}),t.jsx("span",{className:"absolute right-2 top-2 p-1 rounded opacity-0 group-hover:opacity-100 transition-opacity",style:{background:"rgba(15, 23, 42, 0.65)",color:"#fff"},children:t.jsx(be,{size:11})})]}),t.jsxs("div",{className:"p-2.5 space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-1.5 flex-wrap mono text-[10.5px]",children:[t.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[t.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:l.totalDiffRatio>0?{background:"var(--redline-soft, var(--accent-soft))",color:"var(--redline, var(--accent))"}:{background:"var(--diff-add-bg)",color:"var(--diff-add-ink)"},children:N}),t.jsx("span",{style:{color:"var(--muted)"},children:l.regions.length>0?`${l.regions.length} 处变化`:"画面一致"})]}),l.cached&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"var(--surface)",color:"var(--faint)",border:"1px solid var(--hair)"},children:"缓存"})]}),l.summary&&t.jsx("p",{className:"text-[11px] leading-snug line-clamp-2",style:{color:"var(--muted)"},children:l.summary}),t.jsxs("div",{className:"pt-1.5 flex items-center justify-between gap-2",style:{borderTop:"1px solid var(--hair)"},children:[t.jsx("button",{type:"button",onClick:()=>re(n.route,n.viewport),className:"bl-card-action text-[11px]",style:{color:"var(--ink)"},children:"切到该视口"}),t.jsxs("button",{type:"button",onClick:()=>ie(n),className:"bl-card-action inline-flex items-center gap-1 text-[11px] font-medium",style:{color:"var(--accent)"},children:[t.jsx(je,{size:11}),t.jsx("span",{children:"交给 Codex"})]})]})]})]})},r.id)})]},e)})})]})}):t.jsxs("div",{className:"h-full min-h-[260px] flex flex-col items-center justify-center text-center gap-2.5 px-6",children:[t.jsx(ve,{size:28,style:{color:"var(--faint)"}}),t.jsx("div",{className:"text-sm font-medium",style:{color:"var(--ink)"},children:"多路由 × 多视口响应式视觉对比矩阵"}),t.jsx("p",{className:"text-xs max-w-md leading-relaxed",style:{color:"var(--muted)"},children:"在上方勾选需要巡检的路由与断点视口(默认手机 / 平板 / 桌面,上限 12 格),点击「生成响应式矩阵」一次对比各断点画面差异,并可一键切回对应视口或派发给 Codex 修复。"})]})})]})};export{ee as MATRIX_VIEWPORT_PRESETS,Me as ResponsiveMatrixStage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o,j as r}from"./vendor-react-CIotE-6Q.js";const p=({route:e,onRouteApply:i,className:u})=>{const[s,a]=o.useState(e);o.useEffect(()=>{a(e)},[e]);const m=n=>{n.preventDefault();const t=s.trim(),l=t?t.startsWith("/")?t:`/${t}`:"/";a(l),i(l)};return r.jsxs("form",{onSubmit:m,className:`flex items-center gap-1.5 min-w-0 max-w-full shrink ${u||""}`,children:[r.jsx("span",{className:"caps shrink-0",children:"路由"}),r.jsx("input",{type:"text",value:s,onChange:n=>a(n.target.value),placeholder:"/",title:s,"aria-label":"同步路由路径",className:"sheet-input bl-route-input w-44 sm:w-56 min-w-0 max-w-full h-7 text-xs mono"})]})};export{p as R};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{R as l,j as e}from"./vendor-react-CIotE-6Q.js";import{M as n}from"./vendor-markdown-COdlM-u6.js";function o(s){const t=s.trim();if(!t)return"";const a=t.replace(/[\u0000-\u0020]+/g,"").toLowerCase(),r=/[\u0000-\u001f\u007f]/.test(t);return a.startsWith("http://")||a.startsWith("https://")||a.startsWith("mailto:")||t.startsWith("#")||!r&&t.startsWith("/")&&!a.startsWith("//")&&!a.startsWith("/\\")||!r&&t.startsWith("./")||!r&&t.startsWith("../")?t:""}const m={a:({href:s,children:t})=>{const a=typeof s=="string"?o(s):"";return a?e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2",style:{color:"var(--accent)"},children:t}):e.jsx("span",{className:"underline decoration-dotted",style:{color:"var(--muted)"},title:"已拦截不安全链接",children:t})},img:({alt:s})=>e.jsxs("span",{className:"mono text-[11px]",style:{color:"var(--faint)"},children:["[图片:",s||"已隐藏","]"]}),h1:({children:s})=>e.jsx("h3",{className:"text-[13px] font-semibold mt-2.5 mb-1",children:s}),h2:({children:s})=>e.jsx("h4",{className:"text-[12.5px] font-semibold mt-2 mb-1",children:s}),h3:({children:s})=>e.jsx("h5",{className:"text-[12px] font-semibold mt-1.5 mb-0.5",children:s}),p:({children:s})=>e.jsx("p",{className:"leading-relaxed my-1 break-words",children:s}),ul:({children:s})=>e.jsx("ul",{className:"list-disc pl-4 my-1 space-y-0.5",children:s}),ol:({children:s})=>e.jsx("ol",{className:"list-decimal pl-4 my-1 space-y-0.5",children:s}),li:({children:s})=>e.jsx("li",{className:"leading-relaxed break-words",children:s}),blockquote:({children:s})=>e.jsx("blockquote",{className:"pl-2.5 my-1.5",style:{borderLeft:"2px solid var(--accent)",color:"var(--muted)"},children:s}),pre:({children:s})=>e.jsx("pre",{className:"mono text-[11px] p-2 rounded-lg overflow-x-auto my-1.5",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:s}),code:({children:s,className:t})=>e.jsx("code",{className:`mono text-[11px] px-1 py-0.5 rounded ${t??""}`,style:{background:"var(--surface)"},children:s})},i=l.memo(({content:s,className:t})=>e.jsx("div",{"data-markdown-ready":"true",className:`bl-safe-markdown text-[12px] ${t??""}`,children:e.jsx(n,{skipHtml:!1,urlTransform:o,components:m,children:s})}));i.displayName="SafeMarkdownBody";export{i as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as a,j as e}from"./vendor-react-CIotE-6Q.js";import{j as ge,u as z,k as Q,f as Ie,B as Z,H as Oe,b as De,D as J,l as de,m as Le,o as Be,c as Ne,p as Ue,a as X}from"./index-CuRBE0Be.js";import{s as _e,e as ue,l as me,T as ze,I as xe,C as V,a as ee,v as He,w as Ke}from"./vendor-icons-BeN0on9X.js";import{C as Fe}from"./CodexSessionBindingFields-DkR0bGRW.js";import{A as pe,P as H,v as W,E as he,a as $e,G as Je,O as Ve}from"./presets-DiVmkZ02.js";import{D as Ge}from"./DoctorChecklist-cmvmLa4s.js";import"./LiquidSelect-BcHivJrw.js";const We="https://registry.npmjs.org/branch-lens/latest",Xe=4500,be="npx branch-lens@latest";function ve(n){const u=n.trim().replace(/^v/i,""),t=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/.exec(u);return t?{nums:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]??""}:null}function qe(n,u){const t=ve(n),h=ve(u);if(!t||!h)return n.localeCompare(u);for(let r=0;r<3;r+=1)if(t.nums[r]!==h.nums[r])return t.nums[r]>h.nums[r]?1:-1;return!t.pre&&h.pre?1:t.pre&&!h.pre?-1:t.pre.localeCompare(h.pre)}const Ye=({hidden:n,config:u})=>{const{host:t,isDesktop:h,isDesktopBridgeAvailable:r,desktopBridge:c}=ge(),o=z(s=>s.desktopUpdateCheckSeq),k=z(s=>s.openOnboarding),p=h&&r&&!!c,[v,S]=a.useState(null),[j,C]=a.useState(null),[i,f]=a.useState({kind:"idle"}),[w,A]=a.useState(!1),g=a.useRef(!0),R=a.useRef(!1),M=a.useRef(!1),d=a.useRef(0),m=a.useRef(null),N=a.useRef(null);a.useEffect(()=>(g.current=!0,()=>{var s;g.current=!1,(s=N.current)==null||s.abort(),m.current!==null&&window.clearTimeout(m.current)}),[]),a.useEffect(()=>{n||R.current||(R.current=!0,Q.getHealth().then(s=>{g.current&&S(s)}).catch(()=>{}))},[n]),a.useEffect(()=>{n||!p||!c||typeof c.getVersions!="function"||M.current||(M.current=!0,c.getVersions().then(s=>{g.current&&C(s)}).catch(()=>{}))},[n,p,c]);const b=(j==null?void 0:j.coreVersion)||(v==null?void 0:v.version)||(u==null?void 0:u.version)||"0.3.1",E=(j==null?void 0:j.appVersion)||b,D=(v==null?void 0:v.dataHome)||(u==null?void 0:u.dataHome)||"~/.branch-lens",T=(v==null?void 0:v.port)??(u==null?void 0:u.port)??null,L=`${Oe[t]} (${t})`,I=a.useCallback(async()=>{var _;if(p&&c&&typeof c.checkForUpdates=="function"){f({kind:"checking"});try{const l=await c.checkForUpdates();if(!g.current)return;f({kind:"desktop",result:l})}catch(l){if(!g.current)return;f({kind:"desktop",result:{status:"error",message:l instanceof Error?l.message:"检查桌面客户端更新失败,请稍后重试。"}})}return}(_=N.current)==null||_.abort();const s=new AbortController;N.current=s,f({kind:"checking"});const x=window.setTimeout(()=>s.abort(),Xe);try{const l=await fetch(We,{headers:{Accept:"application/json"},signal:s.signal});if(!g.current)return;if(l.status===404){f({kind:"not-published",detail:"npm 仓库尚未发布公开版本的 branch-lens(404),当前为本地或预发布版本。"});return}if(!l.ok){f({kind:"offline",detail:`检查更新失败(HTTP ${l.status}),请稍后重试。`});return}const y=await l.json();if(!g.current)return;const O=typeof(y==null?void 0:y.version)=="string"?y.version.trim():"";if(!O){f({kind:"offline",detail:"npm 响应中未包含有效版本号,请稍后重试。"});return}qe(O,b)>0?f({kind:"update-available",latest:O}):f({kind:"up-to-date",latest:O})}catch{if(!g.current)return;f({kind:"offline",detail:"无法连接 npm 仓库(当前网络离线或请求超时),请稍后重试。"})}finally{window.clearTimeout(x)}},[b,c,p]);a.useEffect(()=>{n||!p||o===0||o<=d.current||(d.current=o,I())},[n,p,o,I]);const U=a.useCallback(async()=>{!await Ie(be)||!g.current||(A(!0),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>{g.current&&A(!1)},1800))},[]),B=a.useCallback(()=>{c&&typeof c.openDataDir=="function"&&c.openDataDir()},[c]),P=s=>s==="available"?{background:"var(--accent-soft)",border:"1px solid color-mix(in srgb, var(--accent) 34%, transparent)"}:s==="up-to-date"?{background:"var(--bl-ok-bg)",border:"1px solid var(--bl-ok-border)"}:s==="error"?{background:"var(--bl-missing-bg)",border:"1px solid var(--bl-missing-border)"}:{background:"var(--surface)",border:"1px solid var(--hair-strong)"};return e.jsxs("div",{"data-settings-tab":"about",className:n?"hidden":"space-y-4 text-xs","aria-hidden":n||void 0,children:[e.jsxs("div",{className:"pb-3.5 flex items-start justify-between gap-3 flex-wrap",style:{borderBottom:"1px solid var(--hair)"},children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-wrap",children:[e.jsx(Z,{size:24}),e.jsx("span",{className:"text-[16px] font-semibold",children:"枝镜 · BranchLens"}),e.jsx("span",{className:"mono text-[11px] px-2 py-0.5 rounded-full font-semibold","data-testid":"about-version-badge",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:p?`客户端 v${E}`:`v${b}`}),p&&e.jsxs("span",{className:"mono text-[10.5px] px-2 py-0.5 rounded-full font-medium","data-testid":"about-core-version-badge",style:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair-strong)"},children:["内核 v",b]})]}),e.jsx("p",{className:"text-[11.5px] leading-relaxed m-0",style:{color:"var(--muted)"},children:"面向前端团队的本地 Git 多分支视觉校图、代码评审与 Agent 协作工作台。"})]}),e.jsxs("button",{type:"button",onClick:()=>void I(),disabled:i.kind==="checking","data-testid":"about-check-update-btn",className:"sheet-btn shrink-0",children:[e.jsx(_e,{size:12,className:i.kind==="checking"?"animate-spin":void 0}),e.jsx("span",{children:i.kind==="checking"?"检查中…":"检查更新"})]})]}),i.kind!=="idle"&&i.kind!=="checking"&&e.jsxs("div",{role:"status","data-testid":"about-update-status","data-desktop-update-status":i.kind==="desktop"?i.result.status:void 0,className:"p-3 rounded-xl space-y-2",style:i.kind==="desktop"?P(i.result.status):i.kind==="update-available"?{background:"var(--accent-soft)",border:"1px solid color-mix(in srgb, var(--accent) 34%, transparent)"}:i.kind==="up-to-date"?{background:"var(--bl-ok-bg)",border:"1px solid var(--bl-ok-border)"}:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[i.kind==="desktop"&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-semibold",style:{color:i.result.status==="available"?"var(--accent)":i.result.status==="up-to-date"?"var(--bl-ok-ink)":i.result.status==="error"?"var(--bl-missing-ink)":"var(--ink)"},children:[i.result.status==="available"?e.jsx(ue,{size:13}):i.result.status==="up-to-date"?e.jsx(me,{size:13}):i.result.status==="error"?e.jsx(ze,{size:13}):e.jsx(xe,{size:13}),e.jsx("span",{children:i.result.status==="available"?`发现桌面客户端新版本${i.result.latestVersion?` v${i.result.latestVersion}`:""}`:i.result.status==="up-to-date"?"桌面客户端已是最新版本":i.result.status==="disabled"?"自动更新未启用":i.result.status==="checking"?"正在检查更新…":"检查更新失败"})]}),e.jsx("div",{className:"text-[11.5px] leading-relaxed",style:{color:"var(--muted)"},children:i.result.message})]}),i.kind==="update-available"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-semibold",style:{color:"var(--accent)"},children:[e.jsx(ue,{size:13}),e.jsxs("span",{children:["发现新版本 v",i.latest,"(当前 v",b,")"]})]}),e.jsx("div",{className:"text-[11.5px]",style:{color:"var(--muted)"},children:"可在终端运行以下命令立即体验最新版:"}),e.jsxs("div",{className:"bl-doctor-cmd",children:[e.jsx("code",{children:be}),e.jsxs("button",{type:"button",onClick:()=>void U(),"data-testid":"about-copy-upgrade-btn",className:"bl-doctor-mini-btn",children:[w?e.jsx(V,{size:11}):e.jsx(ee,{size:11}),e.jsx("span",{children:w?"已复制":"复制"})]})]})]}),i.kind==="up-to-date"&&e.jsxs("div",{className:"flex items-center gap-1.5 font-medium",style:{color:"var(--bl-ok-ink)"},children:[e.jsx(me,{size:13}),e.jsxs("span",{children:["当前已是最新版本(v",b,",npm 最新 v",i.latest,")。"]})]}),(i.kind==="not-published"||i.kind==="offline")&&e.jsxs("div",{className:"flex items-start gap-1.5",style:{color:"var(--muted)"},children:[e.jsx(xe,{size:13,className:"shrink-0 mt-0.5"}),e.jsx("span",{children:i.detail})]})]}),e.jsxs("div",{className:"bl-about-grid","data-testid":"about-runtime-grid",children:[e.jsxs("div",{className:"bl-about-cell space-y-1",children:[e.jsx("div",{className:"caps",children:p?"客户端与内核版本":"当前版本"}),e.jsx("div",{className:"mono text-[13px] font-semibold","data-testid":"about-field-version",children:p?`客户端 v${E}`:`v${b}`}),p&&e.jsxs("div",{className:"mono text-[11px]",style:{color:"var(--muted)"},children:["共享内核 v",b]}),(v==null?void 0:v.apiLevel)!==void 0&&e.jsxs("div",{className:"mono text-[10.5px]",style:{color:"var(--faint)"},children:["API Level ",v.apiLevel,v.pid?` · PID ${v.pid}`:""]})]}),e.jsxs("div",{className:"bl-about-cell space-y-1",children:[e.jsx("div",{className:"caps",children:"运行端口"}),e.jsx("div",{className:"mono text-[13px] font-semibold","data-testid":"about-field-port",children:T?`127.0.0.1:${T}`:"未知"}),e.jsx("div",{className:"text-[10.5px]",style:{color:"var(--faint)"},children:"仅本机回环监听"})]}),e.jsxs("div",{className:"bl-about-cell space-y-1",children:[e.jsx("div",{className:"caps",children:"当前宿主"}),e.jsx("div",{className:"text-[12.5px] font-semibold","data-testid":"about-field-host",children:L}),h&&e.jsxs("div",{className:"mono text-[10.5px]",style:{color:"var(--faint)"},children:["原生桥接:",r?"已就绪":"未注入"]})]}),e.jsxs("div",{className:"bl-about-cell space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"caps",children:"数据目录"}),p&&typeof(c==null?void 0:c.openDataDir)=="function"&&e.jsxs("button",{type:"button",onClick:B,"data-testid":"about-open-data-dir-btn",className:"bl-doctor-mini-btn",children:[e.jsx(He,{size:11}),e.jsx("span",{children:"打开目录"})]})]}),e.jsx("div",{className:"mono text-[11.5px] break-all leading-snug","data-testid":"about-field-data-home",children:D})]})]}),p&&j&&e.jsxs("div",{className:"bl-about-cell space-y-1.5","data-testid":"about-desktop-runtime",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsx("span",{className:"caps",children:"桌面运行时栈"}),e.jsxs("span",{className:"mono text-[10.5px]",style:{color:"var(--faint)"},children:[j.platform," / ",j.arch," ·"," ",j.packaged?"已打包发布版":"本地开发版"]})]}),e.jsxs("div",{className:"mono text-[12px] font-medium",style:{color:"var(--ink)"},children:["Electron ",j.electronVersion," · Chromium ",j.chromeVersion," · Node ",j.nodeVersion]})]}),e.jsxs("div",{className:"pt-2.5 flex items-center justify-between gap-3 flex-wrap text-[11px] leading-relaxed",style:{borderTop:"1px solid var(--hair)",color:"var(--faint)"},children:[e.jsxs("span",{children:["配置、快照缓存、任务与交付报告默认全部保存在本地数据目录,可通过环境变量"," ",e.jsx("span",{className:"mono",children:"BRANCH_LENS_HOME"})," 自定义。"]}),e.jsx("button",{type:"button",onClick:k,"data-testid":"about-rerun-onboarding-btn",className:"sheet-link shrink-0 text-[11.5px]",children:"重新运行新手引导"})]})]})},je="npm install -g @openai/codex",ke=a.forwardRef(({open:n,hidden:u,config:t},h)=>{const r=De(l=>l.agentStatus),[c,o]=a.useState(J),[k,p]=a.useState(de),[v,S]=a.useState(2),[j,C]=a.useState(20),[i,f]=a.useState(""),[w,A]=a.useState("new"),[g,R]=a.useState(""),[M,d]=a.useState(""),[m,N]=a.useState(null),[b,E]=a.useState(!1),[D,T]=a.useState(null),[L,I]=a.useState(0),[U,B]=a.useState(!1),P=a.useRef(null);a.useEffect(()=>()=>{P.current!==null&&window.clearTimeout(P.current)},[]);const s=async()=>{await Ne(je)&&(B(!0),P.current!==null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{P.current=null,B(!1)},1800))};a.useEffect(()=>{var O,$,K,F;if(!t||!n)return;o(((O=t.agent)==null?void 0:O.codexModel)||J),p((($=t.agent)==null?void 0:$.codexReasoningEffort)||de),S(((K=t.agent)==null?void 0:K.maxConcurrentTasks)??2),C(((F=t.agent)==null?void 0:F.timeoutMinutes)??20);const l=t.repoConfig||{},y=l.codexSessionMode==="fork"||l.codexSessionMode==="resume"?l.codexSessionMode:"new";f(l.codexProjectId||""),A(y),R(l.codexSessionId||""),d(l.codexSessionTitle||"")},[t,n]),a.useEffect(()=>{if(!n||u||!(t!=null&&t.activeRepoPath))return;let l=!1;return E(!0),T(null),Q.getCodexSessions({projectId:i.trim()||void 0}).then(y=>{l||N(y)}).catch(y=>{l||T(y instanceof Error?y.message:String(y))}).finally(()=>{l||E(!1)}),()=>{l=!0}},[n,u,t==null?void 0:t.activeRepoPath,i,L]),a.useImperativeHandle(h,()=>({getPayload:()=>({codexModel:c.trim()||J,codexReasoningEffort:k,maxConcurrentTasks:Math.max(1,Math.min(8,Math.round(Number(v)||2))),timeoutMinutes:Math.max(1,Math.min(120,Math.round(Number(j)||20)))}),getRepoCodexPayload:()=>{const l=i.trim(),y=g.trim();return w==="new"?{codexProjectId:l,codexSessionMode:"new",codexSessionId:"",codexSessionTitle:""}:{codexProjectId:l,codexSessionMode:w,codexSessionId:y,codexSessionTitle:M.trim()}}}),[c,k,v,j,i,w,g,M]);const x=(r==null?void 0:r.codex.model)||c||J,_=(r==null?void 0:r.codex.reasoningEffort)||k;return e.jsxs("div",{"data-settings-tab":"agent",className:u?"hidden":"space-y-4","aria-hidden":u||void 0,children:[e.jsxs("div",{className:"p-3 rounded-xl text-xs flex items-center justify-between gap-3",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[e.jsxs("div",{className:"space-y-0.5 min-w-0",children:[e.jsx("div",{className:"caps",children:"本机 CODEX CLI 状态"}),e.jsx("div",{className:"mono text-[12px]",style:{color:"var(--ink)"},children:r?r.codex.installed?`已安装 · ${r.codex.version||"codex"}`:"未检测到 codex 命令":"正在检测…"}),e.jsxs("div",{className:"mono text-[11px]",style:{color:"var(--muted)"},children:["当前模型:",x," · 推理强度:",_]})]}),e.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full shrink-0",style:{background:r!=null&&r.codex.installed?"#30d158":"#d97706"}})]}),r&&!r.codex.installed&&e.jsxs("div",{className:"p-3 rounded-lg text-[11.5px] space-y-1.5",style:{background:"var(--redline-soft, var(--accent-soft))",color:"var(--redline, var(--accent))"},children:[e.jsx("div",{children:"请先在本机安装 Codex CLI 后再派发自动修改任务:"}),e.jsxs("div",{className:"flex items-center justify-between gap-2 px-2.5 py-1.5 rounded-md",style:{background:"var(--bg)",border:"1px solid var(--hair-strong)",color:"var(--ink)"},children:[e.jsx("code",{className:"mono text-[11px] select-all truncate",children:je}),e.jsxs("button",{type:"button",onClick:()=>void s(),"data-testid":"agent-settings-copy-install",className:"bl-card-action shrink-0 inline-flex items-center gap-1 text-[11px] font-medium",style:{color:"var(--accent)"},title:"复制 Codex CLI 安装命令",children:[U?e.jsx(V,{size:11}):e.jsx(ee,{size:11}),e.jsx("span",{children:U?"已复制":"复制"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1",htmlFor:"bl-agent-codex-model",children:"CODEX 模型名称(-m)"}),e.jsx("input",{id:"bl-agent-codex-model",type:"text",value:c,onChange:l=>o(l.target.value),placeholder:J,className:"sheet-input w-full h-8 text-xs mono"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:Le.map(l=>e.jsx("button",{type:"button",onClick:()=>o(l),className:"text-[11px] px-2 py-0.5 rounded-full transition-colors mono",style:{border:`1px solid ${c===l?"var(--accent)":"var(--hair-strong)"}`,color:c===l?"var(--accent)":"var(--muted)",background:c===l?"var(--accent-soft)":"transparent"},children:l},l))}),e.jsxs("p",{className:"mt-1.5 text-[11px]",style:{color:"var(--muted)"},children:["通过 ",e.jsx("code",{className:"mono",children:"-m"})," 传给 Codex CLI。若任务报错提示当前账号不支持该模型,请在此切换可用模型。"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1.5",htmlFor:"bl-agent-reasoning-effort",children:"CODEX 推理强度(reasoning_effort)"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":"Codex 推理强度",children:Be.map(l=>{const y=k===l.id;return e.jsx("button",{type:"button",role:"radio","aria-checked":y,"data-reasoning-effort":l.id,onClick:()=>p(l.id),className:"text-[11.5px] px-2.5 py-1 rounded-full transition-colors mono",style:{border:`1px solid ${y?"var(--accent)":"var(--hair-strong)"}`,color:y?"var(--accent)":"var(--muted)",background:y?"var(--accent-soft)":"transparent",fontWeight:y?600:450},children:l.label},l.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1",htmlFor:"bl-agent-max-concurrent",children:"最大并行任务数(1–8)"}),e.jsx("input",{id:"bl-agent-max-concurrent",type:"number",min:1,max:8,value:v,onChange:l=>S(Number(l.target.value)),className:"sheet-input w-full h-8 text-xs mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1",htmlFor:"bl-agent-timeout-min",children:"单任务超时时间(分钟)"}),e.jsx("input",{id:"bl-agent-timeout-min",type:"number",min:1,max:120,value:j,onChange:l=>C(Number(l.target.value)),className:"sheet-input w-full h-8 text-xs mono"})]})]}),t!=null&&t.activeRepoPath?e.jsx(Fe,{data:m,loading:b,error:D,projectId:i,sessionMode:w,sessionId:g,sessionTitle:M,onProjectIdChange:f,onSessionModeChange:A,onSelectSession:(l,y)=>{R(l),d(y)},onRefresh:()=>I(l=>l+1)}):e.jsx("div",{className:"text-[11px]",style:{color:"var(--muted)"},children:"选择仓库后,可在此配置当前仓库默认关联的 Codex 项目与历史对话。"})]})});ke.displayName="AgentSettingsTab";const Ze=()=>{const n=z(c=>c.pushToast),[u,t]=a.useState(!1),h=a.useRef(null);a.useEffect(()=>()=>{h.current!==null&&window.clearTimeout(h.current)},[]);const r=async()=>{await Ne(pe)?(t(!0),h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{h.current=null,t(!1)},2e3),n({tone:"success",title:"已复制 Agent 联动规范",detail:"可直接粘贴到业务仓库的 AGENTS.md、CLAUDE.md 或 Cursor Rules 中。",durationMs:4500})):n({tone:"warning",title:"复制失败",detail:"请展开下方模板手动全选复制。",durationMs:4e3})};return e.jsxs("div",{"data-agent-guide-card":"true",className:"p-3 rounded-lg space-y-2.5 text-xs",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"space-y-0.5 min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium",style:{color:"var(--ink)"},children:[e.jsx(Ke,{size:13,style:{color:"var(--accent)"}}),e.jsx("span",{children:"外部开发 Agent 联动规范(AGENTS.md / CLAUDE.md)"})]}),e.jsx("p",{className:"text-[11px] leading-relaxed",style:{color:"var(--muted)"},children:"贴入仓库协作规范后,Claude Code / Codex / Cursor 完成开发即可通过 MCP、CLI 或仓库文件自动向 BranchLens 上报通俗说明,零额外 API 费用。"})]}),e.jsxs("button",{type:"button",onClick:()=>void r(),className:"sheet-btn shrink-0",style:{height:30,padding:"0 10px",fontSize:11.5},children:[u?e.jsx(V,{size:12}):e.jsx(ee,{size:12}),e.jsx("span",{children:u?"已复制规范":"一键复制 Agent 联动规范"})]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer select-none font-medium",style:{color:"var(--muted)"},children:"预览 Markdown 联动指令模板"}),e.jsx("pre",{className:"mt-2 p-2.5 rounded-lg mono text-[10.5px] leading-relaxed whitespace-pre-wrap break-words max-h-[220px] overflow-y-auto",style:{background:"var(--bg)",border:"1px solid var(--hair)",color:"var(--ink)"},children:pe})]})]})},Se=a.forwardRef(({open:n,hidden:u,config:t},h)=>{var U,B,P;const[r,c]=a.useState("agent-first"),[o,k]=a.useState("gemini"),[p,v]=a.useState(""),[S,j]=a.useState(""),[C,i]=a.useState(""),[f,w]=a.useState(!1),[A,g]=a.useState(!0),[R,M]=a.useState(!1),[d,m]=a.useState(null),[N,b]=a.useState(null);a.useEffect(()=>{if(!t||!n)return;const s=t.ai.provider==="none"&&!t.ai.hasApiKey?"gemini":t.ai.provider;c(t.ai.explainSourceMode??"agent-first"),k(s),v(t.ai.baseUrl||H[s].baseUrl),j(t.ai.model||H[s].model),i(""),w(!1),g(t.ai.autoAnalyzeNewBranches!==!1),m(null),b(null)},[t,n]),a.useImperativeHandle(h,()=>({getPayload:()=>{if(o!=="none"&&o!=="codex-agent"){const s=W(p);if(s)throw b(s),new Error(s)}return b(null),{provider:o,explainSourceMode:r,...o==="codex-agent"?{}:{baseUrl:p.trim(),model:S.trim(),...f?{apiKey:""}:C.trim()?{apiKey:C.trim()}:{}},autoAnalyzeNewBranches:A}},resetAfterSave:()=>{i(""),w(!1)}}),[o,r,p,S,A,f,C]);const E=s=>{k(s),v(H[s].baseUrl),j(H[s].model),m(null),b(null)},D=((U=t==null?void 0:t.agent)==null?void 0:U.codexModel)||"gpt-6.2-astra",T=((B=t==null?void 0:t.agent)==null?void 0:B.codexReasoningEffort)||"high",L=async()=>{if(o!=="codex-agent"&&o!=="none"){const s=W(p);if(s){b(s),m({ok:!1,text:s});return}}b(null),M(!0),m(null);try{const s=await Q.testAi(o==="codex-agent"?{provider:"codex-agent",model:D}:{provider:o,baseUrl:p.trim(),model:S.trim(),...C.trim()?{apiKey:C.trim()}:{}});m({ok:!0,text:`✓ 连通成功 · ${s.model} (${s.latencyMs}ms)`})}catch(s){m({ok:!1,text:s instanceof Error?s.message:String(s)})}finally{M(!1)}},I=((P=he.find(s=>s.id===r))==null?void 0:P.hint)||"";return e.jsxs("div",{"data-settings-tab":"ai",className:u?"hidden":"space-y-4","aria-hidden":u||void 0,children:[e.jsxs("div",{children:[e.jsx("div",{className:"caps mb-2",children:"服务商"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:$e.map(s=>e.jsx("button",{type:"button","data-ai-provider":s.id,onClick:()=>E(s.id),className:"bl-choice-btn","data-active":o===s.id?"true":void 0,children:s.label},s.id))}),e.jsx("p",{className:"mt-2 text-[11px]",style:{color:"var(--muted)"},children:H[o].hint})]}),o==="codex-agent"&&e.jsxs("div",{"data-codex-agent-panel":"true",className:"p-3 rounded-lg space-y-2.5 text-xs",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"space-y-0.5 min-w-0",children:[e.jsx("div",{className:"font-medium",style:{color:"var(--ink)"},children:"无需填写 API Key · 复用本机 Codex CLI"}),e.jsxs("div",{className:"mono text-[11px]",style:{color:"var(--muted)"},children:["当前模型:",D," · 推理强度:",T]})]}),e.jsx("button",{type:"button",onClick:()=>void L(),disabled:R,className:"sheet-btn shrink-0",style:{height:32,padding:"0 12px",fontSize:12},children:R?"测试中…":"测试连通"})]}),d&&e.jsx("div",{className:"text-[11.5px] mono",style:{color:d.ok?"#15803d":"var(--redline, var(--accent))"},children:d.text})]}),o!=="none"&&o!=="codex-agent"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[e.jsx("label",{className:"caps",children:"API KEY"}),t!=null&&t.ai.hasApiKey&&!f?e.jsxs("div",{className:"flex items-baseline gap-2.5 text-[11px]",children:[e.jsxs("span",{className:"mono",style:{color:"var(--muted)"},children:["已存 ",t.ai.apiKeyMasked]}),e.jsx("button",{type:"button",onClick:()=>w(!0),className:"hover:underline",style:{color:"var(--accent)"},children:"清除"})]}):o==="gemini"?e.jsx("a",{href:"https://aistudio.google.com/apikey",target:"_blank",rel:"noreferrer",className:"text-[11px] hover:underline",style:{color:"var(--accent)"},children:"获取 Google AI Studio Key ↗"}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"password",value:C,onChange:s=>{i(s.target.value),w(!1),m(null)},placeholder:t!=null&&t.ai.hasApiKey&&!f?"留空保持不变,或输入新 Key 替换":o==="gemini"?"粘贴 AIza...(仅存本机 ~/.branch-lens/config.json)":"仅保存在本机 ~/.branch-lens/config.json",className:"sheet-input flex-1 h-8 text-xs mono"}),e.jsx("button",{type:"button",onClick:()=>void L(),disabled:R||!C.trim()&&!(t!=null&&t.ai.hasApiKey),className:"sheet-btn shrink-0",style:{height:32,padding:"0 12px",fontSize:12},children:R?"测试中…":"测试连通"})]}),d&&e.jsx("div",{className:"mt-1.5 text-[11.5px] mono",style:{color:d.ok?"#15803d":"var(--redline, var(--accent))"},children:d.text})]}),e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1",children:"模型名称 (MODEL)"}),e.jsx("input",{type:"text",value:S,onChange:s=>j(s.target.value),placeholder:H[o].model,className:"sheet-input w-full h-8 text-xs mono"}),o==="gemini"&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:Je.map(s=>e.jsx("button",{type:"button",onClick:()=>j(s.id),className:"text-[11px] px-2 py-0.5 rounded-full transition-colors",style:{border:`1px solid ${S===s.id?"var(--accent)":"var(--hair-strong)"}`,color:S===s.id?"var(--accent)":"var(--muted)",background:S===s.id?"var(--accent-soft)":"transparent"},children:s.label},s.id))}),o==="openai"&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:Ve.map(s=>e.jsx("button",{type:"button",onClick:()=>{j(s.id),v(s.baseUrl),b(null)},className:"text-[11px] px-2 py-0.5 rounded-full transition-colors",style:{border:`1px solid ${S===s.id?"var(--accent)":"var(--hair-strong)"}`,color:S===s.id?"var(--accent)":"var(--muted)",background:S===s.id?"var(--accent-soft)":"transparent"},children:s.label},s.id))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bl-ai-base-url",className:"caps block mb-1",children:"API BASE URL"}),e.jsx("input",{id:"bl-ai-base-url",type:"text","aria-label":"API BASE URL","aria-invalid":N?"true":void 0,value:p,onChange:s=>{const x=s.target.value;v(x),N&&!W(x)&&b(null),m(null)},onBlur:()=>b(W(p)),placeholder:H[o].baseUrl,className:"sheet-input w-full h-8 text-xs mono"}),N&&e.jsx("div",{role:"alert","data-testid":"ai-baseurl-error",className:"mt-1 text-[11.5px]",style:{color:"var(--redline, #dc2626)"},children:N})]})]}),e.jsxs("div",{className:"pt-2",style:{borderTop:"1px solid var(--hair)"},children:[e.jsx("div",{className:"caps mb-2",children:"差异说明来源策略"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 items-stretch",role:"radiogroup","aria-label":"差异说明来源策略",children:he.map(s=>{const x=r===s.id;return e.jsxs("button",{type:"button",role:"radio","aria-checked":x,"data-explain-source-mode":s.id,"data-active":x?"true":void 0,onClick:()=>c(s.id),className:"bl-choice-btn bl-strategy-card w-full",children:[e.jsx("span",{className:"bl-strategy-title",children:s.title}),e.jsx("span",{className:"bl-strategy-badge",children:s.badge})]},s.id)})}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-relaxed",style:{color:"var(--muted)"},children:I})]}),o!=="none"&&e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsxs("label",{className:"flex items-center gap-2.5 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:A,onChange:s=>g(s.target.checked),style:{accentColor:"var(--accent)"}}),e.jsx("span",{children:"新分支进来时,自动调用 AI 分析它与前置版本的差别(结果按分支 SHA 本地缓存)"})]}),r==="agent-only"&&e.jsx("p",{className:"text-[11px] pl-6",style:{color:"var(--muted)"},children:"当前策略为「仅外部 Agent」,自动分析将仅读取外部 Agent 报告与本地摘要,跳过外部 API 调用。"})]}),e.jsx(Ze,{})]})});Se.displayName="AiSettingsTab";const Qe=()=>{const{switchStyle:n,setSwitchStyle:u}=Ue(),t=X(h=>{var r;return((r=h.repo)==null?void 0:r.branches.length)??0});return e.jsxs("div",{className:"pb-4",style:{borderBottom:"1px solid var(--hair)"},"data-testid":"dsh-switch-style-section",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2 mb-2.5",children:[e.jsx("div",{className:"font-semibold text-[12.5px]",style:{color:"var(--ink)"},children:"DeepSeek Harness 顶栏入口样式"}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--muted)"},children:"即时生效 · 也可直接右键点击 DSH 顶栏胶囊切换"})]}),e.jsxs("div",{role:"radiogroup","aria-label":"DeepSeek Harness 顶栏入口样式",className:"grid grid-cols-1 sm:grid-cols-2 gap-2.5",children:[e.jsxs("button",{type:"button",role:"radio","aria-checked":n==="compact-badge","data-testid":"dsh-switch-style-compact-badge","data-active":n==="compact-badge"?"true":"false",onClick:()=>u("compact-badge"),className:"bl-dsh-style-card",children:[e.jsx("div",{className:"bl-dsh-preview-stage","aria-hidden":"true",children:e.jsxs("span",{className:"bl-dsh-mini-compact",children:[e.jsx("span",{className:"bl-dsh-mini-icon-badge",children:e.jsx(Z,{size:13})}),e.jsx("span",{className:"bl-dsh-mini-label",children:"打开枝镜"}),e.jsx("span",{className:"bl-dsh-mini-kbd mono",children:"⌥⇧B"})]})}),e.jsxs("div",{className:"bl-dsh-style-meta",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 w-full",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"bl-dsh-style-title",children:"极简单键"}),e.jsx("span",{className:"bl-dsh-style-tag",children:"默认"})]}),e.jsx("span",{className:"bl-dsh-style-check","data-active":n==="compact-badge"?"true":"false","aria-hidden":"true",children:n==="compact-badge"&&e.jsx(V,{size:11,strokeWidth:2.8})})]}),e.jsx("p",{className:"bl-dsh-style-desc",children:"宽度精简,与 Synapse 并排不再重复出现两个「对话」"})]})]}),e.jsxs("button",{type:"button",role:"radio","aria-checked":n==="recessed-segmented","data-testid":"dsh-switch-style-recessed-segmented","data-active":n==="recessed-segmented"?"true":"false",onClick:()=>u("recessed-segmented"),className:"bl-dsh-style-card",children:[e.jsx("div",{className:"bl-dsh-preview-stage","aria-hidden":"true",children:e.jsxs("span",{className:"bl-dsh-mini-recessed",children:[e.jsx("span",{className:"bl-dsh-mini-seg-idle",children:"对话"}),e.jsxs("span",{className:"bl-dsh-mini-seg-cap",children:[e.jsx(Z,{size:13}),e.jsx("span",{children:"枝镜"}),t>0&&e.jsx("span",{className:"bl-dsh-mini-count mono","data-testid":"dsh-preview-branch-count",children:t})]})]})}),e.jsxs("div",{className:"bl-dsh-style-meta",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 w-full",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"bl-dsh-style-title",children:"内凹白键"}),e.jsx("span",{className:"bl-dsh-style-tag",children:"含分支角标"})]}),e.jsx("span",{className:"bl-dsh-style-check","data-active":n==="recessed-segmented"?"true":"false","aria-hidden":"true",children:n==="recessed-segmented"&&e.jsx(V,{size:11,strokeWidth:2.8})})]}),e.jsx("p",{className:"bl-dsh-style-desc",children:"轻盈去黑块,实时显示当前仓库分支数量"})]})]})]})]})},es=({hidden:n,config:u,onCleanWorktrees:t})=>{const h=z(o=>o.setSettingsTab),r=z(o=>o.openOnboarding),{isHarnessPage:c}=ge();return e.jsxs("div",{"data-settings-tab":"env",className:n?"hidden":"space-y-4 text-xs","aria-hidden":n||void 0,children:[c&&e.jsx(Qe,{}),e.jsxs("div",{className:"pb-3",style:{borderBottom:"1px solid var(--hair)"},children:[e.jsx("div",{className:"caps mb-1",children:"当前工作仓库"}),e.jsx("div",{className:"mono break-all",children:(u==null?void 0:u.activeRepoPath)||"尚未选择"})]}),e.jsxs("div",{className:"pb-3",style:{borderBottom:"1px solid var(--hair)"},children:[e.jsx("div",{className:"caps mb-1",children:"本机 CHROME 路径"}),e.jsx("div",{className:"mono break-all",style:{color:"var(--muted)"},children:(u==null?void 0:u.chromePath)||"未检测到(可通过 BRANCH_LENS_CHROME_PATH 指定)"})]}),e.jsx("div",{className:"pb-3",style:{borderBottom:"1px solid var(--hair)"},children:e.jsx(Ge,{enabled:!n,compact:!0,currentSettingsTab:"env",onOpenSettingsTab:o=>h(o),title:"环境自检(7 项)"})}),e.jsxs("div",{className:"flex items-center justify-between gap-4 pb-3",style:{borderBottom:"1px solid var(--hair)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"首次使用引导向导"}),e.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--muted)"},children:"重新查看环境快检、项目选择、AI 解读与编程助手 4 步引导。"})]}),e.jsx("button",{type:"button",onClick:r,"data-testid":"settings-rerun-onboarding-btn",className:"sheet-btn shrink-0",children:"重新运行新手引导"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 pt-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"清理临时 Worktree 缓存"}),e.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--muted)"},children:"停止全部预览进程并释放磁盘空间,不影响主仓库。"})]}),e.jsx("button",{type:"button",onClick:()=>void t(),className:"sheet-btn sheet-btn-accent shrink-0",children:"立即清理"})]})]})};function ye(n,u){const t=n.trim();if(!t)return{};if(t.startsWith("{")){let r;try{r=JSON.parse(t)}catch{throw new Error(`${u} 必须为合法 JSON 对象或每行 key=value`)}if(!r||typeof r!="object"||Array.isArray(r))throw new Error(`${u} 必须为 JSON 对象`);return Object.fromEntries(Object.entries(r).filter(([c])=>c.trim().length>0).map(([c,o])=>[c.trim(),typeof o=="string"?o:JSON.stringify(o)]))}const h={};for(const r of t.split(/\r?\n/)){const c=r.trim();if(!c||c.startsWith("#"))continue;const o=c.indexOf("=");if(o<=0)continue;const k=c.slice(0,o).trim(),p=c.slice(o+1).trim();k&&(h[k]=p)}return h}function fe(n){return n?Object.entries(n).map(([u,t])=>`${u}=${t}`).join(`
|
|
2
|
+
`):""}const Ce=a.forwardRef(({open:n,hidden:u,config:t},h)=>{const[r,c]=a.useState(""),[o,k]=a.useState(""),[p,v]=a.useState(""),[S,j]=a.useState(""),[C,i]=a.useState(4),[f,w]=a.useState(""),[A,g]=a.useState(""),[R,M]=a.useState(""),[d,m]=a.useState(""),[N,b]=a.useState(""),[E,D]=a.useState(!1),[T,L]=a.useState(""),[I,U]=a.useState(""),[B,P]=a.useState("");return a.useEffect(()=>{var _,l,y,O;if(!t||!n)return;const s=t.repoConfig,x=s.auth;c(s.devCommand||""),k(s.installCommand||""),v(s.baseBranch||""),j((s.copyFiles||[]).join(", ")),i(s.maxConcurrentInstances??4),w(fe(x==null?void 0:x.presetLocalStorage)),g(((_=x==null?void 0:x.autoLogin)==null?void 0:_.url)||""),M(((l=x==null?void 0:x.autoLogin)==null?void 0:l.bodyJson)||""),m(((y=x==null?void 0:x.autoLogin)==null?void 0:y.tokenPath)||""),b(((O=x==null?void 0:x.autoLogin)==null?void 0:O.storageKey)||""),D(!!(x!=null&&x.mockAuthEnabled)),L(((x==null?void 0:x.mockAuthPaths)||[]).join(", ")),U((x==null?void 0:x.mockUserJson)||""),P(fe(s.routeParams))},[t,n]),a.useImperativeHandle(h,()=>({getPayload:()=>{var te,ae,re,le,ne,oe,ie,ce;const s=S.split(",").map(Y=>Y.trim()).filter(Boolean),x=ye(f,"预置 localStorage"),_=ye(B,"参数化路由默认参数"),l=T.split(/[,\n]/).map(Y=>Y.trim()).filter(Boolean),y=r.trim(),O=o.trim(),$=p.trim(),K=A.trim(),F=I.trim(),se=Object.keys(x).length>0,we=Object.keys(_).length>0,G=!!((te=t==null?void 0:t.repoConfig)!=null&&te.auth),Ee=!!((re=(ae=t==null?void 0:t.repoConfig)==null?void 0:ae.auth)!=null&&re.autoLogin),Te=!!((le=t==null?void 0:t.repoConfig)!=null&&le.routeParams),Ae=((ne=t==null?void 0:t.repoConfig)==null?void 0:ne.devCommand)!==void 0,Re=((oe=t==null?void 0:t.repoConfig)==null?void 0:oe.installCommand)!==void 0,Me=((ie=t==null?void 0:t.repoConfig)==null?void 0:ie.baseBranch)!==void 0,Pe=((ce=t==null?void 0:t.repoConfig)==null?void 0:ce.copyFiles)!==void 0;let q;return(G||E||se||l.length>0||F||K)&&(q={mockAuthEnabled:E,...l.length>0||G?{mockAuthPaths:l}:{},...F||G?{mockUserJson:F}:{},...se||G?{presetLocalStorage:x}:{},...K?{autoLogin:{url:K,bodyJson:R.trim()||"{}",...d.trim()?{tokenPath:d.trim()}:{},...N.trim()?{storageKey:N.trim()}:{}}}:Ee?{autoLogin:{url:"",bodyJson:"{}"}}:{}}),{...y||Ae?{devCommand:y}:{},...O||Re?{installCommand:O}:{},...$||Me?{baseBranch:$}:{},...s.length>0||Pe?{copyFiles:s}:{},maxConcurrentInstances:Math.max(1,Math.min(8,Number(C)||4)),...we||Te?{routeParams:_}:{},...q?{auth:q}:{}}}}),[t,r,o,p,S,C,f,A,R,d,N,E,T,I,B]),e.jsxs("div",{"data-settings-tab":"repo",className:u?"hidden":"space-y-4","aria-hidden":u||void 0,children:[e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1",children:"自定义启动命令(留空自动识别 Vite)"}),e.jsx("input",{type:"text",value:r,onChange:s=>c(s.target.value),placeholder:"npx vite --port {port} --host 127.0.0.1 --strictPort",className:"sheet-input w-full h-8 text-xs mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1",children:"自定义依赖安装命令"}),e.jsx("input",{type:"text",value:o,onChange:s=>k(s.target.value),placeholder:"pnpm install --prefer-offline",className:"sheet-input w-full h-8 text-xs mono"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1",children:"默认主干分支"}),e.jsx("input",{type:"text",value:p,onChange:s=>v(s.target.value),placeholder:"自动检测 main",className:"sheet-input w-full h-8 text-xs mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1",children:"最大保活实例数"}),e.jsx("input",{type:"number",min:1,max:8,value:C,onChange:s=>i(Number(s.target.value)),className:"sheet-input w-full h-8 text-xs mono"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1",children:"自动复制到 Worktree 的文件(逗号分隔)"}),e.jsx("input",{type:"text",value:S,onChange:s=>j(s.target.value),placeholder:".env, .env.local",className:"sheet-input w-full h-8 text-xs mono"})]}),e.jsxs("div",{className:"pt-4 space-y-3",style:{borderTop:"1px solid var(--hair)"},children:[e.jsx("div",{className:"text-xs font-semibold",style:{color:"var(--ink)"},children:"免登录与路由参数(双保险)"}),e.jsxs("div",{className:"p-3 rounded-lg space-y-2.5",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[e.jsx("div",{className:"caps",children:"保险一 · 预置存储与测试账号自动登录"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] mb-1",style:{color:"var(--muted)"},children:"预置 localStorage(每行 key=value 或 JSON 对象)"}),e.jsx("textarea",{rows:2,"aria-label":"预置 localStorage",value:f,onChange:s=>w(s.target.value),placeholder:`token=demo-token
|
|
3
|
+
role=admin`,className:"sheet-input w-full py-1.5 text-xs mono resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] mb-1",style:{color:"var(--muted)"},children:"自动登录接口路径(以 / 开头)"}),e.jsx("input",{type:"text","aria-label":"自动登录接口路径",value:A,onChange:s=>g(s.target.value),placeholder:"/api/auth/login",className:"sheet-input w-full h-8 text-xs mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] mb-1",style:{color:"var(--muted)"},children:"Token 字段路径(可选)"}),e.jsx("input",{type:"text","aria-label":"Token JSON 路径",value:d,onChange:s=>m(s.target.value),placeholder:"data.token",className:"sheet-input w-full h-8 text-xs mono"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] mb-1",style:{color:"var(--muted)"},children:"自动登录请求体 JSON"}),e.jsx("input",{type:"text","aria-label":"自动登录请求体 JSON",value:R,onChange:s=>M(s.target.value),placeholder:'{"username":"demo","password":"123"}',className:"sheet-input w-full h-8 text-xs mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] mb-1",style:{color:"var(--muted)"},children:"写入 localStorage 键名(默认 token)"}),e.jsx("input",{type:"text","aria-label":"写入 localStorage 键名",value:N,onChange:s=>b(s.target.value),placeholder:"token",className:"sheet-input w-full h-8 text-xs mono"})]})]})]}),e.jsxs("div",{className:"p-3 rounded-lg space-y-2.5",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"caps",children:"保险二 · 代理层 Mock 免登"}),e.jsxs("label",{className:"inline-flex items-center gap-1.5 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox","aria-label":"启用 Mock 免登模式",checked:E,onChange:s=>D(s.target.checked)}),e.jsx("span",{children:"开启 Mock 免登"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] mb-1",style:{color:"var(--muted)"},children:"自定义鉴权探针路径(逗号分隔,每项以 / 开头)"}),e.jsx("input",{type:"text","aria-label":"自定义鉴权探针路径",value:T,onChange:s=>L(s.target.value),placeholder:"/api/auth/me, /api/user/profile",className:"sheet-input w-full h-8 text-xs mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] mb-1",style:{color:"var(--muted)"},children:"Mock 用户信息 JSON(可选)"}),e.jsx("textarea",{rows:2,"aria-label":"Mock 用户信息 JSON",value:I,onChange:s=>U(s.target.value),placeholder:'{"id":1,"name":"Demo User","role":"admin"}',className:"sheet-input w-full py-1.5 text-xs mono resize-y"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1",children:"参数化路由默认参数(每行 key=value 或 JSON,如 id=42 或 /orders/:id=/orders/42)"}),e.jsx("textarea",{rows:2,"aria-label":"参数化路由默认参数",value:B,onChange:s=>P(s.target.value),placeholder:`id=1
|
|
4
|
+
/orders/:id=/orders/42`,className:"sheet-input w-full py-1.5 text-xs mono resize-y"})]})]})]})});Ce.displayName="RepoSettingsTab";const ss=[{id:"ai",label:"AI 模型与解读"},{id:"repo",label:"项目启动参数"},{id:"agent",label:"Agent(Codex)"},{id:"env",label:"本机环境"},{id:"about",label:"关于"}],cs=()=>{const n=z(d=>d.settingsOpen),u=z(d=>d.setSettingsOpen),t=z(d=>d.settingsTab),h=z(d=>d.setSettingsTab),r=X(d=>d.config),c=X(d=>d.saveSettings),o=X(d=>d.cleanWorktrees),k=a.useCallback(()=>u(!1),[u]),[p,v]=a.useState(!1),[S,j]=a.useState(!1),[C,i]=a.useState(null),f=a.useRef(null),w=a.useRef(null),A=a.useRef(null),g=a.useRef(!1);if(a.useEffect(()=>{!r||!n||(j(!1),i(null))},[r,n]),a.useEffect(()=>{if(!n)return;const d=m=>{m.key==="Escape"&&!m.defaultPrevented&&(m.preventDefault(),k())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,k]),!n)return null;const R=d=>{var E;if(g.current)return;const m=d.target,N=(E=m==null?void 0:m.closest)==null?void 0:E.call(m,"[data-settings-tab]"),b=N==null?void 0:N.getAttribute("data-settings-tab");b&&b!==t&&(g.current=!0,h(b),setTimeout(()=>{g.current=!1,m==null||m.focus(),m&&"reportValidity"in m&&typeof m.reportValidity=="function"&&m.reportValidity()},0))},M=async d=>{var m,N,b,E,D;d.preventDefault(),v(!0),i(null),j(!1);try{const T=(m=w.current)==null?void 0:m.getPayload(),L=(N=A.current)==null?void 0:N.getRepoCodexPayload(),I=T||L?{...T,...L}:void 0;await c({ai:(b=f.current)==null?void 0:b.getPayload(),repoConfig:I,agent:(E=A.current)==null?void 0:E.getPayload()}),j(!0),(D=f.current)==null||D.resetAfterSave()}catch(T){i(T instanceof Error?T.message:String(T))}finally{v(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 backdrop-blur-sm",style:{background:"rgba(15, 20, 30, 0.36)"},onClick:k,children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"设置",className:"bl-modal w-full max-w-xl max-h-[90vh] flex flex-col overflow-hidden",onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{className:"bl-modal-head h-13 px-6 shrink-0 flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-semibold",children:"设置 · SETTINGS"}),e.jsx("button",{type:"button",onClick:k,className:"mono text-sm px-1 opacity-60 hover:opacity-100","aria-label":"关闭设置",children:"×"})]}),e.jsx("div",{className:"px-5 shrink-0 flex gap-5 overflow-x-auto",style:{borderBottom:"1px solid var(--hair)"},children:ss.map(d=>e.jsx("button",{type:"button",onClick:()=>h(d.id),className:"sheet-tab bl-subtab text-[13px] py-2.5","aria-selected":t===d.id,children:d.label},d.id))}),e.jsxs("form",{onInvalidCapture:R,onSubmit:d=>void M(d),className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto p-5 space-y-4",children:[e.jsx(Se,{ref:f,open:n,hidden:t!=="ai",config:r}),e.jsx(Ce,{ref:w,open:n,hidden:t!=="repo",config:r}),e.jsx(ke,{ref:A,open:n,hidden:t!=="agent",config:r}),e.jsx(es,{hidden:t!=="env",config:r,onCleanWorktrees:o}),e.jsx(Ye,{hidden:t!=="about",config:r})]}),e.jsxs("div",{className:"shrink-0 px-5 py-3 flex items-center justify-between gap-3",style:{borderTop:"1px solid var(--hair)"},children:[e.jsx("div",{className:"text-xs truncate",style:{color:C?"var(--redline, #dc2626)":"var(--accent)"},role:C?"alert":void 0,children:C||(S?"已保存生效":"")}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx("button",{type:"button",onClick:k,className:"sheet-btn",children:"关闭"}),t!=="env"&&t!=="about"&&e.jsx("button",{type:"submit",disabled:p,className:"sheet-btn sheet-btn-primary",children:p?"保存中…":"保存配置"})]})]})]})]})})};export{cs as SettingsModal};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{r as n,j as s}from"./vendor-react-CIotE-6Q.js";import{b as T,a as F,D as Ie,l as Oe,k as _e,o as ve,q as Me,m as Le}from"./index-CuRBE0Be.js";import{L as K}from"./LiquidSelect-BcHivJrw.js";import{f as Ae}from"./pickedElement-DWJDcr9q.js";import{C as ze}from"./CodexSessionBindingFields-DkR0bGRW.js";import{x as Fe,b as Ke,c as We,y as Be,n as Pe,e as qe}from"./vendor-icons-BeN0on9X.js";function ge(){return[{label:"方案 A",model:"",reasoningEffort:"",instructionSuffix:""},{label:"方案 B",model:"",reasoningEffort:"",instructionSuffix:""},{label:"方案 C",model:"",reasoningEffort:"",instructionSuffix:""}]}const Xe=[{id:"visual-fix",label:"视觉修复",hint:"按批注区域精确修改样式、布局或文案"},{id:"code-change",label:"代码改动",hint:"功能调整或组件改造,保证类型检查通过"},{id:"review",label:"只读审查",hint:"仅分析视觉一致性、可访问性与性能,不修改文件"},{id:"cleanup",label:"代码清理",hint:"清理冗余代码(强制先出方案,确认后再修改)"}],Ge=[{id:"direct",label:"直接执行",hint:"在独立 worktree 中执行修改并生成任务分支"},{id:"plan-first",label:"先出方案",hint:"先只读分析定位并输出方案,经确认后再执行修改"}];function W(t){var f;return((f=t.title)==null?void 0:f.trim())||`未命名批注 #${t.id}`}function Ue(t,j){const f=[];if(t.length>0){const S=t.map((l,c)=>{const h=W(l),N=[`${c+1}. 【区域 ${l.id} · ${h}】(${l.category})${l.description}`];return(l.beforeDesc||l.afterDesc)&&N.push(` 改前:${l.beforeDesc||"—"} → 改后:${l.afterDesc||"—"}`),N.join(`
|
|
2
2
|
`)});f.push(`请根据批注定位并修复以下视觉问题:
|
|
3
|
-
${
|
|
4
|
-
`)}`)}if(j&&j.length>0){const
|
|
5
|
-
${
|
|
3
|
+
${S.join(`
|
|
4
|
+
`)}`)}if(j&&j.length>0){const S=j.map((l,c)=>{const h=l.text?`「${l.text}」`:"";return`${c+1}. <${l.tag}>${h} · 选择器 \`${l.selector}\``});f.push(`请定位并修改以下点选元素:
|
|
5
|
+
${S.join(`
|
|
6
6
|
`)}`)}return f.join(`
|
|
7
7
|
|
|
8
|
-
`)}const Ye=()=>{var ue,pe;const t=T(e=>e.composerDraft),j=T(e=>e.closeComposer),f=T(e=>e.createTask),y=T(e=>e.createRace),l=z(e=>e.repo),c=z(e=>e.config),h=n.useMemo(()=>((l==null?void 0:l.branches)??[]).filter(e=>!e.isWorkingTree),[l==null?void 0:l.branches]),N=((ue=c==null?void 0:c.agent)==null?void 0:ue.codexModel)||Ie,B=((pe=c==null?void 0:c.agent)==null?void 0:pe.codexReasoningEffort)||Oe,[b,P]=n.useState("visual-fix"),[I,O]=n.useState("direct"),[q,E]=n.useState("single"),[k,X]=n.useState(""),[_,G]=n.useState(""),[m,U]=n.useState(2),[H,J]=n.useState(ge),[x,Q]=n.useState(""),[C,V]=n.useState(""),[Y,Z]=n.useState(""),[w,ee]=n.useState(""),[S,se]=n.useState("new"),[M,te]=n.useState(""),[L,ae]=n.useState(""),[ne,le]=n.useState(""),[je,Se]=n.useState(null),[ye,ie]=n.useState(!1),[Ne,A]=n.useState(null),[ke,we]=n.useState(0),[re,$]=n.useState(!1),[R,F]=n.useState(!1),[d,u]=n.useState(null),oe=n.useRef(null),ce=n.useRef(null);if(n.useEffect(()=>{var me,xe,fe,he;if(!t)return;const e=t.defaultKind??"visual-fix";P(e),O(e==="cleanup"?"plan-first":"direct"),E("single"),X(""),G(""),U(2),J(ge());const a=t.sourceRef&&t.sourceRef!=="__working__"?t.sourceRef:t.requireExplicitSourceRef?"":(l==null?void 0:l.baseBranch)||((me=h[0])==null?void 0:me.ref)||"main";Q(a);const i=((xe=t.sourceSha)==null?void 0:xe.trim())||"",g=/^[0-9a-f]{7,40}$/i.test(i)?i:"";V(g);const p=t.pickedElements??[];Z(t.defaultTitle||(t.regions.length===1?W(t.regions[0]):t.regions.length>1?`修复 ${t.regions.length} 处视觉批注`:p.length===1?`调整 ${((fe=p[0].source)==null?void 0:fe.component)||`<${p[0].tag}>`} 样式`:p.length>1?`调整 ${p.length} 处点选元素`:"")),ee(t.defaultInstruction||Ue(t.regions,t.pickedElements));const r=(he=z.getState().config)==null?void 0:he.repoConfig,o=!!(r!=null&&r.codexSessionId&&(r.codexSessionMode==="fork"||r.codexSessionMode==="resume"));te((r==null?void 0:r.codexProjectId)||""),se(o?r.codexSessionMode:"new"),ae(o&&r.codexSessionId||""),le(o&&r.codexSessionTitle||""),$(!!(t.requireExplicitSourceRef||!a||g||o||e==="cleanup")),A(null),u(null),F(!1),window.setTimeout(()=>{var be;(be=ce.current)==null||be.focus()},0)},[t,l==null?void 0:l.baseBranch,h]),n.useEffect(()=>{if(!t)return;let e=!1;return ie(!0),A(null),_e.getCodexSessions({projectId:M.trim()||void 0}).then(a=>{e||Se(a)}).catch(a=>{e||A(a instanceof Error?a.message:String(a))}).finally(()=>{e||ie(!1)}),()=>{e=!0}},[t,M,ke]),!t)return null;const D=(e,a)=>{J(i=>i.map((g,p)=>p===e?{...g,...a}:g))},Ee=async e=>{if(e.preventDefault(),!w.trim()){u("请填写任务指令");return}if(!x.trim()){u("请选择源分支");return}if(S!=="new"&&!L.trim()){u("选择分叉或续接模式时,请先选择或输入要关联的 Codex 对话 ID");return}F(!0),u(null);try{const a=t.pickedElements&&t.pickedElements.length>0?t.pickedElements:void 0,i=q==="race"&&b!=="review",g=i&&S==="resume"?"fork":S,p={kind:b,title:Y.trim()||void 0,instruction:w.trim(),sourceRef:x.trim(),...C?{sourceSha:C}:{},mode:I,sessionMode:g,...g!=="new"?{baseSessionId:L.trim(),baseSessionTitle:ne.trim()||void 0}:{},annotationCacheKey:t.annotationCacheKey,context:{route:t.route,viewport:t.viewport,regions:t.regions,...a?{pickedElements:a}:{},compareWith:t.compareWith&&t.compareWith!=="__working__"?t.compareWith:void 0}};if(i){const r=H.slice(0,m).map(o=>({...o.label.trim()?{label:o.label.trim()}:{},...o.model.trim()?{model:o.model.trim()}:{},...o.reasoningEffort?{reasoningEffort:o.reasoningEffort}:{},...o.instructionSuffix.trim()?{instructionSuffix:o.instructionSuffix.trim()}:{}}));await y({...p,attempts:r})}else await f({...p,...k.trim()?{model:k.trim()}:{},..._?{reasoningEffort:_}:{}})}catch(a){u(a instanceof Error?a.message:String(a))}finally{F(!1)}},v=q==="race"&&b!=="review",Ce=I==="plan-first"?"先出方案":"直接执行",$e=v?`${m} 路赛马`:"单方案",de=[x||"待选分支",$e,Ce,S==="fork"?"分叉继承":S==="resume"?"直接续接":"独立新会话",!v&&k.trim()?k.trim():null].filter(Boolean).join(" · "),Re=[...x&&!h.some(e=>e.ref===x)?[{value:x,label:x}]:[],...h.map(e=>({value:e.ref,label:e.label}))],De=[{value:"",label:`沿用全局 (${B})`},...ve.map(e=>({value:e.id,label:e.label}))],Te=[{value:"",label:`全局 (${B})`},...ve.map(e=>({value:e.id,label:e.label}))];return s.jsx(Me,{open:!0,title:"派发任务给 Codex",maxWidthClass:"max-w-xl",onClose:j,footer:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:j,disabled:R,className:"sheet-btn",children:"取消"}),s.jsxs("button",{type:"submit",form:"bl-task-composer-form",disabled:R||!w.trim(),className:"sheet-btn sheet-btn-primary disabled:opacity-40",children:[v?s.jsx(ze,{size:13}):s.jsx(Ke,{size:13}),s.jsx("span",{children:R?"派发中…":v?`并行启动 ${m} 路赛马`:"交给 Codex 执行"})]})]}),children:s.jsxs("form",{ref:oe,id:"bl-task-composer-form",onSubmit:e=>void Ee(e),className:"space-y-3.5 text-xs",children:[t.regions.length>0&&s.jsxs("div",{className:"p-3 rounded-xl space-y-1.5",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"caps",children:"附带视觉批注上下文"}),s.jsxs("span",{className:"mono text-[11px]",style:{color:"var(--muted)"},children:[t.route||"/"," ·"," ",t.viewport?`${t.viewport.width}×${t.viewport.height}`:"1280×800"]})]}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.regions.map(e=>s.jsxs("span",{className:"mono text-[11px] px-2 py-0.5 rounded-full",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:["#",e.id," ",W(e)]},e.id))})]}),t.pickedElements&&t.pickedElements.length>0&&s.jsxs("div",{className:"p-3 rounded-xl space-y-1.5",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"caps inline-flex items-center gap-1",children:[s.jsx(We,{size:11}),s.jsxs("span",{children:["附带点选元素(",t.pickedElements.length,")"]})]}),s.jsxs("span",{className:"mono text-[11px]",style:{color:"var(--muted)"},children:[t.route||"/"," ·"," ",t.viewport?`${t.viewport.width}×${t.viewport.height}`:"1280×800"]})]}),s.jsx("div",{className:"space-y-1",children:t.pickedElements.map((e,a)=>s.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] px-2 py-1 rounded-lg",style:{background:"var(--bg)",border:"1px solid var(--hair)"},children:[s.jsxs("span",{className:"mono truncate",style:{color:"var(--ink)"},children:["#",a+1," <",e.tag,"> ",e.selector]}),s.jsx("span",{className:"mono text-[10.5px] shrink-0",style:{color:e.source?"var(--accent)":"var(--muted)"},children:e.source?Be(e.source):"未定位源码"})]},`${e.selector}-${a}`))})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("label",{className:"caps",htmlFor:"bl-task-instruction",children:"任务指令"}),s.jsx("span",{className:"mono text-[10.5px]",style:{color:"var(--faint)"},children:"⌘/Ctrl + Enter 直接提交"})]}),s.jsx("textarea",{ref:ce,id:"bl-task-instruction",autoFocus:!0,value:w,onChange:e=>{const a=e.target.value;ee(a),d==="请填写任务指令"&&a.trim()&&u(null)},onKeyDown:e=>{var a;(e.metaKey||e.ctrlKey)&&e.key==="Enter"&&!R&&w.trim()&&(e.preventDefault(),(a=oe.current)==null||a.requestSubmit())},rows:5,placeholder:"描述需要 Codex 修改的视觉细节或代码改动…",className:"w-full p-3 text-xs leading-relaxed rounded-xl outline-none resize-y",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)",color:"var(--ink)"}})]}),s.jsxs("details",{open:re,"data-testid":"task-composer-advanced",className:"rounded-xl overflow-hidden",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[s.jsxs("summary",{onClick:e=>{e.preventDefault(),$(a=>!a)},className:"px-3 py-2 cursor-pointer select-none flex items-center justify-between gap-2 list-none",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium shrink-0",style:{color:"var(--ink)"},children:[re?s.jsx(Le,{size:13}):s.jsx(Ae,{size:13}),s.jsx(Pe,{size:12,style:{color:"var(--accent)"}}),s.jsx("span",{children:"高级执行选项"})]}),s.jsx("span",{className:"mono text-[11px] truncate",style:{color:x?"var(--muted)":"var(--redline, var(--accent))"},title:de,children:de})]}),s.jsxs("div",{className:"px-3 pb-3 pt-3 space-y-3.5",style:{borderTop:"1px solid var(--hair)",background:"var(--bg)"},children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"caps block mb-1",children:"基准源分支"}),s.jsx(K,{value:x,options:Re,onChange:e=>{Q(e),d==="请选择源分支"&&e.trim()&&u(null)},ariaLabel:"基准源分支",placeholder:"请选择源分支",size:"md",fullWidth:!0,className:"text-xs mono"}),C&&s.jsxs("div",{className:"flex items-center justify-between gap-2 mt-1.5 px-2 py-0.5 rounded-lg text-[10.5px] mono",style:{background:"var(--surface)",border:"1px solid var(--hair)"},"data-testid":"task-composer-source-sha",children:[s.jsxs("span",{style:{color:"var(--muted)"},children:["精确基线提交:",s.jsx("code",{children:C.slice(0,7)})]}),s.jsx("button",{type:"button",onClick:()=>V(""),className:"text-[10.5px] sheet-link",title:"改为跟随分支最新提交",children:"清除"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"caps block mb-1",children:"任务标题(可选)"}),s.jsx("input",{type:"text",value:Y,onChange:e=>Z(e.target.value),placeholder:"用于生成 bl/task-* 分支名",className:"sheet-input w-full h-8 text-xs"})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"caps mb-1.5",children:"任务类型"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:Xe.map(e=>s.jsxs("button",{type:"button",onClick:()=>{P(e.id),e.id==="cleanup"&&(O("plan-first"),$(!0)),e.id==="review"&&E("single")},className:"bl-choice-btn flex items-center justify-between gap-2","data-active":b===e.id?"true":void 0,title:e.hint,children:[s.jsx("span",{children:e.label}),e.id==="cleanup"&&s.jsx("span",{className:"mono text-[10px] opacity-75",children:"先出方案"})]},e.id))})]}),s.jsxs("div",{children:[s.jsx("div",{className:"caps mb-1.5",children:"执行模式"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:Ge.map(e=>{const a=b==="cleanup"&&e.id==="direct";return s.jsx("button",{type:"button",disabled:a,onClick:()=>O(e.id),className:"bl-choice-btn flex items-center justify-between gap-2 disabled:opacity-40","data-active":I===e.id?"true":void 0,title:a?"代码清理任务强制采用「先出方案」模式":e.hint,children:s.jsx("span",{children:e.label})},e.id)})})]}),s.jsxs("div",{className:"space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"caps",children:"执行策略"}),b==="review"&&s.jsx("span",{className:"text-[11px]",style:{color:"var(--muted)"},children:"只读审查不支持多方案赛马"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx("button",{type:"button",onClick:()=>E("single"),className:"bl-choice-btn flex items-center justify-between gap-2","data-active":v?void 0:"true",children:s.jsx("span",{children:"单方案执行"})}),s.jsx("button",{type:"button",disabled:b==="review",onClick:()=>{E("race"),$(!0)},className:"bl-choice-btn flex items-center justify-between gap-2 disabled:opacity-40","data-active":v?"true":void 0,title:b==="review"?"只读审查不支持多方案赛马":"同时启动 2–3 路独立分支方案并行实现,完成后一键对比择优采纳",children:s.jsx("span",{children:"多方案赛马(2–3 路并行)"})})]}),s.jsx("datalist",{id:"bl-codex-model-presets",children:Fe.map(e=>s.jsx("option",{value:e},e))}),v?s.jsxs("div",{className:"p-3 rounded-xl space-y-2.5",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"caps",children:"并行方案数"}),s.jsx("div",{className:"inline-flex items-center gap-1.5",children:[2,3].map(e=>s.jsxs("button",{type:"button",onClick:()=>U(e),"aria-pressed":m===e,className:"mono text-[11px] px-2.5 py-0.5 rounded-full transition-colors",style:{border:`1px solid ${m===e?"var(--accent)":"var(--hair-strong)"}`,color:m===e?"var(--accent)":"var(--muted)",background:m===e?"var(--accent-soft)":"transparent",fontWeight:m===e?600:450},children:[e," 路"]},e))})]}),s.jsx("div",{className:"space-y-2",children:H.slice(0,m).map((e,a)=>s.jsxs("div",{"data-race-attempt-draft":a,className:"p-2.5 rounded-lg space-y-2",style:{background:"var(--bg)",border:"1px solid var(--hair)"},children:[s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10.5px] mb-0.5",style:{color:"var(--muted)"},children:"方案名称"}),s.jsx("input",{type:"text","aria-label":`方案 ${a+1} 名称`,value:e.label,onChange:i=>D(a,{label:i.target.value}),placeholder:`方案 ${String.fromCharCode(65+a)}`,className:"sheet-input w-full h-7 text-[11px]"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10.5px] mb-0.5",style:{color:"var(--muted)"},children:"模型覆盖"}),s.jsx("input",{type:"text",list:"bl-codex-model-presets","aria-label":`方案 ${a+1} 模型覆盖`,value:e.model,onChange:i=>D(a,{model:i.target.value}),placeholder:`全局 (${N})`,className:"sheet-input w-full h-7 text-[11px] mono"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10.5px] mb-0.5",style:{color:"var(--muted)"},children:"推理强度"}),s.jsx(K,{ariaLabel:`方案 ${a+1} 推理强度覆盖`,value:e.reasoningEffort,options:Te,onChange:i=>D(a,{reasoningEffort:i}),size:"sm",fullWidth:!0,minMenuWidth:140,className:"text-[11px] mono"})]})]}),s.jsx("input",{type:"text","aria-label":`方案 ${a+1} 方向补充`,value:e.instructionSuffix,onChange:i=>D(a,{instructionSuffix:i.target.value}),placeholder:"可选方向补充,如「最小改动保守修复」或「结构重构优化」",className:"sheet-input w-full h-7 text-[11px]"})]},a))})]}):s.jsxs("div",{className:"p-2.5 rounded-xl grid grid-cols-2 gap-2.5",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] mb-1",style:{color:"var(--muted)"},children:"本次模型覆盖(可选)"}),s.jsx("input",{type:"text",list:"bl-codex-model-presets","aria-label":"本次模型覆盖",value:k,onChange:e=>X(e.target.value),placeholder:`沿用全局 (${N})`,className:"sheet-input w-full h-7 text-[11.5px] mono"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] mb-1",style:{color:"var(--muted)"},children:"本次推理强度(可选)"}),s.jsx(K,{ariaLabel:"本次推理强度覆盖",value:_,options:De,onChange:G,size:"sm",fullWidth:!0,className:"text-[11.5px] mono"})]})]})]}),s.jsx(qe,{compact:!0,isRace:v,data:je,loading:ye,error:Ne,projectId:M,sessionMode:S,sessionId:L,sessionTitle:ne,onProjectIdChange:te,onSessionModeChange:e=>{se(e),e==="new"&&(d!=null&&d.includes("Codex 对话 ID"))&&u(null)},onSelectSession:(e,a)=>{ae(e),le(a),e.trim()&&(d!=null&&d.includes("Codex 对话 ID"))&&u(null)},onRefresh:()=>we(e=>e+1)})]})]}),d&&s.jsx("div",{role:"alert",className:"p-3 rounded-lg",style:{background:"var(--redline-soft, var(--accent-soft))",color:"var(--redline, var(--accent))"},children:d})]})})};export{Ye as TaskComposer};
|
|
8
|
+
`)}const ss=()=>{var ue,me;const t=T(e=>e.composerDraft),j=T(e=>e.closeComposer),f=T(e=>e.createTask),S=T(e=>e.createRace),l=F(e=>e.repo),c=F(e=>e.config),h=n.useMemo(()=>((l==null?void 0:l.branches)??[]).filter(e=>!e.isWorkingTree),[l==null?void 0:l.branches]),N=((ue=c==null?void 0:c.agent)==null?void 0:ue.codexModel)||Ie,B=((me=c==null?void 0:c.agent)==null?void 0:me.codexReasoningEffort)||Oe,[b,P]=n.useState("visual-fix"),[I,O]=n.useState("direct"),[q,E]=n.useState("single"),[k,X]=n.useState(""),[_,G]=n.useState(""),[p,U]=n.useState(2),[H,J]=n.useState(ge),[x,Q]=n.useState(""),[C,V]=n.useState(""),[Y,Z]=n.useState(""),[w,ee]=n.useState(""),[y,se]=n.useState("new"),[M,te]=n.useState(""),[L,ae]=n.useState(""),[ne,le]=n.useState(""),[je,ye]=n.useState(null),[Se,re]=n.useState(!1),[Ne,A]=n.useState(null),[ke,we]=n.useState(0),[ie,$]=n.useState(!1),[R,z]=n.useState(!1),[d,u]=n.useState(null),oe=n.useRef(null),ce=n.useRef(null);if(n.useEffect(()=>{var pe,xe,fe,he;if(!t)return;const e=t.defaultKind??"visual-fix";P(e),O(e==="cleanup"?"plan-first":"direct"),E("single"),X(""),G(""),U(2),J(ge());const a=t.sourceRef&&t.sourceRef!=="__working__"?t.sourceRef:t.requireExplicitSourceRef?"":(l==null?void 0:l.baseBranch)||((pe=h[0])==null?void 0:pe.ref)||"main";Q(a);const r=((xe=t.sourceSha)==null?void 0:xe.trim())||"",g=/^[0-9a-f]{7,40}$/i.test(r)?r:"";V(g);const m=t.pickedElements??[];Z(t.defaultTitle||(t.regions.length===1?W(t.regions[0]):t.regions.length>1?`修复 ${t.regions.length} 处视觉批注`:m.length===1?`调整 ${((fe=m[0].source)==null?void 0:fe.component)||`<${m[0].tag}>`} 样式`:m.length>1?`调整 ${m.length} 处点选元素`:"")),ee(t.defaultInstruction||Ue(t.regions,t.pickedElements));const i=(he=F.getState().config)==null?void 0:he.repoConfig,o=!!(i!=null&&i.codexSessionId&&(i.codexSessionMode==="fork"||i.codexSessionMode==="resume"));te((i==null?void 0:i.codexProjectId)||""),se(o?i.codexSessionMode:"new"),ae(o&&i.codexSessionId||""),le(o&&i.codexSessionTitle||""),$(!!(t.requireExplicitSourceRef||!a||g||o||e==="cleanup")),A(null),u(null),z(!1),window.setTimeout(()=>{var be;(be=ce.current)==null||be.focus()},0)},[t,l==null?void 0:l.baseBranch,h]),n.useEffect(()=>{if(!t)return;let e=!1;return re(!0),A(null),_e.getCodexSessions({projectId:M.trim()||void 0}).then(a=>{e||ye(a)}).catch(a=>{e||A(a instanceof Error?a.message:String(a))}).finally(()=>{e||re(!1)}),()=>{e=!0}},[t,M,ke]),!t)return null;const D=(e,a)=>{J(r=>r.map((g,m)=>m===e?{...g,...a}:g))},Ee=async e=>{if(e.preventDefault(),!w.trim()){u("请填写任务指令");return}if(!x.trim()){u("请选择源分支");return}if(y!=="new"&&!L.trim()){u("选择分叉或续接模式时,请先选择或输入要关联的 Codex 对话 ID");return}z(!0),u(null);try{const a=t.pickedElements&&t.pickedElements.length>0?t.pickedElements:void 0,r=q==="race"&&b!=="review",g=r&&y==="resume"?"fork":y,m={kind:b,title:Y.trim()||void 0,instruction:w.trim(),sourceRef:x.trim(),...C?{sourceSha:C}:{},mode:I,sessionMode:g,...g!=="new"?{baseSessionId:L.trim(),baseSessionTitle:ne.trim()||void 0}:{},annotationCacheKey:t.annotationCacheKey,context:{route:t.route,viewport:t.viewport,regions:t.regions,...a?{pickedElements:a}:{},compareWith:t.compareWith&&t.compareWith!=="__working__"?t.compareWith:void 0}};if(r){const i=H.slice(0,p).map(o=>({...o.label.trim()?{label:o.label.trim()}:{},...o.model.trim()?{model:o.model.trim()}:{},...o.reasoningEffort?{reasoningEffort:o.reasoningEffort}:{},...o.instructionSuffix.trim()?{instructionSuffix:o.instructionSuffix.trim()}:{}}));await S({...m,attempts:i})}else await f({...m,...k.trim()?{model:k.trim()}:{},..._?{reasoningEffort:_}:{}})}catch(a){u(a instanceof Error?a.message:String(a))}finally{z(!1)}},v=q==="race"&&b!=="review",Ce=I==="plan-first"?"先出方案":"直接执行",$e=v?`${p} 路赛马`:"单方案",de=[x||"待选分支",$e,Ce,y==="fork"?"分叉继承":y==="resume"?"直接续接":"独立新会话",!v&&k.trim()?k.trim():null].filter(Boolean).join(" · "),Re=[...x&&!h.some(e=>e.ref===x)?[{value:x,label:x}]:[],...h.map(e=>({value:e.ref,label:e.label}))],De=[{value:"",label:`沿用全局 (${B})`},...ve.map(e=>({value:e.id,label:e.label}))],Te=[{value:"",label:`全局 (${B})`},...ve.map(e=>({value:e.id,label:e.label}))];return s.jsx(Me,{open:!0,title:"派发任务给 Codex",maxWidthClass:"max-w-xl",onClose:j,footer:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:j,disabled:R,className:"sheet-btn",children:"取消"}),s.jsxs("button",{type:"submit",form:"bl-task-composer-form",disabled:R||!w.trim(),className:"sheet-btn sheet-btn-primary disabled:opacity-40",children:[v?s.jsx(Pe,{size:13}):s.jsx(qe,{size:13}),s.jsx("span",{children:R?"派发中…":v?`并行启动 ${p} 路赛马`:"交给 Codex 执行"})]})]}),children:s.jsxs("form",{ref:oe,id:"bl-task-composer-form",onSubmit:e=>void Ee(e),className:"space-y-3.5 text-xs",children:[t.regions.length>0&&s.jsxs("div",{className:"p-3 rounded-xl space-y-1.5",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"caps",children:"附带视觉批注上下文"}),s.jsxs("span",{className:"mono text-[11px]",style:{color:"var(--muted)"},children:[t.route||"/"," ·"," ",t.viewport?`${t.viewport.width}×${t.viewport.height}`:"1280×800"]})]}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.regions.map(e=>s.jsxs("span",{className:"mono text-[11px] px-2 py-0.5 rounded-full",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:["#",e.id," ",W(e)]},e.id))})]}),t.pickedElements&&t.pickedElements.length>0&&s.jsxs("div",{className:"p-3 rounded-xl space-y-1.5",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"caps inline-flex items-center gap-1",children:[s.jsx(Fe,{size:11}),s.jsxs("span",{children:["附带点选元素(",t.pickedElements.length,")"]})]}),s.jsxs("span",{className:"mono text-[11px]",style:{color:"var(--muted)"},children:[t.route||"/"," ·"," ",t.viewport?`${t.viewport.width}×${t.viewport.height}`:"1280×800"]})]}),s.jsx("div",{className:"space-y-1",children:t.pickedElements.map((e,a)=>s.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] px-2 py-1 rounded-lg",style:{background:"var(--bg)",border:"1px solid var(--hair)"},children:[s.jsxs("span",{className:"mono truncate",style:{color:"var(--ink)"},children:["#",a+1," <",e.tag,"> ",e.selector]}),s.jsx("span",{className:"mono text-[10.5px] shrink-0",style:{color:e.source?"var(--accent)":"var(--muted)"},children:e.source?Ae(e.source):"未定位源码"})]},`${e.selector}-${a}`))})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("label",{className:"caps",htmlFor:"bl-task-instruction",children:"任务指令"}),s.jsx("span",{className:"mono text-[10.5px]",style:{color:"var(--faint)"},children:"⌘/Ctrl + Enter 直接提交"})]}),s.jsx("textarea",{ref:ce,id:"bl-task-instruction",autoFocus:!0,value:w,onChange:e=>{const a=e.target.value;ee(a),d==="请填写任务指令"&&a.trim()&&u(null)},onKeyDown:e=>{var a;(e.metaKey||e.ctrlKey)&&e.key==="Enter"&&!R&&w.trim()&&(e.preventDefault(),(a=oe.current)==null||a.requestSubmit())},rows:5,placeholder:"描述需要 Codex 修改的视觉细节或代码改动…",className:"w-full p-3 text-xs leading-relaxed rounded-xl outline-none resize-y",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)",color:"var(--ink)"}})]}),s.jsxs("details",{open:ie,"data-testid":"task-composer-advanced",className:"rounded-xl overflow-hidden",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[s.jsxs("summary",{onClick:e=>{e.preventDefault(),$(a=>!a)},className:"px-3 py-2 cursor-pointer select-none flex items-center justify-between gap-2 list-none",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium shrink-0",style:{color:"var(--ink)"},children:[ie?s.jsx(Ke,{size:13}):s.jsx(We,{size:13}),s.jsx(Be,{size:12,style:{color:"var(--accent)"}}),s.jsx("span",{children:"高级执行选项"})]}),s.jsx("span",{className:"mono text-[11px] truncate",style:{color:x?"var(--muted)":"var(--redline, var(--accent))"},title:de,children:de})]}),s.jsxs("div",{className:"px-3 pb-3 pt-3 space-y-3.5",style:{borderTop:"1px solid var(--hair)",background:"var(--bg)"},children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"caps block mb-1",children:"基准源分支"}),s.jsx(K,{value:x,options:Re,onChange:e=>{Q(e),d==="请选择源分支"&&e.trim()&&u(null)},ariaLabel:"基准源分支",placeholder:"请选择源分支",size:"md",fullWidth:!0,className:"text-xs mono"}),C&&s.jsxs("div",{className:"flex items-center justify-between gap-2 mt-1.5 px-2 py-0.5 rounded-lg text-[10.5px] mono",style:{background:"var(--surface)",border:"1px solid var(--hair)"},"data-testid":"task-composer-source-sha",children:[s.jsxs("span",{style:{color:"var(--muted)"},children:["精确基线提交:",s.jsx("code",{children:C.slice(0,7)})]}),s.jsx("button",{type:"button",onClick:()=>V(""),className:"text-[10.5px] sheet-link",title:"改为跟随分支最新提交",children:"清除"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"caps block mb-1",children:"任务标题(可选)"}),s.jsx("input",{type:"text",value:Y,onChange:e=>Z(e.target.value),placeholder:"用于生成 bl/task-* 分支名",className:"sheet-input w-full h-8 text-xs"})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"caps mb-1.5",children:"任务类型"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:Xe.map(e=>s.jsxs("button",{type:"button",onClick:()=>{P(e.id),e.id==="cleanup"&&(O("plan-first"),$(!0)),e.id==="review"&&E("single")},className:"bl-choice-btn flex items-center justify-between gap-2","data-active":b===e.id?"true":void 0,title:e.hint,children:[s.jsx("span",{children:e.label}),e.id==="cleanup"&&s.jsx("span",{className:"mono text-[10px] opacity-75",children:"先出方案"})]},e.id))})]}),s.jsxs("div",{children:[s.jsx("div",{className:"caps mb-1.5",children:"执行模式"}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:Ge.map(e=>{const a=b==="cleanup"&&e.id==="direct";return s.jsx("button",{type:"button",disabled:a,onClick:()=>O(e.id),className:"bl-choice-btn flex items-center justify-between gap-2 disabled:opacity-40","data-active":I===e.id?"true":void 0,title:a?"代码清理任务强制采用「先出方案」模式":e.hint,children:s.jsx("span",{children:e.label})},e.id)})})]}),s.jsxs("div",{className:"space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"caps",children:"执行策略"}),b==="review"&&s.jsx("span",{className:"text-[11px]",style:{color:"var(--muted)"},children:"只读审查不支持多方案赛马"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx("button",{type:"button",onClick:()=>E("single"),className:"bl-choice-btn flex items-center justify-between gap-2","data-active":v?void 0:"true",children:s.jsx("span",{children:"单方案执行"})}),s.jsx("button",{type:"button",disabled:b==="review",onClick:()=>{E("race"),$(!0)},className:"bl-choice-btn flex items-center justify-between gap-2 disabled:opacity-40","data-active":v?"true":void 0,title:b==="review"?"只读审查不支持多方案赛马":"同时启动 2–3 路独立分支方案并行实现,完成后一键对比择优采纳",children:s.jsx("span",{children:"多方案赛马(2–3 路并行)"})})]}),s.jsx("datalist",{id:"bl-codex-model-presets",children:Le.map(e=>s.jsx("option",{value:e},e))}),v?s.jsxs("div",{className:"p-3 rounded-xl space-y-2.5",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"caps",children:"并行方案数"}),s.jsx("div",{className:"inline-flex items-center gap-1.5",children:[2,3].map(e=>s.jsxs("button",{type:"button",onClick:()=>U(e),"aria-pressed":p===e,className:"mono text-[11px] px-2.5 py-0.5 rounded-full transition-colors",style:{border:`1px solid ${p===e?"var(--accent)":"var(--hair-strong)"}`,color:p===e?"var(--accent)":"var(--muted)",background:p===e?"var(--accent-soft)":"transparent",fontWeight:p===e?600:450},children:[e," 路"]},e))})]}),s.jsx("div",{className:"space-y-2",children:H.slice(0,p).map((e,a)=>s.jsxs("div",{"data-race-attempt-draft":a,className:"p-2.5 rounded-lg space-y-2",style:{background:"var(--bg)",border:"1px solid var(--hair)"},children:[s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10.5px] mb-0.5",style:{color:"var(--muted)"},children:"方案名称"}),s.jsx("input",{type:"text","aria-label":`方案 ${a+1} 名称`,value:e.label,onChange:r=>D(a,{label:r.target.value}),placeholder:`方案 ${String.fromCharCode(65+a)}`,className:"sheet-input w-full h-7 text-[11px]"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10.5px] mb-0.5",style:{color:"var(--muted)"},children:"模型覆盖"}),s.jsx("input",{type:"text",list:"bl-codex-model-presets","aria-label":`方案 ${a+1} 模型覆盖`,value:e.model,onChange:r=>D(a,{model:r.target.value}),placeholder:`全局 (${N})`,className:"sheet-input w-full h-7 text-[11px] mono"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10.5px] mb-0.5",style:{color:"var(--muted)"},children:"推理强度"}),s.jsx(K,{ariaLabel:`方案 ${a+1} 推理强度覆盖`,value:e.reasoningEffort,options:Te,onChange:r=>D(a,{reasoningEffort:r}),size:"sm",fullWidth:!0,minMenuWidth:140,className:"text-[11px] mono"})]})]}),s.jsx("input",{type:"text","aria-label":`方案 ${a+1} 方向补充`,value:e.instructionSuffix,onChange:r=>D(a,{instructionSuffix:r.target.value}),placeholder:"可选方向补充,如「最小改动保守修复」或「结构重构优化」",className:"sheet-input w-full h-7 text-[11px]"})]},a))})]}):s.jsxs("div",{className:"p-2.5 rounded-xl grid grid-cols-2 gap-2.5",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] mb-1",style:{color:"var(--muted)"},children:"本次模型覆盖(可选)"}),s.jsx("input",{type:"text",list:"bl-codex-model-presets","aria-label":"本次模型覆盖",value:k,onChange:e=>X(e.target.value),placeholder:`沿用全局 (${N})`,className:"sheet-input w-full h-7 text-[11.5px] mono"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] mb-1",style:{color:"var(--muted)"},children:"本次推理强度(可选)"}),s.jsx(K,{ariaLabel:"本次推理强度覆盖",value:_,options:De,onChange:G,size:"sm",fullWidth:!0,className:"text-[11.5px] mono"})]})]})]}),s.jsx(ze,{compact:!0,isRace:v,data:je,loading:Se,error:Ne,projectId:M,sessionMode:y,sessionId:L,sessionTitle:ne,onProjectIdChange:te,onSessionModeChange:e=>{se(e),e==="new"&&(d!=null&&d.includes("Codex 对话 ID"))&&u(null)},onSelectSession:(e,a)=>{ae(e),le(a),e.trim()&&(d!=null&&d.includes("Codex 对话 ID"))&&u(null)},onRefresh:()=>we(e=>e+1)})]})]}),d&&s.jsx("div",{role:"alert",className:"p-3 rounded-lg",style:{background:"var(--redline-soft, var(--accent-soft))",color:"var(--redline, var(--accent))"},children:d})]})})};export{ss as TaskComposer};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ExecutionTraceView-BuKMTJLz.js","./vendor-react-CIotE-6Q.js","./index-CuRBE0Be.js","./vendor-icons-BeN0on9X.js","./index-B76NgI6o.css","./LiquidSelect-BcHivJrw.js","./ExecutionTraceView-BI9foB9i.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{g as re,S as je,n as fe,C as me,c as $e,A as we,u as ae,a as Ae,b,d as Re,i as Fe,e as ge,M as Pe,_ as Oe,f as Le,h as qe}from"./index-CuRBE0Be.js";import{r as i,j as e,R as ke}from"./vendor-react-CIotE-6Q.js";import{i as _e,j as Ce,k as De,T as le,l as Ve,m as Ue,R as Ke,n as Se,G as Ie,o as Ge,p as Ee,F as He,g as Te,C as ze,a as Me,q as We,r as Xe,s as Qe,X as Ye,t as Ze,u as Je,h as es,B as ss}from"./vendor-icons-BeN0on9X.js";import{L as ve}from"./LiquidSelect-BcHivJrw.js";import{V as ts}from"./VerificationSummaryCard-D5fnYeAl.js";const be={high:{label:"高置信",tone:"var(--diff-add-ink)"},medium:{label:"中置信",tone:"#d97706"},low:{label:"低置信",tone:"var(--redline, var(--accent))"}},ye={modify:{label:"修改",color:"var(--accent)"},create:{label:"新增",color:"var(--diff-add-ink)"},delete:{label:"删除",color:"var(--redline, var(--accent))"}},as=({task:a,onApprove:m,onRejectPlan:A})=>{var $;const o=a.planStructured,w=(($=a.plan)==null?void 0:$.trim())||"",x=!!o||!!w,[_,y]=i.useState("none"),[F,p]=i.useState(""),[g,B]=i.useState(""),[n,f]=i.useState(null),[N,u]=i.useState(null),[k,P]=i.useState(!1);if(i.useEffect(()=>{y("none"),p(a.editedPlan||a.plan||""),B(""),f(null),u(null),P(!1)},[a.id,a.version]),!x)return null;const v=a.status==="awaiting"&&n===null,T=re(a.status),S=a.status!=="awaiting"?`当前状态为「${T.label}」,仅「待确认」状态可操作方案`:void 0,D=async()=>{if(v){f("approve"),u(null);try{await m(a.id)}catch(r){u(r instanceof Error?r.message:String(r))}finally{f(null)}}},U=async r=>{if(r.preventDefault(),!v)return;const c=F.trim();if(!c){u("修改后的方案内容不能为空");return}f("edit"),u(null);try{await m(a.id,c),y("none")}catch(I){u(I instanceof Error?I.message:String(I))}finally{f(null)}},O=async r=>{if(r.preventDefault(),!v)return;const c=g.trim();if(!c){u("请填写打回反馈或回答 Codex 的疑问");return}f("reject"),u(null);try{await A(a.id,c),y("none"),B("")}catch(I){u(I instanceof Error?I.message:String(I))}finally{f(null)}},L=()=>{var c;if(!v||!((c=o==null?void 0:o.questions)!=null&&c.length))return;const r=o.questions.map((I,M)=>`问题 ${M+1}:${I}
|
|
3
|
+
回答:`).join(`
|
|
4
|
+
|
|
5
|
+
`);B(r),y("reject")},C=o?be[o.confidence]??be.medium:null;return e.jsxs("section",{"aria-label":"修改方案确认卡片","data-plan-card":a.id,className:"bl-plan-card p-2.5 space-y-2 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"caps",style:{color:"var(--accent)"},children:"修改方案"}),C&&e.jsx("span",{className:"mono text-[10.5px] font-semibold px-1.5 py-0.5 rounded",style:{border:`1px solid ${C.tone}`,color:C.tone},children:C.label})]}),a.status==="awaiting"?e.jsx("span",{className:"mono text-[10.5px] font-medium",style:{color:"#d97706"},children:"等待确认执行"}):e.jsxs("span",{className:"mono text-[10.5px]",style:{color:"var(--faint)"},children:["已锁定 · ",T.label]})]}),o&&o.questions.length>0&&e.jsxs("div",{role:"note","data-plan-questions":"true",className:"bl-plan-questions p-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"bl-plan-questions-title flex items-center gap-1.5 font-semibold text-[12px]",children:[e.jsx(_e,{size:14,className:"shrink-0"}),e.jsx("span",{children:"Codex 有疑问,建议先回答再执行"})]}),v&&e.jsx("button",{type:"button",onClick:L,className:"text-[11px] font-medium underline underline-offset-2 shrink-0",style:{color:"var(--accent)"},children:"填入反馈回答 →"})]}),e.jsx("ol",{className:"list-decimal pl-4 space-y-1 text-[11.5px]",children:o.questions.map((r,c)=>e.jsx("li",{className:"break-words leading-relaxed",children:r},c))})]}),o?e.jsxs("div",{className:"space-y-2",children:[o.summary&&e.jsx("div",{className:"font-medium leading-relaxed break-words",style:{color:"var(--ink)"},children:o.summary}),o.steps.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"caps text-[10px]",children:["修改步骤(",o.steps.length,")"]}),e.jsx("ol",{className:"space-y-1",children:o.steps.map((r,c)=>e.jsxs("li",{className:"px-2 py-1.5 rounded-lg space-y-0.5",style:{background:"var(--bg)",border:"1px solid var(--hair)"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"mono text-[10.5px] font-semibold",style:{color:"var(--accent)"},children:String(c+1).padStart(2,"0")}),r.regionId!==null&&r.regionId!==void 0&&e.jsxs("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:["区域 #",r.regionId]}),e.jsx("span",{className:"font-medium break-words",children:r.action})]}),e.jsx("p",{className:"text-[11.5px] leading-relaxed break-words",style:{color:"var(--muted)"},children:r.detail})]},c))})]}),o.files.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"caps text-[10px] flex items-center gap-1",children:[e.jsx(Ce,{size:11}),e.jsxs("span",{children:["计划修改的文件(",o.files.length,")"]})]}),e.jsx("div",{className:"space-y-1",children:o.files.map(r=>{const c=ye[r.change]??ye.modify;return e.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 py-1 rounded text-[11px] mono",style:{background:"var(--bg)",border:"1px solid var(--hair)"},children:[e.jsx("span",{className:"truncate",title:r.path,children:r.path}),e.jsx("span",{className:"shrink-0 text-[10px] font-semibold",style:{color:c.color},children:c.label})]},`${r.change}-${r.path}`)})})]}),o.risks.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"caps text-[10px] flex items-center gap-1",style:{color:"#d97706"},children:[e.jsx(De,{size:11}),e.jsxs("span",{children:["潜在风险(",o.risks.length,")"]})]}),e.jsx("ul",{className:"space-y-1 pl-3.5 list-disc text-[11.5px]",style:{color:"var(--muted)"},children:o.risks.map((r,c)=>e.jsx("li",{className:"break-words leading-relaxed",children:r},c))})]}),w&&e.jsxs("details",{open:k,onToggle:r=>P(r.currentTarget.open),className:"pt-1",style:{borderTop:"1px dashed var(--hair)"},children:[e.jsx("summary",{onClick:r=>{r.preventDefault(),P(c=>!c)},className:"cursor-pointer select-none text-[11px] font-medium",style:{color:"var(--muted)"},children:"查看 Markdown 方案原文"}),k&&e.jsx("div",{className:"mt-1.5",children:e.jsx(je,{content:w})})]})]}):e.jsx(je,{content:w}),a.planRejectFeedback&&e.jsxs("div",{className:"text-[11px] px-2 py-1.5 rounded",style:{background:"var(--bg)",border:"1px dashed var(--hair-strong)",color:"var(--muted)"},children:["上次打回反馈:",a.planRejectFeedback]}),N&&e.jsxs("div",{role:"alert",className:"p-2 rounded text-[11.5px] flex items-start gap-1.5",style:{background:"var(--redline-soft, var(--accent-soft))",color:"var(--redline, var(--accent))"},children:[e.jsx(le,{size:13,className:"shrink-0 mt-0.5"}),e.jsx("span",{className:"break-words",children:N})]}),_==="edit"&&a.status==="awaiting"&&e.jsxs("form",{onSubmit:r=>void U(r),className:"space-y-2 pt-1",children:[e.jsx("label",{className:"caps block text-[10px]",htmlFor:`bl-edit-plan-${a.id}`,children:"编辑方案(提交后将以修改版为准执行)"}),e.jsx("textarea",{id:`bl-edit-plan-${a.id}`,"aria-label":"编辑修改方案",value:F,onChange:r=>p(r.target.value),rows:5,className:"w-full p-2.5 text-[11.5px] mono leading-relaxed rounded-lg outline-none resize-y",style:{background:"var(--bg)",border:"1px solid var(--hair-strong)",color:"var(--ink)"}}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"submit",disabled:!v||!F.trim(),className:"sheet-btn sheet-btn-primary disabled:opacity-40",style:{height:28,padding:"0 10px",fontSize:11.5},children:n==="edit"?"提交中…":"提交修改并执行"}),e.jsx("button",{type:"button",disabled:n!==null,onClick:()=>y("none"),className:"sheet-btn",style:{height:28,padding:"0 10px",fontSize:11.5},children:"取消"})]})]}),_==="reject"&&a.status==="awaiting"&&e.jsxs("form",{onSubmit:r=>void O(r),className:"space-y-2 pt-1",children:[e.jsx("label",{className:"caps block text-[10px]",htmlFor:`bl-reject-plan-${a.id}`,children:"打回重写反馈(可填写修正要求或回答上方疑问)"}),e.jsx("textarea",{id:`bl-reject-plan-${a.id}`,"aria-label":"打回重写反馈",value:g,onChange:r=>B(r.target.value),rows:4,placeholder:"请说明方案需要调整的地方,或回答 Codex 提出的问题…",className:"w-full p-2.5 text-[11.5px] leading-relaxed rounded-lg outline-none resize-y",style:{background:"var(--bg)",border:"1px solid var(--hair-strong)",color:"var(--ink)"}}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"submit",disabled:!v||!g.trim(),className:"sheet-btn sheet-btn-accent disabled:opacity-40",style:{height:28,padding:"0 10px",fontSize:11.5},children:n==="reject"?"提交中…":"提交反馈并重新规划"}),e.jsx("button",{type:"button",disabled:n!==null,onClick:()=>y("none"),className:"sheet-btn",style:{height:28,padding:"0 10px",fontSize:11.5},children:"取消"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap pt-1",children:[e.jsxs("button",{type:"button",disabled:!v,title:S||"直接按当前方案开始修改",onClick:()=>void D(),className:"sheet-btn sheet-btn-primary disabled:opacity-40",style:{height:28,padding:"0 10px",fontSize:11.5},children:[e.jsx(Ve,{size:12}),e.jsx("span",{children:n==="approve"?"启动执行中…":"确认执行"})]}),e.jsxs("button",{type:"button",disabled:!v,title:S||"修改方案正文后再提交执行",onClick:()=>{p(a.editedPlan||a.plan||""),y(r=>r==="edit"?"none":"edit"),u(null)},className:"sheet-btn disabled:opacity-40",style:{height:28,padding:"0 10px",fontSize:11.5},children:[e.jsx(Ue,{size:12}),e.jsx("span",{children:"修改后执行"})]}),e.jsxs("button",{type:"button",disabled:!v,title:S||"填写反馈让 Codex 重新输出方案",onClick:()=>{y(r=>r==="reject"?"none":"reject"),u(null)},className:"sheet-btn sheet-btn-accent disabled:opacity-40",style:{height:28,padding:"0 10px",fontSize:11.5},children:[e.jsx(Ke,{size:12}),e.jsx("span",{children:"打回重写"})]})]}),S&&e.jsx("div",{className:"text-[11px]",style:{color:"var(--faint)"},children:S})]})};function ne(a,m){var o;if((o=a.raceLabel)!=null&&o.trim())return a.raceLabel.trim();const A=typeof a.raceIndex=="number"?a.raceIndex:m;return`方案 ${String.fromCharCode(65+A)}`}function ns(a){const m=fe(a.verification);return m?m.skipped?{text:"跳过验收",tone:"neutral"}:m.passed===!0?{text:"验收通过",tone:"success"}:m.passed===!1?{text:"未通过",tone:"danger"}:{text:"待判定",tone:"neutral"}:null}const rs=({attempts:a,selectedTaskId:m,onSelectTask:A,onCompareAttempts:o})=>{const w=i.useMemo(()=>[...a].sort((n,f)=>(n.raceIndex??0)-(f.raceIndex??0)||n.id.localeCompare(f.id)),[a]),x=i.useMemo(()=>w.filter(n=>n.status==="done"&&!!n.taskBranch),[w]),[_,y]=i.useState(""),[F,p]=i.useState("");if(i.useEffect(()=>{var N;if(x.length<2){y(""),p("");return}const n=x.some(u=>u.id===m)?m:x[0].id,f=((N=x.find(u=>u.id!==n))==null?void 0:N.id)??x[1].id;y(u=>x.some(k=>k.id===u)?u:n),p(u=>x.some(k=>k.id===u)&&u!==n?u:f)},[x,m]),w.length===0)return null;const g=x.find(n=>n.id===_)??x[0],B=x.find(n=>n.id===F&&n.id!==(g==null?void 0:g.id))??x.find(n=>n.id!==(g==null?void 0:g.id));return e.jsxs("section",{"aria-label":"多方案赛马对比条","data-race-strip":w[0].raceId,className:"bl-race-strip p-3 space-y-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Se,{size:13,style:{color:"var(--accent)"}}),e.jsx("span",{className:"caps",style:{color:"var(--accent)"},children:"多方案赛马对比"}),e.jsxs("span",{className:"mono text-[10.5px]",style:{color:"var(--muted)"},children:[w.length," 路"]})]}),x.length>=2&&g&&B&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[x.length>=3&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{ariaLabel:"对比方案 A",size:"xs",minMenuWidth:128,value:g.id,options:x.map((n,f)=>({value:n.id,label:ne(n,f)})),onChange:n=>{if(y(n),n===F){const f=x.find(N=>N.id!==n);f&&p(f.id)}}}),e.jsx("span",{className:"mono text-[10.5px]",style:{color:"var(--faint)"},children:"vs"}),e.jsx(ve,{ariaLabel:"对比方案 B",size:"xs",minMenuWidth:128,value:B.id,options:x.filter(n=>n.id!==g.id).map((n,f)=>({value:n.id,label:ne(n,f)})),onChange:p})]}),e.jsxs("button",{type:"button",onClick:()=>o(g.taskBranch,B.taskBranch),className:"sheet-btn sheet-btn-primary",style:{height:26,padding:"0 10px",fontSize:11},title:`在对比舞台并排比较 ${g.taskBranch} 与 ${B.taskBranch}`,children:[e.jsx(Ie,{size:11}),e.jsx("span",{children:"对比两方案"})]})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:w.map((n,f)=>{var v;const N=n.id===m,u=re(n.status),k=ns(n),P=((v=n.changedFiles)==null?void 0:v.length)??0;return e.jsxs("button",{type:"button","data-race-compare-card":n.id,"data-active":N?"true":void 0,onClick:()=>A(n.id),className:"bl-race-card text-left p-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-semibold text-[11.5px] truncate",style:{color:N?"var(--accent)":"var(--ink)"},children:ne(n,f)}),e.jsx("span",{className:"bl-task-badge mono shrink-0","data-tone":u.tone,"data-task-status":n.status,children:u.label})]}),(n.modelOverride||n.reasoningEffortOverride)&&e.jsx("div",{className:"mono text-[10px] truncate",style:{color:"var(--muted)"},children:[n.modelOverride,n.reasoningEffortOverride].filter(Boolean).join(" · ")}),e.jsxs("div",{className:"flex items-center justify-between gap-1.5 text-[10.5px] mono",children:[e.jsx("span",{style:{color:"var(--faint)"},children:P>0?`${P} 文件`:"待产出"}),k&&e.jsx("span",{style:{color:k.tone==="success"?"var(--diff-add-ink)":k.tone==="danger"?"var(--redline, var(--accent))":"var(--muted)"},children:k.text})]})]},n.id)})})]})},ls=({task:a,maxFollowUps:m=5,cleanableRaceSiblingCount:A=0,onAccept:o,onReject:w,onFollowUp:x,onOpenPrDraft:_,onRetryCleanup:y,cleaning:F=!1})=>{var ee;const p=fe(a.verification),g=!!(p!=null&&p.annotation),B=a.followUpCount??0,n=Math.max(0,m-B),[f,N]=i.useState(!1),[u,k]=i.useState(!0),[P,v]=i.useState(!1),[T,S]=i.useState(null),[D,U]=i.useState(""),[O,L]=i.useState(g&&(p==null?void 0:p.passed)===!1),[C,$]=i.useState(null),[r,c]=i.useState(null),[I,M]=i.useState(!1),Q=((ee=p==null?void 0:p.annotation)==null?void 0:ee.cacheKey)??"",z=(p==null?void 0:p.passed)??null;if(i.useEffect(()=>{N(!1),k(!0),v(!1),S(null),$(null),c(null),M(!1),U("")},[a.id]),i.useEffect(()=>{L(g&&z===!1)},[a.id,g,Q,z]),a.status==="draft"||a.status==="planning"||a.status==="awaiting")return null;const ie=re(a.status),Y=a.status==="running"||a.status==="committing"||a.status==="verifying"||a.status==="accepting"||a.status==="rejecting",q=(()=>{switch(a.status){case"accepting":return"正在执行 squash 采纳合入,请稍候";case"rejecting":return"正在拒绝任务并清理分支,请稍候";case"running":return"任务正在执行中,完成后可采纳、拒绝或追问";case"committing":return"任务正在提交代码,完成后可操作";case"verifying":return"正在自动视觉验收,完成后可操作";case"accepted":return"任务已采纳并合入源分支";case"rejected":return"任务已拒绝并清理";case"cancelled":return"任务已取消,无法操作结果";case"interrupted":return"任务已中断,无法直接采纳或追问";default:return null}})(),t=a.status==="done"&&!!a.taskBranch&&T===null,K=(a.status==="done"||a.status==="failed")&&T===null,G=(a.status==="done"||a.status==="failed")&&!!a.taskBranch&&n>0&&T===null,H=t?void 0:q||(a.status==="failed"?"失败任务不可直接采纳,可追问修复或拒绝清理":a.taskBranch?void 0:"该任务未产生代码分支,无需采纳"),ce=K?void 0:q||void 0,W=G?void 0:q||(a.taskBranch?n<=0?`已达最大追问次数上限(${m} 次)`:void 0:"该任务尚无任务分支,无法继续追问"),oe=async()=>{S("accept"),$(null),c(null);try{await o(a.id,A>0?{rejectOtherAttempts:u}:void 0),N(!1)}catch(h){if(N(!1),h instanceof we&&h.status===409){const R=h.data??{},pe=Array.isArray(R.conflicts)?R.conflicts.filter(s=>typeof s=="string"):[],se=typeof R.suggestedCommand=="string"&&R.suggestedCommand.trim()?R.suggestedCommand.trim():void 0;$({message:h.message,conflicts:pe,suggestedCommand:se})}else c(h instanceof Error?h.message:String(h))}finally{S(null)}},Z=async()=>{S("reject"),c(null);try{await w(a.id),v(!1)}catch(h){v(!1),c(h instanceof Error?h.message:String(h))}finally{S(null)}},J=async h=>{if(h.preventDefault(),!(!G||!D.trim())){S("follow-up"),c(null),$(null);try{await x(a.id,D.trim(),g?O:!1),U("")}catch(R){c(R instanceof Error?R.message:String(R))}finally{S(null)}}},de=async h=>{await $e(h)&&(M(!0),setTimeout(()=>M(!1),2e3))},xe=(a.status==="done"||a.status==="accepted")&&!!_,X=(a.status==="accepted"||a.status==="rejected")&&!!a.cleanupError&&!!y;return e.jsxs("section",{"aria-label":"任务结果操作栏","data-task-action-bar":a.id,className:"bl-action-bar p-3 space-y-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"caps",children:"结果操作"}),e.jsxs("span",{className:"mono text-[10.5px]",style:{color:"var(--faint)"},children:["状态:",ie.label]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",disabled:!t,title:H||`以 squash 方式合并到 ${a.sourceRef}`,onClick:()=>{k(!0),N(!0)},className:"sheet-btn sheet-btn-primary disabled:opacity-40",style:{height:28,padding:"0 10px",fontSize:11.5},children:[e.jsx(Ge,{size:12}),e.jsx("span",{children:T==="accept"||a.status==="accepting"?"采纳中…":"采纳修改"})]}),e.jsxs("button",{type:"button",disabled:!K,title:ce||"拒绝任务并清理任务分支与工作区",onClick:()=>v(!0),className:"sheet-btn sheet-btn-accent disabled:opacity-40",style:{height:28,padding:"0 10px",fontSize:11.5},children:[e.jsx(Ee,{size:12}),e.jsx("span",{children:T==="reject"||a.status==="rejecting"?"拒绝中…":"拒绝任务"})]}),xe&&e.jsxs("button",{type:"button",disabled:T!==null,title:"汇总改动文件与视觉验收截图生成可复制/导出的 PR 描述",onClick:()=>_(a),className:"sheet-btn disabled:opacity-40",style:{height:28,padding:"0 10px",fontSize:11.5},children:[e.jsx(He,{size:12}),e.jsx("span",{children:"生成 PR 产物"})]}),X&&e.jsxs("button",{type:"button",disabled:F,onClick:()=>void y(a),className:"sheet-btn",style:{height:28,padding:"0 10px",fontSize:11.5},children:[e.jsx(Te,{size:12}),e.jsx("span",{children:F?"清理中…":"重试清理"})]})]}),(Y||q)&&e.jsx("div",{className:"text-[11px]",style:{color:"var(--muted)"},"data-action-disabled-reason":"true",children:q}),C&&e.jsxs("div",{role:"alert","data-accept-conflict":C.conflicts.length>0?"merge-conflict":"checked-out",className:"p-2.5 rounded-lg space-y-2 text-[11.5px]",style:{background:"var(--redline-soft, var(--accent-soft))",border:"1px solid var(--redline, var(--accent))"},children:[e.jsxs("div",{className:"flex items-start gap-1.5 font-medium",style:{color:"var(--redline, var(--accent))"},children:[e.jsx(le,{size:13,className:"shrink-0 mt-0.5"}),e.jsx("span",{className:"break-words",children:C.message})]}),C.conflicts.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-[11px] font-medium",style:{color:"var(--ink)"},children:["冲突文件列表(",C.conflicts.length,"):"]}),e.jsx("ul",{className:"space-y-0.5 pl-4 list-disc mono text-[11px]",style:{color:"var(--ink)"},children:C.conflicts.map(h=>e.jsx("li",{className:"break-all",children:h},h))})]}),C.suggestedCommand&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[11px]",style:{color:"var(--muted)"},children:"建议手动执行命令:"}),e.jsxs("button",{type:"button",onClick:()=>void de(C.suggestedCommand),className:"inline-flex items-center gap-1 text-[11px] font-medium hover:underline underline-offset-2",style:{color:"var(--accent)"},children:[I?e.jsx(ze,{size:11}):e.jsx(Me,{size:11}),e.jsx("span",{children:I?"已复制":"复制命令"})]})]}),e.jsx("pre",{className:"mono text-[11px] p-2 rounded overflow-x-auto select-all",style:{background:"var(--bg)",border:"1px solid var(--hair-strong)",color:"var(--ink)"},children:e.jsx("code",{children:C.suggestedCommand})})]})]}),r&&e.jsx("div",{role:"alert",className:"p-2 rounded text-[11.5px]",style:{background:"var(--redline-soft, var(--accent-soft))",color:"var(--redline, var(--accent))"},children:r}),e.jsxs("form",{onSubmit:h=>void J(h),className:"pt-2 space-y-2",style:{borderTop:"1px dashed var(--hair)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("label",{htmlFor:`bl-followup-input-${a.id}`,className:"flex items-center gap-1 text-[11px] font-medium",children:[e.jsx(We,{size:12,style:{color:"var(--accent)"}}),e.jsx("span",{children:"继续追问 Codex"})]}),e.jsxs("span",{className:"mono text-[10.5px]",style:{color:n>0?"var(--faint)":"var(--redline, var(--accent))"},"data-remaining-followups":n,children:["剩余追问次数:",n,"/",m]})]}),e.jsx("textarea",{id:`bl-followup-input-${a.id}`,"aria-label":"追问内容",value:D,onChange:h=>U(h.target.value),disabled:!G,rows:2,placeholder:W||"描述希望继续调整的细节,例如:缩小右侧边距并恢复导航背景色…",className:"w-full p-2 text-[11.5px] leading-relaxed rounded-lg outline-none resize-y disabled:opacity-50",style:{background:"var(--bg)",border:"1px solid var(--hair-strong)",color:"var(--ink)"}}),e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("label",{className:"inline-flex items-center gap-1.5 text-[11px] cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:O,disabled:!G||!g,onChange:h=>L(h.target.checked),style:{accentColor:"var(--accent)"}}),e.jsx("span",{style:{color:g?"var(--ink)":"var(--faint)"},children:"附上验收截图"})]}),e.jsxs("button",{type:"submit",disabled:!G||!D.trim(),title:W||"在当前任务分支上继续修改并重新验收",className:"sheet-btn sheet-btn-primary disabled:opacity-40",style:{height:28,padding:"0 10px",fontSize:11.5},children:[e.jsx(Xe,{size:11}),e.jsx("span",{children:T==="follow-up"?"提交中…":"发送追问"})]})]}),W&&!q&&e.jsx("div",{className:"text-[11px]",style:{color:"var(--faint)"},children:W})]}),e.jsx(me,{open:f,title:"确认采纳任务改动",description:`将以 squash 方式合并到 ${a.sourceRef},源分支会前移 1 个压缩提交,随后自动清理任务分支 ${a.taskBranch} 与临时工作区。`,warnings:p&&p.passed===!1?["当前视觉验收未通过,请确认仍要采纳此任务分支的改动。"]:void 0,checkboxLabel:A>0?`采纳后自动清理同组其余 ${A} 个候选方案`:void 0,checkboxChecked:u,onCheckboxChange:A>0?k:void 0,confirmLabel:"确认 squash 采纳",loading:T==="accept",onClose:()=>N(!1),onConfirm:oe}),e.jsx(me,{open:P,title:"确认拒绝并清理任务",description:`将删除任务分支 ${a.taskBranch||"(无代码分支)"} 与残留临时工作区,源分支 ${a.sourceRef} 不会受到任何影响。`,warnings:["拒绝后任务分支将被永久删除,状态标记为已拒绝。"],confirmLabel:"确认拒绝并删除",danger:!0,loading:T==="reject",onClose:()=>v(!1),onConfirm:Z})]})},is=ke.lazy(()=>Oe(()=>import("./ExecutionTraceView-BuKMTJLz.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(a=>({default:a.ExecutionTraceView}))),ue=({status:a})=>{const m=re(a);return e.jsx("span",{className:"bl-task-badge mono shrink-0","data-tone":m.tone,"data-task-status":a,children:m.label})},cs=({kind:a})=>{switch(a){case"thinking":return e.jsx(ss,{size:13,className:"shrink-0 mt-0.5 opacity-80","aria-label":"思考"});case"command":return e.jsx(es,{size:13,className:"shrink-0 mt-0.5",style:{color:"var(--accent)"},"aria-label":"命令"});case"file_change":return e.jsx(Ce,{size:13,className:"shrink-0 mt-0.5",style:{color:"var(--diff-add-ink)"},"aria-label":"文件改动"});case"message":return e.jsx(Je,{size:13,className:"shrink-0 mt-0.5",style:{color:"var(--ink)"},"aria-label":"消息"});case"error":return e.jsx(le,{size:13,className:"shrink-0 mt-0.5",style:{color:"var(--redline, var(--accent))"},"aria-label":"错误"});default:return e.jsx(Ze,{size:13,className:"shrink-0 mt-0.5 opacity-70","aria-label":"状态"})}},os={thinking:"思考",command:"命令",file_change:"文件改动",message:"消息",error:"错误",status:"状态"},Ne=[],ds=new Intl.DateTimeFormat("zh-CN",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});function he(a){const m=new Date(a);return Number.isNaN(m.getTime())?"":ds.format(m)}const Be=ke.memo(({ev:a})=>e.jsxs("div",{className:"bl-event-row flex items-start gap-2 leading-relaxed","data-event-kind":a.kind,children:[e.jsx(cs,{kind:a.kind}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10.5px] mono",style:{color:"var(--faint)"},children:[e.jsx("span",{children:os[a.kind]??a.kind}),e.jsx("span",{children:"·"}),e.jsx("span",{children:he(a.ts)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words mono text-[11.5px]",style:{color:a.kind==="error"?"var(--redline, var(--accent))":"var(--ink)"},children:a.text})]})]}));Be.displayName="TaskEventRow";const fs=()=>{var se;const a=ae(s=>s.taskPanelOpen),m=ae(s=>s.setTaskPanelOpen),A=ae(s=>s.setSettingsOpen),o=ae(s=>s.pushToast),w=Ae(s=>s.config),x=b(s=>s.tasks),_=b(s=>s.selectedTaskId),y=b(s=>s.loadingTasks),F=b(s=>s.loadTasks),p=b(s=>s.selectTask),g=b(s=>s.approveTask),B=b(s=>s.rejectTaskPlan),n=b(s=>s.followUpTask),f=b(s=>s.acceptTask),N=b(s=>s.rejectTask),u=b(s=>s.cancelTask),k=b(s=>s.cleanupTask),P=b(s=>s.openVerificationView),v=b(s=>s.openPrDraft),T=Re(s=>s.enterCompare),[S,D]=i.useState(null),[U,O]=i.useState(null),[L,C]=i.useState(null),[$,r]=i.useState(null),[c,I]=i.useState(null),[M,Q]=i.useState("overview"),[z,ie]=i.useState(null),Y=i.useRef(null),q=i.useRef(null),t=x.find(s=>s.id===_)??x[0]??null,K=(t==null?void 0:t.id)??null,G=i.useMemo(()=>t?fe(t.verification):void 0,[t]),H=b(s=>K?s.eventsByTaskId[K]??Ne:Ne),ce=b(s=>K?!!s.truncatedByTaskId[K]:!1),W=((se=w==null?void 0:w.agent)==null?void 0:se.maxFollowUps)??5,oe=async s=>{if(!s.codexSessionId)return;const l=`codex resume ${s.codexSessionId}`,d=await Le(l);ie({taskId:s.id,state:d?"copied":"failed"})},Z=i.useMemo(()=>{const s=[],l=new Map;for(const d of x){if(!d.raceId){s.push({kind:"single",task:d});continue}let E=l.get(d.raceId);E||(E=[],l.set(d.raceId,E),s.push({kind:"race",raceId:d.raceId,tasks:E})),E.push(d)}for(const d of l.values())d.sort((E,j)=>(E.raceIndex??0)-(j.raceIndex??0)||E.id.localeCompare(j.id));return s},[x]),J=i.useMemo(()=>t!=null&&t.raceId?x.filter(s=>s.raceId===t.raceId).sort((s,l)=>(s.raceIndex??0)-(l.raceIndex??0)||s.id.localeCompare(l.id)):[],[x,t==null?void 0:t.raceId]),de=i.useMemo(()=>t!=null&&t.raceId?x.filter(s=>s.raceId===t.raceId&&s.id!==t.id&&s.status!=="accepted"&&s.status!=="rejected"&&s.status!=="cancelled"):[],[x,t==null?void 0:t.raceId,t==null?void 0:t.id]);if(i.useEffect(()=>{if(!a||!t)return;const{historyLoaded:s,loadingEvents:l}=b.getState();!s[t.id]&&!l[t.id]&&p(t.id)},[a,t==null?void 0:t.id,p]),i.useEffect(()=>{O(null),r(null),q.current&&(q.current.scrollTop=0)},[t==null?void 0:t.id]),i.useEffect(()=>{if(!a||M!=="overview"||H.length===0)return;const s=()=>{const l=Y.current;l&&(l.scrollTop=l.scrollHeight)};if(typeof requestAnimationFrame=="function"){const l=requestAnimationFrame(s);return()=>cancelAnimationFrame(l)}s()},[a,M,H]),i.useEffect(()=>{if(!a)return;const s=l=>{l.key==="Escape"&&!c&&!b.getState().prDraftRequest&&!b.getState().verificationTaskId&&m(!1)};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[a,c,m]),!a)return null;const xe=async s=>{if(!(s.status==="committing"||s.status==="accepting"||s.status==="rejecting")){D(s.id),O(null);try{await u(s.id)}catch(l){O(l instanceof Error?l.message:String(l))}finally{D(null)}}},X=async(s,l=!1)=>{C(s.id),O(null),r(null);try{await k(s.id,l),I(null),o({tone:"success",title:"残留清理完成",detail:`任务 #${s.id} 的残留资源已清理`,durationMs:4e3})}catch(d){d instanceof we&&d.status===409&&!l?r({taskId:s.id,reason:d.message}):O(d instanceof Error?d.message:String(d))}finally{C(null)}},ee=async(s,l)=>{var te;const d=await f(s,l),E=((te=d.rejectedSiblingIds)==null?void 0:te.length)??0,j=E>0?`,已同步清理同组 ${E} 个候选方案`:"",V=!!(d.warnings&&d.warnings.length>0);return o({tone:V?"warning":"success",title:`已采纳并合入 ${d.sourceRef}`,detail:V?`提交 ${d.commitSha.slice(0,7)} 已生效${j},但清理存在告警:${d.warnings.join(";")}`:`源分支已前移一个 squash 提交(${d.commitSha.slice(0,7)})${j}。`,durationMs:6500}),d},h=async s=>{const l=await N(s);return l.cleanupError?o({tone:"warning",title:`已拒绝,但清理残留失败:${l.cleanupError}`,detail:"请在任务面板中点击“重试清理”按钮,重新删除残留任务分支或临时工作区。",durationMs:7e3}):o({tone:"info",title:"已拒绝任务",detail:`任务 #${s} 对应的任务分支与临时工作区已清理。`,durationMs:4e3}),l},R=s=>!!s.cleanupError||qe(s.status)&&!!s.worktreePath,pe=s=>(s.status==="accepted"||s.status==="rejected")&&!!s.cleanupError;return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{role:"complementary","aria-label":"Codex 任务面板","data-trace-expanded":M==="trace"&&t?"true":"false",className:"bl-task-drawer fixed right-0 bottom-0 z-40 w-[480px] max-w-[94vw] flex flex-col",children:[e.jsxs("div",{className:"h-13 px-5 flex items-center justify-between gap-3 shrink-0",style:{borderBottom:"1px solid var(--hair)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-sm font-semibold",children:"Codex 任务"}),e.jsx("span",{className:"bl-count-badge",children:x.length})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void F(),disabled:y,"aria-label":"刷新任务列表",className:"opacity-70 hover:opacity-100 p-1",title:"刷新任务列表",children:e.jsx(Qe,{size:14,className:y?"animate-spin":""})}),e.jsx("button",{type:"button",onClick:()=>m(!1),"aria-label":"关闭任务面板",className:"opacity-70 hover:opacity-100 p-1",children:e.jsx(Ye,{size:16})})]})]}),e.jsx("div",{className:"max-h-[26%] overflow-y-auto px-3 py-1.5 space-y-1.5 shrink-0",style:{borderBottom:"1px solid var(--hair)"},children:Z.length===0?e.jsx("div",{className:"py-6 text-center text-xs",style:{color:"var(--faint)"},children:"暂无 Codex 任务。在「AI 批注」模式选中区域后,可点击“交给 Codex”发起任务。"}):Z.map(s=>{if(s.kind==="single"){const{task:j}=s,V=(t==null?void 0:t.id)===j.id;return e.jsxs("button",{type:"button",onClick:()=>void p(j.id),className:"bl-task-card w-full text-left px-2.5 py-2 space-y-0.5","data-selected":V?"true":void 0,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs font-medium truncate",children:j.title}),e.jsx(ue,{status:j.status})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] mono",style:{color:"var(--faint)"},children:[e.jsxs("span",{className:"truncate",children:[j.sourceRef,j.taskBranch?` → ${j.taskBranch}`:""]}),e.jsx("span",{className:"shrink-0",children:he(j.createdAt)})]})]},j.id)}const l=(t==null?void 0:t.raceId)===s.raceId,d=s.tasks[0],E=d.title.replace(/\s*[·-]\s*方案\s*[A-Z0-9]+$/i,"").trim()||d.title;return e.jsxs("div",{"data-race-group":s.raceId,"data-selected":l?"true":void 0,className:"bl-task-card px-2.5 py-2 space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>{l||p(d.id)},className:"w-full text-left flex items-center justify-between gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(Se,{size:12,style:{color:"var(--accent)"},className:"shrink-0"}),e.jsx("span",{className:"text-xs font-medium truncate",children:E})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("span",{className:"mono text-[10px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:[s.tasks.length," 路赛马"]}),e.jsx("span",{className:"mono text-[10.5px]",style:{color:"var(--faint)"},children:he(d.createdAt)})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:s.tasks.map((j,V)=>{const te=(t==null?void 0:t.id)===j.id;return e.jsxs("button",{type:"button","data-race-chip":j.id,"data-active":te?"true":void 0,onClick:()=>void p(j.id),className:"bl-race-chip inline-flex items-center gap-1",children:[e.jsx("span",{className:"text-[11px] font-medium",children:ne(j,V)}),e.jsx(ue,{status:j.status})]},j.id)})})]},s.raceId)})}),t?e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-1.5 flex items-center justify-between gap-2 shrink-0",style:{borderBottom:"1px solid var(--hair)",background:"var(--surface)"},children:[e.jsxs("div",{className:"bl-task-subtabs",role:"tablist","aria-label":"任务详情视图",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":M==="overview","data-testid":"task-view-overview-tab","data-active":M==="overview"?"true":"false",onClick:()=>Q("overview"),className:"bl-task-subtab",children:"概览与事件"}),e.jsx("button",{type:"button",role:"tab","aria-selected":M==="trace","data-testid":"task-view-trace-tab","data-active":M==="trace"?"true":"false",onClick:()=>Q("trace"),className:"bl-task-subtab",children:"执行轨迹"})]}),e.jsxs("span",{className:"mono text-[10.5px] truncate",style:{color:"var(--faint)"},children:["#",t.id]})]}),M==="trace"?e.jsx(i.Suspense,{fallback:e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2.5 p-6",children:[e.jsx("div",{className:"bl-spinner"}),e.jsx("span",{className:"text-xs",style:{color:"var(--muted)"},children:"正在加载任务执行轨迹…"})]}),children:e.jsx(is,{mode:"task",taskId:t.id,compact:!0})}):e.jsxs("div",{ref:q,className:"flex-1 min-h-0 overflow-y-auto flex flex-col",children:[e.jsxs("div",{className:"px-4 py-2.5 space-y-2.5 text-xs",children:[t.raceId&&J.length>0&&e.jsx(rs,{attempts:J,selectedTaskId:t.id,onSelectTask:s=>void p(s),onCompareAttempts:(s,l)=>{T(s,l)}}),e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("div",{className:"font-semibold text-[13px] break-words",children:t.title}),e.jsxs("div",{className:"mono text-[11px] flex items-center gap-1.5 flex-wrap",style:{color:"var(--muted)"},children:[e.jsxs("span",{children:["#",t.id," · ",t.sourceRef,t.taskBranch?` → ${t.taskBranch}`:""]}),(t.modelOverride||t.reasoningEffortOverride)&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[t.modelOverride,t.reasoningEffortOverride].filter(Boolean).join(" · ")})]})]}),e.jsx(ue,{status:t.status})]}),(t.sessionMode==="fork"||t.sessionMode==="resume"||t.codexSessionId)&&e.jsxs("div",{"data-task-session-binding":"true",className:"px-2.5 py-1.5 rounded-lg flex items-center justify-between gap-2 text-[11px]",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[e.jsx("div",{className:"min-w-0 truncate",style:{color:"var(--muted)"},children:(()=>{var d,E,j,V;const s=((d=t.baseSessionTitle)==null?void 0:d.trim())||((E=t.baseSessionId)==null?void 0:E.trim().slice(0,8))||((j=t.codexSessionId)==null?void 0:j.trim().slice(0,8))||"";if(t.sessionMode==="fork"&&t.usedSessionMode!=="new")return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",style:{color:"var(--accent)"},children:"分叉继承"}),s&&e.jsxs("span",{children:[":",s]})]});if(t.sessionMode==="resume"&&t.usedSessionMode!=="new")return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",style:{color:"var(--accent)"},children:"直接续接"}),s&&e.jsxs("span",{children:[":",s]})]});if((t.sessionMode==="fork"||t.sessionMode==="resume")&&t.usedSessionMode==="new")return e.jsx("span",{style:{color:"#d97706"},children:"关联已降级为独立会话"});const l=((V=t.codexSessionId)==null?void 0:V.trim().slice(0,8))||"";return e.jsx("span",{className:"mono",children:l?`Codex 会话:${l}`:"Codex 会话"})})()}),t.codexSessionId&&e.jsx("button",{type:"button",onClick:()=>void oe(t),className:"inline-flex items-center gap-1 shrink-0 mono text-[10.5px] hover:underline underline-offset-4",style:{color:(z==null?void 0:z.taskId)===t.id&&z.state==="failed"?"#d97706":"var(--accent)"},title:`复制并在终端续接:codex resume ${t.codexSessionId}`,children:(z==null?void 0:z.taskId)===t.id&&z.state==="copied"?e.jsxs(e.Fragment,{children:[e.jsx(ze,{size:11}),e.jsx("span",{children:"已复制"})]}):(z==null?void 0:z.taskId)===t.id&&z.state==="failed"?e.jsx("span",{children:"复制失败"}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{size:11}),e.jsx("span",{children:"复制 codex resume"})]})})]}),t.resultSummary&&e.jsx("p",{className:"leading-relaxed break-words",style:{color:"var(--muted)"},children:t.resultSummary}),e.jsx(as,{task:t,onApprove:async(s,l)=>{await g(s,l)},onRejectPlan:async(s,l)=>{await B(s,l)}}),G&&e.jsx(ts,{task:t,onOpenFullView:P}),t.error&&e.jsxs("div",{className:"p-2.5 rounded-lg space-y-1.5",style:{background:"var(--redline-soft, var(--accent-soft))",color:"var(--redline, var(--accent))"},children:[e.jsx("div",{className:"break-words",children:t.error}),Fe(t.error)&&e.jsx("button",{type:"button",onClick:()=>A(!0,"agent"),className:"underline underline-offset-4 font-medium",children:"前往设置更换 Codex 模型 →"})]}),R(t)&&e.jsxs("div",{className:"p-2.5 rounded-lg space-y-2",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[e.jsxs("div",{className:"flex items-start gap-1.5",style:{color:"#d97706"},children:[e.jsx(le,{size:13,className:"shrink-0 mt-0.5"}),e.jsx("span",{className:"break-words",children:t.cleanupError||`存在残留临时工作区:${t.worktreePath}`})]}),$&&$.taskId===t.id&&e.jsx("div",{className:"text-[11px] break-words",style:{color:"var(--redline, var(--accent))"},children:$.reason}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",disabled:L===t.id,onClick:()=>void X(t,!1),className:"sheet-btn",style:{height:28,padding:"0 10px",fontSize:11.5},children:[e.jsx(Te,{size:12}),e.jsx("span",{children:L===t.id?"清理中…":pe(t)?"重试清理":"清理残留"})]}),$&&$.taskId===t.id&&e.jsx("button",{type:"button",disabled:L===t.id,onClick:()=>I(t),className:"sheet-btn sheet-btn-accent",style:{height:28,padding:"0 10px",fontSize:11.5},children:"强制清理…"})]})]}),U&&e.jsx("div",{role:"alert",className:"p-2 rounded-lg text-[11.5px]",style:{background:"var(--redline-soft, var(--accent-soft))",color:"var(--redline, var(--accent))"},children:U}),e.jsx(ls,{task:t,maxFollowUps:W,cleanableRaceSiblingCount:de.length,onAccept:ee,onReject:h,onFollowUp:n,onOpenPrDraft:s=>v({taskId:s.id}),onRetryCleanup:s=>X(s,!1),cleaning:L===t.id}),(ge(t.status)||t.taskBranch&&t.status==="done")&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[ge(t.status)&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",disabled:t.status==="committing"||t.status==="accepting"||t.status==="rejecting"||S===t.id,onClick:()=>void xe(t),title:t.status==="committing"?"任务正在提交结果,无法取消":t.status==="accepting"?"任务正在采纳合入,无法取消":t.status==="rejecting"?"任务正在拒绝清理,无法取消":"取消当前任务",className:"sheet-btn sheet-btn-accent disabled:opacity-40",style:{height:28,padding:"0 10px",fontSize:11.5},children:[e.jsx(Ee,{size:12}),e.jsx("span",{children:S===t.id?"取消中…":"取消任务"})]}),t.status==="committing"&&e.jsx("span",{className:"text-[11px]",style:{color:"var(--muted)"},children:"任务正在提交结果,无法取消"}),t.status==="accepting"&&e.jsx("span",{className:"text-[11px]",style:{color:"var(--muted)"},children:"任务正在采纳合入,无法取消"}),t.status==="rejecting"&&e.jsx("span",{className:"text-[11px]",style:{color:"var(--muted)"},children:"任务正在拒绝清理,无法取消"})]}),t.taskBranch&&t.status==="done"&&e.jsxs("button",{type:"button",onClick:()=>{T(t.sourceRef,t.taskBranch)},className:"sheet-btn",style:{height:28,padding:"0 12px",fontSize:11.5},children:[e.jsx(Ie,{size:12}),e.jsx("span",{children:"和源分支对比"})]})]})]}),e.jsxs("div",{className:"flex flex-col shrink-0",style:{borderTop:"1px solid var(--hair)"},children:[e.jsxs("div",{className:"px-4 py-1.5 flex items-center justify-between text-[11px] shrink-0",style:{background:"var(--surface)",borderBottom:"1px solid var(--hair)"},children:[e.jsx("span",{className:"caps",children:"实时事件流"}),e.jsx("span",{className:"mono",style:{color:"var(--faint)"},children:ce?`仅保留最近 ${Pe} 条`:`${H.length} 条`})]}),e.jsx("div",{ref:Y,className:"max-h-[260px] overflow-y-auto px-4 py-2.5 space-y-2 text-xs",children:H.length===0?e.jsx("div",{className:"py-6 text-center",style:{color:"var(--faint)"},children:"暂无事件日志"}):H.map((s,l)=>e.jsx(Be,{ev:s},s.seq!==void 0?`seq-${s.seq}`:`${s.ts}-${l}`))})]})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center p-6 text-xs",style:{color:"var(--faint)"},children:"选择上方任务以查看方案、验收视图、结果操作与实时事件流"})]}),e.jsx(me,{open:!!c,title:"确认强制清理残留工作区",description:c?`后端无法确认任务 #${c.id} 的 Codex 进程是否已完全退出。请确认本机已无对应 Codex 进程运行后,再继续强制删除临时 worktree:${c.worktreePath}`:void 0,warnings:["强制清理将跳过进程存活探测,直接删除临时 worktree 目录。","若进程仍在写入该目录,可能导致残留锁文件或写入中断。"],confirmLabel:"我已确认退出,强制清理",danger:!0,loading:!!c&&L===c.id,onClose:()=>I(null),onConfirm:()=>{if(c)return X(c,!0)}})]})};export{fs as TaskPanel,ue as TaskStatusBadge};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./vendor-react-CIotE-6Q.js";import{n as g}from"./index-CuRBE0Be.js";import{H as y,z as j,l as b,T as N,D as k}from"./vendor-icons-BeN0on9X.js";const z=({task:n,onOpenFullView:h})=>{var m,p;const s=g(n.verification);if(!s)return null;const t=!!s.legacy,r=!!s.skipped,o=s.passed===!0,d=s.passed===!1,f=((p=(m=n.context)==null?void 0:m.regions)==null?void 0:p.length)??0,c=s.hitRegions.length,x=s.sideEffects.length,l=(s.otherRouteEffects??[]).filter(i=>typeof i.totalDiffRatio=="number"&&i.totalDiffRatio>=1e-4),a="var(--diff-del-ink, var(--redline, #ef4444))",u=t?"var(--muted)":r?"#d97706":o?"#16a34a":a,v=t?"历史数据,无法判定":r?"视觉验收已跳过":o?"视觉验收通过":d?"视觉验收未通过":"历史数据,无法判定";return e.jsxs("div",{"data-verification-summary":n.id,"data-verification-state":t?"legacy":r?"skipped":o?"passed":"failed",className:"bl-verify-card p-2.5 space-y-2 text-[11.5px]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-semibold",style:{color:u},children:[t?e.jsx(y,{size:13,className:"shrink-0"}):r?e.jsx(j,{size:13,className:"shrink-0"}):o?e.jsx(b,{size:13,className:"shrink-0"}):e.jsx(N,{size:13,className:"shrink-0"}),e.jsx("span",{children:v})]}),s.annotation&&e.jsxs("button",{type:"button",onClick:()=>h(n.id),className:"inline-flex items-center gap-1 text-[11px] font-medium hover:underline underline-offset-2 shrink-0",style:{color:"var(--accent)"},children:[e.jsx(k,{size:12}),e.jsx("span",{children:"查看验收视图"})]})]}),r&&e.jsx("div",{className:"break-words leading-relaxed",style:{color:"var(--muted)"},children:s.reason||s.note||"已跳过视觉验收"}),t&&e.jsx("div",{className:"break-words leading-relaxed",style:{color:"var(--muted)"},children:s.note||"旧版视觉批注记录,缺少逐像素验收结果。"}),!r&&!t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-1.5 mono text-[10.5px]",children:[e.jsxs("div",{className:"px-2 py-1.5 rounded",style:{background:"var(--bg)",border:"1px solid var(--hair)"},children:[e.jsx("span",{style:{color:"var(--faint)"},children:"目标区内变化:"}),e.jsx("strong",{style:{color:"#16a34a"},children:s.insideChanged!==void 0?`${s.insideChanged} px`:"—"}),typeof s.hitRate=="number"&&e.jsxs("span",{className:"ml-1",style:{color:"var(--muted)"},children:["(",(s.hitRate*100).toFixed(1),"%)"]})]}),e.jsxs("div",{className:"px-2 py-1.5 rounded",style:{background:"var(--bg)",border:"1px solid var(--hair)"},children:[e.jsx("span",{style:{color:"var(--faint)"},children:"区域外变化:"}),e.jsx("strong",{style:{color:d?a:"var(--ink)"},children:s.outsideChanged!==void 0?`${s.outsideChanged} px`:"—"}),typeof s.outsideRatio=="number"&&e.jsxs("span",{className:"ml-1",style:{color:"var(--muted)"},children:["(",(s.outsideRatio*100).toFixed(2),"%)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] mono flex-wrap",style:{color:"var(--muted)"},children:[e.jsxs("span",{children:["命中区域:",c,"/",f||c]}),e.jsxs("span",{style:{color:x>0?a:"var(--muted)"},children:["副作用区域:",x]})]}),s.note&&e.jsx("div",{className:"break-words leading-relaxed",style:{color:"var(--muted)"},children:s.note})]}),l.length>0&&e.jsxs("div",{className:"pt-1.5 space-y-1",style:{borderTop:"1px dashed var(--hair)"},children:[e.jsxs("div",{className:"text-[10.5px] font-medium",style:{color:a},children:["受影响的其他路由(",l.length,"):"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:l.map(i=>e.jsxs("span",{className:"mono text-[10.5px] px-1.5 py-0.5 rounded",style:{background:`color-mix(in srgb, ${a} 10%, transparent)`,border:`1px dashed color-mix(in srgb, ${a} 50%, transparent)`,color:a},children:[i.route," (",(i.totalDiffRatio*100).toFixed(2),"%)"]},i.route))})]})]})};export{z as V};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as y,j as e}from"./vendor-react-CIotE-6Q.js";import{b as x,r as g,a as j,n as b}from"./index-CuRBE0Be.js";import{AiAnnotator as N}from"./AiAnnotator-CCj1dKr0.js";import{V as L}from"./VerificationSummaryCard-D5fnYeAl.js";import{X as k,I as R,H as C}from"./vendor-icons-BeN0on9X.js";import"./LiquidSelect-BcHivJrw.js";import"./RouteBar-CbnzrFM4.js";const w=[],E=({task:o,onClose:a,onOpenFileDiff:n})=>{var m;const d=j(l=>{var c;return((c=l.repo)==null?void 0:c.branches)??w}),t=b(o.verification);if(!t)return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center gap-3",children:[e.jsx(R,{size:24,style:{color:"var(--faint)"}}),e.jsx("div",{className:"text-sm font-semibold",children:"该任务暂无视觉验收结果"}),e.jsx("button",{type:"button",onClick:a,className:"sheet-btn",children:"关闭"})]});const s=!!t.legacy,i=!!t.skipped,r=t.passed===!0;if(i&&!t.annotation)return e.jsx("div",{"data-verification-view":"skipped",className:"flex-1 flex flex-col items-center justify-center p-8",children:e.jsxs("div",{className:"bl-empty-card max-w-lg w-full space-y-3 text-center",children:[e.jsx("div",{className:"caps",style:{color:"#d97706"},children:"VERIFICATION SKIPPED"}),e.jsx("h2",{className:"text-[22px] font-semibold",children:"视觉验收已跳过"}),e.jsx("p",{className:"text-xs leading-relaxed",style:{color:"var(--muted)"},children:t.reason||t.note||"该任务未关联视觉批注区域,已跳过自动视觉验收。"}),e.jsx("div",{className:"pt-2",children:e.jsx("button",{type:"button",onClick:a,className:"sheet-btn sheet-btn-primary",children:"返回任务面板"})})]})});if(!t.annotation)return e.jsx("div",{"data-verification-view":s?"legacy":"no-annotation",className:"flex-1 flex flex-col items-center justify-center p-8",children:e.jsxs("div",{className:"bl-empty-card max-w-lg w-full space-y-3 text-center",children:[e.jsx("div",{className:"caps",style:{color:"var(--muted)"},children:s?"LEGACY VERIFICATION":"VERIFICATION SUMMARY"}),e.jsx("h2",{className:"text-[22px] font-semibold",children:s?"历史数据,无法判定":r?"视觉验收通过":"视觉验收未通过"}),e.jsx("p",{className:"text-xs leading-relaxed",style:{color:"var(--muted)"},children:t.note||"未包含可视化截图批注数据。"}),e.jsx("div",{className:"pt-2",children:e.jsx("button",{type:"button",onClick:a,className:"sheet-btn sheet-btn-primary",children:"返回任务面板"})})]})});const p=(t.otherRouteEffects??[]).filter(l=>typeof l.totalDiffRatio=="number"&&l.totalDiffRatio>=1e-4),h={targetRegions:((m=o.context)==null?void 0:m.regions)??[],hitRegions:t.hitRegions,sideEffects:t.sideEffects,otherRouteEffects:p,insideChanged:t.insideChanged,outsideChanged:t.outsideChanged,outsideRatio:t.outsideRatio,hitRate:t.hitRate,passed:t.passed,skipped:t.skipped,reason:t.reason,legacy:t.legacy,note:t.note},f=s?"var(--muted)":i?"#d97706":r?"#16a34a":"var(--diff-del-ink, var(--redline, #ef4444))",u=e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:a,className:"hover:underline underline-offset-4 font-medium shrink-0",style:{color:"var(--ink)"},children:"← 关闭验收视图"}),e.jsx("span",{style:{color:"var(--hair-strong)"},children:"|"}),e.jsx("span",{className:"mono text-[11px] font-semibold px-2 py-0.5 rounded shrink-0",style:{border:`1px solid ${f}`,color:f},children:s?"历史数据,无法判定":i?"视觉验收已跳过":r?"视觉验收通过":"视觉验收未通过"}),e.jsx("span",{className:"font-medium truncate",children:o.title}),e.jsxs("span",{className:"mono text-[11px] truncate hidden sm:inline",style:{color:"var(--muted)"},children:[t.annotation.baseRef," → ",t.annotation.targetRef]}),!s&&!i&&t.insideChanged!==void 0&&e.jsxs("span",{className:"mono text-[11px] shrink-0 hidden md:inline",style:{color:"var(--muted)"},children:["区内 ",t.insideChanged," px · 区外 ",t.outsideChanged??0," px"]})]});return e.jsxs("div",{"data-verification-view":s?"legacy":r?"passed":"failed",className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[s&&e.jsxs("div",{className:"px-6 py-2 text-xs flex items-center gap-2 shrink-0",style:{background:"var(--surface)",borderBottom:"1px solid var(--hair-strong)",color:"var(--muted)"},children:[e.jsx(C,{size:14,className:"shrink-0"}),e.jsx("span",{className:"font-semibold",children:"历史数据,无法判定"}),e.jsx("span",{children:"— 该记录来自旧版格式,下方仅展示历史视觉批注截图。"})]}),e.jsx(N,{branches:d,baseRef:t.annotation.baseRef,targetRef:t.annotation.targetRef,route:t.annotation.route,onRouteChange:()=>{},compareTargets:[],result:t.annotation,verificationOverlay:h,verificationHeader:u,loading:!1,progressText:"",error:null,onBaseChange:()=>{},onTargetChange:()=>{},onRunAnnotate:()=>{},onOpenSettings:()=>{},onOpenFileDiff:(l,c,v)=>n==null?void 0:n(l,c,v),onBackToLiveCompare:a,onBackToTree:a})]})},O=()=>{const o=x(s=>s.verificationTaskId),a=x(s=>s.tasks),n=x(s=>s.closeVerificationView),d=g(s=>s.openFileDiff),t=o?a.find(s=>s.id===o)??null:null;return y.useEffect(()=>{if(!t)return;const s=i=>{i.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t,n]),t?e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`视觉验收视图:${t.title}`,className:"fixed inset-0 z-50 flex flex-col",style:{background:"var(--bg)"},children:[e.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0",style:{borderBottom:"1px solid var(--hair)",background:"var(--surface)"},children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[e.jsx("span",{className:"caps",style:{color:"var(--accent)"},children:"VERIFICATION INSPECTOR"}),e.jsxs("span",{className:"mono truncate",style:{color:"var(--muted)"},children:["#",t.id," · ",t.title]})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":"关闭验收视图",className:"p-1 opacity-70 hover:opacity-100",children:e.jsx(k,{size:16})})]}),e.jsx(E,{task:t,onClose:n,onOpenFileDiff:(s,i,r)=>void d(s,i,r)})]}):null};export{O as VerificationModal,L as VerificationSummaryCard,E as VerificationView};
|