@muyichengshayu/promptx 0.2.13 → 0.2.15
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 +11 -0
- package/apps/server/src/agentSessionDiscovery.js +180 -7
- package/apps/web/dist/assets/{CodexSessionManagerDialog-Dic9kMHK.js → CodexSessionManagerDialog-y7O-JTxP.js} +1 -1
- package/apps/web/dist/assets/{TaskDiffReviewDialog-CKiZdXqi.js → TaskDiffReviewDialog-CTr_zoAn.js} +1 -1
- package/apps/web/dist/assets/{WorkbenchSettingsDialog-CP0z90bm.js → WorkbenchSettingsDialog-Bf2DCuN_.js} +1 -1
- package/apps/web/dist/assets/{WorkbenchView-D1oxqNr4.css → WorkbenchView-CK1snPBz.css} +1 -1
- package/apps/web/dist/assets/WorkbenchView-Gq3mmtsK.js +60 -0
- package/apps/web/dist/assets/index-Co1Ssha9.js +2 -0
- package/apps/web/dist/index.html +1 -1
- package/package.json +21 -14
- package/apps/runner/src/engines/claudeCodeRunner.test.js +0 -467
- package/apps/runner/src/engines/kimiCodeRunner.test.js +0 -127
- package/apps/runner/src/engines/openCodeRunner.test.js +0 -236
- package/apps/runner/src/engines/runnerContract.test.js +0 -449
- package/apps/runner/src/engines/shellRunner.test.js +0 -46
- package/apps/runner/src/runManager.test.js +0 -913
- package/apps/runner/src/serverClient.test.js +0 -93
- package/apps/server/src/agentSessionDiscovery.test.js +0 -186
- package/apps/server/src/appPaths.test.js +0 -52
- package/apps/server/src/assetRoutes.test.js +0 -168
- package/apps/server/src/codex.test.js +0 -518
- package/apps/server/src/codexRoutes.test.js +0 -376
- package/apps/server/src/codexRuns.test.js +0 -160
- package/apps/server/src/codexSessions.test.js +0 -369
- package/apps/server/src/db.test.js +0 -182
- package/apps/server/src/gitDiff.test.js +0 -542
- package/apps/server/src/gitDiffClient.test.js +0 -140
- package/apps/server/src/internalRoutes.test.js +0 -134
- package/apps/server/src/maintenance.test.js +0 -154
- package/apps/server/src/processControl.test.js +0 -147
- package/apps/server/src/relayClient.test.js +0 -478
- package/apps/server/src/relayConfig.test.js +0 -73
- package/apps/server/src/relayProtocol.test.js +0 -49
- package/apps/server/src/relayServer.test.js +0 -798
- package/apps/server/src/relayTenants.test.js +0 -137
- package/apps/server/src/relayUsageStore.test.js +0 -65
- package/apps/server/src/repository.test.js +0 -150
- package/apps/server/src/runDispatchService.test.js +0 -563
- package/apps/server/src/runEventIngest.test.js +0 -225
- package/apps/server/src/runRecovery.test.js +0 -73
- package/apps/server/src/runnerClient.test.js +0 -80
- package/apps/server/src/runnerDispatch.test.js +0 -136
- package/apps/server/src/systemConfig.test.js +0 -112
- package/apps/server/src/systemRoutes.test.js +0 -319
- package/apps/server/src/taskRoutes.test.js +0 -775
- package/apps/server/src/upload.test.js +0 -30
- package/apps/server/src/webAppRoutes.test.js +0 -67
- package/apps/server/src/workspaceFiles.test.js +0 -279
- package/apps/web/dist/assets/WorkbenchView-noayQwj4.js +0 -60
- package/apps/web/dist/assets/index-HLkdzIYF.js +0 -2
- package/packages/shared/src/dailyLogStream.test.js +0 -29
- package/packages/shared/src/shellCommands.test.js +0 -45
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.15
|
|
4
|
+
|
|
5
|
+
- 修复 AI 回复中项目文件路径链接跳转到前端站内错误 URL 的问题:点击项目内相对路径或当前项目目录下的本地绝对路径时,会打开源码浏览窗口并自动按路径搜索定位;外部链接保持原有打开行为。
|
|
6
|
+
|
|
7
|
+
## 0.2.14
|
|
8
|
+
|
|
9
|
+
- 修复 `Claude Code` 历史 session 在项目路径包含 `.` 时无法匹配的问题:候选发现会优先读取 jsonl 中的真实 `cwd`,并在缺失时用当前工作目录正向编码匹配 Claude projects 目录,避免不可逆 decode 导致 `/Users/foo/.claude` 被误判为 `/Users/foo//claude`。
|
|
10
|
+
- 增强 Claude session 路径匹配的兼容性:支持尾斜杠、Windows 盘符大小写与反斜杠、symlink / realpath 等价路径,并优先扫描当前项目对应目录,避免全局历史文件过多时被扫描上限漏掉。
|
|
11
|
+
- 优化 Claude jsonl 读取策略:大文件现在会安全读取文件头部用于提取 `cwd` 和会话预览,不再因为超过 256KB 就完全跳过。
|
|
12
|
+
- 重构 `Stone Dark` 主题为高对比度冷暖配色,提升工作台、弹窗、列表和状态色在暗色环境下的辨识度。
|
|
13
|
+
|
|
3
14
|
## 0.2.13
|
|
4
15
|
|
|
5
16
|
- 修复 `promptx relay start/restart` 启动失败并提示 `logDir is not defined` 的问题,Relay 后台进程现在会正确拿到日志目录。
|
|
@@ -39,6 +39,32 @@ function safeReadFile(filePath = '', maxBytes = MAX_DAT_FILE_SIZE) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
function safeReadFileHead(filePath = '', maxBytes = 256 * 1024) {
|
|
43
|
+
const stat = safeStat(filePath)
|
|
44
|
+
if (!stat?.isFile()) {
|
|
45
|
+
return ''
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const bytesToRead = Math.min(Math.max(1, Number(maxBytes) || 1), stat.size)
|
|
49
|
+
const buffer = Buffer.allocUnsafe(bytesToRead)
|
|
50
|
+
let fd = null
|
|
51
|
+
try {
|
|
52
|
+
fd = fs.openSync(filePath, 'r')
|
|
53
|
+
const bytesRead = fs.readSync(fd, buffer, 0, bytesToRead, 0)
|
|
54
|
+
return buffer.subarray(0, bytesRead).toString('utf8')
|
|
55
|
+
} catch {
|
|
56
|
+
return ''
|
|
57
|
+
} finally {
|
|
58
|
+
if (fd !== null) {
|
|
59
|
+
try {
|
|
60
|
+
fs.closeSync(fd)
|
|
61
|
+
} catch {
|
|
62
|
+
// ignore close errors for best-effort discovery
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
42
68
|
function parseJson(value) {
|
|
43
69
|
const text = normalizeText(value)
|
|
44
70
|
if (!text) {
|
|
@@ -288,7 +314,7 @@ function extractMessageText(value, depth = 0) {
|
|
|
288
314
|
}
|
|
289
315
|
|
|
290
316
|
function readJsonlPreview(filePath = '') {
|
|
291
|
-
const content =
|
|
317
|
+
const content = safeReadFileHead(filePath, 256 * 1024)
|
|
292
318
|
if (!content) {
|
|
293
319
|
return ''
|
|
294
320
|
}
|
|
@@ -314,6 +340,134 @@ function readJsonlPreview(filePath = '') {
|
|
|
314
340
|
return ''
|
|
315
341
|
}
|
|
316
342
|
|
|
343
|
+
function readClaudeJsonlCwd(filePath = '') {
|
|
344
|
+
const content = safeReadFileHead(filePath, 256 * 1024)
|
|
345
|
+
if (!content) {
|
|
346
|
+
return ''
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const lines = content.replace(/\r\n/g, '\n').split('\n')
|
|
350
|
+
for (const line of lines) {
|
|
351
|
+
const event = parseJson(line)
|
|
352
|
+
if (!event || typeof event !== 'object') {
|
|
353
|
+
continue
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const cwd = normalizeText(event.cwd)
|
|
357
|
+
if (cwd) {
|
|
358
|
+
return cwd
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const message = event.message
|
|
362
|
+
if (message && typeof message === 'object') {
|
|
363
|
+
const msgCwd = normalizeText(message.cwd)
|
|
364
|
+
if (msgCwd) {
|
|
365
|
+
return msgCwd
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return ''
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function normalizeClaudeProjectPathInput(cwd = '') {
|
|
374
|
+
const value = normalizeText(cwd)
|
|
375
|
+
if (!value) {
|
|
376
|
+
return ''
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const normalized = value.replace(/\\/g, '/')
|
|
380
|
+
if (normalized.length > 1 && !/^[A-Za-z]:\/$/i.test(normalized)) {
|
|
381
|
+
return normalized.replace(/\/+$/, '')
|
|
382
|
+
}
|
|
383
|
+
return normalized
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function getClaudeProjectPathInputs(cwd = '') {
|
|
387
|
+
const primary = normalizeClaudeProjectPathInput(cwd)
|
|
388
|
+
if (!primary) {
|
|
389
|
+
return []
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const values = [primary]
|
|
393
|
+
try {
|
|
394
|
+
const realPath = normalizeClaudeProjectPathInput(fs.realpathSync.native(primary))
|
|
395
|
+
if (realPath && !values.includes(realPath)) {
|
|
396
|
+
values.push(realPath)
|
|
397
|
+
}
|
|
398
|
+
} catch {
|
|
399
|
+
// Some candidate paths may not exist locally, especially cross-platform paths.
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return values
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function encodeClaudeProjectPath(cwd = '') {
|
|
406
|
+
const value = normalizeClaudeProjectPathInput(cwd)
|
|
407
|
+
if (!value) {
|
|
408
|
+
return ''
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return value.replace(/[/:.]/g, '-')
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function getClaudeProjectKeysForCwd(cwd = '') {
|
|
415
|
+
const keys = []
|
|
416
|
+
getClaudeProjectPathInputs(cwd).forEach((targetPath) => {
|
|
417
|
+
const key = encodeClaudeProjectPath(targetPath)
|
|
418
|
+
if (!key || keys.includes(key)) {
|
|
419
|
+
return
|
|
420
|
+
}
|
|
421
|
+
keys.push(key)
|
|
422
|
+
|
|
423
|
+
if (/^[A-Za-z]--/.test(key)) {
|
|
424
|
+
const upperDriveKey = `${key[0].toUpperCase()}${key.slice(1)}`
|
|
425
|
+
const lowerDriveKey = `${key[0].toLowerCase()}${key.slice(1)}`
|
|
426
|
+
;[upperDriveKey, lowerDriveKey].forEach((driveKey) => {
|
|
427
|
+
if (!keys.includes(driveKey)) {
|
|
428
|
+
keys.push(driveKey)
|
|
429
|
+
}
|
|
430
|
+
})
|
|
431
|
+
}
|
|
432
|
+
})
|
|
433
|
+
return keys
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function inferClaudeProjectCwd(projectKey = '', options = {}) {
|
|
437
|
+
const key = normalizeText(projectKey)
|
|
438
|
+
const targetPaths = getClaudeProjectPathInputs(options.cwd)
|
|
439
|
+
if (!key || !targetPaths.length) {
|
|
440
|
+
return ''
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const matched = targetPaths.some((targetPath) => {
|
|
444
|
+
const encodedTarget = encodeClaudeProjectPath(targetPath)
|
|
445
|
+
const isWindowsPath = /^[A-Za-z]:\//.test(targetPath)
|
|
446
|
+
return isWindowsPath
|
|
447
|
+
? encodedTarget.toLowerCase() === key.toLowerCase()
|
|
448
|
+
: encodedTarget === key
|
|
449
|
+
})
|
|
450
|
+
return matched ? targetPaths[0] : ''
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function normalizeClaudeDiscoveredCwd(cwd = '', options = {}) {
|
|
454
|
+
const discoveredCwd = normalizeClaudeProjectPathInput(cwd)
|
|
455
|
+
if (!discoveredCwd) {
|
|
456
|
+
return ''
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const targetPaths = getClaudeProjectPathInputs(options.cwd)
|
|
460
|
+
if (!targetPaths.length) {
|
|
461
|
+
return discoveredCwd
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const discoveredComparable = normalizeComparablePath(discoveredCwd)
|
|
465
|
+
const isTargetEquivalent = targetPaths.some((targetPath) => (
|
|
466
|
+
normalizeComparablePath(targetPath) === discoveredComparable
|
|
467
|
+
))
|
|
468
|
+
return isTargetEquivalent ? targetPaths[0] : discoveredCwd
|
|
469
|
+
}
|
|
470
|
+
|
|
317
471
|
export function decodeClaudeProjectPath(projectKey = '') {
|
|
318
472
|
const key = normalizeText(projectKey)
|
|
319
473
|
if (!key) {
|
|
@@ -338,6 +492,7 @@ export function listKnownClaudeCodeSessions(options = {}) {
|
|
|
338
492
|
const transcriptDir = path.join(claudeHome, 'transcripts')
|
|
339
493
|
const projectsDir = path.join(claudeHome, 'projects')
|
|
340
494
|
const items = []
|
|
495
|
+
const seenProjectFiles = new Set()
|
|
341
496
|
|
|
342
497
|
collectFiles(transcriptDir, {
|
|
343
498
|
maxDepth: 0,
|
|
@@ -355,15 +510,19 @@ export function listKnownClaudeCodeSessions(options = {}) {
|
|
|
355
510
|
})
|
|
356
511
|
})
|
|
357
512
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
513
|
+
function addClaudeProjectFile(filePath) {
|
|
514
|
+
const fileKey = path.resolve(filePath)
|
|
515
|
+
if (seenProjectFiles.has(fileKey)) {
|
|
516
|
+
return
|
|
517
|
+
}
|
|
518
|
+
seenProjectFiles.add(fileKey)
|
|
519
|
+
|
|
363
520
|
const stat = safeStat(filePath)
|
|
364
521
|
const relativeParts = path.relative(projectsDir, filePath).split(path.sep).filter(Boolean)
|
|
365
522
|
const projectKey = relativeParts[0] || ''
|
|
366
|
-
const cwd =
|
|
523
|
+
const cwd = normalizeClaudeDiscoveredCwd(readClaudeJsonlCwd(filePath), options)
|
|
524
|
+
|| inferClaudeProjectCwd(projectKey, options)
|
|
525
|
+
|| decodeClaudeProjectPath(projectKey)
|
|
367
526
|
const id = path.basename(filePath, '.jsonl')
|
|
368
527
|
items.push({
|
|
369
528
|
id,
|
|
@@ -373,8 +532,22 @@ export function listKnownClaudeCodeSessions(options = {}) {
|
|
|
373
532
|
updatedAt: stat?.mtime,
|
|
374
533
|
source: 'claude_projects',
|
|
375
534
|
})
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
getClaudeProjectKeysForCwd(options.cwd).forEach((targetProjectKey) => {
|
|
538
|
+
collectFiles(path.join(projectsDir, targetProjectKey), {
|
|
539
|
+
maxDepth: 2,
|
|
540
|
+
maxFiles: MAX_SCAN_FILES,
|
|
541
|
+
match: (filePath) => filePath.endsWith('.jsonl'),
|
|
542
|
+
}).forEach(addClaudeProjectFile)
|
|
376
543
|
})
|
|
377
544
|
|
|
545
|
+
collectFiles(projectsDir, {
|
|
546
|
+
maxDepth: 3,
|
|
547
|
+
maxFiles: MAX_SCAN_FILES,
|
|
548
|
+
match: (filePath) => filePath.endsWith('.jsonl'),
|
|
549
|
+
}).forEach(addClaudeProjectFile)
|
|
550
|
+
|
|
378
551
|
return sortAndLimitCandidates(items, options)
|
|
379
552
|
}
|
|
380
553
|
|
|
@@ -1,3 +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-noayQwj4.js";import{u as Qe,f as Dt,e as Tt}from"./index-HLkdzIYF.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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}
|
|
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-Gq3mmtsK.js";import{u as Qe,f as Dt,e as Tt}from"./index-Co1Ssha9.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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
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
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};
|
package/apps/web/dist/assets/{TaskDiffReviewDialog-CKiZdXqi.js → TaskDiffReviewDialog-CTr_zoAn.js}
RENAMED
|
@@ -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-
|
|
1
|
+
import{g as ut,t as U,f as tt,u as ke,a as st,b as ct}from"./index-Co1Ssha9.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-Gq3mmtsK.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(`
|