From e80168f97c5e5cbf9c0e83b6ee860614cc699602 Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 11 Jul 2026 05:34:18 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=AF=E5=8A=A8=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E6=97=B6=E7=9B=B4=E6=8E=A5=E4=BC=A0=E5=85=A5?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/platform-infra/webterm.yaml | 4 ++-- scripts/src/platform-infra-webterm.ts | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/config/platform-infra/webterm.yaml b/config/platform-infra/webterm.yaml index 426ee14e..bd89db05 100644 --- a/config/platform-infra/webterm.yaml +++ b/config/platform-infra/webterm.yaml @@ -19,7 +19,7 @@ sessionStartModes: command: oncx autoResumePrompt: - enabled: true + enabled: false prompt: "[自动提醒]如果有未完成任务则继续,没有则直接结束" sendEnter: true enterDelayMs: 500 @@ -84,7 +84,7 @@ targets: TERMINAL_SNAPSHOT_BYTES: "524288" BROWSER_KEEPALIVE_INTERVAL_MS: "30000" BROWSER_STALE_TIMEOUT_MS: "180000" - BROWSER_SESSION_OUTPUT_IDLE_MS: "60000" + BROWSER_SESSION_OUTPUT_IDLE_MS: "3000" publicExposure: enabled: true publicBaseUrl: https://term.pikapython.com diff --git a/scripts/src/platform-infra-webterm.ts b/scripts/src/platform-infra-webterm.ts index f2374746..4bf92fc4 100644 --- a/scripts/src/platform-infra-webterm.ts +++ b/scripts/src/platform-infra-webterm.ts @@ -334,7 +334,10 @@ function resolveTarget(targetId: string | null): WebtermTarget { function renderCompose(target: WebtermTarget): string { const environment = { ...target.runtime.environment, - AUTO_START_SESSIONS_JSON: JSON.stringify(target.runtime.autoStartSessions), + AUTO_START_SESSIONS_JSON: JSON.stringify(target.runtime.autoStartSessions.map((session) => ({ + ...session, + command: resumeCommandWithPrompt(session, target.runtime.autoResumePrompt), + }))), SESSION_START_MODES_JSON: JSON.stringify(target.runtime.sessionStartModes.options), SESSION_START_DEFAULT_MODE: target.runtime.sessionStartModes.defaultMode, AUTO_RESUME_PROMPT_JSON: JSON.stringify(target.runtime.autoResumePrompt), @@ -365,6 +368,21 @@ ${envLines} `; } +function resumeCommandWithPrompt( + session: WebtermTarget["runtime"]["autoStartSessions"][number], + prompt: AutoResumePrompt, +): string { + if (!session.resumePrompt) return session.command; + if (!/^\s*(?:mycx|oncx)\s+resume\s+\S+\s*$/.test(session.command)) { + throw new Error(`resumePrompt requires a mycx/oncx resume command: ${session.title}`); + } + return `${session.command.trim()} ${quoteShellArg(prompt.prompt)}`; +} + +function quoteShellArg(value: string): string { + return `'${value.replace(/'/g, `'"'"'`)}'`; +} + function policyChecks(target: WebtermTarget, compose: string): Array & { ok: boolean }> { return [ { name: "enabled", ok: target.enabled, detail: "target must be enabled" },