@muyichengshayu/promptx 0.2.17 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/apps/server/src/codexRoutes.js +12 -0
- package/apps/server/src/index.js +2 -0
- package/apps/server/src/workspaceFiles.js +170 -0
- package/apps/server/src/workspaceFiles.test.js +48 -0
- package/apps/web/dist/assets/{CodexSessionManagerDialog-D1PwOD4T.js → CodexSessionManagerDialog-D_72LIMv.js} +1 -1
- package/apps/web/dist/assets/{TaskDiffReviewDialog-GKKv-IkZ.js → TaskDiffReviewDialog-CoQgN73y.js} +1 -1
- package/apps/web/dist/assets/{WorkbenchSettingsDialog-IWlkg3kU.js → WorkbenchSettingsDialog-Bw-fcsXi.js} +1 -1
- package/apps/web/dist/assets/WorkbenchView-CebqJlAz.css +1 -0
- package/apps/web/dist/assets/WorkbenchView-CsZnW4Q7.js +58 -0
- package/apps/web/dist/assets/index-Bt9T2IKp.js +2 -0
- package/apps/web/dist/assets/{index-BAfqUG7o.css → index-DaJU954y.css} +1 -1
- package/apps/web/dist/index.html +2 -2
- package/package.json +1 -1
- package/apps/web/dist/assets/WorkbenchView-CK1snPBz.css +0 -1
- package/apps/web/dist/assets/WorkbenchView-dXHPTH_M.js +0 -58
- package/apps/web/dist/assets/index-DaIoquOV.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.18
|
|
4
|
+
|
|
5
|
+
- 源码浏览新增行作者提示:查看代码时默认启用 Git blame,鼠标悬停到源码行会在本行下方靠右显示最近修改作者、提交摘要、短 hash 与时间;非 Git 仓库、未跟踪文件、大文件和二进制文件会平稳降级为不可用提示。
|
|
6
|
+
|
|
3
7
|
## 0.2.17
|
|
4
8
|
|
|
5
9
|
- 修复 Windows 上 Codex 任务实际完成后工作台仍显示运行中、任务卡片持续转圈的问题:runner 在收到 `turn.completed` 后会进入短暂收尾等待;如果 Codex 子进程没有及时退出,会按完成状态落库并回收子进程,避免成功任务长时间卡在 `running`。
|
|
@@ -74,6 +74,7 @@ function registerCodexRoutes(app, options = {}) {
|
|
|
74
74
|
listTaskSlugsByCodexSessionId = () => [],
|
|
75
75
|
listWorkspaceSuggestions,
|
|
76
76
|
listWorkspaceTree,
|
|
77
|
+
readWorkspaceFileBlame,
|
|
77
78
|
readWorkspaceFileContent,
|
|
78
79
|
resetPromptxCodexSession = () => null,
|
|
79
80
|
runDispatchService,
|
|
@@ -173,6 +174,17 @@ function registerCodexRoutes(app, options = {}) {
|
|
|
173
174
|
})
|
|
174
175
|
})
|
|
175
176
|
|
|
177
|
+
app.get('/api/codex/sessions/:sessionId/files/blame', async (request, reply) => {
|
|
178
|
+
const session = getPromptxCodexSessionById(request.params.sessionId)
|
|
179
|
+
if (!session) {
|
|
180
|
+
return reply.code(404).send({ messageKey: 'errors.sessionNotFound', message: '没有找到对应的 PromptX 项目。' })
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return readWorkspaceFileBlame(session.cwd, {
|
|
184
|
+
path: request.query?.path,
|
|
185
|
+
})
|
|
186
|
+
})
|
|
187
|
+
|
|
176
188
|
app.get('/api/codex/sessions/:sessionId/files/content-search', async (request, reply) => {
|
|
177
189
|
const session = getPromptxCodexSessionById(request.params.sessionId)
|
|
178
190
|
if (!session) {
|
package/apps/server/src/index.js
CHANGED
|
@@ -55,6 +55,7 @@ import { listKnownSessionsByEngine, listKnownWorkspacesByEngine } from './agents
|
|
|
55
55
|
import {
|
|
56
56
|
listDirectoryPickerTree,
|
|
57
57
|
readWorkspaceFileContent,
|
|
58
|
+
readWorkspaceFileBlame,
|
|
58
59
|
listWorkspaceTree,
|
|
59
60
|
searchDirectoryPickerEntries,
|
|
60
61
|
searchWorkspaceFileContent,
|
|
@@ -434,6 +435,7 @@ registerCodexRoutes(app, {
|
|
|
434
435
|
listTaskSlugsByCodexSessionId,
|
|
435
436
|
listWorkspaceSuggestions: workspaceSuggestionService.listWorkspaceSuggestions,
|
|
436
437
|
listWorkspaceTree,
|
|
438
|
+
readWorkspaceFileBlame,
|
|
437
439
|
readWorkspaceFileContent,
|
|
438
440
|
resetPromptxCodexSession,
|
|
439
441
|
runDispatchService,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import os from 'node:os'
|
|
3
3
|
import path from 'node:path'
|
|
4
|
+
import { spawnSync } from 'node:child_process'
|
|
4
5
|
import { createApiError } from './apiErrors.js'
|
|
5
6
|
|
|
6
7
|
const WORKSPACE_HIDDEN_DIRECTORY_NAMES = new Set([
|
|
@@ -41,6 +42,8 @@ const DEFAULT_CONTENT_SEARCH_LIMIT = 80
|
|
|
41
42
|
const MAX_SEARCH_VISITS = 20000
|
|
42
43
|
const DIRECTORY_PICKER_LIMIT = 240
|
|
43
44
|
const DEFAULT_FILE_PREVIEW_LIMIT = 200 * 1024
|
|
45
|
+
const DEFAULT_FILE_BLAME_LINE_LIMIT = Math.max(200, Number(process.env.PROMPTX_FILE_BLAME_LINE_LIMIT) || 5000)
|
|
46
|
+
const DEFAULT_FILE_BLAME_TIMEOUT_MS = Math.max(500, Number(process.env.PROMPTX_FILE_BLAME_TIMEOUT_MS) || 6000)
|
|
44
47
|
const MAX_IMAGE_PREVIEW_BYTES = 2 * 1024 * 1024
|
|
45
48
|
const MAX_CONTENT_SEARCH_FILE_BYTES = 1024 * 1024
|
|
46
49
|
const MAX_CONTENT_MATCHES_PER_FILE = 20
|
|
@@ -155,6 +158,17 @@ function createHttpError(message, statusCode = 400) {
|
|
|
155
158
|
return createApiError('', message, statusCode)
|
|
156
159
|
}
|
|
157
160
|
|
|
161
|
+
function createWorkspaceUnavailablePayload(target, reason = '', message = '') {
|
|
162
|
+
return {
|
|
163
|
+
cwd: target.root,
|
|
164
|
+
path: target.relativePath,
|
|
165
|
+
supported: false,
|
|
166
|
+
reason: String(reason || 'unavailable').trim() || 'unavailable',
|
|
167
|
+
message: String(message || '').trim(),
|
|
168
|
+
items: [],
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
158
172
|
function toPosixPath(value = '') {
|
|
159
173
|
return String(value || '').replace(/\\/g, '/')
|
|
160
174
|
}
|
|
@@ -216,6 +230,25 @@ function resolveWorkspaceTarget(workspacePath, relativePath = '') {
|
|
|
216
230
|
}
|
|
217
231
|
}
|
|
218
232
|
|
|
233
|
+
function runGit(workspacePath = '', args = [], options = {}) {
|
|
234
|
+
const result = spawnSync('git', ['-C', workspacePath, ...args], {
|
|
235
|
+
encoding: 'utf8',
|
|
236
|
+
maxBuffer: 12 * 1024 * 1024,
|
|
237
|
+
timeout: DEFAULT_FILE_BLAME_TIMEOUT_MS,
|
|
238
|
+
windowsHide: true,
|
|
239
|
+
...options,
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
status: typeof result.status === 'number' ? result.status : 1,
|
|
244
|
+
stdout: String(result.stdout || ''),
|
|
245
|
+
stderr: String(result.stderr || ''),
|
|
246
|
+
signal: String(result.signal || ''),
|
|
247
|
+
errorCode: String(result.error?.code || ''),
|
|
248
|
+
timedOut: String(result.error?.code || '') === 'ETIMEDOUT',
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
219
252
|
function getPathType(absolutePath = '') {
|
|
220
253
|
try {
|
|
221
254
|
const stats = fs.statSync(absolutePath)
|
|
@@ -232,6 +265,78 @@ function getPathType(absolutePath = '') {
|
|
|
232
265
|
return ''
|
|
233
266
|
}
|
|
234
267
|
|
|
268
|
+
function getFileLineCount(absolutePath = '') {
|
|
269
|
+
const content = fs.readFileSync(absolutePath, 'utf8').replace(/\r\n/g, '\n')
|
|
270
|
+
return content ? content.split('\n').length : 0
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function parseGitBlamePorcelain(output = '') {
|
|
274
|
+
const items = []
|
|
275
|
+
const commitMeta = new Map()
|
|
276
|
+
let current = null
|
|
277
|
+
|
|
278
|
+
String(output || '').replace(/\r\n/g, '\n').split('\n').forEach((line) => {
|
|
279
|
+
const headerMatch = line.match(/^([0-9a-f]{40})\s+\d+\s+(\d+)(?:\s+\d+)?$/i)
|
|
280
|
+
if (headerMatch) {
|
|
281
|
+
const commit = headerMatch[1]
|
|
282
|
+
const lineNumber = Number(headerMatch[2]) || 0
|
|
283
|
+
const cached = commitMeta.get(commit) || {}
|
|
284
|
+
current = {
|
|
285
|
+
line: lineNumber,
|
|
286
|
+
commit,
|
|
287
|
+
author: cached.author || '',
|
|
288
|
+
authorMail: cached.authorMail || '',
|
|
289
|
+
authorTime: cached.authorTime || '',
|
|
290
|
+
summary: cached.summary || '',
|
|
291
|
+
}
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (!current) {
|
|
296
|
+
return
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (line.startsWith('author ')) {
|
|
300
|
+
current.author = line.slice('author '.length)
|
|
301
|
+
return
|
|
302
|
+
}
|
|
303
|
+
if (line.startsWith('author-mail ')) {
|
|
304
|
+
current.authorMail = line.slice('author-mail '.length).replace(/^<|>$/g, '')
|
|
305
|
+
return
|
|
306
|
+
}
|
|
307
|
+
if (line.startsWith('author-time ')) {
|
|
308
|
+
const timestamp = Number(line.slice('author-time '.length)) || 0
|
|
309
|
+
current.authorTime = timestamp > 0 ? new Date(timestamp * 1000).toISOString() : ''
|
|
310
|
+
return
|
|
311
|
+
}
|
|
312
|
+
if (line.startsWith('summary ')) {
|
|
313
|
+
current.summary = line.slice('summary '.length)
|
|
314
|
+
return
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (line.startsWith('\t')) {
|
|
318
|
+
if (current.line > 0) {
|
|
319
|
+
const meta = {
|
|
320
|
+
author: current.author,
|
|
321
|
+
authorMail: current.authorMail,
|
|
322
|
+
authorTime: current.authorTime,
|
|
323
|
+
summary: current.summary,
|
|
324
|
+
}
|
|
325
|
+
commitMeta.set(current.commit, meta)
|
|
326
|
+
items.push({
|
|
327
|
+
line: current.line,
|
|
328
|
+
commit: current.commit,
|
|
329
|
+
shortCommit: current.commit.slice(0, 8),
|
|
330
|
+
...meta,
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
current = null
|
|
334
|
+
}
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
return items.sort((left, right) => left.line - right.line)
|
|
338
|
+
}
|
|
339
|
+
|
|
235
340
|
function shouldIgnoreDirectory(entry) {
|
|
236
341
|
return entry?.isDirectory?.() && WORKSPACE_HIDDEN_DIRECTORY_NAMES.has(entry.name)
|
|
237
342
|
}
|
|
@@ -1025,6 +1130,71 @@ export function readWorkspaceFileContent(workspacePath, options = {}) {
|
|
|
1025
1130
|
}
|
|
1026
1131
|
}
|
|
1027
1132
|
|
|
1133
|
+
export function readWorkspaceFileBlame(workspacePath, options = {}) {
|
|
1134
|
+
const target = resolveWorkspaceTarget(workspacePath, options.path)
|
|
1135
|
+
|
|
1136
|
+
let stats
|
|
1137
|
+
try {
|
|
1138
|
+
stats = fs.statSync(target.absolutePath)
|
|
1139
|
+
} catch {
|
|
1140
|
+
throw createApiError('errors.fileNotFound', '文件不存在。', 404)
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
if (!stats.isFile()) {
|
|
1144
|
+
throw createApiError('errors.fileOnly', '只能读取文件内容。')
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
if (stats.size > DEFAULT_FILE_PREVIEW_LIMIT) {
|
|
1148
|
+
return createWorkspaceUnavailablePayload(target, 'too_large', '文件较大,暂不加载行作者信息。')
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
const previewBuffer = readFileSlice(target.absolutePath, Math.min(stats.size, DEFAULT_FILE_PREVIEW_LIMIT))
|
|
1152
|
+
const extension = path.extname(path.basename(target.absolutePath)).toLowerCase()
|
|
1153
|
+
const isKnownTextFile = TEXT_FILE_EXTENSIONS.has(extension)
|
|
1154
|
+
if (!isKnownTextFile && isLikelyBinaryBuffer(previewBuffer)) {
|
|
1155
|
+
return createWorkspaceUnavailablePayload(target, 'binary', '当前文件为二进制内容,暂不加载行作者信息。')
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
const fileLineCount = getFileLineCount(target.absolutePath)
|
|
1159
|
+
if (fileLineCount > DEFAULT_FILE_BLAME_LINE_LIMIT) {
|
|
1160
|
+
return createWorkspaceUnavailablePayload(target, 'too_many_lines', '文件行数较多,暂不加载行作者信息。')
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
const gitCheck = runGit(target.root, ['rev-parse', '--is-inside-work-tree'])
|
|
1164
|
+
if (gitCheck.status !== 0 || String(gitCheck.stdout || '').trim() !== 'true') {
|
|
1165
|
+
return createWorkspaceUnavailablePayload(target, 'not_git', '当前目录不是 Git 仓库。')
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
const blame = runGit(target.root, [
|
|
1169
|
+
'blame',
|
|
1170
|
+
'--line-porcelain',
|
|
1171
|
+
'--',
|
|
1172
|
+
target.relativePath,
|
|
1173
|
+
])
|
|
1174
|
+
|
|
1175
|
+
if (blame.timedOut) {
|
|
1176
|
+
return createWorkspaceUnavailablePayload(target, 'timeout', '行作者信息加载超时。')
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
if (blame.status !== 0) {
|
|
1180
|
+
const stderr = String(blame.stderr || '').trim()
|
|
1181
|
+
if (/no such path|no such file|not in HEAD|fatal: no such/i.test(stderr)) {
|
|
1182
|
+
return createWorkspaceUnavailablePayload(target, 'untracked', '当前文件尚未被 Git 跟踪。')
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
return createWorkspaceUnavailablePayload(target, 'failed', stderr || '行作者信息加载失败。')
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
return {
|
|
1189
|
+
cwd: target.root,
|
|
1190
|
+
path: target.relativePath,
|
|
1191
|
+
supported: true,
|
|
1192
|
+
reason: '',
|
|
1193
|
+
message: '',
|
|
1194
|
+
items: parseGitBlamePorcelain(blame.stdout),
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1028
1198
|
export function listDirectoryPickerTree(options = {}) {
|
|
1029
1199
|
const isRootRequest = !String(options.path || '').trim()
|
|
1030
1200
|
const targetPath = normalizeDirectoryPickerPath(options.path) || getDirectoryPickerHomePath()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import assert from 'node:assert/strict'
|
|
2
|
+
import { execFileSync } from 'node:child_process'
|
|
2
3
|
import fs from 'node:fs'
|
|
3
4
|
import os from 'node:os'
|
|
4
5
|
import path from 'node:path'
|
|
@@ -7,12 +8,20 @@ import test from 'node:test'
|
|
|
7
8
|
import {
|
|
8
9
|
listDirectoryPickerTree,
|
|
9
10
|
listWorkspaceTree,
|
|
11
|
+
readWorkspaceFileBlame,
|
|
10
12
|
readWorkspaceFileContent,
|
|
11
13
|
searchWorkspaceFileContent,
|
|
12
14
|
searchWorkspaceEntries,
|
|
13
15
|
searchDirectoryPickerEntries,
|
|
14
16
|
} from './workspaceFiles.js'
|
|
15
17
|
|
|
18
|
+
function git(cwd, args = []) {
|
|
19
|
+
return execFileSync('git', ['-C', cwd, ...args], {
|
|
20
|
+
encoding: 'utf8',
|
|
21
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
22
|
+
}).trim()
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
test('listDirectoryPickerTree returns filesystem roots when path is empty', () => {
|
|
17
26
|
const payload = listDirectoryPickerTree()
|
|
18
27
|
|
|
@@ -277,3 +286,42 @@ test('readWorkspaceFileContent marks binary files', () => {
|
|
|
277
286
|
assert.equal(payload.binary, true)
|
|
278
287
|
assert.equal(payload.content, '')
|
|
279
288
|
})
|
|
289
|
+
|
|
290
|
+
test('readWorkspaceFileBlame returns author metadata per source line', () => {
|
|
291
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'promptx-workspace-blame-'))
|
|
292
|
+
const sourcePath = path.join(tempDir, 'src', 'main.js')
|
|
293
|
+
|
|
294
|
+
fs.mkdirSync(path.dirname(sourcePath), { recursive: true })
|
|
295
|
+
fs.writeFileSync(sourcePath, 'const answer = 42\nconsole.log(answer)\n', 'utf8')
|
|
296
|
+
git(tempDir, ['init'])
|
|
297
|
+
git(tempDir, ['config', 'user.email', 'promptx@example.com'])
|
|
298
|
+
git(tempDir, ['config', 'user.name', 'PromptX'])
|
|
299
|
+
git(tempDir, ['add', 'src/main.js'])
|
|
300
|
+
git(tempDir, ['commit', '-m', 'initial source'])
|
|
301
|
+
|
|
302
|
+
const payload = readWorkspaceFileBlame(tempDir, {
|
|
303
|
+
path: 'src/main.js',
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
assert.equal(payload.supported, true)
|
|
307
|
+
assert.equal(payload.path, 'src/main.js')
|
|
308
|
+
assert.equal(payload.items.length, 2)
|
|
309
|
+
assert.equal(payload.items[0].line, 1)
|
|
310
|
+
assert.equal(payload.items[0].author, 'PromptX')
|
|
311
|
+
assert.equal(payload.items[0].authorMail, 'promptx@example.com')
|
|
312
|
+
assert.equal(payload.items[0].summary, 'initial source')
|
|
313
|
+
assert.equal(payload.items[0].shortCommit.length, 8)
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
test('readWorkspaceFileBlame returns unavailable payload outside git repository', () => {
|
|
317
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'promptx-workspace-blame-nongit-'))
|
|
318
|
+
fs.writeFileSync(path.join(tempDir, 'note.txt'), 'hello\n', 'utf8')
|
|
319
|
+
|
|
320
|
+
const payload = readWorkspaceFileBlame(tempDir, {
|
|
321
|
+
path: 'note.txt',
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
assert.equal(payload.supported, false)
|
|
325
|
+
assert.equal(payload.reason, 'not_git')
|
|
326
|
+
assert.deepEqual(payload.items, [])
|
|
327
|
+
})
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{W as ut,j as yt,o as Mt,s as jt,p as It,q as ct,h as Et,t as st,f as Pt,v as ft,w as pt,x as At,y as We,z as Rt,A as nt}from"./WorkbenchView-dXHPTH_M.js";import{u as Qe,f as Dt,e as Tt}from"./index-DaIoquOV.js";import{w as ie,n as he,ak as lt,aD as p,aI as ue,aJ as Le,aF as n,aQ as u,u as i,aG as I,aW as Lt,aU as Bt,aX as Ft,aE as m,aR as ye,aS as Se,aL as N,aN as M,aV as Nt,aK as at,b as $,c as k,o as Ot,aZ as xt,r as Ut}from"./vendor-misc-u-M8sNMf.js";import{c as Ht,L as Ze,F as et,e as zt,b as it,X as gt,C as Kt,O as qt,j as Vt,x as Wt,P as Qt,i as mt,E as Gt,Q as Xt,q as Yt,r as Jt,Y as Zt}from"./vendor-ui-BglsaDbv.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";import"./vendor-router-Dn8q3tJM.js";const en={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},tn={class:"theme-muted-text mt-1 text-xs leading-5"},nn={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},sn={class:"flex items-start gap-2 text-xs leading-5"},an={class:"theme-muted-text shrink-0"},ln={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},on={class:"theme-muted-text mt-4 block text-xs"},rn={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},dn=["placeholder"],un={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},cn={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},fn={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},pn={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},gn={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},mn={key:4,class:"theme-empty-state px-3 py-8 text-sm"},vn={key:5,class:"theme-empty-state px-3 py-8 text-sm"},hn={key:6,class:"theme-empty-state px-3 py-8 text-sm"},yn={key:7,class:"space-y-1"},xn=["onClick"],bn={class:"min-w-0 flex-1"},wn=["innerHTML"],Sn=["innerHTML"],kn={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},Cn={key:8,class:"space-y-1"},_n={class:"flex items-start gap-1.5"},$n=["onClick"],Mn=["onClick"],jn={class:"min-w-0 flex-1"},In={key:0,class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all"},En={class:"theme-divider flex flex-col-reverse gap-2 border-t border-dashed px-4 py-4 sm:flex-row sm:items-center sm:justify-end sm:px-5"},Pn={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},An=["disabled"],Rn=["disabled"],Dn={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(d,{emit:W}){const j=d,R=W,{t:v}=Qe(),G=$(""),H=$([]),g=$(!1),w=$(""),E=$(!1),r=$(""),b=$([]),P=$(!1),f=$(""),_=$(""),ce=$(null);let Q=null,O=0,B=null;const z=new Map,K=k(()=>Fe(H.value)),X=k(()=>String(f.value||"").trim()),Y=k(()=>X.value.length>=ut),D=k(()=>!!X.value),le=k(()=>Ce(_.value)||G.value),q=k(()=>D.value?b.value:K.value),me=k(()=>q.value.map(e=>{const l=c((e==null?void 0:e.path)||""),s=e!=null&&e.expanded?1:0,o=e!=null&&e.loading?1:0;return`${l}:${s}:${o}`}).join("|")),se=k(()=>D.value&&!Y.value&&!E.value&&!r.value),J=k(()=>D.value&&Y.value&&!E.value&&!r.value&&!b.value.length),h=k(()=>!D.value&&!g.value&&!w.value&&!K.value.length);function x(e=""){const l=String(e||"").trim();return/^[a-z]:[\\/]/i.test(l)||l.includes("\\")}function c(e=""){const l=String(e||"").trim();if(!l)return"";const s=x(l);let o=l.replace(/\\/g,"/");return o.length>1&&!/^[a-z]:\/?$/i.test(o)&&o!=="/"&&(o=o.replace(/\/+$/,"")),s?o.toLowerCase():o}function U(e="",l=""){const s=c(e),o=c(l);if(!s||!o||o==="/"&&s!=="/")return!1;const A=o.endsWith("/")?o:`${o}/`;return s===o||s.startsWith(A)}function ee(e="",l=""){const s=String(e||"").trim(),o=String(l||"").trim();return s?o?x(s)?/^[a-z]:\\?$/i.test(s)?`${s.replace(/[\\/]+$/,"")}\\${o}`:`${s.replace(/[\\/]+$/,"")}\\${o}`:s==="/"?`/${o}`:`${s.replace(/\/+$/,"")}/${o}`:s:o}function S(e="",l=""){const s=c(e),o=c(l);if(!s||!o||!U(o,s))return[];const A=o===s?"":o.slice(s.length).replace(/^\//,"");return A?A.split("/").filter(Boolean):[]}function ke(e=""){const l=String(e||"").trim(),s=Ce(l);if(!l||!s||c(l)===c(s))return"";const o=x(l),A=l.replace(/\\/g,"/");if(o){const de=A.replace(/\/+$/,""),qe=de.lastIndexOf("/");if(qe<=2)return"";const Te=de.slice(0,qe).replace(/\//g,"\\");return U(Te,s)?Te:""}const V=A.replace(/\/+$/,""),ne=V.lastIndexOf("/");if(ne<=0)return"";const ae=V.slice(0,ne)||"/";return U(ae,s)?ae:""}function Ce(e=""){const l=String(e||"").trim();return l&&H.value.map(o=>String((o==null?void 0:o.path)||"").trim()).filter(o=>o&&U(l,o)).sort((o,A)=>c(A).length-c(o).length)[0]||""}function xe(e){return(e==null?void 0:e.name)||(e==null?void 0:e.path)||v("directoryPicker.unnamedDirectory")}function _e(e=""){const l=String(e||"").trim();return l?l.split(/[\\/]/).filter(Boolean).at(-1)||l:"Home"}function ve(e=""){return String(e||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function fe(e="",l=""){const s=String(e||""),o=String(l||"").trim().toLowerCase();if(!s||!o)return null;const A=s.toLowerCase(),V=A.indexOf(o);if(V>=0)return{start:V,end:V+o.length};const ne=o.split(/[\\/\s_.-]+/).filter(Boolean).sort((ae,de)=>de.length-ae.length);for(const ae of ne){if(ae.length<2)continue;const de=A.indexOf(ae);if(de>=0)return{start:de,end:de+ae.length}}return null}function T(e="",l=""){const s=String(e||""),o=fe(s,l);return o?`${ve(s.slice(0,o.start))}<mark class="theme-search-highlight">${ve(s.slice(o.start,o.end))}</mark>${ve(s.slice(o.end))}`:ve(s)}function tt(e){return T(xe(e),f.value)}function Be(e){return T((e==null?void 0:e.path)||"",f.value)}function $e(e,l=0){return{...e,depth:l,expanded:!1,loaded:!1,loading:!1,children:[]}}function Fe(e=[],l=[]){return e.forEach(s=>{l.push(s),s.expanded&&s.children.length&&Fe(s.children,l)}),l}function oe(){H.value=[...H.value]}function be(){Q&&(window.clearTimeout(Q),Q=null),B&&(B.abort(),B=null)}function we(e,l=H.value){const s=c(e);if(!s)return null;for(const o of l){if(c(o.path)===s)return o;if(o.children.length){const A=we(e,o.children);if(A)return A}}return null}function Z(e){_.value=String((e==null?void 0:e.path)||"").trim()}function pe(e=""){return c(e)}function Ne(e,l){const s=pe(e);if(s){if(l){z.set(s,l);return}z.delete(s)}}function Me(){var l;const e=z.get(pe(_.value));(l=e==null?void 0:e.scrollIntoView)==null||l.call(e,{block:"nearest"})}function Ge(){he(()=>{var e,l;(l=(e=ce.value)==null?void 0:e.focus)==null||l.call(e)})}function re(){const e=q.value;if(!e.length){_.value="";return}const l=pe(_.value);l&&e.some(s=>pe((s==null?void 0:s.path)||"")===l)||Z(e[0])}function ge(){const e=q.value;if(!e.length)return-1;const l=pe(_.value),s=e.findIndex(o=>pe((o==null?void 0:o.path)||"")===l);return s>=0?s:0}function je(){const e=q.value,l=ge();return l<0||!e.length?null:e[l]||null}function Ie(e=1){const l=q.value;if(!l.length)return!1;const s=ge(),o=s<0?0:(s+e+l.length)%l.length;return Z(l[o]),he(Me),!0}async function Oe(){if(D.value)return!1;const e=je();if(!e||!e.hasChildren)return!1;if(!e.expanded)return await De(e),!0;const l=q.value,s=ge(),o=l[s+1];return o&&ke(o.path)===e.path?(Z(o),he(Me),!0):!1}function Ue(){if(D.value)return!1;const e=je();if(!e)return!1;if(e.expanded&&e.hasChildren)return e.expanded=!1,oe(),Z(e),!0;const l=ke(e.path);if(!l)return!1;const s=we(l);return s?(Z(s),he(Me),!0):!1}function Ee(e){var l,s,o;if((l=e==null?void 0:e.preventDefault)==null||l.call(e),X.value){(s=e==null?void 0:e.stopPropagation)==null||s.call(e),f.value="";return}(o=e==null?void 0:e.stopPropagation)==null||o.call(e),R("close")}function Pe(e){const l=String((e==null?void 0:e.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(l)&&!(D.value&&(l==="ArrowLeft"||l==="ArrowRight"))){if(l==="ArrowDown"){e.preventDefault(),Ie(1);return}if(l==="ArrowUp"){e.preventDefault(),Ie(-1);return}if(l==="Escape"){Ee(e);return}if(D.value){if(l==="Enter"){e.preventDefault();const s=je();s&&Je(s)}return}if(l==="ArrowRight"){e.preventDefault(),Oe();return}if(l==="ArrowLeft"){e.preventDefault(),Ue();return}l==="Enter"&&(e.preventDefault(),Ke())}}async function He(e,l={}){if(!(!e||e.loading)&&!(e.loaded&&!l.force)){e.loading=!0,w.value="",oe();try{const s=await ct({path:e.path,limit:240});e.children=(s.items||[]).map(o=>$e(o,e.depth+1)),e.loaded=!0}catch(s){w.value=s.message||v("directoryPicker.loadFailed")}finally{e.loading=!1,oe()}}}async function Ae(){g.value=!0,w.value="";try{const e=await ct({limit:240});G.value=String(e.path||"");const l=Array.isArray(e.roots)&&e.roots.length?e.roots:[{name:_e(e.path||""),path:String(e.path||""),type:"directory",hasChildren:!0,isRoot:!0}],s=c(e.path||""),o=l.map(A=>{const V=$e({...A,isHomeRoot:c(A.path||"")===s},0);return V.isHomeRoot&&(V.children=(e.items||[]).map(ne=>$e(ne,1)),V.loaded=!0,V.expanded=!0),V});H.value=o,Z(o.find(A=>A.isHomeRoot)||o[0])}catch(e){w.value=e.message||v("directoryPicker.treeLoadFailed"),H.value=[],G.value=""}finally{g.value=!1}}async function te(e=""){const l=String(e||"").trim(),s=Ce(l);if(!l||!s)return;let o=we(s);if(!o)return;Z(o);const A=S(s,l);for(const V of A){await He(o),o.expanded=!0,oe();const ne=we(ee(o.path,V),o.children);if(!ne)break;o=ne,Z(o)}}async function Re(){f.value="",b.value=[],r.value="",P.value=!1,_.value="",await Ae();const e=String(j.initialPath||"").trim();e&&Ce(e)&&await te(e)}async function De(e){if(e!=null&&e.path&&(Z(e),!!e.hasChildren)){if(!e.loaded){e.expanded=!0,oe(),await He(e);return}e.expanded=!e.expanded,oe()}}function ze(e){e!=null&&e.path&&Z(e)}async function Xe(){const e=String(f.value||"").trim();O+=1;const l=O;if(be(),!j.open||!e||!le.value||!Y.value){E.value=!1,r.value="",b.value=[],P.value=!1;return}E.value=!0,r.value="",B=new AbortController;try{const s=await jt(e,{path:le.value,limit:80,signal:B.signal});if(l!==O)return;b.value=Array.isArray(s.items)?s.items:[],P.value=!!s.truncated}catch(s){if(It(s)||l!==O)return;r.value=s.message||v("directoryPicker.searchFailed"),b.value=[],P.value=!1}finally{l===O&&(B=null),l===O&&(E.value=!1)}}function Ye(){if(be(),!String(f.value||"").trim()||!Y.value){E.value=!1,r.value="",b.value=[],P.value=!1;return}E.value=!0,r.value="",Q=window.setTimeout(()=>{Q=null,Xe()},Mt)}async function Je(e){e!=null&&e.path&&(await te(e.path),f.value="")}function Ke(){_.value&&(R("select",_.value),R("close"))}return ie(f,()=>{Ye()}),ie(me,()=>{re(),he(Me)},{immediate:!0}),ie(()=>j.open,e=>{if(e){Re().catch(()=>{}),Ge();return}be()}),lt(()=>{be()}),(e,l)=>(p(),ue(yt,{open:d.open,"stack-level":1,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-4xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:px-5","close-disabled":g.value||E.value,"close-on-backdrop":!(g.value||E.value),"close-on-escape":!(g.value||E.value),onClose:l[2]||(l[2]=s=>R("close"))},{title:Le(()=>[n("div",null,[n("div",en,[I(i(et),{class:"h-4 w-4"}),n("span",null,u(i(v)("directoryPicker.title")),1)]),n("p",tn,u(i(v)("directoryPicker.intro")),1)])]),default:Le(()=>[n("div",{class:"flex min-h-0 flex-1 flex-col overflow-hidden",onKeydown:Pe},[n("div",nn,[n("div",sn,[n("span",an,u(i(v)("directoryPicker.currentSelection")),1),n("span",ln,u(_.value||i(v)("directoryPicker.selectionPlaceholder")),1)])]),n("label",on,[n("span",null,u(i(v)("directoryPicker.searchLabel")),1),n("div",rn,[I(i(Ht),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),Lt(n("input",{ref_key:"searchInputRef",ref:ce,"onUpdate:modelValue":l[0]||(l[0]=s=>f.value=s),type:"text",placeholder:i(v)("directoryPicker.searchPlaceholder"),class:"min-w-0 flex-1 border-0 bg-transparent px-0 text-sm text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]",onKeydown:Bt(Ee,["esc"])},null,40,dn),[[Ft,f.value]])])]),n("div",un,[D.value&&r.value?(p(),m("div",cn,u(r.value),1)):!D.value&&w.value?(p(),m("div",fn,u(w.value),1)):D.value&&E.value?(p(),m("div",pn,[I(i(Ze),{class:"h-4 w-4 animate-spin"}),n("span",null,u(i(v)("directoryPicker.searching")),1)])):!D.value&&g.value?(p(),m("div",gn,[I(i(Ze),{class:"h-4 w-4 animate-spin"}),n("span",null,u(i(v)("directoryPicker.treeLoading")),1)])):se.value?(p(),m("div",mn,u(i(v)("directoryPicker.searchMinKeywordHint",{count:i(ut)})),1)):J.value?(p(),m("div",vn,u(i(v)("directoryPicker.noSearchResults")),1)):h.value?(p(),m("div",hn,u(i(v)("directoryPicker.emptyTree")),1)):D.value?(p(),m("div",yn,[(p(!0),m(ye,null,Se(b.value,s=>(p(),m("button",{key:s.path,ref_for:!0,ref:o=>Ne(s.path,o),type:"button",class:N(["theme-list-row focus:outline-none",c(_.value)===c(s.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:o=>Je(s)},[I(i(et),{class:"theme-list-item-icon"}),n("div",bn,[n("div",null,[n("span",{class:"theme-list-item-title block break-all",innerHTML:tt(s)},null,8,wn)]),n("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:Be(s)},null,8,Sn)])],10,xn))),128)),P.value?(p(),m("p",kn,u(i(v)("directoryPicker.truncatedHint")),1)):M("",!0)])):(p(),m("div",Cn,[(p(!0),m(ye,null,Se(K.value,s=>(p(),m("div",{key:s.path,ref_for:!0,ref:o=>Ne(s.path,o),class:N(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",c(_.value)===c(s.path)?"theme-list-item-active":s.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Nt({paddingLeft:`${s.depth*16+6}px`})},[n("div",_n,[n("button",{type:"button",class:N(["theme-icon-button h-5 w-5 shrink-0",s.hasChildren?"":"invisible pointer-events-none"]),onClick:at(o=>De(s),["stop"])},[s.loading?(p(),ue(i(Ze),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(p(),ue(i(zt),{key:1,class:N(["h-3.5 w-3.5 transition",s.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,$n),n("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:o=>ze(s)},[I(i(et),{class:N(["h-4 w-4 shrink-0",c(_.value)===c(s.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),n("div",jn,[n("div",{class:N(["theme-list-item-title truncate",s.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},u(xe(s)),3),s.isHomeRoot?(p(),m("div",In,u(s.path),1)):M("",!0)])],8,Mn)])],6))),128))]))])],32),n("div",En,[n("div",Pn,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:g.value||E.value,onClick:l[1]||(l[1]=s=>R("close"))},u(i(v)("directoryPicker.cancel")),9,An),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex w-full items-center justify-center gap-2 px-3 py-2 text-xs sm:w-auto",disabled:g.value||E.value||!_.value,onClick:Ke},[I(i(it),{class:"h-4 w-4"}),n("span",null,u(i(v)("directoryPicker.useCurrentDirectory")),1)],8,Rn)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Tn={class:"grid gap-4"},Ln={class:"theme-muted-text block text-xs"},Bn=["value","disabled"],Fn={class:"theme-muted-text block text-xs"},Nn={class:"mt-1 flex gap-2"},On={class:"relative min-w-0 flex-1"},Un=["value","disabled"],Hn=["disabled"],zn=["disabled"],Kn={id:"codex-manager-workspace-suggestions"},qn=["value"],Vn={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Wn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},Qn={class:"theme-muted-text block text-xs"},Gn={class:"mt-1"},Xn={class:"flex items-center gap-2 text-sm"},Yn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Jn=["disabled","onClick"],Zn={class:"flex items-center justify-between gap-3"},es={class:"min-w-0 flex-1 truncate"},ts={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},ns={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},ss={class:"theme-muted-text block text-xs"},as={class:"mt-2 grid gap-2"},is=["disabled","onClick"],ls={class:"min-w-0"},os={class:"text-sm text-[var(--theme-textPrimary)]"},rs={class:"theme-muted-text mt-0.5 text-[11px] leading-5"},ds={class:"theme-muted-text mt-2 text-[11px] leading-5"},us={class:"theme-muted-text block text-xs"},cs={class:"mt-1 flex gap-2"},fs=["value","disabled"],ps=["disabled"],gs={key:1,class:"theme-popover theme-divider absolute left-0 right-0 top-[calc(100%+0.375rem)] z-20 overflow-hidden rounded-sm border border-solid shadow-sm"},ms={class:"flex items-center justify-between gap-2 border-b border-solid px-3 py-2 text-[11px] leading-5"},vs={class:"font-medium text-[var(--theme-textPrimary)]"},hs={key:0,class:"theme-muted-text"},ys={key:0,class:"max-h-72 overflow-y-auto p-2"},xs=["disabled","onClick"],bs={class:"flex min-w-0 items-center justify-between gap-3"},ws={class:"min-w-0 flex-1 truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Ss={class:"shrink-0 text-[11px] leading-4 text-[var(--theme-textMuted)]"},ks={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Cs=["disabled"],_s={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},$s={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},vt={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},agentEngines:{type:Array,default:()=>[]},canEditEngine:{type:Boolean,default:!0},canEditCwd:{type:Boolean,default:!0},canEditSessionId:{type:Boolean,default:!0},cwd:{type:String,default:""},cwdReadonlyMessage:{type:String,default:""},duplicateCwdMessage:{type:String,default:""},engine:{type:String,default:"codex"},engineOptions:{type:Array,default:()=>[]},engineReadonlyMessage:{type:String,default:""},mobile:{type:Boolean,default:!1},sessionId:{type:String,default:""},sessionIdCopied:{type:Boolean,default:!1},sessionIdReadonlyMessage:{type:String,default:""},sessionCandidates:{type:Array,default:()=>[]},sessionCandidatesLoading:{type:Boolean,default:!1},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","select-session-candidate","update:agentEngines","update:cwd","update:engine","update:sessionId","update:title"],setup(d,{emit:W}){const j=d,R=W,{t:v}=Qe(),G=$(null),H=$(null),g=$(!1),w=$(-1),E=k(()=>{const h=String(j.engine||"").trim();return j.engineOptions.find(x=>String((x==null?void 0:x.value)||"").trim()===h)||null}),r=k(()=>{const h=Array.isArray(j.agentEngines)?j.agentEngines:[];return[...new Set(h.map(x=>String(x||"").trim()).filter(Boolean))]}),b=k(()=>j.engineOptions.filter(h=>String((h==null?void 0:h.value)||"").trim()!==String(j.engine||"").trim())),P=k(()=>!!String(j.cwd||"").trim()),f=k(()=>String(j.sessionId||"").trim()),_=k(()=>f.value.toLowerCase()),ce=k(()=>j.sessionCandidates.filter(h=>h==null?void 0:h.matchedCwd)),Q=k(()=>{const h=_.value,x=ce.value;return h?x.filter(c=>[c==null?void 0:c.label,c==null?void 0:c.id,c==null?void 0:c.cwd].map(ee=>String(ee||"").toLowerCase()).some(ee=>ee.includes(h))).slice(0,10):x.slice(0,10)});function O(){j.busy||!j.canEditSessionId||!P.value||(g.value=!0)}function B(){g.value=!1,w.value=-1}function z(){const h=Q.value;if(!h.length){w.value=-1;return}const x=h.findIndex(c=>c.id===f.value);w.value=x>=0?x:0}function K(){he(()=>{var h,x;(x=(h=H.value)==null?void 0:h.focus)==null||x.call(h)})}function X(){if(g.value){B();return}O(),K()}function Y(){R("update:cwd","")}function D(h){if(!j.canEditEngine||j.busy)return;const x=String(h||"").trim(),c=r.value.includes(x)?r.value.filter(U=>U!==x):[...r.value,x];R("update:agentEngines",c)}function le(){R("update:sessionId",""),B(),K()}function q(h){var x;R("update:sessionId",((x=h==null?void 0:h.target)==null?void 0:x.value)||""),P.value&&O()}function me(h){R("select-session-candidate",h),B(),K()}function se(h){if(j.busy||!j.canEditSessionId||!P.value)return;const x=Q.value;if(h.key==="ArrowDown"){if(h.preventDefault(),!g.value){O(),z();return}if(!x.length)return;w.value=w.value<0?0:Math.min(x.length-1,w.value+1);return}if(h.key==="ArrowUp"){if(h.preventDefault(),!g.value){O(),z();return}if(!x.length)return;w.value=w.value<0?x.length-1:Math.max(0,w.value-1);return}if(h.key==="Enter"&&g.value&&x.length&&w.value>=0){h.preventDefault(),me(x[w.value]);return}h.key==="Escape"&&g.value&&(h.preventDefault(),B())}function J(h){!g.value||!G.value||G.value.contains(h.target)||B()}return ie(Q,()=>{z()}),ie(()=>j.canEditSessionId,h=>{(!h||!P.value)&&B()}),ie(P,h=>{h||B()}),Ot(()=>{document.addEventListener("pointerdown",J)}),lt(()=>{document.removeEventListener("pointerdown",J)}),(h,x)=>(p(),m("div",Tn,[n("label",Ln,[n("span",null,u(i(v)("projectManager.projectTitleOptional")),1),n("input",{value:d.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:d.busy,onInput:x[0]||(x[0]=c=>R("update:title",c.target.value))},null,40,Bn)]),n("label",Fn,[n("span",null,u(i(v)("projectManager.workingDirectoryField")),1),n("div",Nn,[n("div",On,[n("input",{value:d.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:N(["tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",d.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:d.busy||!d.canEditCwd,onInput:x[1]||(x[1]=c=>R("update:cwd",c.target.value))},null,42,Un),d.cwd&&d.canEditCwd?(p(),m("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:d.busy,onClick:Y},[I(i(gt),{class:"h-3.5 w-3.5"})],8,Hn)):M("",!0)]),n("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:d.busy||!d.canEditCwd,onClick:x[2]||(x[2]=c=>R("open-directory-picker"))},[I(i(et),{class:"h-4 w-4"}),n("span",null,u(d.mobile?i(v)("projectManager.choose"):i(v)("projectManager.chooseDirectory")),1)],8,zn)]),n("datalist",Kn,[(p(!0),m(ye,null,Se(d.workspaceSuggestions,c=>(p(),m("option",{key:c,value:c},null,8,qn))),128))]),d.duplicateCwdMessage?(p(),m("p",Vn,u(d.duplicateCwdMessage),1)):d.cwdReadonlyMessage?(p(),m("p",Wn,u(d.cwdReadonlyMessage),1)):M("",!0)]),n("label",Qn,[n("span",null,u(i(v)("projectManager.engineField")),1),n("div",Gn,[I(Et,{"model-value":d.engine,options:d.engineOptions,disabled:d.busy||!d.canEditEngine,placeholder:i(v)("projectManager.selectEngine"),"empty-text":i(v)("projectManager.noEngines"),"get-option-value":c=>(c==null?void 0:c.value)||"","onUpdate:modelValue":x[3]||(x[3]=c=>R("update:engine",c))},{trigger:Le(({disabled:c})=>{var U;return[n("div",Xn,[n("span",{class:N(["min-w-0 flex-1 truncate",c?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},u(((U=E.value)==null?void 0:U.label)||i(v)("projectManager.selectEngine")),3),E.value&&E.value.enabled===!1?(p(),m("span",Yn,u(i(v)("projectManager.comingSoon")),1)):M("",!0)])]}),option:Le(({option:c,selected:U,select:ee})=>[n("button",{type:"button",class:N(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",U?"theme-filter-active":"theme-filter-idle"]),disabled:(c==null?void 0:c.enabled)===!1,onClick:ee},[n("div",Zn,[n("span",es,u(c.label),1),(c==null?void 0:c.enabled)===!1?(p(),m("span",ts,u(i(v)("projectManager.comingSoon")),1)):M("",!0)])],10,Jn)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),d.engineReadonlyMessage?(p(),m("p",ns,u(d.engineReadonlyMessage),1)):M("",!0)]),n("div",ss,[n("span",null,u(i(v)("projectManager.collaborationAgents")),1),n("div",as,[(p(!0),m(ye,null,Se(b.value,c=>(p(),m("button",{key:c.value,type:"button",class:N(["theme-list-row flex items-center justify-between gap-3 rounded-sm border border-solid px-3 py-2 text-left transition",r.value.includes(c.value)?"theme-list-item-active":"theme-list-item-hover"]),disabled:d.busy||!d.canEditEngine,onClick:U=>D(c.value)},[n("div",ls,[n("div",os,u(c.label),1),n("div",rs,u(r.value.includes(c.value)?i(v)("projectManager.agentEnabled"):i(v)("projectManager.agentDisabled")),1)]),r.value.includes(c.value)?(p(),ue(i(it),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textPrimary)]"})):M("",!0)],10,is))),128))]),n("p",ds,u(i(v)("projectManager.collaborationAgentsHint")),1)]),n("label",us,[n("span",null,u(i(v)("projectManager.sessionId")),1),n("div",cs,[n("div",{ref_key:"sessionComboboxRef",ref:G,class:"relative min-w-0 flex-1"},[n("input",{ref_key:"sessionInputRef",ref:H,value:d.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",disabled:d.busy||!d.canEditSessionId,onFocus:O,onInput:q,onKeydown:se},null,40,fs),d.canEditSessionId?(p(),m("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:d.busy||!P.value,onClick:X},[d.sessionCandidatesLoading?(p(),ue(i(Ze),{key:0,class:"h-3.5 w-3.5 animate-spin"})):f.value?(p(),ue(i(gt),{key:1,class:"h-3.5 w-3.5",onClick:at(le,["stop"])})):(p(),ue(i(Kt),{key:2,class:N(["h-3.5 w-3.5 transition",g.value?"rotate-180":""])},null,8,["class"]))],8,ps)):M("",!0),d.canEditSessionId&&g.value?(p(),m("div",gs,[n("div",ms,[n("span",vs,u(i(v)("projectManager.sessionCandidates")),1),d.sessionCandidatesLoading?(p(),m("span",hs,u(i(v)("projectManager.sessionCandidatesLoading")),1)):M("",!0)]),Q.value.length?(p(),m("div",ys,[(p(!0),m(ye,null,Se(Q.value,(c,U)=>(p(),m("button",{key:`${c.engine}:${c.id}`,type:"button",class:N(["theme-list-row mb-1 w-full px-2 py-1.5 text-left last:mb-0",U===w.value?"theme-list-item-active":"theme-list-item-hover"]),disabled:d.busy,onMousedown:x[4]||(x[4]=at(()=>{},["prevent"])),onClick:ee=>me(c)},[n("div",bs,[n("span",ws,u(c.label||c.id),1),n("span",Ss,u(c.updatedAtLabel||i(v)("projectManager.unknown")),1)])],42,xs))),128))])):(p(),m("div",ks,u(P.value?i(v)("projectManager.noSessionCandidates"):i(v)("projectManager.sessionCandidatesNeedDirectory")),1))])):M("",!0)],512),f.value?(p(),m("button",{key:0,type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:d.busy,onClick:x[5]||(x[5]=c=>R("copy-session-id"))},[d.sessionIdCopied?(p(),ue(i(it),{key:0,class:"h-4 w-4"})):(p(),ue(i(qt),{key:1,class:"h-4 w-4"})),n("span",null,u(d.sessionIdCopied?i(v)("projectManager.sessionIdCopied"):i(v)("projectManager.copySessionId")),1)],8,Cs)):M("",!0)]),d.sessionIdReadonlyMessage?(p(),m("p",_s,u(d.sessionIdReadonlyMessage),1)):(p(),m("p",$s,u(P.value?i(v)("projectManager.sessionIdHint"):i(v)("projectManager.sessionCandidatesNeedDirectory")),1))])]))}},Ms={class:"flex items-center justify-between gap-3"},js={class:"theme-heading text-sm font-medium"},Is={key:0,class:"theme-muted-text mt-1 text-xs"},Es=["disabled"],Ps=["onClick"],As={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},Rs={class:"flex w-full flex-col gap-2 text-left"},Ds={class:"theme-heading min-w-0 text-sm font-medium"},Ts=["title"],Ls=["title"],Bs={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},Fs={key:0,"aria-hidden":"true"},Ns={key:1},Os={class:"flex flex-wrap items-center gap-2 pt-1"},Us={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},ht={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:d=>d},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},hasSessions:{type:Boolean,default:!1},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1},mode:{type:String,default:"edit"},mobile:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]}},emits:["create","select"],setup(d,{emit:W}){const j=d,R=W,{t:v}=Qe();function G(w){return j.mode==="edit"&&j.editingSessionId===w.id?"theme-card-selected":j.isSessionRunning(w.id)?"theme-card-warning":"theme-card-idle-strong"}function H(w){return j.isCurrentSession(w.id)?v("projectManager.current"):v("projectManager.regular")}function g(w){return j.isCurrentSession(w.id)?"theme-status-info":"theme-status-neutral"}return(w,E)=>(p(),m("div",{class:N(d.mobile?"flex h-full min-h-0 flex-col":"")},[n("div",Ms,[n("div",null,[n("div",js,u(i(v)("projectManager.projectList")),1),d.hasSessions?M("",!0):(p(),m("p",Is,u(i(v)("projectManager.noProjects")),1))]),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:d.busy,onClick:E[0]||(E[0]=r=>R("create"))},[I(i(Vt),{class:"h-4 w-4"}),n("span",null,u(i(v)("projectManager.create")),1)],8,Es)]),n("div",{class:N(["mt-4 space-y-2",d.mobile?"min-h-0 flex-1 overflow-y-auto":"max-h-52 overflow-y-auto pr-1 sm:max-h-64 lg:max-h-[calc(88vh-11rem)]"])},[(p(!0),m(ye,null,Se(d.sessions,r=>{var b;return p(),m("article",{key:r.id,class:N(["relative cursor-pointer rounded-sm border p-3 transition",G(r)]),onClick:P=>R("select",r.id)},[d.mode==="edit"&&d.editingSessionId===r.id?(p(),m("span",As)):M("",!0),n("div",Rs,[n("div",Ds,[n("span",{class:"block truncate",title:r.title||i(v)("projectManager.untitledProject")},u(r.title||i(v)("projectManager.untitledProject")),9,Ts)]),n("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:r.cwd},u(r.cwd),9,Ls),n("div",Bs,[n("span",null,u(((b=r==null?void 0:r.agentBindings)==null?void 0:b.length)>1?i(v)("projectManager.agentCount",{count:r.agentBindings.length}):i(st)(r.engine)),1),d.mobile?M("",!0):(p(),m("span",Fs,"·")),d.mobile?M("",!0):(p(),m("span",Ns,u(d.formatUpdatedAt(r.updatedAt)),1))]),n("div",Os,[n("span",{class:N(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",g(r)])},u(H(r)),3),n("span",{class:N(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",d.getRuntimeStatusClass(r.id)])},[d.isSessionRunning(r.id)?(p(),m("span",Us)):M("",!0),xt(" "+u(d.getRuntimeStatusLabel(r.id)),1)],2),n("span",{class:N(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",d.getThreadStatusClass(r)])},u(d.getThreadStatusLabel(r)),3)])])],10,Ps)}),128))],2)],2))}},Hs={class:"space-y-3"},zs={class:"dashed-panel px-3 py-3"},Ks={class:"theme-muted-text text-[11px]"},qs={class:"mt-2 flex flex-wrap gap-2"},Vs={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},Ws={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},Qs={class:"dashed-panel px-3 py-3"},Gs={class:"theme-muted-text text-[11px]"},Xs={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},Ys={key:0,class:"mt-2 flex flex-wrap gap-1.5"},Js={class:"dashed-panel px-3 py-3"},Zs={class:"theme-muted-text text-[11px]"},ea={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},ta={class:"dashed-panel px-3 py-3"},na={class:"theme-muted-text text-[11px]"},sa={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},aa={class:"dashed-panel px-3 py-3"},ia={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},la={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},oa={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:d=>d},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1}},setup(d){const{t:W}=Qe();return(j,R)=>{var v,G,H,g,w,E,r,b,P;return p(),m("div",Hs,[n("div",zs,[n("div",Ks,u(i(W)("projectManager.runtimeStatus")),1),n("div",qs,[n("span",{class:N(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",d.getRuntimeStatusClass((v=d.activeSession)==null?void 0:v.id)])},[d.isSessionRunning((G=d.activeSession)==null?void 0:G.id)?(p(),m("span",Vs)):M("",!0),xt(" "+u(d.getRuntimeStatusLabel((H=d.activeSession)==null?void 0:H.id)),1)],2),n("span",{class:N(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",d.getThreadStatusClass(d.activeSession)])},u(d.getThreadStatusLabel(d.activeSession)),3),(g=d.activeSession)!=null&&g.id&&d.isCurrentSession(d.activeSession.id)?(p(),m("span",Ws,u(i(W)("projectManager.currentProject")),1)):M("",!0)])]),n("div",Qs,[n("div",Gs,u(i(W)("projectManager.engine")),1),n("div",Xs,u(i(st)((w=d.activeSession)==null?void 0:w.engine)),1),((r=(E=d.activeSession)==null?void 0:E.agentBindings)==null?void 0:r.length)>1?(p(),m("div",Ys,[(p(!0),m(ye,null,Se(d.activeSession.agentBindings,f=>(p(),m("span",{key:f.engine,class:"theme-status-neutral inline-flex items-center rounded-sm border border-solid px-1.5 py-0.5 text-[10px]"},u(i(st)(f.engine)),1))),128))])):M("",!0)]),n("div",Js,[n("div",Zs,u(i(W)("projectManager.workingDirectory")),1),n("div",ea,u(((b=d.activeSession)==null?void 0:b.cwd)||i(W)("projectManager.notSet")),1)]),n("div",ta,[n("div",na,u(i(W)("projectManager.updatedAt")),1),n("div",sa,u(d.formatUpdatedAt((P=d.activeSession)==null?void 0:P.updatedAt)),1)]),n("div",aa,[n("div",ia,[I(i(Wt),{class:"h-3.5 w-3.5"}),n("span",null,u(i(W)("projectManager.note")),1)]),n("p",la,u(i(W)("projectManager.noteDescription")),1)])])}}},ra={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},da={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},ua={class:"theme-divider theme-muted-panel border-b px-3 py-3 sm:px-4 sm:py-4 lg:border-b-0 lg:border-r"},ca={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},fa={class:"flex flex-wrap items-start justify-between gap-3"},pa={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ga={class:"mt-5"},ma={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},va={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4 sm:flex-row sm:items-center sm:justify-between"},ha={class:"flex flex-wrap items-center gap-2"},ya=["disabled"],xa=["disabled"],ba=["disabled"],wa={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Sa=["disabled"],ka=["disabled"],Ca=["disabled"],_a={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},$a={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ma={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},ja={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ia={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Ea=["disabled"],Pa={class:"min-w-0 flex-1"},Aa={class:"theme-heading truncate text-sm font-medium"},Ra={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Da={class:"theme-divider border-b px-4 py-3"},Ta={class:"grid grid-cols-2 gap-2"},La=["disabled"],Ba={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Fa={key:0},Na={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Oa={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Ua=["disabled"],Ha=["disabled"],za=["disabled"],Ka=["disabled"],qa=3e3,Za={__name:"CodexSessionManagerDialog",props:{open:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]},workspaces:{type:Array,default:()=>[]},selectedSessionId:{type:String,default:""},selectionLocked:{type:Boolean,default:!1},selectionLockReason:{type:String,default:""},loading:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},onRefresh:{type:Function,default:null},onCreate:{type:Function,default:null},onUpdate:{type:Function,default:null},onDelete:{type:Function,default:null},onReset:{type:Function,default:null}},emits:["close","project-created","select-session","open-source-browser"],setup(d,{expose:W,emit:j}){const R=new Map;function v(t="",a=""){const y=We(t),C=nt(a);return!y||!C?"":`${y}
|
|
1
|
+
import{W as ut,j as yt,o as Mt,s as jt,p as It,q as ct,h as Et,t as st,f as Pt,v as ft,w as pt,x as At,y as We,z as Rt,A as nt}from"./WorkbenchView-CsZnW4Q7.js";import{u as Qe,f as Dt,e as Tt}from"./index-Bt9T2IKp.js";import{w as ie,n as he,ak as lt,aD as p,aI as ue,aJ as Le,aF as n,aQ as u,u as i,aG as I,aW as Lt,aU as Bt,aX as Ft,aE as m,aR as ye,aS as Se,aL as N,aN as M,aV as Nt,aK as at,b as $,c as k,o as Ot,aZ as xt,r as Ut}from"./vendor-misc-u-M8sNMf.js";import{c as Ht,L as Ze,F as et,e as zt,b as it,X as gt,C as Kt,O as qt,j as Vt,x as Wt,P as Qt,i as mt,E as Gt,Q as Xt,q as Yt,r as Jt,Y as Zt}from"./vendor-ui-BglsaDbv.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";import"./vendor-router-Dn8q3tJM.js";const en={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},tn={class:"theme-muted-text mt-1 text-xs leading-5"},nn={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},sn={class:"flex items-start gap-2 text-xs leading-5"},an={class:"theme-muted-text shrink-0"},ln={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},on={class:"theme-muted-text mt-4 block text-xs"},rn={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},dn=["placeholder"],un={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},cn={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},fn={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},pn={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},gn={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},mn={key:4,class:"theme-empty-state px-3 py-8 text-sm"},vn={key:5,class:"theme-empty-state px-3 py-8 text-sm"},hn={key:6,class:"theme-empty-state px-3 py-8 text-sm"},yn={key:7,class:"space-y-1"},xn=["onClick"],bn={class:"min-w-0 flex-1"},wn=["innerHTML"],Sn=["innerHTML"],kn={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},Cn={key:8,class:"space-y-1"},_n={class:"flex items-start gap-1.5"},$n=["onClick"],Mn=["onClick"],jn={class:"min-w-0 flex-1"},In={key:0,class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all"},En={class:"theme-divider flex flex-col-reverse gap-2 border-t border-dashed px-4 py-4 sm:flex-row sm:items-center sm:justify-end sm:px-5"},Pn={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},An=["disabled"],Rn=["disabled"],Dn={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(d,{emit:W}){const j=d,R=W,{t:v}=Qe(),G=$(""),H=$([]),g=$(!1),w=$(""),E=$(!1),r=$(""),b=$([]),P=$(!1),f=$(""),_=$(""),ce=$(null);let Q=null,O=0,B=null;const z=new Map,K=k(()=>Fe(H.value)),X=k(()=>String(f.value||"").trim()),Y=k(()=>X.value.length>=ut),D=k(()=>!!X.value),le=k(()=>Ce(_.value)||G.value),q=k(()=>D.value?b.value:K.value),me=k(()=>q.value.map(e=>{const l=c((e==null?void 0:e.path)||""),s=e!=null&&e.expanded?1:0,o=e!=null&&e.loading?1:0;return`${l}:${s}:${o}`}).join("|")),se=k(()=>D.value&&!Y.value&&!E.value&&!r.value),J=k(()=>D.value&&Y.value&&!E.value&&!r.value&&!b.value.length),h=k(()=>!D.value&&!g.value&&!w.value&&!K.value.length);function x(e=""){const l=String(e||"").trim();return/^[a-z]:[\\/]/i.test(l)||l.includes("\\")}function c(e=""){const l=String(e||"").trim();if(!l)return"";const s=x(l);let o=l.replace(/\\/g,"/");return o.length>1&&!/^[a-z]:\/?$/i.test(o)&&o!=="/"&&(o=o.replace(/\/+$/,"")),s?o.toLowerCase():o}function U(e="",l=""){const s=c(e),o=c(l);if(!s||!o||o==="/"&&s!=="/")return!1;const A=o.endsWith("/")?o:`${o}/`;return s===o||s.startsWith(A)}function ee(e="",l=""){const s=String(e||"").trim(),o=String(l||"").trim();return s?o?x(s)?/^[a-z]:\\?$/i.test(s)?`${s.replace(/[\\/]+$/,"")}\\${o}`:`${s.replace(/[\\/]+$/,"")}\\${o}`:s==="/"?`/${o}`:`${s.replace(/\/+$/,"")}/${o}`:s:o}function S(e="",l=""){const s=c(e),o=c(l);if(!s||!o||!U(o,s))return[];const A=o===s?"":o.slice(s.length).replace(/^\//,"");return A?A.split("/").filter(Boolean):[]}function ke(e=""){const l=String(e||"").trim(),s=Ce(l);if(!l||!s||c(l)===c(s))return"";const o=x(l),A=l.replace(/\\/g,"/");if(o){const de=A.replace(/\/+$/,""),qe=de.lastIndexOf("/");if(qe<=2)return"";const Te=de.slice(0,qe).replace(/\//g,"\\");return U(Te,s)?Te:""}const V=A.replace(/\/+$/,""),ne=V.lastIndexOf("/");if(ne<=0)return"";const ae=V.slice(0,ne)||"/";return U(ae,s)?ae:""}function Ce(e=""){const l=String(e||"").trim();return l&&H.value.map(o=>String((o==null?void 0:o.path)||"").trim()).filter(o=>o&&U(l,o)).sort((o,A)=>c(A).length-c(o).length)[0]||""}function xe(e){return(e==null?void 0:e.name)||(e==null?void 0:e.path)||v("directoryPicker.unnamedDirectory")}function _e(e=""){const l=String(e||"").trim();return l?l.split(/[\\/]/).filter(Boolean).at(-1)||l:"Home"}function ve(e=""){return String(e||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function fe(e="",l=""){const s=String(e||""),o=String(l||"").trim().toLowerCase();if(!s||!o)return null;const A=s.toLowerCase(),V=A.indexOf(o);if(V>=0)return{start:V,end:V+o.length};const ne=o.split(/[\\/\s_.-]+/).filter(Boolean).sort((ae,de)=>de.length-ae.length);for(const ae of ne){if(ae.length<2)continue;const de=A.indexOf(ae);if(de>=0)return{start:de,end:de+ae.length}}return null}function T(e="",l=""){const s=String(e||""),o=fe(s,l);return o?`${ve(s.slice(0,o.start))}<mark class="theme-search-highlight">${ve(s.slice(o.start,o.end))}</mark>${ve(s.slice(o.end))}`:ve(s)}function tt(e){return T(xe(e),f.value)}function Be(e){return T((e==null?void 0:e.path)||"",f.value)}function $e(e,l=0){return{...e,depth:l,expanded:!1,loaded:!1,loading:!1,children:[]}}function Fe(e=[],l=[]){return e.forEach(s=>{l.push(s),s.expanded&&s.children.length&&Fe(s.children,l)}),l}function oe(){H.value=[...H.value]}function be(){Q&&(window.clearTimeout(Q),Q=null),B&&(B.abort(),B=null)}function we(e,l=H.value){const s=c(e);if(!s)return null;for(const o of l){if(c(o.path)===s)return o;if(o.children.length){const A=we(e,o.children);if(A)return A}}return null}function Z(e){_.value=String((e==null?void 0:e.path)||"").trim()}function pe(e=""){return c(e)}function Ne(e,l){const s=pe(e);if(s){if(l){z.set(s,l);return}z.delete(s)}}function Me(){var l;const e=z.get(pe(_.value));(l=e==null?void 0:e.scrollIntoView)==null||l.call(e,{block:"nearest"})}function Ge(){he(()=>{var e,l;(l=(e=ce.value)==null?void 0:e.focus)==null||l.call(e)})}function re(){const e=q.value;if(!e.length){_.value="";return}const l=pe(_.value);l&&e.some(s=>pe((s==null?void 0:s.path)||"")===l)||Z(e[0])}function ge(){const e=q.value;if(!e.length)return-1;const l=pe(_.value),s=e.findIndex(o=>pe((o==null?void 0:o.path)||"")===l);return s>=0?s:0}function je(){const e=q.value,l=ge();return l<0||!e.length?null:e[l]||null}function Ie(e=1){const l=q.value;if(!l.length)return!1;const s=ge(),o=s<0?0:(s+e+l.length)%l.length;return Z(l[o]),he(Me),!0}async function Oe(){if(D.value)return!1;const e=je();if(!e||!e.hasChildren)return!1;if(!e.expanded)return await De(e),!0;const l=q.value,s=ge(),o=l[s+1];return o&&ke(o.path)===e.path?(Z(o),he(Me),!0):!1}function Ue(){if(D.value)return!1;const e=je();if(!e)return!1;if(e.expanded&&e.hasChildren)return e.expanded=!1,oe(),Z(e),!0;const l=ke(e.path);if(!l)return!1;const s=we(l);return s?(Z(s),he(Me),!0):!1}function Ee(e){var l,s,o;if((l=e==null?void 0:e.preventDefault)==null||l.call(e),X.value){(s=e==null?void 0:e.stopPropagation)==null||s.call(e),f.value="";return}(o=e==null?void 0:e.stopPropagation)==null||o.call(e),R("close")}function Pe(e){const l=String((e==null?void 0:e.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(l)&&!(D.value&&(l==="ArrowLeft"||l==="ArrowRight"))){if(l==="ArrowDown"){e.preventDefault(),Ie(1);return}if(l==="ArrowUp"){e.preventDefault(),Ie(-1);return}if(l==="Escape"){Ee(e);return}if(D.value){if(l==="Enter"){e.preventDefault();const s=je();s&&Je(s)}return}if(l==="ArrowRight"){e.preventDefault(),Oe();return}if(l==="ArrowLeft"){e.preventDefault(),Ue();return}l==="Enter"&&(e.preventDefault(),Ke())}}async function He(e,l={}){if(!(!e||e.loading)&&!(e.loaded&&!l.force)){e.loading=!0,w.value="",oe();try{const s=await ct({path:e.path,limit:240});e.children=(s.items||[]).map(o=>$e(o,e.depth+1)),e.loaded=!0}catch(s){w.value=s.message||v("directoryPicker.loadFailed")}finally{e.loading=!1,oe()}}}async function Ae(){g.value=!0,w.value="";try{const e=await ct({limit:240});G.value=String(e.path||"");const l=Array.isArray(e.roots)&&e.roots.length?e.roots:[{name:_e(e.path||""),path:String(e.path||""),type:"directory",hasChildren:!0,isRoot:!0}],s=c(e.path||""),o=l.map(A=>{const V=$e({...A,isHomeRoot:c(A.path||"")===s},0);return V.isHomeRoot&&(V.children=(e.items||[]).map(ne=>$e(ne,1)),V.loaded=!0,V.expanded=!0),V});H.value=o,Z(o.find(A=>A.isHomeRoot)||o[0])}catch(e){w.value=e.message||v("directoryPicker.treeLoadFailed"),H.value=[],G.value=""}finally{g.value=!1}}async function te(e=""){const l=String(e||"").trim(),s=Ce(l);if(!l||!s)return;let o=we(s);if(!o)return;Z(o);const A=S(s,l);for(const V of A){await He(o),o.expanded=!0,oe();const ne=we(ee(o.path,V),o.children);if(!ne)break;o=ne,Z(o)}}async function Re(){f.value="",b.value=[],r.value="",P.value=!1,_.value="",await Ae();const e=String(j.initialPath||"").trim();e&&Ce(e)&&await te(e)}async function De(e){if(e!=null&&e.path&&(Z(e),!!e.hasChildren)){if(!e.loaded){e.expanded=!0,oe(),await He(e);return}e.expanded=!e.expanded,oe()}}function ze(e){e!=null&&e.path&&Z(e)}async function Xe(){const e=String(f.value||"").trim();O+=1;const l=O;if(be(),!j.open||!e||!le.value||!Y.value){E.value=!1,r.value="",b.value=[],P.value=!1;return}E.value=!0,r.value="",B=new AbortController;try{const s=await jt(e,{path:le.value,limit:80,signal:B.signal});if(l!==O)return;b.value=Array.isArray(s.items)?s.items:[],P.value=!!s.truncated}catch(s){if(It(s)||l!==O)return;r.value=s.message||v("directoryPicker.searchFailed"),b.value=[],P.value=!1}finally{l===O&&(B=null),l===O&&(E.value=!1)}}function Ye(){if(be(),!String(f.value||"").trim()||!Y.value){E.value=!1,r.value="",b.value=[],P.value=!1;return}E.value=!0,r.value="",Q=window.setTimeout(()=>{Q=null,Xe()},Mt)}async function Je(e){e!=null&&e.path&&(await te(e.path),f.value="")}function Ke(){_.value&&(R("select",_.value),R("close"))}return ie(f,()=>{Ye()}),ie(me,()=>{re(),he(Me)},{immediate:!0}),ie(()=>j.open,e=>{if(e){Re().catch(()=>{}),Ge();return}be()}),lt(()=>{be()}),(e,l)=>(p(),ue(yt,{open:d.open,"stack-level":1,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-4xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:px-5","close-disabled":g.value||E.value,"close-on-backdrop":!(g.value||E.value),"close-on-escape":!(g.value||E.value),onClose:l[2]||(l[2]=s=>R("close"))},{title:Le(()=>[n("div",null,[n("div",en,[I(i(et),{class:"h-4 w-4"}),n("span",null,u(i(v)("directoryPicker.title")),1)]),n("p",tn,u(i(v)("directoryPicker.intro")),1)])]),default:Le(()=>[n("div",{class:"flex min-h-0 flex-1 flex-col overflow-hidden",onKeydown:Pe},[n("div",nn,[n("div",sn,[n("span",an,u(i(v)("directoryPicker.currentSelection")),1),n("span",ln,u(_.value||i(v)("directoryPicker.selectionPlaceholder")),1)])]),n("label",on,[n("span",null,u(i(v)("directoryPicker.searchLabel")),1),n("div",rn,[I(i(Ht),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),Lt(n("input",{ref_key:"searchInputRef",ref:ce,"onUpdate:modelValue":l[0]||(l[0]=s=>f.value=s),type:"text",placeholder:i(v)("directoryPicker.searchPlaceholder"),class:"min-w-0 flex-1 border-0 bg-transparent px-0 text-sm text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]",onKeydown:Bt(Ee,["esc"])},null,40,dn),[[Ft,f.value]])])]),n("div",un,[D.value&&r.value?(p(),m("div",cn,u(r.value),1)):!D.value&&w.value?(p(),m("div",fn,u(w.value),1)):D.value&&E.value?(p(),m("div",pn,[I(i(Ze),{class:"h-4 w-4 animate-spin"}),n("span",null,u(i(v)("directoryPicker.searching")),1)])):!D.value&&g.value?(p(),m("div",gn,[I(i(Ze),{class:"h-4 w-4 animate-spin"}),n("span",null,u(i(v)("directoryPicker.treeLoading")),1)])):se.value?(p(),m("div",mn,u(i(v)("directoryPicker.searchMinKeywordHint",{count:i(ut)})),1)):J.value?(p(),m("div",vn,u(i(v)("directoryPicker.noSearchResults")),1)):h.value?(p(),m("div",hn,u(i(v)("directoryPicker.emptyTree")),1)):D.value?(p(),m("div",yn,[(p(!0),m(ye,null,Se(b.value,s=>(p(),m("button",{key:s.path,ref_for:!0,ref:o=>Ne(s.path,o),type:"button",class:N(["theme-list-row focus:outline-none",c(_.value)===c(s.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:o=>Je(s)},[I(i(et),{class:"theme-list-item-icon"}),n("div",bn,[n("div",null,[n("span",{class:"theme-list-item-title block break-all",innerHTML:tt(s)},null,8,wn)]),n("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:Be(s)},null,8,Sn)])],10,xn))),128)),P.value?(p(),m("p",kn,u(i(v)("directoryPicker.truncatedHint")),1)):M("",!0)])):(p(),m("div",Cn,[(p(!0),m(ye,null,Se(K.value,s=>(p(),m("div",{key:s.path,ref_for:!0,ref:o=>Ne(s.path,o),class:N(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",c(_.value)===c(s.path)?"theme-list-item-active":s.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Nt({paddingLeft:`${s.depth*16+6}px`})},[n("div",_n,[n("button",{type:"button",class:N(["theme-icon-button h-5 w-5 shrink-0",s.hasChildren?"":"invisible pointer-events-none"]),onClick:at(o=>De(s),["stop"])},[s.loading?(p(),ue(i(Ze),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(p(),ue(i(zt),{key:1,class:N(["h-3.5 w-3.5 transition",s.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,$n),n("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:o=>ze(s)},[I(i(et),{class:N(["h-4 w-4 shrink-0",c(_.value)===c(s.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),n("div",jn,[n("div",{class:N(["theme-list-item-title truncate",s.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},u(xe(s)),3),s.isHomeRoot?(p(),m("div",In,u(s.path),1)):M("",!0)])],8,Mn)])],6))),128))]))])],32),n("div",En,[n("div",Pn,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:g.value||E.value,onClick:l[1]||(l[1]=s=>R("close"))},u(i(v)("directoryPicker.cancel")),9,An),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex w-full items-center justify-center gap-2 px-3 py-2 text-xs sm:w-auto",disabled:g.value||E.value||!_.value,onClick:Ke},[I(i(it),{class:"h-4 w-4"}),n("span",null,u(i(v)("directoryPicker.useCurrentDirectory")),1)],8,Rn)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Tn={class:"grid gap-4"},Ln={class:"theme-muted-text block text-xs"},Bn=["value","disabled"],Fn={class:"theme-muted-text block text-xs"},Nn={class:"mt-1 flex gap-2"},On={class:"relative min-w-0 flex-1"},Un=["value","disabled"],Hn=["disabled"],zn=["disabled"],Kn={id:"codex-manager-workspace-suggestions"},qn=["value"],Vn={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Wn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},Qn={class:"theme-muted-text block text-xs"},Gn={class:"mt-1"},Xn={class:"flex items-center gap-2 text-sm"},Yn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Jn=["disabled","onClick"],Zn={class:"flex items-center justify-between gap-3"},es={class:"min-w-0 flex-1 truncate"},ts={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},ns={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},ss={class:"theme-muted-text block text-xs"},as={class:"mt-2 grid gap-2"},is=["disabled","onClick"],ls={class:"min-w-0"},os={class:"text-sm text-[var(--theme-textPrimary)]"},rs={class:"theme-muted-text mt-0.5 text-[11px] leading-5"},ds={class:"theme-muted-text mt-2 text-[11px] leading-5"},us={class:"theme-muted-text block text-xs"},cs={class:"mt-1 flex gap-2"},fs=["value","disabled"],ps=["disabled"],gs={key:1,class:"theme-popover theme-divider absolute left-0 right-0 top-[calc(100%+0.375rem)] z-20 overflow-hidden rounded-sm border border-solid shadow-sm"},ms={class:"flex items-center justify-between gap-2 border-b border-solid px-3 py-2 text-[11px] leading-5"},vs={class:"font-medium text-[var(--theme-textPrimary)]"},hs={key:0,class:"theme-muted-text"},ys={key:0,class:"max-h-72 overflow-y-auto p-2"},xs=["disabled","onClick"],bs={class:"flex min-w-0 items-center justify-between gap-3"},ws={class:"min-w-0 flex-1 truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Ss={class:"shrink-0 text-[11px] leading-4 text-[var(--theme-textMuted)]"},ks={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Cs=["disabled"],_s={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},$s={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},vt={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},agentEngines:{type:Array,default:()=>[]},canEditEngine:{type:Boolean,default:!0},canEditCwd:{type:Boolean,default:!0},canEditSessionId:{type:Boolean,default:!0},cwd:{type:String,default:""},cwdReadonlyMessage:{type:String,default:""},duplicateCwdMessage:{type:String,default:""},engine:{type:String,default:"codex"},engineOptions:{type:Array,default:()=>[]},engineReadonlyMessage:{type:String,default:""},mobile:{type:Boolean,default:!1},sessionId:{type:String,default:""},sessionIdCopied:{type:Boolean,default:!1},sessionIdReadonlyMessage:{type:String,default:""},sessionCandidates:{type:Array,default:()=>[]},sessionCandidatesLoading:{type:Boolean,default:!1},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","select-session-candidate","update:agentEngines","update:cwd","update:engine","update:sessionId","update:title"],setup(d,{emit:W}){const j=d,R=W,{t:v}=Qe(),G=$(null),H=$(null),g=$(!1),w=$(-1),E=k(()=>{const h=String(j.engine||"").trim();return j.engineOptions.find(x=>String((x==null?void 0:x.value)||"").trim()===h)||null}),r=k(()=>{const h=Array.isArray(j.agentEngines)?j.agentEngines:[];return[...new Set(h.map(x=>String(x||"").trim()).filter(Boolean))]}),b=k(()=>j.engineOptions.filter(h=>String((h==null?void 0:h.value)||"").trim()!==String(j.engine||"").trim())),P=k(()=>!!String(j.cwd||"").trim()),f=k(()=>String(j.sessionId||"").trim()),_=k(()=>f.value.toLowerCase()),ce=k(()=>j.sessionCandidates.filter(h=>h==null?void 0:h.matchedCwd)),Q=k(()=>{const h=_.value,x=ce.value;return h?x.filter(c=>[c==null?void 0:c.label,c==null?void 0:c.id,c==null?void 0:c.cwd].map(ee=>String(ee||"").toLowerCase()).some(ee=>ee.includes(h))).slice(0,10):x.slice(0,10)});function O(){j.busy||!j.canEditSessionId||!P.value||(g.value=!0)}function B(){g.value=!1,w.value=-1}function z(){const h=Q.value;if(!h.length){w.value=-1;return}const x=h.findIndex(c=>c.id===f.value);w.value=x>=0?x:0}function K(){he(()=>{var h,x;(x=(h=H.value)==null?void 0:h.focus)==null||x.call(h)})}function X(){if(g.value){B();return}O(),K()}function Y(){R("update:cwd","")}function D(h){if(!j.canEditEngine||j.busy)return;const x=String(h||"").trim(),c=r.value.includes(x)?r.value.filter(U=>U!==x):[...r.value,x];R("update:agentEngines",c)}function le(){R("update:sessionId",""),B(),K()}function q(h){var x;R("update:sessionId",((x=h==null?void 0:h.target)==null?void 0:x.value)||""),P.value&&O()}function me(h){R("select-session-candidate",h),B(),K()}function se(h){if(j.busy||!j.canEditSessionId||!P.value)return;const x=Q.value;if(h.key==="ArrowDown"){if(h.preventDefault(),!g.value){O(),z();return}if(!x.length)return;w.value=w.value<0?0:Math.min(x.length-1,w.value+1);return}if(h.key==="ArrowUp"){if(h.preventDefault(),!g.value){O(),z();return}if(!x.length)return;w.value=w.value<0?x.length-1:Math.max(0,w.value-1);return}if(h.key==="Enter"&&g.value&&x.length&&w.value>=0){h.preventDefault(),me(x[w.value]);return}h.key==="Escape"&&g.value&&(h.preventDefault(),B())}function J(h){!g.value||!G.value||G.value.contains(h.target)||B()}return ie(Q,()=>{z()}),ie(()=>j.canEditSessionId,h=>{(!h||!P.value)&&B()}),ie(P,h=>{h||B()}),Ot(()=>{document.addEventListener("pointerdown",J)}),lt(()=>{document.removeEventListener("pointerdown",J)}),(h,x)=>(p(),m("div",Tn,[n("label",Ln,[n("span",null,u(i(v)("projectManager.projectTitleOptional")),1),n("input",{value:d.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:d.busy,onInput:x[0]||(x[0]=c=>R("update:title",c.target.value))},null,40,Bn)]),n("label",Fn,[n("span",null,u(i(v)("projectManager.workingDirectoryField")),1),n("div",Nn,[n("div",On,[n("input",{value:d.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:N(["tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",d.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:d.busy||!d.canEditCwd,onInput:x[1]||(x[1]=c=>R("update:cwd",c.target.value))},null,42,Un),d.cwd&&d.canEditCwd?(p(),m("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:d.busy,onClick:Y},[I(i(gt),{class:"h-3.5 w-3.5"})],8,Hn)):M("",!0)]),n("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:d.busy||!d.canEditCwd,onClick:x[2]||(x[2]=c=>R("open-directory-picker"))},[I(i(et),{class:"h-4 w-4"}),n("span",null,u(d.mobile?i(v)("projectManager.choose"):i(v)("projectManager.chooseDirectory")),1)],8,zn)]),n("datalist",Kn,[(p(!0),m(ye,null,Se(d.workspaceSuggestions,c=>(p(),m("option",{key:c,value:c},null,8,qn))),128))]),d.duplicateCwdMessage?(p(),m("p",Vn,u(d.duplicateCwdMessage),1)):d.cwdReadonlyMessage?(p(),m("p",Wn,u(d.cwdReadonlyMessage),1)):M("",!0)]),n("label",Qn,[n("span",null,u(i(v)("projectManager.engineField")),1),n("div",Gn,[I(Et,{"model-value":d.engine,options:d.engineOptions,disabled:d.busy||!d.canEditEngine,placeholder:i(v)("projectManager.selectEngine"),"empty-text":i(v)("projectManager.noEngines"),"get-option-value":c=>(c==null?void 0:c.value)||"","onUpdate:modelValue":x[3]||(x[3]=c=>R("update:engine",c))},{trigger:Le(({disabled:c})=>{var U;return[n("div",Xn,[n("span",{class:N(["min-w-0 flex-1 truncate",c?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},u(((U=E.value)==null?void 0:U.label)||i(v)("projectManager.selectEngine")),3),E.value&&E.value.enabled===!1?(p(),m("span",Yn,u(i(v)("projectManager.comingSoon")),1)):M("",!0)])]}),option:Le(({option:c,selected:U,select:ee})=>[n("button",{type:"button",class:N(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",U?"theme-filter-active":"theme-filter-idle"]),disabled:(c==null?void 0:c.enabled)===!1,onClick:ee},[n("div",Zn,[n("span",es,u(c.label),1),(c==null?void 0:c.enabled)===!1?(p(),m("span",ts,u(i(v)("projectManager.comingSoon")),1)):M("",!0)])],10,Jn)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),d.engineReadonlyMessage?(p(),m("p",ns,u(d.engineReadonlyMessage),1)):M("",!0)]),n("div",ss,[n("span",null,u(i(v)("projectManager.collaborationAgents")),1),n("div",as,[(p(!0),m(ye,null,Se(b.value,c=>(p(),m("button",{key:c.value,type:"button",class:N(["theme-list-row flex items-center justify-between gap-3 rounded-sm border border-solid px-3 py-2 text-left transition",r.value.includes(c.value)?"theme-list-item-active":"theme-list-item-hover"]),disabled:d.busy||!d.canEditEngine,onClick:U=>D(c.value)},[n("div",ls,[n("div",os,u(c.label),1),n("div",rs,u(r.value.includes(c.value)?i(v)("projectManager.agentEnabled"):i(v)("projectManager.agentDisabled")),1)]),r.value.includes(c.value)?(p(),ue(i(it),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textPrimary)]"})):M("",!0)],10,is))),128))]),n("p",ds,u(i(v)("projectManager.collaborationAgentsHint")),1)]),n("label",us,[n("span",null,u(i(v)("projectManager.sessionId")),1),n("div",cs,[n("div",{ref_key:"sessionComboboxRef",ref:G,class:"relative min-w-0 flex-1"},[n("input",{ref_key:"sessionInputRef",ref:H,value:d.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",disabled:d.busy||!d.canEditSessionId,onFocus:O,onInput:q,onKeydown:se},null,40,fs),d.canEditSessionId?(p(),m("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:d.busy||!P.value,onClick:X},[d.sessionCandidatesLoading?(p(),ue(i(Ze),{key:0,class:"h-3.5 w-3.5 animate-spin"})):f.value?(p(),ue(i(gt),{key:1,class:"h-3.5 w-3.5",onClick:at(le,["stop"])})):(p(),ue(i(Kt),{key:2,class:N(["h-3.5 w-3.5 transition",g.value?"rotate-180":""])},null,8,["class"]))],8,ps)):M("",!0),d.canEditSessionId&&g.value?(p(),m("div",gs,[n("div",ms,[n("span",vs,u(i(v)("projectManager.sessionCandidates")),1),d.sessionCandidatesLoading?(p(),m("span",hs,u(i(v)("projectManager.sessionCandidatesLoading")),1)):M("",!0)]),Q.value.length?(p(),m("div",ys,[(p(!0),m(ye,null,Se(Q.value,(c,U)=>(p(),m("button",{key:`${c.engine}:${c.id}`,type:"button",class:N(["theme-list-row mb-1 w-full px-2 py-1.5 text-left last:mb-0",U===w.value?"theme-list-item-active":"theme-list-item-hover"]),disabled:d.busy,onMousedown:x[4]||(x[4]=at(()=>{},["prevent"])),onClick:ee=>me(c)},[n("div",bs,[n("span",ws,u(c.label||c.id),1),n("span",Ss,u(c.updatedAtLabel||i(v)("projectManager.unknown")),1)])],42,xs))),128))])):(p(),m("div",ks,u(P.value?i(v)("projectManager.noSessionCandidates"):i(v)("projectManager.sessionCandidatesNeedDirectory")),1))])):M("",!0)],512),f.value?(p(),m("button",{key:0,type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:d.busy,onClick:x[5]||(x[5]=c=>R("copy-session-id"))},[d.sessionIdCopied?(p(),ue(i(it),{key:0,class:"h-4 w-4"})):(p(),ue(i(qt),{key:1,class:"h-4 w-4"})),n("span",null,u(d.sessionIdCopied?i(v)("projectManager.sessionIdCopied"):i(v)("projectManager.copySessionId")),1)],8,Cs)):M("",!0)]),d.sessionIdReadonlyMessage?(p(),m("p",_s,u(d.sessionIdReadonlyMessage),1)):(p(),m("p",$s,u(P.value?i(v)("projectManager.sessionIdHint"):i(v)("projectManager.sessionCandidatesNeedDirectory")),1))])]))}},Ms={class:"flex items-center justify-between gap-3"},js={class:"theme-heading text-sm font-medium"},Is={key:0,class:"theme-muted-text mt-1 text-xs"},Es=["disabled"],Ps=["onClick"],As={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},Rs={class:"flex w-full flex-col gap-2 text-left"},Ds={class:"theme-heading min-w-0 text-sm font-medium"},Ts=["title"],Ls=["title"],Bs={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},Fs={key:0,"aria-hidden":"true"},Ns={key:1},Os={class:"flex flex-wrap items-center gap-2 pt-1"},Us={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},ht={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:d=>d},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},hasSessions:{type:Boolean,default:!1},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1},mode:{type:String,default:"edit"},mobile:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]}},emits:["create","select"],setup(d,{emit:W}){const j=d,R=W,{t:v}=Qe();function G(w){return j.mode==="edit"&&j.editingSessionId===w.id?"theme-card-selected":j.isSessionRunning(w.id)?"theme-card-warning":"theme-card-idle-strong"}function H(w){return j.isCurrentSession(w.id)?v("projectManager.current"):v("projectManager.regular")}function g(w){return j.isCurrentSession(w.id)?"theme-status-info":"theme-status-neutral"}return(w,E)=>(p(),m("div",{class:N(d.mobile?"flex h-full min-h-0 flex-col":"")},[n("div",Ms,[n("div",null,[n("div",js,u(i(v)("projectManager.projectList")),1),d.hasSessions?M("",!0):(p(),m("p",Is,u(i(v)("projectManager.noProjects")),1))]),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:d.busy,onClick:E[0]||(E[0]=r=>R("create"))},[I(i(Vt),{class:"h-4 w-4"}),n("span",null,u(i(v)("projectManager.create")),1)],8,Es)]),n("div",{class:N(["mt-4 space-y-2",d.mobile?"min-h-0 flex-1 overflow-y-auto":"max-h-52 overflow-y-auto pr-1 sm:max-h-64 lg:max-h-[calc(88vh-11rem)]"])},[(p(!0),m(ye,null,Se(d.sessions,r=>{var b;return p(),m("article",{key:r.id,class:N(["relative cursor-pointer rounded-sm border p-3 transition",G(r)]),onClick:P=>R("select",r.id)},[d.mode==="edit"&&d.editingSessionId===r.id?(p(),m("span",As)):M("",!0),n("div",Rs,[n("div",Ds,[n("span",{class:"block truncate",title:r.title||i(v)("projectManager.untitledProject")},u(r.title||i(v)("projectManager.untitledProject")),9,Ts)]),n("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:r.cwd},u(r.cwd),9,Ls),n("div",Bs,[n("span",null,u(((b=r==null?void 0:r.agentBindings)==null?void 0:b.length)>1?i(v)("projectManager.agentCount",{count:r.agentBindings.length}):i(st)(r.engine)),1),d.mobile?M("",!0):(p(),m("span",Fs,"·")),d.mobile?M("",!0):(p(),m("span",Ns,u(d.formatUpdatedAt(r.updatedAt)),1))]),n("div",Os,[n("span",{class:N(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",g(r)])},u(H(r)),3),n("span",{class:N(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",d.getRuntimeStatusClass(r.id)])},[d.isSessionRunning(r.id)?(p(),m("span",Us)):M("",!0),xt(" "+u(d.getRuntimeStatusLabel(r.id)),1)],2),n("span",{class:N(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",d.getThreadStatusClass(r)])},u(d.getThreadStatusLabel(r)),3)])])],10,Ps)}),128))],2)],2))}},Hs={class:"space-y-3"},zs={class:"dashed-panel px-3 py-3"},Ks={class:"theme-muted-text text-[11px]"},qs={class:"mt-2 flex flex-wrap gap-2"},Vs={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},Ws={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},Qs={class:"dashed-panel px-3 py-3"},Gs={class:"theme-muted-text text-[11px]"},Xs={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},Ys={key:0,class:"mt-2 flex flex-wrap gap-1.5"},Js={class:"dashed-panel px-3 py-3"},Zs={class:"theme-muted-text text-[11px]"},ea={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},ta={class:"dashed-panel px-3 py-3"},na={class:"theme-muted-text text-[11px]"},sa={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},aa={class:"dashed-panel px-3 py-3"},ia={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},la={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},oa={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:d=>d},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1}},setup(d){const{t:W}=Qe();return(j,R)=>{var v,G,H,g,w,E,r,b,P;return p(),m("div",Hs,[n("div",zs,[n("div",Ks,u(i(W)("projectManager.runtimeStatus")),1),n("div",qs,[n("span",{class:N(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",d.getRuntimeStatusClass((v=d.activeSession)==null?void 0:v.id)])},[d.isSessionRunning((G=d.activeSession)==null?void 0:G.id)?(p(),m("span",Vs)):M("",!0),xt(" "+u(d.getRuntimeStatusLabel((H=d.activeSession)==null?void 0:H.id)),1)],2),n("span",{class:N(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",d.getThreadStatusClass(d.activeSession)])},u(d.getThreadStatusLabel(d.activeSession)),3),(g=d.activeSession)!=null&&g.id&&d.isCurrentSession(d.activeSession.id)?(p(),m("span",Ws,u(i(W)("projectManager.currentProject")),1)):M("",!0)])]),n("div",Qs,[n("div",Gs,u(i(W)("projectManager.engine")),1),n("div",Xs,u(i(st)((w=d.activeSession)==null?void 0:w.engine)),1),((r=(E=d.activeSession)==null?void 0:E.agentBindings)==null?void 0:r.length)>1?(p(),m("div",Ys,[(p(!0),m(ye,null,Se(d.activeSession.agentBindings,f=>(p(),m("span",{key:f.engine,class:"theme-status-neutral inline-flex items-center rounded-sm border border-solid px-1.5 py-0.5 text-[10px]"},u(i(st)(f.engine)),1))),128))])):M("",!0)]),n("div",Js,[n("div",Zs,u(i(W)("projectManager.workingDirectory")),1),n("div",ea,u(((b=d.activeSession)==null?void 0:b.cwd)||i(W)("projectManager.notSet")),1)]),n("div",ta,[n("div",na,u(i(W)("projectManager.updatedAt")),1),n("div",sa,u(d.formatUpdatedAt((P=d.activeSession)==null?void 0:P.updatedAt)),1)]),n("div",aa,[n("div",ia,[I(i(Wt),{class:"h-3.5 w-3.5"}),n("span",null,u(i(W)("projectManager.note")),1)]),n("p",la,u(i(W)("projectManager.noteDescription")),1)])])}}},ra={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},da={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},ua={class:"theme-divider theme-muted-panel border-b px-3 py-3 sm:px-4 sm:py-4 lg:border-b-0 lg:border-r"},ca={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},fa={class:"flex flex-wrap items-start justify-between gap-3"},pa={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ga={class:"mt-5"},ma={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},va={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4 sm:flex-row sm:items-center sm:justify-between"},ha={class:"flex flex-wrap items-center gap-2"},ya=["disabled"],xa=["disabled"],ba=["disabled"],wa={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Sa=["disabled"],ka=["disabled"],Ca=["disabled"],_a={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},$a={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ma={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},ja={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ia={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Ea=["disabled"],Pa={class:"min-w-0 flex-1"},Aa={class:"theme-heading truncate text-sm font-medium"},Ra={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Da={class:"theme-divider border-b px-4 py-3"},Ta={class:"grid grid-cols-2 gap-2"},La=["disabled"],Ba={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Fa={key:0},Na={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Oa={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Ua=["disabled"],Ha=["disabled"],za=["disabled"],Ka=["disabled"],qa=3e3,Za={__name:"CodexSessionManagerDialog",props:{open:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]},workspaces:{type:Array,default:()=>[]},selectedSessionId:{type:String,default:""},selectionLocked:{type:Boolean,default:!1},selectionLockReason:{type:String,default:""},loading:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},onRefresh:{type:Function,default:null},onCreate:{type:Function,default:null},onUpdate:{type:Function,default:null},onDelete:{type:Function,default:null},onReset:{type:Function,default:null}},emits:["close","project-created","select-session","open-source-browser"],setup(d,{expose:W,emit:j}){const R=new Map;function v(t="",a=""){const y=We(t),C=nt(a);return!y||!C?"":`${y}
|
|
2
2
|
${C}`}function G(t=""){if(!t)return null;const a=R.get(t);return a?a.expiresAt<=Date.now()?(R.delete(t),null):Array.isArray(a.items)?a.items:[]:null}function H(t="",a=[]){t&&R.set(t,{expiresAt:Date.now()+qa,items:Array.isArray(a)?a:[]})}const g=d,w=j,{locale:E,t:r}=Qe(),b=$("edit"),P=$(""),f=Ut({title:"",engine:"codex",agentEngines:[],cwd:"",sessionId:""}),_=$(""),ce=$(!1),Q=$(!1),O=$(!1),B=$(!1),z=$(!1),K=$(!1),X=$(!1),Y=$(!1),{matches:D}=Pt("(max-width: 767px)"),le=$("list"),q=$("basic"),me=$(ft()),se=$([]),J=$(!1);let h=null,x=null,c=null,U=0;const ee=k(()=>je(g.sessions)),S=k(()=>g.sessions.find(t=>t.id===P.value)||null),ke=k(()=>g.sessions.length>0),Ce=k(()=>g.sessions.find(t=>t.id===g.selectedSessionId)||null),xe=k(()=>!!(S.value&&re(S.value.id))),_e=k(()=>{var t;return!((t=S.value)!=null&&t.started)}),ve=k(()=>{var t;return!((t=S.value)!=null&&t.started)}),fe=k(()=>{var t;return!((t=S.value)!=null&&t.started)}),T=k(()=>g.loading||ce.value||Q.value||O.value||B.value),tt=k(()=>String(f.sessionId||"").trim()),Be=k(()=>{var y,C;const t=new Set,a=[];return[f.cwd,(y=S.value)==null?void 0:y.cwd,(C=Ce.value)==null?void 0:C.cwd,...g.workspaces,...g.sessions.map(F=>F.cwd)].forEach(F=>{const L=String(F||"").trim();!L||t.has(L)||(t.add(L),a.push(L))}),a.slice(0,12)}),$e=k(()=>me.value),Fe=k(()=>se.value.map(t=>({...t,updatedAtLabel:t.updatedAt?Pe(t.updatedAt):""}))),oe=k(()=>{const t=nt(f.cwd);return t?g.sessions.filter(a=>{var y;return a.id===((y=S.value)==null?void 0:y.id)?!1:nt(a.cwd)===t}):[]}),be=k(()=>{if(!oe.value.length)return"";const t=oe.value.slice(0,3).map(a=>{const y=a.title||r("projectManager.untitledProject");return E.value==="en-US"?`"${y}"`:`「${y}」`}).join(E.value==="en-US"?", ":"、");return r("projectManager.duplicateDirectory",{labels:t,count:oe.value.length})}),we=k(()=>b.value!=="edit"||_e.value?"":r("projectManager.cwdReadonly")),Z=k(()=>b.value!=="edit"||!S.value||ve.value?"":r("projectManager.engineReadonly")),pe=k(()=>b.value!=="edit"||!S.value||fe.value?"":r("projectManager.sessionIdReadonly")),Ne=k(()=>b.value==="create"?ce.value?r("projectManager.creatingProject"):r("projectManager.createProject"):Q.value?r("projectManager.savingChanges"):r("projectManager.saveChanges")),Me=k(()=>{var t;return b.value==="create"?r("projectManager.newProject"):((t=S.value)==null?void 0:t.title)||r("projectManager.untitledProject")});function Ge(t=""){const a=Date.parse(String(t||""));return Number.isFinite(a)?a:0}function re(t){var a;return!!((a=g.sessions.find(y=>y.id===t))!=null&&a.running)}function ge(t){return!!t&&t===g.selectedSessionId}function je(t=[]){return[...t].sort((a,y)=>{const C=Number(re(y.id))-Number(re(a.id));if(C)return C;const F=Number(ge(y.id))-Number(ge(a.id));if(F)return F;const L=Ge(y.updatedAt)-Ge(a.updatedAt);return L||Tt(String(a.title||a.cwd||a.id),String(y.title||y.cwd||y.id))})}function Ie(t){return re(t)?r("projectManager.running"):r("projectManager.idle")}function Oe(t){return re(t)?"theme-status-warning":"theme-status-success"}function Ue(t){return t!=null&&t.started?r("projectManager.threadBound"):r("projectManager.notStarted")}function Ee(t){return t!=null&&t.started?"theme-status-success":"theme-status-neutral"}function Pe(t=""){if(!t)return r("projectManager.unknown");const a=new Date(t);return Number.isNaN(a.getTime())?t:Dt(a.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function He(t){f.title=String((t==null?void 0:t.title)||""),f.engine=We(t==null?void 0:t.engine),f.agentEngines=(Array.isArray(t==null?void 0:t.agentBindings)?t.agentBindings:[]).map(a=>We(a==null?void 0:a.engine)).filter(a=>a&&a!==f.engine),f.cwd=String((t==null?void 0:t.cwd)||""),f.sessionId=String((t==null?void 0:t.sessionId)||(t==null?void 0:t.engineSessionId)||(t==null?void 0:t.engineThreadId)||(t==null?void 0:t.codexThreadId)||"").trim()}function Ae(){b.value="create",P.value="",_.value="",f.title="",f.engine="codex",f.agentEngines=[],f.cwd="",f.sessionId=""}function te(t){const a=g.sessions.find(y=>y.id===t);a&&(b.value="edit",P.value=a.id,_.value="",He(a))}function Re(){var t;return g.selectedSessionId&&g.sessions.some(a=>a.id===g.selectedSessionId)?g.selectedSessionId:((t=ee.value[0])==null?void 0:t.id)||""}function De(t="basic"){le.value="detail",q.value=t}function ze(){le.value="list",q.value="basic"}function Xe(){Ae(),D.value&&De("basic")}function Ye(t){T.value||(te(t),D.value&&De("basic"))}function Je(t){f.cwd=String(t||"").trim()}async function Ke(){var a,y;const t=((a=S.value)==null?void 0:a.id)||Re();return!t||((!S.value||S.value.id!==t)&&(te(t),await he()),!((y=S.value)!=null&&y.cwd))?!1:(D.value&&De("basic"),w("open-source-browser",S.value),w("close"),!0)}function e(){return z.value?(z.value=!1,!0):K.value?(K.value=!1,!0):X.value?(X.value=!1,!0):g.open?(w("close"),!0):!1}function l(t){f.title=String(t||"")}function s(t){f.engine=We(t),f.agentEngines=f.agentEngines.filter(a=>a!==f.engine)}function o(t){f.agentEngines=[...new Set((Array.isArray(t)?t:[]).map(a=>We(a)).filter(a=>a&&a!==f.engine))]}function A(t){f.cwd=String(t||"")}function V(t){f.sessionId=String(t||"")}function ne(t){f.sessionId=String((t==null?void 0:t.id)||"").trim()}function ae(){_.value="",z.value=!1,K.value=!1,Y.value=!1,q.value="basic",le.value=D.value?"list":"detail";const t=Re();if(t){te(t);return}Ae()}async function de(){if(!(T.value||typeof g.onRefresh!="function")){_.value="";try{await Promise.all([g.onRefresh(),qe()])}catch(t){_.value=t.message}}}async function qe(){try{me.value=await At()}catch{me.value=ft()}}function Te(){x&&(clearTimeout(x),x=null)}function Ve(){c&&(c.abort(),c=null)}async function bt(){const t=String(f.cwd||"").trim();if(!g.open||!fe.value||!t){se.value=[],J.value=!1,Ve();return}const a=++U;Ve();const y=v(f.engine,t),C=G(y);if(C){se.value=C,J.value=!1;return}c=new AbortController,J.value=!0;try{const F=await Rt({engine:f.engine,cwd:t,limit:50,signal:c.signal});if(a!==U)return;const L=Array.isArray(F==null?void 0:F.items)?F.items:[];se.value=L,H(y,L)}catch(F){if((F==null?void 0:F.name)==="AbortError")return;a===U&&(se.value=[])}finally{a===U&&(J.value=!1,c=null)}}function ot(t=250){if(Te(),!g.open||!fe.value||!String(f.cwd||"").trim()){se.value=[],J.value=!1,Ve();return}x=setTimeout(()=>{x=null,bt().catch(()=>{})},t)}async function wt(t){var y;if((y=navigator.clipboard)!=null&&y.writeText&&window.isSecureContext){await navigator.clipboard.writeText(t);return}const a=document.createElement("textarea");a.value=t,a.setAttribute("readonly","true"),a.style.position="fixed",a.style.opacity="0",a.style.pointerEvents="none",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}async function rt(){const t=tt.value;if(t)try{await wt(t),Y.value=!0,h&&clearTimeout(h),h=setTimeout(()=>{Y.value=!1,h=null},1800)}catch(a){_.value=(a==null?void 0:a.message)||r("projectManager.copySessionIdFailed")}}async function dt(){if(!T.value){_.value="";try{const t=St();if(!t)return;await kt(t)}catch(t){_.value=t.message}}}function St(){if(b.value==="create"){const a=String(f.cwd||"").trim();return a?{type:"create",cwd:a,payload:{title:f.title,engine:f.engine,agentEngines:[f.engine,...f.agentEngines],cwd:a,sessionId:String(f.sessionId||"").trim()}}:(_.value=r("projectManager.directoryRequired"),null)}if(!S.value)return _.value=r("projectManager.projectMissing"),null;const t={title:f.title,engine:f.engine,agentEngines:[f.engine,...f.agentEngines]};return _e.value&&(t.cwd=f.cwd),fe.value&&(t.sessionId=String(f.sessionId||"").trim()),{type:"update",sessionId:S.value.id,payload:t}}async function kt(t){var a,y;if(t.type==="create"){ce.value=!0;try{const C=await((a=g.onCreate)==null?void 0:a.call(g,t.payload));C!=null&&C.id&&(te(C.id),w("select-session",C.id),await he(),w("project-created",C),w("close"));return}finally{ce.value=!1}}Q.value=!0;try{const C=await((y=g.onUpdate)==null?void 0:y.call(g,t.sessionId,t.payload));C!=null&&C.id&&te(C.id)}finally{Q.value=!1}}async function Ct(){var a,y;if(!S.value||O.value)return;const t=S.value.id;_.value="",O.value=!0;try{const C=await((a=g.onDelete)==null?void 0:a.call(g,t));z.value=!1;const F=g.sessions.filter($t=>$t.id!==t),L=(C==null?void 0:C.selectedSessionId)||((y=je(F)[0])==null?void 0:y.id)||"";w("select-session",L),L?(te(L),D.value&&ze()):(Ae(),D.value&&ze())}catch(C){_.value=C.message}finally{O.value=!1}}async function _t(){var a;if(!S.value||B.value)return;const t=S.value.id;_.value="",B.value=!0;try{const y=await((a=g.onReset)==null?void 0:a.call(g,t));K.value=!1;const C=(y==null?void 0:y.session)||g.sessions.find(F=>F.id===t)||null;C!=null&&C.id&&te(C.id)}catch(y){_.value=y.message}finally{B.value=!1}}return ie(()=>g.open,t=>{if(t){ae(),typeof g.onRefresh=="function"?de().catch(()=>{}):qe().catch(()=>{});return}X.value=!1,z.value=!1,K.value=!1,Y.value=!1,_.value="",Te(),Ve(),se.value=[],J.value=!1},{immediate:!0}),ie(D,t=>{t||(le.value="detail")},{immediate:!0}),ie(()=>g.sessions,()=>{if(!g.open)return;if(b.value==="create"){if(!!(String(f.title||"").trim()||String(f.cwd||"").trim())||!!String(f.sessionId||"").trim())return;const y=Re();y&&te(y);return}if(S.value){He(S.value);return}const t=Re();if(t){te(t);return}Ae()}),ie(()=>[g.open,b.value,f.engine,f.cwd,fe.value].join(`
|
|
3
3
|
`),()=>{ot(250)},{immediate:!0}),ie(()=>{var t;return((t=S.value)==null?void 0:t.id)||""},()=>{ot(0)}),lt(()=>{h&&(clearTimeout(h),h=null),Te(),Ve()}),W({closeTopDialog:e}),(t,a)=>(p(),m(ye,null,[I(pt,{open:K.value,title:i(r)("projectManager.confirmResetTitle"),description:S.value?i(r)("projectManager.confirmResetDescription",{title:S.value.title||i(r)("projectManager.untitledProject")}):"","confirm-text":i(r)("projectManager.confirmReset"),"cancel-text":i(r)("projectManager.keep"),loading:B.value,onCancel:a[0]||(a[0]=y=>K.value=!1),onConfirm:_t},null,8,["open","title","description","confirm-text","cancel-text","loading"]),I(pt,{open:z.value,title:i(r)("projectManager.confirmDeleteTitle"),description:S.value?i(r)("projectManager.confirmDeleteDescription",{title:S.value.title||i(r)("projectManager.untitledProject")}):"","confirm-text":i(r)("projectManager.confirmDelete"),"cancel-text":i(r)("projectManager.keep"),loading:O.value,danger:"",onCancel:a[1]||(a[1]=y=>z.value=!1),onConfirm:Ct},null,8,["open","title","description","confirm-text","cancel-text","loading"]),I(Dn,{open:X.value,"initial-path":f.cwd,suggestions:Be.value,onClose:a[2]||(a[2]=y=>X.value=!1),onSelect:Je},null,8,["open","initial-path","suggestions"]),I(yt,{open:d.open,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-5xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 overflow-hidden","close-disabled":T.value,"close-on-backdrop":!T.value,"close-on-escape":!T.value,onClose:a[12]||(a[12]=y=>w("close"))},{title:Le(()=>[n("div",ra,[I(i(Zt),{class:"h-4 w-4"}),n("span",null,u(i(r)("projectManager.managingTitle")),1)])]),default:Le(()=>{var y,C,F;return[i(D)?(p(),m("div",_a,[le.value==="list"?(p(),m("div",$a,[n("div",Ma,[I(ht,{mobile:"",busy:T.value,"editing-session-id":P.value,"format-updated-at":Pe,"get-runtime-status-class":Oe,"get-runtime-status-label":Ie,"get-thread-status-class":Ee,"get-thread-status-label":Ue,"has-sessions":ke.value,"is-current-session":ge,"is-session-running":re,mode:b.value,sessions:ee.value,onCreate:Xe,onSelect:Ye},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])])])):(p(),m("div",ja,[n("div",Ia,[n("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",disabled:T.value,onClick:ze},[I(i(Jt),{class:"h-4 w-4"}),n("span",null,u(i(r)("projectManager.projectList")),1)],8,Ea),n("div",Pa,[n("div",Aa,u(Me.value),1),b.value==="edit"&&((C=S.value)!=null&&C.cwd)?(p(),m("p",Ra,u(S.value.cwd),1)):M("",!0)])]),n("div",Da,[n("div",Ta,[n("button",{type:"button",class:N(["tool-button px-3 py-2 text-sm",q.value==="basic"?"tool-button-accent-subtle":""]),onClick:a[7]||(a[7]=L=>q.value="basic")},u(i(r)("projectManager.basicInfo")),3),n("button",{type:"button",class:N(["tool-button px-3 py-2 text-sm",q.value==="status"?"tool-button-accent-subtle":""]),disabled:b.value==="create",onClick:a[8]||(a[8]=L=>q.value="status")},u(i(r)("projectManager.status")),11,La)])]),n("div",Ba,[q.value==="basic"?(p(),m("div",Fa,[I(vt,{mobile:"",busy:T.value,"can-edit-engine":b.value!=="edit"||ve.value,"can-edit-cwd":b.value!=="edit"||_e.value,"can-edit-session-id":b.value!=="edit"||fe.value,cwd:f.cwd,"cwd-readonly-message":we.value,"duplicate-cwd-message":be.value,engine:f.engine,"agent-engines":f.agentEngines,"engine-options":$e.value,"engine-readonly-message":Z.value,"session-candidates":Fe.value,"session-candidates-loading":J.value,"session-id":f.sessionId,"session-id-copied":Y.value,"session-id-readonly-message":pe.value,title:f.title,"workspace-suggestions":Be.value,onCopySessionId:rt,onOpenDirectoryPicker:a[9]||(a[9]=L=>X.value=!0),onSelectSessionCandidate:ne,"onUpdate:cwd":A,"onUpdate:engine":s,"onUpdate:agentEngines":o,"onUpdate:sessionId":V,"onUpdate:title":l},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","agent-engines","engine-options","engine-readonly-message","session-candidates","session-candidates-loading","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"]),_.value?(p(),m("p",Na,[I(i(mt),{class:"h-4 w-4"}),n("span",null,u(_.value),1)])):M("",!0),n("div",Oa,[n("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-sm",disabled:T.value,onClick:dt},u(Ne.value),9,Ua),b.value==="edit"&&S.value?(p(),m("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:T.value||!((F=S.value)!=null&&F.cwd),onClick:Ke},u(i(r)("projectManager.viewSource")),9,Ha)):M("",!0),b.value==="edit"&&S.value?(p(),m("button",{key:1,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:T.value||xe.value,onClick:a[10]||(a[10]=L=>K.value=!0)},u(B.value?i(r)("projectManager.resettingSession"):i(r)("projectManager.newSession")),9,za)):M("",!0),b.value==="edit"&&S.value?(p(),m("button",{key:2,type:"button",class:"tool-button tool-button-danger-subtle w-full px-3 py-2 text-sm",disabled:T.value||xe.value,onClick:a[11]||(a[11]=L=>z.value=!0)},u(O.value?i(r)("projectManager.deletingProject"):i(r)("projectManager.deleteProject")),9,Ka)):M("",!0)])])):(p(),ue(oa,{key:1,"active-session":S.value,"format-updated-at":Pe,"get-runtime-status-class":Oe,"get-runtime-status-label":Ie,"get-thread-status-class":Ee,"get-thread-status-label":Ue,"is-current-session":ge,"is-session-running":re},null,8,["active-session"]))])]))])):(p(),m("div",da,[n("aside",ua,[I(ht,{busy:T.value,"editing-session-id":P.value,"format-updated-at":Pe,"get-runtime-status-class":Oe,"get-runtime-status-label":Ie,"get-thread-status-class":Ee,"get-thread-status-label":Ue,"has-sessions":ke.value,"is-current-session":ge,"is-session-running":re,mode:b.value,sessions:ee.value,onCreate:Xe,onSelect:Ye},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])]),n("div",ca,[n("div",fa,[n("div",null,[n("div",pa,[I(i(Qt),{class:"h-4 w-4"}),n("span",null,u(b.value==="create"?i(r)("projectManager.createTitle"):i(r)("projectManager.editTitle")),1)])])]),n("div",ga,[I(vt,{busy:T.value,"can-edit-engine":b.value!=="edit"||ve.value,"can-edit-cwd":b.value!=="edit"||_e.value,"can-edit-session-id":b.value!=="edit"||fe.value,cwd:f.cwd,"cwd-readonly-message":we.value,"duplicate-cwd-message":be.value,engine:f.engine,"agent-engines":f.agentEngines,"engine-options":$e.value,"engine-readonly-message":Z.value,"session-candidates":Fe.value,"session-candidates-loading":J.value,"session-id":f.sessionId,"session-id-copied":Y.value,"session-id-readonly-message":pe.value,title:f.title,"workspace-suggestions":Be.value,onCopySessionId:rt,onOpenDirectoryPicker:a[3]||(a[3]=L=>X.value=!0),onSelectSessionCandidate:ne,"onUpdate:cwd":A,"onUpdate:engine":s,"onUpdate:agentEngines":o,"onUpdate:sessionId":V,"onUpdate:title":l},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","agent-engines","engine-options","engine-readonly-message","session-candidates","session-candidates-loading","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"])]),_.value?(p(),m("p",ma,[I(i(mt),{class:"h-4 w-4"}),n("span",null,u(_.value),1)])):M("",!0),n("div",va,[n("div",ha,[b.value==="edit"&&S.value?(p(),m("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||!((y=S.value)!=null&&y.cwd),onClick:Ke},[I(i(Gt),{class:"h-4 w-4"}),n("span",null,u(i(r)("projectManager.viewSource")),1)],8,ya)):M("",!0),b.value==="edit"&&S.value?(p(),m("button",{key:1,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||xe.value,onClick:a[4]||(a[4]=L=>K.value=!0)},[I(i(Xt),{class:"h-4 w-4"}),n("span",null,u(B.value?i(r)("projectManager.resettingSession"):i(r)("projectManager.newSession")),1)],8,xa)):M("",!0),b.value==="edit"&&S.value?(p(),m("button",{key:2,type:"button",class:"tool-button tool-button-danger-subtle inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||xe.value,onClick:a[5]||(a[5]=L=>z.value=!0)},[I(i(Yt),{class:"h-4 w-4"}),n("span",null,u(O.value?i(r)("projectManager.deletingProject"):i(r)("projectManager.deleteProject")),1)],8,ba)):M("",!0)]),n("div",wa,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:a[6]||(a[6]=L=>w("close"))},u(i(r)("projectManager.close")),9,Sa),b.value==="create"&&ke.value?(p(),m("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:ae},u(i(r)("projectManager.backToList")),9,ka)):M("",!0),n("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:dt},u(Ne.value),9,Ca)])])])]))]}),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"])],64))}};export{Za as default};
|