@muyichengshayu/promptx 0.1.40 → 0.1.42

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/apps/server/src/codexRoutes.js +13 -0
  3. package/apps/server/src/index.js +8 -6
  4. package/apps/server/src/workspaceFiles.js +214 -3
  5. package/apps/web/dist/assets/CodexSessionManagerDialog-DH2dM17T.css +1 -0
  6. package/apps/web/dist/assets/CodexSessionManagerDialog-l1owFA6n.js +2 -0
  7. package/apps/web/dist/assets/TaskDiffReviewDialog-BQB_ZIjd.js +2 -0
  8. package/apps/web/dist/assets/TaskDiffReviewDialog-Dvg4WGbp.css +1 -0
  9. package/apps/web/dist/assets/WorkbenchSettingsDialog-CgvCPSFx.js +1 -0
  10. package/apps/web/dist/assets/WorkbenchView-BTxN9MWc.js +45 -0
  11. package/apps/web/dist/assets/index-CCgke-qd.css +1 -0
  12. package/apps/web/dist/assets/index-DFFeo0Jj.js +2 -0
  13. package/apps/web/dist/assets/{vendor-markdown-dRyaFEqN.js → vendor-markdown-BENmzbO1.js} +1 -1
  14. package/apps/web/dist/assets/vendor-misc-DxKJ95A9.js +179 -0
  15. package/apps/web/dist/assets/{vendor-router-HagsR990.js → vendor-router-iukOUtEP.js} +1 -1
  16. package/apps/web/dist/assets/vendor-shiki-core-BEj7WMrf.js +4 -0
  17. package/apps/web/dist/assets/vendor-shiki-lang-bash-CsFNeEqN.js +1 -0
  18. package/apps/web/dist/assets/vendor-shiki-lang-c-BcjOwTnT.js +1 -0
  19. package/apps/web/dist/assets/vendor-shiki-lang-cpp-RQOeHt9v.js +1 -0
  20. package/apps/web/dist/assets/vendor-shiki-lang-css-CnK7V8uS.js +1 -0
  21. package/apps/web/dist/assets/vendor-shiki-lang-diff-Ba_mN76d.js +1 -0
  22. package/apps/web/dist/assets/vendor-shiki-lang-dockerfile-DexPvRap.js +1 -0
  23. package/apps/web/dist/assets/vendor-shiki-lang-go-Dk57BT_E.js +1 -0
  24. package/apps/web/dist/assets/vendor-shiki-lang-html-D-4N43uu.js +1 -0
  25. package/apps/web/dist/assets/vendor-shiki-lang-java-Ataf9s36.js +1 -0
  26. package/apps/web/dist/assets/vendor-shiki-lang-javascript-BmgvEpOZ.js +1 -0
  27. package/apps/web/dist/assets/vendor-shiki-lang-json-BM2fuodu.js +1 -0
  28. package/apps/web/dist/assets/vendor-shiki-lang-markdown-D1kkAUm_.js +1 -0
  29. package/apps/web/dist/assets/vendor-shiki-lang-python-NfTv2t04.js +1 -0
  30. package/apps/web/dist/assets/vendor-shiki-lang-rust-CnDh16MN.js +1 -0
  31. package/apps/web/dist/assets/vendor-shiki-lang-sql-s5-_63Hi.js +1 -0
  32. package/apps/web/dist/assets/vendor-shiki-lang-tsx-CLUFHL3U.js +1 -0
  33. package/apps/web/dist/assets/vendor-shiki-lang-typescript-Ctu8XPGP.js +1 -0
  34. package/apps/web/dist/assets/vendor-shiki-lang-vue-C5VFP2hw.js +1 -0
  35. package/apps/web/dist/assets/vendor-shiki-lang-xml-_rmOJA0y.js +1 -0
  36. package/apps/web/dist/assets/vendor-shiki-lang-yaml-DIKR-ygN.js +1 -0
  37. package/apps/web/dist/assets/vendor-shiki-theme-github-dark-default-DvEFPrX1.js +1 -0
  38. package/apps/web/dist/assets/vendor-shiki-theme-github-light-DxBVwbUZ.js +1 -0
  39. package/apps/web/dist/assets/{vendor-tiptap-nB6QZpDd.js → vendor-tiptap-COqMdKic.js} +1 -1
  40. package/apps/web/dist/assets/{vendor-ui-D8m4HkwG.js → vendor-ui-DlJXv6Z0.js} +54 -49
  41. package/apps/web/dist/index.html +4 -4
  42. package/package.json +1 -1
  43. package/apps/web/dist/assets/CodexSessionManagerDialog-Cc50X1uZ.js +0 -1
  44. package/apps/web/dist/assets/TaskDiffReviewDialog-iM9E65NV.js +0 -2
  45. package/apps/web/dist/assets/WorkbenchSettingsDialog-B_a2jRAE.js +0 -1
  46. package/apps/web/dist/assets/WorkbenchView-CecYCciI.js +0 -35
  47. package/apps/web/dist/assets/index-BlxLlAxM.css +0 -1
  48. package/apps/web/dist/assets/index-CF-PozcK.js +0 -2
  49. package/apps/web/dist/assets/vendor-misc-BuoI1ILx.js +0 -33
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.42
4
+
5
+ - 继续收敛中栏消息阅读体验:去掉 `PromptX` 与 `response` 卡片头部的“展开 / 收起”入口,两类卡片默认始终完整展开,避免频繁折叠造成阅读打断。
6
+ - 修复切换任务时中栏消息区偶发没有滚到底部的问题:任务切换后的 run 历史加载、事件懒加载以及回复区异步 Markdown / 代码高亮渲染完成后,都会按最新一轮补做滚底跟随,避免长任务停在半截。
7
+ - 为任务切换滚底链路补充回归测试,锁住 `scrollToLatest` 必须强制滚底的行为,减少后续重构时再次回归。
8
+ - 调整 `WeChat` 主题的文本选区颜色:把选中背景从接近 `PromptX` 卡片的浅绿色改为更清晰的浅蓝色,避免选中文本时和消息气泡背景撞色。
9
+
10
+ ## 0.1.41
11
+
12
+ - 项目管理新增只读源码查看能力:编辑项目时可打开“查看源码”弹层,左侧浏览目录树,右侧预览文件内容,并支持嵌套目录懒加载与项目路径标题展示。
13
+ - 统一源码、回复代码块与代码变更弹窗的高亮体验:改用 Shiki 的 GitHub 风格着色,补齐行号、语言识别、diff 高亮和 2000 行以内整文件高亮策略,超大文件自动降级为纯文本以避免卡顿。
14
+ - 调整源码查看与代码变更弹窗尺寸和层级:二级弹层提升到更高 z-index,弹窗改为更接近 90% 的大尺寸,行号列和文件信息展示更紧凑。
15
+ - 修复源码目录中嵌套 `apps/web/apps/web` 这类路径展开后为空的问题,服务端文件浏览接口现在能更稳定地返回深层目录内容。
16
+ - 修复移动端执行过程卡片被长搜索 query、长链接或普通列表项撑出横向滚动的问题:过程详情的列表、Markdown 文本和事件卡片都限制在卡片宽度内并默认折行。
17
+
3
18
  ## 0.1.40
4
19
 
5
20
  - 右侧编辑区发送链路补齐首尾空白行裁剪:发送前会去掉文本块页头页尾的空行,但保留中间空行与正文缩进;前端 prompt 组装、草稿保存与服务端 `promptBlocks` 入库三层都加了统一兜底,避免不同入口行为不一致。
@@ -73,6 +73,7 @@ function registerCodexRoutes(app, options = {}) {
73
73
  listTaskSlugsByCodexSessionId = () => [],
74
74
  listWorkspaceSuggestions,
75
75
  listWorkspaceTree,
76
+ readWorkspaceFileContent,
76
77
  resetPromptxCodexSession = () => null,
77
78
  runDispatchService,
78
79
  searchDirectoryPickerEntries,
@@ -127,6 +128,18 @@ function registerCodexRoutes(app, options = {}) {
127
128
  })
128
129
  })
129
130
 
