@gamflaz/opencode-todolist 1.0.4 → 1.0.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.
@@ -0,0 +1,77 @@
1
+ import { Plugin } from "@opencode/plugin/tui";
2
+ import { ColorInput, ScrollBoxRenderable } from "@opentui/core";
3
+ import { TodoStatus } from "../schemas/status";
4
+ /** How many open items the Continue prompt lists before collapsing the rest. */
5
+ export declare const CONTINUE_PROMPT_MAX_ITEMS = 3;
6
+ /** Per-field caps so one long note cannot flood the prompt. */
7
+ export declare const CONTINUE_PROMPT_MAX_CONTENT = 60;
8
+ export declare const CONTINUE_PROMPT_MAX_NOTE = 60;
9
+ /**
10
+ * Maximum number of todo rows the panel shows before it starts scrolling.
11
+ * Keeping the panel compact protects the composer; scrolling guarantees no
12
+ * row is ever silently dropped.
13
+ */
14
+ export declare const TODO_PANEL_MAX_ROWS = 8;
15
+ export interface TodoListRow {
16
+ id: number;
17
+ content: string;
18
+ icon: string;
19
+ iconColor: ColorInput;
20
+ textColor: ColorInput;
21
+ depth: number;
22
+ status: TodoStatus;
23
+ }
24
+ /** A renderable line: either a task row or its on-demand error row. */
25
+ export type TodoListEntry = {
26
+ kind: "row";
27
+ row: TodoListRow;
28
+ } | {
29
+ kind: "error";
30
+ row: TodoListRow;
31
+ };
32
+ export interface FollowScrollInput {
33
+ currentTop: number;
34
+ activeIndex: number;
35
+ rowCount: number;
36
+ viewportHeight: number;
37
+ }
38
+ /**
39
+ * Flattens rows into renderable lines, inserting an error detail right below
40
+ * an expanded error row (click to toggle).
41
+ */
42
+ export declare function TodoListEntries(rows: TodoListRow[], expandedIds: readonly number[]): TodoListEntry[];
43
+ /**
44
+ * Follow the most advanced active row: the last `in_progress` entry is the
45
+ * task currently being executed. Error lines are skipped.
46
+ */
47
+ export declare function FindActiveEntryIndex(entries: TodoListEntry[]): number;
48
+ /**
49
+ * Scroll offset needed to reveal the active row, or `undefined` when nothing
50
+ * should move (no active row, already visible, or the list fits).
51
+ *
52
+ * Kept pure so the follow behaviour is testable without a live renderer.
53
+ */
54
+ export declare function NextFollowScrollTop(input: FollowScrollInput): number | undefined;
55
+ /**
56
+ * Presentational, context-free todo list.
57
+ *
58
+ * The panel is deliberately chrome-free: no indicator row, and the horizontal
59
+ * scrollbar stays hidden. Long titles never wrap — they are reached by
60
+ * scrolling left/right, and the vertical list scrolls when it exceeds
61
+ * `TODO_PANEL_MAX_ROWS`. When a row is `in_progress` the panel follows it.
62
+ *
63
+ * `activeIcon` is an accessor so the spinner updates only the icon text node
64
+ * instead of forcing every row object to be rebuilt on each animation frame.
65
+ */
66
+ export declare function TodoList(props: {
67
+ rows: TodoListRow[];
68
+ expandedIds?: readonly number[];
69
+ scrollbarColor?: ColorInput;
70
+ activeIcon?: () => string;
71
+ onToggleRow?: (id: number) => void;
72
+ ref?: (el: ScrollBoxRenderable) => void;
73
+ }): import("solid-js").JSX.Element;
74
+ export declare function TodoProgress(props: {
75
+ context: Plugin.Context;
76
+ sessionID: string;
77
+ }): import("solid-js").JSX.Element;
@@ -0,0 +1,503 @@
1
+ import { mkdirSync, watch } from "node:fs";
2
+ import { createEffect, createMemo, createSignal, For, onCleanup, Show, } from "solid-js";
3
+ import { supportsImageRendering } from "../icons/image-capabilities";
4
+ import { SvgIcon } from "../icons/svg-icon";
5
+ import { arrowDownSvgIcon, arrowRightSvgIcon, continuePromptSvgIcon, removeSvgIcon, } from "../icons/svg-icons";
6
+ import { StatusLabel } from "../schemas/status";
7
+ import { getTodosDirectory, hashSessionID, readTodosSync, writeTodos, } from "../storage/todo-store";
8
+ import { getTodoDisplaySummary, hasOpenTodos, } from "../todos/display";
9
+ import { TodoTree } from "../todos/todo-tree";
10
+ import { shorten } from "./text";
11
+ import { ERROR_PREFIX, ErrorRowWidth, RowWidth } from "./layout";
12
+ /** How many open items the Continue prompt lists before collapsing the rest. */
13
+ export const CONTINUE_PROMPT_MAX_ITEMS = 3;
14
+ /** Per-field caps so one long note cannot flood the prompt. */
15
+ export const CONTINUE_PROMPT_MAX_CONTENT = 60;
16
+ export const CONTINUE_PROMPT_MAX_NOTE = 60;
17
+ const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
18
+ const SPINNER_INTERVAL_MS = 100;
19
+ const WATCH_DEBOUNCE_MS = 50;
20
+ /**
21
+ * Maximum number of todo rows the panel shows before it starts scrolling.
22
+ * Keeping the panel compact protects the composer; scrolling guarantees no
23
+ * row is ever silently dropped.
24
+ */
25
+ export const TODO_PANEL_MAX_ROWS = 8;
26
+ const isOpen = (status) => status !== "completed" && status !== "cancelled";
27
+ function ContinuePrompt(summary) {
28
+ const open = summary?.items.filter((item) => isOpen(item.status)) ?? [];
29
+ const shown = open.slice(0, CONTINUE_PROMPT_MAX_ITEMS);
30
+ const hidden = open.length - shown.length;
31
+ const lines = [
32
+ "Continue the current todolist.",
33
+ "First call manage_todo_list [read] and reconcile the stored list with this summary.",
34
+ ];
35
+ if (summary) {
36
+ lines.push(`Progress: ${summary.completed}/${summary.total} completed.`);
37
+ }
38
+ if (open.length) {
39
+ lines.push("Open items that still need work (short summary):");
40
+ for (const item of shown) {
41
+ const note = item.note
42
+ ? ` — ${shorten(item.note, CONTINUE_PROMPT_MAX_NOTE)}`
43
+ : "";
44
+ lines.push(`${item.depth ? " " : ""}- ${item.id} (${StatusLabel[item.status]}) ${shorten(item.content, CONTINUE_PROMPT_MAX_CONTENT)}${note}`);
45
+ }
46
+ if (hidden > 0)
47
+ lines.push(`... (${hidden} more open item(s))`);
48
+ }
49
+ else {
50
+ lines.push("No open items are listed. Verify the stored state before stopping.");
51
+ }
52
+ lines.push("Continue the next open item immediately. Keep exactly one item in_progress and update the todo list after verification.");
53
+ return lines.join("\n");
54
+ }
55
+ /**
56
+ * Flattens rows into renderable lines, inserting an error detail right below
57
+ * an expanded error row (click to toggle).
58
+ */
59
+ export function TodoListEntries(rows, expandedIds) {
60
+ const expanded = new Set(expandedIds);
61
+ const entries = [];
62
+ for (const row of rows) {
63
+ entries.push({ kind: "row", row });
64
+ if (row.status === "error" && expanded.has(row.id)) {
65
+ entries.push({ kind: "error", row });
66
+ }
67
+ }
68
+ return entries;
69
+ }
70
+ /**
71
+ * Follow the most advanced active row: the last `in_progress` entry is the
72
+ * task currently being executed. Error lines are skipped.
73
+ */
74
+ export function FindActiveEntryIndex(entries) {
75
+ for (let index = entries.length - 1; index >= 0; index -= 1) {
76
+ const entry = entries[index];
77
+ if (entry.kind === "row" && entry.row.status === "in_progress") {
78
+ return index;
79
+ }
80
+ }
81
+ return -1;
82
+ }
83
+ /**
84
+ * Scroll offset needed to reveal the active row, or `undefined` when nothing
85
+ * should move (no active row, already visible, or the list fits).
86
+ *
87
+ * Kept pure so the follow behaviour is testable without a live renderer.
88
+ */
89
+ export function NextFollowScrollTop(input) {
90
+ const { currentTop, activeIndex, rowCount, viewportHeight } = input;
91
+ if (activeIndex < 0)
92
+ return undefined;
93
+ const viewport = Math.max(1, viewportHeight);
94
+ const maxTop = Math.max(0, rowCount - viewport);
95
+ if (maxTop === 0)
96
+ return undefined;
97
+ const activeBottom = activeIndex + 1;
98
+ const visibleBottom = currentTop + viewport;
99
+ if (activeIndex >= currentTop && activeBottom <= visibleBottom) {
100
+ return undefined;
101
+ }
102
+ const targetTop = activeIndex >= visibleBottom ? activeBottom - viewport : activeIndex;
103
+ return Math.min(Math.max(0, targetTop), maxTop);
104
+ }
105
+ /**
106
+ * Presentational, context-free todo list.
107
+ *
108
+ * The panel is deliberately chrome-free: no indicator row, and the horizontal
109
+ * scrollbar stays hidden. Long titles never wrap — they are reached by
110
+ * scrolling left/right, and the vertical list scrolls when it exceeds
111
+ * `TODO_PANEL_MAX_ROWS`. When a row is `in_progress` the panel follows it.
112
+ *
113
+ * `activeIcon` is an accessor so the spinner updates only the icon text node
114
+ * instead of forcing every row object to be rebuilt on each animation frame.
115
+ */
116
+ export function TodoList(props) {
117
+ const rowId = (id) => `todo-row-${id}`;
118
+ const [box, setBox] = createSignal();
119
+ const entries = createMemo(() => TodoListEntries(props.rows, props.expandedIds ?? []));
120
+ const iconOf = (row) => row.status === "in_progress"
121
+ ? (props.activeIcon?.() ?? row.icon)
122
+ : row.icon;
123
+ const followActiveRow = (el) => {
124
+ if (el.isDestroyed)
125
+ return;
126
+ const target = NextFollowScrollTop({
127
+ currentTop: el.scrollTop,
128
+ activeIndex: FindActiveEntryIndex(entries()),
129
+ rowCount: entries().length,
130
+ viewportHeight: el.viewport.height,
131
+ });
132
+ if (target !== undefined)
133
+ el.scrollTo(target);
134
+ };
135
+ const attach = (el) => {
136
+ setBox(el);
137
+ el.content.maxWidth = undefined;
138
+ const internalOnSizeChange = el.content.onSizeChange;
139
+ el.content.onSizeChange = () => {
140
+ internalOnSizeChange?.call(el.content);
141
+ followActiveRow(el);
142
+ };
143
+ props.ref?.(el);
144
+ };
145
+ // `entries()` already changes whenever rows or expanded ids change.
146
+ createEffect(() => {
147
+ entries();
148
+ const el = box();
149
+ if (el)
150
+ followActiveRow(el);
151
+ });
152
+ const scrollbarOptions = () => props.scrollbarColor
153
+ ? {
154
+ trackOptions: {
155
+ backgroundColor: props.scrollbarColor,
156
+ foregroundColor: props.scrollbarColor,
157
+ },
158
+ }
159
+ : undefined;
160
+ const isExpanded = (id) => (props.expandedIds ?? []).includes(id);
161
+ return (<scrollbox ref={attach} width="100%" height={Math.min(entries().length, TODO_PANEL_MAX_ROWS)} verticalScrollbarOptions={scrollbarOptions()} horizontalScrollbarOptions={{ visible: false }}>
162
+ <box flexDirection="column" flexShrink={0}>
163
+ <For each={entries()}>
164
+ {(entry) => entry.kind === "row" ? (<box id={rowId(entry.row.id)} flexDirection="row" height={1} flexShrink={0} width={RowWidth(entry.row)} onMouseDown={(e) => {
165
+ if (e.button === 0 && entry.row.status === "error") {
166
+ e.stopPropagation?.();
167
+ props.onToggleRow?.(entry.row.id);
168
+ }
169
+ }}>
170
+ <text wrapMode="none">
171
+ <Show when={entry.row.depth > 0}>
172
+ <span>{" "}</span>
173
+ </Show>
174
+ <span style={{ fg: entry.row.iconColor }}>
175
+ {iconOf(entry.row)}{" "}
176
+ </span>
177
+ <span style={{ fg: entry.row.textColor }}>
178
+ {TodoTree.formatIdPrefix(entry.row.id, entry.row.depth)}
179
+ </span>
180
+ <span style={{
181
+ fg: entry.row.textColor,
182
+ strikethrough: entry.row.status === "completed",
183
+ }}>
184
+ {entry.row.content}
185
+ </span>
186
+ <Show when={entry.row.status === "error"}>
187
+ <span style={{ fg: props.scrollbarColor }}>
188
+ {" "}
189
+ {isExpanded(entry.row.id) ? "⌄" : "›"}
190
+ </span>
191
+ </Show>
192
+ </text>
193
+ </box>) : (<box id={`${rowId(entry.row.id)}-note`} flexDirection="row" height={1} flexShrink={0} width={ErrorRowWidth({
194
+ error: entry.row.content,
195
+ depth: entry.row.depth,
196
+ })} onMouseDown={(e) => {
197
+ if (e.button === 0) {
198
+ e.stopPropagation?.();
199
+ props.onToggleRow?.(entry.row.id);
200
+ }
201
+ }}>
202
+ <text wrapMode="none">
203
+ <span style={{ fg: props.scrollbarColor }}>
204
+ {entry.row.depth > 0 ? " " : " "}
205
+ {ERROR_PREFIX}
206
+ </span>
207
+ <span style={{ fg: entry.row.textColor }}>
208
+ {entry.row.content}
209
+ </span>
210
+ </text>
211
+ </box>)}
212
+ </For>
213
+ </box>
214
+ </scrollbox>);
215
+ }
216
+ /** Small helper so each hover target does not repeat three lines. */
217
+ function createHover() {
218
+ const [hovered, setHovered] = createSignal(false);
219
+ return {
220
+ hovered,
221
+ onMouseOver: () => setHovered(true),
222
+ onMouseOut: () => setHovered(false),
223
+ };
224
+ }
225
+ /**
226
+ * Watches the todos directory and calls `onChange` (debounced) when a file
227
+ * belonging to the current session changes. Cleans up with the owner scope.
228
+ */
229
+ function watchSessionTodos(sessionID, onChange) {
230
+ let timer;
231
+ let watcher;
232
+ const hashed = createMemo(() => {
233
+ const sid = sessionID();
234
+ if (!sid)
235
+ return "";
236
+ try {
237
+ return hashSessionID(sid);
238
+ }
239
+ catch {
240
+ return "";
241
+ }
242
+ });
243
+ const notify = () => {
244
+ clearTimeout(timer);
245
+ timer = setTimeout(onChange, WATCH_DEBOUNCE_MS);
246
+ };
247
+ const belongsToSession = (name) => {
248
+ const sid = sessionID();
249
+ if (!sid)
250
+ return true;
251
+ const hash = hashed();
252
+ return ((hash !== "" && name.startsWith(hash)) ||
253
+ name.startsWith(sid) ||
254
+ name.startsWith(`todos-${sid}-`));
255
+ };
256
+ try {
257
+ const baseDir = getTodosDirectory();
258
+ mkdirSync(baseDir, { recursive: true });
259
+ watcher = watch(baseDir, { recursive: true, persistent: false }, (_, filename) => {
260
+ if (!filename || belongsToSession(String(filename)))
261
+ notify();
262
+ });
263
+ }
264
+ catch (err) {
265
+ console.error("[todos] watcher initialization failed:", err);
266
+ }
267
+ onCleanup(() => {
268
+ clearTimeout(timer);
269
+ watcher?.close();
270
+ });
271
+ }
272
+ export function TodoProgress(props) {
273
+ const { context } = props;
274
+ const sessionID = () => props.sessionID ?? "";
275
+ const theme = () => context.theme;
276
+ const [refresh, setRefresh] = createSignal(0);
277
+ const [isCollapsed, setIsCollapsed] = createSignal(true);
278
+ const [isContinuePending, setIsContinuePending] = createSignal(false);
279
+ const [animFrame, setAnimFrame] = createSignal(0);
280
+ const [expandedIds, setExpandedIds] = createSignal([]);
281
+ const clearHover = createHover();
282
+ const continueHover = createHover();
283
+ // Image capability
284
+ const [imageSupported, setImageSupported] = createSignal(supportsImageRendering(context.renderer?.capabilities));
285
+ const onCapabilities = (caps) => setImageSupported(supportsImageRendering(caps));
286
+ context.renderer.on("capabilities", onCapabilities);
287
+ onCleanup(() => context.renderer.off("capabilities", onCapabilities));
288
+ // Running state
289
+ const readRunning = () => {
290
+ const sid = sessionID();
291
+ if (!sid)
292
+ return false;
293
+ try {
294
+ return context.data.session.status(sid) === "running";
295
+ }
296
+ catch {
297
+ return false;
298
+ }
299
+ };
300
+ const [isRunning, setIsRunning] = createSignal(readRunning());
301
+ createEffect(() => setIsRunning(readRunning()));
302
+ const unsubscribe = context.data.listen(({ details }) => {
303
+ const sid = sessionID();
304
+ switch (details.type) {
305
+ case "session.execution.started":
306
+ case "session.execution.interrupted":
307
+ case "session.execution.succeeded":
308
+ case "session.execution.failed":
309
+ case "session.idle":
310
+ if (!sid || details.data.sessionID === sid) {
311
+ setIsRunning(details.type === "session.execution.started");
312
+ setIsContinuePending(false);
313
+ }
314
+ break;
315
+ case "session.status":
316
+ if (!sid || details.data.sessionID === sid) {
317
+ setIsRunning(details.data.status.type !== "idle");
318
+ setIsContinuePending(false);
319
+ }
320
+ break;
321
+ }
322
+ });
323
+ onCleanup(() => {
324
+ try {
325
+ unsubscribe();
326
+ }
327
+ catch { }
328
+ });
329
+ // Todo data
330
+ watchSessionTodos(sessionID, () => setRefresh((v) => v + 1));
331
+ const summary = createMemo(() => {
332
+ refresh();
333
+ const sid = sessionID();
334
+ if (!sid)
335
+ return null;
336
+ try {
337
+ return getTodoDisplaySummary(readTodosSync(sid));
338
+ }
339
+ catch {
340
+ return null;
341
+ }
342
+ });
343
+ // Spinner: one interval, only while something is actually running.
344
+ const hasInProgress = createMemo(() => summary()?.items.some((i) => i.status === "in_progress") ?? false);
345
+ createEffect(() => {
346
+ if (!(hasInProgress() && isRunning()))
347
+ return;
348
+ const id = setInterval(() => setAnimFrame((prev) => (prev + 1) % SPINNER_FRAMES.length), SPINNER_INTERVAL_MS);
349
+ onCleanup(() => clearInterval(id));
350
+ });
351
+ const activeIcon = () => (isRunning() ? SPINNER_FRAMES[animFrame()] : "-");
352
+ const itemIcon = (status, fallback) => status === "in_progress" ? activeIcon() : fallback;
353
+ const activeItem = createMemo(() => {
354
+ const items = summary()?.items;
355
+ if (!items)
356
+ return null;
357
+ return (items.find((i) => i.status === "in_progress" && i.depth > 0) ??
358
+ items.find((i) => i.status === "in_progress") ??
359
+ null);
360
+ });
361
+ // Colors
362
+ const getStatusColor = (status) => {
363
+ const t = theme();
364
+ switch (status) {
365
+ case "in_progress":
366
+ return isRunning()
367
+ ? (t.text.action?.primary?.base ??
368
+ t.text.feedback.info?.base ??
369
+ t.text.base)
370
+ : t.text.muted;
371
+ case "completed":
372
+ return t.text.feedback.success.base;
373
+ case "error":
374
+ case "cancelled":
375
+ return t.text.feedback.error.base;
376
+ default:
377
+ return t.text.muted;
378
+ }
379
+ };
380
+ const getTextColor = (status) => status === "completed" || status === "cancelled" || status === "error"
381
+ ? theme().text.muted
382
+ : theme().text.base;
383
+ /**
384
+ * Rows are built only while the panel is expanded and do NOT depend on the
385
+ * spinner frame, so the row objects stay stable between animation ticks.
386
+ */
387
+ const rows = createMemo(() => {
388
+ if (isCollapsed())
389
+ return [];
390
+ return (summary()?.items ?? []).map((item) => ({
391
+ id: item.id,
392
+ content: item.content,
393
+ icon: item.icon,
394
+ iconColor: getStatusColor(item.status),
395
+ textColor: getTextColor(item.status),
396
+ depth: item.depth,
397
+ status: item.status,
398
+ }));
399
+ });
400
+ // Actions
401
+ const toggleRowNote = (id) => setExpandedIds((current) => current.includes(id)
402
+ ? current.filter((entry) => entry !== id)
403
+ : [...current, id]);
404
+ const continueTodos = async () => {
405
+ if (isRunning() || isContinuePending())
406
+ return;
407
+ const sid = sessionID();
408
+ if (!sid)
409
+ return;
410
+ setIsContinuePending(true);
411
+ try {
412
+ await context.client.session.prompt({
413
+ sessionID: sid,
414
+ text: ContinuePrompt(summary()),
415
+ });
416
+ }
417
+ catch (error) {
418
+ setIsContinuePending(false);
419
+ console.error("[todos] continue failed:", error);
420
+ }
421
+ };
422
+ const clearTodos = async () => {
423
+ const sid = sessionID();
424
+ if (!sid)
425
+ return;
426
+ try {
427
+ await writeTodos(sid, []);
428
+ setRefresh((v) => v + 1);
429
+ }
430
+ catch (error) {
431
+ console.error("[todos] clear failed:", error);
432
+ }
433
+ };
434
+ const hoverColor = (hovered, active) => hovered ? active : theme().text.muted;
435
+ return (<Show when={summary()}>
436
+ {(data) => (<box flexDirection="column" border={true} borderStyle="rounded" borderColor={theme().border.base} paddingLeft={1} paddingRight={1}>
437
+ <box flexDirection="row" justifyContent="space-between">
438
+ <box flexDirection="row" flexGrow={1} onMouseDown={(e) => {
439
+ if (e.button === 0) {
440
+ e.stopPropagation?.();
441
+ setIsCollapsed((v) => !v);
442
+ }
443
+ }}>
444
+ <box flexDirection="row" width={2} height={1} marginRight={1} marginLeft={imageSupported() ? 0 : 1} alignItems="flex-start">
445
+ <SvgIcon source={isCollapsed() ? arrowRightSvgIcon : arrowDownSvgIcon} color={theme().text.muted} fallback={isCollapsed() ? "▶" : "▼"} width={2} height={1}/>
446
+ </box>
447
+
448
+ <box flexDirection="row" flexGrow={1} flexShrink={1} overflow="hidden" marginRight={1}>
449
+ <text wrapMode="none">
450
+ <span style={{ fg: theme().text.base }}>{"Todos "}</span>
451
+ <span style={{ fg: theme().text.muted }}>
452
+ {`(${data().completed}/${data().total})`}
453
+ </span>
454
+ <Show when={isCollapsed() && activeItem()}>
455
+ {(active) => (<>
456
+ <span style={{ fg: theme().text.muted }}>{" "}</span>
457
+ <span style={{ fg: getStatusColor(active().status) }}>
458
+ {itemIcon(active().status, active().icon)}{" "}
459
+ </span>
460
+ <span style={{ fg: getTextColor(active().status) }}>
461
+ {TodoTree.formatIdPrefix(active().id, active().depth)}
462
+ {active().content}
463
+ </span>
464
+ </>)}
465
+ </Show>
466
+ </text>
467
+ </box>
468
+ </box>
469
+
470
+ <Show when={hasOpenTodos(data().items) &&
471
+ !isRunning() &&
472
+ !isContinuePending()}>
473
+ <box flexDirection="row" gap={1} marginRight={3} onMouseOver={continueHover.onMouseOver} onMouseOut={continueHover.onMouseOut} onMouseDown={(e) => {
474
+ if (e.button === 0) {
475
+ e.stopPropagation();
476
+ void continueTodos();
477
+ }
478
+ }}>
479
+ <SvgIcon source={continuePromptSvgIcon} color={hoverColor(continueHover.hovered(), theme().text.action.primary.base)} fallback="↻" width={2} height={1}/>
480
+ <text wrapMode="none" fg={hoverColor(continueHover.hovered(), theme().text.action.primary.base)}>
481
+ Continue
482
+ </text>
483
+ </box>
484
+ </Show>
485
+
486
+ <box marginRight={!imageSupported() ? 1.5 : 0} flexDirection="row" onMouseOver={clearHover.onMouseOver} onMouseOut={clearHover.onMouseOut} onMouseDown={(e) => {
487
+ if (e.button === 0) {
488
+ e.stopPropagation();
489
+ void clearTodos();
490
+ }
491
+ }}>
492
+ <SvgIcon color={hoverColor(clearHover.hovered(), theme().text.feedback.error.base)} source={removeSvgIcon} fallback="✖" height={1} width={2}/>
493
+ </box>
494
+ </box>
495
+
496
+ <Show when={!isCollapsed()}>
497
+ <box flexDirection="column" paddingTop={1} paddingLeft={0.5}>
498
+ <TodoList rows={rows()} expandedIds={expandedIds()} activeIcon={activeIcon} onToggleRow={toggleRowNote}/>
499
+ </box>
500
+ </Show>
501
+ </box>)}
502
+ </Show>);
503
+ }
package/dist/tui.d.ts CHANGED
@@ -1,100 +1,3 @@
1
1
  import { Plugin } from "@opencode/plugin/tui";
2
- import type { ColorInput, ScrollBoxRenderable } from "@opentui/core";
3
- import type { TodoStatus } from "./schema/status.schema";
4
- import { type TodoDisplaySummary } from "./todo/display";
5
- /** How many open items the Continue prompt lists before collapsing the rest. */
6
- export declare const CONTINUE_PROMPT_MAX_ITEMS = 3;
7
- /** Per-field caps so one long note cannot flood the prompt. */
8
- export declare const CONTINUE_PROMPT_MAX_CONTENT = 60;
9
- export declare const CONTINUE_PROMPT_MAX_NOTE = 60;
10
- export declare function buildContinuePrompt(summary: TodoDisplaySummary | null): string;
11
- /**
12
- * Maximum number of todo rows the panel shows before it starts scrolling.
13
- * Keeping the panel compact protects the composer; scrolling guarantees no
14
- * row is ever silently dropped.
15
- */
16
- export declare const TODO_PANEL_MAX_ROWS = 8;
17
- export interface TodoListRow {
18
- id: number;
19
- content: string;
20
- icon: string;
21
- iconColor: ColorInput;
22
- textColor: ColorInput;
23
- depth: number;
24
- status: TodoStatus;
25
- }
26
- /** Rendered prefix of an error detail row. */
27
- export declare const ERROR_PREFIX = "\u21B3 error: ";
28
- /** A renderable line: either a task row or its on-demand note row. */
29
- export type TodoListEntry = {
30
- kind: "row";
31
- row: TodoListRow;
32
- } | {
33
- kind: "error";
34
- row: TodoListRow;
35
- };
36
- /**
37
- * Flattens rows into renderable lines, inserting an error detail right below
38
- * an expanded error row (click to toggle).
39
- */
40
- export declare function buildTodoListEntries(rows: TodoListRow[], expandedIds: readonly number[]): TodoListEntry[];
41
- /**
42
- * Follow the most advanced active row: the last `in_progress` entry is the
43
- * task currently being executed. Note lines are skipped, they follow their
44
- * own row.
45
- */
46
- export declare function findActiveEntryIndex(entries: TodoListEntry[]): number;
47
- /**
48
- * Rendered width of a row: the indentation, the icon cell and the title.
49
- *
50
- * Rows must be sized explicitly, otherwise the scroll content never grows
51
- * wider than the viewport and horizontal scrolling has nothing to move.
52
- */
53
- export declare function rowWidth(row: {
54
- id?: number;
55
- content: string;
56
- depth: number;
57
- }): number;
58
- /** Rendered width of an expanded error line under its row. */
59
- export declare function errorRowWidth(row: {
60
- error: string;
61
- depth: number;
62
- }): number;
63
- export interface FollowScrollInput {
64
- currentTop: number;
65
- activeIndex: number;
66
- rowCount: number;
67
- viewportHeight: number;
68
- }
69
- /**
70
- * Scroll offset needed to reveal the active row, or `undefined` when nothing
71
- * should move (no active row, already visible, or the list fits).
72
- *
73
- * Kept pure so the follow behaviour is testable without a live renderer.
74
- */
75
- export declare function nextFollowScrollTop(input: FollowScrollInput): number | undefined;
76
- /**
77
- * Follow the most advanced active row: the last `in_progress` entry is the
78
- * task currently being executed.
79
- */
80
- export declare function findActiveRowIndex(rows: {
81
- status: TodoStatus;
82
- }[]): number;
83
- /**
84
- * Presentational, context-free todo list.
85
- *
86
- * The panel is deliberately chrome-free: no indicator row, and the horizontal
87
- * scrollbar stays hidden. Long titles never wrap (that would break the
88
- * one-line-per-row layout) — they are reached by scrolling left/right, and the
89
- * vertical list scrolls when it exceeds `TODO_PANEL_MAX_ROWS`. When a row is
90
- * `in_progress` the panel follows it so the active task is never out of sight.
91
- */
92
- export declare function TodoList(props: {
93
- rows: TodoListRow[];
94
- expandedIds?: readonly number[];
95
- scrollbarColor?: ColorInput;
96
- onToggleRow?: (id: number) => void;
97
- ref?: (el: ScrollBoxRenderable) => void;
98
- }): import("solid-js").JSX.Element;
99
2
  declare const _default: Plugin.Definition;
100
3
  export default _default;