@muyichengshayu/promptx 0.2.10 → 0.2.12

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,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.12
4
+
5
+ - 修复全局 npm 安装后 `promptx start` 启动失败的问题:server / runner 运行时代码不再通过 workspace 裸包名加载 `@promptx/shared`,改为使用发布包内可解析的相对路径,避免 `ERR_MODULE_NOT_FOUND`。
6
+ - 发布前检查新增运行时 import 扫描,防止 server / runner 再次引入只在 workspace 内可解析的内部包名;同时从发布包中排除 shared 测试文件。
7
+
8
+ ## 0.2.11
9
+
10
+ - 优化任务文件更改数的刷新策略:Agent turn 进入终态后延迟 800ms 自动刷新对应任务的 workspace diff summary,避免每次全量查询所有任务;多任务同时结束时合并为一次请求,降低后端 git diff 计算开销。
11
+ - 优化 Windows 目录选择器根节点展示:空路径请求时返回 home 目录 + 可用盘符(C 盘 / D 盘等)作为快捷入口;前端解除 homePath 导航边界限制,允许自由退到任意父目录;修复 `parentPath` 始终为空字符串的问题。
12
+ - 新增按日期分割的后台服务日志:server、runner、relay 的日志统一写入 `runtime/logs/` 目录,文件名按天切分(`server-YYYY-MM-DD.log`),支持 14 天自动清理;降级为未配置日志目录时继续使用控制台输出。
13
+ - WeChat Light 主题对比度微调:`appPanelMuted`、`borderDefault`、`borderMuted`、`textMuted` 色值调深,提升文字与边界的可读性;去掉 reasoning 区块的左侧边框线,让过程日志更紧凑。
14
+ - 修复运行计时首次出现时未触发自动滚动的问题:`sendingElapsedSeconds` 从零变为正数时补发一次 `scheduleScrollToBottom`,确保“耗时 X 秒”文案出现时视图跟随到底部。
15
+
3
16
  ## 0.2.10
4
17
 
5
18
  - 修复 Claude Code 结果完成时偶发卡死的问题:当 Claude CLI 在 result 事件后延迟退出时,runner 会进入优雅退出等待,避免强制 kill 导致消息丢失。
@@ -3,8 +3,9 @@ import cors from '@fastify/cors'
3
3
  import { createRunManager } from './runManager.js'
4
4
  import { assertInternalRequest } from './internalAuth.js'
5
5
  import { createServerClient } from './serverClient.js'
6
+ import { createFastifyLoggerOptions } from '../../../packages/shared/src/dailyLogStream.js'
6
7
 
7
- const app = Fastify({ logger: true })
8
+ const app = Fastify({ logger: createFastifyLoggerOptions({ logName: 'runner' }) })
8
9
  const port = Math.max(1, Number(process.env.PROMPTX_RUNNER_PORT || process.env.RUNNER_PORT || 3002))
9
10
  const host = process.env.PROMPTX_RUNNER_HOST || process.env.HOST || '127.0.0.1'
10
11
 
@@ -87,9 +87,10 @@ import { registerAssetRoutes } from './assetRoutes.js'
87
87
  import { getApiErrorPayload } from './apiErrors.js'
88
88
  import { registerWebAppRoutes } from './webAppRoutes.js'
89
89
  import { createTempFilePath, normalizeUploadFileName } from './upload.js'
90
- import { importPdfBlocks } from './pdf.js'
91
-
92
- const app = Fastify({ logger: true })
90
+ import { importPdfBlocks } from './pdf.js'
91
+ import { createFastifyLoggerOptions } from '../../../packages/shared/src/dailyLogStream.js'
92
+
93
+ const app = Fastify({ logger: createFastifyLoggerOptions({ logName: 'server' }) })
93
94
  const port = Number(process.env.PORT || 3000)
94
95
  const host = process.env.HOST || '127.0.0.1'
95
96
  const { tmpDir, uploadsDir } = ensurePromptxStorageReady()
