refactor: remove todo tool (#35989)
This commit is contained in:
parent
d4155f2906
commit
7feefb697f
250 changed files with 237 additions and 4755 deletions
|
|
@ -10,7 +10,7 @@
|
|||
// /permission [kind] → triggers a permission request variant
|
||||
// /question [kind] → triggers a question request variant
|
||||
// /fmt <kind> → emits a specific tool/text type (text, reasoning, bash,
|
||||
// write, edit, patch, task, todo, question, error, mix)
|
||||
// write, edit, patch, task, question, error, mix)
|
||||
//
|
||||
// Demo mode also handles permission and question replies locally, completing
|
||||
// or failing the synthetic tool parts as appropriate.
|
||||
|
|
@ -30,7 +30,6 @@ const KINDS = [
|
|||
"edit",
|
||||
"patch",
|
||||
"task",
|
||||
"todo",
|
||||
"question",
|
||||
"error",
|
||||
"mix",
|
||||
|
|
@ -733,30 +732,6 @@ function emitTask(state: State): void {
|
|||
})
|
||||
}
|
||||
|
||||
function emitTodo(state: State): void {
|
||||
const ref = make(state, "todowrite", {
|
||||
todos: [
|
||||
{
|
||||
content: "Trigger permission UI",
|
||||
status: "completed",
|
||||
},
|
||||
{
|
||||
content: "Trigger question UI",
|
||||
status: "in_progress",
|
||||
},
|
||||
{
|
||||
content: "Tune tool formatting",
|
||||
status: "pending",
|
||||
},
|
||||
],
|
||||
})
|
||||
doneTool(state, ref, {
|
||||
title: "todowrite",
|
||||
output: "",
|
||||
metadata: {},
|
||||
})
|
||||
}
|
||||
|
||||
function emitQuestionTool(state: State): void {
|
||||
const ref = make(state, "question", {
|
||||
questions: [
|
||||
|
|
@ -952,7 +927,6 @@ function emitQuestion(state: State, kind: QuestionKind = "multi"): void {
|
|||
options: [
|
||||
{ label: "Diff", description: "Show an edit diff in the footer" },
|
||||
{ label: "Task", description: "Show a structured task summary" },
|
||||
{ label: "Todo", description: "Show a todo snapshot" },
|
||||
{ label: "Error", description: "Show an error transcript row" },
|
||||
],
|
||||
multiple: true,
|
||||
|
|
@ -992,7 +966,6 @@ function emitQuestion(state: State, kind: QuestionKind = "multi"): void {
|
|||
options: [
|
||||
{ label: "Diff", description: "Emit edit diff" },
|
||||
{ label: "Task", description: "Emit task card" },
|
||||
{ label: "Todo", description: "Emit todo card" },
|
||||
],
|
||||
multiple: true,
|
||||
custom: true,
|
||||
|
|
@ -1066,11 +1039,6 @@ async function emitFmt(state: State, kind: string, body: string, signal?: AbortS
|
|||
return true
|
||||
}
|
||||
|
||||
if (kind === "todo") {
|
||||
emitTodo(state)
|
||||
return true
|
||||
}
|
||||
|
||||
if (kind === "question") {
|
||||
emitQuestionTool(state)
|
||||
return true
|
||||
|
|
@ -1091,7 +1059,6 @@ async function emitFmt(state: State, kind: string, body: string, signal?: AbortS
|
|||
emitEdit(state)
|
||||
emitPatch(state)
|
||||
emitTask(state)
|
||||
emitTodo(state)
|
||||
emitQuestionTool(state)
|
||||
emitError(state, "demo mixed scenario error")
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -7,26 +7,6 @@ import { toolFiletype, toolStructuredFinal } from "./tool"
|
|||
import { RUN_THEME_FALLBACK, transparent, type RunTheme } from "./theme"
|
||||
import type { EntryLayout, RunEntryBody, ScrollbackOptions, StreamCommit } from "./types"
|
||||
|
||||
function todoText(item: { status: string; content: string }): string {
|
||||
if (item.status === "completed") {
|
||||
return `[✓] ${item.content}`
|
||||
}
|
||||
|
||||
if (item.status === "cancelled") {
|
||||
return `~[ ] ${item.content}~`
|
||||
}
|
||||
|
||||
if (item.status === "in_progress") {
|
||||
return `[•] ${item.content}`
|
||||
}
|
||||
|
||||
return `[ ] ${item.content}`
|
||||
}
|
||||
|
||||
function todoColor(theme: RunTheme, status: string) {
|
||||
return status === "in_progress" ? theme.block.warning : theme.block.muted
|
||||
}
|
||||
|
||||
export function entryGroupKey(commit: StreamCommit): string | undefined {
|
||||
if (!commit.partID) {
|
||||
return undefined
|
||||
|
|
@ -137,10 +117,6 @@ export function RunEntryContent(props: {
|
|||
const next = structured()
|
||||
return next?.kind === "task" ? next : undefined
|
||||
})
|
||||
const todo_snapshot = createMemo(() => {
|
||||
const next = structured()
|
||||
return next?.kind === "todo" ? next : undefined
|
||||
})
|
||||
const question_snapshot = createMemo(() => {
|
||||
const next = structured()
|
||||
return next?.kind === "question" ? next : undefined
|
||||
|
|
@ -242,25 +218,6 @@ export function RunEntryContent(props: {
|
|||
</box>
|
||||
</box>
|
||||
</Match>
|
||||
<Match when={todo_snapshot()}>
|
||||
<box width="100%" flexDirection="column" gap={1}>
|
||||
<text width="100%" wrapMode="word" fg={theme().block.muted}>
|
||||
# Todos
|
||||
</text>
|
||||
<box width="100%" flexDirection="column" gap={0}>
|
||||
{todo_snapshot()!.items.map((item) => (
|
||||
<text width="100%" wrapMode="word" fg={todoColor(theme(), item.status)}>
|
||||
{todoText(item)}
|
||||
</text>
|
||||
))}
|
||||
{todo_snapshot()!.tail ? (
|
||||
<text width="100%" wrapMode="word" fg={theme().block.muted}>
|
||||
{todo_snapshot()!.tail}
|
||||
</text>
|
||||
) : null}
|
||||
</box>
|
||||
</box>
|
||||
</Match>
|
||||
<Match when={question_snapshot()}>
|
||||
<box width="100%" flexDirection="column" gap={1}>
|
||||
<text width="100%" wrapMode="word" fg={theme().block.muted}>
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ type ToolInput = ToolDict & {
|
|||
content?: string
|
||||
command?: string
|
||||
workdir?: string
|
||||
todos?: Array<{ status?: string; content?: string }>
|
||||
questions?: Array<{ question?: string }>
|
||||
diff?: string
|
||||
}
|
||||
|
|
@ -122,7 +121,6 @@ type ToolName =
|
|||
| "patch"
|
||||
| "batch"
|
||||
| "task"
|
||||
| "todowrite"
|
||||
| "question"
|
||||
| "read"
|
||||
| "glob"
|
||||
|
|
@ -398,25 +396,6 @@ function runTask(p: ToolProps): ToolInline {
|
|||
}
|
||||
}
|
||||
|
||||
function runTodo(p: ToolProps): ToolInline {
|
||||
return {
|
||||
icon: "#",
|
||||
title: "Todos",
|
||||
mode: "block",
|
||||
body: list<{ status?: string; content?: string }>(p.frame.input.todos)
|
||||
.flatMap((item) => {
|
||||
const body = typeof item?.content === "string" ? item.content : ""
|
||||
if (!body) {
|
||||
return []
|
||||
}
|
||||
|
||||
const mark = item.status === "completed" ? "[✓]" : item.status === "in_progress" ? "[•]" : "[ ]"
|
||||
return [`${mark} ${body}`]
|
||||
})
|
||||
.join("\n"),
|
||||
}
|
||||
}
|
||||
|
||||
function runSkill(p: ToolProps): ToolInline {
|
||||
return {
|
||||
icon: "→",
|
||||
|
|
@ -604,28 +583,6 @@ function snapTask(p: ToolProps): ToolSnapshot {
|
|||
}
|
||||
}
|
||||
|
||||
function snapTodo(p: ToolProps): ToolSnapshot {
|
||||
const items = list<{ status?: string; content?: string }>(p.frame.input.todos).flatMap((item) => {
|
||||
const content = typeof item?.content === "string" ? item.content : ""
|
||||
if (!content) {
|
||||
return []
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
status: typeof item.status === "string" ? item.status : "",
|
||||
content,
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
return {
|
||||
kind: "todo",
|
||||
items,
|
||||
tail: "",
|
||||
}
|
||||
}
|
||||
|
||||
function snapQuestion(p: ToolProps): ToolSnapshot {
|
||||
const answers = list<unknown[]>(p.frame.meta.answers)
|
||||
const items = list<{ question?: string }>(p.frame.input.questions).map((item, i) => {
|
||||
|
|
@ -814,42 +771,6 @@ function scrollTaskFinal(p: ToolProps): string {
|
|||
return `# ${kind} Task\n${row}`
|
||||
}
|
||||
|
||||
function scrollTodoStart(_: ToolProps): string {
|
||||
return ""
|
||||
}
|
||||
|
||||
function scrollTodoFinal(p: ToolProps): string {
|
||||
const items = list<{ status?: string }>(p.input.todos)
|
||||
const time = span(p.frame.state)
|
||||
if (items.length === 0) {
|
||||
if (!time) {
|
||||
return "0 todos"
|
||||
}
|
||||
|
||||
return `0 todos · ${time}`
|
||||
}
|
||||
|
||||
const doneN = items.filter((item) => item.status === "completed").length
|
||||
const runN = items.filter((item) => item.status === "in_progress").length
|
||||
const left = items.length - doneN - runN
|
||||
const tail = [`${items.length} total`]
|
||||
if (doneN > 0) {
|
||||
tail.push(`${doneN} done`)
|
||||
}
|
||||
if (runN > 0) {
|
||||
tail.push(`${runN} active`)
|
||||
}
|
||||
if (left > 0) {
|
||||
tail.push(`${left} pending`)
|
||||
}
|
||||
|
||||
if (time) {
|
||||
tail.push(time)
|
||||
}
|
||||
|
||||
return tail.join(" · ")
|
||||
}
|
||||
|
||||
function scrollQuestionStart(_: ToolProps): string {
|
||||
return ""
|
||||
}
|
||||
|
|
@ -1131,19 +1052,6 @@ const TOOL_RULES = {
|
|||
},
|
||||
permission: permTask,
|
||||
},
|
||||
todowrite: {
|
||||
view: {
|
||||
output: false,
|
||||
final: true,
|
||||
snap: "structured",
|
||||
},
|
||||
run: runTodo,
|
||||
snap: snapTodo,
|
||||
scroll: {
|
||||
start: scrollTodoStart,
|
||||
final: scrollTodoFinal,
|
||||
},
|
||||
},
|
||||
question: {
|
||||
view: {
|
||||
output: false,
|
||||
|
|
|
|||
|
|
@ -199,15 +199,6 @@ export type ToolTaskSnapshot = {
|
|||
tail: string
|
||||
}
|
||||
|
||||
export type ToolTodoSnapshot = {
|
||||
kind: "todo"
|
||||
items: Array<{
|
||||
status: string
|
||||
content: string
|
||||
}>
|
||||
tail: string
|
||||
}
|
||||
|
||||
export type ToolQuestionSnapshot = {
|
||||
kind: "question"
|
||||
items: Array<{
|
||||
|
|
@ -217,12 +208,7 @@ export type ToolQuestionSnapshot = {
|
|||
tail: string
|
||||
}
|
||||
|
||||
export type ToolSnapshot =
|
||||
| ToolCodeSnapshot
|
||||
| ToolDiffSnapshot
|
||||
| ToolTaskSnapshot
|
||||
| ToolTodoSnapshot
|
||||
| ToolQuestionSnapshot
|
||||
export type ToolSnapshot = ToolCodeSnapshot | ToolDiffSnapshot | ToolTaskSnapshot | ToolQuestionSnapshot
|
||||
|
||||
export type EntryLayout = "inline" | "block"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue