@muyichengshayu/promptx 0.1.32 → 0.1.34

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.34
4
+
5
+ - 统一图片预览层遮罩,直接复用和工作台弹窗一致的 `theme-modal-backdrop`,不再单独维护一套 overlay 背景,避免预览层与其它弹窗视觉割裂。
6
+ - 修复放大图片时顶部工具按钮对比度不足的问题:为缩放、翻页和关闭按钮补上稳定的底色、边框和阴影,在亮图背景上也能清楚辨认。
7
+
8
+ ## 0.1.33
9
+
10
+ - 修复安装包在 Node.js 22 下启动失败的问题:移除 `jimp` 及其 `@jimp/plugin-print -> simple-xml-to-json` 这条有问题的 ESM 依赖链,避免 `promptx start` 在加载阶段直接抛出 `does not provide an export named 'default'`。
11
+ - 上传图片改为使用现有的 `@napi-rs/canvas` 完成读取、缩放和 JPEG 导出,不再依赖 `jimp`,同时保持上传后图片会统一缩放到 `1600x1600` 以内的现有语义。
12
+ - 补充图片上传回归测试,并更新锁文件与打包产物校验,确保新安装包不再带入这条启动时会炸掉的依赖链。
13
+
3
14
  ## 0.1.32
4
15
 
5
16
  - 继续收敛执行过程面板:统一过程事件卡片为白底轻边框,过程区与输入区统一等宽字体,移动端优先折行显示,减少横向滚动与样式不一致带来的阅读负担。
@@ -1,10 +1,21 @@
1
1
  import fs from 'node:fs'
2
2
  import path from 'node:path'
3
3
  import { pipeline } from 'node:stream/promises'
4
- import { Jimp } from 'jimp'
4
+ import { createCanvas, loadImage } from '@napi-rs/canvas'
5
5
  import { nanoid } from 'nanoid'
6
6
  import { createApiError } from './apiErrors.js'
7
7
 