@@ -367,6 +368,7 @@ registerRealtimeRoutes(app, {
367
368
 
368
369
  const taskWorkspaceDiffSummaryService = createTaskWorkspaceDiffSummaryService({
369
370
  getPromptxCodexSessionById,
371
+ getTaskBySlug,
370
372
  getWorkspaceGitDiffStatusSummaryByCwd,
371
373
  listTasks,
372
374
  })
@@ -115,6 +115,7 @@ function toWorkspaceDiffSummary(payload = null) {
115
115
  function createTaskWorkspaceDiffSummaryService(options = {}) {
116
116
  const getPromptxCodexSessionById = options.getPromptxCodexSessionById || (() => null)
117
117
  const getWorkspaceGitDiffStatusSummaryByCwd = options.getWorkspaceGitDiffStatusSummaryByCwd || (() => null)
118
+ const getTaskBySlug = options.getTaskBySlug || (() => null)
118
119
  const listTasks = options.listTasks || (() => [])
119
120
 
120
121
  function attachTaskWorkspaceDiffSummaries(items = []) {
@@ -144,8 +145,19 @@ function createTaskWorkspaceDiffSummaryService(options = {}) {
144
145
  })
145
146
  }
146
147
 
147
- function listTaskWorkspaceDiffSummaries(limit = 30) {
148
- return attachTaskWorkspaceDiffSummaries(listTasks(limit)).map((task) => ({
148
+ function listTaskWorkspaceDiffSummaries(limit = 30, slugs = []) {
149
+ const requestedSlugs = [
150
+ ...new Set(
151
+ (Array.isArray(slugs) ? slugs : [slugs])
152
+ .map((slug) => String(slug || '').trim())
153
+ .filter(Boolean)
154
+ ),
155
+ ]
156
+ const tasks = requestedSlugs.length
157
+ ? requestedSlugs.map((slug) => getTaskBySlug(slug)).filter(Boolean)
158
+ : listTasks(limit)
159
+
160
+ return attachTaskWorkspaceDiffSummaries(tasks).map((task) => ({
149
161
  slug: String(task?.slug || '').trim(),
150
162
  workspaceDiffSummary: task?.workspaceDiffSummary || createEmptyWorkspaceDiffSummary(),
151
163
  }))
@@ -232,8 +244,13 @@ function registerTaskRoutes(app, options = {}) {
232
244
 
233
245
  app.get('/api/tasks/workspace-diff-summaries', async (request) => {
234
246
  purgeExpiredContent()
247
+ const requestedSlugs = Array.isArray(request.query?.slug)
248
+ ? request.query.slug
249
+ : String(request.query?.slug || '').trim()
250
+ ? [request.query.slug]
251
+ : []
235
252
  return {
236
- items: listTaskWorkspaceDiffSummaries(request.query?.limit),
253
+ items: listTaskWorkspaceDiffSummaries(request.query?.limit, requestedSlugs),
237
254
  }
238
255
  })
239
256
 
@@ -69,6 +69,55 @@ test('task workspace diff summary service normalizes and reuses workspace summar
69
69
  ])
70
70
  })
71
71
 
72
+ test('task workspace diff summary service can refresh requested task slugs only', () => {
73
+ const lookups = []
74
+ const tasksBySlug = {
75
+ a: { slug: 'a', codexSessionId: 's1' },
76
+ b: { slug: 'b', codexSessionId: 's2' },
77
+ }
78
+ const service = createTaskWorkspaceDiffSummaryService({
79
+ getPromptxCodexSessionById(sessionId) {
80
+ return {
81
+ s1: { id: 's1', cwd: '/repo/a' },
82
+ s2: { id: 's2', cwd: '/repo/b' },
83
+ }[sessionId] || null
84
+ },
85
+ getTaskBySlug(slug) {
86
+ return tasksBySlug[slug] || null
87
+ },
88
+ getWorkspaceGitDiffStatusSummaryByCwd(cwd) {
89
+ lookups.push(cwd)
90
+ return {
91
+ supported: true,
92
+ summary: {
93
+ fileCount: cwd === '/repo/b' ? 2 : 1,
94
+ additions: 0,
95
+ deletions: 0,
96
+ statsComplete: true,
97
+ },
98
+ }
99
+ },
100
+ listTasks() {
101
+ return Object.values(tasksBySlug)
102
+ },
103
+ })
104
+
105
+ const items = service.listTaskWorkspaceDiffSummaries(30, ['b'])
106
+ assert.deepEqual(lookups, ['/repo/b'])
107
+ assert.deepEqual(items, [
108
+ {
109
+ slug: 'b',
110
+ workspaceDiffSummary: {
111
+ supported: true,
112
+ fileCount: 2,
113
+ additions: 0,
114
+ deletions: 0,
115
+ statsComplete: true,
116
+ },
117
+ },
118
+ ])
119
+ })
120
+
72
121
  test('task routes return 202 when runner dispatch remains pending', async () => {
73
122
  const app = Fastify()
74
123
  registerTaskRoutes(app, {
@@ -319,6 +319,40 @@ function getDirectoryPickerHomePath() {
319
319
  return path.resolve(os.homedir())
320
320
  }
321
321
 
322
+ function isReadableDirectory(directoryPath = '') {
323
+ try {
324
+ const stats = fs.statSync(directoryPath)
325
+ return stats.isDirectory()
326
+ } catch {
327
+ return false
328
+ }
329
+ }
330
+
331
+ function getDirectoryPickerRootItems(homePath = getDirectoryPickerHomePath()) {
332
+ const roots = [createDirectoryPickerItem(homePath)]
333
+
334
+ if (process.platform !== 'win32') {
335
+ return roots
336
+ }
337
+
338
+ ;['c', 'd', 'e', 'f'].forEach((driveLetter) => {
339
+ const drivePath = `${driveLetter.toUpperCase()}:\\`
340
+ if (!isReadableDirectory(drivePath)) {
341
+ return
342
+ }
343
+
344
+ const normalizedHomePath = path.resolve(homePath).toLowerCase()
345
+ const normalizedDrivePath = path.resolve(drivePath).toLowerCase()
346
+ if (normalizedHomePath === normalizedDrivePath) {
347
+ return
348
+ }
349
+
350
+ roots.push(createDirectoryPickerItem(drivePath, `${driveLetter.toUpperCase()} 盘`))
351
+ })
352
+
353
+ return roots
354
+ }
355
+
322
356
  function normalizeDirectoryPickerPath(input = '') {
323
357
  const value = String(input || '').trim()
324
358
  if (!value) {
@@ -992,6 +1026,7 @@ export function readWorkspaceFileContent(workspacePath, options = {}) {
992
1026
  }
993
1027
 
994
1028
  export function listDirectoryPickerTree(options = {}) {
1029
+ const isRootRequest = !String(options.path || '').trim()
995
1030
  const targetPath = normalizeDirectoryPickerPath(options.path) || getDirectoryPickerHomePath()
996
1031
 
997
1032
  const limit = clampLimit(options.limit, DIRECTORY_PICKER_LIMIT, 600)
@@ -1002,7 +1037,8 @@ export function listDirectoryPickerTree(options = {}) {
1002
1037
 
1003
1038
  return {
1004
1039
  path: targetPath,
1005
- parentPath: '',
1040
+ parentPath: getDirectoryParentPath(targetPath),
1041
+ roots: isRootRequest ? getDirectoryPickerRootItems(targetPath) : undefined,
1006
1042
  items: entries.slice(0, limit),
1007
1043
  truncated: entries.length > limit,
1008
1044
  }
@@ -17,12 +17,29 @@ test('listDirectoryPickerTree returns filesystem roots when path is empty', () =
17
17
  const payload = listDirectoryPickerTree()
18
18
 
19
19
  assert.equal(payload.path, path.resolve(os.homedir()))
20
- assert.equal(payload.parentPath, '')
20
+ assert.equal(payload.parentPath, path.dirname(path.resolve(os.homedir())))
21
21
  assert.equal(Array.isArray(payload.items), true)
22
+ assert.equal(Array.isArray(payload.roots), true)
23
+ assert.equal(payload.roots[0]?.path, path.resolve(os.homedir()))
24
+ assert.equal(payload.roots[0]?.type, 'directory')
25
+ assert.equal(typeof payload.roots[0]?.name, 'string')
26
+ assert.equal(Boolean(payload.roots[0]?.name), true)
22
27
  assert.equal(payload.items.length > 0, true)
23
28
  assert.equal(payload.items.every((item) => item.type === 'directory'), true)
24
29
  })
25
30
 
31
+ test('listDirectoryPickerTree returns parentPath for nested paths', () => {
32
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'promptx-dir-picker-parent-'))
33
+ const childDir = path.join(tempDir, 'project-a')
34
+
35
+ fs.mkdirSync(childDir)
36
+
37
+ const payload = listDirectoryPickerTree({ path: childDir })
38
+
39
+ assert.equal(payload.path, childDir)
40
+ assert.equal(payload.parentPath, tempDir)
41
+ })
42
+
26
43
  test('listDirectoryPickerTree lists child directories and excludes files', () => {
27
44
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'promptx-dir-picker-'))
28
45
  const childDir = path.join(tempDir, 'project-a')
@@ -0,0 +1,3 @@
1
+ import{W as ut,j as yt,o as Mt,s as jt,p as It,q as ct,h as Et,t as st,f as Pt,v as ft,w as pt,x as At,y as We,z as Rt,A as nt}from"./WorkbenchView-pIUuQsCk.js";import{u as Qe,f as Dt,e as Tt}from"./index-Ch8uSQYT.js";import{w as ie,n as he,ak as lt,aD as p,aI as ue,aJ as Le,aF as n,aQ as u,u as i,aG as I,aW as Lt,aU as Bt,aX as Ft,aE as m,aR as ye,aS as Se,aL as N,aN as M,aV as Nt,aK as at,b as $,c as k,o as Ot,aZ as xt,r as Ut}from"./vendor-misc-u-M8sNMf.js";import{c as Ht,L as Ze,F as et,e as zt,b as it,X as gt,C as Kt,O as qt,j as Vt,x as Wt,P as Qt,i as mt,E as Gt,Q as Xt,q as Yt,r as Jt,Y as Zt}from"./vendor-ui-BglsaDbv.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";import"./vendor-router-Dn8q3tJM.js";const en={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},tn={class:"theme-muted-text mt-1 text-xs leading-5"},nn={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},sn={class:"flex items-start gap-2 text-xs leading-5"},an={class:"theme-muted-text shrink-0"},ln={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},on={class:"theme-muted-text mt-4 block text-xs"},rn={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},dn=["placeholder"],un={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},cn={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},fn={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},pn={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},gn={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},mn={key:4,class:"theme-empty-state px-3 py-8 text-sm"},vn={key:5,class:"theme-empty-state px-3 py-8 text-sm"},hn={key:6,class:"theme-empty-state px-3 py-8 text-sm"},yn={key:7,class:"space-y-1"},xn=["onClick"],bn={class:"min-w-0 flex-1"},wn=["innerHTML"],Sn=["innerHTML"],kn={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},Cn={key:8,class:"space-y-1"},_n={class:"flex items-start gap-1.5"},$n=["onClick"],Mn=["onClick"],jn={class:"min-w-0 flex-1"},In={key:0,class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all"},En={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"},Pn={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},An=["disabled"],Rn=["disabled"],Dn={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(d,{emit:W}){const j=d,R=W,{t:v}=Qe(),G=$(""),H=$([]),g=$(!1),w=$(""),E=$(!1),r=$(""),b=$([]),P=$(!1),f=$(""),_=$(""),ce=$(null);let Q=null,O=0,B=null;const z=new Map,K=k(()=>Fe(H.value)),X=k(()=>String(f.value||"").trim()),Y=k(()=>X.value.length>=ut),D=k(()=>!!X.value),le=k(()=>Ce(_.value)||G.value),q=k(()=>D.value?b.value:K.value),me=k(()=>q.value.map(e=>{const l=c((e==null?void 0:e.path)||""),s=e!=null&&e.expanded?1:0,o=e!=null&&e.loading?1:0;return`${l}:${s}:${o}`}).join("|")),se=k(()=>D.value&&!Y.value&&!E.value&&!r.value),J=k(()=>D.value&&Y.value&&!E.value&&!r.value&&!b.value.length),h=k(()=>!D.value&&!g.value&&!w.value&&!K.value.length);function x(e=""){const l=String(e||"").trim();return/^[a-z]:[\\/]/i.test(l)||l.includes("\\")}function c(e=""){const l=String(e||"").trim();if(!l)return"";const s=x(l);let o=l.replace(/\\/g,"/");return o.length>1&&!/^[a-z]:\/?$/i.test(o)&&o!=="/"&&(o=o.replace(/\/+$/,"")),s?o.toLowerCase():o}function U(e="",l=""){const s=c(e),o=c(l);if(!s||!o||o==="/"&&s!=="/")return!1;const A=o.endsWith("/")?o:`${o}/`;return s===o||s.startsWith(A)}function ee(e="",l=""){const s=String(e||"").trim(),o=String(l||"").trim();return s?o?x(s)?/^[a-z]:\\?$/i.test(s)?`${s.replace(/[\\/]+$/,"")}\\${o}`:`${s.replace(/[\\/]+$/,"")}\\${o}`:s==="/"?`/${o}`:`${s.replace(/\/+$/,"")}/${o}`:s:o}function S(e="",l=""){const s=c(e),o=c(l);if(!s||!o||!U(o,s))return[];const A=o===s?"":o.slice(s.length).replace(/^\//,"");return A?A.split("/").filter(Boolean):[]}function ke(e=""){const l=String(e||"").trim(),s=Ce(l);if(!l||!s||c(l)===c(s))return"";const o=x(l),A=l.replace(/\\/g,"/");if(o){const de=A.replace(/\/+$/,""),qe=de.lastIndexOf("/");if(qe<=2)return"";const Te=de.slice(0,qe).replace(/\//g,"\\");return U(Te,s)?Te:""}const V=A.replace(/\/+$/,""),ne=V.lastIndexOf("/");if(ne<=0)return"";const ae=V.slice(0,ne)||"/";return U(ae,s)?ae:""}function Ce(e=""){const l=String(e||"").trim();return l&&H.value.map(o=>String((o==null?void 0:o.path)||"").trim()).filter(o=>o&&U(l,o)).sort((o,A)=>c(A).length-c(o).length)[0]||""}function xe(e){return(e==null?void 0:e.name)||(e==null?void 0:e.path)||v("directoryPicker.unnamedDirectory")}function _e(e=""){const l=String(e||"").trim();return l?l.split(/[\\/]/).filter(Boolean).at(-1)||l:"Home"}function ve(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function fe(e="",l=""){const s=String(e||""),o=String(l||"").trim().toLowerCase();if(!s||!o)return null;const A=s.toLowerCase(),V=A.indexOf(o);if(V>=0)return{start:V,end:V+o.length};const ne=o.split(/[\\/\s_.-]+/).filter(Boolean).sort((ae,de)=>de.length-ae.length);for(const ae of ne){if(ae.length<2)continue;const de=A.indexOf(ae);if(de>=0)return{start:de,end:de+ae.length}}return null}function T(e="",l=""){const s=String(e||""),o=fe(s,l);return o?`${ve(s.slice(0,o.start))}<mark class="theme-search-highlight">${ve(s.slice(o.start,o.end))}</mark>${ve(s.slice(o.end))}`:ve(s)}function tt(e){return T(xe(e),f.value)}function Be(e){return T((e==null?void 0:e.path)||"",f.value)}function $e(e,l=0){return{...e,depth:l,expanded:!1,loaded:!1,loading:!1,children:[]}}function Fe(e=[],l=[]){return e.forEach(s=>{l.push(s),s.expanded&&s.children.length&&Fe(s.children,l)}),l}function oe(){H.value=[...H.value]}function be(){Q&&(window.clearTimeout(Q),Q=null),B&&(B.abort(),B=null)}function we(e,l=H.value){const s=c(e);if(!s)return null;for(const o of l){if(c(o.path)===s)return o;if(o.children.length){const A=we(e,o.children);if(A)return A}}return null}function Z(e){_.value=String((e==null?void 0:e.path)||"").trim()}function pe(e=""){return c(e)}function Ne(e,l){const s=pe(e);if(s){if(l){z.set(s,l);return}z.delete(s)}}function Me(){var l;const e=z.get(pe(_.value));(l=e==null?void 0:e.scrollIntoView)==null||l.call(e,{block:"nearest"})}function Ge(){he(()=>{var e,l;(l=(e=ce.value)==null?void 0:e.focus)==null||l.call(e)})}function re(){const e=q.value;if(!e.length){_.value="";return}const l=pe(_.value);l&&e.some(s=>pe((s==null?void 0:s.path)||"")===l)||Z(e[0])}function ge(){const e=q.value;if(!e.length)return-1;const l=pe(_.value),s=e.findIndex(o=>pe((o==null?void 0:o.path)||"")===l);return s>=0?s:0}function je(){const e=q.value,l=ge();return l<0||!e.length?null:e[l]||null}function Ie(e=1){const l=q.value;if(!l.length)return!1;const s=ge(),o=s<0?0:(s+e+l.length)%l.length;return Z(l[o]),he(Me),!0}async function Oe(){if(D.value)return!1;const e=je();if(!e||!e.hasChildren)return!1;if(!e.expanded)return await De(e),!0;const l=q.value,s=ge(),o=l[s+1];return o&&ke(o.path)===e.path?(Z(o),he(Me),!0):!1}function Ue(){if(D.value)return!1;const e=je();if(!e)return!1;if(e.expanded&&e.hasChildren)return e.expanded=!1,oe(),Z(e),!0;const l=ke(e.path);if(!l)return!1;const s=we(l);return s?(Z(s),he(Me),!0):!1}function Ee(e){var l,s,o;if((l=e==null?void 0:e.preventDefault)==null||l.call(e),X.value){(s=e==null?void 0:e.stopPropagation)==null||s.call(e),f.value="";return}(o=e==null?void 0:e.stopPropagation)==null||o.call(e),R("close")}function Pe(e){const l=String((e==null?void 0:e.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(l)&&!(D.value&&(l==="ArrowLeft"||l==="ArrowRight"))){if(l==="ArrowDown"){e.preventDefault(),Ie(1);return}if(l==="ArrowUp"){e.preventDefault(),Ie(-1);return}if(l==="Escape"){Ee(e);return}if(D.value){if(l==="Enter"){e.preventDefault();const s=je();s&&Je(s)}return}if(l==="ArrowRight"){e.preventDefault(),Oe();return}if(l==="ArrowLeft"){e.preventDefault(),Ue();return}l==="Enter"&&(e.preventDefault(),Ke())}}async function He(e,l={}){if(!(!e||e.loading)&&!(e.loaded&&!l.force)){e.loading=!0,w.value="",oe();try{const s=await ct({path:e.path,limit:240});e.children=(s.items||[]).map(o=>$e(o,e.depth+1)),e.loaded=!0}catch(s){w.value=s.message||v("directoryPicker.loadFailed")}finally{e.loading=!1,oe()}}}async function Ae(){g.value=!0,w.value="";try{const e=await ct({limit:240});G.value=String(e.path||"");const l=Array.isArray(e.roots)&&e.roots.length?e.roots:[{name:_e(e.path||""),path:String(e.path||""),type:"directory",hasChildren:!0,isRoot:!0}],s=c(e.path||""),o=l.map(A=>{const V=$e({...A,isHomeRoot:c(A.path||"")===s},0);return V.isHomeRoot&&(V.children=(e.items||[]).map(ne=>$e(ne,1)),V.loaded=!0,V.expanded=!0),V});H.value=o,Z(o.find(A=>A.isHomeRoot)||o[0])}catch(e){w.value=e.message||v("directoryPicker.treeLoadFailed"),H.value=[],G.value=""}finally{g.value=!1}}async function te(e=""){const l=String(e||"").trim(),s=Ce(l);if(!l||!s)return;let o=we(s);if(!o)return;Z(o);const A=S(s,l);for(const V of A){await He(o),o.expanded=!0,oe();const ne=we(ee(o.path,V),o.children);if(!ne)break;o=ne,Z(o)}}async function Re(){f.value="",b.value=[],r.value="",P.value=!1,_.value="",await Ae();const e=String(j.initialPath||"").trim();e&&Ce(e)&&await te(e)}async function De(e){if(e!=null&&e.path&&(Z(e),!!e.hasChildren)){if(!e.loaded){e.expanded=!0,oe(),await He(e);return}e.expanded=!e.expanded,oe()}}function ze(e){e!=null&&e.path&&Z(e)}async function Xe(){const e=String(f.value||"").trim();O+=1;const l=O;if(be(),!j.open||!e||!le.value||!Y.value){E.value=!1,r.value="",b.value=[],P.value=!1;return}E.value=!0,r.value="",B=new AbortController;try{const s=await jt(e,{path:le.value,limit:80,signal:B.signal});if(l!==O)return;b.value=Array.isArray(s.items)?s.items:[],P.value=!!s.truncated}catch(s){if(It(s)||l!==O)return;r.value=s.message||v("directoryPicker.searchFailed"),b.value=[],P.value=!1}finally{l===O&&(B=null),l===O&&(E.value=!1)}}function Ye(){if(be(),!String(f.value||"").trim()||!Y.value){E.value=!1,r.value="",b.value=[],P.value=!1;return}E.value=!0,r.value="",Q=window.setTimeout(()=>{Q=null,Xe()},Mt)}async function Je(e){e!=null&&e.path&&(await te(e.path),f.value="")}function Ke(){_.value&&(R("select",_.value),R("close"))}return ie(f,()=>{Ye()}),ie(me,()=>{re(),he(Me)},{immediate:!0}),ie(()=>j.open,e=>{if(e){Re().catch(()=>{}),Ge();return}be()}),lt(()=>{be()}),(e,l)=>(p(),ue(yt,{open:d.open,"stack-level":1,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-4xl sm:h-[96vh] sm:max-h-[96vh]","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":g.value||E.value,"close-on-backdrop":!(g.value||E.value),"close-on-escape":!(g.value||E.value),onClose:l[2]||(l[2]=s=>R("close"))},{title:Le(()=>[n("div",null,[n("div",en,[I(i(et),{class:"h-4 w-4"}),n("span",null,u(i(v)("directoryPicker.title")),1)]),n("p",tn,u(i(v)("directoryPicker.intro")),1)])]),default:Le(()=>[n("div",{class:"flex min-h-0 flex-1 flex-col overflow-hidden",onKeydown:Pe},[n("div",nn,[n("div",sn,[n("span",an,u(i(v)("directoryPicker.currentSelection")),1),n("span",ln,u(_.value||i(v)("directoryPicker.selectionPlaceholder")),1)])]),n("label",on,[n("span",null,u(i(v)("directoryPicker.searchLabel")),1),n("div",rn,[I(i(Ht),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),Lt(n("input",{ref_key:"searchInputRef",ref:ce,"onUpdate:modelValue":l[0]||(l[0]=s=>f.value=s),type:"text",placeholder:i(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)]",onKeydown:Bt(Ee,["esc"])},null,40,dn),[[Ft,f.value]])])]),n("div",un,[D.value&&r.value?(p(),m("div",cn,u(r.value),1)):!D.value&&w.value?(p(),m("div",fn,u(w.value),1)):D.value&&E.value?(p(),m("div",pn,[I(i(Ze),{class:"h-4 w-4 animate-spin"}),n("span",null,u(i(v)("directoryPicker.searching")),1)])):!D.value&&g.value?(p(),m("div",gn,[I(i(Ze),{class:"h-4 w-4 animate-spin"}),n("span",null,u(i(v)("directoryPicker.treeLoading")),1)])):se.value?(p(),m("div",mn,u(i(v)("directoryPicker.searchMinKeywordHint",{count:i(ut)})),1)):J.value?(p(),m("div",vn,u(i(v)("directoryPicker.noSearchResults")),1)):h.value?(p(),m("div",hn,u(i(v)("directoryPicker.emptyTree")),1)):D.value?(p(),m("div",yn,[(p(!0),m(ye,null,Se(b.value,s=>(p(),m("button",{key:s.path,ref_for:!0,ref:o=>Ne(s.path,o),type:"button",class:N(["theme-list-row focus:outline-none",c(_.value)===c(s.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:o=>Je(s)},[I(i(et),{class:"theme-list-item-icon"}),n("div",bn,[n("div",null,[n("span",{class:"theme-list-item-title block break-all",innerHTML:tt(s)},null,8,wn)]),n("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:Be(s)},null,8,Sn)])],10,xn))),128)),P.value?(p(),m("p",kn,u(i(v)("directoryPicker.truncatedHint")),1)):M("",!0)])):(p(),m("div",Cn,[(p(!0),m(ye,null,Se(K.value,s=>(p(),m("div",{key:s.path,ref_for:!0,ref:o=>Ne(s.path,o),class:N(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",c(_.value)===c(s.path)?"theme-list-item-active":s.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Nt({paddingLeft:`${s.depth*16+6}px`})},[n("div",_n,[n("button",{type:"button",class:N(["theme-icon-button h-5 w-5 shrink-0",s.hasChildren?"":"invisible pointer-events-none"]),onClick:at(o=>De(s),["stop"])},[s.loading?(p(),ue(i(Ze),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(p(),ue(i(zt),{key:1,class:N(["h-3.5 w-3.5 transition",s.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,$n),n("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:o=>ze(s)},[I(i(et),{class:N(["h-4 w-4 shrink-0",c(_.value)===c(s.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),n("div",jn,[n("div",{class:N(["theme-list-item-title truncate",s.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},u(xe(s)),3),s.isHomeRoot?(p(),m("div",In,u(s.path),1)):M("",!0)])],8,Mn)])],6))),128))]))])],32),n("div",En,[n("div",Pn,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:g.value||E.value,onClick:l[1]||(l[1]=s=>R("close"))},u(i(v)("directoryPicker.cancel")),9,An),n("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:g.value||E.value||!_.value,onClick:Ke},[I(i(it),{class:"h-4 w-4"}),n("span",null,u(i(v)("directoryPicker.useCurrentDirectory")),1)],8,Rn)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Tn={class:"grid gap-4"},Ln={class:"theme-muted-text block text-xs"},Bn=["value","disabled"],Fn={class:"theme-muted-text block text-xs"},Nn={class:"mt-1 flex gap-2"},On={class:"relative min-w-0 flex-1"},Un=["value","disabled"],Hn=["disabled"],zn=["disabled"],Kn={id:"codex-manager-workspace-suggestions"},qn=["value"],Vn={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Wn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},Qn={class:"theme-muted-text block text-xs"},Gn={class:"mt-1"},Xn={class:"flex items-center gap-2 text-sm"},Yn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Jn=["disabled","onClick"],Zn={class:"flex items-center justify-between gap-3"},es={class:"min-w-0 flex-1 truncate"},ts={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},ns={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},ss={class:"theme-muted-text block text-xs"},as={class:"mt-2 grid gap-2"},is=["disabled","onClick"],ls={class:"min-w-0"},os={class:"text-sm text-[var(--theme-textPrimary)]"},rs={class:"theme-muted-text mt-0.5 text-[11px] leading-5"},ds={class:"theme-muted-text mt-2 text-[11px] leading-5"},us={class:"theme-muted-text block text-xs"},cs={class:"mt-1 flex gap-2"},fs=["value","disabled"],ps=["disabled"],gs={key:1,class:"theme-popover theme-divider absolute left-0 right-0 top-[calc(100%+0.375rem)] z-20 overflow-hidden rounded-sm border border-solid shadow-sm"},ms={class:"flex items-center justify-between gap-2 border-b border-solid px-3 py-2 text-[11px] leading-5"},vs={class:"font-medium text-[var(--theme-textPrimary)]"},hs={key:0,class:"theme-muted-text"},ys={key:0,class:"max-h-72 overflow-y-auto p-2"},xs=["disabled","onClick"],bs={class:"flex min-w-0 items-center justify-between gap-3"},ws={class:"min-w-0 flex-1 truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Ss={class:"shrink-0 text-[11px] leading-4 text-[var(--theme-textMuted)]"},ks={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Cs=["disabled"],_s={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},$s={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},vt={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},agentEngines:{type:Array,default:()=>[]},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:""},sessionCandidates:{type:Array,default:()=>[]},sessionCandidatesLoading:{type:Boolean,default:!1},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","select-session-candidate","update:agentEngines","update:cwd","update:engine","update:sessionId","update:title"],setup(d,{emit:W}){const j=d,R=W,{t:v}=Qe(),G=$(null),H=$(null),g=$(!1),w=$(-1),E=k(()=>{const h=String(j.engine||"").trim();return j.engineOptions.find(x=>String((x==null?void 0:x.value)||"").trim()===h)||null}),r=k(()=>{const h=Array.isArray(j.agentEngines)?j.agentEngines:[];return[...new Set(h.map(x=>String(x||"").trim()).filter(Boolean))]}),b=k(()=>j.engineOptions.filter(h=>String((h==null?void 0:h.value)||"").trim()!==String(j.engine||"").trim())),P=k(()=>!!String(j.cwd||"").trim()),f=k(()=>String(j.sessionId||"").trim()),_=k(()=>f.value.toLowerCase()),ce=k(()=>j.sessionCandidates.filter(h=>h==null?void 0:h.matchedCwd)),Q=k(()=>{const h=_.value,x=ce.value;return h?x.filter(c=>[c==null?void 0:c.label,c==null?void 0:c.id,c==null?void 0:c.cwd].map(ee=>String(ee||"").toLowerCase()).some(ee=>ee.includes(h))).slice(0,10):x.slice(0,10)});function O(){j.busy||!j.canEditSessionId||!P.value||(g.value=!0)}function B(){g.value=!1,w.value=-1}function z(){const h=Q.value;if(!h.length){w.value=-1;return}const x=h.findIndex(c=>c.id===f.value);w.value=x>=0?x:0}function K(){he(()=>{var h,x;(x=(h=H.value)==null?void 0:h.focus)==null||x.call(h)})}function X(){if(g.value){B();return}O(),K()}function Y(){R("update:cwd","")}function D(h){if(!j.canEditEngine||j.busy)return;const x=String(h||"").trim(),c=r.value.includes(x)?r.value.filter(U=>U!==x):[...r.value,x];R("update:agentEngines",c)}function le(){R("update:sessionId",""),B(),K()}function q(h){var x;R("update:sessionId",((x=h==null?void 0:h.target)==null?void 0:x.value)||""),P.value&&O()}function me(h){R("select-session-candidate",h),B(),K()}function se(h){if(j.busy||!j.canEditSessionId||!P.value)return;const x=Q.value;if(h.key==="ArrowDown"){if(h.preventDefault(),!g.value){O(),z();return}if(!x.length)return;w.value=w.value<0?0:Math.min(x.length-1,w.value+1);return}if(h.key==="ArrowUp"){if(h.preventDefault(),!g.value){O(),z();return}if(!x.length)return;w.value=w.value<0?x.length-1:Math.max(0,w.value-1);return}if(h.key==="Enter"&&g.value&&x.length&&w.value>=0){h.preventDefault(),me(x[w.value]);return}h.key==="Escape"&&g.value&&(h.preventDefault(),B())}function J(h){!g.value||!G.value||G.value.contains(h.target)||B()}return ie(Q,()=>{z()}),ie(()=>j.canEditSessionId,h=>{(!h||!P.value)&&B()}),ie(P,h=>{h||B()}),Ot(()=>{document.addEventListener("pointerdown",J)}),lt(()=>{document.removeEventListener("pointerdown",J)}),(h,x)=>(p(),m("div",Tn,[n("label",Ln,[n("span",null,u(i(v)("projectManager.projectTitleOptional")),1),n("input",{value:d.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:d.busy,onInput:x[0]||(x[0]=c=>R("update:title",c.target.value))},null,40,Bn)]),n("label",Fn,[n("span",null,u(i(v)("projectManager.workingDirectoryField")),1),n("div",Nn,[n("div",On,[n("input",{value:d.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:N(["tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",d.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:d.busy||!d.canEditCwd,onInput:x[1]||(x[1]=c=>R("update:cwd",c.target.value))},null,42,Un),d.cwd&&d.canEditCwd?(p(),m("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:d.busy,onClick:Y},[I(i(gt),{class:"h-3.5 w-3.5"})],8,Hn)):M("",!0)]),n("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:d.busy||!d.canEditCwd,onClick:x[2]||(x[2]=c=>R("open-directory-picker"))},[I(i(et),{class:"h-4 w-4"}),n("span",null,u(d.mobile?i(v)("projectManager.choose"):i(v)("projectManager.chooseDirectory")),1)],8,zn)]),n("datalist",Kn,[(p(!0),m(ye,null,Se(d.workspaceSuggestions,c=>(p(),m("option",{key:c,value:c},null,8,qn))),128))]),d.duplicateCwdMessage?(p(),m("p",Vn,u(d.duplicateCwdMessage),1)):d.cwdReadonlyMessage?(p(),m("p",Wn,u(d.cwdReadonlyMessage),1)):M("",!0)]),n("label",Qn,[n("span",null,u(i(v)("projectManager.engineField")),1),n("div",Gn,[I(Et,{"model-value":d.engine,options:d.engineOptions,disabled:d.busy||!d.canEditEngine,placeholder:i(v)("projectManager.selectEngine"),"empty-text":i(v)("projectManager.noEngines"),"get-option-value":c=>(c==null?void 0:c.value)||"","onUpdate:modelValue":x[3]||(x[3]=c=>R("update:engine",c))},{trigger:Le(({disabled:c})=>{var U;return[n("div",Xn,[n("span",{class:N(["min-w-0 flex-1 truncate",c?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},u(((U=E.value)==null?void 0:U.label)||i(v)("projectManager.selectEngine")),3),E.value&&E.value.enabled===!1?(p(),m("span",Yn,u(i(v)("projectManager.comingSoon")),1)):M("",!0)])]}),option:Le(({option:c,selected:U,select:ee})=>[n("button",{type:"button",class:N(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",U?"theme-filter-active":"theme-filter-idle"]),disabled:(c==null?void 0:c.enabled)===!1,onClick:ee},[n("div",Zn,[n("span",es,u(c.label),1),(c==null?void 0:c.enabled)===!1?(p(),m("span",ts,u(i(v)("projectManager.comingSoon")),1)):M("",!0)])],10,Jn)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),d.engineReadonlyMessage?(p(),m("p",ns,u(d.engineReadonlyMessage),1)):M("",!0)]),n("div",ss,[n("span",null,u(i(v)("projectManager.collaborationAgents")),1),n("div",as,[(p(!0),m(ye,null,Se(b.value,c=>(p(),m("button",{key:c.value,type:"button",class:N(["theme-list-row flex items-center justify-between gap-3 rounded-sm border border-solid px-3 py-2 text-left transition",r.value.includes(c.value)?"theme-list-item-active":"theme-list-item-hover"]),disabled:d.busy||!d.canEditEngine,onClick:U=>D(c.value)},[n("div",ls,[n("div",os,u(c.label),1),n("div",rs,u(r.value.includes(c.value)?i(v)("projectManager.agentEnabled"):i(v)("projectManager.agentDisabled")),1)]),r.value.includes(c.value)?(p(),ue(i(it),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textPrimary)]"})):M("",!0)],10,is))),128))]),n("p",ds,u(i(v)("projectManager.collaborationAgentsHint")),1)]),n("label",us,[n("span",null,u(i(v)("projectManager.sessionId")),1),n("div",cs,[n("div",{ref_key:"sessionComboboxRef",ref:G,class:"relative min-w-0 flex-1"},[n("input",{ref_key:"sessionInputRef",ref:H,value:d.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",disabled:d.busy||!d.canEditSessionId,onFocus:O,onInput:q,onKeydown:se},null,40,fs),d.canEditSessionId?(p(),m("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:d.busy||!P.value,onClick:X},[d.sessionCandidatesLoading?(p(),ue(i(Ze),{key:0,class:"h-3.5 w-3.5 animate-spin"})):f.value?(p(),ue(i(gt),{key:1,class:"h-3.5 w-3.5",onClick:at(le,["stop"])})):(p(),ue(i(Kt),{key:2,class:N(["h-3.5 w-3.5 transition",g.value?"rotate-180":""])},null,8,["class"]))],8,ps)):M("",!0),d.canEditSessionId&&g.value?(p(),m("div",gs,[n("div",ms,[n("span",vs,u(i(v)("projectManager.sessionCandidates")),1),d.sessionCandidatesLoading?(p(),m("span",hs,u(i(v)("projectManager.sessionCandidatesLoading")),1)):M("",!0)]),Q.value.length?(p(),m("div",ys,[(p(!0),m(ye,null,Se(Q.value,(c,U)=>(p(),m("button",{key:`${c.engine}:${c.id}`,type:"button",class:N(["theme-list-row mb-1 w-full px-2 py-1.5 text-left last:mb-0",U===w.value?"theme-list-item-active":"theme-list-item-hover"]),disabled:d.busy,onMousedown:x[4]||(x[4]=at(()=>{},["prevent"])),onClick:ee=>me(c)},[n("div",bs,[n("span",ws,u(c.label||c.id),1),n("span",Ss,u(c.updatedAtLabel||i(v)("projectManager.unknown")),1)])],42,xs))),128))])):(p(),m("div",ks,u(P.value?i(v)("projectManager.noSessionCandidates"):i(v)("projectManager.sessionCandidatesNeedDirectory")),1))])):M("",!0)],512),f.value?(p(),m("button",{key:0,type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:d.busy,onClick:x[5]||(x[5]=c=>R("copy-session-id"))},[d.sessionIdCopied?(p(),ue(i(it),{key:0,class:"h-4 w-4"})):(p(),ue(i(qt),{key:1,class:"h-4 w-4"})),n("span",null,u(d.sessionIdCopied?i(v)("projectManager.sessionIdCopied"):i(v)("projectManager.copySessionId")),1)],8,Cs)):M("",!0)]),d.sessionIdReadonlyMessage?(p(),m("p",_s,u(d.sessionIdReadonlyMessage),1)):(p(),m("p",$s,u(P.value?i(v)("projectManager.sessionIdHint"):i(v)("projectManager.sessionCandidatesNeedDirectory")),1))])]))}},Ms={class:"flex items-center justify-between gap-3"},js={class:"theme-heading text-sm font-medium"},Is={key:0,class:"theme-muted-text mt-1 text-xs"},Es=["disabled"],Ps=["onClick"],As={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},Rs={class:"flex w-full flex-col gap-2 text-left"},Ds={class:"theme-heading min-w-0 text-sm font-medium"},Ts=["title"],Ls=["title"],Bs={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},Fs={key:0,"aria-hidden":"true"},Ns={key:1},Os={class:"flex flex-wrap items-center gap-2 pt-1"},Us={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},ht={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:d=>d},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(d,{emit:W}){const j=d,R=W,{t:v}=Qe();function G(w){return j.mode==="edit"&&j.editingSessionId===w.id?"theme-card-selected":j.isSessionRunning(w.id)?"theme-card-warning":"theme-card-idle-strong"}function H(w){return j.isCurrentSession(w.id)?v("projectManager.current"):v("projectManager.regular")}function g(w){return j.isCurrentSession(w.id)?"theme-status-info":"theme-status-neutral"}return(w,E)=>(p(),m("div",{class:N(d.mobile?"flex h-full min-h-0 flex-col":"")},[n("div",Ms,[n("div",null,[n("div",js,u(i(v)("projectManager.projectList")),1),d.hasSessions?M("",!0):(p(),m("p",Is,u(i(v)("projectManager.noProjects")),1))]),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:d.busy,onClick:E[0]||(E[0]=r=>R("create"))},[I(i(Vt),{class:"h-4 w-4"}),n("span",null,u(i(v)("projectManager.create")),1)],8,Es)]),n("div",{class:N(["mt-4 space-y-2",d.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),m(ye,null,Se(d.sessions,r=>{var b;return p(),m("article",{key:r.id,class:N(["relative cursor-pointer rounded-sm border p-3 transition",G(r)]),onClick:P=>R("select",r.id)},[d.mode==="edit"&&d.editingSessionId===r.id?(p(),m("span",As)):M("",!0),n("div",Rs,[n("div",Ds,[n("span",{class:"block truncate",title:r.title||i(v)("projectManager.untitledProject")},u(r.title||i(v)("projectManager.untitledProject")),9,Ts)]),n("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:r.cwd},u(r.cwd),9,Ls),n("div",Bs,[n("span",null,u(((b=r==null?void 0:r.agentBindings)==null?void 0:b.length)>1?i(v)("projectManager.agentCount",{count:r.agentBindings.length}):i(st)(r.engine)),1),d.mobile?M("",!0):(p(),m("span",Fs,"·")),d.mobile?M("",!0):(p(),m("span",Ns,u(d.formatUpdatedAt(r.updatedAt)),1))]),n("div",Os,[n("span",{class:N(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",g(r)])},u(H(r)),3),n("span",{class:N(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",d.getRuntimeStatusClass(r.id)])},[d.isSessionRunning(r.id)?(p(),m("span",Us)):M("",!0),xt(" "+u(d.getRuntimeStatusLabel(r.id)),1)],2),n("span",{class:N(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",d.getThreadStatusClass(r)])},u(d.getThreadStatusLabel(r)),3)])])],10,Ps)}),128))],2)],2))}},Hs={class:"space-y-3"},zs={class:"dashed-panel px-3 py-3"},Ks={class:"theme-muted-text text-[11px]"},qs={class:"mt-2 flex flex-wrap gap-2"},Vs={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},Ws={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},Qs={class:"dashed-panel px-3 py-3"},Gs={class:"theme-muted-text text-[11px]"},Xs={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},Ys={key:0,class:"mt-2 flex flex-wrap gap-1.5"},Js={class:"dashed-panel px-3 py-3"},Zs={class:"theme-muted-text text-[11px]"},ea={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},ta={class:"dashed-panel px-3 py-3"},na={class:"theme-muted-text text-[11px]"},sa={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},aa={class:"dashed-panel px-3 py-3"},ia={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},la={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},oa={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:d=>d},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(d){const{t:W}=Qe();return(j,R)=>{var v,G,H,g,w,E,r,b,P;return p(),m("div",Hs,[n("div",zs,[n("div",Ks,u(i(W)("projectManager.runtimeStatus")),1),n("div",qs,[n("span",{class:N(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",d.getRuntimeStatusClass((v=d.activeSession)==null?void 0:v.id)])},[d.isSessionRunning((G=d.activeSession)==null?void 0:G.id)?(p(),m("span",Vs)):M("",!0),xt(" "+u(d.getRuntimeStatusLabel((H=d.activeSession)==null?void 0:H.id)),1)],2),n("span",{class:N(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",d.getThreadStatusClass(d.activeSession)])},u(d.getThreadStatusLabel(d.activeSession)),3),(g=d.activeSession)!=null&&g.id&&d.isCurrentSession(d.activeSession.id)?(p(),m("span",Ws,u(i(W)("projectManager.currentProject")),1)):M("",!0)])]),n("div",Qs,[n("div",Gs,u(i(W)("projectManager.engine")),1),n("div",Xs,u(i(st)((w=d.activeSession)==null?void 0:w.engine)),1),((r=(E=d.activeSession)==null?void 0:E.agentBindings)==null?void 0:r.length)>1?(p(),m("div",Ys,[(p(!0),m(ye,null,Se(d.activeSession.agentBindings,f=>(p(),m("span",{key:f.engine,class:"theme-status-neutral inline-flex items-center rounded-sm border border-solid px-1.5 py-0.5 text-[10px]"},u(i(st)(f.engine)),1))),128))])):M("",!0)]),n("div",Js,[n("div",Zs,u(i(W)("projectManager.workingDirectory")),1),n("div",ea,u(((b=d.activeSession)==null?void 0:b.cwd)||i(W)("projectManager.notSet")),1)]),n("div",ta,[n("div",na,u(i(W)("projectManager.updatedAt")),1),n("div",sa,u(d.formatUpdatedAt((P=d.activeSession)==null?void 0:P.updatedAt)),1)]),n("div",aa,[n("div",ia,[I(i(Wt),{class:"h-3.5 w-3.5"}),n("span",null,u(i(W)("projectManager.note")),1)]),n("p",la,u(i(W)("projectManager.noteDescription")),1)])])}}},ra={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},da={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},ua={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"},ca={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},fa={class:"flex flex-wrap items-start justify-between gap-3"},pa={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ga={class:"mt-5"},ma={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},va={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"},ha={class:"flex flex-wrap items-center gap-2"},ya=["disabled"],xa=["disabled"],ba=["disabled"],wa={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Sa=["disabled"],ka=["disabled"],Ca=["disabled"],_a={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},$a={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ma={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},ja={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ia={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Ea=["disabled"],Pa={class:"min-w-0 flex-1"},Aa={class:"theme-heading truncate text-sm font-medium"},Ra={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Da={class:"theme-divider border-b px-4 py-3"},Ta={class:"grid grid-cols-2 gap-2"},La=["disabled"],Ba={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Fa={key:0},Na={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Oa={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Ua=["disabled"],Ha=["disabled"],za=["disabled"],Ka=["disabled"],qa=3e3,Za={__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","open-source-browser"],setup(d,{expose:W,emit:j}){const R=new Map;function v(t="",a=""){const y=We(t),C=nt(a);return!y||!C?"":`${y}
2
+ ${C}`}function G(t=""){if(!t)return null;const a=R.get(t);return a?a.expiresAt<=Date.now()?(R.delete(t),null):Array.isArray(a.items)?a.items:[]:null}function H(t="",a=[]){t&&R.set(t,{expiresAt:Date.now()+qa,items:Array.isArray(a)?a:[]})}const g=d,w=j,{locale:E,t:r}=Qe(),b=$("edit"),P=$(""),f=Ut({title:"",engine:"codex",agentEngines:[],cwd:"",sessionId:""}),_=$(""),ce=$(!1),Q=$(!1),O=$(!1),B=$(!1),z=$(!1),K=$(!1),X=$(!1),Y=$(!1),{matches:D}=Pt("(max-width: 767px)"),le=$("list"),q=$("basic"),me=$(ft()),se=$([]),J=$(!1);let h=null,x=null,c=null,U=0;const ee=k(()=>je(g.sessions)),S=k(()=>g.sessions.find(t=>t.id===P.value)||null),ke=k(()=>g.sessions.length>0),Ce=k(()=>g.sessions.find(t=>t.id===g.selectedSessionId)||null),xe=k(()=>!!(S.value&&re(S.value.id))),_e=k(()=>{var t;return!((t=S.value)!=null&&t.started)}),ve=k(()=>{var t;return!((t=S.value)!=null&&t.started)}),fe=k(()=>{var t;return!((t=S.value)!=null&&t.started)}),T=k(()=>g.loading||ce.value||Q.value||O.value||B.value),tt=k(()=>String(f.sessionId||"").trim()),Be=k(()=>{var y,C;const t=new Set,a=[];return[f.cwd,(y=S.value)==null?void 0:y.cwd,(C=Ce.value)==null?void 0:C.cwd,...g.workspaces,...g.sessions.map(F=>F.cwd)].forEach(F=>{const L=String(F||"").trim();!L||t.has(L)||(t.add(L),a.push(L))}),a.slice(0,12)}),$e=k(()=>me.value),Fe=k(()=>se.value.map(t=>({...t,updatedAtLabel:t.updatedAt?Pe(t.updatedAt):""}))),oe=k(()=>{const t=nt(f.cwd);return t?g.sessions.filter(a=>{var y;return a.id===((y=S.value)==null?void 0:y.id)?!1:nt(a.cwd)===t}):[]}),be=k(()=>{if(!oe.value.length)return"";const t=oe.value.slice(0,3).map(a=>{const y=a.title||r("projectManager.untitledProject");return E.value==="en-US"?`"${y}"`:`「${y}」`}).join(E.value==="en-US"?", ":"、");return r("projectManager.duplicateDirectory",{labels:t,count:oe.value.length})}),we=k(()=>b.value!=="edit"||_e.value?"":r("projectManager.cwdReadonly")),Z=k(()=>b.value!=="edit"||!S.value||ve.value?"":r("projectManager.engineReadonly")),pe=k(()=>b.value!=="edit"||!S.value||fe.value?"":r("projectManager.sessionIdReadonly")),Ne=k(()=>b.value==="create"?ce.value?r("projectManager.creatingProject"):r("projectManager.createProject"):Q.value?r("projectManager.savingChanges"):r("projectManager.saveChanges")),Me=k(()=>{var t;return b.value==="create"?r("projectManager.newProject"):((t=S.value)==null?void 0:t.title)||r("projectManager.untitledProject")});function Ge(t=""){const a=Date.parse(String(t||""));return Number.isFinite(a)?a:0}function re(t){var a;return!!((a=g.sessions.find(y=>y.id===t))!=null&&a.running)}function ge(t){return!!t&&t===g.selectedSessionId}function je(t=[]){return[...t].sort((a,y)=>{const C=Number(re(y.id))-Number(re(a.id));if(C)return C;const F=Number(ge(y.id))-Number(ge(a.id));if(F)return F;const L=Ge(y.updatedAt)-Ge(a.updatedAt);return L||Tt(String(a.title||a.cwd||a.id),String(y.title||y.cwd||y.id))})}function Ie(t){return re(t)?r("projectManager.running"):r("projectManager.idle")}function Oe(t){return re(t)?"theme-status-warning":"theme-status-success"}function Ue(t){return t!=null&&t.started?r("projectManager.threadBound"):r("projectManager.notStarted")}function Ee(t){return t!=null&&t.started?"theme-status-success":"theme-status-neutral"}function Pe(t=""){if(!t)return r("projectManager.unknown");const a=new Date(t);return Number.isNaN(a.getTime())?t:Dt(a.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function He(t){f.title=String((t==null?void 0:t.title)||""),f.engine=We(t==null?void 0:t.engine),f.agentEngines=(Array.isArray(t==null?void 0:t.agentBindings)?t.agentBindings:[]).map(a=>We(a==null?void 0:a.engine)).filter(a=>a&&a!==f.engine),f.cwd=String((t==null?void 0:t.cwd)||""),f.sessionId=String((t==null?void 0:t.sessionId)||(t==null?void 0:t.engineSessionId)||(t==null?void 0:t.engineThreadId)||(t==null?void 0:t.codexThreadId)||"").trim()}function Ae(){b.value="create",P.value="",_.value="",f.title="",f.engine="codex",f.agentEngines=[],f.cwd="",f.sessionId=""}function te(t){const a=g.sessions.find(y=>y.id===t);a&&(b.value="edit",P.value=a.id,_.value="",He(a))}function Re(){var t;return g.selectedSessionId&&g.sessions.some(a=>a.id===g.selectedSessionId)?g.selectedSessionId:((t=ee.value[0])==null?void 0:t.id)||""}function De(t="basic"){le.value="detail",q.value=t}function ze(){le.value="list",q.value="basic"}function Xe(){Ae(),D.value&&De("basic")}function Ye(t){T.value||(te(t),D.value&&De("basic"))}function Je(t){f.cwd=String(t||"").trim()}async function Ke(){var a,y;const t=((a=S.value)==null?void 0:a.id)||Re();return!t||((!S.value||S.value.id!==t)&&(te(t),await he()),!((y=S.value)!=null&&y.cwd))?!1:(D.value&&De("basic"),w("open-source-browser",S.value),w("close"),!0)}function e(){return z.value?(z.value=!1,!0):K.value?(K.value=!1,!0):X.value?(X.value=!1,!0):g.open?(w("close"),!0):!1}function l(t){f.title=String(t||"")}function s(t){f.engine=We(t),f.agentEngines=f.agentEngines.filter(a=>a!==f.engine)}function o(t){f.agentEngines=[...new Set((Array.isArray(t)?t:[]).map(a=>We(a)).filter(a=>a&&a!==f.engine))]}function A(t){f.cwd=String(t||"")}function V(t){f.sessionId=String(t||"")}function ne(t){f.sessionId=String((t==null?void 0:t.id)||"").trim()}function ae(){_.value="",z.value=!1,K.value=!1,Y.value=!1,q.value="basic",le.value=D.value?"list":"detail";const t=Re();if(t){te(t);return}Ae()}async function de(){if(!(T.value||typeof g.onRefresh!="function")){_.value="";try{await Promise.all([g.onRefresh(),qe()])}catch(t){_.value=t.message}}}async function qe(){try{me.value=await At()}catch{me.value=ft()}}function Te(){x&&(clearTimeout(x),x=null)}function Ve(){c&&(c.abort(),c=null)}async function bt(){const t=String(f.cwd||"").trim();if(!g.open||!fe.value||!t){se.value=[],J.value=!1,Ve();return}const a=++U;Ve();const y=v(f.engine,t),C=G(y);if(C){se.value=C,J.value=!1;return}c=new AbortController,J.value=!0;try{const F=await Rt({engine:f.engine,cwd:t,limit:50,signal:c.signal});if(a!==U)return;const L=Array.isArray(F==null?void 0:F.items)?F.items:[];se.value=L,H(y,L)}catch(F){if((F==null?void 0:F.name)==="AbortError")return;a===U&&(se.value=[])}finally{a===U&&(J.value=!1,c=null)}}function ot(t=250){if(Te(),!g.open||!fe.value||!String(f.cwd||"").trim()){se.value=[],J.value=!1,Ve();return}x=setTimeout(()=>{x=null,bt().catch(()=>{})},t)}async function wt(t){var y;if((y=navigator.clipboard)!=null&&y.writeText&&window.isSecureContext){await navigator.clipboard.writeText(t);return}const a=document.createElement("textarea");a.value=t,a.setAttribute("readonly","true"),a.style.position="fixed",a.style.opacity="0",a.style.pointerEvents="none",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}async function rt(){const t=tt.value;if(t)try{await wt(t),Y.value=!0,h&&clearTimeout(h),h=setTimeout(()=>{Y.value=!1,h=null},1800)}catch(a){_.value=(a==null?void 0:a.message)||r("projectManager.copySessionIdFailed")}}async function dt(){if(!T.value){_.value="";try{const t=St();if(!t)return;await kt(t)}catch(t){_.value=t.message}}}function St(){if(b.value==="create"){const a=String(f.cwd||"").trim();return a?{type:"create",cwd:a,payload:{title:f.title,engine:f.engine,agentEngines:[f.engine,...f.agentEngines],cwd:a,sessionId:String(f.sessionId||"").trim()}}:(_.value=r("projectManager.directoryRequired"),null)}if(!S.value)return _.value=r("projectManager.projectMissing"),null;const t={title:f.title,engine:f.engine,agentEngines:[f.engine,...f.agentEngines]};return _e.value&&(t.cwd=f.cwd),fe.value&&(t.sessionId=String(f.sessionId||"").trim()),{type:"update",sessionId:S.value.id,payload:t}}async function kt(t){var a,y;if(t.type==="create"){ce.value=!0;try{const C=await((a=g.onCreate)==null?void 0:a.call(g,t.payload));C!=null&&C.id&&(te(C.id),w("select-session",C.id),await he(),w("project-created",C),w("close"));return}finally{ce.value=!1}}Q.value=!0;try{const C=await((y=g.onUpdate)==null?void 0:y.call(g,t.sessionId,t.payload));C!=null&&C.id&&te(C.id)}finally{Q.value=!1}}async function Ct(){var a,y;if(!S.value||O.value)return;const t=S.value.id;_.value="",O.value=!0;try{const C=await((a=g.onDelete)==null?void 0:a.call(g,t));z.value=!1;const F=g.sessions.filter($t=>$t.id!==t),L=(C==null?void 0:C.selectedSessionId)||((y=je(F)[0])==null?void 0:y.id)||"";w("select-session",L),L?(te(L),D.value&&ze()):(Ae(),D.value&&ze())}catch(C){_.value=C.message}finally{O.value=!1}}async function _t(){var a;if(!S.value||B.value)return;const t=S.value.id;_.value="",B.value=!0;try{const y=await((a=g.onReset)==null?void 0:a.call(g,t));K.value=!1;const C=(y==null?void 0:y.session)||g.sessions.find(F=>F.id===t)||null;C!=null&&C.id&&te(C.id)}catch(y){_.value=y.message}finally{B.value=!1}}return ie(()=>g.open,t=>{if(t){ae(),typeof g.onRefresh=="function"?de().catch(()=>{}):qe().catch(()=>{});return}X.value=!1,z.value=!1,K.value=!1,Y.value=!1,_.value="",Te(),Ve(),se.value=[],J.value=!1},{immediate:!0}),ie(D,t=>{t||(le.value="detail")},{immediate:!0}),ie(()=>g.sessions,()=>{if(!g.open)return;if(b.value==="create"){if(!!(String(f.title||"").trim()||String(f.cwd||"").trim())||!!String(f.sessionId||"").trim())return;const y=Re();y&&te(y);return}if(S.value){He(S.value);return}const t=Re();if(t){te(t);return}Ae()}),ie(()=>[g.open,b.value,f.engine,f.cwd,fe.value].join(`
3
+ `),()=>{ot(250)},{immediate:!0}),ie(()=>{var t;return((t=S.value)==null?void 0:t.id)||""},()=>{ot(0)}),lt(()=>{h&&(clearTimeout(h),h=null),Te(),Ve()}),W({closeTopDialog:e}),(t,a)=>(p(),m(ye,null,[I(pt,{open:K.value,title:i(r)("projectManager.confirmResetTitle"),description:S.value?i(r)("projectManager.confirmResetDescription",{title:S.value.title||i(r)("projectManager.untitledProject")}):"","confirm-text":i(r)("projectManager.confirmReset"),"cancel-text":i(r)("projectManager.keep"),loading:B.value,onCancel:a[0]||(a[0]=y=>K.value=!1),onConfirm:_t},null,8,["open","title","description","confirm-text","cancel-text","loading"]),I(pt,{open:z.value,title:i(r)("projectManager.confirmDeleteTitle"),description:S.value?i(r)("projectManager.confirmDeleteDescription",{title:S.value.title||i(r)("projectManager.untitledProject")}):"","confirm-text":i(r)("projectManager.confirmDelete"),"cancel-text":i(r)("projectManager.keep"),loading:O.value,danger:"",onCancel:a[1]||(a[1]=y=>z.value=!1),onConfirm:Ct},null,8,["open","title","description","confirm-text","cancel-text","loading"]),I(Dn,{open:X.value,"initial-path":f.cwd,suggestions:Be.value,onClose:a[2]||(a[2]=y=>X.value=!1),onSelect:Je},null,8,["open","initial-path","suggestions"]),I(yt,{open:d.open,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-5xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 overflow-hidden","close-disabled":T.value,"close-on-backdrop":!T.value,"close-on-escape":!T.value,onClose:a[12]||(a[12]=y=>w("close"))},{title:Le(()=>[n("div",ra,[I(i(Zt),{class:"h-4 w-4"}),n("span",null,u(i(r)("projectManager.managingTitle")),1)])]),default:Le(()=>{var y,C,F;return[i(D)?(p(),m("div",_a,[le.value==="list"?(p(),m("div",$a,[n("div",Ma,[I(ht,{mobile:"",busy:T.value,"editing-session-id":P.value,"format-updated-at":Pe,"get-runtime-status-class":Oe,"get-runtime-status-label":Ie,"get-thread-status-class":Ee,"get-thread-status-label":Ue,"has-sessions":ke.value,"is-current-session":ge,"is-session-running":re,mode:b.value,sessions:ee.value,onCreate:Xe,onSelect:Ye},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])])])):(p(),m("div",ja,[n("div",Ia,[n("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",disabled:T.value,onClick:ze},[I(i(Jt),{class:"h-4 w-4"}),n("span",null,u(i(r)("projectManager.projectList")),1)],8,Ea),n("div",Pa,[n("div",Aa,u(Me.value),1),b.value==="edit"&&((C=S.value)!=null&&C.cwd)?(p(),m("p",Ra,u(S.value.cwd),1)):M("",!0)])]),n("div",Da,[n("div",Ta,[n("button",{type:"button",class:N(["tool-button px-3 py-2 text-sm",q.value==="basic"?"tool-button-accent-subtle":""]),onClick:a[7]||(a[7]=L=>q.value="basic")},u(i(r)("projectManager.basicInfo")),3),n("button",{type:"button",class:N(["tool-button px-3 py-2 text-sm",q.value==="status"?"tool-button-accent-subtle":""]),disabled:b.value==="create",onClick:a[8]||(a[8]=L=>q.value="status")},u(i(r)("projectManager.status")),11,La)])]),n("div",Ba,[q.value==="basic"?(p(),m("div",Fa,[I(vt,{mobile:"",busy:T.value,"can-edit-engine":b.value!=="edit"||ve.value,"can-edit-cwd":b.value!=="edit"||_e.value,"can-edit-session-id":b.value!=="edit"||fe.value,cwd:f.cwd,"cwd-readonly-message":we.value,"duplicate-cwd-message":be.value,engine:f.engine,"agent-engines":f.agentEngines,"engine-options":$e.value,"engine-readonly-message":Z.value,"session-candidates":Fe.value,"session-candidates-loading":J.value,"session-id":f.sessionId,"session-id-copied":Y.value,"session-id-readonly-message":pe.value,title:f.title,"workspace-suggestions":Be.value,onCopySessionId:rt,onOpenDirectoryPicker:a[9]||(a[9]=L=>X.value=!0),onSelectSessionCandidate:ne,"onUpdate:cwd":A,"onUpdate:engine":s,"onUpdate:agentEngines":o,"onUpdate:sessionId":V,"onUpdate:title":l},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","agent-engines","engine-options","engine-readonly-message","session-candidates","session-candidates-loading","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"]),_.value?(p(),m("p",Na,[I(i(mt),{class:"h-4 w-4"}),n("span",null,u(_.value),1)])):M("",!0),n("div",Oa,[n("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-sm",disabled:T.value,onClick:dt},u(Ne.value),9,Ua),b.value==="edit"&&S.value?(p(),m("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:T.value||!((F=S.value)!=null&&F.cwd),onClick:Ke},u(i(r)("projectManager.viewSource")),9,Ha)):M("",!0),b.value==="edit"&&S.value?(p(),m("button",{key:1,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:T.value||xe.value,onClick:a[10]||(a[10]=L=>K.value=!0)},u(B.value?i(r)("projectManager.resettingSession"):i(r)("projectManager.newSession")),9,za)):M("",!0),b.value==="edit"&&S.value?(p(),m("button",{key:2,type:"button",class:"tool-button tool-button-danger-subtle w-full px-3 py-2 text-sm",disabled:T.value||xe.value,onClick:a[11]||(a[11]=L=>z.value=!0)},u(O.value?i(r)("projectManager.deletingProject"):i(r)("projectManager.deleteProject")),9,Ka)):M("",!0)])])):(p(),ue(oa,{key:1,"active-session":S.value,"format-updated-at":Pe,"get-runtime-status-class":Oe,"get-runtime-status-label":Ie,"get-thread-status-class":Ee,"get-thread-status-label":Ue,"is-current-session":ge,"is-session-running":re},null,8,["active-session"]))])]))])):(p(),m("div",da,[n("aside",ua,[I(ht,{busy:T.value,"editing-session-id":P.value,"format-updated-at":Pe,"get-runtime-status-class":Oe,"get-runtime-status-label":Ie,"get-thread-status-class":Ee,"get-thread-status-label":Ue,"has-sessions":ke.value,"is-current-session":ge,"is-session-running":re,mode:b.value,sessions:ee.value,onCreate:Xe,onSelect:Ye},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])]),n("div",ca,[n("div",fa,[n("div",null,[n("div",pa,[I(i(Qt),{class:"h-4 w-4"}),n("span",null,u(b.value==="create"?i(r)("projectManager.createTitle"):i(r)("projectManager.editTitle")),1)])])]),n("div",ga,[I(vt,{busy:T.value,"can-edit-engine":b.value!=="edit"||ve.value,"can-edit-cwd":b.value!=="edit"||_e.value,"can-edit-session-id":b.value!=="edit"||fe.value,cwd:f.cwd,"cwd-readonly-message":we.value,"duplicate-cwd-message":be.value,engine:f.engine,"agent-engines":f.agentEngines,"engine-options":$e.value,"engine-readonly-message":Z.value,"session-candidates":Fe.value,"session-candidates-loading":J.value,"session-id":f.sessionId,"session-id-copied":Y.value,"session-id-readonly-message":pe.value,title:f.title,"workspace-suggestions":Be.value,onCopySessionId:rt,onOpenDirectoryPicker:a[3]||(a[3]=L=>X.value=!0),onSelectSessionCandidate:ne,"onUpdate:cwd":A,"onUpdate:engine":s,"onUpdate:agentEngines":o,"onUpdate:sessionId":V,"onUpdate:title":l},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","agent-engines","engine-options","engine-readonly-message","session-candidates","session-candidates-loading","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"])]),_.value?(p(),m("p",ma,[I(i(mt),{class:"h-4 w-4"}),n("span",null,u(_.value),1)])):M("",!0),n("div",va,[n("div",ha,[b.value==="edit"&&S.value?(p(),m("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||!((y=S.value)!=null&&y.cwd),onClick:Ke},[I(i(Gt),{class:"h-4 w-4"}),n("span",null,u(i(r)("projectManager.viewSource")),1)],8,ya)):M("",!0),b.value==="edit"&&S.value?(p(),m("button",{key:1,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||xe.value,onClick:a[4]||(a[4]=L=>K.value=!0)},[I(i(Xt),{class:"h-4 w-4"}),n("span",null,u(B.value?i(r)("projectManager.resettingSession"):i(r)("projectManager.newSession")),1)],8,xa)):M("",!0),b.value==="edit"&&S.value?(p(),m("button",{key:2,type:"button",class:"tool-button tool-button-danger-subtle inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||xe.value,onClick:a[5]||(a[5]=L=>z.value=!0)},[I(i(Yt),{class:"h-4 w-4"}),n("span",null,u(O.value?i(r)("projectManager.deletingProject"):i(r)("projectManager.deleteProject")),1)],8,ba)):M("",!0)]),n("div",wa,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:a[6]||(a[6]=L=>w("close"))},u(i(r)("projectManager.close")),9,Sa),b.value==="create"&&ke.value?(p(),m("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:ae},u(i(r)("projectManager.backToList")),9,ka)):M("",!0),n("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:dt},u(Ne.value),9,Ca)])])])]))]}),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"])],64))}};export{Za as default};
@@ -1,4 +1,4 @@
1
- import{g as ut,t as U,f as tt,u as ke,a as st,b as ct}from"./index-DW5iQdjP.js";import{u as ft,g as He,b as ht,l as mt,_ as vt,a as gt,c as pt,r as xt,e as yt,D as Be,d as bt,i as wt,f as kt,h as St,j as Rt}from"./WorkbenchView-BYtJENv9.js";import{w as te,c as z,b as Q,n as at,aD as c,aE as h,aF as a,aR as he,aS as Ie,aL as Z,aQ as o,aG as V,u as t,aW as Ue,aX as $t,aN as O,aI as ve,aT as Ft,ak as _t,aJ as we,f as Pt,a$ as We}from"./vendor-misc-u-M8sNMf.js";import{c as Ct,D as Te,f as Ke,M as Lt,V as Tt,p as It,k as Ge,C as Je,R as Qe,b as Dt,i as Mt,h as nt,F as Xe,z as Ye}from"./vendor-ui-BglsaDbv.js";import"./vendor-router-Dn8q3tJM.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";function oe(e,r,i=""){const w=r==="run"?"run":r==="task"?"task":"workspace";return[String(e||"").trim(),w,String(i||"").trim()].join("::")}function Ne(e="",r=""){return`${String(e||"").trim()}::${String(r||"").trim()}`}function jt(e=""){return`${String(e||"").trim()}::`}function it(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ye(e,r){const i=e.get(r);return i?(e.delete(r),e.set(r,i),it(i)):null}function be(e,r,i,w=0){for(e.delete(r),e.set(r,it(i));w>0&&e.size>w;){const b=e.keys().next().value;if(typeof b>"u")break;e.delete(b)}}function fe(e=""){const r=String(e||"").trim().toUpperCase();return r==="A"||r==="D"?r:"M"}function At(e=""){const r=String(e||"");if(!r)return[];const i=r.split(`
1
+ import{g as ut,t as U,f as tt,u as ke,a as st,b as ct}from"./index-Ch8uSQYT.js";import{u as ft,g as He,b as ht,l as mt,_ as vt,a as gt,c as pt,r as xt,e as yt,D as Be,d as bt,i as wt,f as kt,h as St,j as Rt}from"./WorkbenchView-pIUuQsCk.js";import{w as te,c as z,b as Q,n as at,aD as c,aE as h,aF as a,aR as he,aS as Ie,aL as Z,aQ as o,aG as V,u as t,aW as Ue,aX as $t,aN as O,aI as ve,aT as Ft,ak as _t,aJ as we,f as Pt,a$ as We}from"./vendor-misc-u-M8sNMf.js";import{c as Ct,D as Te,f as Ke,M as Lt,V as Tt,p as It,k as Ge,C as Je,R as Qe,b as Dt,i as Mt,h as nt,F as Xe,z as Ye}from"./vendor-ui-BglsaDbv.js";import"./vendor-router-Dn8q3tJM.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";function oe(e,r,i=""){const w=r==="run"?"run":r==="task"?"task":"workspace";return[String(e||"").trim(),w,String(i||"").trim()].join("::")}function Ne(e="",r=""){return`${String(e||"").trim()}::${String(r||"").trim()}`}function jt(e=""){return`${String(e||"").trim()}::`}function it(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ye(e,r){const i=e.get(r);return i?(e.delete(r),e.set(r,i),it(i)):null}function be(e,r,i,w=0){for(e.delete(r),e.set(r,it(i));w>0&&e.size>w;){const b=e.keys().next().value;if(typeof b>"u")break;e.delete(b)}}function fe(e=""){const r=String(e||"").trim().toUpperCase();return r==="A"||r==="D"?r:"M"}function At(e=""){const r=String(e||"");if(!r)return[];const i=r.split(`
2
2
  `),w=[];let b=0,T=0;return i.forEach((v,u)=>{const I=v.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(I){b=Number(I[1]),T=Number(I[2]),w.push({id:`hunk-${u}`,kind:"hunk",oldNumber:"",newNumber:"",content:v});return}if(v.startsWith("+")&&!v.startsWith("+++")){w.push({id:`line-${u}`,kind:"add",oldNumber:"",newNumber:T,content:v}),T+=1;return}if(v.startsWith("-")&&!v.startsWith("---")){w.push({id:`line-${u}`,kind:"delete",oldNumber:b,newNumber:"",content:v}),b+=1;return}if(v.startsWith(" ")){w.push({id:`line-${u}`,kind:"context",oldNumber:b,newNumber:T,content:v}),b+=1,T+=1;return}w.push({id:`line-${u}`,kind:"meta",oldNumber:"",newNumber:"",content:v})}),w}function Ht(e=""){const r=String(e||"").trim();if(!r)return"";const i=r.match(/^当前分支已从 (.+) 切换到 (.+)$/);return i?U("diffReview.warningBranchChanged",{from:i[1],to:i[2]}):r==="当前 HEAD 已不在基线 commit 的后续历史中,仓库可能经历了 reset、rebase 或切分支"?U("diffReview.warningHeadDetachedFromBaseline"):r}function De(e=""){const r=String(e||"").trim();if(!r)return"";const w=new Map([["二进制文件暂不支持在线 diff 预览。","diffReview.binaryPreviewUnavailable"],["文件内容较大,暂不展示具体 diff。","diffReview.fileTooLarge"],["diff 内容较长,暂不在页面内完整展示。","diffReview.diffTooLong"],["diff 内容较长,当前仅展示摘要预览。","diffReview.diffPreviewOnly"],["当前工作目录不是 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(r);return w?U(w):/^git diff 计算超时(>\d+ms)[。.]?$/.test(r)||r==="该文件 diff 计算超时,暂不在线展示详细内容。"?U("diffReview.fileDiffTimedOut"):r}function Ve(e=null){return!e||typeof e!="object"?e:{...e,reason:De(e.reason),warnings:Array.isArray(e.warnings)?e.warnings.map(r=>Ht(r)).filter(Boolean):[],files:Array.isArray(e.files)?e.files.map(r=>({...r,message:De(r==null?void 0:r.message)})):[]}}function Bt(e=[],r="",i=0){const w=Math.max(0,Number(i)||0);if(!w)return[];const b=String(r||"").trim(),T=Array.isArray(e)?e:[],v=[],u=new Set;return b&&T.find(R=>String((R==null?void 0:R.path)||"").trim()===b)&&(v.push(b),u.add(b)),T.forEach(I=>{const R=String((I==null?void 0:I.path)||"").trim();!R||u.has(R)||v.length>=w||(v.push(R),u.add(R))}),v}function Nt(e){const r=Q("workspace"),i=Q(""),w=Q(""),b=Q("all"),T=Q(""),v=Q([]),u=Q(null),I=Q(!1),R=Q(!1),M=Q(""),N=Q(!1),G=Q(null),j=Q(0),E=new Map,se=ft();let _=0,$=0,f="",C="",p="",g=-1;const X=new Map,J=new Map,q=new Map,Y=new Map,W=12e3,re=3,de=z(()=>v.value.filter(s=>s.completed)),n=z(()=>{var l;const s={all:0,A:0,M:0,D:0};return(((l=u.value)==null?void 0:l.files)||[]).forEach(m=>{const y=fe(m==null?void 0:m.status);s.all+=1,s[y]+=1}),s}),d=z(()=>{var m;const s=((m=u.value)==null?void 0:m.files)||[],l=String(T.value||"").trim().toLowerCase();return s.filter(y=>b.value!=="all"&&fe(y==null?void 0:y.status)!==b.value?!1:l?String((y==null?void 0:y.path)||"").toLowerCase().includes(l):!0)}),k=z(()=>{const s=d.value;return s.find(l=>l.path===w.value)||s[0]||null}),A=z(()=>{var s;return At(((s=k.value)==null?void 0:s.patch)||"")}),P=z(()=>A.value.map((s,l)=>({...s,index:l})).filter(s=>s.kind==="hunk")),ae=z(()=>Bt(d.value,w.value,re)),x=z(()=>{var s,l;return R.value&&!((l=(s=u.value)==null?void 0:s.summary)!=null&&l.statsComplete)}),H=z(()=>{var m;const s=((m=u.value)==null?void 0:m.baseline)||null;if(!(s!=null&&s.createdAt)&&!(s!=null&&s.headShort))return"";const l=[];return s.createdAt&&l.push(U("diffReview.baselineTime",{value:tt(s.createdAt)})),s.branch&&l.push(U("diffReview.baselineBranch",{value:s.branch})),s.headShort&&l.push(U("diffReview.baselineCommit",{value:s.headShort})),s.currentHeadShort&&l.push(U("diffReview.currentHead",{value:s.currentHeadShort})),l.join(" · ")});function L(s){return(s==null?void 0:s.status)==="completed"?U("diffReview.completed"):(s==null?void 0:s.status)==="error"?U("diffReview.failed"):(s==null?void 0:s.status)==="interrupted"?U("diffReview.interrupted"):U("diffReview.stopped")}function me(s,l){if(s){if(l){E.set(s,l);return}E.delete(s)}}function ue(s,l={}){const m=P.value;if(!m.length)return;const y=Math.min(Math.max(0,Number(s)||0),m.length-1),K=m[y],B=E.get(K.id);B&&(j.value=y,B.scrollIntoView({block:l.block||"center",behavior:l.behavior||"smooth"}))}function le(s=1){P.value.length&&ue(j.value+s)}function S(s){return`${new Date((s==null?void 0:s.startedAt)||(s==null?void 0:s.createdAt)).toLocaleString(ut())} · ${L(s)}`}function Se(){const s=de.value;if(!s.length){i.value="";return}s.some(l=>l.id===i.value)||(i.value=s[0].id)}function ce(){const s=d.value;if(!s.length){w.value="";return}s.some(l=>l.path===w.value)||(w.value=s[0].path)}function Re(s=""){return fe(s)==="A"?U("diffReview.added"):fe(s)==="D"?U("diffReview.deleted"):U("diffReview.modified")}function $e(s=""){return fe(s)==="A"?"theme-status-success":fe(s)==="D"?"theme-status-danger":"theme-status-warning"}function Fe(s="all"){return s==="A"?U("diffReview.added"):s==="D"?U("diffReview.deleted"):s==="M"?U("diffReview.modified"):U("diffReview.all")}function F(s="all"){return b.value===s?"theme-filter-active":"theme-filter-idle"}function _e(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 ge(s,l=""){const m=String(l||"").trim();m&&Array.from(s.keys()).forEach(y=>{String(y||"").startsWith(m)&&s.delete(y)})}function lt(){const s=jt(e.taskSlug);ge(X,s),ge(J,s),ge(q,s)}function Me(){const s=r.value==="run"?"run":r.value==="task"?"task":"workspace",l=s==="run"?i.value:"",m=oe(e.taskSlug,s,l);return{scope:s,runId:l,signature:m}}function rt(s,l="after"){const m=String((s==null?void 0:s.path)||"").trim();if(!e.taskSlug||!m)return"";const y=Me();return ht(e.taskSlug,{scope:y.scope,runId:y.runId,filePath:m,side:l})}function ze(s=""){var m;const l=String(s||"").trim();return l&&(((m=u.value)==null?void 0:m.files)||[]).find(y=>y.path===l)||null}function Oe(s=null){return!!s&&!s.patchLoaded&&!s.binary&&!s.tooLarge&&!s.message}function pe(s="",l="",m=null,y=null){var B;const K=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");return s!==K||!m||!((B=u.value)!=null&&B.files)?!1:(u.value={...u.value,baseline:(y==null?void 0:y.baseline)||u.value.baseline||null,warnings:(y==null?void 0:y.warnings)||u.value.warnings||[],files:u.value.files.map(D=>D.path===l?m:D)},!0)}async function Ee(s="",l={}){const m=String(s||"").trim(),y=String(l.signature||"").trim();if(!m||!y)return null;const K=Ne(y,m),B=ye(q,K);if(B)return{detailedFile:B,normalizedPayload:null};const D=Y.get(K);if(D)return D;const ne=(async()=>{try{const ee=await He(e.taskSlug,{scope:l.scope,runId:l.runId,filePath:m,timeoutMs:W}),ie=Ve(ee),xe=(ie.files||[]).find(Le=>Le.path===m);if(!xe)throw new Error(U("diffReview.noFileDiffContent"));return be(q,K,xe,120),{detailedFile:xe,normalizedPayload:ie}}catch(ee){return{error:ee}}finally{Y.delete(K)}})();return Y.set(K,ne),ne}async function je(){var l,m;if(!e.taskSlug||!e.active||!((l=u.value)!=null&&l.supported))return;const s=Me();for(const y of ae.value){const K=ze(y);if(!Oe(K))continue;const B=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(s.signature!==B)return;const D=await Ee(y,s);if(D){if(D.error){const ne=De(((m=D.error)==null?void 0:m.message)||"")||U("diffReview.fileDiffTimedOut"),ee={...K,patch:"",patchLoaded:!0,tooLarge:!0,message:ne};be(q,Ne(s.signature,y),ee,120),pe(s.signature,y,ee,null);continue}pe(s.signature,y,D.detailedFile,D.normalizedPayload)}}}async function ot(){if(!e.taskSlug){v.value=[],i.value="",p="",g=-1;return}const s=se.getTaskRunSyncVersion(e.taskSlug);if(p===e.taskSlug&&g===s)return;const l=await mt(e.taskSlug,{limit:20,events:"none"});v.value=l.items||[],p=e.taskSlug,g=s,Se()}async function Ae(){if(!e.taskSlug||!e.active)return;const s=++_;I.value=!0,R.value=!1,M.value="";try{const l=r.value==="run"?"run":r.value==="task"?"task":"workspace";l==="run"&&await ot();const m=oe(e.taskSlug,l,l==="run"?i.value:"");if(l==="run"&&!i.value){u.value={supported:!1,reason:U("diffReview.noReviewRuns"),repoRoot:"",summary:{fileCount:0,additions:0,deletions:0,statsComplete:!0},files:[]},ce();return}const y=ye(X,m);if(y){u.value=y,f=m;const D=ye(J,m);D?(u.value={...y,baseline:D.baseline||y.baseline||null,warnings:D.warnings||y.warnings||[],summary:D.summary||y.summary},C=m):C="",ce(),Pe().catch(()=>{}),je().catch(()=>{}),D||qe().catch(()=>{});return}const K=await He(e.taskSlug,{scope:l,runId:l==="run"?i.value:"",includeStats:!1});if(s!==_)return;const B=Ve(K);u.value=B,be(X,m,B,36),f=m,C="",ce(),Pe().catch(()=>{}),je().catch(()=>{}),qe().catch(()=>{})}catch(l){if(s!==_)return;M.value=l.message,u.value=null}finally{s===_&&(I.value=!1)}}async function qe(){var K,B,D;if(!e.taskSlug||!e.active||!((K=u.value)!=null&&K.supported))return;const s=r.value==="run"?"run":r.value==="task"?"task":"workspace",l=s==="run"?i.value:"",m=oe(e.taskSlug,s,l);if(C===m&&((D=(B=u.value)==null?void 0:B.summary)!=null&&D.statsComplete))return;const y=ye(J,m);if(y){u.value={...u.value,baseline:y.baseline||u.value.baseline||null,warnings:y.warnings||u.value.warnings||[],summary:y.summary||u.value.summary},C=m,R.value=!1;return}R.value=!0;try{const ne=await He(e.taskSlug,{scope:s,runId:l,includeFiles:!1,includeStats:!0}),ee=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(m!==ee||!u.value)return;const ie=Ve(ne);u.value={...u.value,baseline:ie.baseline||u.value.baseline||null,warnings:ie.warnings||u.value.warnings||[],summary:ie.summary||u.value.summary},be(J,m,{baseline:ie.baseline||null,warnings:ie.warnings||[],summary:ie.summary||null},36),C=m}catch{}finally{const ne=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");m===ne&&(R.value=!1)}}async function Pe(){var D,ne;const s=String(w.value||"").trim();if(!e.taskSlug||!e.active||!s)return;const l=Me(),m=ze(s);if(!Oe(m))return;const y=Ne(l.signature,s),K=ye(q,y);if(K&&((D=u.value)!=null&&D.files)){pe(l.signature,s,K,null);return}const B=++$;N.value=!0;try{const ee=await Ee(s,l);if(B!==$||!ee)return;const ie=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(l.signature!==ie)return;if(ee.error){const xe=De(((ne=ee.error)==null?void 0:ne.message)||"")||U("diffReview.fileDiffTimedOut"),Le={...m,patch:"",patchLoaded:!0,tooLarge:!0,message:xe};be(q,y,Le,120),pe(l.signature,s,Le,null);return}pe(l.signature,s,ee.detailedFile,ee.normalizedPayload)}finally{B===$&&(N.value=!1,String(w.value||"").trim()!==s&&Pe().catch(()=>{}))}}function Ce({force:s=!1}={}){if(!e.taskSlug||!e.active)return;const l=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");!s&&l===f||Ae().catch(()=>{})}async function dt(){!e.taskSlug||!e.active||I.value||(lt(),f="",C="",p="",g=-1,await Ae())}return te(()=>[e.taskSlug,e.active,r.value,i.value],([s,l],m=[])=>{const y=m[0]||"";s!==y&&(w.value="",f="",v.value=[],i.value="",p="",g=-1,C=""),!(!s||!l)&&Ce()},{immediate:!0}),te(()=>{var s,l;return[b.value,((l=(s=u.value)==null?void 0:s.files)==null?void 0:l.length)||0]},()=>{ce()}),te(()=>[w.value,P.value.length],()=>{j.value=0,E.clear(),at(()=>{var s,l;P.value.length?ue(0,{behavior:"auto",block:"start"}):(l=(s=G.value)==null?void 0:s.scrollTo)==null||l.call(s,{top:0,behavior:"auto"})})}),te(()=>w.value,()=>{Pe().catch(()=>{})},{immediate:!0}),te(()=>{var s;return[e.active,(s=u.value)==null?void 0:s.supported,ae.value.join(`
3
3
  `)]},([s,l])=>{!s||!l||je().catch(()=>{})}),te(()=>[e.preferredScope,e.preferredRunId,e.focusToken],([s,l,m],y=[])=>{const K=Number(y[2]||0),B=s==="run"?"run":s==="task"?"task":"workspace",D=B==="run"&&l?String(l||""):"",ne=r.value!==B,ee=B==="run"&&D&&i.value!==D;r.value=B,D&&(i.value=D),B!=="run"&&(i.value=""),!ne&&!ee&&e.active&&e.taskSlug&&m!==K&&(f="",Ce())},{immediate:!0}),te(()=>se.readyVersion.value,()=>{!e.active||!e.taskSlug||(p="",g=-1,f="",C="",Ce({force:!0}))}),te(()=>se.getTaskDiffSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||(p="",g=-1,C="",f="",Ce({force:!0}))}),{activeHunkIndex:j,baselineMetaText:H,diffPayload:u,diffScope:r,error:M,fileSearch:T,filteredFiles:d,getFilterButtonClass:F,getFilterLabel:Fe,getFileBlobUrl:rt,getPatchLineClass:_e,getRunStatusLabel:L,getStatusClass:$e,getStatusLabel:Re,jumpToAdjacentHunk:le,loadDiff:Ae,loading:I,normalizeFileStatus:fe,patchLoading:N,patchViewportRef:G,runs:v,selectedFile:k,selectedFilePath:w,selectedPatchHunks:P,selectedPatchLines:A,selectedRunId:i,setPatchLineRef:me,showSummarySkeleton:x,statsLoading:R,statusCounts:n,statusFilter:b,terminalRuns:de,formatRunOptionLabel:S,refreshDiff:dt}}const Vt={class:"mb-3 grid grid-cols-2 gap-2"},Ut=["onClick"],zt={class:"theme-input-shell mb-3 flex items-center gap-2 rounded-sm border px-3 py-2 text-xs text-[var(--theme-textMuted)]"},Ot=["placeholder"],Et={key:0,class:"theme-empty-state theme-empty-state-strong mb-3 px-3 py-2 text-[11px]"},qt={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Wt={key:2,class:"theme-empty-state px-3 py-4 text-xs"},Kt={key:3,class:"space-y-1"},Gt=["onClick","onKeydown"],Jt={class:"min-w-0 flex-1"},Qt={class:"flex items-start gap-2"},Xt={class:"theme-list-item-title min-w-0 flex-1 break-all"},Yt={key:0,class:"theme-status-info inline-flex shrink-0 items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Zt={class:"theme-list-item-meta mt-1"},Ze={__name:"TaskDiffFileList",props:{diffPayload:{type:Object,default:null},fileSearch:{type:String,default:""},autoFocusSelected:{type:Boolean,default:!1},filteredFiles:{type:Array,default:()=>[]},focusToken:{type:Number,default:0},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:r}){const i=e,w=r,{t:b}=ke(),T=new Map,v=Q(0),u=Q(0),I=z({get:()=>i.fileSearch,set:_=>w("update:fileSearch",_)}),R=z({get:()=>i.statusFilter,set:_=>w("update:statusFilter",_)}),M=z(()=>{var _;return Array.isArray((_=i.diffPayload)==null?void 0:_.files)&&i.diffPayload.files.length>0});function N(_,$){if($){T.set(_,$);return}T.delete(_)}function G(_){at(()=>{var f,C;const $=T.get(_);(f=$==null?void 0:$.focus)==null||f.call($),(C=$==null?void 0:$.scrollIntoView)==null||C.call($,{block:"nearest",inline:"nearest"})})}function j(){!i.autoFocusSelected||!i.selectedFilePath||v.value===u.value||(u.value=v.value,G(i.selectedFilePath))}function E(_=1,$=""){const f=Array.isArray(i.filteredFiles)?i.filteredFiles:[];if(!f.length)return;const C=f.findIndex(q=>q.path===$),p=f.findIndex(q=>q.path===i.selectedFilePath),X=(Math.max(0,C>=0?C:p)+_+f.length)%f.length,J=f[X];J!=null&&J.path&&(w("select-file",J.path),G(J.path))}function se(_,$){const f=String((_==null?void 0:_.key)||"");if(f==="ArrowDown"){_.preventDefault(),E(1,$);return}if(f==="ArrowUp"){_.preventDefault(),E(-1,$);return}(f==="Enter"||f===" ")&&$&&(_.preventDefault(),w("select-file",$))}return te(()=>i.focusToken,_=>{v.value=_,j()},{immediate:!0}),te(()=>i.selectedFilePath,()=>{j()}),(_,$)=>(c(),h(he,null,[a("div",Vt,[(c(),h(he,null,Ie(["all","A","M","D"],f=>a("button",{key:f,type:"button",class:Z(["inline-flex w-full items-center justify-center gap-1 whitespace-nowrap rounded-sm border px-2 py-1 text-[11px] transition",e.getFilterButtonClass(f)]),onClick:C=>R.value=f},o(e.getFilterLabel(f))+" "+o(e.statusCounts[f]||0),11,Ut)),64))]),a("label",zt,[V(t(Ct),{class:"h-3.5 w-3.5 shrink-0"}),Ue(a("input",{"onUpdate:modelValue":$[0]||($[0]=f=>I.value=f),type:"text",placeholder:t(b)("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,Ot),[[$t,I.value]])]),e.showSummarySkeleton?(c(),h("div",Et,o(t(b)("diffReview.statsPending")),1)):O("",!0),M.value?e.filteredFiles.length?(c(),h("div",Kt,[(c(!0),h(he,null,Ie(e.filteredFiles,f=>{var C;return c(),h("button",{key:f.path,ref_for:!0,ref:p=>N(f.path,p),type:"button",class:Z(["theme-list-row focus:outline-none",f.path===e.selectedFilePath?"theme-list-item-active":"theme-list-item-hover"]),onClick:p=>w("select-file",f.path),onKeydown:p=>se(p,f.path)},[a("span",{class:Z(["theme-list-item-badge",e.getStatusClass(f.status)])},o(e.getStatusLabel(f.status)),3),a("div",Jt,[a("div",Qt,[a("div",Xt,o(f.path),1),f.binary?(c(),h("span",Yt,o(t(b)("diffReview.binaryTag")),1)):O("",!0)]),a("div",Zt,o(f.binary?((C=f.binaryPreview)==null?void 0:C.mimeType)||t(b)("diffReview.binaryPreviewTitle"):f.statsLoaded?`+${f.additions} / -${f.deletions}`:t(b)("diffReview.statsOnDemand")),1)])],42,Gt)}),128))])):(c(),h("div",Wt,o(t(b)("diffReview.noMatches")),1)):(c(),h("div",qt,o(t(b)("diffReview.noChanges")),1))],64))}},es={class:"flex h-full min-h-0 flex-col overflow-hidden"},ts={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-[12px]"},ss={class:"flex flex-wrap items-center gap-2"},as={class:"font-medium text-[var(--theme-textPrimary)]"},ns={class:"theme-muted-text"},is={class:"min-h-0 flex-1 overflow-auto p-4"},ls={key:0,class:"grid min-h-full gap-4 md:grid-cols-2"},rs={class:"theme-inline-panel flex min-h-[20rem] flex-col rounded-sm border p-3"},os={class:"mb-3 flex items-center justify-between gap-2"},ds={class:"min-w-0"},us={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},cs={class:"theme-muted-text mt-1 text-[11px]"},fs=["href","download","title"],hs={key:0,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},ms={key:1,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},vs={key:2,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},gs=["title"],ps=["src","alt"],xs=["src"],ys=["src"],bs=["src","title"],ws={class:"theme-inline-panel flex min-h-[20rem] flex-col rounded-sm border p-3"},ks={class:"mb-3 flex items-center justify-between gap-2"},Ss={class:"min-w-0"},Rs={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},$s={class:"theme-muted-text mt-1 text-[11px]"},Fs=["href","download","title"],_s={key:0,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Ps={key:1,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Cs={key:2,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Ls=["title"],Ts=["src","alt"],Is=["src"],Ds=["src"],Ms=["src","title"],js={key:1,class:"theme-inline-panel flex min-h-full flex-col rounded-sm border p-4"},As={class:"flex items-center gap-2"},Hs={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Bs={class:"mt-4 grid gap-3 md:grid-cols-2"},Ns={class:"rounded-sm border border-dashed px-3 py-3"},Vs={class:"text-xs font-medium text-[var(--theme-textPrimary)]"},Us={class:"theme-muted-text mt-2 space-y-1 text-[12px]"},zs={key:0},Os=["href","download"],Es={class:"rounded-sm border border-dashed px-3 py-3"},qs={class:"text-xs font-medium text-[var(--theme-textPrimary)]"},Ws={class:"theme-muted-text mt-2 space-y-1 text-[12px]"},Ks={key:0},Gs=["href","download"],Js={__name:"TaskDiffBinaryPreview",props:{getFileBlobUrl:{type:Function,default:()=>""},selectedFile:{type:Object,default:null}},setup(e){const r=e,{t:i}=ke(),w=Q(""),b=Q({before:!1,after:!1});function T(p=0){const g=Math.max(0,Number(p)||0);return g<1024?`${g} B`:g<1024*1024?`${(g/1024).toFixed(g<10*1024?1:0)} KB`:`${(g/(1024*1024)).toFixed(g<10*1024*1024?1:0)} MB`}function v(p="after"){var g,X;return((X=(g=r.selectedFile)==null?void 0:g.binaryPreview)==null?void 0:X[p])||{exists:!1,size:0,hashShort:"",mimeType:"",previewKind:"binary",tooLarge:!1}}function u(p="after"){return r.selectedFile?r.getFileBlobUrl(r.selectedFile,p):""}function I(p="binary"){return p==="image"?Ke:p==="audio"?Lt:p==="video"?Tt:p==="pdf"?It:Ke}const R=z(()=>{var p,g;return String(((g=(p=r.selectedFile)==null?void 0:p.binaryPreview)==null?void 0:g.kind)||"binary")}),M=z(()=>v("before")),N=z(()=>v("after")),G=z(()=>u("before")),j=z(()=>u("after")),E=z(()=>{var p;return String(((p=r.selectedFile)==null?void 0:p.path)||"").trim()}),se=z(()=>["image","audio","video","pdf"].includes(R.value)),_=z(()=>R.value!=="image"?[]:[M.value.exists&&!M.value.tooLarge&&!b.value.before?G.value:"",N.value.exists&&!N.value.tooLarge&&!b.value.after?j.value:""].filter(Boolean));function $(p){return(p==null?void 0:p.exists)&&!(p!=null&&p.tooLarge)}function f(p="before"){b.value={...b.value,[p]:!0}}function C(p=""){const g=String(p||"").trim();g&&(w.value=g)}return te(()=>{var p,g,X,J,q,Y,W;return[String(((p=r.selectedFile)==null?void 0:p.path)||"").trim(),String(G.value||"").trim(),String(j.value||"").trim(),String(((J=(X=(g=r.selectedFile)==null?void 0:g.binaryPreview)==null?void 0:X.before)==null?void 0:J.hash)||"").trim(),String(((W=(Y=(q=r.selectedFile)==null?void 0:q.binaryPreview)==null?void 0:Y.after)==null?void 0:W.hash)||"").trim()].join(`
4
4
  `)},()=>{w.value="",b.value={before:!1,after:!1}},{immediate:!0}),(p,g)=>{var X,J,q,Y;return c(),h("div",es,[a("div",ts,[a("div",ss,[a("span",as,o(E.value),1),a("span",ns,o(t(i)("diffReview.binaryPreviewTitle")),1)])]),a("div",is,[se.value?(c(),h("div",ls,[a("section",rs,[a("div",os,[a("div",ds,[a("p",us,o(t(i)("diffReview.binaryBefore")),1),a("p",cs,o(M.value.exists?`${T(M.value.size)} · ${M.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1)]),$(M.value)?(c(),h("a",{key:0,class:"theme-icon-button h-8 w-8",href:G.value,download:((X=e.selectedFile)==null?void 0:X.path)||"before.bin",title:t(i)("diffReview.downloadBinarySide")},[V(t(Te),{class:"h-4 w-4"})],8,fs)):O("",!0)]),M.value.exists?M.value.tooLarge?(c(),h("div",ms,o(t(i)("diffReview.binaryPreviewTooLarge")),1)):b.value.before?(c(),h("div",vs,o(t(i)("diffReview.binaryPreviewUnavailable")),1)):R.value==="image"?(c(),h("button",{key:3,type:"button",class:"task-diff-binary-image-wrap flex min-h-[16rem] flex-1 cursor-zoom-in items-center justify-center rounded-sm border p-3",title:t(i)("diffReview.openImagePreview"),onClick:g[1]||(g[1]=W=>C(G.value))},[a("img",{src:G.value,alt:`${E.value} before`,class:"max-h-full max-w-full object-contain",onError:g[0]||(g[0]=W=>f("before"))},null,40,ps)],8,gs)):R.value==="audio"?(c(),h("audio",{key:4,class:"w-full",src:G.value,controls:"",preload:"metadata",onError:g[2]||(g[2]=W=>f("before"))},null,40,xs)):R.value==="video"?(c(),h("video",{key:5,class:"max-h-[26rem] w-full rounded-sm border bg-black",src:G.value,controls:"",preload:"metadata",onError:g[3]||(g[3]=W=>f("before"))},null,40,ys)):R.value==="pdf"?(c(),h("iframe",{key:6,class:"min-h-[26rem] w-full rounded-sm border bg-white",src:G.value,title:`${E.value} before`,onError:g[4]||(g[4]=W=>f("before"))},null,40,bs)):O("",!0):(c(),h("div",hs,o(t(i)("diffReview.binarySideMissing")),1))]),a("section",ws,[a("div",ks,[a("div",Ss,[a("p",Rs,o(t(i)("diffReview.binaryAfter")),1),a("p",$s,o(N.value.exists?`${T(N.value.size)} · ${N.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1)]),$(N.value)?(c(),h("a",{key:0,class:"theme-icon-button h-8 w-8",href:j.value,download:((J=e.selectedFile)==null?void 0:J.path)||"after.bin",title:t(i)("diffReview.downloadBinarySide")},[V(t(Te),{class:"h-4 w-4"})],8,Fs)):O("",!0)]),N.value.exists?N.value.tooLarge?(c(),h("div",Ps,o(t(i)("diffReview.binaryPreviewTooLarge")),1)):b.value.after?(c(),h("div",Cs,o(t(i)("diffReview.binaryPreviewUnavailable")),1)):R.value==="image"?(c(),h("button",{key:3,type:"button",class:"task-diff-binary-image-wrap flex min-h-[16rem] flex-1 cursor-zoom-in items-center justify-center rounded-sm border p-3",title:t(i)("diffReview.openImagePreview"),onClick:g[6]||(g[6]=W=>C(j.value))},[a("img",{src:j.value,alt:`${E.value} after`,class:"max-h-full max-w-full object-contain",onError:g[5]||(g[5]=W=>f("after"))},null,40,Ts)],8,Ls)):R.value==="audio"?(c(),h("audio",{key:4,class:"w-full",src:j.value,controls:"",preload:"metadata",onError:g[7]||(g[7]=W=>f("after"))},null,40,Is)):R.value==="video"?(c(),h("video",{key:5,class:"max-h-[26rem] w-full rounded-sm border bg-black",src:j.value,controls:"",preload:"metadata",onError:g[8]||(g[8]=W=>f("after"))},null,40,Ds)):R.value==="pdf"?(c(),h("iframe",{key:6,class:"min-h-[26rem] w-full rounded-sm border bg-white",src:j.value,title:`${E.value} after`,onError:g[9]||(g[9]=W=>f("after"))},null,40,Ms)):O("",!0):(c(),h("div",_s,o(t(i)("diffReview.binarySideMissing")),1))])])):(c(),h("div",js,[a("div",As,[(c(),ve(Ft(I(R.value)),{class:"h-5 w-5 text-[var(--theme-textSecondary)]"})),a("span",Hs,o(t(i)("diffReview.binaryMetaTitle")),1)]),a("div",Bs,[a("div",Ns,[a("div",Vs,o(t(i)("diffReview.binaryBefore")),1),a("div",Us,[a("p",null,o(M.value.exists?`${T(M.value.size)} · ${M.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1),M.value.mimeType?(c(),h("p",zs,o(M.value.mimeType),1)):O("",!0)]),$(M.value)?(c(),h("a",{key:0,class:"tool-button mt-3 inline-flex items-center gap-2 px-3 py-2 text-xs",href:G.value,download:((q=e.selectedFile)==null?void 0:q.path)||"before.bin"},[V(t(Te),{class:"h-3.5 w-3.5"}),a("span",null,o(t(i)("diffReview.downloadBinarySide")),1)],8,Os)):O("",!0)]),a("div",Es,[a("div",qs,o(t(i)("diffReview.binaryAfter")),1),a("div",Ws,[a("p",null,o(N.value.exists?`${T(N.value.size)} · ${N.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1),N.value.mimeType?(c(),h("p",Ks,o(N.value.mimeType),1)):O("",!0)]),$(N.value)?(c(),h("a",{key:0,class:"tool-button mt-3 inline-flex items-center gap-2 px-3 py-2 text-xs",href:j.value,download:((Y=e.selectedFile)==null?void 0:Y.path)||"after.bin"},[V(t(Te),{class:"h-3.5 w-3.5"}),a("span",null,o(t(i)("diffReview.downloadBinarySide")),1)],8,Gs)):O("",!0)])])]))]),V(vt,{modelValue:w.value,"onUpdate:modelValue":g[10]||(g[10]=W=>w.value=W),images:_.value},null,8,["modelValue","images"])])}}},Qs=st(Js,[["__scopeId","data-v-4703ec91"]]),Xs={key:0,class:"flex h-full min-h-0 flex-col overflow-hidden"},Ys={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-[12px]"},Zs={class:"space-y-3 sm:hidden"},ea={class:"flex items-start gap-2"},ta={class:"min-w-0 break-all font-medium text-[var(--theme-textPrimary)]"},sa={class:"flex items-center justify-between gap-3"},aa={class:"min-w-0"},na={class:"opacity-75"},ia={key:0,class:"theme-muted-text mt-1 text-[11px]"},la=["disabled"],ra={class:"min-w-[64px] text-center text-[12px] text-[var(--theme-textSecondary)]"},oa=["disabled"],da={class:"hidden items-center gap-3 sm:flex"},ua={class:"flex min-w-0 flex-1 flex-wrap items-center gap-2"},ca={class:"break-all font-medium text-[var(--theme-textPrimary)]"},fa={class:"opacity-75"},ha={key:0,class:"theme-muted-text text-[11px]"},ma=["disabled"],va={class:"min-w-[64px] text-center text-[12px] text-[var(--theme-textSecondary)]"},ga=["disabled"],pa={key:1,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},xa={class:"theme-empty-state px-4 py-4"},ya={key:2,class:"theme-muted-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},ba={class:"task-diff-view min-w-max px-4 py-4 font-mono"},wa={key:0,class:"theme-inline-panel theme-secondary-text mb-3 rounded-sm border border-dashed px-3 py-2 text-[12px]"},ka=["data-line-id","data-line-kind"],Sa={class:"task-diff-row__number select-none"},Ra={class:"task-diff-row__number select-none"},$a=["innerHTML"],Fa={key:4,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},_a={class:"theme-empty-state px-4 py-4"},Pa={key:1,class:"theme-muted-text flex h-full items-center justify-center px-5 text-[12px]"},Ca={__name:"TaskDiffPatchView",props:{activeHunkIndex:{type:Number,default:0},getPatchLineClass:{type:Function,default:()=>""},getFileBlobUrl:{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:()=>{}}},emits:["insert-code-context"],setup(e,{emit:r}){const i=e,w=r,{t:b}=ke(),{isDark:T}=ct(),v=Q([]),u=z(()=>{var n;return wt(((n=i.selectedFile)==null?void 0:n.path)||"")}),I=Q(null),R=new Map,M=z(()=>{var n,d;return!!((n=i.selectedFile)!=null&&n.binary&&((d=i.selectedFile)!=null&&d.binaryPreview))});function N(n={}){return["add","delete","context"].includes(String((n==null?void 0:n.kind)||"").trim())}function G(n=""){const d=String(n||"").trim();return d&&v.value.find(k=>k.id===d)||null}const{selectedRows:j,selectionAction:E,clearSelectionState:se,handleSelectionMouseUp:_,updateSelectionActionFromDom:$}=gt({getContainer:()=>I.value,isActive:()=>!!(i.selectedFile&&i.selectedPatchLines.length),rowSelector:".task-diff-row[data-line-id]",getOrderedRowElements:n=>[...n.querySelectorAll(".task-diff-row[data-line-id]")].filter(d=>N(G(d.getAttribute("data-line-id")))),mapRowElement:n=>{var d;return G(((d=n==null?void 0:n.getAttribute)==null?void 0:d.call(n,"data-line-id"))||"")},getCodeLeft:n=>{var ae,x,H;const d=(ae=n==null?void 0:n.querySelector)==null?void 0:ae.call(n,".task-diff-line");if(!d)return 0;const k=(x=d.getBoundingClientRect)==null?void 0:x.call(d),A=(H=window.getComputedStyle)==null?void 0:H.call(window,d),P=Number.parseFloat((A==null?void 0:A.paddingLeft)||"0")||0;return((k==null?void 0:k.left)||0)+P},debounceMs:72});function f(n=[]){const d=n.flatMap(P=>[Number((P==null?void 0:P.oldNumber)||0),Number((P==null?void 0:P.newNumber)||0)]).filter(P=>P>0);if(!d.length)return{start:0,end:0,label:""};const k=Math.min(...d),A=Math.max(...d);return{start:k,end:A,label:k===A?`L${k}`:`L${k}-L${A}`}}function C(n=[]){return n.map(d=>String((d==null?void 0:d.content)||"")).join(`