fix(tui): add /cron command to list and cancel - #2971
Conversation
🦋 Changeset detectedLatest commit: 9c1e742 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 64c0a87b70
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const flat = prompt.replaceAll(/\s+/g, ' ').trim(); | ||
| return flat.length > PROMPT_PREVIEW_LENGTH ? `${flat.slice(0, PROMPT_PREVIEW_LENGTH)}…` : flat; |
There was a problem hiding this comment.
Sanitize cron prompts before rendering
When a scheduled prompt contains terminal control bytes, this whitespace-only normalization leaves them intact and the resulting preview is written directly through pi-tui, which preserves ANSI/OSC sequences. Because CronCreateInputSchema accepts arbitrary prompt strings—including model-generated text influenced by untrusted repository content—opening /cron can execute sequences that clear or corrupt the display, spoof hyperlinks, or alter terminal state. Strip terminal sequences and remaining C0/C1 controls from the display-only preview before styling it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Related Issue
Resolve #2968
Problem
See linked issue. Cron tasks created via the CronCreate tool are invisible to users: no slash command lists them, the
/taskspanel does not show them, and the only way to cancel one is to ask the model — so a forgotten recurring task keeps spending tokens with no user-facing off switch.What changed
Adds a
/cronslash command that lists the current session's scheduled cron tasks in a selector (cron expression, next fire time, recurring/one-shot, prompt preview) and cancels the selected task withDafter an inline[y/N]confirmation, following the existing dialog design spec (SELECT_POINTER, theme tokens,SearchableList).Listing already existed over the SDK (
Session.getCronTasks()); cancellation did not cross the engine boundary. This PR adds the missing delete path without inventing new engine machinery — both engines already had removal APIs, only the RPC/SDK exposure was missing:agent-core(v1):AgentAPI.deleteCronTaskRPC wired to the existingCronManager.removeTasks, andCronTaskSnapshotgains thepromptfield so hosts can show what a task does before canceling itagent-core-v2: the SDK v2 client bridgesdeleteCronTaskto the existingISessionCronService.removeTasks, mirroringgetCronTasks' main-agent scoping (deleted: falsefor non-main agents instead of failing)@moonshot-ai/kimi-code-sdk: publicSession.deleteCronTask(taskId)returning{ deleted: boolean }CronSelectorComponent, and bilingual slash-command reference rowsChecklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.