@muyichengshayu/promptx 0.1.3 → 0.1.5
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/apps/server/src/codex.js +3 -0
- package/apps/server/src/codexRuns.js +51 -4
- package/apps/server/src/db.js +6 -0
- package/apps/server/src/gitDiff.js +2 -0
- package/apps/server/src/index.js +9 -7
- package/apps/web/dist/assets/CodexSessionManagerDialog-BOpeBi6M.js +6 -0
- package/apps/web/dist/assets/{TaskDiffReviewDialog-Twev0IGz.js → TaskDiffReviewDialog-Ae6hSwBS.js} +1 -1
- package/apps/web/dist/assets/{WorkbenchSettingsDialog-r5bqLsmQ.js → WorkbenchSettingsDialog-BbYYkqdm.js} +1 -1
- package/apps/web/dist/assets/WorkbenchView-CxQdxLrh.js +216 -0
- package/apps/web/dist/assets/{index-CJNRF_I8.js → index-AK0zYNQo.js} +1 -1
- package/apps/web/dist/assets/index-BtGLsYNA.css +1 -0
- package/apps/web/dist/index.html +2 -2
- package/bin/promptx.js +1 -0
- package/package.json +1 -1
- package/scripts/doctor.mjs +3 -0
- package/scripts/service.mjs +1 -0
- package/apps/web/dist/assets/CodexSessionManagerDialog-BpDNRA83.js +0 -6
- package/apps/web/dist/assets/WorkbenchView-361Ud4iT.js +0 -216
- package/apps/web/dist/assets/index-DDNrspNi.css +0 -1
package/apps/server/src/codex.js
CHANGED
|
@@ -49,6 +49,7 @@ function resolveCodexBinary() {
|
|
|
49
49
|
const output = execFileSync('where.exe', [CODEX_BIN], {
|
|
50
50
|
encoding: 'utf8',
|
|
51
51
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
52
|
+
windowsHide: true,
|
|
52
53
|
}).trim()
|
|
53
54
|
|
|
54
55
|
if (!output) {
|
|
@@ -73,6 +74,7 @@ function createCodexSpawn(commandArgs = [], cwd = '') {
|
|
|
73
74
|
const options = {
|
|
74
75
|
env: process.env,
|
|
75
76
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
77
|
+
windowsHide: true,
|
|
76
78
|
}
|
|
77
79
|
const normalizedCwd = String(cwd || '').trim()
|
|
78
80
|
|
|
@@ -570,6 +572,7 @@ export function streamPromptToCodexSession(sessionInput, prompt, callbacks = {})
|
|
|
570
572
|
try {
|
|
571
573
|
execFileSync('taskkill.exe', ['/PID', String(child.pid), '/T', '/F'], {
|
|
572
574
|
stdio: 'ignore',
|
|
575
|
+
windowsHide: true,
|
|
573
576
|
})
|
|
574
577
|
return
|
|
575
578
|
} catch {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { nanoid } from 'nanoid'
|
|
2
|
+
import { BLOCK_TYPES, clampText } from '../../../packages/shared/src/index.js'
|
|
2
3
|
import { all, get, run, transaction } from './db.js'
|
|
3
4
|
import { getPromptxCodexSessionById } from './codexSessions.js'
|
|
4
5
|
import { captureRunGitBaseline, captureRunGitFinalSnapshot, captureTaskGitBaseline } from './gitDiff.js'
|
|
@@ -18,6 +19,48 @@ function parseEventPayload(rawValue = '{}') {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
function parsePromptBlocks(rawValue = '[]') {
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(rawValue || '[]')
|
|
25
|
+
return Array.isArray(parsed) ? parsed.filter(Boolean) : []
|
|
26
|
+
} catch {
|
|
27
|
+
return []
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function normalizePromptBlock(block = {}) {
|
|
32
|
+
const type =
|
|
33
|
+
block.type === BLOCK_TYPES.IMAGE
|
|
34
|
+
? BLOCK_TYPES.IMAGE
|
|
35
|
+
: block.type === BLOCK_TYPES.IMPORTED_TEXT
|
|
36
|
+
? BLOCK_TYPES.IMPORTED_TEXT
|
|
37
|
+
: BLOCK_TYPES.TEXT
|
|
38
|
+
|
|
39
|
+
const content = clampText(
|
|
40
|
+
String(block.content || ''),
|
|
41
|
+
type === BLOCK_TYPES.IMAGE ? 1000 : 50000
|
|
42
|
+
)
|
|
43
|
+
const meta =
|
|
44
|
+
type === BLOCK_TYPES.IMPORTED_TEXT
|
|
45
|
+
? {
|
|
46
|
+
fileName: clampText(block.meta?.fileName || '', 180),
|
|
47
|
+
collapsed: Boolean(block.meta?.collapsed),
|
|
48
|
+
}
|
|
49
|
+
: {}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
type,
|
|
53
|
+
content,
|
|
54
|
+
meta,
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function normalizePromptBlocks(blocks = []) {
|
|
59
|
+
return Array.isArray(blocks)
|
|
60
|
+
? blocks.map((block) => normalizePromptBlock(block)).filter(Boolean)
|
|
61
|
+
: []
|
|
62
|
+
}
|
|
63
|
+
|
|
21
64
|
function toCodexRunEvent(row) {
|
|
22
65
|
return {
|
|
23
66
|
id: Number(row.id),
|
|
@@ -38,6 +81,7 @@ function toCodexRun(row, events = []) {
|
|
|
38
81
|
taskSlug: row.task_slug,
|
|
39
82
|
sessionId: row.session_id,
|
|
40
83
|
prompt: row.prompt || '',
|
|
84
|
+
promptBlocks: parsePromptBlocks(row.prompt_blocks_json),
|
|
41
85
|
status: row.status || 'running',
|
|
42
86
|
responseMessage: row.response_message || '',
|
|
43
87
|
errorMessage: row.error_message || '',
|
|
@@ -100,7 +144,7 @@ function getRunRowById(runId) {
|
|
|
100
144
|
}
|
|
101
145
|
|
|
102
146
|
return get(
|
|
103
|
-
`SELECT id, task_slug, session_id, prompt, status, response_message, error_message, created_at, updated_at, started_at, finished_at
|
|
147
|
+
`SELECT id, task_slug, session_id, prompt, prompt_blocks_json, status, response_message, error_message, created_at, updated_at, started_at, finished_at
|
|
104
148
|
FROM codex_runs
|
|
105
149
|
WHERE id = ?`,
|
|
106
150
|
[targetId]
|
|
@@ -208,6 +252,7 @@ export function listTaskCodexRunsWithOptions(taskSlug, options = {}) {
|
|
|
208
252
|
runs.task_slug,
|
|
209
253
|
runs.session_id,
|
|
210
254
|
runs.prompt,
|
|
255
|
+
runs.prompt_blocks_json,
|
|
211
256
|
runs.status,
|
|
212
257
|
runs.response_message,
|
|
213
258
|
runs.error_message,
|
|
@@ -227,6 +272,7 @@ export function listTaskCodexRunsWithOptions(taskSlug, options = {}) {
|
|
|
227
272
|
runs.task_slug,
|
|
228
273
|
runs.session_id,
|
|
229
274
|
runs.prompt,
|
|
275
|
+
runs.prompt_blocks_json,
|
|
230
276
|
runs.status,
|
|
231
277
|
runs.response_message,
|
|
232
278
|
runs.error_message,
|
|
@@ -271,6 +317,7 @@ export function createCodexRun(input = {}) {
|
|
|
271
317
|
const taskSlug = String(input.taskSlug || '').trim()
|
|
272
318
|
const sessionId = String(input.sessionId || '').trim()
|
|
273
319
|
const prompt = String(input.prompt || '').trim()
|
|
320
|
+
const promptBlocks = normalizePromptBlocks(input.promptBlocks)
|
|
274
321
|
|
|
275
322
|
if (!taskSlug) {
|
|
276
323
|
throw new Error('缺少任务。')
|
|
@@ -298,11 +345,11 @@ export function createCodexRun(input = {}) {
|
|
|
298
345
|
transaction(() => {
|
|
299
346
|
run(
|
|
300
347
|
`INSERT INTO codex_runs (
|
|
301
|
-
id, task_slug, session_id, prompt, status,
|
|
348
|
+
id, task_slug, session_id, prompt, prompt_blocks_json, status,
|
|
302
349
|
response_message, error_message, created_at, updated_at, started_at, finished_at
|
|
303
350
|
)
|
|
304
|
-
VALUES (?, ?, ?, ?, 'running', '', '', ?, ?, ?, NULL)`,
|
|
305
|
-
[runId, task.slug, session.id, prompt, now, now, now]
|
|
351
|
+
VALUES (?, ?, ?, ?, ?, 'running', '', '', ?, ?, ?, NULL)`,
|
|
352
|
+
[runId, task.slug, session.id, prompt, JSON.stringify(promptBlocks), now, now, now]
|
|
306
353
|
)
|
|
307
354
|
})
|
|
308
355
|
|
package/apps/server/src/db.js
CHANGED
|
@@ -206,6 +206,7 @@ function migrateToV1() {
|
|
|
206
206
|
task_slug TEXT NOT NULL,
|
|
207
207
|
session_id TEXT NOT NULL,
|
|
208
208
|
prompt TEXT NOT NULL DEFAULT '',
|
|
209
|
+
prompt_blocks_json TEXT NOT NULL DEFAULT '[]',
|
|
209
210
|
status TEXT NOT NULL,
|
|
210
211
|
response_message TEXT NOT NULL DEFAULT '',
|
|
211
212
|
error_message TEXT NOT NULL DEFAULT '',
|
|
@@ -295,11 +296,14 @@ function migrateToV1() {
|
|
|
295
296
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_run_git_final_snapshot_entries_scope_path
|
|
296
297
|
ON run_git_final_snapshot_entries(run_id, path);
|
|
297
298
|
`)
|
|
299
|
+
}
|
|
298
300
|
|
|
301
|
+
function applyAdditiveSchemaPatches() {
|
|
299
302
|
const alterStatements = [
|
|
300
303
|
`ALTER TABLE tasks ADD COLUMN auto_title TEXT NOT NULL DEFAULT ''`,
|
|
301
304
|
`ALTER TABLE tasks ADD COLUMN last_prompt_preview TEXT NOT NULL DEFAULT ''`,
|
|
302
305
|
`ALTER TABLE tasks ADD COLUMN codex_session_id TEXT NOT NULL DEFAULT ''`,
|
|
306
|
+
`ALTER TABLE codex_runs ADD COLUMN prompt_blocks_json TEXT NOT NULL DEFAULT '[]'`,
|
|
303
307
|
`ALTER TABLE task_git_baselines ADD COLUMN branch_label TEXT NOT NULL DEFAULT ''`,
|
|
304
308
|
`ALTER TABLE run_git_baselines ADD COLUMN branch_label TEXT NOT NULL DEFAULT ''`,
|
|
305
309
|
`ALTER TABLE codex_run_events ADD COLUMN event_type TEXT NOT NULL DEFAULT 'event'`,
|
|
@@ -329,6 +333,8 @@ function ensureSchema() {
|
|
|
329
333
|
writeSchemaVersion(1)
|
|
330
334
|
}
|
|
331
335
|
|
|
336
|
+
applyAdditiveSchemaPatches()
|
|
337
|
+
|
|
332
338
|
if (readSchemaVersion() < SCHEMA_VERSION) {
|
|
333
339
|
writeSchemaVersion(SCHEMA_VERSION)
|
|
334
340
|
}
|
|
@@ -58,6 +58,7 @@ function runGit(repoRoot = '', args = [], options = {}) {
|
|
|
58
58
|
const result = spawnSync('git', ['-C', repoRoot, ...args], {
|
|
59
59
|
encoding: 'utf8',
|
|
60
60
|
maxBuffer: 8 * 1024 * 1024,
|
|
61
|
+
windowsHide: true,
|
|
61
62
|
...options,
|
|
62
63
|
})
|
|
63
64
|
|
|
@@ -72,6 +73,7 @@ function runGitBuffer(repoRoot = '', args = [], options = {}) {
|
|
|
72
73
|
const result = spawnSync('git', ['-C', repoRoot, ...args], {
|
|
73
74
|
encoding: 'buffer',
|
|
74
75
|
maxBuffer: 8 * 1024 * 1024,
|
|
76
|
+
windowsHide: true,
|
|
75
77
|
...options,
|
|
76
78
|
})
|
|
77
79
|
|
package/apps/server/src/index.js
CHANGED
|
@@ -522,8 +522,9 @@ app.post('/api/tasks/:slug/codex-runs', async (request, reply) => {
|
|
|
522
522
|
return reply.code(404).send({ message: '任务不存在。' })
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
-
const sessionId = String(request.body?.sessionId || '').trim()
|
|
526
|
-
const prompt = String(request.body?.prompt || '').trim()
|
|
525
|
+
const sessionId = String(request.body?.sessionId || '').trim()
|
|
526
|
+
const prompt = String(request.body?.prompt || '').trim()
|
|
527
|
+
const promptBlocks = Array.isArray(request.body?.promptBlocks) ? request.body.promptBlocks : []
|
|
527
528
|
|
|
528
529
|
if (!sessionId) {
|
|
529
530
|
return reply.code(400).send({ message: '请先选择一个 PromptX 项目。' })
|
|
@@ -542,11 +543,12 @@ app.post('/api/tasks/:slug/codex-runs', async (request, reply) => {
|
|
|
542
543
|
return reply.code(409).send({ message: '当前项目正在执行中,请等待完成后再发送。' })
|
|
543
544
|
}
|
|
544
545
|
|
|
545
|
-
const runRecord = createCodexRun({
|
|
546
|
-
taskSlug: request.params.slug,
|
|
547
|
-
sessionId,
|
|
548
|
-
prompt,
|
|
549
|
-
|
|
546
|
+
const runRecord = createCodexRun({
|
|
547
|
+
taskSlug: request.params.slug,
|
|
548
|
+
sessionId,
|
|
549
|
+
prompt,
|
|
550
|
+
promptBlocks,
|
|
551
|
+
})
|
|
550
552
|
|
|
551
553
|
updateTaskCodexSession(request.params.slug, sessionId)
|
|
552
554
|
codexRunRuntime.start(runRecord)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{w as re,o as Re,a as d,c as de,b as u,d as e,e as b,u as k,t as g,G as Be,I as Ne,n as P,F as ue,m as be,f as T,l as ze,g as $e,T as Me,p as $,q as D,A as De,v as Ee}from"./index-AK0zYNQo.js";import{c as Ae,f as oe,X as Ie,S as Ce,L as ke,j as je,d as He,s as Ue,k as _e,P as Oe,b as Ve,m as qe,B as We,n as Ke,e as Pe,T as Xe,A as Ge}from"./WorkbenchView-CxQdxLrh.js";/**
|
|
2
|
+
* @license lucide-vue-next v0.577.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Qe=Ae("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),Je={class:"panel flex h-full w-full max-w-4xl flex-col overflow-hidden sm:h-auto sm:max-h-[86vh]"},Ye={class:"theme-divider flex items-start justify-between gap-3 border-b px-4 py-3 sm:px-5 sm:py-4"},Ze={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},et=["disabled"],tt={class:"flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:px-5"},st={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},nt={class:"flex items-start gap-2 text-xs leading-5"},at={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},lt={class:"theme-muted-text mt-4 block text-xs"},it={class:"mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2",style:{borderColor:"var(--theme-inputBorder)",background:"var(--theme-inputBg)",color:"var(--theme-textPrimary)","--tw-ring-color":"var(--theme-focusRing)"}},ot={class:"mt-4 flex items-center gap-1.5"},rt={class:"mt-3 min-h-0 flex-1 overflow-y-auto rounded-sm border border-dashed border-[var(--theme-borderDefault)] bg-[var(--theme-appPanelStrong)] p-2"},dt={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},ut={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},ct={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},mt={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},vt={key:4,class:"theme-empty-state px-3 py-8 text-sm"},ft={key:5,class:"theme-empty-state px-3 py-8 text-sm"},pt={key:6,class:"theme-empty-state px-3 py-8 text-sm"},ht={key:7,class:"space-y-1"},xt=["onClick"],gt={class:"min-w-0 flex-1"},yt=["innerHTML"],bt=["innerHTML"],wt={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},St={key:8,class:"space-y-1"},kt={class:"flex items-start gap-1.5"},$t=["onClick"],Ct=["onClick"],_t={class:"min-w-0 flex-1"},Pt={key:0,class:"theme-muted-text truncate font-mono text-[10px]"},Lt={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"},Tt={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},Rt=["disabled"],Mt=["disabled"],Dt={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""}},emits:["close","select"],setup(i,{emit:U}){const o=i,C=U,c=$(""),h=$(null),p=$(!1),f=$(""),y=$(!1),x=$(""),R=$([]),F=$(!1),L=$(""),w=$("tree"),I=$(""),z=$("");let B=null,S=0;const Q=D(()=>ee(h.value?[h.value]:[])),we=D(()=>w.value==="search"&&!L.value.trim()),J=D(()=>w.value==="search"&&!!L.value.trim()&&!y.value&&!x.value&&!R.value.length),_=D(()=>w.value==="tree"&&!p.value&&!f.value&&!Q.value.length);function Y(s=""){const l=String(s||"").trim();return/^[a-z]:[\\/]/i.test(l)||l.includes("\\")}function M(s=""){const l=String(s||"").trim();if(!l)return"";const n=Y(l);let r=l.replace(/\\/g,"/");return r.length>1&&!/^[a-z]:\/?$/i.test(r)&&r!=="/"&&(r=r.replace(/\/+$/,"")),n?r.toLowerCase():r}function Z(s="",l=""){const n=M(s),r=M(l);return!n||!r?!1:n===r||n.startsWith(`${r}/`)}function ce(s="",l=""){const n=String(s||"").trim(),r=String(l||"").trim();return n?r?Y(n)?/^[a-z]:\\?$/i.test(n)?`${n.replace(/[\\/]+$/,"")}\\${r}`:`${n.replace(/[\\/]+$/,"")}\\${r}`:n==="/"?`/${r}`:`${n.replace(/\/+$/,"")}/${r}`:n:r}function me(s="",l=""){const n=M(s),r=M(l);if(!n||!r||!Z(r,n))return[];const N=r===n?"":r.slice(n.length).replace(/^\//,"");return N?N.split("/").filter(Boolean):[]}function ae(s){return(s==null?void 0:s.name)||(s==null?void 0:s.path)||"未命名目录"}function ve(s=""){const l=String(s||"").trim();return l?l.split(/[\\/]/).filter(Boolean).at(-1)||l:"Home"}function K(s=""){return String(s||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function A(s="",l=""){const n=String(s||""),r=String(l||"").trim().toLowerCase();if(!n||!r)return null;const N=n.toLowerCase(),q=N.indexOf(r);if(q>=0)return{start:q,end:q+r.length};const t=r.split(/[\\/\s_.-]+/).filter(Boolean).sort((a,v)=>v.length-a.length);for(const a of t){if(a.length<2)continue;const v=N.indexOf(a);if(v>=0)return{start:v,end:v+a.length}}return null}function O(s="",l=""){const n=String(s||""),r=A(n,l);return r?`${K(n.slice(0,r.start))}<mark class="rounded bg-[var(--theme-warningSoft)] px-0.5 text-inherit">${K(n.slice(r.start,r.end))}</mark>${K(n.slice(r.end))}`:K(n)}function fe(s){return O(ae(s),L.value)}function le(s){return O((s==null?void 0:s.path)||"",L.value)}function X(s,l=0){return{...s,depth:l,expanded:!1,loaded:!1,loading:!1,children:[]}}function ee(s=[],l=[]){return s.forEach(n=>{l.push(n),n.expanded&&n.children.length&&ee(n.children,l)}),l}function j(){h.value&&(h.value={...h.value})}function te(s,l=h.value?[h.value]:[]){const n=M(s);if(!n)return null;for(const r of l){if(M(r.path)===n)return r;if(r.children.length){const N=te(s,r.children);if(N)return N}}return null}function V(s){I.value=String((s==null?void 0:s.path)||"").trim(),z.value=ae(s)}async function G(s,l={}){if(!(!s||s.loading)&&!(s.loaded&&!l.force)){s.loading=!0,f.value="",j();try{const n=await _e({path:s.path,limit:240});s.children=(n.items||[]).map(r=>X(r,s.depth+1)),s.loaded=!0}catch(n){f.value=n.message||"目录加载失败。"}finally{s.loading=!1,j()}}}async function H(){p.value=!0,f.value="";try{const s=await _e({limit:240});c.value=String(s.path||""),h.value=X({name:ve(s.path||""),path:String(s.path||""),type:"directory",hasChildren:!0,isHomeRoot:!0},0),h.value.children=(s.items||[]).map(l=>X(l,1)),h.value.loaded=!0,h.value.expanded=!0,V(h.value)}catch(s){f.value=s.message||"目录树加载失败。",h.value=null,c.value=""}finally{p.value=!1}}async function se(s=""){const l=String(s||"").trim();if(!l||!c.value||!Z(l,c.value))return;let n=h.value;if(!n)return;V(n);const r=me(c.value,l);for(const N of r){await G(n),n.expanded=!0,j();const q=te(ce(n.path,N),n.children);if(!q)break;n=q,V(n)}}async function pe(){L.value="",w.value="tree",R.value=[],x.value="",F.value=!1,I.value="",z.value="",await H();const s=String(o.initialPath||"").trim();s&&Z(s,c.value)&&await se(s)}async function ie(s){if(s!=null&&s.path&&(V(s),!!s.hasChildren)){if(!s.loaded){s.expanded=!0,j(),await G(s);return}s.expanded=!s.expanded,j()}}function he(s){s!=null&&s.path&&(V(s),w.value="tree")}async function xe(){const s=String(L.value||"").trim();S+=1;const l=S;if(!o.open||!s||!c.value){y.value=!1,x.value="",R.value=[],F.value=!1;return}y.value=!0,x.value="";try{const n=await Ue(s,{path:c.value,limit:80});if(l!==S)return;R.value=Array.isArray(n.items)?n.items:[],F.value=!!n.truncated}catch(n){if(l!==S)return;x.value=n.message||"搜索失败。",R.value=[],F.value=!1}finally{l===S&&(y.value=!1)}}function Se(){if(B&&(window.clearTimeout(B),B=null),!String(L.value||"").trim()){y.value=!1,x.value="",R.value=[],F.value=!1;return}y.value=!0,x.value="",B=window.setTimeout(()=>{xe()},120)}async function ge(s){s!=null&&s.path&&(w.value="tree",await se(s.path))}function ye(){I.value&&(C("select",I.value),C("close"))}function ne(s){o.open&&s.key==="Escape"&&C("close")}return re(L,()=>{w.value=L.value.trim()?"search":"tree",Se()}),re(()=>o.open,s=>{if(document.body.classList.toggle("overflow-hidden",s),s){window.addEventListener("keydown",ne),pe().catch(()=>{});return}window.removeEventListener("keydown",ne),B&&(window.clearTimeout(B),B=null)}),Re(()=>{document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",ne),B&&window.clearTimeout(B)}),(s,l)=>(d(),de(Me,{to:"body"},[i.open?(d(),u("div",{key:0,class:"fixed inset-0 z-[60] flex items-end justify-center bg-black/45 px-0 py-0 backdrop-blur-sm sm:items-center sm:px-4 sm:py-6",onClick:l[5]||(l[5]=$e(n=>!(p.value||y.value)&&C("close"),["self"]))},[e("section",Je,[e("div",Ye,[e("div",null,[e("div",Ze,[b(k(oe),{class:"h-4 w-4"}),l[6]||(l[6]=e("span",null,"选择工作目录",-1))]),l[7]||(l[7]=e("p",{class:"theme-muted-text mt-1 text-xs leading-5"}," 默认只在当前用户目录下浏览和搜索;特殊路径继续用手动输入。 ",-1))]),e("button",{type:"button",class:"theme-icon-button h-9 w-9",disabled:p.value||y.value,onClick:l[0]||(l[0]=n=>C("close"))},[b(k(Ie),{class:"h-4 w-4"})],8,et)]),e("div",tt,[e("div",st,[e("div",nt,[l[8]||(l[8]=e("span",{class:"theme-muted-text shrink-0"},"当前选中",-1)),e("span",at,g(I.value||"请在目录树或搜索结果里选择目录"),1)])]),e("label",lt,[l[9]||(l[9]=e("span",null,"搜索目录",-1)),e("div",it,[b(k(Ce),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),Be(e("input",{"onUpdate:modelValue":l[1]||(l[1]=n=>L.value=n),type:"text",placeholder:"输入目录名或路径片段,例如 promptx / code",class:"min-w-0 flex-1 border-0 bg-transparent px-0 text-sm text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]"},null,512),[[Ne,L.value]])])]),e("div",ot,[e("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",w.value==="search"?"tool-button-primary":"theme-filter-idle border-dashed"]),onClick:l[2]||(l[2]=n=>w.value="search")},[b(k(Ce),{class:"h-3.5 w-3.5"}),l[10]||(l[10]=e("span",null,"搜索",-1))],2),e("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",w.value==="tree"?"tool-button-primary":"theme-filter-idle border-dashed"]),onClick:l[3]||(l[3]=n=>w.value="tree")},[b(k(oe),{class:"h-3.5 w-3.5"}),l[11]||(l[11]=e("span",null,"目录树",-1))],2)]),e("div",rt,[w.value==="search"&&x.value?(d(),u("div",dt,g(x.value),1)):w.value==="tree"&&f.value?(d(),u("div",ut,g(f.value),1)):w.value==="search"&&y.value?(d(),u("div",ct,[b(k(ke),{class:"h-4 w-4 animate-spin"}),l[12]||(l[12]=e("span",null,"搜索中...",-1))])):w.value==="tree"&&p.value?(d(),u("div",mt,[b(k(ke),{class:"h-4 w-4 animate-spin"}),l[13]||(l[13]=e("span",null,"目录树加载中...",-1))])):we.value?(d(),u("div",vt," 输入关键词后,只会在当前用户目录下搜索。 ")):J.value?(d(),u("div",ft," 没搜到匹配目录,试试更短的关键词,或者直接用目录树浏览。 ")):_.value?(d(),u("div",pt," 当前没有可显示的目录。 ")):w.value==="search"?(d(),u("div",ht,[(d(!0),u(ue,null,be(R.value,n=>(d(),u("button",{key:n.path,type:"button",class:P(["flex w-full items-start gap-2 rounded-sm border border-transparent px-2.5 py-1.5 text-left transition",M(I.value)===M(n.path)?"bg-[var(--theme-appPanelInset)]":"hover:bg-[var(--theme-appPanelMuted)]"]),onClick:r=>ge(n)},[b(k(oe),{class:"theme-muted-text mt-0.5 h-4 w-4 shrink-0"}),e("div",gt,[e("div",null,[e("span",{class:"truncate text-[13px] text-[var(--theme-textPrimary)]",innerHTML:fe(n)},null,8,yt)]),e("div",{class:"theme-muted-text truncate font-mono text-[10px]",innerHTML:le(n)},null,8,bt)])],10,xt))),128)),F.value?(d(),u("p",wt," 搜索结果已截断,只展示最相关的一部分目录。 ")):T("",!0)])):(d(),u("div",St,[(d(!0),u(ue,null,be(Q.value,n=>(d(),u("div",{key:n.path,class:P(["rounded-sm border border-transparent px-1.5 py-1 transition",M(I.value)===M(n.path)?"bg-[var(--theme-appPanelInset)]":n.expanded?"bg-[var(--theme-appPanelMuted)]":"hover:bg-[var(--theme-appPanelMuted)]"]),style:ze({paddingLeft:`${n.depth*16+6}px`})},[e("div",kt,[e("button",{type:"button",class:P(["theme-icon-button h-5 w-5 shrink-0",n.hasChildren?"":"invisible pointer-events-none"]),onClick:$e(r=>ie(n),["stop"])},[n.loading?(d(),de(k(ke),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(d(),de(k(je),{key:1,class:P(["h-3.5 w-3.5 transition",n.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,$t),e("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:r=>he(n)},[b(k(oe),{class:P(["h-4 w-4 shrink-0",M(I.value)===M(n.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),e("div",_t,[e("div",{class:P(["truncate text-[13px]",n.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},g(ae(n)),3),n.isHomeRoot?(d(),u("div",Pt,g(n.path),1)):T("",!0)])],8,Ct)])],6))),128))]))])]),e("div",Lt,[e("div",Tt,[e("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:p.value||y.value,onClick:l[4]||(l[4]=n=>C("close"))}," 取消 ",8,Rt),e("button",{type:"button",class:"tool-button tool-button-primary inline-flex w-full items-center justify-center gap-2 px-3 py-2 text-xs sm:w-auto",disabled:p.value||y.value||!I.value,onClick:ye},[b(k(He),{class:"h-4 w-4"}),l[14]||(l[14]=e("span",null,"使用当前目录",-1))],8,Mt)])])])])):T("",!0)]))}},It={class:"theme-muted-text block text-xs"},Ft=["value","disabled"],Bt={class:"theme-muted-text block text-xs"},Nt={class:"mt-1 flex gap-2"},zt=["value","disabled"],Et=["disabled"],At={id:"codex-manager-workspace-suggestions"},jt=["value"],Ht={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Ut={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},Le={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},canEditCwd:{type:Boolean,default:!0},cwd:{type:String,default:""},cwdReadonlyMessage:{type:String,default:""},duplicateCwdMessage:{type:String,default:""},mobile:{type:Boolean,default:!1},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["open-directory-picker","update:cwd","update:title"],setup(i,{emit:U}){const o=U;return(C,c)=>(d(),u("div",{class:P(["grid gap-4",i.mobile?"":"sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]"])},[e("label",It,[c[3]||(c[3]=e("span",null,"项目标题(可选)",-1)),e("input",{value:i.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:i.busy,onInput:c[0]||(c[0]=h=>o("update:title",h.target.value))},null,40,Ft)]),e("label",Bt,[c[4]||(c[4]=e("span",null,"工作目录",-1)),e("div",Nt,[e("input",{value:i.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:P(["tool-input min-w-0 flex-1 disabled:cursor-not-allowed disabled:opacity-80",i.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:i.busy||!i.canEditCwd,onInput:c[1]||(c[1]=h=>o("update:cwd",h.target.value))},null,42,zt),e("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:i.busy||!i.canEditCwd,onClick:c[2]||(c[2]=h=>o("open-directory-picker"))},[b(k(oe),{class:"h-4 w-4"}),e("span",null,g(i.mobile?"选择":"选择目录"),1)],8,Et)]),e("datalist",At,[(d(!0),u(ue,null,be(i.workspaceSuggestions,h=>(d(),u("option",{key:h,value:h},null,8,jt))),128))]),i.duplicateCwdMessage?(d(),u("p",Ht,g(i.duplicateCwdMessage),1)):i.cwdReadonlyMessage?(d(),u("p",Ut,g(i.cwdReadonlyMessage),1)):T("",!0)])],2))}},Ot={class:"flex items-center justify-between gap-3"},Vt={key:0,class:"theme-muted-text mt-1 text-xs"},qt=["disabled"],Wt=["onClick"],Kt={key:0,class:"absolute inset-y-3 left-0 w-1 rounded-full bg-[var(--theme-accent)]"},Xt={class:"w-full text-left"},Gt={class:"theme-heading flex flex-wrap items-center gap-2 text-sm font-medium"},Qt={class:"truncate"},Jt={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},Yt={class:"theme-muted-text mt-2 break-all font-mono text-[11px] leading-5"},Zt={key:0,class:"theme-muted-text mt-2 text-[11px]"},Te={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:i=>i},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},hasSessions:{type:Boolean,default:!1},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1},mode:{type:String,default:"edit"},mobile:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]}},emits:["create","select"],setup(i,{emit:U}){const o=i,C=U;function c(f){return o.mode==="edit"&&o.editingSessionId===f.id?"border-[var(--theme-accent)] bg-[var(--theme-accentSoft)] text-[var(--theme-textPrimary)] shadow-md shadow-[color-mix(in_srgb,var(--theme-accent)_18%,transparent)]":o.isSessionRunning(f.id)?"border-[var(--theme-warning)] bg-[var(--theme-appPanelMuted)] text-[var(--theme-textPrimary)] hover:bg-[var(--theme-appPanelHover)]":"border-[var(--theme-borderDefault)] bg-[var(--theme-appPanelStrong)] hover:border-[var(--theme-borderStrong)] hover:bg-[var(--theme-appPanel)]"}function h(f){return o.isCurrentSession(f.id)?"当前":"普通"}function p(f){return o.isCurrentSession(f.id)?"theme-status-info":"theme-status-neutral"}return(f,y)=>(d(),u(ue,null,[e("div",Ot,[e("div",null,[y[1]||(y[1]=e("div",{class:"theme-heading text-sm font-medium"},"项目列表",-1)),i.hasSessions?T("",!0):(d(),u("p",Vt," 还没有项目,先新建一个固定工作目录。 "))]),e("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:i.busy,onClick:y[0]||(y[0]=x=>C("create"))},[b(k(Oe),{class:"h-4 w-4"}),y[2]||(y[2]=e("span",null,"新建",-1))],8,qt)]),e("div",{class:P(["mt-4 space-y-2",i.mobile?"min-h-0 flex-1 overflow-y-auto":"max-h-52 overflow-y-auto pr-1 sm:max-h-64 lg:max-h-[calc(88vh-11rem)]"])},[(d(!0),u(ue,null,be(i.sessions,x=>(d(),u("article",{key:x.id,class:P(["relative cursor-pointer rounded-sm border p-3 transition",c(x)]),onClick:R=>C("select",x.id)},[i.mode==="edit"&&i.editingSessionId===x.id?(d(),u("span",Kt)):T("",!0),e("div",Xt,[e("div",Gt,[e("span",Qt,g(x.title||"未命名项目"),1),e("span",{class:P(["rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",p(x)])},g(h(x)),3),e("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",i.getRuntimeStatusClass(x.id)])},[i.isSessionRunning(x.id)?(d(),u("span",Jt)):T("",!0),De(" "+g(i.getRuntimeStatusLabel(x.id)),1)],2),e("span",{class:P(["rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",i.getThreadStatusClass(x)])},g(i.getThreadStatusLabel(x)),3)]),e("div",Yt,g(x.cwd),1),i.mobile?T("",!0):(d(),u("div",Zt," 最近更新:"+g(i.formatUpdatedAt(x.updatedAt)),1))])],10,Wt))),128))],2)],64))}},es={class:"space-y-3"},ts={class:"dashed-panel px-3 py-3"},ss={class:"mt-2 flex flex-wrap gap-2"},ns={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},as={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},ls={class:"dashed-panel px-3 py-3"},is={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},os={class:"dashed-panel px-3 py-3"},rs={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},ds={class:"dashed-panel px-3 py-3"},us={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},cs={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:i=>i},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1}},setup(i){return(U,o)=>{var C,c,h,p,f,y;return d(),u("div",es,[e("div",ts,[o[0]||(o[0]=e("div",{class:"theme-muted-text text-[11px]"},"运行状态",-1)),e("div",ss,[e("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",i.getRuntimeStatusClass((C=i.activeSession)==null?void 0:C.id)])},[i.isSessionRunning((c=i.activeSession)==null?void 0:c.id)?(d(),u("span",ns)):T("",!0),De(" "+g(i.getRuntimeStatusLabel((h=i.activeSession)==null?void 0:h.id)),1)],2),e("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",i.getThreadStatusClass(i.activeSession)])},g(i.getThreadStatusLabel(i.activeSession)),3),(p=i.activeSession)!=null&&p.id&&i.isCurrentSession(i.activeSession.id)?(d(),u("span",as," 当前项目 ")):T("",!0)])]),e("div",ls,[o[1]||(o[1]=e("div",{class:"theme-muted-text text-[11px]"},"工作目录",-1)),e("div",is,g(((f=i.activeSession)==null?void 0:f.cwd)||"未设置"),1)]),e("div",os,[o[2]||(o[2]=e("div",{class:"theme-muted-text text-[11px]"},"最近更新",-1)),e("div",rs,g(i.formatUpdatedAt((y=i.activeSession)==null?void 0:y.updatedAt)),1)]),e("div",ds,[e("div",us,[b(k(Qe),{class:"h-3.5 w-3.5"}),o[3]||(o[3]=e("span",null,"说明",-1))]),o[4]||(o[4]=e("p",{class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"}," 项目绑定目录,目录不变时会继续复用同一个 Codex 线程。 ",-1))])])}}},ms={class:"panel flex h-full w-full max-w-5xl flex-col overflow-hidden sm:h-auto sm:max-h-[88vh]"},vs={class:"theme-divider flex flex-wrap items-start justify-between gap-3 border-b px-4 py-3 sm:px-5 sm:py-4"},fs={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ps={class:"flex items-center gap-2"},hs=["disabled"],xs={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},gs={class:"theme-divider border-b bg-[var(--theme-appPanelMuted)] px-3 py-3 sm:px-4 sm:py-4 lg:border-b-0 lg:border-r"},ys={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},bs={class:"flex flex-wrap items-start justify-between gap-3"},ws={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Ss={class:"mt-5"},ks={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},$s={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"},Cs={class:"flex flex-wrap items-center gap-2"},_s=["disabled"],Ps={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Ls=["disabled"],Ts=["disabled"],Rs=["disabled"],Ms={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ds={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Is={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},Fs={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Bs={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Ns=["disabled"],zs={class:"min-w-0 flex-1"},Es={class:"theme-heading truncate text-sm font-medium"},As={key:0,class:"theme-muted-text mt-1 truncate text-xs"},js={class:"theme-divider border-b px-4 py-3"},Hs={class:"grid grid-cols-2 gap-2"},Us=["disabled"],Os={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Vs={key:0},qs={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Ws={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Ks=["disabled"],Xs=["disabled"],Js={__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}},emits:["close","select-session"],setup(i,{emit:U}){const o=i,C=U,c=$("edit"),h=$(""),p=Ee({title:"",cwd:""}),f=$(""),y=$(!1),x=$(!1),R=$(!1),F=$(!1),L=$(!1),{matches:w}=Ve("(max-width: 767px)"),I=$("list"),z=$("basic"),B=D(()=>fe(o.sessions)),S=D(()=>o.sessions.find(t=>t.id===h.value)||null),Q=D(()=>o.sessions.length>0),we=D(()=>o.sessions.find(t=>t.id===o.selectedSessionId)||null),J=D(()=>{var t;return!((t=S.value)!=null&&t.started)}),_=D(()=>o.loading||y.value||x.value||R.value),Y=D(()=>{var v,m;const t=new Set,a=[];return[p.cwd,(v=S.value)==null?void 0:v.cwd,(m=we.value)==null?void 0:m.cwd,...o.workspaces,...o.sessions.map(W=>W.cwd)].forEach(W=>{const E=String(W||"").trim();!E||t.has(E)||(t.add(E),a.push(E))}),a.slice(0,12)}),M=D(()=>{const t=K(p.cwd);return t?o.sessions.filter(a=>{var v;return a.id===((v=S.value)==null?void 0:v.id)?!1:K(a.cwd)===t}):[]}),Z=D(()=>{if(!M.value.length)return"";const t=M.value.slice(0,3).map(v=>`「${v.title||"未命名项目"}」`).join("、"),a=M.value.length>3?"等项目":"项目";return`该目录已被${t}${a}使用,建议优先复用,避免把同一目录拆成多个项目。`}),ce=D(()=>c.value!=="edit"||J.value?"":"当前项目已绑定 Codex 线程,工作目录不能再修改;如需使用新目录,请新建项目。"),me=D(()=>c.value==="create"?y.value?"创建中...":"创建项目":x.value?"保存中...":"保存修改"),ae=D(()=>{var t;return c.value==="create"?"新建项目":((t=S.value)==null?void 0:t.title)||"未命名项目"});function ve(t=""){const a=Date.parse(String(t||""));return Number.isFinite(a)?a:0}function K(t=""){const a=String(t||"").trim();if(!a)return"";const v=/^[a-z]:[\\/]/i.test(a)||a.includes("\\");let m=a.replace(/\\/g,"/");return m.length>1&&!/^[a-z]:\/$/i.test(m)&&(m=m.replace(/\/+$/,"")),v?m.toLowerCase():m}function A(t){var a;return!!((a=o.sessions.find(v=>v.id===t))!=null&&a.running)}function O(t){return!!t&&t===o.selectedSessionId}function fe(t=[]){return[...t].sort((a,v)=>{const m=Number(A(v.id))-Number(A(a.id));if(m)return m;const W=Number(O(v.id))-Number(O(a.id));if(W)return W;const E=ve(v.updatedAt)-ve(a.updatedAt);return E||String(a.title||a.cwd||a.id).localeCompare(String(v.title||v.cwd||v.id),"zh-CN")})}function le(t){return A(t)?"运行中":"空闲"}function X(t){return A(t)?"theme-status-warning":"theme-status-success"}function ee(t){return t!=null&&t.started?"已绑定线程":"未启动"}function j(t){return t!=null&&t.started?"theme-status-success":"theme-status-neutral"}function te(t=""){if(!t)return"未知";const a=new Date(t);return Number.isNaN(a.getTime())?t:a.toLocaleString("zh-CN")}function V(t){p.title=String((t==null?void 0:t.title)||""),p.cwd=String((t==null?void 0:t.cwd)||"")}function G(){c.value="create",h.value="",f.value="",p.title="",p.cwd=""}function H(t){const a=o.sessions.find(v=>v.id===t);a&&(c.value="edit",h.value=a.id,f.value="",V(a))}function se(){var t;return o.selectedSessionId&&o.sessions.some(a=>a.id===o.selectedSessionId)?o.selectedSessionId:((t=B.value[0])==null?void 0:t.id)||""}function pe(t="basic"){I.value="detail",z.value=t}function ie(){I.value="list",z.value="basic"}function he(){G(),w.value&&pe("basic")}function xe(t){_.value||(H(t),w.value&&pe("basic"))}function Se(t){p.cwd=String(t||"").trim()}function ge(t){p.title=String(t||"")}function ye(t){p.cwd=String(t||"")}function ne(){f.value="",F.value=!1,z.value="basic",I.value=w.value?"list":"detail";const t=se();if(t){H(t);return}G()}function s(t){!o.open||_.value||t.key==="Escape"&&C("close")}async function l(){if(!(_.value||typeof o.onRefresh!="function")){f.value="";try{await o.onRefresh()}catch(t){f.value=t.message}}}async function n(){if(!_.value){f.value="";try{const t=r();if(!t)return;await N(t)}catch(t){f.value=t.message}}}function r(){if(c.value==="create"){const a=String(p.cwd||"").trim();return a?{type:"create",cwd:a,payload:{title:p.title,cwd:a}}:(f.value="请先填写工作目录。",null)}if(!S.value)return f.value="当前项目不存在,请重新选择。",null;const t={title:p.title};return J.value&&(t.cwd=p.cwd),{type:"update",sessionId:S.value.id,payload:t}}async function N(t){var a,v;if(t.type==="create"){y.value=!0;try{const m=await((a=o.onCreate)==null?void 0:a.call(o,t.payload));m!=null&&m.id&&(H(m.id),C("select-session",m.id));return}finally{y.value=!1}}x.value=!0;try{const m=await((v=o.onUpdate)==null?void 0:v.call(o,t.sessionId,t.payload));m!=null&&m.id&&H(m.id)}finally{x.value=!1}}async function q(){var a,v;if(!S.value||R.value)return;const t=S.value.id;f.value="",R.value=!0;try{const m=await((a=o.onDelete)==null?void 0:a.call(o,t));F.value=!1;const W=o.sessions.filter(Fe=>Fe.id!==t),E=(m==null?void 0:m.selectedSessionId)||((v=fe(W)[0])==null?void 0:v.id)||"";C("select-session",E),E?(H(E),w.value&&ie()):(G(),w.value&&ie())}catch(m){f.value=m.message}finally{R.value=!1}}return re(()=>o.open,t=>{if(document.body.classList.toggle("overflow-hidden",t),t){window.addEventListener("keydown",s),ne(),l().catch(()=>{});return}window.removeEventListener("keydown",s),L.value=!1,F.value=!1,f.value=""},{immediate:!0}),re(w,t=>{t||(I.value="detail")},{immediate:!0}),re(()=>o.sessions,()=>{if(!o.open)return;if(c.value==="create"){if(!!(String(p.title||"").trim()||String(p.cwd||"").trim()))return;const v=se();v&&H(v);return}if(S.value){V(S.value);return}const t=se();if(t){H(t);return}G()}),Re(()=>{document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",s)}),(t,a)=>{var v;return d(),de(Me,{to:"body"},[i.open?(d(),u("div",{key:0,class:"fixed inset-0 z-50 flex items-end justify-center bg-black/45 px-0 py-0 backdrop-blur-sm sm:items-center sm:px-4 sm:py-6",onClick:a[10]||(a[10]=$e(m=>!_.value&&C("close"),["self"]))},[e("section",ms,[b(qe,{open:F.value,title:"确认删除 PromptX 项目?",description:S.value?`将删除「${S.value.title||"未命名项目"}」这条本地记录,不会删除工作目录,也不会删除 Codex 的历史数据。`:"","confirm-text":"确认删除","cancel-text":"先保留",loading:R.value,danger:"",onCancel:a[0]||(a[0]=m=>F.value=!1),onConfirm:q},null,8,["open","description","loading"]),b(Dt,{open:L.value,"initial-path":p.cwd,suggestions:Y.value,onClose:a[1]||(a[1]=m=>L.value=!1),onSelect:Se},null,8,["open","initial-path","suggestions"]),e("div",vs,[e("div",null,[e("div",fs,[b(k(We),{class:"h-4 w-4"}),a[11]||(a[11]=e("span",null,"PromptX 项目管理",-1))])]),e("div",ps,[e("button",{type:"button",class:"theme-icon-button h-9 w-9",disabled:_.value,onClick:a[2]||(a[2]=m=>C("close"))},[b(k(Ie),{class:"h-4 w-4"})],8,hs)])]),k(w)?(d(),u("div",Ms,[I.value==="list"?(d(),u("div",Ds,[e("div",Is,[b(Te,{mobile:"",busy:_.value,"editing-session-id":h.value,"format-updated-at":te,"get-runtime-status-class":X,"get-runtime-status-label":le,"get-thread-status-class":j,"get-thread-status-label":ee,"has-sessions":Q.value,"is-current-session":O,"is-session-running":A,mode:c.value,sessions:B.value,onCreate:he,onSelect:xe},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])])])):(d(),u("div",Fs,[e("div",Bs,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",disabled:_.value,onClick:ie},[b(k(Ge),{class:"h-4 w-4"}),a[12]||(a[12]=e("span",null,"列表",-1))],8,Ns),e("div",zs,[e("div",Es,g(ae.value),1),c.value==="edit"&&((v=S.value)!=null&&v.cwd)?(d(),u("p",As,g(S.value.cwd),1)):T("",!0)])]),e("div",js,[e("div",Hs,[e("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",z.value==="basic"?"tool-button-primary":""]),onClick:a[6]||(a[6]=m=>z.value="basic")}," 基本信息 ",2),e("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",z.value==="status"?"tool-button-primary":""]),disabled:c.value==="create",onClick:a[7]||(a[7]=m=>z.value="status")}," 状态 ",10,Us)])]),e("div",Os,[z.value==="basic"?(d(),u("div",Vs,[b(Le,{mobile:"",busy:_.value,"can-edit-cwd":c.value!=="edit"||J.value,cwd:p.cwd,"cwd-readonly-message":ce.value,"duplicate-cwd-message":Z.value,title:p.title,"workspace-suggestions":Y.value,onOpenDirectoryPicker:a[8]||(a[8]=m=>L.value=!0),"onUpdate:cwd":ye,"onUpdate:title":ge},null,8,["busy","can-edit-cwd","cwd","cwd-readonly-message","duplicate-cwd-message","title","workspace-suggestions"]),f.value?(d(),u("p",qs,[b(k(Pe),{class:"h-4 w-4"}),e("span",null,g(f.value),1)])):T("",!0),e("div",Ws,[e("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-sm",disabled:_.value,onClick:n},g(me.value),9,Ks),c.value==="edit"&&S.value?(d(),u("button",{key:0,type:"button",class:"tool-button theme-danger-text theme-danger-hover w-full px-3 py-2 text-sm",disabled:_.value||i.sending,onClick:a[9]||(a[9]=m=>F.value=!0)},g(R.value?"删除中...":"删除项目"),9,Xs)):T("",!0)])])):(d(),de(cs,{key:1,"active-session":S.value,"format-updated-at":te,"get-runtime-status-class":X,"get-runtime-status-label":le,"get-thread-status-class":j,"get-thread-status-label":ee,"is-current-session":O,"is-session-running":A},null,8,["active-session"]))])]))])):(d(),u("div",xs,[e("aside",gs,[b(Te,{busy:_.value,"editing-session-id":h.value,"format-updated-at":te,"get-runtime-status-class":X,"get-runtime-status-label":le,"get-thread-status-class":j,"get-thread-status-label":ee,"has-sessions":Q.value,"is-current-session":O,"is-session-running":A,mode:c.value,sessions:B.value,onCreate:he,onSelect:xe},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])]),e("div",ys,[e("div",bs,[e("div",null,[e("div",ws,[b(k(Ke),{class:"h-4 w-4"}),e("span",null,g(c.value==="create"?"新建项目":"编辑项目"),1)])])]),e("div",Ss,[b(Le,{busy:_.value,"can-edit-cwd":c.value!=="edit"||J.value,cwd:p.cwd,"cwd-readonly-message":ce.value,"duplicate-cwd-message":Z.value,title:p.title,"workspace-suggestions":Y.value,onOpenDirectoryPicker:a[3]||(a[3]=m=>L.value=!0),"onUpdate:cwd":ye,"onUpdate:title":ge},null,8,["busy","can-edit-cwd","cwd","cwd-readonly-message","duplicate-cwd-message","title","workspace-suggestions"])]),f.value?(d(),u("p",ks,[b(k(Pe),{class:"h-4 w-4"}),e("span",null,g(f.value),1)])):T("",!0),e("div",$s,[e("div",Cs,[c.value==="edit"&&S.value?(d(),u("button",{key:0,type:"button",class:"tool-button theme-danger-text theme-danger-hover inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:_.value||i.sending,onClick:a[4]||(a[4]=m=>F.value=!0)},[b(k(Xe),{class:"h-4 w-4"}),e("span",null,g(R.value?"删除中...":"删除项目"),1)],8,_s)):T("",!0)]),e("div",Ps,[e("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:_.value,onClick:a[5]||(a[5]=m=>C("close"))}," 关闭 ",8,Ls),c.value==="create"&&Q.value?(d(),u("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:_.value,onClick:ne}," 返回列表 ",8,Ts)):T("",!0),e("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-xs sm:w-auto",disabled:_.value,onClick:n},g(me.value),9,Rs)])])])]))])])):T("",!0)])}}};export{Js as default};
|
package/apps/web/dist/assets/{TaskDiffReviewDialog-Twev0IGz.js → TaskDiffReviewDialog-Ae6hSwBS.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as H,q as j,p as C,i as Ue,a as c,b as v,d as a,F as Q,m as ge,n as w,t as h,e as k,u as s,G as Fe,I as qe,f as T,c as Ce,s as we,x as Oe,H as Te,o as We,g as Ke,T as Ge}from"./index-
|
|
1
|
+
import{w as H,q as j,p as C,i as Ue,a as c,b as v,d as a,F as Q,m as ge,n as w,t as h,e as k,u as s,G as Fe,I as qe,f as T,c as Ce,s as we,x as Oe,H as Te,o as We,g as Ke,T as Ge}from"./index-AK0zYNQo.js";import{c as Ve,u as Je,g as Se,l as Qe,S as Xe,C as He,a as Me,b as Ye,d as Ze,_ as et,e as tt,F as Be,f as De,X as st}from"./WorkbenchView-CxQdxLrh.js";/**
|
|
2
2
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as d,d as e,t as c,u as m,F as x,m as b,J as k,q as $,n as S,l as C,c as y,f as w,w as T,o as L,e as g,g as B,T as E,p as _}from"./index-
|
|
1
|
+
import{a as o,b as d,d as e,t as c,u as m,F as x,m as b,J as k,q as $,n as S,l as C,c as y,f as w,w as T,o as L,e as g,g as B,T as E,p as _}from"./index-AK0zYNQo.js";import{d as j,h as D,X as M,i as P}from"./WorkbenchView-CxQdxLrh.js";const N={class:"space-y-4"},V={class:"flex items-center justify-between gap-3"},z={class:"theme-muted-text rounded-sm border border-dashed border-[var(--theme-borderDefault)] bg-[var(--theme-appPanelStrong)] px-2 py-1 text-[11px]"},F={class:"space-y-4"},X={class:"theme-muted-text px-1 text-[10px] font-medium uppercase tracking-[0.16em]"},q=["onClick"],G={class:"flex items-start gap-3"},J={class:"mt-0.5 flex items-center gap-1.5"},K={class:"min-w-0 flex-1"},U={class:"flex items-center justify-between gap-2"},W={class:"truncate text-sm font-medium"},A={class:"theme-muted-text mt-1 text-[11px] leading-5"},H={__name:"ThemeToggle",setup(v){const{currentTheme:u,setTheme:h,themes:r}=k(),l=$(()=>{const i=r.filter(n=>n.mode==="light"),a=r.filter(n=>n.mode==="dark");return[{id:"light",label:"浅色主题",items:i},{id:"dark",label:"深色主题",items:a}].filter(n=>n.items.length)});function p(i){h(i)}return(i,a)=>(o(),d("div",N,[e("div",null,[e("div",V,[a[0]||(a[0]=e("div",{class:"theme-heading text-sm font-medium"},"界面主题",-1)),e("div",z," 当前:"+c(m(u).shortName),1)]),a[1]||(a[1]=e("div",{class:"theme-muted-text mt-1 text-xs leading-5"},"像编辑器一样切换整套配色,而不只是深浅模式。",-1))]),e("div",F,[(o(!0),d(x,null,b(l.value,n=>(o(),d("section",{key:n.id,class:"space-y-1.5"},[e("div",X,c(n.label),1),(o(!0),d(x,null,b(n.items,t=>(o(),d("button",{key:t.id,type:"button",class:S(["theme-option w-full rounded-sm border px-3 py-2 text-left transition",t.id===m(u).id?"theme-option-active":"theme-option-idle"]),onClick:s=>p(t.id)},[e("div",G,[e("div",J,[(o(!0),d(x,null,b(t.swatches,(s,f)=>(o(),d("span",{key:`${t.id}-${f}`,class:"h-3 w-3 rounded-full border border-black/10",style:C({backgroundColor:s})},null,4))),128))]),e("div",K,[e("div",U,[e("span",W,c(t.name),1),t.id===m(u).id?(o(),y(m(j),{key:0,class:"h-4 w-4 shrink-0"})):w("",!0)]),e("div",A,c(t.description),1)])])],10,q))),128))]))),128))])]))}},I={class:"panel flex w-full max-w-xl flex-col overflow-hidden"},O={class:"theme-divider flex items-start justify-between gap-4 border-b px-5 py-4"},Q={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},R={class:"space-y-6 px-5 py-5"},Y={class:"rounded-sm border border-dashed border-[var(--theme-borderDefault)] bg-[var(--theme-appPanelMuted)] px-4 py-4"},Z={class:"rounded-sm border border-dashed border-[var(--theme-borderDefault)] bg-[var(--theme-appPanelMuted)] px-4 py-4"},ee={class:"flex items-center justify-between gap-3"},te={class:"theme-muted-text mt-1 text-xs leading-5"},se={class:"rounded-sm border border-dashed border-[var(--theme-borderStrong)] bg-[var(--theme-appPanelStrong)] px-2.5 py-1 text-xs font-medium text-[var(--theme-textSecondary)]"},ie={__name:"WorkbenchSettingsDialog",props:{open:{type:Boolean,default:!1}},emits:["close"],setup(v,{emit:u}){const h=v,r=u,l=_(""),p=_(!1),i=_("");async function a(){p.value=!0,i.value="";try{const t=await P(),s=String((t==null?void 0:t.version)||"").trim();l.value=s,s||(i.value="当前服务暂未返回版本号,请确认已重启到最新版本。")}catch(t){l.value="",i.value=(t==null?void 0:t.message)||"版本信息读取失败。"}finally{p.value=!1}}function n(t){h.open&&t.key==="Escape"&&r("close")}return T(()=>h.open,t=>{if(document.body.classList.toggle("overflow-hidden",t),t){window.addEventListener("keydown",n),a();return}window.removeEventListener("keydown",n)},{immediate:!0}),L(()=>{document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",n)}),(t,s)=>(o(),y(E,{to:"body"},[v.open?(o(),d("div",{key:0,class:"fixed inset-0 z-[70] flex items-center justify-center bg-black/45 px-4 py-6 backdrop-blur-sm",onClick:s[1]||(s[1]=B(f=>r("close"),["self"]))},[e("section",I,[e("div",O,[e("div",null,[e("div",Q,[g(m(D),{class:"h-4 w-4"}),s[2]||(s[2]=e("span",null,"设置",-1))]),s[3]||(s[3]=e("p",{class:"theme-muted-text mt-1 text-xs leading-5"},"先把界面主题收到这里,后面其他偏好也可以继续往里放。",-1))]),e("button",{type:"button",class:"theme-icon-button h-8 w-8 shrink-0",onClick:s[0]||(s[0]=f=>r("close"))},[g(m(M),{class:"h-4 w-4"})])]),e("div",R,[e("section",Y,[g(H)]),e("section",Z,[e("div",ee,[e("div",null,[s[4]||(s[4]=e("div",{class:"theme-heading text-sm font-medium"},"版本信息",-1)),e("p",te,c(i.value||"当前已安装的 PromptX 版本。"),1)]),e("span",se,c(p.value?"读取中...":l.value?`v${l.value}`:"不可用"),1)])])])])])):w("",!0)]))}};export{ie as default};
|