diff --git a/packages/cli/src/serve/scheduled-task-keepalive.test.ts b/packages/cli/src/serve/scheduled-task-keepalive.test.ts index daf11b53a38..fa822d25869 100644 --- a/packages/cli/src/serve/scheduled-task-keepalive.test.ts +++ b/packages/cli/src/serve/scheduled-task-keepalive.test.ts @@ -7,9 +7,11 @@ import { promises as fsp } from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; -import { afterEach, beforeEach, describe, expect, it } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { Storage, + readCronTasks, + SessionService, updateCronTasks, type DurableCronTask, } from '@qwen-code/qwen-code-core'; @@ -42,6 +44,15 @@ describe('scheduled-task keepalive', () => { loadSession: async (req: { sessionId: string }) => { loads.push(req.sessionId); }, + spawnOrAttach: async () => { + throw new Error('spawnOrAttach not mocked'); + }, + closeSession: async () => { + throw new Error('closeSession not mocked'); + }, + updateSessionMetadata: () => { + throw new Error('updateSessionMetadata not mocked'); + }, }; beforeEach(async () => { @@ -104,6 +115,13 @@ describe('scheduled-task keepalive', () => { loadSession: async (req: { sessionId: string }) => { loads.push(req.sessionId); }, + spawnOrAttach: async () => { + throw new Error('not mocked'); + }, + closeSession: async () => {}, + updateSessionMetadata: () => { + throw new Error('not mocked'); + }, }; const ka = startScheduledTaskKeepalive({ bridge: guarded, @@ -140,6 +158,13 @@ describe('scheduled-task keepalive', () => { loadSession: async (req: { sessionId: string }) => { loads.push(req.sessionId); }, + spawnOrAttach: async () => { + throw new Error('not mocked'); + }, + closeSession: async () => {}, + updateSessionMetadata: () => { + throw new Error('not mocked'); + }, }; const ka = startScheduledTaskKeepalive({ bridge: reviving, @@ -168,6 +193,13 @@ describe('scheduled-task keepalive', () => { loads.push(req.sessionId); if (req.sessionId === 'sess-1') throw new Error('transcript gone'); }, + spawnOrAttach: async () => { + throw new Error('not mocked'); + }, + closeSession: async () => {}, + updateSessionMetadata: () => { + throw new Error('not mocked'); + }, }; const ka = startScheduledTaskKeepalive({ bridge: reviving, @@ -192,6 +224,13 @@ describe('scheduled-task keepalive', () => { loads.push(req.sessionId); throw new Error('transcript gone'); }, + spawnOrAttach: async () => { + throw new Error('not mocked'); + }, + closeSession: async () => {}, + updateSessionMetadata: () => { + throw new Error('not mocked'); + }, }; const ka = startScheduledTaskKeepalive({ bridge: reviving, @@ -220,6 +259,13 @@ describe('scheduled-task keepalive', () => { releaseLoad = resolve; }); }, + spawnOrAttach: async () => { + throw new Error('not mocked'); + }, + closeSession: async () => {}, + updateSessionMetadata: () => { + throw new Error('not mocked'); + }, }; const ka = startScheduledTaskKeepalive({ bridge: reviving, @@ -351,4 +397,219 @@ describe('scheduled-task keepalive', () => { expect(res.loaded).toHaveLength(0); expect(started).toBe(12); // ...and every queued session was still attempted }); + + it('binds an unbound task to a dedicated session and writes sessionId to disk', async () => { + await updateCronTasks(workspace, () => [ + task({ id: 'unbound-1', prompt: 'check build' }), + ]); + const spawns: unknown[] = []; + const names: Array<[string, { displayName?: string }]> = []; + const binding = { + ...bridge, + spawnOrAttach: async (req: unknown) => { + spawns.push(req); + return { sessionId: 'new-sess-1' }; + }, + closeSession: async () => {}, + updateSessionMetadata: (id: string, m: { displayName?: string }) => { + names.push([id, m]); + }, + }; + const ka = startScheduledTaskKeepalive({ + bridge: binding, + boundWorkspace: workspace, + intervalMs: 60_000, + }); + await ka.tick(); + ka.stop(); + expect(spawns).toHaveLength(1); + expect(spawns[0]).toEqual({ + workspaceCwd: workspace, + sessionScope: 'thread', + }); + expect(names).toHaveLength(1); + expect(names[0]![0]).toBe('new-sess-1'); + expect(names[0]![1].displayName).toContain('⏰'); + const tasks = await readCronTasks(workspace); + expect(tasks[0]!.sessionId).toBe('new-sess-1'); + }); + + it('renames a bound session without ⏰ prefix exactly once', async () => { + await updateCronTasks(workspace, () => [ + task({ id: 'bound-1', sessionId: 'existing-sess', prompt: 'lint' }), + ]); + const names: Array<[string, { displayName?: string }]> = []; + const naming = { + ...bridge, + updateSessionMetadata: (id: string, m: { displayName?: string }) => { + names.push([id, m]); + }, + }; + const ka = startScheduledTaskKeepalive({ + bridge: naming, + boundWorkspace: workspace, + intervalMs: 60_000, + }); + await ka.tick(); + await ka.tick(); + ka.stop(); + expect(names).toHaveLength(1); + expect(names[0]![0]).toBe('existing-sess'); + expect(names[0]![1].displayName).toContain('⏰'); + }); + + it('does not bind disabled unbound tasks', async () => { + await updateCronTasks(workspace, () => [ + task({ id: 'disabled-unbound', enabled: false }), + ]); + let spawnCount = 0; + const noSpawn = { + ...bridge, + spawnOrAttach: async () => { + spawnCount++; + return { sessionId: 'should-not-spawn' }; + }, + }; + const ka = startScheduledTaskKeepalive({ + bridge: noSpawn, + boundWorkspace: workspace, + intervalMs: 60_000, + }); + await ka.tick(); + ka.stop(); + expect(spawnCount).toBe(0); + }); + + it('still binds a task when updateSessionMetadata fails', async () => { + await updateCronTasks(workspace, () => [ + task({ id: 'name-fail', prompt: 'test prompt' }), + ]); + const naming = { + ...bridge, + spawnOrAttach: async () => ({ sessionId: 'bound-despite-naming-fail' }), + closeSession: async () => {}, + updateSessionMetadata: () => { + throw new Error('metadata service down'); + }, + }; + const ka = startScheduledTaskKeepalive({ + bridge: naming, + boundWorkspace: workspace, + intervalMs: 60_000, + }); + await ka.tick(); + ka.stop(); + const tasks = await readCronTasks(workspace); + expect(tasks[0]!.sessionId).toBe('bound-despite-naming-fail'); + }); + + it('rolls back the spawned session when the task vanishes before write', async () => { + // Seed an unbound task, then replace it with a different task between the + // keepalive's read and the updateCronTasks callback — simulating a + // concurrent delete. The spawned session must be closed AND its persisted + // transcript removed. + const closed: string[] = []; + const removeSpy = vi + .spyOn(SessionService.prototype, 'removeSession') + .mockResolvedValue(true); + const rollbackBridge = { + ...bridge, + spawnOrAttach: async () => { + // Simulate concurrent deletion: remove the task from disk right after + // spawn returns (before updateCronTasks's read-modify-write). + await updateCronTasks(workspace, () => []); + return { sessionId: 'orphan-sess' }; + }, + closeSession: async (id: string) => { + closed.push(id); + }, + updateSessionMetadata: () => {}, + }; + await updateCronTasks(workspace, () => [ + task({ id: 'will-vanish', prompt: 'doomed' }), + ]); + const ka = startScheduledTaskKeepalive({ + bridge: rollbackBridge, + boundWorkspace: workspace, + intervalMs: 60_000, + }); + await ka.tick(); + ka.stop(); + expect(closed).toContain('orphan-sess'); + expect(removeSpy).toHaveBeenCalledWith('orphan-sess'); + removeSpy.mockRestore(); + }); + + it('rolls back when another process binds the task before write', async () => { + // Another keepalive/process binds the same task between our spawn and + // our updateCronTasks lock. Our spawned session must be rolled back. + const closed: string[] = []; + const removeSpy = vi + .spyOn(SessionService.prototype, 'removeSession') + .mockResolvedValue(true); + const raceBridge = { + ...bridge, + spawnOrAttach: async () => { + // Simulate another process binding the task. + await updateCronTasks(workspace, (list) => + list.map((t) => + t.id === 'raced' ? { ...t, sessionId: 'other-sess' } : t, + ), + ); + return { sessionId: 'our-orphan' }; + }, + closeSession: async (id: string) => { + closed.push(id); + }, + updateSessionMetadata: () => {}, + }; + await updateCronTasks(workspace, () => [ + task({ id: 'raced', prompt: 'contested' }), + ]); + const ka = startScheduledTaskKeepalive({ + bridge: raceBridge, + boundWorkspace: workspace, + intervalMs: 60_000, + }); + await ka.tick(); + ka.stop(); + expect(closed).toContain('our-orphan'); + // The other process's sessionId is preserved. + const tasks = await readCronTasks(workspace); + expect(tasks[0]!.sessionId).toBe('other-sess'); + removeSpy.mockRestore(); + }); + + it('a hung spawnOrAttach does not stall subsequent ticks', async () => { + // spawnOrAttach is not abortable — if it hangs, the keepalive must time + // out and move on so later ticks can still heartbeat/revive other + // sessions. Use a tiny interval so the backoff expires fast. + await updateCronTasks(workspace, () => [ + task({ id: 'hung', prompt: 'will hang' }), + task({ id: 'ok', sessionId: 'healthy-sess', prompt: 'fine' }), + ]); + let releaseSpawn: (() => void) | undefined; + const hungBridge = { + ...bridge, + spawnOrAttach: () => + new Promise<{ sessionId: string }>((resolve) => { + releaseSpawn = () => resolve({ sessionId: 'late-sess' }); + }), + closeSession: async () => {}, + updateSessionMetadata: () => {}, + }; + const ka = startScheduledTaskKeepalive({ + bridge: hungBridge, + boundWorkspace: workspace, + intervalMs: 50, + spawnTimeoutMs: 50, + }); + // First tick: spawn hangs → timeout fires → tick completes. + await ka.tick(); + // healthy-sess should still get heartbeated despite the hung spawn. + expect(beats).toContain('healthy-sess'); + ka.stop(); + // Clean up the hung spawn. + releaseSpawn?.(); + }); }); diff --git a/packages/cli/src/serve/scheduled-task-keepalive.ts b/packages/cli/src/serve/scheduled-task-keepalive.ts index 79d56c5277a..822ba81e859 100644 --- a/packages/cli/src/serve/scheduled-task-keepalive.ts +++ b/packages/cli/src/serve/scheduled-task-keepalive.ts @@ -28,11 +28,17 @@ * gap is caught up when the session loads. */ +import * as fsSync from 'node:fs'; +import * as path from 'node:path'; import { readCronTasks, + updateCronTasks, + getCronFilePath, createDebugLogger, + SessionService, type DurableCronTask, } from '@qwen-code/qwen-code-core'; +import { scheduledTaskSessionName } from './routes/scheduled-tasks.js'; const log = createDebugLogger('SCHED_KEEPALIVE'); @@ -62,7 +68,10 @@ function collectBoundSessionIds(tasks: readonly DurableCronTask[]): string[] { /** The slice of the bridge the keepalive needs — narrowed for testability. * `recordHeartbeat` keeps a live session resident; `loadSession` revives one - * the reaper already let go (a re-enabled task's session). */ + * the reaper already let go (a re-enabled task's session). `spawnOrAttach` + * and `updateSessionMetadata` bind unbound durable tasks to dedicated + * sessions — the same flow the POST /scheduled-tasks route uses for + * UI-created tasks, applied retroactively to cron_create tool tasks. */ export interface KeepaliveBridge { recordHeartbeat(sessionId: string): unknown; loadSession(req: { @@ -70,15 +79,158 @@ export interface KeepaliveBridge { workspaceCwd: string; historyReplay?: 'stream' | 'response'; }): Promise; + spawnOrAttach(req: { + workspaceCwd: string; + sessionScope?: 'single' | 'thread'; + }): Promise<{ sessionId: string }>; + closeSession(sessionId: string): Promise; + updateSessionMetadata( + sessionId: string, + metadata: { displayName?: string }, + ): unknown; } /** Per-session revive-load timeout: a hung reload must not stall the sweep. */ const KEEPALIVE_REVIVE_TIMEOUT_MS = 30_000; +/** Per-task spawn timeout: a hung spawnOrAttach must not stall the sweep. */ +const KEEPALIVE_SPAWN_TIMEOUT_MS = 30_000; /** Upper bound on the per-session revive backoff, so a permanently-gone session * (transcript deleted out-of-band) is retried at most this often rather than * every interval forever. */ const MAX_REVIVE_BACKOFF_MS = 30 * 60_000; +/** + * Bind unbound durable tasks to dedicated sessions, and rename bound + * sessions that don't yet have the ⏰ prefix. The cron_create tool leaves + * durable tasks unbound so they stay pickable by any lock owner (CLI/ACP + * /headless). In daemon mode this keepalive mints a dedicated session per + * task and names it — binding is a daemon-only concern. + * + * For unbound tasks: mints a dedicated session, names it `⏰ prompt`, + * writes sessionId to disk. + * For bound tasks without ⏰ name: renames the session to `⏰ prompt`. + * + * A Set tracks renamed sessions so we don't call updateSessionMetadata + * every tick. Best-effort — failures are logged and retried next tick. + */ +async function bindAndNameSessions( + bridge: KeepaliveBridge, + boundWorkspace: string, + tasks: readonly DurableCronTask[], + renamed: Set, + spawnTimeoutMs: number, + binding: Set, +): Promise { + const unbound = tasks.filter( + (t) => !t.sessionId && t.enabled !== false && !binding.has(t.id), + ); + const needsName = tasks.filter( + (t) => t.sessionId && t.enabled !== false && !renamed.has(t.sessionId), + ); + + for (const task of unbound) { + let spawnedSessionId: string | undefined; + try { + binding.add(task.id); + const rawSpawn = bridge.spawnOrAttach({ + workspaceCwd: boundWorkspace, + sessionScope: 'thread', + }); + // spawnOrAttach is not abortable — if the timeout fires first, the + // raw promise may still resolve later with a live session. Attach a + // background handler to clean up that orphan immediately. Clear the + // binding guard on TRUE settlement so retries are possible. + let timedOut = false; + rawSpawn + .then(({ sessionId }) => { + if (timedOut) { + log.debug( + 'keepalive: late spawn resolved, cleaning up', + task.id, + sessionId, + ); + bridge.closeSession(sessionId).catch(() => {}); + new SessionService(boundWorkspace) + .removeSession(sessionId) + .catch(() => {}); + } + }) + .catch(() => {}) + .finally(() => { + binding.delete(task.id); + }); + const { sessionId } = await withTimeout( + rawSpawn, + spawnTimeoutMs, + `spawnOrAttach(${task.id})`, + ).catch((err) => { + timedOut = true; // raw spawn may still resolve — background handler will clean up + throw err; + }); + spawnedSessionId = sessionId; + try { + bridge.updateSessionMetadata(sessionId, { + displayName: scheduledTaskSessionName(task.prompt), + }); + renamed.add(sessionId); + } catch { + // naming is non-critical — the session still fires correctly + } + let matched = false; + await updateCronTasks(boundWorkspace, (list) => { + // Another process may have bound or disabled this task between our + // read and this write-lock acquisition — only attach when the task is + // still unbound and enabled. Otherwise return unchanged so the + // orphan spawn is rolled back below. + if ( + !list.some( + (t) => t.id === task.id && !t.sessionId && t.enabled !== false, + ) + ) { + return list; + } + const result = list.map((t) => + t.id === task.id && !t.sessionId && t.enabled !== false + ? { ...t, sessionId } + : t, + ); + matched = true; + return result; + }); + if (!matched) { + // Task was deleted between read and write — roll back the orphan. + throw new Error(`task ${task.id} no longer on disk`); + } + log.debug( + 'keepalive: bound task', + task.id, + 'to dedicated session', + sessionId, + ); + } catch (err) { + log.debug('keepalive: failed to bind task', task.id, err); + if (spawnedSessionId !== undefined) { + await bridge.closeSession(spawnedSessionId).catch(() => {}); + await new SessionService(boundWorkspace) + .removeSession(spawnedSessionId) + .catch(() => {}); + } + } + } + + for (const task of needsName) { + const sessionId = task.sessionId!; + try { + bridge.updateSessionMetadata(sessionId, { + displayName: scheduledTaskSessionName(task.prompt), + }); + renamed.add(sessionId); + } catch (err) { + log.debug('keepalive: failed to name session', sessionId, err); + } + } +} + export interface ScheduledTaskKeepalive { /** Stops the periodic heartbeat. Idempotent. */ stop(): void; @@ -93,6 +245,8 @@ export interface StartScheduledTaskKeepaliveOptions { intervalMs: number; /** Per-session revive timeout; defaults to KEEPALIVE_REVIVE_TIMEOUT_MS. */ reviveTimeoutMs?: number; + /** Per-task spawn timeout; defaults to KEEPALIVE_SPAWN_TIMEOUT_MS. */ + spawnTimeoutMs?: number; } export function startScheduledTaskKeepalive( @@ -100,6 +254,7 @@ export function startScheduledTaskKeepalive( ): ScheduledTaskKeepalive { const { bridge, boundWorkspace, intervalMs } = opts; const reviveTimeoutMs = opts.reviveTimeoutMs ?? KEEPALIVE_REVIVE_TIMEOUT_MS; + const spawnTimeoutMs = opts.spawnTimeoutMs ?? KEEPALIVE_SPAWN_TIMEOUT_MS; // Per-session revive state: `nextAttemptAt` gates retries after failures so a // permanently-gone session isn't reloaded every interval; cleared on success. @@ -113,6 +268,15 @@ export function startScheduledTaskKeepalive( // the load's TRUE settlement, not the timeout. const reviving = new Set(); + // Tasks with a spawn in flight. After withTimeout rejects, the raw + // spawnOrAttach may still be running — skip the task in subsequent ticks + // until the raw spawn settles. + const binding = new Set(); + + // Tracks sessions the keepalive has already named with ⏰ prefix, + // so updateSessionMetadata isn't called every tick. + const renamed = new Set(); + const tick = async (): Promise => { let tasks; try { @@ -156,7 +320,7 @@ export function startScheduledTaskKeepalive( reviving.delete(sessionId); }); try { - await withTimeout(load, reviveTimeoutMs, sessionId); + await withTimeout(load, reviveTimeoutMs, `loadSession(${sessionId})`); log.debug('keepalive: revived non-resident session', sessionId); reviveState.delete(sessionId); } catch (loadErr) { @@ -180,13 +344,25 @@ export function startScheduledTaskKeepalive( } } } - // Drop backoff state for sessions no longer bound to any task. - if (reviveState.size > 0) { + // Drop backoff state and renamed entries for sessions no longer bound to any task. + if (reviveState.size > 0 || renamed.size > 0) { const live = new Set(tasks.map((t) => t.sessionId)); for (const id of reviveState.keys()) { if (!live.has(id)) reviveState.delete(id); } + for (const id of renamed) { + if (!live.has(id)) renamed.delete(id); + } } + + await bindAndNameSessions( + bridge, + boundWorkspace, + tasks, + renamed, + spawnTimeoutMs, + binding, + ); }; // In-flight guard: a pass can outlast the interval (each revive awaits up to @@ -204,12 +380,49 @@ export function startScheduledTaskKeepalive( // The heartbeat alone must never hold the daemon process open. timer.unref?.(); + // Watch the tasks file so a newly created cron_create task is bound to a + // dedicated session immediately, not after the next interval. Same + // directory-watch + debounce pattern the scheduler uses. + let bindDebounce: ReturnType | undefined; + const cronFilePath = getCronFilePath(boundWorkspace); + const cronDir = path.dirname(cronFilePath); + const cronFileName = path.basename(cronFilePath); + let fileWatcher: ReturnType | undefined; + try { + fsSync.mkdirSync(cronDir, { recursive: true }); + fileWatcher = fsSync.watch( + cronDir, + { persistent: false }, + (_event, filename) => { + // On Linux fs.watch delivers null as filename — treat it as a match + // (could be our file); non-matching filenames are skipped. + if (filename !== null && filename !== cronFileName) return; + if (bindDebounce) clearTimeout(bindDebounce); + bindDebounce = setTimeout(() => { + if (running) return; + running = true; + void tick().finally(() => { + running = false; + }); + }, 500); + bindDebounce.unref?.(); + }, + ); + fileWatcher.on('error', () => { + // Watch errors are non-fatal — the interval timer still ticks. + }); + } catch { + // Directory doesn't exist or can't be watched — interval timer still runs. + } + let stopped = false; return { stop: () => { if (stopped) return; stopped = true; clearInterval(timer); + if (bindDebounce) clearTimeout(bindDebounce); + fileWatcher?.close(); }, tick, }; @@ -280,7 +493,7 @@ export async function rehydrateScheduledTaskSessions(deps: { // raise an unhandled rejection once we've stopped awaiting it below. void load.catch(() => {}); try { - await withTimeout(load, timeoutMs, sessionId); + await withTimeout(load, timeoutMs, `loadSession(${sessionId})`); loaded.push(sessionId); } catch (err) { // Timed out (or the load rejected). Do NOT await the raw `load` here: a @@ -329,7 +542,7 @@ export async function rehydrateScheduledTaskSessions(deps: { function withTimeout(p: Promise, ms: number, label: string): Promise { return new Promise((resolve, reject) => { const timer = setTimeout(() => { - reject(new Error(`loadSession(${label}) timed out after ${ms}ms`)); + reject(new Error(`${label} timed out after ${ms}ms`)); }, ms); if (typeof timer.unref === 'function') timer.unref(); p.then( diff --git a/packages/core/src/services/cronScheduler.test.ts b/packages/core/src/services/cronScheduler.test.ts index 74645c18a3e..35052f35d7b 100644 --- a/packages/core/src/services/cronScheduler.test.ts +++ b/packages/core/src/services/cronScheduler.test.ts @@ -1674,6 +1674,17 @@ describe('CronScheduler', () => { expect(tasks[0]!.prompt).toBe('headless durable'); }); + it('createDurable leaves tasks unbound even after enableDurable', async () => { + // Regression guard: durable tasks created via cron_create must stay + // unbound so non-daemon paths (TUI/ACP/headless) keep the shared-lock + // model. Binding is the daemon keepalive's job, not createDurable's. + await scheduler.enableDurable('session-1'); + await scheduler.createDurable('* * * * *', 'unbound', true); + const tasks = await readCronTasks(tmpDir); + expect(tasks).toHaveLength(1); + expect(tasks[0]!.sessionId).toBeUndefined(); + }); + it('non-owner loads durable tasks for listing but does not fire them', async () => { await lockAsOtherSession(); await writeCronTasks(tmpDir, [diskTask('foreign1')]); diff --git a/packages/core/src/services/cronScheduler.ts b/packages/core/src/services/cronScheduler.ts index 4b67059c798..11820d325a2 100644 --- a/packages/core/src/services/cronScheduler.ts +++ b/packages/core/src/services/cronScheduler.ts @@ -1515,6 +1515,7 @@ function jobToDurableTask(job: CronJob): DurableCronTask { recurring: job.recurring, createdAt: job.createdAt, lastFiredAt: job.lastFiredAt ?? null, + ...(job.boundSessionId ? { sessionId: job.boundSessionId } : {}), }; } diff --git a/packages/web-shell/client/components/dialogs/ScheduledTasksDialog.test.tsx b/packages/web-shell/client/components/dialogs/ScheduledTasksDialog.test.tsx index 708ab3c4d25..d462a2ca400 100644 --- a/packages/web-shell/client/components/dialogs/ScheduledTasksDialog.test.tsx +++ b/packages/web-shell/client/components/dialogs/ScheduledTasksDialog.test.tsx @@ -405,9 +405,9 @@ describe('ScheduledTasksDialog view-history (bound session)', () => { ], { onOpenSession }, ); - // A bound task shows a "View history" control (with a run count) that opens - // its session transcript — not the inline expand toggle. - const btn = findButton('View history (1)'); + // A bound task shows a "View conversation" control (with a run count) that + // opens its session transcript — not the inline expand toggle. + const btn = findButton('View conversation (1)'); expect(btn).toBeDefined(); expect(document.querySelector('button[aria-expanded]')).toBeNull(); click(btn); @@ -420,7 +420,7 @@ describe('ScheduledTasksDialog view-history (bound session)', () => { onOpenSession, }); // Discoverable even with zero runs — the original "can't find history" pain. - const btn = findButton('View history'); + const btn = findButton('View conversation'); expect(btn).toBeDefined(); click(btn); expect(onOpenSession).toHaveBeenCalledWith('sess-42'); @@ -432,7 +432,7 @@ describe('ScheduledTasksDialog view-history (bound session)', () => { await mount([ baseTask({ sessionId: 'sess-42', runs: [{ at: 1_700_000_100_000 }] }), ]); - expect(findButton('View history (1)')).toBeUndefined(); + expect(findButton('View conversation (1)')).toBeUndefined(); expect(document.querySelector('button[aria-expanded]')).not.toBeNull(); }); }); diff --git a/packages/web-shell/client/i18n.tsx b/packages/web-shell/client/i18n.tsx index f231784c979..b4e37571b82 100644 --- a/packages/web-shell/client/i18n.tsx +++ b/packages/web-shell/client/i18n.tsx @@ -661,8 +661,8 @@ const EN: Messages = { 'scheduledTasks.save': 'Save', 'scheduledTasks.saving': 'Saving…', 'scheduledTasks.runHistory': (v) => `Run history (${v?.count ?? 0})`, - 'scheduledTasks.viewHistory': (v) => `View history (${v?.count ?? 0})`, - 'scheduledTasks.viewHistoryEmpty': 'View history', + 'scheduledTasks.viewHistory': (v) => `View conversation (${v?.count ?? 0})`, + 'scheduledTasks.viewHistoryEmpty': 'View conversation', 'scheduledTasks.viewHistoryHint': "Open the task's session to see its runs", 'scheduledTasks.runKind.catchUp': 'late', 'scheduledTasks.runKind.manual': 'manual', @@ -2280,8 +2280,8 @@ const ZH: Messages = { 'scheduledTasks.save': '保存', 'scheduledTasks.saving': '保存中…', 'scheduledTasks.runHistory': (v) => `运行记录(${v?.count ?? 0})`, - 'scheduledTasks.viewHistory': (v) => `查看历史(${v?.count ?? 0})`, - 'scheduledTasks.viewHistoryEmpty': '查看历史', + 'scheduledTasks.viewHistory': (v) => `查看对话(${v?.count ?? 0})`, + 'scheduledTasks.viewHistoryEmpty': '查看对话', 'scheduledTasks.viewHistoryHint': '打开该任务的会话查看运行详情', 'scheduledTasks.runKind.catchUp': '补跑', 'scheduledTasks.runKind.manual': '手动',