8
+ function scaleImageToFit(width = 0, height = 0, maxWidth = 1600, maxHeight = 1600) {
9
+ const safeWidth = Math.max(1, Number(width) || 0)
10
+ const safeHeight = Math.max(1, Number(height) || 0)
11
+ const ratio = Math.min(maxWidth / safeWidth, maxHeight / safeHeight)
12
+
13
+ return {
14
+ width: Math.max(1, Math.round(safeWidth * ratio)),
15
+ height: Math.max(1, Math.round(safeHeight * ratio)),
16
+ }
17
+ }
18
+
8
19
  function registerAssetRoutes(app, options = {}) {
9
20
  const {
10
21
  createTempFilePath,
@@ -31,20 +42,23 @@ function registerAssetRoutes(app, options = {}) {
31
42
  try {
32
43
  await pipeline(part.file, fs.createWriteStream(tempPath))
33
44
 
34
- const image = await Jimp.read(tempPath)
35
- image.scaleToFit({ w: 1600, h: 1600 })
45
+ const source = await loadImage(tempPath)
46
+ const scaled = scaleImageToFit(source.width, source.height)
47
+ const canvas = createCanvas(scaled.width, scaled.height)
48
+ const context = canvas.getContext('2d')
49
+ context.drawImage(source, 0, 0, scaled.width, scaled.height)
36
50
 
37
51
  const outputName = `${nanoid(16)}.jpg`
38
52
  outputPath = path.join(uploadsDir, outputName)
39
- const outputBuffer = await image.getBuffer('image/jpeg', { quality: 82 })
53
+ const outputBuffer = canvas.toBuffer('image/jpeg', 82)
40
54
  fs.writeFileSync(outputPath, outputBuffer)
41
55
 
42
56
  const stats = fs.statSync(outputPath)
43
57
  completed = true
44
58
  return reply.code(201).send({
45
59
  url: `/uploads/${outputName}`,
46
- width: image.bitmap.width,
47
- height: image.bitmap.height,
60
+ width: scaled.width,
61
+ height: scaled.height,
48
62
  mimeType: 'image/jpeg',
49
63
  size: stats.size,
50
64
  })
@@ -1 +1 @@
1
- import{u as ye,f as st,d as lt}from"./index-CR3pS7j1.js";import{A as it,n as Pe,e as _e,r as ot,b as Ge,s as rt,f as ze,_ as dt,a as ct,h as Ue}from"./WorkbenchView-BdPBiKKe.js";import{w as he,aB as p,aG as se,aH as le,aD as t,aO as o,u as a,aE as S,aU as ut,aV as pt,aJ as P,aC as f,aP as xe,aQ as Ce,aL as j,aT as mt,aI as gt,b as $,c as _,aX as Je,ak as ft,r as vt,n as ht}from"./vendor-misc-CWjGI0ex.js";import{g as He,h as ve,L as Ie,j as xt,b as Ke,H as yt,m as bt,v as wt,P as St,d as Ve,J as kt,l as $t,p as _t,K as Ct}from"./vendor-ui-D4mCpibF.js";import"./vendor-router-Bcjfmow0.js";import"./vendor-markdown-CNlC48LI.js";import"./vendor-tiptap-BCwG_IWj.js";function Mt(i=[]){return(Array.isArray(i)&&i.length?i:it).filter(u=>u&&typeof u=="object").map(u=>{const k=Pe(u.value);return{...u,value:k,label:String(u.label||_e(k)).trim()||_e(k),enabled:u.enabled!==!1,available:u.available!==!1}})}function Te(i=[]){return Mt(i).filter(T=>T.enabled&&T.available)}async function jt(){const i=await ot("/api/meta",{cache:"no-store"});return Te(i==null?void 0:i.agentEngineOptions)}const It={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Pt={class:"theme-muted-text mt-1 text-xs leading-5"},Tt={class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Rt={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},Dt={class:"flex items-start gap-2 text-xs leading-5"},Et={class:"theme-muted-text shrink-0"},Lt={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},Ft={class:"theme-muted-text mt-4 block text-xs"},Bt={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},At=["placeholder"],Nt={class:"mt-4 flex items-center gap-1.5"},Ot={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},zt={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},Ut={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},Ht={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},Vt={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},qt={key:4,class:"theme-empty-state px-3 py-8 text-sm"},Wt={key:5,class:"theme-empty-state px-3 py-8 text-sm"},Gt={key:6,class:"theme-empty-state px-3 py-8 text-sm"},Jt={key:7,class:"space-y-1"},Kt=["onClick"],Qt={class:"min-w-0 flex-1"},Xt=["innerHTML"],Yt=["innerHTML"],Zt={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},en={key:8,class:"space-y-1"},tn={class:"flex items-start gap-1.5"},nn=["onClick"],an=["onClick"],sn={class:"min-w-0 flex-1"},ln={key:0,class:"theme-muted-text truncate font-mono text-[10px]"},on={class:"theme-divider flex flex-col-reverse gap-2 border-t border-dashed px-4 py-4 sm:flex-row sm:items-center sm:justify-end sm:px-5"},rn={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},dn=["disabled"],cn=["disabled"],un={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(i,{emit:T}){const u=i,k=T,{t:v}=ye(),c=$(""),h=$(null),M=$(!1),r=$(""),d=$(!1),w=$(""),L=$([]),F=$(!1),R=$(""),C=$("tree"),E=$(""),G=$("");let B=null,A=0;const J=_(()=>de(h.value?[h.value]:[])),O=_(()=>C.value==="search"&&!R.value.trim()),ie=_(()=>C.value==="search"&&!!R.value.trim()&&!d.value&&!w.value&&!L.value.length),V=_(()=>C.value==="tree"&&!M.value&&!r.value&&!J.value.length);function ne(n=""){const m=String(n||"").trim();return/^[a-z]:[\\/]/i.test(m)||m.includes("\\")}function b(n=""){const m=String(n||"").trim();if(!m)return"";const l=ne(m);let g=m.replace(/\\/g,"/");return g.length>1&&!/^[a-z]:\/?$/i.test(g)&&g!=="/"&&(g=g.replace(/\/+$/,"")),l?g.toLowerCase():g}function Z(n="",m=""){const l=b(n),g=b(m);return!l||!g?!1:l===g||l.startsWith(`${g}/`)}function Me(n="",m=""){const l=String(n||"").trim(),g=String(m||"").trim();return l?g?ne(l)?/^[a-z]:\\?$/i.test(l)?`${l.replace(/[\\/]+$/,"")}\\${g}`:`${l.replace(/[\\/]+$/,"")}\\${g}`:l==="/"?`/${g}`:`${l.replace(/\/+$/,"")}/${g}`:l:g}function ae(n="",m=""){const l=b(n),g=b(m);if(!l||!g||!Z(g,l))return[];const D=g===l?"":g.slice(l.length).replace(/^\//,"");return D?D.split("/").filter(Boolean):[]}function K(n){return(n==null?void 0:n.name)||(n==null?void 0:n.path)||v("directoryPicker.unnamedDirectory")}function oe(n=""){const m=String(n||"").trim();return m?m.split(/[\\/]/).filter(Boolean).at(-1)||m:"Home"}function q(n=""){return String(n||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function I(n="",m=""){const l=String(n||""),g=String(m||"").trim().toLowerCase();if(!l||!g)return null;const D=l.toLowerCase(),U=D.indexOf(g);if(U>=0)return{start:U,end:U+g.length};const $e=g.split(/[\\/\s_.-]+/).filter(Boolean).sort((W,Y)=>Y.length-W.length);for(const W of $e){if(W.length<2)continue;const Y=D.indexOf(W);if(Y>=0)return{start:Y,end:Y+W.length}}return null}function be(n="",m=""){const l=String(n||""),g=I(l,m);return g?`${q(l.slice(0,g.start))}<mark class="theme-search-highlight">${q(l.slice(g.start,g.end))}</mark>${q(l.slice(g.end))}`:q(l)}function re(n){return be(K(n),R.value)}function we(n){return be((n==null?void 0:n.path)||"",R.value)}function ee(n,m=0){return{...n,depth:m,expanded:!1,loaded:!1,loading:!1,children:[]}}function de(n=[],m=[]){return n.forEach(l=>{m.push(l),l.expanded&&l.children.length&&de(l.children,m)}),m}function Q(){h.value&&(h.value={...h.value})}function ce(n,m=h.value?[h.value]:[]){const l=b(n);if(!l)return null;for(const g of m){if(b(g.path)===l)return g;if(g.children.length){const D=ce(n,g.children);if(D)return D}}return null}function X(n){E.value=String((n==null?void 0:n.path)||"").trim(),G.value=K(n)}async function ue(n,m={}){if(!(!n||n.loading)&&!(n.loaded&&!m.force)){n.loading=!0,r.value="",Q();try{const l=await ze({path:n.path,limit:240});n.children=(l.items||[]).map(g=>ee(g,n.depth+1)),n.loaded=!0}catch(l){r.value=l.message||v("directoryPicker.loadFailed")}finally{n.loading=!1,Q()}}}async function je(){M.value=!0,r.value="";try{const n=await ze({limit:240});c.value=String(n.path||""),h.value=ee({name:oe(n.path||""),path:String(n.path||""),type:"directory",hasChildren:!0,isHomeRoot:!0},0),h.value.children=(n.items||[]).map(m=>ee(m,1)),h.value.loaded=!0,h.value.expanded=!0,X(h.value)}catch(n){r.value=n.message||v("directoryPicker.treeLoadFailed"),h.value=null,c.value=""}finally{M.value=!1}}async function pe(n=""){const m=String(n||"").trim();if(!m||!c.value||!Z(m,c.value))return;let l=h.value;if(!l)return;X(l);const g=ae(c.value,m);for(const D of g){await ue(l),l.expanded=!0,Q();const U=ce(Me(l.path,D),l.children);if(!U)break;l=U,X(l)}}async function Se(){R.value="",C.value="tree",L.value=[],w.value="",F.value=!1,E.value="",G.value="",await je();const n=String(u.initialPath||"").trim();n&&Z(n,c.value)&&await pe(n)}async function z(n){if(n!=null&&n.path&&(X(n),!!n.hasChildren)){if(!n.loaded){n.expanded=!0,Q(),await ue(n);return}n.expanded=!n.expanded,Q()}}function te(n){n!=null&&n.path&&(X(n),C.value="tree")}async function ke(){const n=String(R.value||"").trim();A+=1;const m=A;if(!u.open||!n||!c.value){d.value=!1,w.value="",L.value=[],F.value=!1;return}d.value=!0,w.value="";try{const l=await rt(n,{path:c.value,limit:80});if(m!==A)return;L.value=Array.isArray(l.items)?l.items:[],F.value=!!l.truncated}catch(l){if(m!==A)return;w.value=l.message||v("directoryPicker.searchFailed"),L.value=[],F.value=!1}finally{m===A&&(d.value=!1)}}function me(){if(B&&(window.clearTimeout(B),B=null),!String(R.value||"").trim()){d.value=!1,w.value="",L.value=[],F.value=!1;return}d.value=!0,w.value="",B=window.setTimeout(()=>{ke()},120)}async function ge(n){n!=null&&n.path&&(C.value="tree",await pe(n.path))}function fe(){E.value&&(k("select",E.value),k("close"))}return he(R,()=>{C.value=R.value.trim()?"search":"tree",me()}),he(()=>u.open,n=>{if(n){Se().catch(()=>{});return}B&&(window.clearTimeout(B),B=null)}),(n,m)=>(p(),se(Ge,{open:i.open,"backdrop-class":"z-[60] items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6","panel-class":"settings-dialog-panel h-full max-w-4xl sm:h-auto sm:max-h-[86vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:px-5","close-disabled":M.value||d.value,"close-on-backdrop":!(M.value||d.value),"close-on-escape":!(M.value||d.value),onClose:m[4]||(m[4]=l=>k("close"))},{title:le(()=>[t("div",null,[t("div",It,[S(a(ve),{class:"h-4 w-4"}),t("span",null,o(a(v)("directoryPicker.title")),1)]),t("p",Pt,o(a(v)("directoryPicker.intro")),1)])]),default:le(()=>[t("div",Tt,[t("div",Rt,[t("div",Dt,[t("span",Et,o(a(v)("directoryPicker.currentSelection")),1),t("span",Lt,o(E.value||a(v)("directoryPicker.selectionPlaceholder")),1)])]),t("label",Ft,[t("span",null,o(a(v)("directoryPicker.searchLabel")),1),t("div",Bt,[S(a(He),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),ut(t("input",{"onUpdate:modelValue":m[0]||(m[0]=l=>R.value=l),type:"text",placeholder:a(v)("directoryPicker.searchPlaceholder"),class:"min-w-0 flex-1 border-0 bg-transparent px-0 text-sm text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]"},null,8,At),[[pt,R.value]])])]),t("div",Nt,[t("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",C.value==="search"?"tool-button-accent-subtle":"theme-filter-idle border-dashed"]),onClick:m[1]||(m[1]=l=>C.value="search")},[S(a(He),{class:"h-3.5 w-3.5"}),t("span",null,o(a(v)("directoryPicker.searchTab")),1)],2),t("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",C.value==="tree"?"tool-button-accent-subtle":"theme-filter-idle border-dashed"]),onClick:m[2]||(m[2]=l=>C.value="tree")},[S(a(ve),{class:"h-3.5 w-3.5"}),t("span",null,o(a(v)("directoryPicker.treeTab")),1)],2)]),t("div",Ot,[C.value==="search"&&w.value?(p(),f("div",zt,o(w.value),1)):C.value==="tree"&&r.value?(p(),f("div",Ut,o(r.value),1)):C.value==="search"&&d.value?(p(),f("div",Ht,[S(a(Ie),{class:"h-4 w-4 animate-spin"}),t("span",null,o(a(v)("directoryPicker.searching")),1)])):C.value==="tree"&&M.value?(p(),f("div",Vt,[S(a(Ie),{class:"h-4 w-4 animate-spin"}),t("span",null,o(a(v)("directoryPicker.treeLoading")),1)])):O.value?(p(),f("div",qt,o(a(v)("directoryPicker.searchPrompt")),1)):ie.value?(p(),f("div",Wt,o(a(v)("directoryPicker.noSearchResults")),1)):V.value?(p(),f("div",Gt,o(a(v)("directoryPicker.emptyTree")),1)):C.value==="search"?(p(),f("div",Jt,[(p(!0),f(xe,null,Ce(L.value,l=>(p(),f("button",{key:l.path,type:"button",class:P(["flex w-full items-start gap-2 rounded-sm border border-transparent px-2.5 py-1.5 text-left transition",b(E.value)===b(l.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:g=>ge(l)},[S(a(ve),{class:"theme-muted-text mt-0.5 h-4 w-4 shrink-0"}),t("div",Qt,[t("div",null,[t("span",{class:"truncate text-[13px] text-[var(--theme-textPrimary)]",innerHTML:re(l)},null,8,Xt)]),t("div",{class:"theme-muted-text truncate font-mono text-[10px]",innerHTML:we(l)},null,8,Yt)])],10,Kt))),128)),F.value?(p(),f("p",Zt,o(a(v)("directoryPicker.truncatedHint")),1)):j("",!0)])):(p(),f("div",en,[(p(!0),f(xe,null,Ce(J.value,l=>(p(),f("div",{key:l.path,class:P(["rounded-sm border border-transparent px-1.5 py-1 transition",b(E.value)===b(l.path)?"theme-list-item-active":l.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:mt({paddingLeft:`${l.depth*16+6}px`})},[t("div",tn,[t("button",{type:"button",class:P(["theme-icon-button h-5 w-5 shrink-0",l.hasChildren?"":"invisible pointer-events-none"]),onClick:gt(g=>z(l),["stop"])},[l.loading?(p(),se(a(Ie),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(p(),se(a(xt),{key:1,class:P(["h-3.5 w-3.5 transition",l.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,nn),t("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:g=>te(l)},[S(a(ve),{class:P(["h-4 w-4 shrink-0",b(E.value)===b(l.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),t("div",sn,[t("div",{class:P(["truncate text-[13px]",l.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},o(K(l)),3),l.isHomeRoot?(p(),f("div",ln,o(l.path),1)):j("",!0)])],8,an)])],6))),128))]))])]),t("div",on,[t("div",rn,[t("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:M.value||d.value,onClick:m[3]||(m[3]=l=>k("close"))},o(a(v)("directoryPicker.cancel")),9,dn),t("button",{type:"button",class:"tool-button tool-button-primary inline-flex w-full items-center justify-center gap-2 px-3 py-2 text-xs sm:w-auto",disabled:M.value||d.value||!E.value,onClick:fe},[S(a(Ke),{class:"h-4 w-4"}),t("span",null,o(a(v)("directoryPicker.useCurrentDirectory")),1)],8,cn)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},pn={class:"grid gap-4"},mn={class:"theme-muted-text block text-xs"},gn=["value","disabled"],fn={class:"theme-muted-text block text-xs"},vn={class:"mt-1 flex gap-2"},hn=["value","disabled"],xn=["disabled"],yn={id:"codex-manager-workspace-suggestions"},bn=["value"],wn={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Sn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},kn={class:"theme-muted-text block text-xs"},$n={class:"mt-1"},_n={class:"flex items-center gap-2 text-sm"},Cn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Mn=["disabled","onClick"],jn={class:"flex items-center justify-between gap-3"},In={class:"min-w-0 flex-1 truncate"},Pn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Tn={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},Rn={class:"theme-muted-text block text-xs"},Dn={class:"mt-1 flex gap-2"},En=["value","disabled"],Ln=["disabled"],Fn={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},Bn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},qe={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},canEditEngine:{type:Boolean,default:!0},canEditCwd:{type:Boolean,default:!0},canEditSessionId:{type:Boolean,default:!0},cwd:{type:String,default:""},cwdReadonlyMessage:{type:String,default:""},duplicateCwdMessage:{type:String,default:""},engine:{type:String,default:"codex"},engineOptions:{type:Array,default:()=>[]},engineReadonlyMessage:{type:String,default:""},mobile:{type:Boolean,default:!1},sessionId:{type:String,default:""},sessionIdCopied:{type:Boolean,default:!1},sessionIdReadonlyMessage:{type:String,default:""},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","update:cwd","update:engine","update:sessionId","update:title"],setup(i,{emit:T}){const u=i,k=T,{t:v}=ye(),c=_(()=>{const M=String(u.engine||"").trim();return u.engineOptions.find(r=>String((r==null?void 0:r.value)||"").trim()===M)||null}),h=_(()=>String(u.sessionId||"").trim());return(M,r)=>(p(),f("div",pn,[t("label",mn,[t("span",null,o(a(v)("projectManager.projectTitleOptional")),1),t("input",{value:i.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:i.busy,onInput:r[0]||(r[0]=d=>k("update:title",d.target.value))},null,40,gn)]),t("label",fn,[t("span",null,o(a(v)("projectManager.workingDirectoryField")),1),t("div",vn,[t("input",{value:i.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:P(["tool-input min-w-0 flex-1 disabled:cursor-not-allowed disabled:opacity-80",i.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:i.busy||!i.canEditCwd,onInput:r[1]||(r[1]=d=>k("update:cwd",d.target.value))},null,42,hn),t("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:i.busy||!i.canEditCwd,onClick:r[2]||(r[2]=d=>k("open-directory-picker"))},[S(a(ve),{class:"h-4 w-4"}),t("span",null,o(i.mobile?a(v)("projectManager.choose"):a(v)("projectManager.chooseDirectory")),1)],8,xn)]),t("datalist",yn,[(p(!0),f(xe,null,Ce(i.workspaceSuggestions,d=>(p(),f("option",{key:d,value:d},null,8,bn))),128))]),i.duplicateCwdMessage?(p(),f("p",wn,o(i.duplicateCwdMessage),1)):i.cwdReadonlyMessage?(p(),f("p",Sn,o(i.cwdReadonlyMessage),1)):j("",!0)]),t("label",kn,[t("span",null,o(a(v)("projectManager.engineField")),1),t("div",$n,[S(dt,{"model-value":i.engine,options:i.engineOptions,disabled:i.busy||!i.canEditEngine,placeholder:a(v)("projectManager.selectEngine"),"empty-text":a(v)("projectManager.noEngines"),"get-option-value":d=>(d==null?void 0:d.value)||"","onUpdate:modelValue":r[3]||(r[3]=d=>k("update:engine",d))},{trigger:le(({disabled:d})=>{var w;return[t("div",_n,[t("span",{class:P(["min-w-0 flex-1 truncate",d?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},o(((w=c.value)==null?void 0:w.label)||a(v)("projectManager.selectEngine")),3),c.value&&c.value.enabled===!1?(p(),f("span",Cn,o(a(v)("projectManager.comingSoon")),1)):j("",!0)])]}),option:le(({option:d,selected:w,select:L})=>[t("button",{type:"button",class:P(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",w?"theme-filter-active":"theme-filter-idle"]),disabled:(d==null?void 0:d.enabled)===!1,onClick:L},[t("div",jn,[t("span",In,o(d.label),1),(d==null?void 0:d.enabled)===!1?(p(),f("span",Pn,o(a(v)("projectManager.comingSoon")),1)):j("",!0)])],10,Mn)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),i.engineReadonlyMessage?(p(),f("p",Tn,o(i.engineReadonlyMessage),1)):j("",!0)]),t("label",Rn,[t("span",null,o(a(v)("projectManager.sessionId")),1),t("div",Dn,[t("input",{value:i.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 flex-1 disabled:cursor-not-allowed disabled:opacity-80",disabled:i.busy||!i.canEditSessionId,onInput:r[4]||(r[4]=d=>k("update:sessionId",d.target.value))},null,40,En),h.value?(p(),f("button",{key:0,type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:i.busy,onClick:r[5]||(r[5]=d=>k("copy-session-id"))},[i.sessionIdCopied?(p(),se(a(Ke),{key:0,class:"h-4 w-4"})):(p(),se(a(yt),{key:1,class:"h-4 w-4"})),t("span",null,o(i.sessionIdCopied?a(v)("projectManager.sessionIdCopied"):a(v)("projectManager.copySessionId")),1)],8,Ln)):j("",!0)]),i.sessionIdReadonlyMessage?(p(),f("p",Fn,o(i.sessionIdReadonlyMessage),1)):(p(),f("p",Bn,o(a(v)("projectManager.sessionIdHint")),1))])]))}},An={class:"flex items-center justify-between gap-3"},Nn={class:"theme-heading text-sm font-medium"},On={key:0,class:"theme-muted-text mt-1 text-xs"},zn=["disabled"],Un=["onClick"],Hn={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},Vn={class:"flex w-full flex-col gap-2 text-left"},qn={class:"theme-heading min-w-0 text-sm font-medium"},Wn=["title"],Gn=["title"],Jn={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},Kn={key:0,"aria-hidden":"true"},Qn={key:1},Xn={class:"flex flex-wrap items-center gap-2 pt-1"},Yn={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},We={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:i=>i},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},hasSessions:{type:Boolean,default:!1},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1},mode:{type:String,default:"edit"},mobile:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]}},emits:["create","select"],setup(i,{emit:T}){const u=i,k=T,{t:v}=ye();function c(r){return u.mode==="edit"&&u.editingSessionId===r.id?"theme-card-selected":u.isSessionRunning(r.id)?"theme-card-warning":"theme-card-idle-strong"}function h(r){return u.isCurrentSession(r.id)?v("projectManager.current"):v("projectManager.regular")}function M(r){return u.isCurrentSession(r.id)?"theme-status-info":"theme-status-neutral"}return(r,d)=>(p(),f("div",{class:P(i.mobile?"flex h-full min-h-0 flex-col":"")},[t("div",An,[t("div",null,[t("div",Nn,o(a(v)("projectManager.projectList")),1),i.hasSessions?j("",!0):(p(),f("p",On,o(a(v)("projectManager.noProjects")),1))]),t("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:i.busy,onClick:d[0]||(d[0]=w=>k("create"))},[S(a(bt),{class:"h-4 w-4"}),t("span",null,o(a(v)("projectManager.create")),1)],8,zn)]),t("div",{class:P(["mt-4 space-y-2",i.mobile?"min-h-0 flex-1 overflow-y-auto":"max-h-52 overflow-y-auto pr-1 sm:max-h-64 lg:max-h-[calc(88vh-11rem)]"])},[(p(!0),f(xe,null,Ce(i.sessions,w=>(p(),f("article",{key:w.id,class:P(["relative cursor-pointer rounded-sm border p-3 transition",c(w)]),onClick:L=>k("select",w.id)},[i.mode==="edit"&&i.editingSessionId===w.id?(p(),f("span",Hn)):j("",!0),t("div",Vn,[t("div",qn,[t("span",{class:"block truncate",title:w.title||a(v)("projectManager.untitledProject")},o(w.title||a(v)("projectManager.untitledProject")),9,Wn)]),t("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:w.cwd},o(w.cwd),9,Gn),t("div",Jn,[t("span",null,o(a(_e)(w.engine)),1),i.mobile?j("",!0):(p(),f("span",Kn,"·")),i.mobile?j("",!0):(p(),f("span",Qn,o(i.formatUpdatedAt(w.updatedAt)),1))]),t("div",Xn,[t("span",{class:P(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",M(w)])},o(h(w)),3),t("span",{class:P(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",i.getRuntimeStatusClass(w.id)])},[i.isSessionRunning(w.id)?(p(),f("span",Yn)):j("",!0),Je(" "+o(i.getRuntimeStatusLabel(w.id)),1)],2),t("span",{class:P(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",i.getThreadStatusClass(w)])},o(i.getThreadStatusLabel(w)),3)])])],10,Un))),128))],2)],2))}},Zn={class:"space-y-3"},ea={class:"dashed-panel px-3 py-3"},ta={class:"theme-muted-text text-[11px]"},na={class:"mt-2 flex flex-wrap gap-2"},aa={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},sa={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},la={class:"dashed-panel px-3 py-3"},ia={class:"theme-muted-text text-[11px]"},oa={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},ra={class:"dashed-panel px-3 py-3"},da={class:"theme-muted-text text-[11px]"},ca={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},ua={class:"dashed-panel px-3 py-3"},pa={class:"theme-muted-text text-[11px]"},ma={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},ga={class:"dashed-panel px-3 py-3"},fa={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},va={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},ha={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:i=>i},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1}},setup(i){const{t:T}=ye();return(u,k)=>{var v,c,h,M,r,d,w;return p(),f("div",Zn,[t("div",ea,[t("div",ta,o(a(T)("projectManager.runtimeStatus")),1),t("div",na,[t("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",i.getRuntimeStatusClass((v=i.activeSession)==null?void 0:v.id)])},[i.isSessionRunning((c=i.activeSession)==null?void 0:c.id)?(p(),f("span",aa)):j("",!0),Je(" "+o(i.getRuntimeStatusLabel((h=i.activeSession)==null?void 0:h.id)),1)],2),t("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",i.getThreadStatusClass(i.activeSession)])},o(i.getThreadStatusLabel(i.activeSession)),3),(M=i.activeSession)!=null&&M.id&&i.isCurrentSession(i.activeSession.id)?(p(),f("span",sa,o(a(T)("projectManager.currentProject")),1)):j("",!0)])]),t("div",la,[t("div",ia,o(a(T)("projectManager.engine")),1),t("div",oa,o(a(_e)((r=i.activeSession)==null?void 0:r.engine)),1)]),t("div",ra,[t("div",da,o(a(T)("projectManager.workingDirectory")),1),t("div",ca,o(((d=i.activeSession)==null?void 0:d.cwd)||a(T)("projectManager.notSet")),1)]),t("div",ua,[t("div",pa,o(a(T)("projectManager.updatedAt")),1),t("div",ma,o(i.formatUpdatedAt((w=i.activeSession)==null?void 0:w.updatedAt)),1)]),t("div",ga,[t("div",fa,[S(a(wt),{class:"h-3.5 w-3.5"}),t("span",null,o(a(T)("projectManager.note")),1)]),t("p",va,o(a(T)("projectManager.noteDescription")),1)])])}}},xa={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ya={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},ba={class:"theme-divider theme-muted-panel border-b px-3 py-3 sm:px-4 sm:py-4 lg:border-b-0 lg:border-r"},wa={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},Sa={class:"flex flex-wrap items-start justify-between gap-3"},ka={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},$a={class:"mt-5"},_a={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Ca={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4 sm:flex-row sm:items-center sm:justify-between"},Ma={class:"flex flex-wrap items-center gap-2"},ja=["disabled"],Ia=["disabled"],Pa={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Ta=["disabled"],Ra=["disabled"],Da=["disabled"],Ea={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},La={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Fa={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},Ba={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Aa={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Na=["disabled"],Oa={class:"min-w-0 flex-1"},za={class:"theme-heading truncate text-sm font-medium"},Ua={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Ha={class:"theme-divider border-b px-4 py-3"},Va={class:"grid grid-cols-2 gap-2"},qa=["disabled"],Wa={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Ga={key:0},Ja={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Ka={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Qa=["disabled"],Xa=["disabled"],Ya=["disabled"],is={__name:"CodexSessionManagerDialog",props:{open:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]},workspaces:{type:Array,default:()=>[]},selectedSessionId:{type:String,default:""},selectionLocked:{type:Boolean,default:!1},selectionLockReason:{type:String,default:""},loading:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},onRefresh:{type:Function,default:null},onCreate:{type:Function,default:null},onUpdate:{type:Function,default:null},onDelete:{type:Function,default:null},onReset:{type:Function,default:null}},emits:["close","project-created","select-session"],setup(i,{emit:T}){const u=i,k=T,{locale:v,t:c}=ye(),h=$("edit"),M=$(""),r=vt({title:"",engine:"codex",cwd:"",sessionId:""}),d=$(""),w=$(!1),L=$(!1),F=$(!1),R=$(!1),C=$(!1),E=$(!1),G=$(!1),B=$(!1),{matches:A}=ct("(max-width: 767px)"),J=$("list"),O=$("basic"),ie=$(Te());let V=null;const ne=_(()=>ke(u.sessions)),b=_(()=>u.sessions.find(e=>e.id===M.value)||null),Z=_(()=>u.sessions.length>0),Me=_(()=>u.sessions.find(e=>e.id===u.selectedSessionId)||null),ae=_(()=>!!(b.value&&z(b.value.id))),K=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),oe=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),q=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),I=_(()=>u.loading||w.value||L.value||F.value||R.value),be=_(()=>String(r.sessionId||"").trim()),re=_(()=>{var x,y;const e=new Set,s=[];return[r.cwd,(x=b.value)==null?void 0:x.cwd,(y=Me.value)==null?void 0:y.cwd,...u.workspaces,...u.sessions.map(H=>H.cwd)].forEach(H=>{const N=String(H||"").trim();!N||e.has(N)||(e.add(N),s.push(N))}),s.slice(0,12)}),we=_(()=>ie.value),ee=_(()=>{const e=Se(r.cwd);return e?u.sessions.filter(s=>{var x;return s.id===((x=b.value)==null?void 0:x.id)?!1:Se(s.cwd)===e}):[]}),de=_(()=>{if(!ee.value.length)return"";const e=ee.value.slice(0,3).map(s=>{const x=s.title||c("projectManager.untitledProject");return v.value==="en-US"?`"${x}"`:`「${x}」`}).join(v.value==="en-US"?", ":"、");return c("projectManager.duplicateDirectory",{labels:e,count:ee.value.length})}),Q=_(()=>h.value!=="edit"||K.value?"":c("projectManager.cwdReadonly")),ce=_(()=>h.value!=="edit"||!b.value||oe.value?"":c("projectManager.engineReadonly")),X=_(()=>h.value!=="edit"||!b.value||q.value?"":c("projectManager.sessionIdReadonly")),ue=_(()=>h.value==="create"?w.value?c("projectManager.creatingProject"):c("projectManager.createProject"):L.value?c("projectManager.savingChanges"):c("projectManager.saveChanges")),je=_(()=>{var e;return h.value==="create"?c("projectManager.newProject"):((e=b.value)==null?void 0:e.title)||c("projectManager.untitledProject")});function pe(e=""){const s=Date.parse(String(e||""));return Number.isFinite(s)?s:0}function Se(e=""){const s=String(e||"").trim();if(!s)return"";const x=/^[a-z]:[\\/]/i.test(s)||s.includes("\\");let y=s.replace(/\\/g,"/");return y.length>1&&!/^[a-z]:\/$/i.test(y)&&(y=y.replace(/\/+$/,"")),x?y.toLowerCase():y}function z(e){var s;return!!((s=u.sessions.find(x=>x.id===e))!=null&&s.running)}function te(e){return!!e&&e===u.selectedSessionId}function ke(e=[]){return[...e].sort((s,x)=>{const y=Number(z(x.id))-Number(z(s.id));if(y)return y;const H=Number(te(x.id))-Number(te(s.id));if(H)return H;const N=pe(x.updatedAt)-pe(s.updatedAt);return N||lt(String(s.title||s.cwd||s.id),String(x.title||x.cwd||x.id))})}function me(e){return z(e)?c("projectManager.running"):c("projectManager.idle")}function ge(e){return z(e)?"theme-status-warning":"theme-status-success"}function fe(e){return e!=null&&e.started?c("projectManager.threadBound"):c("projectManager.notStarted")}function n(e){return e!=null&&e.started?"theme-status-success":"theme-status-neutral"}function m(e=""){if(!e)return c("projectManager.unknown");const s=new Date(e);return Number.isNaN(s.getTime())?e:st(s.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function l(e){r.title=String((e==null?void 0:e.title)||""),r.engine=Pe(e==null?void 0:e.engine),r.cwd=String((e==null?void 0:e.cwd)||""),r.sessionId=String((e==null?void 0:e.sessionId)||(e==null?void 0:e.engineSessionId)||(e==null?void 0:e.engineThreadId)||(e==null?void 0:e.codexThreadId)||"").trim()}function g(){h.value="create",M.value="",d.value="",r.title="",r.engine="codex",r.cwd="",r.sessionId=""}function D(e){const s=u.sessions.find(x=>x.id===e);s&&(h.value="edit",M.value=s.id,d.value="",l(s))}function U(){var e;return u.selectedSessionId&&u.sessions.some(s=>s.id===u.selectedSessionId)?u.selectedSessionId:((e=ne.value[0])==null?void 0:e.id)||""}function $e(e="basic"){J.value="detail",O.value=e}function W(){J.value="list",O.value="basic"}function Y(){g(),A.value&&$e("basic")}function Re(e){I.value||(D(e),A.value&&$e("basic"))}function Qe(e){r.cwd=String(e||"").trim()}function De(e){r.title=String(e||"")}function Ee(e){r.engine=Pe(e)}function Le(e){r.cwd=String(e||"")}function Fe(e){r.sessionId=String(e||"")}function Be(){d.value="",C.value=!1,E.value=!1,B.value=!1,O.value="basic",J.value=A.value?"list":"detail";const e=U();if(e){D(e);return}g()}async function Xe(){if(!(I.value||typeof u.onRefresh!="function")){d.value="";try{await Promise.all([u.onRefresh(),Ae()])}catch(e){d.value=e.message}}}async function Ae(){try{ie.value=await jt()}catch{ie.value=Te()}}async function Ye(e){var x;if((x=navigator.clipboard)!=null&&x.writeText&&window.isSecureContext){await navigator.clipboard.writeText(e);return}const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly","true"),s.style.position="fixed",s.style.opacity="0",s.style.pointerEvents="none",document.body.appendChild(s),s.select(),document.execCommand("copy"),document.body.removeChild(s)}async function Ne(){const e=be.value;if(e)try{await Ye(e),B.value=!0,V&&clearTimeout(V),V=setTimeout(()=>{B.value=!1,V=null},1800)}catch(s){d.value=(s==null?void 0:s.message)||c("projectManager.copySessionIdFailed")}}async function Oe(){if(!I.value){d.value="";try{const e=Ze();if(!e)return;await et(e)}catch(e){d.value=e.message}}}function Ze(){if(h.value==="create"){const s=String(r.cwd||"").trim();return s?{type:"create",cwd:s,payload:{title:r.title,engine:r.engine,cwd:s,sessionId:String(r.sessionId||"").trim()}}:(d.value=c("projectManager.directoryRequired"),null)}if(!b.value)return d.value=c("projectManager.projectMissing"),null;const e={title:r.title,engine:r.engine};return K.value&&(e.cwd=r.cwd),q.value&&(e.sessionId=String(r.sessionId||"").trim()),{type:"update",sessionId:b.value.id,payload:e}}async function et(e){var s,x;if(e.type==="create"){w.value=!0;try{const y=await((s=u.onCreate)==null?void 0:s.call(u,e.payload));y!=null&&y.id&&(D(y.id),k("select-session",y.id),await ht(),k("project-created",y),k("close"));return}finally{w.value=!1}}L.value=!0;try{const y=await((x=u.onUpdate)==null?void 0:x.call(u,e.sessionId,e.payload));y!=null&&y.id&&D(y.id)}finally{L.value=!1}}async function tt(){var s,x;if(!b.value||F.value)return;const e=b.value.id;d.value="",F.value=!0;try{const y=await((s=u.onDelete)==null?void 0:s.call(u,e));C.value=!1;const H=u.sessions.filter(at=>at.id!==e),N=(y==null?void 0:y.selectedSessionId)||((x=ke(H)[0])==null?void 0:x.id)||"";k("select-session",N),N?(D(N),A.value&&W()):(g(),A.value&&W())}catch(y){d.value=y.message}finally{F.value=!1}}async function nt(){var s;if(!b.value||R.value)return;const e=b.value.id;d.value="",R.value=!0;try{const x=await((s=u.onReset)==null?void 0:s.call(u,e));E.value=!1;const y=(x==null?void 0:x.session)||u.sessions.find(H=>H.id===e)||null;y!=null&&y.id&&D(y.id)}catch(x){d.value=x.message}finally{R.value=!1}}return he(()=>u.open,e=>{if(e){Be(),typeof u.onRefresh=="function"?Xe().catch(()=>{}):Ae().catch(()=>{});return}G.value=!1,C.value=!1,E.value=!1,B.value=!1,d.value=""},{immediate:!0}),he(A,e=>{e||(J.value="detail")},{immediate:!0}),he(()=>u.sessions,()=>{if(!u.open)return;if(h.value==="create"){if(!!(String(r.title||"").trim()||String(r.cwd||"").trim())||!!String(r.sessionId||"").trim())return;const x=U();x&&D(x);return}if(b.value){l(b.value);return}const e=U();if(e){D(e);return}g()}),ft(()=>{V&&(clearTimeout(V),V=null)}),(e,s)=>(p(),f(xe,null,[S(Ue,{open:E.value,title:a(c)("projectManager.confirmResetTitle"),description:b.value?a(c)("projectManager.confirmResetDescription",{title:b.value.title||a(c)("projectManager.untitledProject")}):"","confirm-text":a(c)("projectManager.confirmReset"),"cancel-text":a(c)("projectManager.keep"),loading:R.value,onCancel:s[0]||(s[0]=x=>E.value=!1),onConfirm:nt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),S(Ue,{open:C.value,title:a(c)("projectManager.confirmDeleteTitle"),description:b.value?a(c)("projectManager.confirmDeleteDescription",{title:b.value.title||a(c)("projectManager.untitledProject")}):"","confirm-text":a(c)("projectManager.confirmDelete"),"cancel-text":a(c)("projectManager.keep"),loading:F.value,danger:"",onCancel:s[1]||(s[1]=x=>C.value=!1),onConfirm:tt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),S(un,{open:G.value,"initial-path":r.cwd,suggestions:re.value,onClose:s[2]||(s[2]=x=>G.value=!1),onSelect:Qe},null,8,["open","initial-path","suggestions"]),S(Ge,{open:i.open,"panel-class":"settings-dialog-panel h-full max-w-5xl sm:h-auto sm:max-h-[88vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 overflow-hidden","close-disabled":I.value,"close-on-backdrop":!I.value,"close-on-escape":!I.value,onClose:s[12]||(s[12]=x=>k("close"))},{title:le(()=>[t("div",xa,[S(a(Ct),{class:"h-4 w-4"}),t("span",null,o(a(c)("projectManager.managingTitle")),1)])]),default:le(()=>{var x;return[a(A)?(p(),f("div",Ea,[J.value==="list"?(p(),f("div",La,[t("div",Fa,[S(We,{mobile:"",busy:I.value,"editing-session-id":M.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"has-sessions":Z.value,"is-current-session":te,"is-session-running":z,mode:h.value,sessions:ne.value,onCreate:Y,onSelect:Re},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])])])):(p(),f("div",Ba,[t("div",Aa,[t("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",disabled:I.value,onClick:W},[S(a(_t),{class:"h-4 w-4"}),t("span",null,o(a(c)("projectManager.projectList")),1)],8,Na),t("div",Oa,[t("div",za,o(je.value),1),h.value==="edit"&&((x=b.value)!=null&&x.cwd)?(p(),f("p",Ua,o(b.value.cwd),1)):j("",!0)])]),t("div",Ha,[t("div",Va,[t("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",O.value==="basic"?"tool-button-accent-subtle":""]),onClick:s[7]||(s[7]=y=>O.value="basic")},o(a(c)("projectManager.basicInfo")),3),t("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",O.value==="status"?"tool-button-accent-subtle":""]),disabled:h.value==="create",onClick:s[8]||(s[8]=y=>O.value="status")},o(a(c)("projectManager.status")),11,qa)])]),t("div",Wa,[O.value==="basic"?(p(),f("div",Ga,[S(qe,{mobile:"",busy:I.value,"can-edit-engine":h.value!=="edit"||oe.value,"can-edit-cwd":h.value!=="edit"||K.value,"can-edit-session-id":h.value!=="edit"||q.value,cwd:r.cwd,"cwd-readonly-message":Q.value,"duplicate-cwd-message":de.value,engine:r.engine,"engine-options":we.value,"engine-readonly-message":ce.value,"session-id":r.sessionId,"session-id-copied":B.value,"session-id-readonly-message":X.value,title:r.title,"workspace-suggestions":re.value,onCopySessionId:Ne,onOpenDirectoryPicker:s[9]||(s[9]=y=>G.value=!0),"onUpdate:cwd":Le,"onUpdate:engine":Ee,"onUpdate:sessionId":Fe,"onUpdate:title":De},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","engine-options","engine-readonly-message","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"]),d.value?(p(),f("p",Ja,[S(a(Ve),{class:"h-4 w-4"}),t("span",null,o(d.value),1)])):j("",!0),t("div",Ka,[t("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-sm",disabled:I.value,onClick:Oe},o(ue.value),9,Qa),h.value==="edit"&&b.value?(p(),f("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:I.value||ae.value,onClick:s[10]||(s[10]=y=>E.value=!0)},o(R.value?a(c)("projectManager.resettingSession"):a(c)("projectManager.newSession")),9,Xa)):j("",!0),h.value==="edit"&&b.value?(p(),f("button",{key:1,type:"button",class:"tool-button tool-button-danger-subtle w-full px-3 py-2 text-sm",disabled:I.value||ae.value,onClick:s[11]||(s[11]=y=>C.value=!0)},o(F.value?a(c)("projectManager.deletingProject"):a(c)("projectManager.deleteProject")),9,Ya)):j("",!0)])])):(p(),se(ha,{key:1,"active-session":b.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"is-current-session":te,"is-session-running":z},null,8,["active-session"]))])]))])):(p(),f("div",ya,[t("aside",ba,[S(We,{busy:I.value,"editing-session-id":M.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"has-sessions":Z.value,"is-current-session":te,"is-session-running":z,mode:h.value,sessions:ne.value,onCreate:Y,onSelect:Re},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])]),t("div",wa,[t("div",Sa,[t("div",null,[t("div",ka,[S(a(St),{class:"h-4 w-4"}),t("span",null,o(h.value==="create"?a(c)("projectManager.createTitle"):a(c)("projectManager.editTitle")),1)])])]),t("div",$a,[S(qe,{busy:I.value,"can-edit-engine":h.value!=="edit"||oe.value,"can-edit-cwd":h.value!=="edit"||K.value,"can-edit-session-id":h.value!=="edit"||q.value,cwd:r.cwd,"cwd-readonly-message":Q.value,"duplicate-cwd-message":de.value,engine:r.engine,"engine-options":we.value,"engine-readonly-message":ce.value,"session-id":r.sessionId,"session-id-copied":B.value,"session-id-readonly-message":X.value,title:r.title,"workspace-suggestions":re.value,onCopySessionId:Ne,onOpenDirectoryPicker:s[3]||(s[3]=y=>G.value=!0),"onUpdate:cwd":Le,"onUpdate:engine":Ee,"onUpdate:sessionId":Fe,"onUpdate:title":De},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","engine-options","engine-readonly-message","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"])]),d.value?(p(),f("p",_a,[S(a(Ve),{class:"h-4 w-4"}),t("span",null,o(d.value),1)])):j("",!0),t("div",Ca,[t("div",Ma,[h.value==="edit"&&b.value?(p(),f("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:I.value||ae.value,onClick:s[4]||(s[4]=y=>E.value=!0)},[S(a(kt),{class:"h-4 w-4"}),t("span",null,o(R.value?a(c)("projectManager.resettingSession"):a(c)("projectManager.newSession")),1)],8,ja)):j("",!0),h.value==="edit"&&b.value?(p(),f("button",{key:1,type:"button",class:"tool-button tool-button-danger-subtle inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:I.value||ae.value,onClick:s[5]||(s[5]=y=>C.value=!0)},[S(a($t),{class:"h-4 w-4"}),t("span",null,o(F.value?a(c)("projectManager.deletingProject"):a(c)("projectManager.deleteProject")),1)],8,Ia)):j("",!0)]),t("div",Pa,[t("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:s[6]||(s[6]=y=>k("close"))},o(a(c)("projectManager.close")),9,Ta),h.value==="create"&&Z.value?(p(),f("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:Be},o(a(c)("projectManager.backToList")),9,Ra)):j("",!0),t("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:Oe},o(ue.value),9,Da)])])])]))]}),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"])],64))}};export{is as default};
1
+ import{u as ye,f as st,d as lt}from"./index-CGOI_HcK.js";import{A as it,n as Pe,e as _e,r as ot,b as Ge,s as rt,f as ze,_ as dt,a as ct,h as Ue}from"./WorkbenchView-CMjjT7fc.js";import{w as he,aB as p,aG as se,aH as le,aD as t,aO as o,u as a,aE as S,aU as ut,aV as pt,aJ as P,aC as f,aP as xe,aQ as Ce,aL as j,aT as mt,aI as gt,b as $,c as _,aX as Je,ak as ft,r as vt,n as ht}from"./vendor-misc-CWjGI0ex.js";import{g as He,h as ve,L as Ie,j as xt,b as Ke,H as yt,m as bt,v as wt,P as St,d as Ve,J as kt,l as $t,p as _t,K as Ct}from"./vendor-ui-D4mCpibF.js";import"./vendor-router-Bcjfmow0.js";import"./vendor-markdown-CNlC48LI.js";import"./vendor-tiptap-BCwG_IWj.js";function Mt(i=[]){return(Array.isArray(i)&&i.length?i:it).filter(u=>u&&typeof u=="object").map(u=>{const k=Pe(u.value);return{...u,value:k,label:String(u.label||_e(k)).trim()||_e(k),enabled:u.enabled!==!1,available:u.available!==!1}})}function Te(i=[]){return Mt(i).filter(T=>T.enabled&&T.available)}async function jt(){const i=await ot("/api/meta",{cache:"no-store"});return Te(i==null?void 0:i.agentEngineOptions)}const It={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Pt={class:"theme-muted-text mt-1 text-xs leading-5"},Tt={class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Rt={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},Dt={class:"flex items-start gap-2 text-xs leading-5"},Et={class:"theme-muted-text shrink-0"},Lt={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},Ft={class:"theme-muted-text mt-4 block text-xs"},Bt={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},At=["placeholder"],Nt={class:"mt-4 flex items-center gap-1.5"},Ot={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},zt={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},Ut={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},Ht={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},Vt={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},qt={key:4,class:"theme-empty-state px-3 py-8 text-sm"},Wt={key:5,class:"theme-empty-state px-3 py-8 text-sm"},Gt={key:6,class:"theme-empty-state px-3 py-8 text-sm"},Jt={key:7,class:"space-y-1"},Kt=["onClick"],Qt={class:"min-w-0 flex-1"},Xt=["innerHTML"],Yt=["innerHTML"],Zt={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},en={key:8,class:"space-y-1"},tn={class:"flex items-start gap-1.5"},nn=["onClick"],an=["onClick"],sn={class:"min-w-0 flex-1"},ln={key:0,class:"theme-muted-text truncate font-mono text-[10px]"},on={class:"theme-divider flex flex-col-reverse gap-2 border-t border-dashed px-4 py-4 sm:flex-row sm:items-center sm:justify-end sm:px-5"},rn={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},dn=["disabled"],cn=["disabled"],un={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(i,{emit:T}){const u=i,k=T,{t:v}=ye(),c=$(""),h=$(null),M=$(!1),r=$(""),d=$(!1),w=$(""),L=$([]),F=$(!1),R=$(""),C=$("tree"),E=$(""),G=$("");let B=null,A=0;const J=_(()=>de(h.value?[h.value]:[])),O=_(()=>C.value==="search"&&!R.value.trim()),ie=_(()=>C.value==="search"&&!!R.value.trim()&&!d.value&&!w.value&&!L.value.length),V=_(()=>C.value==="tree"&&!M.value&&!r.value&&!J.value.length);function ne(n=""){const m=String(n||"").trim();return/^[a-z]:[\\/]/i.test(m)||m.includes("\\")}function b(n=""){const m=String(n||"").trim();if(!m)return"";const l=ne(m);let g=m.replace(/\\/g,"/");return g.length>1&&!/^[a-z]:\/?$/i.test(g)&&g!=="/"&&(g=g.replace(/\/+$/,"")),l?g.toLowerCase():g}function Z(n="",m=""){const l=b(n),g=b(m);return!l||!g?!1:l===g||l.startsWith(`${g}/`)}function Me(n="",m=""){const l=String(n||"").trim(),g=String(m||"").trim();return l?g?ne(l)?/^[a-z]:\\?$/i.test(l)?`${l.replace(/[\\/]+$/,"")}\\${g}`:`${l.replace(/[\\/]+$/,"")}\\${g}`:l==="/"?`/${g}`:`${l.replace(/\/+$/,"")}/${g}`:l:g}function ae(n="",m=""){const l=b(n),g=b(m);if(!l||!g||!Z(g,l))return[];const D=g===l?"":g.slice(l.length).replace(/^\//,"");return D?D.split("/").filter(Boolean):[]}function K(n){return(n==null?void 0:n.name)||(n==null?void 0:n.path)||v("directoryPicker.unnamedDirectory")}function oe(n=""){const m=String(n||"").trim();return m?m.split(/[\\/]/).filter(Boolean).at(-1)||m:"Home"}function q(n=""){return String(n||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function I(n="",m=""){const l=String(n||""),g=String(m||"").trim().toLowerCase();if(!l||!g)return null;const D=l.toLowerCase(),U=D.indexOf(g);if(U>=0)return{start:U,end:U+g.length};const $e=g.split(/[\\/\s_.-]+/).filter(Boolean).sort((W,Y)=>Y.length-W.length);for(const W of $e){if(W.length<2)continue;const Y=D.indexOf(W);if(Y>=0)return{start:Y,end:Y+W.length}}return null}function be(n="",m=""){const l=String(n||""),g=I(l,m);return g?`${q(l.slice(0,g.start))}<mark class="theme-search-highlight">${q(l.slice(g.start,g.end))}</mark>${q(l.slice(g.end))}`:q(l)}function re(n){return be(K(n),R.value)}function we(n){return be((n==null?void 0:n.path)||"",R.value)}function ee(n,m=0){return{...n,depth:m,expanded:!1,loaded:!1,loading:!1,children:[]}}function de(n=[],m=[]){return n.forEach(l=>{m.push(l),l.expanded&&l.children.length&&de(l.children,m)}),m}function Q(){h.value&&(h.value={...h.value})}function ce(n,m=h.value?[h.value]:[]){const l=b(n);if(!l)return null;for(const g of m){if(b(g.path)===l)return g;if(g.children.length){const D=ce(n,g.children);if(D)return D}}return null}function X(n){E.value=String((n==null?void 0:n.path)||"").trim(),G.value=K(n)}async function ue(n,m={}){if(!(!n||n.loading)&&!(n.loaded&&!m.force)){n.loading=!0,r.value="",Q();try{const l=await ze({path:n.path,limit:240});n.children=(l.items||[]).map(g=>ee(g,n.depth+1)),n.loaded=!0}catch(l){r.value=l.message||v("directoryPicker.loadFailed")}finally{n.loading=!1,Q()}}}async function je(){M.value=!0,r.value="";try{const n=await ze({limit:240});c.value=String(n.path||""),h.value=ee({name:oe(n.path||""),path:String(n.path||""),type:"directory",hasChildren:!0,isHomeRoot:!0},0),h.value.children=(n.items||[]).map(m=>ee(m,1)),h.value.loaded=!0,h.value.expanded=!0,X(h.value)}catch(n){r.value=n.message||v("directoryPicker.treeLoadFailed"),h.value=null,c.value=""}finally{M.value=!1}}async function pe(n=""){const m=String(n||"").trim();if(!m||!c.value||!Z(m,c.value))return;let l=h.value;if(!l)return;X(l);const g=ae(c.value,m);for(const D of g){await ue(l),l.expanded=!0,Q();const U=ce(Me(l.path,D),l.children);if(!U)break;l=U,X(l)}}async function Se(){R.value="",C.value="tree",L.value=[],w.value="",F.value=!1,E.value="",G.value="",await je();const n=String(u.initialPath||"").trim();n&&Z(n,c.value)&&await pe(n)}async function z(n){if(n!=null&&n.path&&(X(n),!!n.hasChildren)){if(!n.loaded){n.expanded=!0,Q(),await ue(n);return}n.expanded=!n.expanded,Q()}}function te(n){n!=null&&n.path&&(X(n),C.value="tree")}async function ke(){const n=String(R.value||"").trim();A+=1;const m=A;if(!u.open||!n||!c.value){d.value=!1,w.value="",L.value=[],F.value=!1;return}d.value=!0,w.value="";try{const l=await rt(n,{path:c.value,limit:80});if(m!==A)return;L.value=Array.isArray(l.items)?l.items:[],F.value=!!l.truncated}catch(l){if(m!==A)return;w.value=l.message||v("directoryPicker.searchFailed"),L.value=[],F.value=!1}finally{m===A&&(d.value=!1)}}function me(){if(B&&(window.clearTimeout(B),B=null),!String(R.value||"").trim()){d.value=!1,w.value="",L.value=[],F.value=!1;return}d.value=!0,w.value="",B=window.setTimeout(()=>{ke()},120)}async function ge(n){n!=null&&n.path&&(C.value="tree",await pe(n.path))}function fe(){E.value&&(k("select",E.value),k("close"))}return he(R,()=>{C.value=R.value.trim()?"search":"tree",me()}),he(()=>u.open,n=>{if(n){Se().catch(()=>{});return}B&&(window.clearTimeout(B),B=null)}),(n,m)=>(p(),se(Ge,{open:i.open,"backdrop-class":"z-[60] items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6","panel-class":"settings-dialog-panel h-full max-w-4xl sm:h-auto sm:max-h-[86vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:px-5","close-disabled":M.value||d.value,"close-on-backdrop":!(M.value||d.value),"close-on-escape":!(M.value||d.value),onClose:m[4]||(m[4]=l=>k("close"))},{title:le(()=>[t("div",null,[t("div",It,[S(a(ve),{class:"h-4 w-4"}),t("span",null,o(a(v)("directoryPicker.title")),1)]),t("p",Pt,o(a(v)("directoryPicker.intro")),1)])]),default:le(()=>[t("div",Tt,[t("div",Rt,[t("div",Dt,[t("span",Et,o(a(v)("directoryPicker.currentSelection")),1),t("span",Lt,o(E.value||a(v)("directoryPicker.selectionPlaceholder")),1)])]),t("label",Ft,[t("span",null,o(a(v)("directoryPicker.searchLabel")),1),t("div",Bt,[S(a(He),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),ut(t("input",{"onUpdate:modelValue":m[0]||(m[0]=l=>R.value=l),type:"text",placeholder:a(v)("directoryPicker.searchPlaceholder"),class:"min-w-0 flex-1 border-0 bg-transparent px-0 text-sm text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]"},null,8,At),[[pt,R.value]])])]),t("div",Nt,[t("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",C.value==="search"?"tool-button-accent-subtle":"theme-filter-idle border-dashed"]),onClick:m[1]||(m[1]=l=>C.value="search")},[S(a(He),{class:"h-3.5 w-3.5"}),t("span",null,o(a(v)("directoryPicker.searchTab")),1)],2),t("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",C.value==="tree"?"tool-button-accent-subtle":"theme-filter-idle border-dashed"]),onClick:m[2]||(m[2]=l=>C.value="tree")},[S(a(ve),{class:"h-3.5 w-3.5"}),t("span",null,o(a(v)("directoryPicker.treeTab")),1)],2)]),t("div",Ot,[C.value==="search"&&w.value?(p(),f("div",zt,o(w.value),1)):C.value==="tree"&&r.value?(p(),f("div",Ut,o(r.value),1)):C.value==="search"&&d.value?(p(),f("div",Ht,[S(a(Ie),{class:"h-4 w-4 animate-spin"}),t("span",null,o(a(v)("directoryPicker.searching")),1)])):C.value==="tree"&&M.value?(p(),f("div",Vt,[S(a(Ie),{class:"h-4 w-4 animate-spin"}),t("span",null,o(a(v)("directoryPicker.treeLoading")),1)])):O.value?(p(),f("div",qt,o(a(v)("directoryPicker.searchPrompt")),1)):ie.value?(p(),f("div",Wt,o(a(v)("directoryPicker.noSearchResults")),1)):V.value?(p(),f("div",Gt,o(a(v)("directoryPicker.emptyTree")),1)):C.value==="search"?(p(),f("div",Jt,[(p(!0),f(xe,null,Ce(L.value,l=>(p(),f("button",{key:l.path,type:"button",class:P(["flex w-full items-start gap-2 rounded-sm border border-transparent px-2.5 py-1.5 text-left transition",b(E.value)===b(l.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:g=>ge(l)},[S(a(ve),{class:"theme-muted-text mt-0.5 h-4 w-4 shrink-0"}),t("div",Qt,[t("div",null,[t("span",{class:"truncate text-[13px] text-[var(--theme-textPrimary)]",innerHTML:re(l)},null,8,Xt)]),t("div",{class:"theme-muted-text truncate font-mono text-[10px]",innerHTML:we(l)},null,8,Yt)])],10,Kt))),128)),F.value?(p(),f("p",Zt,o(a(v)("directoryPicker.truncatedHint")),1)):j("",!0)])):(p(),f("div",en,[(p(!0),f(xe,null,Ce(J.value,l=>(p(),f("div",{key:l.path,class:P(["rounded-sm border border-transparent px-1.5 py-1 transition",b(E.value)===b(l.path)?"theme-list-item-active":l.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:mt({paddingLeft:`${l.depth*16+6}px`})},[t("div",tn,[t("button",{type:"button",class:P(["theme-icon-button h-5 w-5 shrink-0",l.hasChildren?"":"invisible pointer-events-none"]),onClick:gt(g=>z(l),["stop"])},[l.loading?(p(),se(a(Ie),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(p(),se(a(xt),{key:1,class:P(["h-3.5 w-3.5 transition",l.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,nn),t("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:g=>te(l)},[S(a(ve),{class:P(["h-4 w-4 shrink-0",b(E.value)===b(l.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),t("div",sn,[t("div",{class:P(["truncate text-[13px]",l.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},o(K(l)),3),l.isHomeRoot?(p(),f("div",ln,o(l.path),1)):j("",!0)])],8,an)])],6))),128))]))])]),t("div",on,[t("div",rn,[t("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:M.value||d.value,onClick:m[3]||(m[3]=l=>k("close"))},o(a(v)("directoryPicker.cancel")),9,dn),t("button",{type:"button",class:"tool-button tool-button-primary inline-flex w-full items-center justify-center gap-2 px-3 py-2 text-xs sm:w-auto",disabled:M.value||d.value||!E.value,onClick:fe},[S(a(Ke),{class:"h-4 w-4"}),t("span",null,o(a(v)("directoryPicker.useCurrentDirectory")),1)],8,cn)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},pn={class:"grid gap-4"},mn={class:"theme-muted-text block text-xs"},gn=["value","disabled"],fn={class:"theme-muted-text block text-xs"},vn={class:"mt-1 flex gap-2"},hn=["value","disabled"],xn=["disabled"],yn={id:"codex-manager-workspace-suggestions"},bn=["value"],wn={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Sn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},kn={class:"theme-muted-text block text-xs"},$n={class:"mt-1"},_n={class:"flex items-center gap-2 text-sm"},Cn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Mn=["disabled","onClick"],jn={class:"flex items-center justify-between gap-3"},In={class:"min-w-0 flex-1 truncate"},Pn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Tn={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},Rn={class:"theme-muted-text block text-xs"},Dn={class:"mt-1 flex gap-2"},En=["value","disabled"],Ln=["disabled"],Fn={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},Bn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},qe={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},canEditEngine:{type:Boolean,default:!0},canEditCwd:{type:Boolean,default:!0},canEditSessionId:{type:Boolean,default:!0},cwd:{type:String,default:""},cwdReadonlyMessage:{type:String,default:""},duplicateCwdMessage:{type:String,default:""},engine:{type:String,default:"codex"},engineOptions:{type:Array,default:()=>[]},engineReadonlyMessage:{type:String,default:""},mobile:{type:Boolean,default:!1},sessionId:{type:String,default:""},sessionIdCopied:{type:Boolean,default:!1},sessionIdReadonlyMessage:{type:String,default:""},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","update:cwd","update:engine","update:sessionId","update:title"],setup(i,{emit:T}){const u=i,k=T,{t:v}=ye(),c=_(()=>{const M=String(u.engine||"").trim();return u.engineOptions.find(r=>String((r==null?void 0:r.value)||"").trim()===M)||null}),h=_(()=>String(u.sessionId||"").trim());return(M,r)=>(p(),f("div",pn,[t("label",mn,[t("span",null,o(a(v)("projectManager.projectTitleOptional")),1),t("input",{value:i.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:i.busy,onInput:r[0]||(r[0]=d=>k("update:title",d.target.value))},null,40,gn)]),t("label",fn,[t("span",null,o(a(v)("projectManager.workingDirectoryField")),1),t("div",vn,[t("input",{value:i.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:P(["tool-input min-w-0 flex-1 disabled:cursor-not-allowed disabled:opacity-80",i.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:i.busy||!i.canEditCwd,onInput:r[1]||(r[1]=d=>k("update:cwd",d.target.value))},null,42,hn),t("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:i.busy||!i.canEditCwd,onClick:r[2]||(r[2]=d=>k("open-directory-picker"))},[S(a(ve),{class:"h-4 w-4"}),t("span",null,o(i.mobile?a(v)("projectManager.choose"):a(v)("projectManager.chooseDirectory")),1)],8,xn)]),t("datalist",yn,[(p(!0),f(xe,null,Ce(i.workspaceSuggestions,d=>(p(),f("option",{key:d,value:d},null,8,bn))),128))]),i.duplicateCwdMessage?(p(),f("p",wn,o(i.duplicateCwdMessage),1)):i.cwdReadonlyMessage?(p(),f("p",Sn,o(i.cwdReadonlyMessage),1)):j("",!0)]),t("label",kn,[t("span",null,o(a(v)("projectManager.engineField")),1),t("div",$n,[S(dt,{"model-value":i.engine,options:i.engineOptions,disabled:i.busy||!i.canEditEngine,placeholder:a(v)("projectManager.selectEngine"),"empty-text":a(v)("projectManager.noEngines"),"get-option-value":d=>(d==null?void 0:d.value)||"","onUpdate:modelValue":r[3]||(r[3]=d=>k("update:engine",d))},{trigger:le(({disabled:d})=>{var w;return[t("div",_n,[t("span",{class:P(["min-w-0 flex-1 truncate",d?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},o(((w=c.value)==null?void 0:w.label)||a(v)("projectManager.selectEngine")),3),c.value&&c.value.enabled===!1?(p(),f("span",Cn,o(a(v)("projectManager.comingSoon")),1)):j("",!0)])]}),option:le(({option:d,selected:w,select:L})=>[t("button",{type:"button",class:P(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",w?"theme-filter-active":"theme-filter-idle"]),disabled:(d==null?void 0:d.enabled)===!1,onClick:L},[t("div",jn,[t("span",In,o(d.label),1),(d==null?void 0:d.enabled)===!1?(p(),f("span",Pn,o(a(v)("projectManager.comingSoon")),1)):j("",!0)])],10,Mn)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),i.engineReadonlyMessage?(p(),f("p",Tn,o(i.engineReadonlyMessage),1)):j("",!0)]),t("label",Rn,[t("span",null,o(a(v)("projectManager.sessionId")),1),t("div",Dn,[t("input",{value:i.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 flex-1 disabled:cursor-not-allowed disabled:opacity-80",disabled:i.busy||!i.canEditSessionId,onInput:r[4]||(r[4]=d=>k("update:sessionId",d.target.value))},null,40,En),h.value?(p(),f("button",{key:0,type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:i.busy,onClick:r[5]||(r[5]=d=>k("copy-session-id"))},[i.sessionIdCopied?(p(),se(a(Ke),{key:0,class:"h-4 w-4"})):(p(),se(a(yt),{key:1,class:"h-4 w-4"})),t("span",null,o(i.sessionIdCopied?a(v)("projectManager.sessionIdCopied"):a(v)("projectManager.copySessionId")),1)],8,Ln)):j("",!0)]),i.sessionIdReadonlyMessage?(p(),f("p",Fn,o(i.sessionIdReadonlyMessage),1)):(p(),f("p",Bn,o(a(v)("projectManager.sessionIdHint")),1))])]))}},An={class:"flex items-center justify-between gap-3"},Nn={class:"theme-heading text-sm font-medium"},On={key:0,class:"theme-muted-text mt-1 text-xs"},zn=["disabled"],Un=["onClick"],Hn={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},Vn={class:"flex w-full flex-col gap-2 text-left"},qn={class:"theme-heading min-w-0 text-sm font-medium"},Wn=["title"],Gn=["title"],Jn={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},Kn={key:0,"aria-hidden":"true"},Qn={key:1},Xn={class:"flex flex-wrap items-center gap-2 pt-1"},Yn={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},We={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:i=>i},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},hasSessions:{type:Boolean,default:!1},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1},mode:{type:String,default:"edit"},mobile:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]}},emits:["create","select"],setup(i,{emit:T}){const u=i,k=T,{t:v}=ye();function c(r){return u.mode==="edit"&&u.editingSessionId===r.id?"theme-card-selected":u.isSessionRunning(r.id)?"theme-card-warning":"theme-card-idle-strong"}function h(r){return u.isCurrentSession(r.id)?v("projectManager.current"):v("projectManager.regular")}function M(r){return u.isCurrentSession(r.id)?"theme-status-info":"theme-status-neutral"}return(r,d)=>(p(),f("div",{class:P(i.mobile?"flex h-full min-h-0 flex-col":"")},[t("div",An,[t("div",null,[t("div",Nn,o(a(v)("projectManager.projectList")),1),i.hasSessions?j("",!0):(p(),f("p",On,o(a(v)("projectManager.noProjects")),1))]),t("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:i.busy,onClick:d[0]||(d[0]=w=>k("create"))},[S(a(bt),{class:"h-4 w-4"}),t("span",null,o(a(v)("projectManager.create")),1)],8,zn)]),t("div",{class:P(["mt-4 space-y-2",i.mobile?"min-h-0 flex-1 overflow-y-auto":"max-h-52 overflow-y-auto pr-1 sm:max-h-64 lg:max-h-[calc(88vh-11rem)]"])},[(p(!0),f(xe,null,Ce(i.sessions,w=>(p(),f("article",{key:w.id,class:P(["relative cursor-pointer rounded-sm border p-3 transition",c(w)]),onClick:L=>k("select",w.id)},[i.mode==="edit"&&i.editingSessionId===w.id?(p(),f("span",Hn)):j("",!0),t("div",Vn,[t("div",qn,[t("span",{class:"block truncate",title:w.title||a(v)("projectManager.untitledProject")},o(w.title||a(v)("projectManager.untitledProject")),9,Wn)]),t("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:w.cwd},o(w.cwd),9,Gn),t("div",Jn,[t("span",null,o(a(_e)(w.engine)),1),i.mobile?j("",!0):(p(),f("span",Kn,"·")),i.mobile?j("",!0):(p(),f("span",Qn,o(i.formatUpdatedAt(w.updatedAt)),1))]),t("div",Xn,[t("span",{class:P(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",M(w)])},o(h(w)),3),t("span",{class:P(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",i.getRuntimeStatusClass(w.id)])},[i.isSessionRunning(w.id)?(p(),f("span",Yn)):j("",!0),Je(" "+o(i.getRuntimeStatusLabel(w.id)),1)],2),t("span",{class:P(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",i.getThreadStatusClass(w)])},o(i.getThreadStatusLabel(w)),3)])])],10,Un))),128))],2)],2))}},Zn={class:"space-y-3"},ea={class:"dashed-panel px-3 py-3"},ta={class:"theme-muted-text text-[11px]"},na={class:"mt-2 flex flex-wrap gap-2"},aa={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},sa={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},la={class:"dashed-panel px-3 py-3"},ia={class:"theme-muted-text text-[11px]"},oa={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},ra={class:"dashed-panel px-3 py-3"},da={class:"theme-muted-text text-[11px]"},ca={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},ua={class:"dashed-panel px-3 py-3"},pa={class:"theme-muted-text text-[11px]"},ma={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},ga={class:"dashed-panel px-3 py-3"},fa={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},va={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},ha={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:i=>i},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1}},setup(i){const{t:T}=ye();return(u,k)=>{var v,c,h,M,r,d,w;return p(),f("div",Zn,[t("div",ea,[t("div",ta,o(a(T)("projectManager.runtimeStatus")),1),t("div",na,[t("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",i.getRuntimeStatusClass((v=i.activeSession)==null?void 0:v.id)])},[i.isSessionRunning((c=i.activeSession)==null?void 0:c.id)?(p(),f("span",aa)):j("",!0),Je(" "+o(i.getRuntimeStatusLabel((h=i.activeSession)==null?void 0:h.id)),1)],2),t("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",i.getThreadStatusClass(i.activeSession)])},o(i.getThreadStatusLabel(i.activeSession)),3),(M=i.activeSession)!=null&&M.id&&i.isCurrentSession(i.activeSession.id)?(p(),f("span",sa,o(a(T)("projectManager.currentProject")),1)):j("",!0)])]),t("div",la,[t("div",ia,o(a(T)("projectManager.engine")),1),t("div",oa,o(a(_e)((r=i.activeSession)==null?void 0:r.engine)),1)]),t("div",ra,[t("div",da,o(a(T)("projectManager.workingDirectory")),1),t("div",ca,o(((d=i.activeSession)==null?void 0:d.cwd)||a(T)("projectManager.notSet")),1)]),t("div",ua,[t("div",pa,o(a(T)("projectManager.updatedAt")),1),t("div",ma,o(i.formatUpdatedAt((w=i.activeSession)==null?void 0:w.updatedAt)),1)]),t("div",ga,[t("div",fa,[S(a(wt),{class:"h-3.5 w-3.5"}),t("span",null,o(a(T)("projectManager.note")),1)]),t("p",va,o(a(T)("projectManager.noteDescription")),1)])])}}},xa={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ya={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},ba={class:"theme-divider theme-muted-panel border-b px-3 py-3 sm:px-4 sm:py-4 lg:border-b-0 lg:border-r"},wa={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},Sa={class:"flex flex-wrap items-start justify-between gap-3"},ka={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},$a={class:"mt-5"},_a={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Ca={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4 sm:flex-row sm:items-center sm:justify-between"},Ma={class:"flex flex-wrap items-center gap-2"},ja=["disabled"],Ia=["disabled"],Pa={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Ta=["disabled"],Ra=["disabled"],Da=["disabled"],Ea={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},La={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Fa={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},Ba={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Aa={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Na=["disabled"],Oa={class:"min-w-0 flex-1"},za={class:"theme-heading truncate text-sm font-medium"},Ua={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Ha={class:"theme-divider border-b px-4 py-3"},Va={class:"grid grid-cols-2 gap-2"},qa=["disabled"],Wa={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Ga={key:0},Ja={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Ka={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Qa=["disabled"],Xa=["disabled"],Ya=["disabled"],is={__name:"CodexSessionManagerDialog",props:{open:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]},workspaces:{type:Array,default:()=>[]},selectedSessionId:{type:String,default:""},selectionLocked:{type:Boolean,default:!1},selectionLockReason:{type:String,default:""},loading:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},onRefresh:{type:Function,default:null},onCreate:{type:Function,default:null},onUpdate:{type:Function,default:null},onDelete:{type:Function,default:null},onReset:{type:Function,default:null}},emits:["close","project-created","select-session"],setup(i,{emit:T}){const u=i,k=T,{locale:v,t:c}=ye(),h=$("edit"),M=$(""),r=vt({title:"",engine:"codex",cwd:"",sessionId:""}),d=$(""),w=$(!1),L=$(!1),F=$(!1),R=$(!1),C=$(!1),E=$(!1),G=$(!1),B=$(!1),{matches:A}=ct("(max-width: 767px)"),J=$("list"),O=$("basic"),ie=$(Te());let V=null;const ne=_(()=>ke(u.sessions)),b=_(()=>u.sessions.find(e=>e.id===M.value)||null),Z=_(()=>u.sessions.length>0),Me=_(()=>u.sessions.find(e=>e.id===u.selectedSessionId)||null),ae=_(()=>!!(b.value&&z(b.value.id))),K=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),oe=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),q=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),I=_(()=>u.loading||w.value||L.value||F.value||R.value),be=_(()=>String(r.sessionId||"").trim()),re=_(()=>{var x,y;const e=new Set,s=[];return[r.cwd,(x=b.value)==null?void 0:x.cwd,(y=Me.value)==null?void 0:y.cwd,...u.workspaces,...u.sessions.map(H=>H.cwd)].forEach(H=>{const N=String(H||"").trim();!N||e.has(N)||(e.add(N),s.push(N))}),s.slice(0,12)}),we=_(()=>ie.value),ee=_(()=>{const e=Se(r.cwd);return e?u.sessions.filter(s=>{var x;return s.id===((x=b.value)==null?void 0:x.id)?!1:Se(s.cwd)===e}):[]}),de=_(()=>{if(!ee.value.length)return"";const e=ee.value.slice(0,3).map(s=>{const x=s.title||c("projectManager.untitledProject");return v.value==="en-US"?`"${x}"`:`「${x}」`}).join(v.value==="en-US"?", ":"、");return c("projectManager.duplicateDirectory",{labels:e,count:ee.value.length})}),Q=_(()=>h.value!=="edit"||K.value?"":c("projectManager.cwdReadonly")),ce=_(()=>h.value!=="edit"||!b.value||oe.value?"":c("projectManager.engineReadonly")),X=_(()=>h.value!=="edit"||!b.value||q.value?"":c("projectManager.sessionIdReadonly")),ue=_(()=>h.value==="create"?w.value?c("projectManager.creatingProject"):c("projectManager.createProject"):L.value?c("projectManager.savingChanges"):c("projectManager.saveChanges")),je=_(()=>{var e;return h.value==="create"?c("projectManager.newProject"):((e=b.value)==null?void 0:e.title)||c("projectManager.untitledProject")});function pe(e=""){const s=Date.parse(String(e||""));return Number.isFinite(s)?s:0}function Se(e=""){const s=String(e||"").trim();if(!s)return"";const x=/^[a-z]:[\\/]/i.test(s)||s.includes("\\");let y=s.replace(/\\/g,"/");return y.length>1&&!/^[a-z]:\/$/i.test(y)&&(y=y.replace(/\/+$/,"")),x?y.toLowerCase():y}function z(e){var s;return!!((s=u.sessions.find(x=>x.id===e))!=null&&s.running)}function te(e){return!!e&&e===u.selectedSessionId}function ke(e=[]){return[...e].sort((s,x)=>{const y=Number(z(x.id))-Number(z(s.id));if(y)return y;const H=Number(te(x.id))-Number(te(s.id));if(H)return H;const N=pe(x.updatedAt)-pe(s.updatedAt);return N||lt(String(s.title||s.cwd||s.id),String(x.title||x.cwd||x.id))})}function me(e){return z(e)?c("projectManager.running"):c("projectManager.idle")}function ge(e){return z(e)?"theme-status-warning":"theme-status-success"}function fe(e){return e!=null&&e.started?c("projectManager.threadBound"):c("projectManager.notStarted")}function n(e){return e!=null&&e.started?"theme-status-success":"theme-status-neutral"}function m(e=""){if(!e)return c("projectManager.unknown");const s=new Date(e);return Number.isNaN(s.getTime())?e:st(s.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function l(e){r.title=String((e==null?void 0:e.title)||""),r.engine=Pe(e==null?void 0:e.engine),r.cwd=String((e==null?void 0:e.cwd)||""),r.sessionId=String((e==null?void 0:e.sessionId)||(e==null?void 0:e.engineSessionId)||(e==null?void 0:e.engineThreadId)||(e==null?void 0:e.codexThreadId)||"").trim()}function g(){h.value="create",M.value="",d.value="",r.title="",r.engine="codex",r.cwd="",r.sessionId=""}function D(e){const s=u.sessions.find(x=>x.id===e);s&&(h.value="edit",M.value=s.id,d.value="",l(s))}function U(){var e;return u.selectedSessionId&&u.sessions.some(s=>s.id===u.selectedSessionId)?u.selectedSessionId:((e=ne.value[0])==null?void 0:e.id)||""}function $e(e="basic"){J.value="detail",O.value=e}function W(){J.value="list",O.value="basic"}function Y(){g(),A.value&&$e("basic")}function Re(e){I.value||(D(e),A.value&&$e("basic"))}function Qe(e){r.cwd=String(e||"").trim()}function De(e){r.title=String(e||"")}function Ee(e){r.engine=Pe(e)}function Le(e){r.cwd=String(e||"")}function Fe(e){r.sessionId=String(e||"")}function Be(){d.value="",C.value=!1,E.value=!1,B.value=!1,O.value="basic",J.value=A.value?"list":"detail";const e=U();if(e){D(e);return}g()}async function Xe(){if(!(I.value||typeof u.onRefresh!="function")){d.value="";try{await Promise.all([u.onRefresh(),Ae()])}catch(e){d.value=e.message}}}async function Ae(){try{ie.value=await jt()}catch{ie.value=Te()}}async function Ye(e){var x;if((x=navigator.clipboard)!=null&&x.writeText&&window.isSecureContext){await navigator.clipboard.writeText(e);return}const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly","true"),s.style.position="fixed",s.style.opacity="0",s.style.pointerEvents="none",document.body.appendChild(s),s.select(),document.execCommand("copy"),document.body.removeChild(s)}async function Ne(){const e=be.value;if(e)try{await Ye(e),B.value=!0,V&&clearTimeout(V),V=setTimeout(()=>{B.value=!1,V=null},1800)}catch(s){d.value=(s==null?void 0:s.message)||c("projectManager.copySessionIdFailed")}}async function Oe(){if(!I.value){d.value="";try{const e=Ze();if(!e)return;await et(e)}catch(e){d.value=e.message}}}function Ze(){if(h.value==="create"){const s=String(r.cwd||"").trim();return s?{type:"create",cwd:s,payload:{title:r.title,engine:r.engine,cwd:s,sessionId:String(r.sessionId||"").trim()}}:(d.value=c("projectManager.directoryRequired"),null)}if(!b.value)return d.value=c("projectManager.projectMissing"),null;const e={title:r.title,engine:r.engine};return K.value&&(e.cwd=r.cwd),q.value&&(e.sessionId=String(r.sessionId||"").trim()),{type:"update",sessionId:b.value.id,payload:e}}async function et(e){var s,x;if(e.type==="create"){w.value=!0;try{const y=await((s=u.onCreate)==null?void 0:s.call(u,e.payload));y!=null&&y.id&&(D(y.id),k("select-session",y.id),await ht(),k("project-created",y),k("close"));return}finally{w.value=!1}}L.value=!0;try{const y=await((x=u.onUpdate)==null?void 0:x.call(u,e.sessionId,e.payload));y!=null&&y.id&&D(y.id)}finally{L.value=!1}}async function tt(){var s,x;if(!b.value||F.value)return;const e=b.value.id;d.value="",F.value=!0;try{const y=await((s=u.onDelete)==null?void 0:s.call(u,e));C.value=!1;const H=u.sessions.filter(at=>at.id!==e),N=(y==null?void 0:y.selectedSessionId)||((x=ke(H)[0])==null?void 0:x.id)||"";k("select-session",N),N?(D(N),A.value&&W()):(g(),A.value&&W())}catch(y){d.value=y.message}finally{F.value=!1}}async function nt(){var s;if(!b.value||R.value)return;const e=b.value.id;d.value="",R.value=!0;try{const x=await((s=u.onReset)==null?void 0:s.call(u,e));E.value=!1;const y=(x==null?void 0:x.session)||u.sessions.find(H=>H.id===e)||null;y!=null&&y.id&&D(y.id)}catch(x){d.value=x.message}finally{R.value=!1}}return he(()=>u.open,e=>{if(e){Be(),typeof u.onRefresh=="function"?Xe().catch(()=>{}):Ae().catch(()=>{});return}G.value=!1,C.value=!1,E.value=!1,B.value=!1,d.value=""},{immediate:!0}),he(A,e=>{e||(J.value="detail")},{immediate:!0}),he(()=>u.sessions,()=>{if(!u.open)return;if(h.value==="create"){if(!!(String(r.title||"").trim()||String(r.cwd||"").trim())||!!String(r.sessionId||"").trim())return;const x=U();x&&D(x);return}if(b.value){l(b.value);return}const e=U();if(e){D(e);return}g()}),ft(()=>{V&&(clearTimeout(V),V=null)}),(e,s)=>(p(),f(xe,null,[S(Ue,{open:E.value,title:a(c)("projectManager.confirmResetTitle"),description:b.value?a(c)("projectManager.confirmResetDescription",{title:b.value.title||a(c)("projectManager.untitledProject")}):"","confirm-text":a(c)("projectManager.confirmReset"),"cancel-text":a(c)("projectManager.keep"),loading:R.value,onCancel:s[0]||(s[0]=x=>E.value=!1),onConfirm:nt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),S(Ue,{open:C.value,title:a(c)("projectManager.confirmDeleteTitle"),description:b.value?a(c)("projectManager.confirmDeleteDescription",{title:b.value.title||a(c)("projectManager.untitledProject")}):"","confirm-text":a(c)("projectManager.confirmDelete"),"cancel-text":a(c)("projectManager.keep"),loading:F.value,danger:"",onCancel:s[1]||(s[1]=x=>C.value=!1),onConfirm:tt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),S(un,{open:G.value,"initial-path":r.cwd,suggestions:re.value,onClose:s[2]||(s[2]=x=>G.value=!1),onSelect:Qe},null,8,["open","initial-path","suggestions"]),S(Ge,{open:i.open,"panel-class":"settings-dialog-panel h-full max-w-5xl sm:h-auto sm:max-h-[88vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 overflow-hidden","close-disabled":I.value,"close-on-backdrop":!I.value,"close-on-escape":!I.value,onClose:s[12]||(s[12]=x=>k("close"))},{title:le(()=>[t("div",xa,[S(a(Ct),{class:"h-4 w-4"}),t("span",null,o(a(c)("projectManager.managingTitle")),1)])]),default:le(()=>{var x;return[a(A)?(p(),f("div",Ea,[J.value==="list"?(p(),f("div",La,[t("div",Fa,[S(We,{mobile:"",busy:I.value,"editing-session-id":M.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"has-sessions":Z.value,"is-current-session":te,"is-session-running":z,mode:h.value,sessions:ne.value,onCreate:Y,onSelect:Re},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])])])):(p(),f("div",Ba,[t("div",Aa,[t("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",disabled:I.value,onClick:W},[S(a(_t),{class:"h-4 w-4"}),t("span",null,o(a(c)("projectManager.projectList")),1)],8,Na),t("div",Oa,[t("div",za,o(je.value),1),h.value==="edit"&&((x=b.value)!=null&&x.cwd)?(p(),f("p",Ua,o(b.value.cwd),1)):j("",!0)])]),t("div",Ha,[t("div",Va,[t("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",O.value==="basic"?"tool-button-accent-subtle":""]),onClick:s[7]||(s[7]=y=>O.value="basic")},o(a(c)("projectManager.basicInfo")),3),t("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",O.value==="status"?"tool-button-accent-subtle":""]),disabled:h.value==="create",onClick:s[8]||(s[8]=y=>O.value="status")},o(a(c)("projectManager.status")),11,qa)])]),t("div",Wa,[O.value==="basic"?(p(),f("div",Ga,[S(qe,{mobile:"",busy:I.value,"can-edit-engine":h.value!=="edit"||oe.value,"can-edit-cwd":h.value!=="edit"||K.value,"can-edit-session-id":h.value!=="edit"||q.value,cwd:r.cwd,"cwd-readonly-message":Q.value,"duplicate-cwd-message":de.value,engine:r.engine,"engine-options":we.value,"engine-readonly-message":ce.value,"session-id":r.sessionId,"session-id-copied":B.value,"session-id-readonly-message":X.value,title:r.title,"workspace-suggestions":re.value,onCopySessionId:Ne,onOpenDirectoryPicker:s[9]||(s[9]=y=>G.value=!0),"onUpdate:cwd":Le,"onUpdate:engine":Ee,"onUpdate:sessionId":Fe,"onUpdate:title":De},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","engine-options","engine-readonly-message","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"]),d.value?(p(),f("p",Ja,[S(a(Ve),{class:"h-4 w-4"}),t("span",null,o(d.value),1)])):j("",!0),t("div",Ka,[t("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-sm",disabled:I.value,onClick:Oe},o(ue.value),9,Qa),h.value==="edit"&&b.value?(p(),f("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:I.value||ae.value,onClick:s[10]||(s[10]=y=>E.value=!0)},o(R.value?a(c)("projectManager.resettingSession"):a(c)("projectManager.newSession")),9,Xa)):j("",!0),h.value==="edit"&&b.value?(p(),f("button",{key:1,type:"button",class:"tool-button tool-button-danger-subtle w-full px-3 py-2 text-sm",disabled:I.value||ae.value,onClick:s[11]||(s[11]=y=>C.value=!0)},o(F.value?a(c)("projectManager.deletingProject"):a(c)("projectManager.deleteProject")),9,Ya)):j("",!0)])])):(p(),se(ha,{key:1,"active-session":b.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"is-current-session":te,"is-session-running":z},null,8,["active-session"]))])]))])):(p(),f("div",ya,[t("aside",ba,[S(We,{busy:I.value,"editing-session-id":M.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"has-sessions":Z.value,"is-current-session":te,"is-session-running":z,mode:h.value,sessions:ne.value,onCreate:Y,onSelect:Re},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])]),t("div",wa,[t("div",Sa,[t("div",null,[t("div",ka,[S(a(St),{class:"h-4 w-4"}),t("span",null,o(h.value==="create"?a(c)("projectManager.createTitle"):a(c)("projectManager.editTitle")),1)])])]),t("div",$a,[S(qe,{busy:I.value,"can-edit-engine":h.value!=="edit"||oe.value,"can-edit-cwd":h.value!=="edit"||K.value,"can-edit-session-id":h.value!=="edit"||q.value,cwd:r.cwd,"cwd-readonly-message":Q.value,"duplicate-cwd-message":de.value,engine:r.engine,"engine-options":we.value,"engine-readonly-message":ce.value,"session-id":r.sessionId,"session-id-copied":B.value,"session-id-readonly-message":X.value,title:r.title,"workspace-suggestions":re.value,onCopySessionId:Ne,onOpenDirectoryPicker:s[3]||(s[3]=y=>G.value=!0),"onUpdate:cwd":Le,"onUpdate:engine":Ee,"onUpdate:sessionId":Fe,"onUpdate:title":De},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","engine-options","engine-readonly-message","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"])]),d.value?(p(),f("p",_a,[S(a(Ve),{class:"h-4 w-4"}),t("span",null,o(d.value),1)])):j("",!0),t("div",Ca,[t("div",Ma,[h.value==="edit"&&b.value?(p(),f("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:I.value||ae.value,onClick:s[4]||(s[4]=y=>E.value=!0)},[S(a(kt),{class:"h-4 w-4"}),t("span",null,o(R.value?a(c)("projectManager.resettingSession"):a(c)("projectManager.newSession")),1)],8,ja)):j("",!0),h.value==="edit"&&b.value?(p(),f("button",{key:1,type:"button",class:"tool-button tool-button-danger-subtle inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:I.value||ae.value,onClick:s[5]||(s[5]=y=>C.value=!0)},[S(a($t),{class:"h-4 w-4"}),t("span",null,o(F.value?a(c)("projectManager.deletingProject"):a(c)("projectManager.deleteProject")),1)],8,Ia)):j("",!0)]),t("div",Pa,[t("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:s[6]||(s[6]=y=>k("close"))},o(a(c)("projectManager.close")),9,Ta),h.value==="create"&&Z.value?(p(),f("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:Be},o(a(c)("projectManager.backToList")),9,Ra)):j("",!0),t("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:Oe},o(ue.value),9,Da)])])])]))]}),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"])],64))}};export{is as default};
@@ -1,2 +1,2 @@
1
- import{g as Xe,t as w,f as Ee,u as Re}from"./index-CR3pS7j1.js";import{u as Ye,g as Le,l as Ze,a as et,_ as tt,b as st}from"./WorkbenchView-BdPBiKKe.js";import{w as V,c as T,b as P,n as at,aB as h,aC as p,aD as a,aP as te,aQ as Se,aJ as F,aO as o,aE as S,u as t,aU as De,aV as nt,aL as B,aG as je,aH as ue,f as it,a_ as Ae}from"./vendor-misc-CWjGI0ex.js";import{g as lt,e as Ie,C as Ne,R as Be,b as rt,d as ot,F as qe,h as Ve,x as ze}from"./vendor-ui-D4mCpibF.js";import"./vendor-router-Bcjfmow0.js";import"./vendor-markdown-CNlC48LI.js";import"./vendor-tiptap-BCwG_IWj.js";function Z(e,n,u=""){const d=n==="run"?"run":n==="task"?"task":"workspace";return[String(e||"").trim(),d,String(u||"").trim()].join("::")}function ut(e="",n=""){return`${String(e||"").trim()}::${String(n||"").trim()}`}function dt(e=""){return`${String(e||"").trim()}::`}function Ge(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function we(e,n){const u=e.get(n);return u?(e.delete(n),e.set(n,u),Ge(u)):null}function _e(e,n,u,d=0){for(e.delete(n),e.set(n,Ge(u));d>0&&e.size>d;){const l=e.keys().next().value;if(typeof l>"u")break;e.delete(l)}}function ee(e=""){const n=String(e||"").trim().toUpperCase();return n==="A"||n==="D"?n:"M"}function ct(e=""){const n=String(e||"");if(!n)return[];const u=n.split(`
1
+ import{g as Xe,t as w,f as Ee,u as Re}from"./index-CGOI_HcK.js";import{u as Ye,g as Le,l as Ze,a as et,_ as tt,b as st}from"./WorkbenchView-CMjjT7fc.js";import{w as V,c as T,b as P,n as at,aB as h,aC as p,aD as a,aP as te,aQ as Se,aJ as F,aO as o,aE as S,u as t,aU as De,aV as nt,aL as B,aG as je,aH as ue,f as it,a_ as Ae}from"./vendor-misc-CWjGI0ex.js";import{g as lt,e as Ie,C as Ne,R as Be,b as rt,d as ot,F as qe,h as Ve,x as ze}from"./vendor-ui-D4mCpibF.js";import"./vendor-router-Bcjfmow0.js";import"./vendor-markdown-CNlC48LI.js";import"./vendor-tiptap-BCwG_IWj.js";function Z(e,n,u=""){const d=n==="run"?"run":n==="task"?"task":"workspace";return[String(e||"").trim(),d,String(u||"").trim()].join("::")}function ut(e="",n=""){return`${String(e||"").trim()}::${String(n||"").trim()}`}function dt(e=""){return`${String(e||"").trim()}::`}function Ge(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function we(e,n){const u=e.get(n);return u?(e.delete(n),e.set(n,u),Ge(u)):null}function _e(e,n,u,d=0){for(e.delete(n),e.set(n,Ge(u));d>0&&e.size>d;){const l=e.keys().next().value;if(typeof l>"u")break;e.delete(l)}}function ee(e=""){const n=String(e||"").trim().toUpperCase();return n==="A"||n==="D"?n:"M"}function ct(e=""){const n=String(e||"");if(!n)return[];const u=n.split(`
2
2
  `),d=[];let l=0,x=0;return u.forEach((g,r)=>{const k=g.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(k){l=Number(k[1]),x=Number(k[2]),d.push({id:`hunk-${r}`,kind:"hunk",oldNumber:"",newNumber:"",content:g});return}if(g.startsWith("+")&&!g.startsWith("+++")){d.push({id:`line-${r}`,kind:"add",oldNumber:"",newNumber:x,content:g}),x+=1;return}if(g.startsWith("-")&&!g.startsWith("---")){d.push({id:`line-${r}`,kind:"delete",oldNumber:l,newNumber:"",content:g}),l+=1;return}if(g.startsWith(" ")){d.push({id:`line-${r}`,kind:"context",oldNumber:l,newNumber:x,content:g}),l+=1,x+=1;return}d.push({id:`line-${r}`,kind:"meta",oldNumber:"",newNumber:"",content:g})}),d}function ft(e=""){const n=String(e||"").trim();if(!n)return"";const u=n.match(/^当前分支已从 (.+) 切换到 (.+)$/);return u?w("diffReview.warningBranchChanged",{from:u[1],to:u[2]}):n==="当前 HEAD 已不在基线 commit 的后续历史中,仓库可能经历了 reset、rebase 或切分支"?w("diffReview.warningHeadDetachedFromBaseline"):n}function Oe(e=""){const n=String(e||"").trim();if(!n)return"";const d=new Map([["二进制文件暂不支持在线 diff 预览。","diffReview.binaryPreviewUnavailable"],["文件内容较大,暂不展示具体 diff。","diffReview.fileTooLarge"],["diff 内容较长,暂不在页面内完整展示。","diffReview.diffTooLong"],["当前工作目录不是 Git 仓库,暂不支持代码变更审查。","diffReview.notGitRepo"],["任务不存在。","diffReview.taskNotFound"],["请选择一轮执行后再查看本轮代码变更。","diffReview.runRequired"],["没有找到对应的执行记录。","diffReview.runNotFound"],["这轮执行还没有建立代码变更基线,暂时无法查看本轮 diff。","diffReview.runBaselineMissing"],["当前任务还没有建立代码变更基线,请先让 Codex 执行一轮。","diffReview.taskBaselineMissing"],["这轮执行缺少结束快照,暂时无法准确还原本轮代码变更。","diffReview.runSnapshotMissing"],["原工作目录已不是有效的 Git 仓库,暂时无法读取代码变更。","diffReview.originalRepoInvalid"],["基线对应的 commit 已不存在,仓库可能被 reset、rebase 或切换到无关历史,暂时无法准确读取该范围的代码变更。","diffReview.baselineCommitMissing"]]).get(n);return d?w(d):n}function Te(e=null){return!e||typeof e!="object"?e:{...e,reason:Oe(e.reason),warnings:Array.isArray(e.warnings)?e.warnings.map(n=>ft(n)).filter(Boolean):[],files:Array.isArray(e.files)?e.files.map(n=>({...n,message:Oe(n==null?void 0:n.message)})):[]}}function ht(e){const n=P("workspace"),u=P(""),d=P(""),l=P("all"),x=P(""),g=P([]),r=P(null),k=P(!1),D=P(!1),y=P(""),z=P(!1),re=P(null),se=P(0),O=new Map,E=Ye();let J=0,M=0,j="",_="",A="",H=-1;const U=new Map,K=new Map,ae=new Map,ne=T(()=>g.value.filter(s=>s.completed)),de=T(()=>{var i;const s={all:0,A:0,M:0,D:0};return(((i=r.value)==null?void 0:i.files)||[]).forEach(c=>{const v=ee(c==null?void 0:c.status);s.all+=1,s[v]+=1}),s}),Q=T(()=>{var c;const s=((c=r.value)==null?void 0:c.files)||[],i=String(x.value||"").trim().toLowerCase();return s.filter(v=>l.value!=="all"&&ee(v==null?void 0:v.status)!==l.value?!1:i?String((v==null?void 0:v.path)||"").toLowerCase().includes(i):!0)}),ce=T(()=>{const s=Q.value;return s.find(i=>i.path===d.value)||s[0]||null}),oe=T(()=>{var s;return ct(((s=ce.value)==null?void 0:s.patch)||"")}),I=T(()=>oe.value.map((s,i)=>({...s,index:i})).filter(s=>s.kind==="hunk")),fe=T(()=>{var s,i;return D.value&&!((i=(s=r.value)==null?void 0:s.summary)!=null&&i.statsComplete)}),X=T(()=>{var c;const s=((c=r.value)==null?void 0:c.baseline)||null;if(!(s!=null&&s.createdAt)&&!(s!=null&&s.headShort))return"";const i=[];return s.createdAt&&i.push(w("diffReview.baselineTime",{value:Ee(s.createdAt)})),s.branch&&i.push(w("diffReview.baselineBranch",{value:s.branch})),s.headShort&&i.push(w("diffReview.baselineCommit",{value:s.headShort})),s.currentHeadShort&&i.push(w("diffReview.currentHead",{value:s.currentHeadShort})),i.join(" · ")});function L(s){return(s==null?void 0:s.status)==="completed"?w("diffReview.completed"):(s==null?void 0:s.status)==="error"?w("diffReview.failed"):(s==null?void 0:s.status)==="interrupted"?w("diffReview.interrupted"):w("diffReview.stopped")}function b(s,i){if(s){if(i){O.set(s,i);return}O.delete(s)}}function he(s,i={}){const c=I.value;if(!c.length)return;const v=Math.min(Math.max(0,Number(s)||0),c.length-1),$=c[v],R=O.get($.id);R&&(se.value=v,R.scrollIntoView({block:i.block||"center",behavior:i.behavior||"smooth"}))}function me(s=1){I.value.length&&he(se.value+s)}function N(s){return`${new Date((s==null?void 0:s.startedAt)||(s==null?void 0:s.createdAt)).toLocaleString(Xe())} · ${L(s)}`}function f(){const s=ne.value;if(!s.length){u.value="";return}s.some(i=>i.id===u.value)||(u.value=s[0].id)}function Y(){const s=Q.value;if(!s.length){d.value="";return}s.some(i=>i.path===d.value)||(d.value=s[0].path)}function ve(s=""){return ee(s)==="A"?w("diffReview.added"):ee(s)==="D"?w("diffReview.deleted"):w("diffReview.modified")}function pe(s=""){return ee(s)==="A"?"theme-status-success":ee(s)==="D"?"theme-status-danger":"theme-status-warning"}function ge(s="all"){return s==="A"?w("diffReview.added"):s==="D"?w("diffReview.deleted"):s==="M"?w("diffReview.modified"):w("diffReview.all")}function xe(s="all"){return l.value===s?"theme-filter-active":"theme-filter-idle"}function m(s="context"){return s==="add"?"theme-patch-add":s==="delete"?"theme-patch-delete":s==="hunk"?"theme-patch-hunk":s==="meta"?"theme-patch-meta":"theme-patch-context"}function ie(s,i=""){const c=String(i||"").trim();c&&Array.from(s.keys()).forEach(v=>{String(v||"").startsWith(c)&&s.delete(v)})}function Ce(){const s=dt(e.taskSlug);ie(U,s),ie(K,s),ie(ae,s)}async function Je(){if(!e.taskSlug){g.value=[],u.value="",A="",H=-1;return}const s=E.getTaskRunSyncVersion(e.taskSlug);if(A===e.taskSlug&&H===s)return;const i=await Ze(e.taskSlug,{limit:20,events:"none"});g.value=i.items||[],A=e.taskSlug,H=s,f()}async function Fe(){if(!e.taskSlug||!e.active)return;const s=++J;k.value=!0,D.value=!1,y.value="";try{const i=n.value==="run"?"run":n.value==="task"?"task":"workspace";i==="run"&&await Je();const c=Z(e.taskSlug,i,i==="run"?u.value:"");if(i==="run"&&!u.value){r.value={supported:!1,reason:w("diffReview.noReviewRuns"),repoRoot:"",summary:{fileCount:0,additions:0,deletions:0,statsComplete:!0},files:[]},Y();return}const v=we(U,c);if(v){r.value=v,j=c;const C=we(K,c);C?(r.value={...v,baseline:C.baseline||v.baseline||null,warnings:C.warnings||v.warnings||[],summary:C.summary||v.summary},_=c):_="",Y(),ye().catch(()=>{}),C||He().catch(()=>{});return}const $=await Le(e.taskSlug,{scope:i,runId:i==="run"?u.value:"",includeStats:!1});if(s!==J)return;const R=Te($);r.value=R,_e(U,c,R,36),j=c,_="",Y(),ye().catch(()=>{}),He().catch(()=>{})}catch(i){if(s!==J)return;y.value=i.message,r.value=null}finally{s===J&&(k.value=!1)}}async function He(){var $,R,C;if(!e.taskSlug||!e.active||!(($=r.value)!=null&&$.supported))return;const s=n.value==="run"?"run":n.value==="task"?"task":"workspace",i=s==="run"?u.value:"",c=Z(e.taskSlug,s,i);if(_===c&&((C=(R=r.value)==null?void 0:R.summary)!=null&&C.statsComplete))return;const v=we(K,c);if(v){r.value={...r.value,baseline:v.baseline||r.value.baseline||null,warnings:v.warnings||r.value.warnings||[],summary:v.summary||r.value.summary},_=c,D.value=!1;return}D.value=!0;try{const q=await Le(e.taskSlug,{scope:s,runId:i,includeFiles:!1,includeStats:!0}),le=Z(e.taskSlug,n.value,n.value==="run"?u.value:"");if(c!==le||!r.value)return;const W=Te(q);r.value={...r.value,baseline:W.baseline||r.value.baseline||null,warnings:W.warnings||r.value.warnings||[],summary:W.summary||r.value.summary},_e(K,c,{baseline:W.baseline||null,warnings:W.warnings||[],summary:W.summary||null},36),_=c}catch{}finally{const q=Z(e.taskSlug,n.value,n.value==="run"?u.value:"");c===q&&(D.value=!1)}}async function ye(){var le,W,Me;const s=String(d.value||"").trim();if(!e.taskSlug||!e.active||!s||z.value)return;const i=n.value==="run"?"run":n.value==="task"?"task":"workspace",c=i==="run"?u.value:"",v=Z(e.taskSlug,i,c),$=(((le=r.value)==null?void 0:le.files)||[]).find(G=>G.path===s);if(!$||$.patchLoaded||$.binary||$.tooLarge||$.message)return;const R=ut(v,s),C=we(ae,R);if(C&&((W=r.value)!=null&&W.files)){r.value={...r.value,files:r.value.files.map(G=>G.path===s?C:G)};return}const q=++M;z.value=!0;try{const G=await Le(e.taskSlug,{scope:i,runId:c,filePath:s});if(q!==M)return;const Qe=Z(e.taskSlug,n.value,n.value==="run"?u.value:"");if(v!==Qe)return;const $e=Te(G),Pe=($e.files||[]).find(ke=>ke.path===s);if(!Pe||!((Me=r.value)!=null&&Me.files))return;_e(ae,R,Pe,120),r.value={...r.value,baseline:$e.baseline||r.value.baseline||null,warnings:$e.warnings||r.value.warnings||[],files:r.value.files.map(ke=>ke.path===s?Pe:ke)}}catch(G){y.value=G.message}finally{q===M&&(z.value=!1,String(d.value||"").trim()!==s&&ye().catch(()=>{}))}}function be({force:s=!1}={}){if(!e.taskSlug||!e.active)return;const i=Z(e.taskSlug,n.value,n.value==="run"?u.value:"");!s&&i===j||Fe().catch(()=>{})}async function Ke(){!e.taskSlug||!e.active||k.value||(Ce(),j="",_="",A="",H=-1,await Fe())}return V(()=>[e.taskSlug,e.active,n.value,u.value],([s,i],c=[])=>{const v=c[0]||"";s!==v&&(d.value="",j="",g.value=[],u.value="",A="",H=-1,_=""),!(!s||!i)&&be()},{immediate:!0}),V(()=>{var s,i;return[l.value,((i=(s=r.value)==null?void 0:s.files)==null?void 0:i.length)||0]},()=>{Y()}),V(()=>[d.value,I.value.length],()=>{se.value=0,O.clear(),at(()=>{var s,i;I.value.length?he(0,{behavior:"auto",block:"start"}):(i=(s=re.value)==null?void 0:s.scrollTo)==null||i.call(s,{top:0,behavior:"auto"})})}),V(()=>d.value,()=>{ye().catch(()=>{})},{immediate:!0}),V(()=>[e.preferredScope,e.preferredRunId,e.focusToken],([s,i,c],v=[])=>{const $=Number(v[2]||0),R=s==="run"?"run":s==="task"?"task":"workspace",C=R==="run"&&i?String(i||""):"",q=n.value!==R,le=R==="run"&&C&&u.value!==C;n.value=R,C&&(u.value=C),R!=="run"&&(u.value=""),!q&&!le&&e.active&&e.taskSlug&&c!==$&&(j="",be())},{immediate:!0}),V(()=>E.readyVersion.value,()=>{!e.active||!e.taskSlug||(A="",H=-1,j="",_="",be({force:!0}))}),V(()=>E.getTaskDiffSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||(A="",H=-1,_="",j="",be({force:!0}))}),{activeHunkIndex:se,baselineMetaText:X,diffPayload:r,diffScope:n,error:y,fileSearch:x,filteredFiles:Q,getFilterButtonClass:xe,getFilterLabel:ge,getPatchLineClass:m,getRunStatusLabel:L,getStatusClass:pe,getStatusLabel:ve,jumpToAdjacentHunk:me,loadDiff:Fe,loading:k,normalizeFileStatus:ee,patchLoading:z,patchViewportRef:re,runs:g,selectedFile:ce,selectedFilePath:d,selectedPatchHunks:I,selectedPatchLines:oe,selectedRunId:u,setPatchLineRef:b,showSummarySkeleton:fe,statsLoading:D,statusCounts:de,statusFilter:l,terminalRuns:ne,formatRunOptionLabel:N,refreshDiff:Ke}}const mt={class:"mb-3 grid grid-cols-2 gap-2"},vt=["onClick"],pt={class:"theme-input-shell mb-3 flex items-center gap-2 rounded-sm border px-3 py-2 text-xs text-[var(--theme-textMuted)]"},gt=["placeholder"],xt={key:0,class:"theme-empty-state theme-empty-state-strong mb-3 px-3 py-2 text-[11px]"},yt={key:1,class:"theme-empty-state px-3 py-4 text-xs"},bt={key:2,class:"theme-empty-state px-3 py-4 text-xs"},kt={key:3,class:"space-y-2"},wt=["onClick"],St={class:"flex items-start gap-2"},Rt={class:"min-w-0 flex-1"},Ct={class:"break-all text-xs font-medium"},Ft={class:"mt-1 text-[11px] opacity-75"},Ue={__name:"TaskDiffFileList",props:{diffPayload:{type:Object,default:null},fileSearch:{type:String,default:""},filteredFiles:{type:Array,default:()=>[]},getFilterButtonClass:{type:Function,default:()=>""},getFilterLabel:{type:Function,default:e=>e},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},selectedFilePath:{type:String,default:""},showSummarySkeleton:{type:Boolean,default:!1},statusCounts:{type:Object,default:()=>({})},statusFilter:{type:String,default:"all"}},emits:["select-file","update:fileSearch","update:statusFilter"],setup(e,{emit:n}){const u=e,d=n,{t:l}=Re(),x=T({get:()=>u.fileSearch,set:k=>d("update:fileSearch",k)}),g=T({get:()=>u.statusFilter,set:k=>d("update:statusFilter",k)}),r=T(()=>{var k;return Array.isArray((k=u.diffPayload)==null?void 0:k.files)&&u.diffPayload.files.length>0});return(k,D)=>(h(),p(te,null,[a("div",mt,[(h(),p(te,null,Se(["all","A","M","D"],y=>a("button",{key:y,type:"button",class:F(["inline-flex w-full items-center justify-center gap-1 whitespace-nowrap rounded-sm border px-2 py-1 text-[11px] transition",e.getFilterButtonClass(y)]),onClick:z=>g.value=y},o(e.getFilterLabel(y))+" "+o(e.statusCounts[y]||0),11,vt)),64))]),a("label",pt,[S(t(lt),{class:"h-3.5 w-3.5 shrink-0"}),De(a("input",{"onUpdate:modelValue":D[0]||(D[0]=y=>x.value=y),type:"text",placeholder:t(l)("diffReview.searchFilePath"),class:"min-w-0 flex-1 bg-transparent text-xs text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]"},null,8,gt),[[nt,x.value]])]),e.showSummarySkeleton?(h(),p("div",xt,o(t(l)("diffReview.statsPending")),1)):B("",!0),r.value?e.filteredFiles.length?(h(),p("div",kt,[(h(!0),p(te,null,Se(e.filteredFiles,y=>(h(),p("button",{key:y.path,type:"button",class:F(["w-full rounded-sm border px-3 py-2 text-left transition",y.path===e.selectedFilePath?"theme-filter-active":"theme-filter-idle"]),onClick:z=>d("select-file",y.path)},[a("div",St,[a("span",{class:F(["inline-flex shrink-0 rounded-sm border px-1.5 py-0.5 text-[10px]",e.getStatusClass(y.status)])},o(e.getStatusLabel(y.status)),3),a("div",Rt,[a("div",Ct,o(y.path),1),a("div",Ft,o(y.statsLoaded?`+${y.additions} / -${y.deletions}`:t(l)("diffReview.statsOnDemand")),1)])])],10,wt))),128))])):(h(),p("div",bt,o(t(l)("diffReview.noMatches")),1)):(h(),p("div",yt,o(t(l)("diffReview.noChanges")),1))],64))}},$t={key:0,class:"flex h-full min-h-0 flex-col overflow-hidden"},Pt={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-xs"},Lt={class:"space-y-3 sm:hidden"},_t={class:"flex items-start gap-2"},Tt={class:"min-w-0 break-all font-medium text-[var(--theme-textPrimary)]"},Dt={class:"flex items-center justify-between gap-3"},jt={class:"opacity-75"},Ht=["disabled"],Mt={class:"min-w-[64px] text-center text-[11px] text-[var(--theme-textSecondary)]"},At=["disabled"],It={class:"hidden items-center gap-3 sm:flex"},Nt={class:"flex min-w-0 flex-1 flex-wrap items-center gap-2"},Bt={class:"break-all font-medium text-[var(--theme-textPrimary)]"},Vt={class:"opacity-75"},zt=["disabled"],Ot={class:"min-w-[64px] text-center text-[11px] text-[var(--theme-textSecondary)]"},Ut=["disabled"],Wt={key:0,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-sm"},Et={class:"theme-empty-state px-4 py-4"},qt={key:1,class:"theme-muted-text flex-1 overflow-y-auto px-4 py-4 text-sm"},Gt={class:"min-w-max px-4 py-4 font-mono text-[11px] leading-5"},Jt={class:"select-none border-r border-[var(--theme-borderMuted)] px-2 py-0.5 text-right opacity-60"},Kt={class:"select-none border-r border-[var(--theme-borderMuted)] px-2 py-0.5 text-right opacity-60"},Qt={class:"overflow-visible whitespace-pre px-3 py-0.5"},Xt={key:3,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-sm"},Yt={class:"theme-empty-state px-4 py-4"},Zt={key:1,class:"theme-muted-text flex h-full items-center justify-center px-5 text-sm"},We={__name:"TaskDiffPatchView",props:{activeHunkIndex:{type:Number,default:0},getPatchLineClass:{type:Function,default:()=>""},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},jumpToAdjacentHunk:{type:Function,default:()=>{}},patchLoading:{type:Boolean,default:!1},selectedFile:{type:Object,default:null},selectedPatchHunks:{type:Array,default:()=>[]},selectedPatchLines:{type:Array,default:()=>[]},setPatchLineRef:{type:Function,default:()=>{}},setPatchViewportRef:{type:Function,default:()=>{}}},setup(e){const{t:n}=Re();return(u,d)=>e.selectedFile?(h(),p("div",$t,[a("div",Pt,[a("div",Lt,[a("div",_t,[a("span",{class:F(["inline-flex shrink-0 rounded-sm border px-1.5 py-0.5 text-[10px]",e.getStatusClass(e.selectedFile.status)])},o(e.getStatusLabel(e.selectedFile.status)),3),a("span",Tt,o(e.selectedFile.path),1)]),a("div",Dt,[a("span",jt,o(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(n)("diffReview.statsOnDemand")),1),a("div",{class:F(["inline-flex h-8 shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:d[0]||(d[0]=l=>e.jumpToAdjacentHunk(-1))},[S(t(Ie),{class:"h-4 w-4"})],8,Ht),a("span",Mt,o(t(n)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:d[1]||(d[1]=l=>e.jumpToAdjacentHunk(1))},[S(t(Ne),{class:"h-4 w-4"})],8,At)],2)])]),a("div",It,[a("div",Nt,[a("span",{class:F(["inline-flex rounded-sm border px-1.5 py-0.5 text-[10px]",e.getStatusClass(e.selectedFile.status)])},o(e.getStatusLabel(e.selectedFile.status)),3),a("span",Bt,o(e.selectedFile.path),1),a("span",Vt,o(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(n)("diffReview.statsOnDemand")),1)]),a("div",{class:F(["inline-flex h-8 w-[132px] shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:d[2]||(d[2]=l=>e.jumpToAdjacentHunk(-1))},[S(t(Ie),{class:"h-4 w-4"})],8,zt),a("span",Ot,o(t(n)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:d[3]||(d[3]=l=>e.jumpToAdjacentHunk(1))},[S(t(Ne),{class:"h-4 w-4"})],8,Ut)],2)])]),e.selectedFile.message?(h(),p("div",Wt,[a("div",Et,o(e.selectedFile.message),1)])):e.patchLoading&&!e.selectedFile.patchLoaded?(h(),p("div",qt,o(t(n)("diffReview.loadingFileDiff")),1)):e.selectedPatchLines.length?(h(),p("div",{key:2,ref:e.setPatchViewportRef,class:"flex-1 overflow-auto"},[a("div",Gt,[(h(!0),p(te,null,Se(e.selectedPatchLines,l=>{var x;return h(),p("div",{key:l.id,ref_for:!0,ref:g=>e.setPatchLineRef(l.id,g),class:F(["grid grid-cols-[56px_56px_minmax(0,1fr)]",[e.getPatchLineClass(l.kind),l.kind==="hunk"&&((x=e.selectedPatchHunks[e.activeHunkIndex])==null?void 0:x.id)===l.id?"ring-1 ring-inset ring-[var(--theme-warning)]":""]])},[a("span",Jt,o(l.oldNumber),1),a("span",Kt,o(l.newNumber),1),a("pre",Qt,o(l.content),1)],2)}),128))])],512)):(h(),p("div",Xt,[a("div",Yt,o(t(n)("diffReview.noFileDiffContent")),1)]))])):(h(),p("div",Zt,o(t(n)("diffReview.selectFile")),1))}},es={class:"panel flex h-full min-h-0 flex-col overflow-hidden"},ts={class:"theme-divider border-b px-4 py-3"},ss={class:"flex flex-col gap-2"},as={class:"grid grid-cols-4 gap-2 sm:flex sm:flex-wrap sm:items-center"},ns={class:"sm:hidden"},is={class:"hidden sm:inline"},ls={class:"sm:hidden"},rs={class:"hidden sm:inline"},os=["disabled"],us={class:"sm:hidden"},ds={class:"hidden sm:inline"},cs={class:"truncate text-xs text-[var(--theme-textPrimary)]"},fs={class:"theme-divider theme-muted-text border-b border-dashed px-3 py-2 text-[11px]"},hs=["onClick"],ms={class:"flex items-start gap-3"},vs={class:"min-w-0 flex-1"},ps={class:"truncate text-xs font-medium text-[var(--theme-textPrimary)]"},gs={class:"theme-muted-text mt-1 text-[11px]"},xs={key:0,class:"theme-divider theme-danger-text border-b px-4 py-3 text-sm"},ys={class:"inline-flex items-start gap-2"},bs={class:"break-all"},ks={key:1,class:"theme-muted-text flex flex-1 items-center justify-center px-5 text-sm"},ws={key:2,class:"flex flex-1 items-center justify-center px-5"},Ss={class:"theme-empty-state w-full max-w-xl px-4 py-5 text-sm text-[var(--theme-textSecondary)]"},Rs={class:"theme-heading inline-flex items-center gap-2 font-medium"},Cs={class:"mt-2 break-all leading-7"},Fs={key:0,class:"mt-3 flex flex-wrap gap-2 text-xs"},$s={class:"theme-status-neutral inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},Ps={class:"break-all"},Ls={key:0,class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},_s={key:3,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ts={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-xs"},Ds={class:"flex flex-wrap items-center gap-2"},js={key:0,class:"theme-status-info inline-flex min-w-0 items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},Hs={class:"min-w-0 break-all"},Ms={class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},As={class:"text-[var(--theme-textPrimary)]"},Is={class:"font-medium text-[var(--theme-success)]"},Ns={class:"font-medium text-[var(--theme-danger)]"},Bs={key:2,class:"opacity-75"},Vs={key:0,class:"mt-2 break-all text-[11px] opacity-75"},zs={key:1,class:"mt-2 flex flex-col gap-1"},Os={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Us={class:"theme-divider border-b px-3 py-3"},Ws={class:"grid grid-cols-2 gap-2"},Es=["disabled"],qs={class:"theme-divider theme-muted-panel min-h-0 flex-1 overflow-y-auto p-3"},Gs={class:"min-h-0 flex-1 overflow-hidden bg-[var(--theme-appPanelStrong)]"},Js={key:1,class:"grid min-h-0 flex-1 grid-cols-[320px_minmax(0,1fr)] overflow-hidden"},Ks={class:"theme-divider theme-muted-panel min-h-0 overflow-y-auto border-r p-3"},Qs={class:"min-h-0 overflow-hidden bg-[var(--theme-appPanelStrong)]"},Xs={__name:"TaskDiffReviewPanel",props:{taskSlug:{type:String,default:""},preferredScope:{type:String,default:"workspace"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0},active:{type:Boolean,default:!1}},setup(e){const n=e,{activeHunkIndex:u,baselineMetaText:d,diffPayload:l,diffScope:x,error:g,fileSearch:r,filteredFiles:k,formatRunOptionLabel:D,getFilterButtonClass:y,getFilterLabel:z,getPatchLineClass:re,getRunStatusLabel:se,getStatusClass:O,getStatusLabel:E,jumpToAdjacentHunk:J,loading:M,patchLoading:j,patchViewportRef:_,refreshDiff:A,selectedFile:H,selectedFilePath:U,selectedPatchHunks:K,selectedPatchLines:ae,selectedRunId:ne,setPatchLineRef:de,showSummarySkeleton:Q,statsLoading:ce,statusCounts:oe,statusFilter:I,terminalRuns:fe}=ht(n),{matches:X}=et("(max-width: 767px)"),L=P("files"),{t:b}=Re();function he(N){U.value=N,X.value&&(L.value="patch")}function me(N){_.value=N||null}return V(X,N=>{N||(L.value="files")},{immediate:!0}),V(U,N=>{!N&&X.value&&(L.value="files")}),V(x,()=>{X.value&&(L.value="files")}),(N,f)=>{var Y,ve,pe,ge,xe;return h(),p("section",es,[a("div",ts,[a("div",ss,[a("div",as,[a("button",{type:"button",class:F(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(x)==="workspace"?"theme-filter-active":""]),onClick:f[0]||(f[0]=m=>x.value="workspace")},[a("span",ns,o(t(b)("diffReview.scopeCurrentShort")),1),a("span",is,o(t(b)("diffReview.scopeCurrent")),1)],2),a("button",{type:"button",class:F(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(x)==="task"?"theme-filter-active":""]),onClick:f[1]||(f[1]=m=>x.value="task")},[a("span",ls,o(t(b)("diffReview.scopeTaskShort")),1),a("span",rs,o(t(b)("diffReview.scopeTask")),1)],2),a("button",{type:"button",class:F(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(x)==="run"?"theme-filter-active":""]),onClick:f[2]||(f[2]=m=>x.value="run")},[a("span",null,o(t(b)("diffReview.scopeRun")),1)],2),a("button",{type:"button",class:"tool-button tool-button-info-subtle inline-flex shrink-0 items-center justify-center gap-2 px-3 py-2 text-xs",disabled:t(M),onClick:f[3]||(f[3]=(...m)=>t(A)&&t(A)(...m))},[S(t(Be),{class:F(["h-3.5 w-3.5 sm:hidden",t(M)?"animate-spin":""])},null,8,["class"]),a("span",us,o(t(b)("diffReview.refresh")),1),S(t(Be),{class:F(["hidden h-3.5 w-3.5 sm:inline-block",t(M)?"animate-spin":""])},null,8,["class"]),a("span",ds,o(t(M)?t(b)("diffReview.refreshing"):t(ce)?t(b)("diffReview.computing"):t(b)("diffReview.refresh")),1)],8,os)]),t(x)==="run"?(h(),je(tt,{key:0,modelValue:t(ne),"onUpdate:modelValue":f[4]||(f[4]=m=>it(ne)?ne.value=m:null),class:"min-w-0 sm:max-w-[360px]",options:t(fe),loading:t(M),"get-option-value":m=>(m==null?void 0:m.id)||"",placeholder:t(b)("diffReview.selectRun"),"empty-text":t(b)("diffReview.noRuns")},{trigger:ue(({selectedOption:m})=>[a("div",cs,o(m?t(D)(m):t(b)("diffReview.selectRun")),1)]),header:ue(()=>[a("div",fs,o(t(b)("diffReview.runCount",{count:t(fe).length})),1)]),option:ue(({option:m,selected:ie,select:Ce})=>[a("button",{type:"button",class:F(["w-full rounded-sm border border-dashed px-3 py-2 text-left transition",ie?"theme-filter-active":"theme-filter-idle"]),onClick:Ce},[a("div",ms,[a("div",vs,[a("div",ps,o(t(Ee)(m.startedAt||m.createdAt)),1),a("div",gs,o(t(se)(m)),1)]),ie?(h(),je(t(rt),{key:0,class:"mt-0.5 h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):B("",!0)])],10,hs)]),_:1},8,["modelValue","options","loading","get-option-value","placeholder","empty-text"])):B("",!0)])]),t(g)?(h(),p("div",xs,[a("div",ys,[S(t(ot),{class:"mt-0.5 h-4 w-4 shrink-0"}),a("span",bs,o(t(g)),1)])])):B("",!0),t(M)&&!t(l)?(h(),p("div",ks,o(t(b)("diffReview.loading")),1)):t(l)&&!t(l).supported?(h(),p("div",ws,[a("div",Ss,[a("div",Rs,[S(t(qe),{class:"h-4 w-4"}),a("span",null,o(t(b)("diffReview.unavailableTitle")),1)]),a("p",Cs,o(t(l).reason||t(b)("diffReview.unavailableReason")),1),t(l).repoRoot?(h(),p("div",Fs,[a("div",$s,[S(t(Ve),{class:"h-3.5 w-3.5 shrink-0"}),a("span",Ps,o(t(l).repoRoot),1)]),t(l).branch?(h(),p("div",Ls,[S(t(ze),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,o(t(l).branch),1)])):B("",!0)])):B("",!0)])])):t(l)?(h(),p("div",_s,[a("div",Ts,[a("div",Ds,[t(l).repoRoot?(h(),p("div",js,[S(t(Ve),{class:"h-3.5 w-3.5 shrink-0"}),a("span",Hs,o(t(l).repoRoot),1)])):B("",!0),a("div",Ms,[S(t(ze),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,o(t(l).branch||t(b)("diffReview.unknownBranch")),1),f[16]||(f[16]=a("span",{class:"opacity-50"},"•",-1)),a("span",As,o(t(b)("diffReview.fileCount",{count:((Y=t(l).summary)==null?void 0:Y.fileCount)||0})),1),(ve=t(l).summary)!=null&&ve.statsComplete?(h(),p(te,{key:0},[f[12]||(f[12]=a("span",{class:"opacity-50"},"•",-1)),a("span",Is,"+"+o(((pe=t(l).summary)==null?void 0:pe.additions)||0),1),a("span",Ns,"-"+o(((ge=t(l).summary)==null?void 0:ge.deletions)||0),1)],64)):t(Q)?(h(),p(te,{key:1},[f[13]||(f[13]=a("span",{class:"opacity-50"},"•",-1)),f[14]||(f[14]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-successSoft)]"},null,-1)),f[15]||(f[15]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-dangerSoft)]"},null,-1))],64)):(h(),p("span",Bs,o(t(b)("diffReview.waitingStats")),1))])]),t(d)?(h(),p("p",Vs,o(t(d)),1)):B("",!0),(xe=t(l).warnings)!=null&&xe.length?(h(),p("div",zs,[(h(!0),p(te,null,Se(t(l).warnings,m=>(h(),p("p",{key:m,class:"text-[11px] text-[var(--theme-warningText)]"},o(m),1))),128))])):B("",!0)]),t(X)?(h(),p("div",Os,[a("div",Us,[a("div",Ws,[a("button",{type:"button",class:F(["tool-button px-3 py-2 text-sm",L.value==="files"?"tool-button-accent-subtle":""]),onClick:f[5]||(f[5]=m=>L.value="files")},o(t(b)("diffReview.filesTab")),3),a("button",{type:"button",class:F(["tool-button px-3 py-2 text-sm",L.value==="patch"?"tool-button-accent-subtle":""]),disabled:!t(H),onClick:f[6]||(f[6]=m=>L.value="patch")},o(t(b)("diffReview.diffTab")),11,Es)])]),De(a("div",qs,[S(Ue,{"diff-payload":t(l),"file-search":t(r),"filtered-files":t(k),"get-filter-button-class":t(y),"get-filter-label":t(z),"get-status-class":t(O),"get-status-label":t(E),"selected-file-path":t(U),"show-summary-skeleton":t(Q),"status-counts":t(oe),"status-filter":t(I),"onUpdate:fileSearch":f[7]||(f[7]=m=>r.value=m),"onUpdate:statusFilter":f[8]||(f[8]=m=>I.value=m),onSelectFile:he},null,8,["diff-payload","file-search","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])],512),[[Ae,L.value==="files"]]),De(a("div",Gs,[S(We,{"active-hunk-index":t(u),"get-patch-line-class":t(re),"get-status-class":t(O),"get-status-label":t(E),"jump-to-adjacent-hunk":t(J),"patch-loading":t(j),"selected-file":t(H),"selected-patch-hunks":t(K),"selected-patch-lines":t(ae),"set-patch-line-ref":t(de),"set-patch-viewport-ref":me},null,8,["active-hunk-index","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])],512),[[Ae,L.value==="patch"]])])):(h(),p("div",Js,[a("div",Ks,[S(Ue,{"diff-payload":t(l),"file-search":t(r),"filtered-files":t(k),"get-filter-button-class":t(y),"get-filter-label":t(z),"get-status-class":t(O),"get-status-label":t(E),"selected-file-path":t(U),"show-summary-skeleton":t(Q),"status-counts":t(oe),"status-filter":t(I),"onUpdate:fileSearch":f[9]||(f[9]=m=>r.value=m),"onUpdate:statusFilter":f[10]||(f[10]=m=>I.value=m),onSelectFile:f[11]||(f[11]=m=>U.value=m)},null,8,["diff-payload","file-search","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])]),a("div",Qs,[S(We,{"active-hunk-index":t(u),"get-patch-line-class":t(re),"get-status-class":t(O),"get-status-label":t(E),"jump-to-adjacent-hunk":t(J),"patch-loading":t(j),"selected-file":t(H),"selected-patch-hunks":t(K),"selected-patch-lines":t(ae),"set-patch-line-ref":t(de),"set-patch-viewport-ref":me},null,8,["active-hunk-index","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])])]))])):B("",!0)])}}},Ys={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},la={__name:"TaskDiffReviewDialog",props:{open:{type:Boolean,default:!1},taskSlug:{type:String,default:""},taskTitle:{type:String,default:""},preferredScope:{type:String,default:"task"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0}},emits:["close"],setup(e,{emit:n}){const u=e,d=n,{t:l}=Re(),x=T(()=>{const g=String(u.taskTitle||"").trim();return g?l("diffReview.dialogTitleWithTask",{title:g}):l("diffReview.dialogTitle")});return(g,r)=>(h(),je(st,{open:e.open,"panel-class":"settings-dialog-panel h-full sm:h-[min(90vh,960px)] sm:max-w-[min(96vw,1560px)]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex-1 overflow-hidden p-3 sm:p-4",onClose:r[0]||(r[0]=k=>d("close"))},{title:ue(()=>[a("div",Ys,[S(t(qe),{class:"h-4 w-4"}),a("span",null,o(x.value),1)])]),default:ue(()=>[S(Xs,{"task-slug":e.taskSlug,active:e.open,"preferred-scope":e.preferredScope,"preferred-run-id":e.preferredRunId,"focus-token":e.focusToken},null,8,["task-slug","active","preferred-scope","preferred-run-id","focus-token"])]),_:1},8,["open"]))}};export{la as default};