131
+ app.get('/api/codex/sessions/:sessionId/files/content', async (request, reply) => {
132
+ const session = getPromptxCodexSessionById(request.params.sessionId)
133
+ if (!session) {
134
+ return reply.code(404).send({ messageKey: 'errors.sessionNotFound', message: '没有找到对应的 PromptX 项目。' })
135
+ }
136
+
137
+ return readWorkspaceFileContent(session.cwd, {
138
+ path: request.query?.path,
139
+ limit: request.query?.limit,
140
+ })
141
+ })
142
+
130
143
  app.post('/api/codex/sessions', async (request, reply) => {
131
144
  const session = createPromptxCodexSession(request.body || {})
132
145
  broadcastServerEvent('sessions.changed', {
@@ -50,12 +50,13 @@ import {
50
50
  updateCodexRunFromRunnerStatus,
51
51
  } from './codexRuns.js'
52
52
  import { listKnownWorkspacesByEngine } from './agents/index.js'
53
- import {
54
- listDirectoryPickerTree,
55
- listWorkspaceTree,
56
- searchDirectoryPickerEntries,
57
- searchWorkspaceEntries,
58
- } from './workspaceFiles.js'
53
+ import {
54
+ listDirectoryPickerTree,
55
+ readWorkspaceFileContent,
56
+ listWorkspaceTree,
57
+ searchDirectoryPickerEntries,
58
+ searchWorkspaceEntries,
59
+ } from './workspaceFiles.js'
59
60
  import { ensurePromptxStorageReady, serverRootDir } from './appPaths.js'
60
61
  import { createRelayClient } from './relayClient.js'
61
62
  import { getRelayConfigForClient } from './relayConfig.js'
@@ -417,6 +418,7 @@ registerCodexRoutes(app, {
417
418
  listTaskSlugsByCodexSessionId,
418
419
  listWorkspaceSuggestions: workspaceSuggestionService.listWorkspaceSuggestions,
419
420
  listWorkspaceTree,
421
+ readWorkspaceFileContent,
420
422
  resetPromptxCodexSession,
421
423
  runDispatchService,
422
424
  searchDirectoryPickerEntries,
@@ -3,7 +3,7 @@ import os from 'node:os'
3
3
  import path from 'node:path'
4
4
  import { createApiError } from './apiErrors.js'
5
5
 
6
- const IGNORED_DIRECTORY_NAMES = new Set([
6
+ const WORKSPACE_HIDDEN_DIRECTORY_NAMES = new Set([
7
7
  '.git',
8
8
  '.hg',
9
9
  '.svn',
@@ -13,6 +13,10 @@ const IGNORED_DIRECTORY_NAMES = new Set([
13
13
  '.turbo',
14
14
  '.cache',
15
15
  'node_modules',
16
+ ])
17
+
18
+ const DIRECTORY_PICKER_IGNORED_DIRECTORY_NAMES = new Set([
19
+ ...WORKSPACE_HIDDEN_DIRECTORY_NAMES,
16
20
  'dist',
17
21
  'build',
18
22
  'coverage',
@@ -35,6 +39,88 @@ const DEFAULT_TREE_LIMIT = 200
35
39
  const DEFAULT_SEARCH_LIMIT = 80
36
40
  const MAX_SEARCH_VISITS = 20000
37
41
  const DIRECTORY_PICKER_LIMIT = 240
42
+ const DEFAULT_FILE_PREVIEW_LIMIT = 200 * 1024
43
+ const MAX_IMAGE_PREVIEW_BYTES = 2 * 1024 * 1024
44
+
45
+ const TEXT_FILE_EXTENSIONS = new Set([
46
+ '.c',
47
+ '.cc',
48
+ '.conf',
49
+ '.cpp',
50
+ '.css',
51
+ '.csv',
52
+ '.env',
53
+ '.gitignore',
54
+ '.go',
55
+ '.graphql',
56
+ '.h',
57
+ '.html',
58
+ '.ini',
59
+ '.java',
60
+ '.js',
61
+ '.json',
62
+ '.jsx',
63
+ '.log',
64
+ '.md',
65
+ '.mjs',
66
+ '.py',
67
+ '.rb',
68
+ '.rs',
69
+ '.sh',
70
+ '.sql',
71
+ '.svg',
72
+ '.toml',
73
+ '.ts',
74
+ '.tsx',
75
+ '.txt',
76
+ '.vue',
77
+ '.xml',
78
+ '.yaml',
79
+ '.yml',
80
+ ])
81
+
82
+ const IMAGE_MIME_TYPES = new Map([
83
+ ['.avif', 'image/avif'],
84
+ ['.bmp', 'image/bmp'],
85
+ ['.gif', 'image/gif'],
86
+ ['.ico', 'image/x-icon'],
87
+ ['.jpeg', 'image/jpeg'],
88
+ ['.jpg', 'image/jpeg'],
89
+ ['.png', 'image/png'],
90
+ ['.webp', 'image/webp'],
91
+ ])
92
+
93
+ const LANGUAGE_BY_EXTENSION = new Map([
94
+ ['.bash', 'bash'],
95
+ ['.bat', 'bash'],
96
+ ['.c', 'c'],
97
+ ['.cc', 'cpp'],
98
+ ['.cpp', 'cpp'],
99
+ ['.css', 'css'],
100
+ ['.diff', 'diff'],
101
+ ['.go', 'go'],
102
+ ['.h', 'c'],
103
+ ['.html', 'html'],
104
+ ['.java', 'java'],
105
+ ['.js', 'javascript'],
106
+ ['.json', 'json'],
107
+ ['.jsx', 'react'],
108
+ ['.md', 'markdown'],
109
+ ['.mjs', 'javascript'],
110
+ ['.py', 'python'],
111
+ ['.rs', 'rust'],
112
+ ['.sh', 'bash'],
113
+ ['.sql', 'sql'],
114
+ ['.svg', 'svg'],
115
+ ['.ts', 'typescript'],
116
+ ['.tsx', 'react'],
117
+ ['.txt', 'text'],
118
+ ['.vue', 'vue'],
119
+ ['.xml', 'xml'],
120
+ ['.yaml', 'yaml'],
121
+ ['.yml', 'yaml'],
122
+ ['Dockerfile', 'dockerfile'],
123
+ ])
38
124
 
39
125
  function createHttpError(message, statusCode = 400) {
40
126
  return createApiError('', message, statusCode)
@@ -118,7 +204,7 @@ function getPathType(absolutePath = '') {
118
204
  }
119
205
 
120
206
  function shouldIgnoreDirectory(entry) {
121
- return entry?.isDirectory?.() && IGNORED_DIRECTORY_NAMES.has(entry.name)
207
+ return entry?.isDirectory?.() && WORKSPACE_HIDDEN_DIRECTORY_NAMES.has(entry.name)
122
208
  }
123
209
 
124
210
  function shouldIgnorePickerDirectory(entry) {
@@ -132,7 +218,7 @@ function shouldIgnorePickerDirectory(entry) {
132
218
  }
133
219
 
134
220
  return name.startsWith('.')
135
- || IGNORED_DIRECTORY_NAMES.has(name)
221
+ || DIRECTORY_PICKER_IGNORED_DIRECTORY_NAMES.has(name)
136
222
  || DIRECTORY_PICKER_HIDDEN_NAMES.has(name)
137
223
  }
138
224
 
@@ -244,6 +330,60 @@ function clampLimit(value, fallback, max) {
244
330
  return Math.min(Math.floor(normalized), max)
245
331
  }
246
332
 
333
+ function readFileSlice(absolutePath = '', length = 0) {
334
+ const fileHandle = fs.openSync(absolutePath, 'r')
335
+
336
+ try {
337
+ const buffer = Buffer.alloc(Math.max(0, length))
338
+ const bytesRead = fs.readSync(fileHandle, buffer, 0, buffer.length, 0)
339
+ return buffer.subarray(0, bytesRead)
340
+ } finally {
341
+ fs.closeSync(fileHandle)
342
+ }
343
+ }
344
+
345
+ function isLikelyBinaryBuffer(buffer) {
346
+ if (!Buffer.isBuffer(buffer) || buffer.length === 0) {
347
+ return false
348
+ }
349
+
350
+ const sample = buffer.subarray(0, Math.min(buffer.length, 8000))
351
+ let suspiciousBytes = 0
352
+
353
+ for (const byte of sample) {
354
+ if (byte === 0) {
355
+ return true
356
+ }
357
+
358
+ const isControlChar = byte < 32 && byte !== 9 && byte !== 10 && byte !== 13
359
+ if (isControlChar) {
360
+ suspiciousBytes += 1
361
+ }
362
+ }
363
+
364
+ return (suspiciousBytes / sample.length) > 0.1
365
+ }
366
+
367
+ function getFileLanguage(relativePath = '', absolutePath = '') {
368
+ const relativeName = path.basename(String(relativePath || '').trim())
369
+ const absoluteName = path.basename(String(absolutePath || '').trim())
370
+
371
+ if (LANGUAGE_BY_EXTENSION.has(relativeName)) {
372
+ return LANGUAGE_BY_EXTENSION.get(relativeName)
373
+ }
374
+ if (LANGUAGE_BY_EXTENSION.has(absoluteName)) {
375
+ return LANGUAGE_BY_EXTENSION.get(absoluteName)
376
+ }
377
+
378
+ const extension = path.extname(relativeName || absoluteName).toLowerCase()
379
+ return LANGUAGE_BY_EXTENSION.get(extension) || ''
380
+ }
381
+
382
+ function getImageMimeType(relativePath = '', absolutePath = '') {
383
+ const extension = path.extname(String(relativePath || absolutePath || '')).toLowerCase()
384
+ return IMAGE_MIME_TYPES.get(extension) || ''
385
+ }
386
+
247
387
  function removeExtension(value = '') {
248
388
  const normalized = String(value || '')
249
389
  const extensionIndex = normalized.lastIndexOf('.')
@@ -539,6 +679,77 @@ export function searchWorkspaceEntries(workspacePath, options = {}) {
539
679
  }
540
680
  }
541
681
 
682
+ export function readWorkspaceFileContent(workspacePath, options = {}) {
683
+ const target = resolveWorkspaceTarget(workspacePath, options.path)
684
+ const previewLimit = clampLimit(options.limit, DEFAULT_FILE_PREVIEW_LIMIT, DEFAULT_FILE_PREVIEW_LIMIT)
685
+ const fileName = path.basename(target.absolutePath)
686
+
687
+ let stats
688
+ try {
689
+ stats = fs.statSync(target.absolutePath)
690
+ } catch {
691
+ throw createApiError('errors.fileNotFound', '文件不存在。', 404)
692
+ }
693
+
694
+ if (!stats.isFile()) {
695
+ throw createApiError('errors.fileOnly', '只能读取文件内容。')
696
+ }
697
+
698
+ const language = getFileLanguage(target.relativePath, target.absolutePath)
699
+ const imageMimeType = getImageMimeType(target.relativePath, target.absolutePath)
700
+ const basePayload = {
701
+ cwd: target.root,
702
+ name: fileName,
703
+ path: target.relativePath,
704
+ type: 'file',
705
+ language,
706
+ size: stats.size,
707
+ binary: false,
708
+ truncated: false,
709
+ tooLarge: false,
710
+ content: '',
711
+ mimeType: imageMimeType || '',
712
+ previewUrl: '',
713
+ }
714
+
715
+ if (imageMimeType) {
716
+ if (stats.size > MAX_IMAGE_PREVIEW_BYTES) {
717
+ return {
718
+ ...basePayload,
719
+ binary: true,
720
+ tooLarge: true,
721
+ }
722
+ }
723
+
724
+ const buffer = fs.readFileSync(target.absolutePath)
725
+ return {
726
+ ...basePayload,
727
+ binary: true,
728
+ previewUrl: `data:${imageMimeType};base64,${buffer.toString('base64')}`,
729
+ }
730
+ }
731
+
732
+ const sliceLength = Math.min(stats.size, previewLimit)
733
+ const buffer = readFileSlice(target.absolutePath, sliceLength)
734
+ const extension = path.extname(fileName).toLowerCase()
735
+ const isKnownTextFile = TEXT_FILE_EXTENSIONS.has(extension)
736
+ const binary = !isKnownTextFile && isLikelyBinaryBuffer(buffer)
737
+
738
+ if (binary) {
739
+ return {
740
+ ...basePayload,
741
+ binary: true,
742
+ }
743
+ }
744
+
745
+ return {
746
+ ...basePayload,
747
+ content: buffer.toString('utf8').replace(/\r\n/g, '\n'),
748
+ truncated: stats.size > previewLimit,
749
+ tooLarge: stats.size > previewLimit,
750
+ }
751
+ }
752
+
542
753
  export function listDirectoryPickerTree(options = {}) {
543
754
  const targetPath = normalizeDirectoryPickerPath(options.path) || getDirectoryPickerHomePath()
544
755
 
@@ -0,0 +1 @@
1
+ .source-browser-image-wrap[data-v-c0949126]{border-color:var(--theme-borderDefault);background:var(--theme-panel)}.source-browser-code[data-v-c0949126]{background:var(--source-code-bg);border-color:var(--theme-borderDefault);color:var(--source-code-fg);height:100%;overflow:auto}.source-code-view[data-v-c0949126]{min-width:-moz-max-content;min-width:max-content}.source-code-view__table[data-v-c0949126]{border-collapse:separate;border-spacing:0;color:inherit;font-family:var(--theme-fontMono);font-size:.82rem;line-height:1.56;min-width:100%;width:-moz-max-content;width:max-content}.source-code-view[data-v-c0949126] .source-code-view__gutter{border-right:1px solid color-mix(in srgb,var(--theme-borderDefault) 82%,transparent);color:color-mix(in srgb,var(--source-code-fg) 50%,transparent);font-family:var(--theme-fontMono);font-size:.7rem;width:var(--source-code-gutter-width);min-width:var(--source-code-gutter-width);max-width:var(--source-code-gutter-width);padding:0 .38rem;text-align:right;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:top;white-space:nowrap;font-variant-numeric:tabular-nums}.source-code-view[data-v-c0949126] .source-code-view__code{padding:0 .8rem;vertical-align:top;white-space:pre}.source-code-view[data-v-c0949126] .source-code-view__line-inner{display:block;min-height:1.46em}
@@ -0,0 +1,2 @@
1
+ import{u as Ce,b as ht,a as mt,f as ft,c as gt}from"./index-DFFeo0Jj.js";import{A as xt,n as Ee,j as Te,d as yt,c as Ae,s as bt,k as Ke,_ as wt,m as _t,o as St,p as kt,S as Re,q as $t,b as Ct,t as Qe}from"./WorkbenchView-BTxN9MWc.js";import{w as ae,aD as r,aI as Q,aJ as xe,aF as e,aQ as o,u as t,aG as M,aW as Ye,aX as et,aL as P,aE as c,aR as ge,aS as _e,aN as I,aV as Fe,aK as tt,b as $,c as C,aZ as st,aT as Be,r as nt,ak as Mt,n as jt}from"./vendor-misc-DxKJ95A9.js";import{g as Le,h as ce,L as Pe,j as at,b as lt,H as It,m as Pt,v as Tt,i as De,J as Lt,P as Rt,d as Je,E as Bt,K as Dt,l as Et,p as Ft,M as Ht}from"./vendor-ui-DlJXv6Z0.js";import"./vendor-router-iukOUtEP.js";import"./vendor-markdown-BENmzbO1.js";import"./vendor-tiptap-COqMdKic.js";function At(d=[]){return(Array.isArray(d)&&d.length?d:xt).filter(m=>m&&typeof m=="object").map(m=>{const T=Ee(m.value);return{...m,value:T,label:String(m.label||Te(T)).trim()||Te(T),enabled:m.enabled!==!1,available:m.available!==!1}})}function He(d=[]){return At(d).filter(H=>H.enabled&&H.available)}async function Nt(){const d=await yt("/api/meta",{cache:"no-store"});return He(d==null?void 0:d.agentEngineOptions)}const Ut={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},zt={class:"theme-muted-text mt-1 text-xs leading-5"},Ot={class:"flex min-h-0 flex-1 flex-col overflow-hidden"},qt={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},Vt={class:"flex items-start gap-2 text-xs leading-5"},Wt={class:"theme-muted-text shrink-0"},Gt={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},Kt={class:"theme-muted-text mt-4 block text-xs"},Qt={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},Jt=["placeholder"],Xt={class:"mt-4 flex items-center gap-1.5"},Zt={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},Yt={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},es={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},ts={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},ss={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},ns={key:4,class:"theme-empty-state px-3 py-8 text-sm"},as={key:5,class:"theme-empty-state px-3 py-8 text-sm"},ls={key:6,class:"theme-empty-state px-3 py-8 text-sm"},os={key:7,class:"space-y-1"},is=["onClick"],rs={class:"min-w-0 flex-1"},ds=["innerHTML"],cs=["innerHTML"],us={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},ps={key:8,class:"space-y-1"},vs={class:"flex items-start gap-1.5"},hs=["onClick"],ms=["onClick"],fs={class:"min-w-0 flex-1"},gs={key:0,class:"theme-muted-text truncate font-mono text-[10px]"},xs={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"},ys={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},bs=["disabled"],ws=["disabled"],_s={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(d,{emit:H}){const m=d,T=H,{t:v}=Ce(),h=$(""),f=$(null),j=$(!1),u=$(""),p=$(!1),y=$(""),k=$([]),F=$(!1),E=$(""),B=$("tree"),N=$(""),Z=$("");let z=null,O=0;const J=C(()=>ve(f.value?[f.value]:[])),le=C(()=>B.value==="search"&&!E.value.trim()),V=C(()=>B.value==="search"&&!!E.value.trim()&&!p.value&&!y.value&&!k.value.length),te=C(()=>B.value==="tree"&&!j.value&&!u.value&&!J.value.length);function q(a=""){const g=String(a||"").trim();return/^[a-z]:[\\/]/i.test(g)||g.includes("\\")}function U(a=""){const g=String(a||"").trim();if(!g)return"";const i=q(g);let n=g.replace(/\\/g,"/");return n.length>1&&!/^[a-z]:\/?$/i.test(n)&&n!=="/"&&(n=n.replace(/\/+$/,"")),i?n.toLowerCase():n}function w(a="",g=""){const i=U(a),n=U(g);return!i||!n?!1:i===n||i.startsWith(`${n}/`)}function W(a="",g=""){const i=String(a||"").trim(),n=String(g||"").trim();return i?n?q(i)?/^[a-z]:\\?$/i.test(i)?`${i.replace(/[\\/]+$/,"")}\\${n}`:`${i.replace(/[\\/]+$/,"")}\\${n}`:i==="/"?`/${n}`:`${i.replace(/\/+$/,"")}/${n}`:i:n}function ue(a="",g=""){const i=U(a),n=U(g);if(!i||!n||!w(n,i))return[];const _=n===i?"":n.slice(i.length).replace(/^\//,"");return _?_.split("/").filter(Boolean):[]}function Y(a){return(a==null?void 0:a.name)||(a==null?void 0:a.path)||v("directoryPicker.unnamedDirectory")}function oe(a=""){const g=String(a||"").trim();return g?g.split(/[\\/]/).filter(Boolean).at(-1)||g:"Home"}function se(a=""){return String(a||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ie(a="",g=""){const i=String(a||""),n=String(g||"").trim().toLowerCase();if(!i||!n)return null;const _=i.toLowerCase(),L=_.indexOf(n);if(L>=0)return{start:L,end:L+n.length};const x=n.split(/[\\/\s_.-]+/).filter(Boolean).sort((D,X)=>X.length-D.length);for(const D of x){if(D.length<2)continue;const X=_.indexOf(D);if(X>=0)return{start:X,end:X+D.length}}return null}function R(a="",g=""){const i=String(a||""),n=ie(i,g);return n?`${se(i.slice(0,n.start))}<mark class="theme-search-highlight">${se(i.slice(n.start,n.end))}</mark>${se(i.slice(n.end))}`:se(i)}function Me(a){return R(Y(a),E.value)}function ye(a){return R((a==null?void 0:a.path)||"",E.value)}function pe(a,g=0){return{...a,depth:g,expanded:!1,loaded:!1,loading:!1,children:[]}}function ve(a=[],g=[]){return a.forEach(i=>{g.push(i),i.expanded&&i.children.length&&ve(i.children,g)}),g}function ee(){f.value&&(f.value={...f.value})}function he(a,g=f.value?[f.value]:[]){const i=U(a);if(!i)return null;for(const n of g){if(U(n.path)===i)return n;if(n.children.length){const _=he(a,n.children);if(_)return _}}return null}function ne(a){N.value=String((a==null?void 0:a.path)||"").trim(),Z.value=Y(a)}async function me(a,g={}){if(!(!a||a.loading)&&!(a.loaded&&!g.force)){a.loading=!0,u.value="",ee();try{const i=await Ke({path:a.path,limit:240});a.children=(i.items||[]).map(n=>pe(n,a.depth+1)),a.loaded=!0}catch(i){u.value=i.message||v("directoryPicker.loadFailed")}finally{a.loading=!1,ee()}}}async function fe(){j.value=!0,u.value="";try{const a=await Ke({limit:240});h.value=String(a.path||""),f.value=pe({name:oe(a.path||""),path:String(a.path||""),type:"directory",hasChildren:!0,isHomeRoot:!0},0),f.value.children=(a.items||[]).map(g=>pe(g,1)),f.value.loaded=!0,f.value.expanded=!0,ne(f.value)}catch(a){u.value=a.message||v("directoryPicker.treeLoadFailed"),f.value=null,h.value=""}finally{j.value=!1}}async function Se(a=""){const g=String(a||"").trim();if(!g||!h.value||!w(g,h.value))return;let i=f.value;if(!i)return;ne(i);const n=ue(h.value,g);for(const _ of n){await me(i),i.expanded=!0,ee();const L=he(W(i.path,_),i.children);if(!L)break;i=L,ne(i)}}async function ke(){E.value="",B.value="tree",k.value=[],y.value="",F.value=!1,N.value="",Z.value="",await fe();const a=String(m.initialPath||"").trim();a&&w(a,h.value)&&await Se(a)}async function $e(a){if(a!=null&&a.path&&(ne(a),!!a.hasChildren)){if(!a.loaded){a.expanded=!0,ee(),await me(a);return}a.expanded=!a.expanded,ee()}}function G(a){a!=null&&a.path&&(ne(a),B.value="tree")}async function re(){const a=String(E.value||"").trim();O+=1;const g=O;if(!m.open||!a||!h.value){p.value=!1,y.value="",k.value=[],F.value=!1;return}p.value=!0,y.value="";try{const i=await bt(a,{path:h.value,limit:80});if(g!==O)return;k.value=Array.isArray(i.items)?i.items:[],F.value=!!i.truncated}catch(i){if(g!==O)return;y.value=i.message||v("directoryPicker.searchFailed"),k.value=[],F.value=!1}finally{g===O&&(p.value=!1)}}function be(){if(z&&(window.clearTimeout(z),z=null),!String(E.value||"").trim()){p.value=!1,y.value="",k.value=[],F.value=!1;return}p.value=!0,y.value="",z=window.setTimeout(()=>{re()},120)}async function we(a){a!=null&&a.path&&(B.value="tree",await Se(a.path))}function de(){N.value&&(T("select",N.value),T("close"))}return ae(E,()=>{B.value=E.value.trim()?"search":"tree",be()}),ae(()=>m.open,a=>{if(a){ke().catch(()=>{});return}z&&(window.clearTimeout(z),z=null)}),(a,g)=>(r(),Q(Ae,{open:d.open,"stack-level":1,"panel-class":"settings-dialog-panel h-full max-w-4xl sm:h-auto sm:max-h-[86vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:px-5","close-disabled":j.value||p.value,"close-on-backdrop":!(j.value||p.value),"close-on-escape":!(j.value||p.value),onClose:g[4]||(g[4]=i=>T("close"))},{title:xe(()=>[e("div",null,[e("div",Ut,[M(t(ce),{class:"h-4 w-4"}),e("span",null,o(t(v)("directoryPicker.title")),1)]),e("p",zt,o(t(v)("directoryPicker.intro")),1)])]),default:xe(()=>[e("div",Ot,[e("div",qt,[e("div",Vt,[e("span",Wt,o(t(v)("directoryPicker.currentSelection")),1),e("span",Gt,o(N.value||t(v)("directoryPicker.selectionPlaceholder")),1)])]),e("label",Kt,[e("span",null,o(t(v)("directoryPicker.searchLabel")),1),e("div",Qt,[M(t(Le),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),Ye(e("input",{"onUpdate:modelValue":g[0]||(g[0]=i=>E.value=i),type:"text",placeholder:t(v)("directoryPicker.searchPlaceholder"),class:"min-w-0 flex-1 border-0 bg-transparent px-0 text-sm text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]"},null,8,Jt),[[et,E.value]])])]),e("div",Xt,[e("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",B.value==="search"?"tool-button-accent-subtle":"theme-filter-idle border-dashed"]),onClick:g[1]||(g[1]=i=>B.value="search")},[M(t(Le),{class:"h-3.5 w-3.5"}),e("span",null,o(t(v)("directoryPicker.searchTab")),1)],2),e("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",B.value==="tree"?"tool-button-accent-subtle":"theme-filter-idle border-dashed"]),onClick:g[2]||(g[2]=i=>B.value="tree")},[M(t(ce),{class:"h-3.5 w-3.5"}),e("span",null,o(t(v)("directoryPicker.treeTab")),1)],2)]),e("div",Zt,[B.value==="search"&&y.value?(r(),c("div",Yt,o(y.value),1)):B.value==="tree"&&u.value?(r(),c("div",es,o(u.value),1)):B.value==="search"&&p.value?(r(),c("div",ts,[M(t(Pe),{class:"h-4 w-4 animate-spin"}),e("span",null,o(t(v)("directoryPicker.searching")),1)])):B.value==="tree"&&j.value?(r(),c("div",ss,[M(t(Pe),{class:"h-4 w-4 animate-spin"}),e("span",null,o(t(v)("directoryPicker.treeLoading")),1)])):le.value?(r(),c("div",ns,o(t(v)("directoryPicker.searchPrompt")),1)):V.value?(r(),c("div",as,o(t(v)("directoryPicker.noSearchResults")),1)):te.value?(r(),c("div",ls,o(t(v)("directoryPicker.emptyTree")),1)):B.value==="search"?(r(),c("div",os,[(r(!0),c(ge,null,_e(k.value,i=>(r(),c("button",{key:i.path,type:"button",class:P(["flex w-full items-start gap-2 rounded-sm border border-transparent px-2.5 py-1.5 text-left transition",U(N.value)===U(i.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:n=>we(i)},[M(t(ce),{class:"theme-muted-text mt-0.5 h-4 w-4 shrink-0"}),e("div",rs,[e("div",null,[e("span",{class:"truncate text-[13px] text-[var(--theme-textPrimary)]",innerHTML:Me(i)},null,8,ds)]),e("div",{class:"theme-muted-text truncate font-mono text-[10px]",innerHTML:ye(i)},null,8,cs)])],10,is))),128)),F.value?(r(),c("p",us,o(t(v)("directoryPicker.truncatedHint")),1)):I("",!0)])):(r(),c("div",ps,[(r(!0),c(ge,null,_e(J.value,i=>(r(),c("div",{key:i.path,class:P(["rounded-sm border border-transparent px-1.5 py-1 transition",U(N.value)===U(i.path)?"theme-list-item-active":i.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Fe({paddingLeft:`${i.depth*16+6}px`})},[e("div",vs,[e("button",{type:"button",class:P(["theme-icon-button h-5 w-5 shrink-0",i.hasChildren?"":"invisible pointer-events-none"]),onClick:tt(n=>$e(i),["stop"])},[i.loading?(r(),Q(t(Pe),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(r(),Q(t(at),{key:1,class:P(["h-3.5 w-3.5 transition",i.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,hs),e("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:n=>G(i)},[M(t(ce),{class:P(["h-4 w-4 shrink-0",U(N.value)===U(i.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),e("div",fs,[e("div",{class:P(["truncate text-[13px]",i.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},o(Y(i)),3),i.isHomeRoot?(r(),c("div",gs,o(i.path),1)):I("",!0)])],8,ms)])],6))),128))]))])]),e("div",xs,[e("div",ys,[e("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:j.value||p.value,onClick:g[3]||(g[3]=i=>T("close"))},o(t(v)("directoryPicker.cancel")),9,bs),e("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:j.value||p.value||!N.value,onClick:de},[M(t(lt),{class:"h-4 w-4"}),e("span",null,o(t(v)("directoryPicker.useCurrentDirectory")),1)],8,ws)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Ss={class:"grid gap-4"},ks={class:"theme-muted-text block text-xs"},$s=["value","disabled"],Cs={class:"theme-muted-text block text-xs"},Ms={class:"mt-1 flex gap-2"},js=["value","disabled"],Is=["disabled"],Ps={id:"codex-manager-workspace-suggestions"},Ts=["value"],Ls={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Rs={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},Bs={class:"theme-muted-text block text-xs"},Ds={class:"mt-1"},Es={class:"flex items-center gap-2 text-sm"},Fs={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Hs=["disabled","onClick"],As={class:"flex items-center justify-between gap-3"},Ns={class:"min-w-0 flex-1 truncate"},Us={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},zs={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},Os={class:"theme-muted-text block text-xs"},qs={class:"mt-1 flex gap-2"},Vs=["value","disabled"],Ws=["disabled"],Gs={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},Ks={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},Xe={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},canEditEngine:{type:Boolean,default:!0},canEditCwd:{type:Boolean,default:!0},canEditSessionId:{type:Boolean,default:!0},cwd:{type:String,default:""},cwdReadonlyMessage:{type:String,default:""},duplicateCwdMessage:{type:String,default:""},engine:{type:String,default:"codex"},engineOptions:{type:Array,default:()=>[]},engineReadonlyMessage:{type:String,default:""},mobile:{type:Boolean,default:!1},sessionId:{type:String,default:""},sessionIdCopied:{type:Boolean,default:!1},sessionIdReadonlyMessage:{type:String,default:""},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","update:cwd","update:engine","update:sessionId","update:title"],setup(d,{emit:H}){const m=d,T=H,{t:v}=Ce(),h=C(()=>{const j=String(m.engine||"").trim();return m.engineOptions.find(u=>String((u==null?void 0:u.value)||"").trim()===j)||null}),f=C(()=>String(m.sessionId||"").trim());return(j,u)=>(r(),c("div",Ss,[e("label",ks,[e("span",null,o(t(v)("projectManager.projectTitleOptional")),1),e("input",{value:d.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:d.busy,onInput:u[0]||(u[0]=p=>T("update:title",p.target.value))},null,40,$s)]),e("label",Cs,[e("span",null,o(t(v)("projectManager.workingDirectoryField")),1),e("div",Ms,[e("input",{value:d.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:P(["tool-input min-w-0 flex-1 disabled:cursor-not-allowed disabled:opacity-80",d.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:d.busy||!d.canEditCwd,onInput:u[1]||(u[1]=p=>T("update:cwd",p.target.value))},null,42,js),e("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:u[2]||(u[2]=p=>T("open-directory-picker"))},[M(t(ce),{class:"h-4 w-4"}),e("span",null,o(d.mobile?t(v)("projectManager.choose"):t(v)("projectManager.chooseDirectory")),1)],8,Is)]),e("datalist",Ps,[(r(!0),c(ge,null,_e(d.workspaceSuggestions,p=>(r(),c("option",{key:p,value:p},null,8,Ts))),128))]),d.duplicateCwdMessage?(r(),c("p",Ls,o(d.duplicateCwdMessage),1)):d.cwdReadonlyMessage?(r(),c("p",Rs,o(d.cwdReadonlyMessage),1)):I("",!0)]),e("label",Bs,[e("span",null,o(t(v)("projectManager.engineField")),1),e("div",Ds,[M(wt,{"model-value":d.engine,options:d.engineOptions,disabled:d.busy||!d.canEditEngine,placeholder:t(v)("projectManager.selectEngine"),"empty-text":t(v)("projectManager.noEngines"),"get-option-value":p=>(p==null?void 0:p.value)||"","onUpdate:modelValue":u[3]||(u[3]=p=>T("update:engine",p))},{trigger:xe(({disabled:p})=>{var y;return[e("div",Es,[e("span",{class:P(["min-w-0 flex-1 truncate",p?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},o(((y=h.value)==null?void 0:y.label)||t(v)("projectManager.selectEngine")),3),h.value&&h.value.enabled===!1?(r(),c("span",Fs,o(t(v)("projectManager.comingSoon")),1)):I("",!0)])]}),option:xe(({option:p,selected:y,select:k})=>[e("button",{type:"button",class:P(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",y?"theme-filter-active":"theme-filter-idle"]),disabled:(p==null?void 0:p.enabled)===!1,onClick:k},[e("div",As,[e("span",Ns,o(p.label),1),(p==null?void 0:p.enabled)===!1?(r(),c("span",Us,o(t(v)("projectManager.comingSoon")),1)):I("",!0)])],10,Hs)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),d.engineReadonlyMessage?(r(),c("p",zs,o(d.engineReadonlyMessage),1)):I("",!0)]),e("label",Os,[e("span",null,o(t(v)("projectManager.sessionId")),1),e("div",qs,[e("input",{value:d.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 flex-1 disabled:cursor-not-allowed disabled:opacity-80",disabled:d.busy||!d.canEditSessionId,onInput:u[4]||(u[4]=p=>T("update:sessionId",p.target.value))},null,40,Vs),f.value?(r(),c("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:u[5]||(u[5]=p=>T("copy-session-id"))},[d.sessionIdCopied?(r(),Q(t(lt),{key:0,class:"h-4 w-4"})):(r(),Q(t(It),{key:1,class:"h-4 w-4"})),e("span",null,o(d.sessionIdCopied?t(v)("projectManager.sessionIdCopied"):t(v)("projectManager.copySessionId")),1)],8,Ws)):I("",!0)]),d.sessionIdReadonlyMessage?(r(),c("p",Gs,o(d.sessionIdReadonlyMessage),1)):(r(),c("p",Ks,o(t(v)("projectManager.sessionIdHint")),1))])]))}},Qs={class:"flex items-center justify-between gap-3"},Js={class:"theme-heading text-sm font-medium"},Xs={key:0,class:"theme-muted-text mt-1 text-xs"},Zs=["disabled"],Ys=["onClick"],en={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},tn={class:"flex w-full flex-col gap-2 text-left"},sn={class:"theme-heading min-w-0 text-sm font-medium"},nn=["title"],an=["title"],ln={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},on={key:0,"aria-hidden":"true"},rn={key:1},dn={class:"flex flex-wrap items-center gap-2 pt-1"},cn={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},Ze={__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:H}){const m=d,T=H,{t:v}=Ce();function h(u){return m.mode==="edit"&&m.editingSessionId===u.id?"theme-card-selected":m.isSessionRunning(u.id)?"theme-card-warning":"theme-card-idle-strong"}function f(u){return m.isCurrentSession(u.id)?v("projectManager.current"):v("projectManager.regular")}function j(u){return m.isCurrentSession(u.id)?"theme-status-info":"theme-status-neutral"}return(u,p)=>(r(),c("div",{class:P(d.mobile?"flex h-full min-h-0 flex-col":"")},[e("div",Qs,[e("div",null,[e("div",Js,o(t(v)("projectManager.projectList")),1),d.hasSessions?I("",!0):(r(),c("p",Xs,o(t(v)("projectManager.noProjects")),1))]),e("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:p[0]||(p[0]=y=>T("create"))},[M(t(Pt),{class:"h-4 w-4"}),e("span",null,o(t(v)("projectManager.create")),1)],8,Zs)]),e("div",{class:P(["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)]"])},[(r(!0),c(ge,null,_e(d.sessions,y=>(r(),c("article",{key:y.id,class:P(["relative cursor-pointer rounded-sm border p-3 transition",h(y)]),onClick:k=>T("select",y.id)},[d.mode==="edit"&&d.editingSessionId===y.id?(r(),c("span",en)):I("",!0),e("div",tn,[e("div",sn,[e("span",{class:"block truncate",title:y.title||t(v)("projectManager.untitledProject")},o(y.title||t(v)("projectManager.untitledProject")),9,nn)]),e("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:y.cwd},o(y.cwd),9,an),e("div",ln,[e("span",null,o(t(Te)(y.engine)),1),d.mobile?I("",!0):(r(),c("span",on,"·")),d.mobile?I("",!0):(r(),c("span",rn,o(d.formatUpdatedAt(y.updatedAt)),1))]),e("div",dn,[e("span",{class:P(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",j(y)])},o(f(y)),3),e("span",{class:P(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",d.getRuntimeStatusClass(y.id)])},[d.isSessionRunning(y.id)?(r(),c("span",cn)):I("",!0),st(" "+o(d.getRuntimeStatusLabel(y.id)),1)],2),e("span",{class:P(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",d.getThreadStatusClass(y)])},o(d.getThreadStatusLabel(y)),3)])])],10,Ys))),128))],2)],2))}},un={class:"space-y-3"},pn={class:"dashed-panel px-3 py-3"},vn={class:"theme-muted-text text-[11px]"},hn={class:"mt-2 flex flex-wrap gap-2"},mn={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},fn={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},gn={class:"dashed-panel px-3 py-3"},xn={class:"theme-muted-text text-[11px]"},yn={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},bn={class:"dashed-panel px-3 py-3"},wn={class:"theme-muted-text text-[11px]"},_n={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},Sn={class:"dashed-panel px-3 py-3"},kn={class:"theme-muted-text text-[11px]"},$n={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},Cn={class:"dashed-panel px-3 py-3"},Mn={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},jn={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},In={__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:H}=Ce();return(m,T)=>{var v,h,f,j,u,p,y;return r(),c("div",un,[e("div",pn,[e("div",vn,o(t(H)("projectManager.runtimeStatus")),1),e("div",hn,[e("span",{class:P(["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((h=d.activeSession)==null?void 0:h.id)?(r(),c("span",mn)):I("",!0),st(" "+o(d.getRuntimeStatusLabel((f=d.activeSession)==null?void 0:f.id)),1)],2),e("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",d.getThreadStatusClass(d.activeSession)])},o(d.getThreadStatusLabel(d.activeSession)),3),(j=d.activeSession)!=null&&j.id&&d.isCurrentSession(d.activeSession.id)?(r(),c("span",fn,o(t(H)("projectManager.currentProject")),1)):I("",!0)])]),e("div",gn,[e("div",xn,o(t(H)("projectManager.engine")),1),e("div",yn,o(t(Te)((u=d.activeSession)==null?void 0:u.engine)),1)]),e("div",bn,[e("div",wn,o(t(H)("projectManager.workingDirectory")),1),e("div",_n,o(((p=d.activeSession)==null?void 0:p.cwd)||t(H)("projectManager.notSet")),1)]),e("div",Sn,[e("div",kn,o(t(H)("projectManager.updatedAt")),1),e("div",$n,o(d.formatUpdatedAt((y=d.activeSession)==null?void 0:y.updatedAt)),1)]),e("div",Cn,[e("div",Mn,[M(t(Tt),{class:"h-3.5 w-3.5"}),e("span",null,o(t(H)("projectManager.note")),1)]),e("p",jn,o(t(H)("projectManager.noteDescription")),1)])])}}},Pn={class:"min-w-0"},Tn={class:"theme-heading truncate text-sm font-medium"},Ln={class:"grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[21rem_minmax(0,1fr)]"},Rn={class:"theme-divider flex min-h-0 flex-col border-b md:border-b-0 md:border-r"},Bn={class:"theme-divider border-b px-4 py-3"},Dn={class:"block"},En={class:"sr-only"},Fn={class:"relative"},Hn=["placeholder"],An={class:"mt-3 flex items-center gap-2"},Nn={class:"ml-auto flex h-8 w-8 items-center justify-center"},Un={class:"min-h-0 flex-1 overflow-y-auto p-2"},zn={key:0,class:"theme-empty-state px-3 py-4 text-xs"},On={key:1,class:"theme-status-danger rounded-sm border px-3 py-3 text-xs"},qn={key:2,class:"theme-empty-state px-3 py-4 text-xs"},Vn={key:3,class:"theme-empty-state px-3 py-4 text-xs"},Wn={key:4,class:"theme-empty-state px-3 py-4 text-xs"},Gn={key:5,class:"theme-empty-state px-3 py-4 text-xs"},Kn={key:6,class:"space-y-1"},Qn={key:0,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},Jn=["onMouseenter","onClick"],Xn={class:"min-w-0 flex-1"},Zn=["innerHTML"],Yn=["innerHTML"],ea={key:1,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},ta=["onMouseenter","onClick"],sa={class:"min-w-0 flex-1"},na=["innerHTML"],aa=["innerHTML"],la={key:7,class:"space-y-1"},oa=["onMouseenter"],ia={class:"flex items-start gap-1.5"},ra=["onClick"],da={key:1,class:"block h-5 w-5 shrink-0"},ca=["onClick"],ua={class:"flex min-h-0 flex-col overflow-hidden"},pa={class:"theme-divider border-b px-4 py-2"},va={key:0,class:"theme-muted-text truncate text-[11px]"},ha={class:"min-h-0 flex-1 overflow-auto px-4 py-3"},ma={key:0,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-sm"},fa={key:1,class:"theme-status-danger rounded-sm border px-4 py-3 text-sm"},ga={key:2,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-sm"},xa={key:3,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-sm"},ya={key:4,class:"source-browser-image-wrap flex min-h-[12rem] items-center justify-center rounded-sm border p-4"},ba=["src","alt"],wa={key:5,class:"theme-empty-state flex h-full min-h-[12rem] flex-col items-center justify-center gap-3 text-sm"},_a={class:"source-code-view"},Sa={class:"source-code-view__table"},ka=["innerHTML"],$a={__name:"CodexSessionSourceBrowserDialog",props:{open:{type:Boolean,default:!1},session:{type:Object,default:null}},emits:["close"],setup(d,{emit:H}){const m=d,T=H,{t:v}=Ce(),{isDark:h}=mt(),f=nt({open:!1,sessionId:"",query:""}),j=$(""),u=$(""),p=$(!1),y=$(""),k=$(null);let F=0;const E=C(()=>{var n;return String(((n=m.session)==null?void 0:n.id)||"").trim()}),B=C(()=>{var n;return String(((n=m.session)==null?void 0:n.cwd)||"").trim()}),N=C(()=>{var n;return((n=k.value)==null?void 0:n.name)||j.value||""}),Z=C(()=>{var n;return((n=k.value)==null?void 0:n.path)||j.value||""}),z=C(()=>{var n;return we(((n=k.value)==null?void 0:n.size)||0)}),O=C(()=>{var _,L;const n=[];return(Z.value||N.value)&&n.push(Z.value||N.value),(_=k.value)!=null&&_.size&&n.push(z.value),(L=k.value)!=null&&L.truncated&&n.push(v("sourceBrowser.truncated")),n.join(" ")}),J=C(()=>{var n;return!!((n=k.value)!=null&&n.previewUrl)}),le=C(()=>{var n,_;return!!((n=k.value)!=null&&n.binary&&!((_=k.value)!=null&&_.previewUrl))}),V=C(()=>!!(k.value&&!k.value.binary&&!k.value.previewUrl)),te=$(""),q=$(""),U=$(""),w=$("2.6rem"),{activeKey:W,activeTab:ue,currentError:Y,currentLoading:oe,getDisplayName:se,getHighlightedName:ie,getHighlightedPath:R,handleQueryChange:Me,handleSessionChange:ye,handleVisibleItemsChange:pe,initializeData:ve,normalSearchItems:ee,recentSearchItems:he,resetData:ne,setActiveTab:me,setItemRef:fe,showSearchEmptyState:Se,showSearchPromptState:ke,showTreeEmptyState:$e,toggleDirectory:G,treeItems:re,visibleItems:be}=_t({props:f,onSelect:i});function we(n=0){const _=Math.max(0,Number(n)||0);return _<1024?`${_} B`:_<1024*1024?`${(_/1024).toFixed(_<10*1024?1:0)} KB`:`${(_/(1024*1024)).toFixed(1)} MB`}function de(){F+=1,j.value="",u.value="",p.value=!1,y.value="",k.value=null,te.value="",q.value="",U.value="",w.value="2.6rem"}async function a(){var X,je,Ie;if(!V.value){te.value="",q.value="",U.value="";return}const n=F,_=String(((X=k.value)==null?void 0:X.content)||"").replace(/\r\n/g,`
2
+ `),L=((je=k.value)==null?void 0:je.language)||"",x=St(_,Re),D=await kt(((Ie=k.value)==null?void 0:Ie.content)||"",{isDark:h.value,language:L,maxHighlightLines:Re.maxLines,maxHighlightChars:Re.maxChars});n===F&&(te.value=D.html,q.value=x?"":D.bg||"",U.value=x?"":D.fg||"",w.value=D.gutterWidth||"2.6rem")}async function g(n=""){const _=String(n||"").trim();if(!E.value||!_)return;F+=1;const L=F;p.value=!0,y.value="";try{const x=await $t(E.value,{path:_,limit:204800,refreshToken:String(Date.now())});if(L!==F)return;k.value=x,await a()}catch(x){if(L!==F)return;k.value=null,y.value=(x==null?void 0:x.message)||v("sourceBrowser.previewFailed")}finally{L===F&&(p.value=!1)}}function i(n){if(W.value=(n==null?void 0:n.path)||"",j.value=String((n==null?void 0:n.path)||"").trim(),u.value=String((n==null?void 0:n.type)||"").trim(),y.value="",(n==null?void 0:n.type)==="directory"){k.value=null,ue.value==="tree"&&G(n.path);return}g(n==null?void 0:n.path)}return ae(()=>m.open,n=>{if(f.open=n,n){f.sessionId=E.value,f.query="",de(),ve();return}de(),ne()},{immediate:!0}),ae(E,n=>{f.sessionId=n,m.open&&(de(),ye())}),ae(()=>f.query,()=>{Me()}),ae(()=>be.value,()=>{pe()},{deep:!0}),ae(h,()=>{!m.open||!V.value||a()}),(n,_)=>(r(),Q(Ae,{open:d.open,"stack-level":2,"panel-class":"settings-dialog-panel h-full sm:h-[90vh] sm:w-[90vw] sm:max-w-[90vw]","header-class":"settings-dialog-header px-5 py-3.5","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col overflow-hidden",onClose:_[3]||(_[3]=L=>T("close"))},{title:xe(()=>[e("div",Pn,[e("div",Tn,o(B.value||t(v)("sourceBrowser.title")),1)])]),default:xe(()=>{var L;return[e("div",Ln,[e("aside",Rn,[e("div",Bn,[e("label",Dn,[e("span",En,o(t(v)("sourceBrowser.searchLabel")),1),e("div",Fn,[M(t(Le),{class:"theme-muted-text pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),Ye(e("input",{"onUpdate:modelValue":_[0]||(_[0]=x=>f.query=x),type:"text",class:"tool-input pl-9 text-sm",placeholder:t(v)("sourceBrowser.searchPlaceholder")},null,8,Hn),[[et,f.query]])])]),e("div",An,[e("button",{type:"button",class:P(["tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",t(ue)==="tree"?"tool-button-accent-subtle":""]),onClick:_[1]||(_[1]=x=>t(me)("tree"))},[M(t(ce),{class:"h-4 w-4"}),e("span",null,o(t(v)("sourceBrowser.treeTab")),1)],2),e("button",{type:"button",class:P(["tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",t(ue)==="search"?"tool-button-accent-subtle":""]),onClick:_[2]||(_[2]=x=>t(me)("search"))},[M(t(Le),{class:"h-4 w-4"}),e("span",null,o(t(v)("sourceBrowser.searchTab")),1)],2),e("div",Nn,[t(oe)?(r(),Q(t(Pe),{key:0,class:"theme-muted-text h-4 w-4 animate-spin"})):I("",!0)])])]),e("div",Un,[E.value?t(Y)?(r(),c("div",On,o(t(Y)),1)):t(ke)?(r(),c("div",qn,o(t(v)("sourceBrowser.searchPrompt")),1)):t(Se)?(r(),c("div",Vn,o(t(v)("sourceBrowser.searchEmpty")),1)):t($e)?(r(),c("div",Wn,o(t(v)("sourceBrowser.treeEmpty")),1)):t(oe)&&!t(be).length?(r(),c("div",Gn,o(t(v)("sourceBrowser.loadingFiles")),1)):t(ue)==="search"?(r(),c("div",Kn,[t(he).length?(r(),c("div",Qn,o(t(v)("sourceBrowser.recent")),1)):I("",!0),(r(!0),c(ge,null,_e(t(he),x=>(r(),c("button",{key:`recent-${x.path}`,ref_for:!0,ref:D=>t(fe)(x.path,D),type:"button",class:P(["flex w-full items-start gap-2 rounded-sm border border-transparent px-2.5 py-2 text-left transition",t(W)===x.path?"theme-list-item-active":"theme-list-item-hover"]),onMouseenter:D=>W.value=x.path,onClick:D=>i(x)},[(r(),Q(Be(x.type==="directory"?t(ce):t(De)),{class:"theme-muted-text mt-0.5 h-4 w-4 shrink-0"})),e("div",Xn,[e("div",null,[e("span",{class:"truncate text-[13px] text-[var(--theme-textPrimary)]",innerHTML:t(ie)(x)},null,8,Zn)]),e("div",{class:"theme-muted-text truncate font-mono text-[10px]",innerHTML:t(R)(x)},null,8,Yn)])],42,Jn))),128)),f.query.trim()&&t(ee).length?(r(),c("div",ea,o(t(v)("sourceBrowser.results")),1)):I("",!0),(r(!0),c(ge,null,_e(t(ee),x=>(r(),c("button",{key:`result-${x.path}`,ref_for:!0,ref:D=>t(fe)(x.path,D),type:"button",class:P(["flex w-full items-start gap-2 rounded-sm border border-transparent px-2.5 py-2 text-left transition",t(W)===x.path?"theme-list-item-active":"theme-list-item-hover"]),onMouseenter:D=>W.value=x.path,onClick:D=>i(x)},[(r(),Q(Be(x.type==="directory"?t(ce):t(De)),{class:"theme-muted-text mt-0.5 h-4 w-4 shrink-0"})),e("div",sa,[e("div",null,[e("span",{class:"truncate text-[13px] text-[var(--theme-textPrimary)]",innerHTML:t(ie)(x)},null,8,na)]),e("div",{class:"theme-muted-text truncate font-mono text-[10px]",innerHTML:t(R)(x)},null,8,aa)])],42,ta))),128))])):(r(),c("div",la,[(r(!0),c(ge,null,_e(t(re),x=>(r(),c("div",{key:x.path,ref_for:!0,ref:D=>t(fe)(x.path,D),class:P(["rounded-sm border border-transparent px-1.5 py-1 transition",t(W)===x.path?"theme-list-item-active":x.type==="directory"&&x.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Fe({paddingLeft:`${x.depth*16+6}px`}),onMouseenter:D=>W.value=x.path},[e("div",ia,[x.type==="directory"?(r(),c("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:tt(D=>t(G)(x.path),["stop"])},[x.loading?(r(),Q(t(Pe),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(r(),Q(t(at),{key:1,class:P(["h-3.5 w-3.5 transition",x.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,ra)):(r(),c("span",da)),e("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:D=>i(x)},[(r(),Q(Be(x.type==="directory"?t(ce):t(De)),{class:P(["h-4 w-4 shrink-0",x.type==="directory"&&x.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),e("span",{class:P(["min-w-0 flex-1 truncate text-[13px]",x.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},o(t(se)(x)),3)],8,ca)])],46,oa))),128))])):(r(),c("div",zn,o(t(v)("sourceBrowser.noProject")),1))])]),e("section",ua,[e("div",pa,[O.value?(r(),c("p",va,o(O.value),1)):I("",!0)]),e("div",ha,[p.value?(r(),c("div",ma,[e("span",null,o(t(v)("sourceBrowser.previewLoading")),1)])):y.value?(r(),c("div",fa,o(y.value),1)):u.value==="directory"?(r(),c("div",ga,o(t(v)("sourceBrowser.selectFileHint")),1)):j.value?J.value?(r(),c("div",ya,[e("img",{src:k.value.previewUrl,alt:N.value,class:"max-h-full max-w-full object-contain"},null,8,ba)])):le.value?(r(),c("div",wa,[M(t(Lt),{class:"h-8 w-8"}),e("span",null,o((L=k.value)!=null&&L.tooLarge?t(v)("sourceBrowser.binaryTooLarge"):t(v)("sourceBrowser.binaryUnsupported")),1)])):V.value?(r(),c("div",{key:6,class:"source-browser-code rounded-sm border",style:Fe({"--source-code-bg":q.value||"var(--theme-panel)","--source-code-fg":U.value||"var(--theme-textPrimary)","--source-code-gutter-width":w.value})},[e("div",_a,[e("table",Sa,[e("tbody",{innerHTML:te.value},null,8,ka)])])],4)):I("",!0):(r(),c("div",xa,o(t(v)("sourceBrowser.selectFile")),1))])])])]}),_:1},8,["open"]))}},Ca=ht($a,[["__scopeId","data-v-c0949126"]]),Ma={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ja={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},Ia={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"},Pa={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},Ta={class:"flex flex-wrap items-start justify-between gap-3"},La={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Ra={class:"mt-5"},Ba={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Da={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"},Ea={class:"flex flex-wrap items-center gap-2"},Fa=["disabled"],Ha=["disabled"],Aa=["disabled"],Na={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Ua=["disabled"],za=["disabled"],Oa=["disabled"],qa={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Va={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Wa={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},Ga={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ka={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Qa=["disabled"],Ja={class:"min-w-0 flex-1"},Xa={class:"theme-heading truncate text-sm font-medium"},Za={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Ya={class:"theme-divider border-b px-4 py-3"},el={class:"grid grid-cols-2 gap-2"},tl=["disabled"],sl={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},nl={key:0},al={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},ll={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},ol=["disabled"],il=["disabled"],rl=["disabled"],dl=["disabled"],gl={__name:"CodexSessionManagerDialog",props:{open:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]},workspaces:{type:Array,default:()=>[]},selectedSessionId:{type:String,default:""},selectionLocked:{type:Boolean,default:!1},selectionLockReason:{type:String,default:""},loading:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},onRefresh:{type:Function,default:null},onCreate:{type:Function,default:null},onUpdate:{type:Function,default:null},onDelete:{type:Function,default:null},onReset:{type:Function,default:null}},emits:["close","project-created","select-session"],setup(d,{emit:H}){const m=d,T=H,{locale:v,t:h}=Ce(),f=$("edit"),j=$(""),u=nt({title:"",engine:"codex",cwd:"",sessionId:""}),p=$(""),y=$(!1),k=$(!1),F=$(!1),E=$(!1),B=$(!1),N=$(!1),Z=$(!1),z=$(!1),O=$(!1),{matches:J}=Ct("(max-width: 767px)"),le=$("list"),V=$("basic"),te=$(He());let q=null;const U=C(()=>be(m.sessions)),w=C(()=>m.sessions.find(s=>s.id===j.value)||null),W=C(()=>m.sessions.length>0),ue=C(()=>m.sessions.find(s=>s.id===m.selectedSessionId)||null),Y=C(()=>!!(w.value&&G(w.value.id))),oe=C(()=>{var s;return!((s=w.value)!=null&&s.started)}),se=C(()=>{var s;return!((s=w.value)!=null&&s.started)}),ie=C(()=>{var s;return!((s=w.value)!=null&&s.started)}),R=C(()=>m.loading||y.value||k.value||F.value||E.value),Me=C(()=>String(u.sessionId||"").trim()),ye=C(()=>{var b,S;const s=new Set,l=[];return[u.cwd,(b=w.value)==null?void 0:b.cwd,(S=ue.value)==null?void 0:S.cwd,...m.workspaces,...m.sessions.map(K=>K.cwd)].forEach(K=>{const A=String(K||"").trim();!A||s.has(A)||(s.add(A),l.push(A))}),l.slice(0,12)}),pe=C(()=>te.value),ve=C(()=>{const s=$e(u.cwd);return s?m.sessions.filter(l=>{var b;return l.id===((b=w.value)==null?void 0:b.id)?!1:$e(l.cwd)===s}):[]}),ee=C(()=>{if(!ve.value.length)return"";const s=ve.value.slice(0,3).map(l=>{const b=l.title||h("projectManager.untitledProject");return v.value==="en-US"?`"${b}"`:`「${b}」`}).join(v.value==="en-US"?", ":"、");return h("projectManager.duplicateDirectory",{labels:s,count:ve.value.length})}),he=C(()=>f.value!=="edit"||oe.value?"":h("projectManager.cwdReadonly")),ne=C(()=>f.value!=="edit"||!w.value||se.value?"":h("projectManager.engineReadonly")),me=C(()=>f.value!=="edit"||!w.value||ie.value?"":h("projectManager.sessionIdReadonly")),fe=C(()=>f.value==="create"?y.value?h("projectManager.creatingProject"):h("projectManager.createProject"):k.value?h("projectManager.savingChanges"):h("projectManager.saveChanges")),Se=C(()=>{var s;return f.value==="create"?h("projectManager.newProject"):((s=w.value)==null?void 0:s.title)||h("projectManager.untitledProject")});function ke(s=""){const l=Date.parse(String(s||""));return Number.isFinite(l)?l:0}function $e(s=""){const l=String(s||"").trim();if(!l)return"";const b=/^[a-z]:[\\/]/i.test(l)||l.includes("\\");let S=l.replace(/\\/g,"/");return S.length>1&&!/^[a-z]:\/$/i.test(S)&&(S=S.replace(/\/+$/,"")),b?S.toLowerCase():S}function G(s){var l;return!!((l=m.sessions.find(b=>b.id===s))!=null&&l.running)}function re(s){return!!s&&s===m.selectedSessionId}function be(s=[]){return[...s].sort((l,b)=>{const S=Number(G(b.id))-Number(G(l.id));if(S)return S;const K=Number(re(b.id))-Number(re(l.id));if(K)return K;const A=ke(b.updatedAt)-ke(l.updatedAt);return A||gt(String(l.title||l.cwd||l.id),String(b.title||b.cwd||b.id))})}function we(s){return G(s)?h("projectManager.running"):h("projectManager.idle")}function de(s){return G(s)?"theme-status-warning":"theme-status-success"}function a(s){return s!=null&&s.started?h("projectManager.threadBound"):h("projectManager.notStarted")}function g(s){return s!=null&&s.started?"theme-status-success":"theme-status-neutral"}function i(s=""){if(!s)return h("projectManager.unknown");const l=new Date(s);return Number.isNaN(l.getTime())?s:ft(l.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function n(s){u.title=String((s==null?void 0:s.title)||""),u.engine=Ee(s==null?void 0:s.engine),u.cwd=String((s==null?void 0:s.cwd)||""),u.sessionId=String((s==null?void 0:s.sessionId)||(s==null?void 0:s.engineSessionId)||(s==null?void 0:s.engineThreadId)||(s==null?void 0:s.codexThreadId)||"").trim()}function _(){f.value="create",j.value="",p.value="",u.title="",u.engine="codex",u.cwd="",u.sessionId=""}function L(s){const l=m.sessions.find(b=>b.id===s);l&&(f.value="edit",j.value=l.id,p.value="",n(l))}function x(){var s;return m.selectedSessionId&&m.sessions.some(l=>l.id===m.selectedSessionId)?m.selectedSessionId:((s=U.value[0])==null?void 0:s.id)||""}function D(s="basic"){le.value="detail",V.value=s}function X(){le.value="list",V.value="basic"}function je(){_(),J.value&&D("basic")}function Ie(s){R.value||(L(s),J.value&&D("basic"))}function ot(s){u.cwd=String(s||"").trim()}function Ne(s){u.title=String(s||"")}function Ue(s){u.engine=Ee(s)}function ze(s){u.cwd=String(s||"")}function Oe(s){u.sessionId=String(s||"")}function qe(){p.value="",B.value=!1,N.value=!1,z.value=!1,O.value=!1,V.value="basic",le.value=J.value?"list":"detail";const s=x();if(s){L(s);return}_()}async function it(){if(!(R.value||typeof m.onRefresh!="function")){p.value="";try{await Promise.all([m.onRefresh(),Ve()])}catch(s){p.value=s.message}}}async function Ve(){try{te.value=await Nt()}catch{te.value=He()}}async function rt(s){var b;if((b=navigator.clipboard)!=null&&b.writeText&&window.isSecureContext){await navigator.clipboard.writeText(s);return}const l=document.createElement("textarea");l.value=s,l.setAttribute("readonly","true"),l.style.position="fixed",l.style.opacity="0",l.style.pointerEvents="none",document.body.appendChild(l),l.select(),document.execCommand("copy"),document.body.removeChild(l)}async function We(){const s=Me.value;if(s)try{await rt(s),O.value=!0,q&&clearTimeout(q),q=setTimeout(()=>{O.value=!1,q=null},1800)}catch(l){p.value=(l==null?void 0:l.message)||h("projectManager.copySessionIdFailed")}}async function Ge(){if(!R.value){p.value="";try{const s=dt();if(!s)return;await ct(s)}catch(s){p.value=s.message}}}function dt(){if(f.value==="create"){const l=String(u.cwd||"").trim();return l?{type:"create",cwd:l,payload:{title:u.title,engine:u.engine,cwd:l,sessionId:String(u.sessionId||"").trim()}}:(p.value=h("projectManager.directoryRequired"),null)}if(!w.value)return p.value=h("projectManager.projectMissing"),null;const s={title:u.title,engine:u.engine};return oe.value&&(s.cwd=u.cwd),ie.value&&(s.sessionId=String(u.sessionId||"").trim()),{type:"update",sessionId:w.value.id,payload:s}}async function ct(s){var l,b;if(s.type==="create"){y.value=!0;try{const S=await((l=m.onCreate)==null?void 0:l.call(m,s.payload));S!=null&&S.id&&(L(S.id),T("select-session",S.id),await jt(),T("project-created",S),T("close"));return}finally{y.value=!1}}k.value=!0;try{const S=await((b=m.onUpdate)==null?void 0:b.call(m,s.sessionId,s.payload));S!=null&&S.id&&L(S.id)}finally{k.value=!1}}async function ut(){var l,b;if(!w.value||F.value)return;const s=w.value.id;p.value="",F.value=!0;try{const S=await((l=m.onDelete)==null?void 0:l.call(m,s));B.value=!1;const K=m.sessions.filter(vt=>vt.id!==s),A=(S==null?void 0:S.selectedSessionId)||((b=be(K)[0])==null?void 0:b.id)||"";T("select-session",A),A?(L(A),J.value&&X()):(_(),J.value&&X())}catch(S){p.value=S.message}finally{F.value=!1}}async function pt(){var l;if(!w.value||E.value)return;const s=w.value.id;p.value="",E.value=!0;try{const b=await((l=m.onReset)==null?void 0:l.call(m,s));N.value=!1;const S=(b==null?void 0:b.session)||m.sessions.find(K=>K.id===s)||null;S!=null&&S.id&&L(S.id)}catch(b){p.value=b.message}finally{E.value=!1}}return ae(()=>m.open,s=>{if(s){qe(),typeof m.onRefresh=="function"?it().catch(()=>{}):Ve().catch(()=>{});return}Z.value=!1,B.value=!1,N.value=!1,z.value=!1,O.value=!1,p.value=""},{immediate:!0}),ae(J,s=>{s||(le.value="detail")},{immediate:!0}),ae(()=>m.sessions,()=>{if(!m.open)return;if(f.value==="create"){if(!!(String(u.title||"").trim()||String(u.cwd||"").trim())||!!String(u.sessionId||"").trim())return;const b=x();b&&L(b);return}if(w.value){n(w.value);return}const s=x();if(s){L(s);return}_()}),Mt(()=>{q&&(clearTimeout(q),q=null)}),(s,l)=>(r(),c(ge,null,[M(Qe,{open:N.value,title:t(h)("projectManager.confirmResetTitle"),description:w.value?t(h)("projectManager.confirmResetDescription",{title:w.value.title||t(h)("projectManager.untitledProject")}):"","confirm-text":t(h)("projectManager.confirmReset"),"cancel-text":t(h)("projectManager.keep"),loading:E.value,onCancel:l[0]||(l[0]=b=>N.value=!1),onConfirm:pt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),M(Qe,{open:B.value,title:t(h)("projectManager.confirmDeleteTitle"),description:w.value?t(h)("projectManager.confirmDeleteDescription",{title:w.value.title||t(h)("projectManager.untitledProject")}):"","confirm-text":t(h)("projectManager.confirmDelete"),"cancel-text":t(h)("projectManager.keep"),loading:F.value,danger:"",onCancel:l[1]||(l[1]=b=>B.value=!1),onConfirm:ut},null,8,["open","title","description","confirm-text","cancel-text","loading"]),M(_s,{open:Z.value,"initial-path":u.cwd,suggestions:ye.value,onClose:l[2]||(l[2]=b=>Z.value=!1),onSelect:ot},null,8,["open","initial-path","suggestions"]),M(Ca,{open:z.value,session:w.value,onClose:l[3]||(l[3]=b=>z.value=!1)},null,8,["open","session"]),M(Ae,{open:d.open,"panel-class":"settings-dialog-panel h-full max-w-5xl sm:h-auto sm:max-h-[88vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 overflow-hidden","close-disabled":R.value,"close-on-backdrop":!R.value,"close-on-escape":!R.value,onClose:l[15]||(l[15]=b=>T("close"))},{title:xe(()=>[e("div",Ma,[M(t(Ht),{class:"h-4 w-4"}),e("span",null,o(t(h)("projectManager.managingTitle")),1)])]),default:xe(()=>{var b,S,K;return[t(J)?(r(),c("div",qa,[le.value==="list"?(r(),c("div",Va,[e("div",Wa,[M(Ze,{mobile:"",busy:R.value,"editing-session-id":j.value,"format-updated-at":i,"get-runtime-status-class":de,"get-runtime-status-label":we,"get-thread-status-class":g,"get-thread-status-label":a,"has-sessions":W.value,"is-current-session":re,"is-session-running":G,mode:f.value,sessions:U.value,onCreate:je,onSelect:Ie},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])])])):(r(),c("div",Ga,[e("div",Ka,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",disabled:R.value,onClick:X},[M(t(Ft),{class:"h-4 w-4"}),e("span",null,o(t(h)("projectManager.projectList")),1)],8,Qa),e("div",Ja,[e("div",Xa,o(Se.value),1),f.value==="edit"&&((S=w.value)!=null&&S.cwd)?(r(),c("p",Za,o(w.value.cwd),1)):I("",!0)])]),e("div",Ya,[e("div",el,[e("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",V.value==="basic"?"tool-button-accent-subtle":""]),onClick:l[9]||(l[9]=A=>V.value="basic")},o(t(h)("projectManager.basicInfo")),3),e("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",V.value==="status"?"tool-button-accent-subtle":""]),disabled:f.value==="create",onClick:l[10]||(l[10]=A=>V.value="status")},o(t(h)("projectManager.status")),11,tl)])]),e("div",sl,[V.value==="basic"?(r(),c("div",nl,[M(Xe,{mobile:"",busy:R.value,"can-edit-engine":f.value!=="edit"||se.value,"can-edit-cwd":f.value!=="edit"||oe.value,"can-edit-session-id":f.value!=="edit"||ie.value,cwd:u.cwd,"cwd-readonly-message":he.value,"duplicate-cwd-message":ee.value,engine:u.engine,"engine-options":pe.value,"engine-readonly-message":ne.value,"session-id":u.sessionId,"session-id-copied":O.value,"session-id-readonly-message":me.value,title:u.title,"workspace-suggestions":ye.value,onCopySessionId:We,onOpenDirectoryPicker:l[11]||(l[11]=A=>Z.value=!0),"onUpdate:cwd":ze,"onUpdate:engine":Ue,"onUpdate:sessionId":Oe,"onUpdate:title":Ne},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","engine-options","engine-readonly-message","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"]),p.value?(r(),c("p",al,[M(t(Je),{class:"h-4 w-4"}),e("span",null,o(p.value),1)])):I("",!0),e("div",ll,[e("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-sm",disabled:R.value,onClick:Ge},o(fe.value),9,ol),f.value==="edit"&&w.value?(r(),c("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:R.value||!((K=w.value)!=null&&K.cwd),onClick:l[12]||(l[12]=A=>z.value=!0)},o(t(h)("projectManager.viewSource")),9,il)):I("",!0),f.value==="edit"&&w.value?(r(),c("button",{key:1,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:R.value||Y.value,onClick:l[13]||(l[13]=A=>N.value=!0)},o(E.value?t(h)("projectManager.resettingSession"):t(h)("projectManager.newSession")),9,rl)):I("",!0),f.value==="edit"&&w.value?(r(),c("button",{key:2,type:"button",class:"tool-button tool-button-danger-subtle w-full px-3 py-2 text-sm",disabled:R.value||Y.value,onClick:l[14]||(l[14]=A=>B.value=!0)},o(F.value?t(h)("projectManager.deletingProject"):t(h)("projectManager.deleteProject")),9,dl)):I("",!0)])])):(r(),Q(In,{key:1,"active-session":w.value,"format-updated-at":i,"get-runtime-status-class":de,"get-runtime-status-label":we,"get-thread-status-class":g,"get-thread-status-label":a,"is-current-session":re,"is-session-running":G},null,8,["active-session"]))])]))])):(r(),c("div",ja,[e("aside",Ia,[M(Ze,{busy:R.value,"editing-session-id":j.value,"format-updated-at":i,"get-runtime-status-class":de,"get-runtime-status-label":we,"get-thread-status-class":g,"get-thread-status-label":a,"has-sessions":W.value,"is-current-session":re,"is-session-running":G,mode:f.value,sessions:U.value,onCreate:je,onSelect:Ie},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])]),e("div",Pa,[e("div",Ta,[e("div",null,[e("div",La,[M(t(Rt),{class:"h-4 w-4"}),e("span",null,o(f.value==="create"?t(h)("projectManager.createTitle"):t(h)("projectManager.editTitle")),1)])])]),e("div",Ra,[M(Xe,{busy:R.value,"can-edit-engine":f.value!=="edit"||se.value,"can-edit-cwd":f.value!=="edit"||oe.value,"can-edit-session-id":f.value!=="edit"||ie.value,cwd:u.cwd,"cwd-readonly-message":he.value,"duplicate-cwd-message":ee.value,engine:u.engine,"engine-options":pe.value,"engine-readonly-message":ne.value,"session-id":u.sessionId,"session-id-copied":O.value,"session-id-readonly-message":me.value,title:u.title,"workspace-suggestions":ye.value,onCopySessionId:We,onOpenDirectoryPicker:l[4]||(l[4]=A=>Z.value=!0),"onUpdate:cwd":ze,"onUpdate:engine":Ue,"onUpdate:sessionId":Oe,"onUpdate:title":Ne},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","engine-options","engine-readonly-message","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"])]),p.value?(r(),c("p",Ba,[M(t(Je),{class:"h-4 w-4"}),e("span",null,o(p.value),1)])):I("",!0),e("div",Da,[e("div",Ea,[f.value==="edit"&&w.value?(r(),c("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:R.value||!((b=w.value)!=null&&b.cwd),onClick:l[5]||(l[5]=A=>z.value=!0)},[M(t(Bt),{class:"h-4 w-4"}),e("span",null,o(t(h)("projectManager.viewSource")),1)],8,Fa)):I("",!0),f.value==="edit"&&w.value?(r(),c("button",{key:1,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:R.value||Y.value,onClick:l[6]||(l[6]=A=>N.value=!0)},[M(t(Dt),{class:"h-4 w-4"}),e("span",null,o(E.value?t(h)("projectManager.resettingSession"):t(h)("projectManager.newSession")),1)],8,Ha)):I("",!0),f.value==="edit"&&w.value?(r(),c("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:R.value||Y.value,onClick:l[7]||(l[7]=A=>B.value=!0)},[M(t(Et),{class:"h-4 w-4"}),e("span",null,o(F.value?t(h)("projectManager.deletingProject"):t(h)("projectManager.deleteProject")),1)],8,Aa)):I("",!0)]),e("div",Na,[e("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:R.value,onClick:l[8]||(l[8]=A=>T("close"))},o(t(h)("projectManager.close")),9,Ua),f.value==="create"&&W.value?(r(),c("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:R.value,onClick:qe},o(t(h)("projectManager.backToList")),9,za)):I("",!0),e("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-xs sm:w-auto",disabled:R.value,onClick:Ge},o(fe.value),9,Oa)])])])]))]}),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"])],64))}};export{gl as default};
@@ -0,0 +1,2 @@
1
+ import{g as Ye,t as F,f as Ge,u as Re,b as Ze,a as et}from"./index-DFFeo0Jj.js";import{u as tt,g as Pe,l as st,r as at,e as nt,D as _e,a as it,i as lt,b as rt,_ as dt,c as ot}from"./WorkbenchView-BTxN9MWc.js";import{w as z,c as A,b as j,n as ut,aD as v,aE as x,aF as a,aR as ae,aS as Se,aL as T,aQ as u,aG as L,u as t,aW as De,aX as ct,aN as G,aI as je,aJ as oe,f as ft,a$ as Ae}from"./vendor-misc-DxKJ95A9.js";import{g as ht,e as Ne,C as Be,R as Ve,b as mt,d as vt,F as qe,h as ze,x as Ee}from"./vendor-ui-DlJXv6Z0.js";import"./vendor-router-iukOUtEP.js";import"./vendor-markdown-BENmzbO1.js";import"./vendor-tiptap-COqMdKic.js";function te(e,n,d=""){const h=n==="run"?"run":n==="task"?"task":"workspace";return[String(e||"").trim(),h,String(d||"").trim()].join("::")}function pt(e="",n=""){return`${String(e||"").trim()}::${String(n||"").trim()}`}function gt(e=""){return`${String(e||"").trim()}::`}function Je(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function we(e,n){const d=e.get(n);return d?(e.delete(n),e.set(n,d),Je(d)):null}function Te(e,n,d,h=0){for(e.delete(n),e.set(n,Je(d));h>0&&e.size>h;){const c=e.keys().next().value;if(typeof c>"u")break;e.delete(c)}}function se(e=""){const n=String(e||"").trim().toUpperCase();return n==="A"||n==="D"?n:"M"}function xt(e=""){const n=String(e||"");if(!n)return[];const d=n.split(`
2
+ `),h=[];let c=0,S=0;return d.forEach((y,r)=>{const R=y.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(R){c=Number(R[1]),S=Number(R[2]),h.push({id:`hunk-${r}`,kind:"hunk",oldNumber:"",newNumber:"",content:y});return}if(y.startsWith("+")&&!y.startsWith("+++")){h.push({id:`line-${r}`,kind:"add",oldNumber:"",newNumber:S,content:y}),S+=1;return}if(y.startsWith("-")&&!y.startsWith("---")){h.push({id:`line-${r}`,kind:"delete",oldNumber:c,newNumber:"",content:y}),c+=1;return}if(y.startsWith(" ")){h.push({id:`line-${r}`,kind:"context",oldNumber:c,newNumber:S,content:y}),c+=1,S+=1;return}h.push({id:`line-${r}`,kind:"meta",oldNumber:"",newNumber:"",content:y})}),h}function yt(e=""){const n=String(e||"").trim();if(!n)return"";const d=n.match(/^当前分支已从 (.+) 切换到 (.+)$/);return d?F("diffReview.warningBranchChanged",{from:d[1],to:d[2]}):n==="当前 HEAD 已不在基线 commit 的后续历史中,仓库可能经历了 reset、rebase 或切分支"?F("diffReview.warningHeadDetachedFromBaseline"):n}function Oe(e=""){const n=String(e||"").trim();if(!n)return"";const h=new Map([["二进制文件暂不支持在线 diff 预览。","diffReview.binaryPreviewUnavailable"],["文件内容较大,暂不展示具体 diff。","diffReview.fileTooLarge"],["diff 内容较长,暂不在页面内完整展示。","diffReview.diffTooLong"],["当前工作目录不是 Git 仓库,暂不支持代码变更审查。","diffReview.notGitRepo"],["任务不存在。","diffReview.taskNotFound"],["请选择一轮执行后再查看本轮代码变更。","diffReview.runRequired"],["没有找到对应的执行记录。","diffReview.runNotFound"],["这轮执行还没有建立代码变更基线,暂时无法查看本轮 diff。","diffReview.runBaselineMissing"],["当前任务还没有建立代码变更基线,请先让 Codex 执行一轮。","diffReview.taskBaselineMissing"],["这轮执行缺少结束快照,暂时无法准确还原本轮代码变更。","diffReview.runSnapshotMissing"],["原工作目录已不是有效的 Git 仓库,暂时无法读取代码变更。","diffReview.originalRepoInvalid"],["基线对应的 commit 已不存在,仓库可能被 reset、rebase 或切换到无关历史,暂时无法准确读取该范围的代码变更。","diffReview.baselineCommitMissing"]]).get(n);return h?F(h):n}function He(e=null){return!e||typeof e!="object"?e:{...e,reason:Oe(e.reason),warnings:Array.isArray(e.warnings)?e.warnings.map(n=>yt(n)).filter(Boolean):[],files:Array.isArray(e.files)?e.files.map(n=>({...n,message:Oe(n==null?void 0:n.message)})):[]}}function kt(e){const n=j("workspace"),d=j(""),h=j(""),c=j("all"),S=j(""),y=j([]),r=j(null),R=j(!1),H=j(!1),k=j(""),i=j(!1),b=j(null),w=j(0),$=new Map,N=tt();let E=0,o=0,P="",B="",O="",V=-1;const q=new Map,X=new Map,ne=new Map,ie=A(()=>y.value.filter(s=>s.completed)),ue=A(()=>{var l;const s={all:0,A:0,M:0,D:0};return(((l=r.value)==null?void 0:l.files)||[]).forEach(f=>{const g=se(f==null?void 0:f.status);s.all+=1,s[g]+=1}),s}),Y=A(()=>{var f;const s=((f=r.value)==null?void 0:f.files)||[],l=String(S.value||"").trim().toLowerCase();return s.filter(g=>c.value!=="all"&&se(g==null?void 0:g.status)!==c.value?!1:l?String((g==null?void 0:g.path)||"").toLowerCase().includes(l):!0)}),ce=A(()=>{const s=Y.value;return s.find(l=>l.path===h.value)||s[0]||null}),de=A(()=>{var s;return xt(((s=ce.value)==null?void 0:s.patch)||"")}),W=A(()=>de.value.map((s,l)=>({...s,index:l})).filter(s=>s.kind==="hunk")),fe=A(()=>{var s,l;return H.value&&!((l=(s=r.value)==null?void 0:s.summary)!=null&&l.statsComplete)}),Z=A(()=>{var f;const s=((f=r.value)==null?void 0:f.baseline)||null;if(!(s!=null&&s.createdAt)&&!(s!=null&&s.headShort))return"";const l=[];return s.createdAt&&l.push(F("diffReview.baselineTime",{value:Ge(s.createdAt)})),s.branch&&l.push(F("diffReview.baselineBranch",{value:s.branch})),s.headShort&&l.push(F("diffReview.baselineCommit",{value:s.headShort})),s.currentHeadShort&&l.push(F("diffReview.currentHead",{value:s.currentHeadShort})),l.join(" · ")});function M(s){return(s==null?void 0:s.status)==="completed"?F("diffReview.completed"):(s==null?void 0:s.status)==="error"?F("diffReview.failed"):(s==null?void 0:s.status)==="interrupted"?F("diffReview.interrupted"):F("diffReview.stopped")}function C(s,l){if(s){if(l){$.set(s,l);return}$.delete(s)}}function he(s,l={}){const f=W.value;if(!f.length)return;const g=Math.min(Math.max(0,Number(s)||0),f.length-1),I=f[g],_=$.get(I.id);_&&(w.value=g,_.scrollIntoView({block:l.block||"center",behavior:l.behavior||"smooth"}))}function me(s=1){W.value.length&&he(w.value+s)}function U(s){return`${new Date((s==null?void 0:s.startedAt)||(s==null?void 0:s.createdAt)).toLocaleString(Ye())} · ${M(s)}`}function m(){const s=ie.value;if(!s.length){d.value="";return}s.some(l=>l.id===d.value)||(d.value=s[0].id)}function ee(){const s=Y.value;if(!s.length){h.value="";return}s.some(l=>l.path===h.value)||(h.value=s[0].path)}function ve(s=""){return se(s)==="A"?F("diffReview.added"):se(s)==="D"?F("diffReview.deleted"):F("diffReview.modified")}function pe(s=""){return se(s)==="A"?"theme-status-success":se(s)==="D"?"theme-status-danger":"theme-status-warning"}function ge(s="all"){return s==="A"?F("diffReview.added"):s==="D"?F("diffReview.deleted"):s==="M"?F("diffReview.modified"):F("diffReview.all")}function xe(s="all"){return c.value===s?"theme-filter-active":"theme-filter-idle"}function p(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 le(s,l=""){const f=String(l||"").trim();f&&Array.from(s.keys()).forEach(g=>{String(g||"").startsWith(f)&&s.delete(g)})}function Ce(){const s=gt(e.taskSlug);le(q,s),le(X,s),le(ne,s)}async function Ke(){if(!e.taskSlug){y.value=[],d.value="",O="",V=-1;return}const s=N.getTaskRunSyncVersion(e.taskSlug);if(O===e.taskSlug&&V===s)return;const l=await st(e.taskSlug,{limit:20,events:"none"});y.value=l.items||[],O=e.taskSlug,V=s,m()}async function Fe(){if(!e.taskSlug||!e.active)return;const s=++E;R.value=!0,H.value=!1,k.value="";try{const l=n.value==="run"?"run":n.value==="task"?"task":"workspace";l==="run"&&await Ke();const f=te(e.taskSlug,l,l==="run"?d.value:"");if(l==="run"&&!d.value){r.value={supported:!1,reason:F("diffReview.noReviewRuns"),repoRoot:"",summary:{fileCount:0,additions:0,deletions:0,statsComplete:!0},files:[]},ee();return}const g=we(q,f);if(g){r.value=g,P=f;const D=we(X,f);D?(r.value={...g,baseline:D.baseline||g.baseline||null,warnings:D.warnings||g.warnings||[],summary:D.summary||g.summary},B=f):B="",ee(),ye().catch(()=>{}),D||Ie().catch(()=>{});return}const I=await Pe(e.taskSlug,{scope:l,runId:l==="run"?d.value:"",includeStats:!1});if(s!==E)return;const _=He(I);r.value=_,Te(q,f,_,36),P=f,B="",ee(),ye().catch(()=>{}),Ie().catch(()=>{})}catch(l){if(s!==E)return;k.value=l.message,r.value=null}finally{s===E&&(R.value=!1)}}async function Ie(){var I,_,D;if(!e.taskSlug||!e.active||!((I=r.value)!=null&&I.supported))return;const s=n.value==="run"?"run":n.value==="task"?"task":"workspace",l=s==="run"?d.value:"",f=te(e.taskSlug,s,l);if(B===f&&((D=(_=r.value)==null?void 0:_.summary)!=null&&D.statsComplete))return;const g=we(X,f);if(g){r.value={...r.value,baseline:g.baseline||r.value.baseline||null,warnings:g.warnings||r.value.warnings||[],summary:g.summary||r.value.summary},B=f,H.value=!1;return}H.value=!0;try{const K=await Pe(e.taskSlug,{scope:s,runId:l,includeFiles:!1,includeStats:!0}),re=te(e.taskSlug,n.value,n.value==="run"?d.value:"");if(f!==re||!r.value)return;const J=He(K);r.value={...r.value,baseline:J.baseline||r.value.baseline||null,warnings:J.warnings||r.value.warnings||[],summary:J.summary||r.value.summary},Te(X,f,{baseline:J.baseline||null,warnings:J.warnings||[],summary:J.summary||null},36),B=f}catch{}finally{const K=te(e.taskSlug,n.value,n.value==="run"?d.value:"");f===K&&(H.value=!1)}}async function ye(){var re,J,Me;const s=String(h.value||"").trim();if(!e.taskSlug||!e.active||!s||i.value)return;const l=n.value==="run"?"run":n.value==="task"?"task":"workspace",f=l==="run"?d.value:"",g=te(e.taskSlug,l,f),I=(((re=r.value)==null?void 0:re.files)||[]).find(Q=>Q.path===s);if(!I||I.patchLoaded||I.binary||I.tooLarge||I.message)return;const _=pt(g,s),D=we(ne,_);if(D&&((J=r.value)!=null&&J.files)){r.value={...r.value,files:r.value.files.map(Q=>Q.path===s?D:Q)};return}const K=++o;i.value=!0;try{const Q=await Pe(e.taskSlug,{scope:l,runId:f,filePath:s});if(K!==o)return;const Xe=te(e.taskSlug,n.value,n.value==="run"?d.value:"");if(g!==Xe)return;const Le=He(Q),$e=(Le.files||[]).find(be=>be.path===s);if(!$e||!((Me=r.value)!=null&&Me.files))return;Te(ne,_,$e,120),r.value={...r.value,baseline:Le.baseline||r.value.baseline||null,warnings:Le.warnings||r.value.warnings||[],files:r.value.files.map(be=>be.path===s?$e:be)}}catch(Q){k.value=Q.message}finally{K===o&&(i.value=!1,String(h.value||"").trim()!==s&&ye().catch(()=>{}))}}function ke({force:s=!1}={}){if(!e.taskSlug||!e.active)return;const l=te(e.taskSlug,n.value,n.value==="run"?d.value:"");!s&&l===P||Fe().catch(()=>{})}async function Qe(){!e.taskSlug||!e.active||R.value||(Ce(),P="",B="",O="",V=-1,await Fe())}return z(()=>[e.taskSlug,e.active,n.value,d.value],([s,l],f=[])=>{const g=f[0]||"";s!==g&&(h.value="",P="",y.value=[],d.value="",O="",V=-1,B=""),!(!s||!l)&&ke()},{immediate:!0}),z(()=>{var s,l;return[c.value,((l=(s=r.value)==null?void 0:s.files)==null?void 0:l.length)||0]},()=>{ee()}),z(()=>[h.value,W.value.length],()=>{w.value=0,$.clear(),ut(()=>{var s,l;W.value.length?he(0,{behavior:"auto",block:"start"}):(l=(s=b.value)==null?void 0:s.scrollTo)==null||l.call(s,{top:0,behavior:"auto"})})}),z(()=>h.value,()=>{ye().catch(()=>{})},{immediate:!0}),z(()=>[e.preferredScope,e.preferredRunId,e.focusToken],([s,l,f],g=[])=>{const I=Number(g[2]||0),_=s==="run"?"run":s==="task"?"task":"workspace",D=_==="run"&&l?String(l||""):"",K=n.value!==_,re=_==="run"&&D&&d.value!==D;n.value=_,D&&(d.value=D),_!=="run"&&(d.value=""),!K&&!re&&e.active&&e.taskSlug&&f!==I&&(P="",ke())},{immediate:!0}),z(()=>N.readyVersion.value,()=>{!e.active||!e.taskSlug||(O="",V=-1,P="",B="",ke({force:!0}))}),z(()=>N.getTaskDiffSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||(O="",V=-1,B="",P="",ke({force:!0}))}),{activeHunkIndex:w,baselineMetaText:Z,diffPayload:r,diffScope:n,error:k,fileSearch:S,filteredFiles:Y,getFilterButtonClass:xe,getFilterLabel:ge,getPatchLineClass:p,getRunStatusLabel:M,getStatusClass:pe,getStatusLabel:ve,jumpToAdjacentHunk:me,loadDiff:Fe,loading:R,normalizeFileStatus:se,patchLoading:i,patchViewportRef:b,runs:y,selectedFile:ce,selectedFilePath:h,selectedPatchHunks:W,selectedPatchLines:de,selectedRunId:d,setPatchLineRef:C,showSummarySkeleton:fe,statsLoading:H,statusCounts:ue,statusFilter:c,terminalRuns:ie,formatRunOptionLabel:U,refreshDiff:Qe}}const bt={class:"mb-3 grid grid-cols-2 gap-2"},wt=["onClick"],St={class:"theme-input-shell mb-3 flex items-center gap-2 rounded-sm border px-3 py-2 text-xs text-[var(--theme-textMuted)]"},Rt=["placeholder"],Ct={key:0,class:"theme-empty-state theme-empty-state-strong mb-3 px-3 py-2 text-[11px]"},Ft={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Lt={key:2,class:"theme-empty-state px-3 py-4 text-xs"},$t={key:3,class:"space-y-2"},Pt=["onClick"],_t={class:"flex items-start gap-2"},Tt={class:"min-w-0 flex-1"},Ht={class:"break-all text-xs font-medium"},Dt={class:"mt-1 text-[11px] opacity-75"},We={__name:"TaskDiffFileList",props:{diffPayload:{type:Object,default:null},fileSearch:{type:String,default:""},filteredFiles:{type:Array,default:()=>[]},getFilterButtonClass:{type:Function,default:()=>""},getFilterLabel:{type:Function,default:e=>e},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},selectedFilePath:{type:String,default:""},showSummarySkeleton:{type:Boolean,default:!1},statusCounts:{type:Object,default:()=>({})},statusFilter:{type:String,default:"all"}},emits:["select-file","update:fileSearch","update:statusFilter"],setup(e,{emit:n}){const d=e,h=n,{t:c}=Re(),S=A({get:()=>d.fileSearch,set:R=>h("update:fileSearch",R)}),y=A({get:()=>d.statusFilter,set:R=>h("update:statusFilter",R)}),r=A(()=>{var R;return Array.isArray((R=d.diffPayload)==null?void 0:R.files)&&d.diffPayload.files.length>0});return(R,H)=>(v(),x(ae,null,[a("div",bt,[(v(),x(ae,null,Se(["all","A","M","D"],k=>a("button",{key:k,type:"button",class:T(["inline-flex w-full items-center justify-center gap-1 whitespace-nowrap rounded-sm border px-2 py-1 text-[11px] transition",e.getFilterButtonClass(k)]),onClick:i=>y.value=k},u(e.getFilterLabel(k))+" "+u(e.statusCounts[k]||0),11,wt)),64))]),a("label",St,[L(t(ht),{class:"h-3.5 w-3.5 shrink-0"}),De(a("input",{"onUpdate:modelValue":H[0]||(H[0]=k=>S.value=k),type:"text",placeholder:t(c)("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,Rt),[[ct,S.value]])]),e.showSummarySkeleton?(v(),x("div",Ct,u(t(c)("diffReview.statsPending")),1)):G("",!0),r.value?e.filteredFiles.length?(v(),x("div",$t,[(v(!0),x(ae,null,Se(e.filteredFiles,k=>(v(),x("button",{key:k.path,type:"button",class:T(["w-full rounded-sm border px-3 py-2 text-left transition",k.path===e.selectedFilePath?"theme-filter-active":"theme-filter-idle"]),onClick:i=>h("select-file",k.path)},[a("div",_t,[a("span",{class:T(["inline-flex shrink-0 rounded-sm border px-1.5 py-0.5 text-[10px]",e.getStatusClass(k.status)])},u(e.getStatusLabel(k.status)),3),a("div",Tt,[a("div",Ht,u(k.path),1),a("div",Dt,u(k.statsLoaded?`+${k.additions} / -${k.deletions}`:t(c)("diffReview.statsOnDemand")),1)])])],10,Pt))),128))])):(v(),x("div",Lt,u(t(c)("diffReview.noMatches")),1)):(v(),x("div",Ft,u(t(c)("diffReview.noChanges")),1))],64))}},jt={key:0,class:"flex h-full min-h-0 flex-col overflow-hidden"},It={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-xs"},Mt={class:"space-y-3 sm:hidden"},At={class:"flex items-start gap-2"},Nt={class:"min-w-0 break-all font-medium text-[var(--theme-textPrimary)]"},Bt={class:"flex items-center justify-between gap-3"},Vt={class:"opacity-75"},zt=["disabled"],Et={class:"min-w-[64px] text-center text-[11px] text-[var(--theme-textSecondary)]"},Ot=["disabled"],Wt={class:"hidden items-center gap-3 sm:flex"},Ut={class:"flex min-w-0 flex-1 flex-wrap items-center gap-2"},Gt={class:"break-all font-medium text-[var(--theme-textPrimary)]"},qt={class:"opacity-75"},Jt=["disabled"],Kt={class:"min-w-[64px] text-center text-[11px] text-[var(--theme-textSecondary)]"},Qt=["disabled"],Xt={key:0,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-sm"},Yt={class:"theme-empty-state px-4 py-4"},Zt={key:1,class:"theme-muted-text flex-1 overflow-y-auto px-4 py-4 text-sm"},es={class:"min-w-max px-4 py-4 font-mono text-[11px] leading-5"},ts={class:"task-diff-row__number select-none"},ss={class:"task-diff-row__number select-none"},as=["innerHTML"],ns={key:3,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-sm"},is={class:"theme-empty-state px-4 py-4"},ls={key:1,class:"theme-muted-text flex h-full items-center justify-center px-5 text-sm"},rs={__name:"TaskDiffPatchView",props:{activeHunkIndex:{type:Number,default:0},getPatchLineClass:{type:Function,default:()=>""},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},jumpToAdjacentHunk:{type:Function,default:()=>{}},patchLoading:{type:Boolean,default:!1},selectedFile:{type:Object,default:null},selectedPatchHunks:{type:Array,default:()=>[]},selectedPatchLines:{type:Array,default:()=>[]},setPatchLineRef:{type:Function,default:()=>{}},setPatchViewportRef:{type:Function,default:()=>{}}},setup(e){const n=e,{t:d}=Re(),{isDark:h}=et(),c=j([]),S=A(()=>{var i;return lt(((i=n.selectedFile)==null?void 0:i.path)||"")});function y(i){return(i==null?void 0:i.kind)==="add"?"+":(i==null?void 0:i.kind)==="delete"?"-":(i==null?void 0:i.kind)==="context"?" ":""}function r(i){const b=String((i==null?void 0:i.content)||"");return(i==null?void 0:i.kind)==="add"||(i==null?void 0:i.kind)==="delete"||(i==null?void 0:i.kind)==="context"?b.slice(1):b}function R(i=""){return String(i||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function H(i,b=""){if((i==null?void 0:i.kind)==="add"||(i==null?void 0:i.kind)==="delete"||(i==null?void 0:i.kind)==="context"){const w=y(i),$=`task-diff-line__prefix--${i.kind}`;return{...i,renderedHtml:`<span class="task-diff-line__prefix ${$}">${R(w||" ")}</span><span class="task-diff-line__body">${b||"&#8203;"}</span>`}}return{...i,renderedHtml:R(String((i==null?void 0:i.content)||""))}}async function k(){const i=Array.isArray(n.selectedPatchLines)?n.selectedPatchLines:[],b=[];i.forEach((o,P)=>{((o==null?void 0:o.kind)==="add"||(o==null?void 0:o.kind)==="delete"||(o==null?void 0:o.kind)==="context")&&b.push({lineIndex:P,body:r(o)})});const w=at(b.map(o=>o.body));let $=0;if(c.value=i.map(o=>{if((o==null?void 0:o.kind)==="add"||(o==null?void 0:o.kind)==="delete"||(o==null?void 0:o.kind)==="context"){const P=w[$]||"&#8203;";return $+=1,H(o,P)}return H(o)}),!b.length||nt(b.map(o=>o.body),_e))return;const N=await it(b.map(o=>o.body),{isDark:h.value,language:S.value,maxHighlightLines:_e.maxLines,maxHighlightChars:_e.maxChars});let E=0;c.value=i.map(o=>{if((o==null?void 0:o.kind)==="add"||(o==null?void 0:o.kind)==="delete"||(o==null?void 0:o.kind)==="context"){const P=N[E]||"&#8203;";return E+=1,H(o,P)}return H(o)})}return z(()=>{var i;return[n.selectedPatchLines,(i=n.selectedFile)==null?void 0:i.path,h.value]},()=>{k()},{immediate:!0,deep:!0}),(i,b)=>e.selectedFile?(v(),x("div",jt,[a("div",It,[a("div",Mt,[a("div",At,[a("span",{class:T(["inline-flex shrink-0 rounded-sm border px-1.5 py-0.5 text-[10px]",e.getStatusClass(e.selectedFile.status)])},u(e.getStatusLabel(e.selectedFile.status)),3),a("span",Nt,u(e.selectedFile.path),1)]),a("div",Bt,[a("span",Vt,u(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(d)("diffReview.statsOnDemand")),1),a("div",{class:T(["inline-flex h-8 shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:b[0]||(b[0]=w=>e.jumpToAdjacentHunk(-1))},[L(t(Ne),{class:"h-4 w-4"})],8,zt),a("span",Et,u(t(d)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:b[1]||(b[1]=w=>e.jumpToAdjacentHunk(1))},[L(t(Be),{class:"h-4 w-4"})],8,Ot)],2)])]),a("div",Wt,[a("div",Ut,[a("span",{class:T(["inline-flex rounded-sm border px-1.5 py-0.5 text-[10px]",e.getStatusClass(e.selectedFile.status)])},u(e.getStatusLabel(e.selectedFile.status)),3),a("span",Gt,u(e.selectedFile.path),1),a("span",qt,u(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(d)("diffReview.statsOnDemand")),1)]),a("div",{class:T(["inline-flex h-8 w-[132px] shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:b[2]||(b[2]=w=>e.jumpToAdjacentHunk(-1))},[L(t(Ne),{class:"h-4 w-4"})],8,Jt),a("span",Kt,u(t(d)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:b[3]||(b[3]=w=>e.jumpToAdjacentHunk(1))},[L(t(Be),{class:"h-4 w-4"})],8,Qt)],2)])]),e.selectedFile.message?(v(),x("div",Xt,[a("div",Yt,u(e.selectedFile.message),1)])):e.patchLoading&&!e.selectedFile.patchLoaded?(v(),x("div",Zt,u(t(d)("diffReview.loadingFileDiff")),1)):e.selectedPatchLines.length?(v(),x("div",{key:2,ref:e.setPatchViewportRef,class:"flex-1 overflow-auto"},[a("div",es,[(v(!0),x(ae,null,Se(c.value,w=>{var $;return v(),x("div",{key:w.id,ref_for:!0,ref:N=>e.setPatchLineRef(w.id,N),class:T(["task-diff-row grid",[e.getPatchLineClass(w.kind),w.kind==="hunk"&&(($=e.selectedPatchHunks[e.activeHunkIndex])==null?void 0:$.id)===w.id?"ring-1 ring-inset ring-[var(--theme-warning)]":""]])},[a("span",ts,u(w.oldNumber),1),a("span",ss,u(w.newNumber),1),a("pre",{class:T(["task-diff-line overflow-visible whitespace-pre px-3 py-0.5",w.kind==="meta"||w.kind==="hunk"?"task-diff-line--plain":""]),innerHTML:w.renderedHtml},null,10,as)],2)}),128))])],512)):(v(),x("div",ns,[a("div",is,u(t(d)("diffReview.noFileDiffContent")),1)]))])):(v(),x("div",ls,u(t(d)("diffReview.selectFile")),1))}},Ue=Ze(rs,[["__scopeId","data-v-1a81fddc"]]),ds={class:"panel flex h-full min-h-0 flex-col overflow-hidden"},os={class:"theme-divider border-b px-4 py-3"},us={class:"flex flex-col gap-2"},cs={class:"grid grid-cols-4 gap-2 sm:flex sm:flex-wrap sm:items-center"},fs={class:"sm:hidden"},hs={class:"hidden sm:inline"},ms={class:"sm:hidden"},vs={class:"hidden sm:inline"},ps=["disabled"],gs={class:"sm:hidden"},xs={class:"hidden sm:inline"},ys={class:"truncate text-xs text-[var(--theme-textPrimary)]"},ks={class:"theme-divider theme-muted-text border-b border-dashed px-3 py-2 text-[11px]"},bs=["onClick"],ws={class:"flex items-start gap-3"},Ss={class:"min-w-0 flex-1"},Rs={class:"truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Cs={class:"theme-muted-text mt-1 text-[11px]"},Fs={key:0,class:"theme-divider theme-danger-text border-b px-4 py-3 text-sm"},Ls={class:"inline-flex items-start gap-2"},$s={class:"break-all"},Ps={key:1,class:"theme-muted-text flex flex-1 items-center justify-center px-5 text-sm"},_s={key:2,class:"flex flex-1 items-center justify-center px-5"},Ts={class:"theme-empty-state w-full max-w-xl px-4 py-5 text-sm text-[var(--theme-textSecondary)]"},Hs={class:"theme-heading inline-flex items-center gap-2 font-medium"},Ds={class:"mt-2 break-all leading-7"},js={key:0,class:"mt-3 flex flex-wrap gap-2 text-xs"},Is={class:"theme-status-neutral inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},Ms={class:"break-all"},As={key:0,class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},Ns={key:3,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Bs={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-xs"},Vs={class:"flex flex-wrap items-center gap-2"},zs={key:0,class:"theme-status-info inline-flex min-w-0 items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},Es={class:"min-w-0 break-all"},Os={class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},Ws={class:"text-[var(--theme-textPrimary)]"},Us={class:"font-medium text-[var(--theme-success)]"},Gs={class:"font-medium text-[var(--theme-danger)]"},qs={key:2,class:"opacity-75"},Js={key:0,class:"mt-2 break-all text-[11px] opacity-75"},Ks={key:1,class:"mt-2 flex flex-col gap-1"},Qs={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Xs={class:"theme-divider border-b px-3 py-3"},Ys={class:"grid grid-cols-2 gap-2"},Zs=["disabled"],ea={class:"theme-divider theme-muted-panel min-h-0 flex-1 overflow-y-auto p-3"},ta={class:"min-h-0 flex-1 overflow-hidden bg-[var(--theme-appPanelStrong)]"},sa={key:1,class:"grid min-h-0 flex-1 grid-cols-[320px_minmax(0,1fr)] overflow-hidden"},aa={class:"theme-divider theme-muted-panel min-h-0 overflow-y-auto border-r p-3"},na={class:"min-h-0 overflow-hidden bg-[var(--theme-appPanelStrong)]"},ia={__name:"TaskDiffReviewPanel",props:{taskSlug:{type:String,default:""},preferredScope:{type:String,default:"workspace"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0},active:{type:Boolean,default:!1}},setup(e){const n=e,{activeHunkIndex:d,baselineMetaText:h,diffPayload:c,diffScope:S,error:y,fileSearch:r,filteredFiles:R,formatRunOptionLabel:H,getFilterButtonClass:k,getFilterLabel:i,getPatchLineClass:b,getRunStatusLabel:w,getStatusClass:$,getStatusLabel:N,jumpToAdjacentHunk:E,loading:o,patchLoading:P,patchViewportRef:B,refreshDiff:O,selectedFile:V,selectedFilePath:q,selectedPatchHunks:X,selectedPatchLines:ne,selectedRunId:ie,setPatchLineRef:ue,showSummarySkeleton:Y,statsLoading:ce,statusCounts:de,statusFilter:W,terminalRuns:fe}=kt(n),{matches:Z}=rt("(max-width: 767px)"),M=j("files"),{t:C}=Re();function he(U){q.value=U,Z.value&&(M.value="patch")}function me(U){B.value=U||null}return z(Z,U=>{U||(M.value="files")},{immediate:!0}),z(q,U=>{!U&&Z.value&&(M.value="files")}),z(S,()=>{Z.value&&(M.value="files")}),(U,m)=>{var ee,ve,pe,ge,xe;return v(),x("section",ds,[a("div",os,[a("div",us,[a("div",cs,[a("button",{type:"button",class:T(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(S)==="workspace"?"theme-filter-active":""]),onClick:m[0]||(m[0]=p=>S.value="workspace")},[a("span",fs,u(t(C)("diffReview.scopeCurrentShort")),1),a("span",hs,u(t(C)("diffReview.scopeCurrent")),1)],2),a("button",{type:"button",class:T(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(S)==="task"?"theme-filter-active":""]),onClick:m[1]||(m[1]=p=>S.value="task")},[a("span",ms,u(t(C)("diffReview.scopeTaskShort")),1),a("span",vs,u(t(C)("diffReview.scopeTask")),1)],2),a("button",{type:"button",class:T(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(S)==="run"?"theme-filter-active":""]),onClick:m[2]||(m[2]=p=>S.value="run")},[a("span",null,u(t(C)("diffReview.scopeRun")),1)],2),a("button",{type:"button",class:"tool-button tool-button-info-subtle inline-flex shrink-0 items-center justify-center gap-2 px-3 py-2 text-xs",disabled:t(o),onClick:m[3]||(m[3]=(...p)=>t(O)&&t(O)(...p))},[L(t(Ve),{class:T(["h-3.5 w-3.5 sm:hidden",t(o)?"animate-spin":""])},null,8,["class"]),a("span",gs,u(t(C)("diffReview.refresh")),1),L(t(Ve),{class:T(["hidden h-3.5 w-3.5 sm:inline-block",t(o)?"animate-spin":""])},null,8,["class"]),a("span",xs,u(t(o)?t(C)("diffReview.refreshing"):t(ce)?t(C)("diffReview.computing"):t(C)("diffReview.refresh")),1)],8,ps)]),t(S)==="run"?(v(),je(dt,{key:0,modelValue:t(ie),"onUpdate:modelValue":m[4]||(m[4]=p=>ft(ie)?ie.value=p:null),class:"min-w-0 sm:max-w-[360px]",options:t(fe),loading:t(o),"get-option-value":p=>(p==null?void 0:p.id)||"",placeholder:t(C)("diffReview.selectRun"),"empty-text":t(C)("diffReview.noRuns")},{trigger:oe(({selectedOption:p})=>[a("div",ys,u(p?t(H)(p):t(C)("diffReview.selectRun")),1)]),header:oe(()=>[a("div",ks,u(t(C)("diffReview.runCount",{count:t(fe).length})),1)]),option:oe(({option:p,selected:le,select:Ce})=>[a("button",{type:"button",class:T(["w-full rounded-sm border border-dashed px-3 py-2 text-left transition",le?"theme-filter-active":"theme-filter-idle"]),onClick:Ce},[a("div",ws,[a("div",Ss,[a("div",Rs,u(t(Ge)(p.startedAt||p.createdAt)),1),a("div",Cs,u(t(w)(p)),1)]),le?(v(),je(t(mt),{key:0,class:"mt-0.5 h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):G("",!0)])],10,bs)]),_:1},8,["modelValue","options","loading","get-option-value","placeholder","empty-text"])):G("",!0)])]),t(y)?(v(),x("div",Fs,[a("div",Ls,[L(t(vt),{class:"mt-0.5 h-4 w-4 shrink-0"}),a("span",$s,u(t(y)),1)])])):G("",!0),t(o)&&!t(c)?(v(),x("div",Ps,u(t(C)("diffReview.loading")),1)):t(c)&&!t(c).supported?(v(),x("div",_s,[a("div",Ts,[a("div",Hs,[L(t(qe),{class:"h-4 w-4"}),a("span",null,u(t(C)("diffReview.unavailableTitle")),1)]),a("p",Ds,u(t(c).reason||t(C)("diffReview.unavailableReason")),1),t(c).repoRoot?(v(),x("div",js,[a("div",Is,[L(t(ze),{class:"h-3.5 w-3.5 shrink-0"}),a("span",Ms,u(t(c).repoRoot),1)]),t(c).branch?(v(),x("div",As,[L(t(Ee),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,u(t(c).branch),1)])):G("",!0)])):G("",!0)])])):t(c)?(v(),x("div",Ns,[a("div",Bs,[a("div",Vs,[t(c).repoRoot?(v(),x("div",zs,[L(t(ze),{class:"h-3.5 w-3.5 shrink-0"}),a("span",Es,u(t(c).repoRoot),1)])):G("",!0),a("div",Os,[L(t(Ee),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,u(t(c).branch||t(C)("diffReview.unknownBranch")),1),m[16]||(m[16]=a("span",{class:"opacity-50"},"•",-1)),a("span",Ws,u(t(C)("diffReview.fileCount",{count:((ee=t(c).summary)==null?void 0:ee.fileCount)||0})),1),(ve=t(c).summary)!=null&&ve.statsComplete?(v(),x(ae,{key:0},[m[12]||(m[12]=a("span",{class:"opacity-50"},"•",-1)),a("span",Us,"+"+u(((pe=t(c).summary)==null?void 0:pe.additions)||0),1),a("span",Gs,"-"+u(((ge=t(c).summary)==null?void 0:ge.deletions)||0),1)],64)):t(Y)?(v(),x(ae,{key:1},[m[13]||(m[13]=a("span",{class:"opacity-50"},"•",-1)),m[14]||(m[14]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-successSoft)]"},null,-1)),m[15]||(m[15]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-dangerSoft)]"},null,-1))],64)):(v(),x("span",qs,u(t(C)("diffReview.waitingStats")),1))])]),t(h)?(v(),x("p",Js,u(t(h)),1)):G("",!0),(xe=t(c).warnings)!=null&&xe.length?(v(),x("div",Ks,[(v(!0),x(ae,null,Se(t(c).warnings,p=>(v(),x("p",{key:p,class:"text-[11px] text-[var(--theme-warningText)]"},u(p),1))),128))])):G("",!0)]),t(Z)?(v(),x("div",Qs,[a("div",Xs,[a("div",Ys,[a("button",{type:"button",class:T(["tool-button px-3 py-2 text-sm",M.value==="files"?"tool-button-accent-subtle":""]),onClick:m[5]||(m[5]=p=>M.value="files")},u(t(C)("diffReview.filesTab")),3),a("button",{type:"button",class:T(["tool-button px-3 py-2 text-sm",M.value==="patch"?"tool-button-accent-subtle":""]),disabled:!t(V),onClick:m[6]||(m[6]=p=>M.value="patch")},u(t(C)("diffReview.diffTab")),11,Zs)])]),De(a("div",ea,[L(We,{"diff-payload":t(c),"file-search":t(r),"filtered-files":t(R),"get-filter-button-class":t(k),"get-filter-label":t(i),"get-status-class":t($),"get-status-label":t(N),"selected-file-path":t(q),"show-summary-skeleton":t(Y),"status-counts":t(de),"status-filter":t(W),"onUpdate:fileSearch":m[7]||(m[7]=p=>r.value=p),"onUpdate:statusFilter":m[8]||(m[8]=p=>W.value=p),onSelectFile:he},null,8,["diff-payload","file-search","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])],512),[[Ae,M.value==="files"]]),De(a("div",ta,[L(Ue,{"active-hunk-index":t(d),"get-patch-line-class":t(b),"get-status-class":t($),"get-status-label":t(N),"jump-to-adjacent-hunk":t(E),"patch-loading":t(P),"selected-file":t(V),"selected-patch-hunks":t(X),"selected-patch-lines":t(ne),"set-patch-line-ref":t(ue),"set-patch-viewport-ref":me},null,8,["active-hunk-index","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])],512),[[Ae,M.value==="patch"]])])):(v(),x("div",sa,[a("div",aa,[L(We,{"diff-payload":t(c),"file-search":t(r),"filtered-files":t(R),"get-filter-button-class":t(k),"get-filter-label":t(i),"get-status-class":t($),"get-status-label":t(N),"selected-file-path":t(q),"show-summary-skeleton":t(Y),"status-counts":t(de),"status-filter":t(W),"onUpdate:fileSearch":m[9]||(m[9]=p=>r.value=p),"onUpdate:statusFilter":m[10]||(m[10]=p=>W.value=p),onSelectFile:m[11]||(m[11]=p=>q.value=p)},null,8,["diff-payload","file-search","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])]),a("div",na,[L(Ue,{"active-hunk-index":t(d),"get-patch-line-class":t(b),"get-status-class":t($),"get-status-label":t(N),"jump-to-adjacent-hunk":t(E),"patch-loading":t(P),"selected-file":t(V),"selected-patch-hunks":t(X),"selected-patch-lines":t(ne),"set-patch-line-ref":t(ue),"set-patch-viewport-ref":me},null,8,["active-hunk-index","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])])]))])):G("",!0)])}}},la={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ma={__name:"TaskDiffReviewDialog",props:{open:{type:Boolean,default:!1},taskSlug:{type:String,default:""},taskTitle:{type:String,default:""},preferredScope:{type:String,default:"task"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0}},emits:["close"],setup(e,{emit:n}){const d=e,h=n,{t:c}=Re(),S=A(()=>{const y=String(d.taskTitle||"").trim();return y?c("diffReview.dialogTitleWithTask",{title:y}):c("diffReview.dialogTitle")});return(y,r)=>(v(),je(ot,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-full sm:h-[90vh] sm:w-[90vw] sm:max-w-[90vw]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex-1 overflow-hidden p-3 sm:p-4",onClose:r[0]||(r[0]=R=>h("close"))},{title:oe(()=>[a("div",la,[L(t(qe),{class:"h-4 w-4"}),a("span",null,u(S.value),1)])]),default:oe(()=>[L(ia,{"task-slug":e.taskSlug,active:e.open,"preferred-scope":e.preferredScope,"preferred-run-id":e.preferredRunId,"focus-token":e.focusToken},null,8,["task-slug","active","preferred-scope","preferred-run-id","focus-token"])]),_:1},8,["open"]))}};export{ma as default};
@@ -0,0 +1 @@
1
+ .task-diff-row[data-v-1a81fddc]{grid-template-columns:3.1rem 3.1rem minmax(0,1fr)}.task-diff-row__number[data-v-1a81fddc]{border-right:1px solid var(--theme-borderMuted);color:color-mix(in srgb,var(--theme-textPrimary) 52%,transparent);font-variant-numeric:tabular-nums;padding:.125rem .5rem;text-align:right}.task-diff-line[data-v-1a81fddc]{color:inherit}.task-diff-line[data-v-1a81fddc] .task-diff-line__prefix{display:inline-block;font-weight:600;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:1ch}.task-diff-line[data-v-1a81fddc] .task-diff-line__prefix--add{color:var(--theme-successText)}.task-diff-line[data-v-1a81fddc] .task-diff-line__prefix--delete{color:var(--theme-dangerText)}.task-diff-line[data-v-1a81fddc] .task-diff-line__prefix--context{color:color-mix(in srgb,var(--theme-textPrimary) 35%,transparent)}.task-diff-line[data-v-1a81fddc] .task-diff-line__body{display:inline}.task-diff-line--plain[data-v-1a81fddc]{color:inherit}