@abhishek944/pi-tasks 0.2.0 → 0.4.0
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.
- package/README.md +1 -1
- package/dist/index.js +5 -6
- package/dist/markdown.d.ts +2 -0
- package/dist/markdown.js +23 -0
- package/dist/ui/panel.d.ts +3 -2
- package/dist/ui/panel.js +123 -49
- package/dist/ui/works-dashboard.d.ts +12 -2
- package/dist/ui/works-dashboard.js +104 -9
- package/docs/REFERENCE.md +2 -2
- package/docs/USAGE_GUIDE.md +6 -3
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ WorkUpdate workId="W1" status="completed"
|
|
|
35
35
|
|
|
36
36
|
Run `/works` to inspect full `workInfo` and `taskInfo` in an interactive overlay.
|
|
37
37
|
|
|
38
|
-
The panel defaults to the floating top-right layout.
|
|
38
|
+
The panel defaults to the floating top-right layout. In fullscreen TUI mode, its title bar has clickable Copy and Minimize/Maximize actions, and you can scroll overflowing rows directly with the mouse wheel. Open `/works` to inspect every row or copy from the keyboard. Use `/works-panel minimize` or `/works-panel maximize` when mouse input is unavailable. Switch layouts with `/works-panel floating`, `/works-panel widget`, or `/works-panel off`.
|
|
39
39
|
|
|
40
40
|
See [the usage guide](docs/USAGE_GUIDE.md) and [reference](docs/REFERENCE.md).
|
|
41
41
|
|
package/dist/index.js
CHANGED
|
@@ -11,18 +11,17 @@ export default function tasksExtension(pi) {
|
|
|
11
11
|
registerTrackingGuidance(pi);
|
|
12
12
|
registerWorksCommand(pi, state);
|
|
13
13
|
pi.registerCommand("works-panel", {
|
|
14
|
-
description: "Set the works panel mode
|
|
14
|
+
description: "Set the works panel display mode",
|
|
15
15
|
handler: async (args, ctx) => {
|
|
16
16
|
const requested = args.trim();
|
|
17
|
-
if (requested === "
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
ctx.ui.notify(error, "warning");
|
|
17
|
+
if (requested === "minimize" || requested === "maximize") {
|
|
18
|
+
panel?.setMinimized(requested === "minimize");
|
|
19
|
+
ctx.ui.notify(`Works panel: ${requested}d`, "info");
|
|
21
20
|
return;
|
|
22
21
|
}
|
|
23
22
|
const mode = requested === "floating" || requested === "widget" || requested === "off" ? requested : undefined;
|
|
24
23
|
if (!mode) {
|
|
25
|
-
ctx.ui.notify("Usage: /works-panel floating|widget|off|
|
|
24
|
+
ctx.ui.notify("Usage: /works-panel floating|widget|off|minimize|maximize", "info");
|
|
26
25
|
return;
|
|
27
26
|
}
|
|
28
27
|
panel?.setMode(mode);
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { safeMultiline, safeSingleLine } from "./text.js";
|
|
2
|
+
export function formatWorksMarkdown(works) {
|
|
3
|
+
const lines = ["# Works and Todos", ""];
|
|
4
|
+
if (works.length === 0)
|
|
5
|
+
return `${lines.join("\n")}\n_No works or todos in this session._\n`;
|
|
6
|
+
for (const work of works) {
|
|
7
|
+
lines.push(`## ${work.workId} — ${escapeMarkdownInline(safeSingleLine(work.workName))}`, "", `**Status:** ${work.status}`, "", "### Details", "", markdownBody(work.workInfo), "", "### Todos", "");
|
|
8
|
+
if (work.tasks.length === 0) {
|
|
9
|
+
lines.push("_No todos._", "");
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
for (const todo of work.tasks) {
|
|
13
|
+
lines.push(`#### ${todo.taskId} — ${escapeMarkdownInline(safeSingleLine(todo.taskName))}`, "", `**Status:** ${todo.status}`, "", markdownBody(todo.taskInfo), "");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return `${lines.join("\n").trimEnd()}\n`;
|
|
17
|
+
}
|
|
18
|
+
function markdownBody(value) {
|
|
19
|
+
return safeMultiline(value).join("\n").trim() || "_No details provided._";
|
|
20
|
+
}
|
|
21
|
+
function escapeMarkdownInline(value) {
|
|
22
|
+
return value.replace(/([-\\`*_[\]{}()<>#+.!|])/g, "\\$1");
|
|
23
|
+
}
|
package/dist/ui/panel.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ExtensionUIContext, type Theme } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import type { TaskState } from "../state.js";
|
|
3
3
|
import type { TodoStatus, WorkStatus } from "../types.js";
|
|
4
4
|
export type TasksPanelMode = "floating" | "widget" | "off";
|
|
@@ -9,11 +9,12 @@ export declare class TasksPanelHost {
|
|
|
9
9
|
private handle;
|
|
10
10
|
private ui;
|
|
11
11
|
private mode;
|
|
12
|
+
private minimized;
|
|
12
13
|
constructor(state: TaskState);
|
|
13
14
|
attach(ui: ExtensionUIContext): void;
|
|
14
15
|
setMode(mode: TasksPanelMode): void;
|
|
15
16
|
getMode(): TasksPanelMode;
|
|
16
|
-
|
|
17
|
+
setMinimized(minimized: boolean): void;
|
|
17
18
|
update(): void;
|
|
18
19
|
hide(): void;
|
|
19
20
|
private applyMode;
|
package/dist/ui/panel.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { copyToClipboard } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
import { formatWorksMarkdown } from "../markdown.js";
|
|
4
|
+
import { safeSingleLine } from "../text.js";
|
|
2
5
|
const EMPTY_COMPONENT = { render: () => [], invalidate: () => { } };
|
|
3
6
|
export class TasksPanelHost {
|
|
4
7
|
state;
|
|
@@ -7,6 +10,7 @@ export class TasksPanelHost {
|
|
|
7
10
|
handle;
|
|
8
11
|
ui;
|
|
9
12
|
mode = "floating";
|
|
13
|
+
minimized = false;
|
|
10
14
|
constructor(state) {
|
|
11
15
|
this.state = state;
|
|
12
16
|
}
|
|
@@ -23,18 +27,10 @@ export class TasksPanelHost {
|
|
|
23
27
|
getMode() {
|
|
24
28
|
return this.mode;
|
|
25
29
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return "The Works panel is not available.";
|
|
31
|
-
const columns = this.tui.terminal.columns || process.stdout.columns || 0;
|
|
32
|
-
const rows = this.tui.terminal.rows || process.stdout.rows || 0;
|
|
33
|
-
if (columns < 90 || rows < 18)
|
|
34
|
-
return "The terminal is too small to browse the Works panel.";
|
|
35
|
-
this.handle.focus();
|
|
36
|
-
this.tui.requestRender();
|
|
37
|
-
return undefined;
|
|
30
|
+
setMinimized(minimized) {
|
|
31
|
+
this.minimized = minimized;
|
|
32
|
+
this.panel?.setMinimized(minimized);
|
|
33
|
+
this.tui?.requestRender();
|
|
38
34
|
}
|
|
39
35
|
update() {
|
|
40
36
|
this.panel?.invalidate();
|
|
@@ -55,14 +51,18 @@ export class TasksPanelHost {
|
|
|
55
51
|
if (this.mode === "widget") {
|
|
56
52
|
ui.setWidget("pi-tasks-panel", (tui, theme) => {
|
|
57
53
|
this.tui = tui;
|
|
58
|
-
this.panel = new TasksPanel(tui, this.state, theme, "widget")
|
|
54
|
+
this.panel = new TasksPanel(tui, this.state, theme, "widget", this.minimized, (minimized) => {
|
|
55
|
+
this.minimized = minimized;
|
|
56
|
+
}, (message, type) => ui.notify(message, type));
|
|
59
57
|
return this.panel;
|
|
60
58
|
});
|
|
61
59
|
return;
|
|
62
60
|
}
|
|
63
61
|
ui.setWidget("pi-tasks-panel-host", (tui, theme) => {
|
|
64
62
|
this.tui = tui;
|
|
65
|
-
this.panel = new TasksPanel(tui, this.state, theme, "floating", () =>
|
|
63
|
+
this.panel = new TasksPanel(tui, this.state, theme, "floating", this.minimized, (minimized) => {
|
|
64
|
+
this.minimized = minimized;
|
|
65
|
+
}, (message, type) => ui.notify(message, type));
|
|
66
66
|
this.handle = tui.showOverlay(this.panel, {
|
|
67
67
|
anchor: "top-right",
|
|
68
68
|
width: "42%",
|
|
@@ -89,17 +89,24 @@ class TasksPanel {
|
|
|
89
89
|
state;
|
|
90
90
|
theme;
|
|
91
91
|
placement;
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
minimized;
|
|
93
|
+
onMinimizedChange;
|
|
94
|
+
notify;
|
|
94
95
|
scrollOffset = 0;
|
|
95
96
|
pageSize = 1;
|
|
96
97
|
contentLength = 0;
|
|
97
|
-
|
|
98
|
+
followTail = true;
|
|
99
|
+
copying = false;
|
|
100
|
+
copyHitRegion;
|
|
101
|
+
toggleHitRegion;
|
|
102
|
+
constructor(tui, state, theme, placement, minimized, onMinimizedChange, notify) {
|
|
98
103
|
this.tui = tui;
|
|
99
104
|
this.state = state;
|
|
100
105
|
this.theme = theme;
|
|
101
106
|
this.placement = placement;
|
|
102
|
-
this.
|
|
107
|
+
this.minimized = minimized;
|
|
108
|
+
this.onMinimizedChange = onMinimizedChange;
|
|
109
|
+
this.notify = notify;
|
|
103
110
|
}
|
|
104
111
|
render(width) {
|
|
105
112
|
if (width < 38)
|
|
@@ -108,6 +115,14 @@ class TasksPanel {
|
|
|
108
115
|
const boxWidth = this.placement === "floating" ? width : Math.min(54, Math.max(38, Math.floor(width * 0.44)));
|
|
109
116
|
const innerWidth = boxWidth - 2;
|
|
110
117
|
const leftPad = this.placement === "widget" ? " ".repeat(Math.max(0, width - boxWidth)) : "";
|
|
118
|
+
if (this.minimized) {
|
|
119
|
+
const header = this.renderHeader("Works", innerWidth, leftPad.length);
|
|
120
|
+
return [
|
|
121
|
+
border(innerWidth, "top", this.theme),
|
|
122
|
+
frame(header, innerWidth, this.theme),
|
|
123
|
+
border(innerWidth, "bottom", this.theme),
|
|
124
|
+
].map((line) => `${leftPad}${line}`);
|
|
125
|
+
}
|
|
111
126
|
const content = [];
|
|
112
127
|
if (works.length === 0)
|
|
113
128
|
content.push(this.theme.fg("muted", "No works yet."));
|
|
@@ -120,56 +135,115 @@ class TasksPanel {
|
|
|
120
135
|
this.contentLength = content.length;
|
|
121
136
|
const terminalRows = this.tui.terminal.rows || process.stdout.rows || 30;
|
|
122
137
|
this.pageSize = this.placement === "widget" ? Math.max(1, content.length) : Math.max(1, Math.floor(terminalRows * 0.48) - 4);
|
|
123
|
-
this.
|
|
138
|
+
if (this.placement === "widget") {
|
|
139
|
+
this.scrollOffset = 0;
|
|
140
|
+
this.followTail = true;
|
|
141
|
+
}
|
|
142
|
+
else if (this.followTail) {
|
|
143
|
+
this.scrollOffset = this.maxScrollOffset();
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
this.clampScrollOffset();
|
|
147
|
+
}
|
|
124
148
|
const shown = content.slice(this.scrollOffset, this.scrollOffset + this.pageSize);
|
|
125
|
-
const hasOverflow = content.length >
|
|
149
|
+
const hasOverflow = content.length > this.pageSize;
|
|
126
150
|
const range = `${this.scrollOffset + 1}–${this.scrollOffset + shown.length}/${content.length}`;
|
|
127
151
|
let title = "Works";
|
|
128
|
-
if (this.placement === "floating" &&
|
|
129
|
-
title += this.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
title += " · Esc to return";
|
|
152
|
+
if (this.placement === "floating" && hasOverflow) {
|
|
153
|
+
title += this.tui.mode === "fullscreen"
|
|
154
|
+
? ` · ${range} · wheel to scroll`
|
|
155
|
+
: ` · ${range} · latest · /works for all`;
|
|
133
156
|
}
|
|
157
|
+
const header = this.renderHeader(title, innerWidth, leftPad.length);
|
|
134
158
|
const lines = [
|
|
135
159
|
border(innerWidth, "top", this.theme),
|
|
136
|
-
frame(
|
|
160
|
+
frame(header, innerWidth, this.theme),
|
|
137
161
|
rule(innerWidth, this.theme),
|
|
138
162
|
...shown.map((line) => frame(line, innerWidth, this.theme)),
|
|
139
163
|
border(innerWidth, "bottom", this.theme),
|
|
140
164
|
];
|
|
141
165
|
return lines.map((line) => `${leftPad}${line}`);
|
|
142
166
|
}
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
this.
|
|
146
|
-
|
|
147
|
-
|
|
167
|
+
handleMouse(event) {
|
|
168
|
+
if (event.type === "click" && event.button === "left" && event.y === 1) {
|
|
169
|
+
if (this.isHit(event.x, this.toggleHitRegion)) {
|
|
170
|
+
this.setMinimized(!this.minimized);
|
|
171
|
+
return { handled: true, render: true };
|
|
172
|
+
}
|
|
173
|
+
if (this.isHit(event.x, this.copyHitRegion)) {
|
|
174
|
+
void this.copyAllAsMarkdown();
|
|
175
|
+
return { handled: true, render: true };
|
|
176
|
+
}
|
|
148
177
|
}
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
else if (matchesKey(data, Key.pageUp))
|
|
154
|
-
this.scrollBy(-this.pageSize);
|
|
155
|
-
else if (matchesKey(data, Key.pageDown))
|
|
156
|
-
this.scrollBy(this.pageSize);
|
|
157
|
-
else if (matchesKey(data, Key.home))
|
|
158
|
-
this.scrollTo(0);
|
|
159
|
-
else if (matchesKey(data, Key.end))
|
|
160
|
-
this.scrollTo(this.contentLength);
|
|
178
|
+
if (this.minimized || this.placement !== "floating" || event.type !== "wheel" || !event.wheelDelta)
|
|
179
|
+
return undefined;
|
|
180
|
+
const changed = this.scrollBy(event.wheelDelta < 0 ? -1 : 1);
|
|
181
|
+
return { handled: true, render: changed };
|
|
161
182
|
}
|
|
162
183
|
invalidate() { }
|
|
184
|
+
setMinimized(minimized) {
|
|
185
|
+
if (this.minimized === minimized)
|
|
186
|
+
return;
|
|
187
|
+
this.minimized = minimized;
|
|
188
|
+
this.onMinimizedChange(minimized);
|
|
189
|
+
this.tui.requestRender();
|
|
190
|
+
}
|
|
191
|
+
renderHeader(titleText, width, leftPadWidth) {
|
|
192
|
+
const title = this.theme.fg("accent", this.theme.bold(titleText));
|
|
193
|
+
const copyAction = this.copying
|
|
194
|
+
? this.theme.fg("dim", "[Copying…]")
|
|
195
|
+
: this.theme.fg("accent", this.theme.bold("[Copy]"));
|
|
196
|
+
const toggleLabel = this.minimized ? "[Maximize]" : "[Minimize]";
|
|
197
|
+
const toggleAction = this.theme.fg("accent", this.theme.bold(toggleLabel));
|
|
198
|
+
const actionsWidth = visibleWidth(copyAction) + 1 + visibleWidth(toggleAction);
|
|
199
|
+
const titleWidth = Math.max(0, width - actionsWidth - 1);
|
|
200
|
+
const shownTitle = truncateToWidth(title, titleWidth, "");
|
|
201
|
+
const gap = " ".repeat(Math.max(1, width - visibleWidth(shownTitle) - actionsWidth));
|
|
202
|
+
const copyStart = leftPadWidth + 1 + visibleWidth(shownTitle) + gap.length;
|
|
203
|
+
this.copyHitRegion = { start: copyStart, end: copyStart + visibleWidth(copyAction) };
|
|
204
|
+
const toggleStart = this.copyHitRegion.end + 1;
|
|
205
|
+
this.toggleHitRegion = { start: toggleStart, end: toggleStart + visibleWidth(toggleAction) };
|
|
206
|
+
return `${shownTitle}${gap}${copyAction} ${toggleAction}`;
|
|
207
|
+
}
|
|
208
|
+
isHit(x, region) {
|
|
209
|
+
return region !== undefined && x >= region.start && x < region.end;
|
|
210
|
+
}
|
|
211
|
+
async copyAllAsMarkdown() {
|
|
212
|
+
if (this.copying)
|
|
213
|
+
return;
|
|
214
|
+
this.copying = true;
|
|
215
|
+
this.tui.requestRender();
|
|
216
|
+
const works = this.state.listWorks();
|
|
217
|
+
try {
|
|
218
|
+
await copyToClipboard(formatWorksMarkdown(works));
|
|
219
|
+
const todoCount = works.reduce((total, work) => total + work.tasks.length, 0);
|
|
220
|
+
this.notify(`Copied ${works.length} work${works.length === 1 ? "" : "s"} and ${todoCount} todo${todoCount === 1 ? "" : "s"} as Markdown.`, "info");
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
const reason = error instanceof Error && error.message ? ` ${safeSingleLine(error.message)}` : "";
|
|
224
|
+
this.notify(`Could not copy works and todos.${reason}`, "error");
|
|
225
|
+
}
|
|
226
|
+
finally {
|
|
227
|
+
this.copying = false;
|
|
228
|
+
this.tui.requestRender();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
163
231
|
scrollBy(lines) {
|
|
164
|
-
this.scrollTo(this.scrollOffset + lines);
|
|
232
|
+
return this.scrollTo(this.scrollOffset + lines);
|
|
165
233
|
}
|
|
166
234
|
scrollTo(offset) {
|
|
167
|
-
this.scrollOffset
|
|
168
|
-
this.
|
|
169
|
-
this.
|
|
235
|
+
const previous = this.scrollOffset;
|
|
236
|
+
this.scrollOffset = Math.max(0, Math.min(offset, this.maxScrollOffset()));
|
|
237
|
+
this.followTail = this.scrollOffset >= this.maxScrollOffset();
|
|
238
|
+
return this.scrollOffset !== previous;
|
|
170
239
|
}
|
|
171
240
|
clampScrollOffset() {
|
|
172
|
-
this.scrollOffset = Math.max(0, Math.min(this.scrollOffset,
|
|
241
|
+
this.scrollOffset = Math.max(0, Math.min(this.scrollOffset, this.maxScrollOffset()));
|
|
242
|
+
if (this.scrollOffset >= this.maxScrollOffset())
|
|
243
|
+
this.followTail = true;
|
|
244
|
+
}
|
|
245
|
+
maxScrollOffset() {
|
|
246
|
+
return Math.max(0, this.contentLength - this.pageSize);
|
|
173
247
|
}
|
|
174
248
|
}
|
|
175
249
|
function workSummaryLine(status, name, count, width, theme) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type Component, type Focusable, type TUI } from "@earendil-works/pi-tui";
|
|
1
|
+
import { type KeybindingsManager, type Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { type Component, type Focusable, type TUI, type TuiMouseEvent, type TuiMouseEventResult } from "@earendil-works/pi-tui";
|
|
3
3
|
import type { TaskState } from "../state.js";
|
|
4
4
|
export declare class WorksDashboard implements Component, Focusable {
|
|
5
5
|
private readonly tui;
|
|
@@ -14,11 +14,17 @@ export declare class WorksDashboard implements Component, Focusable {
|
|
|
14
14
|
private detailPageSize;
|
|
15
15
|
private detailsVisible;
|
|
16
16
|
private message;
|
|
17
|
+
private messageColor;
|
|
18
|
+
private copying;
|
|
19
|
+
private minimized;
|
|
20
|
+
private copyHitRegion;
|
|
21
|
+
private toggleHitRegion;
|
|
17
22
|
private disposed;
|
|
18
23
|
private readonly refreshTimer;
|
|
19
24
|
constructor(tui: TUI, theme: Theme, keybindings: KeybindingsManager, state: TaskState, close: () => void);
|
|
20
25
|
render(width: number): string[];
|
|
21
26
|
handleInput(data: string): void;
|
|
27
|
+
handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined;
|
|
22
28
|
invalidate(): void;
|
|
23
29
|
dispose(): void;
|
|
24
30
|
private items;
|
|
@@ -27,5 +33,9 @@ export declare class WorksDashboard implements Component, Focusable {
|
|
|
27
33
|
private keepSelectionVisible;
|
|
28
34
|
private renderRow;
|
|
29
35
|
private renderDetails;
|
|
36
|
+
private renderHeader;
|
|
37
|
+
private toggleMinimized;
|
|
38
|
+
private isHit;
|
|
39
|
+
private copyAllAsMarkdown;
|
|
30
40
|
private renderFooter;
|
|
31
41
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { copyToClipboard } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
|
|
3
|
+
import { formatWorksMarkdown } from "../markdown.js";
|
|
2
4
|
import { safeMultiline, safeSingleLine } from "../text.js";
|
|
3
5
|
import { border, frame, rule, todoIcon, workIcon } from "./panel.js";
|
|
4
6
|
const CHROME_LINES = 8;
|
|
@@ -15,6 +17,11 @@ export class WorksDashboard {
|
|
|
15
17
|
detailPageSize = 1;
|
|
16
18
|
detailsVisible = true;
|
|
17
19
|
message = "Ready. Select an item; Escape closes.";
|
|
20
|
+
messageColor = "warning";
|
|
21
|
+
copying = false;
|
|
22
|
+
minimized = false;
|
|
23
|
+
copyHitRegion;
|
|
24
|
+
toggleHitRegion;
|
|
18
25
|
disposed = false;
|
|
19
26
|
refreshTimer;
|
|
20
27
|
constructor(tui, theme, keybindings, state, close) {
|
|
@@ -32,12 +39,20 @@ export class WorksDashboard {
|
|
|
32
39
|
render(width) {
|
|
33
40
|
const dialogWidth = Math.max(1, width);
|
|
34
41
|
const innerWidth = Math.max(1, dialogWidth - 2);
|
|
35
|
-
const
|
|
42
|
+
const works = this.state.listWorks();
|
|
43
|
+
const todos = works.flatMap((work) => work.tasks);
|
|
44
|
+
const header = this.renderHeader(innerWidth, works.length, todos.length);
|
|
45
|
+
if (this.minimized) {
|
|
46
|
+
return [
|
|
47
|
+
border(innerWidth, "top", this.theme),
|
|
48
|
+
frame(header, innerWidth, this.theme),
|
|
49
|
+
border(innerWidth, "bottom", this.theme),
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
const items = this.items(works);
|
|
36
53
|
this.syncSelection(items);
|
|
37
54
|
const terminalRows = this.tui.terminal.rows || process.stdout.rows || 30;
|
|
38
55
|
const dialogHeight = Math.max(8, Math.min(36, Math.floor(terminalRows * 0.82)));
|
|
39
|
-
const works = this.state.listWorks();
|
|
40
|
-
const todos = works.flatMap((work) => work.tasks);
|
|
41
56
|
const activeWorks = works.filter((work) => work.status === "active").length;
|
|
42
57
|
const completedTodos = todos.filter((todo) => todo.status === "completed").length;
|
|
43
58
|
const summary = `${activeWorks}/${works.length} works active · ${completedTodos}/${todos.length} todos completed · session scoped`;
|
|
@@ -52,12 +67,12 @@ export class WorksDashboard {
|
|
|
52
67
|
rows.push("");
|
|
53
68
|
return [
|
|
54
69
|
border(innerWidth, "top", this.theme),
|
|
55
|
-
frame(
|
|
70
|
+
frame(header, innerWidth, this.theme),
|
|
56
71
|
frame(this.theme.fg("dim", summary), innerWidth, this.theme),
|
|
57
72
|
rule(innerWidth, this.theme),
|
|
58
73
|
...[...rows, ...details].map((line) => frame(line, innerWidth, this.theme)),
|
|
59
74
|
rule(innerWidth, this.theme),
|
|
60
|
-
frame(this.theme.fg(
|
|
75
|
+
frame(this.theme.fg(this.messageColor, truncateToWidth(this.message, innerWidth, "")), innerWidth, this.theme),
|
|
61
76
|
frame(this.renderFooter(innerWidth), innerWidth, this.theme),
|
|
62
77
|
border(innerWidth, "bottom", this.theme),
|
|
63
78
|
];
|
|
@@ -72,6 +87,17 @@ export class WorksDashboard {
|
|
|
72
87
|
this.close();
|
|
73
88
|
return;
|
|
74
89
|
}
|
|
90
|
+
if (matchesKey(data, "c")) {
|
|
91
|
+
void this.copyAllAsMarkdown();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (matchesKey(data, "m")) {
|
|
95
|
+
this.toggleMinimized();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (this.minimized)
|
|
99
|
+
return;
|
|
100
|
+
this.messageColor = "warning";
|
|
75
101
|
if (this.keybindings.matches(data, "tui.select.up")) {
|
|
76
102
|
this.select(items, index - 1);
|
|
77
103
|
}
|
|
@@ -93,6 +119,19 @@ export class WorksDashboard {
|
|
|
93
119
|
}
|
|
94
120
|
this.tui.requestRender();
|
|
95
121
|
}
|
|
122
|
+
handleMouse(event) {
|
|
123
|
+
if (this.disposed || event.type !== "click" || event.button !== "left" || event.y !== 1)
|
|
124
|
+
return undefined;
|
|
125
|
+
if (this.isHit(event.x, this.toggleHitRegion)) {
|
|
126
|
+
this.toggleMinimized();
|
|
127
|
+
return { handled: true, focus: true, render: true };
|
|
128
|
+
}
|
|
129
|
+
if (this.isHit(event.x, this.copyHitRegion)) {
|
|
130
|
+
void this.copyAllAsMarkdown();
|
|
131
|
+
return { handled: true, focus: true, render: true };
|
|
132
|
+
}
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
96
135
|
invalidate() { }
|
|
97
136
|
dispose() {
|
|
98
137
|
if (this.disposed)
|
|
@@ -100,9 +139,9 @@ export class WorksDashboard {
|
|
|
100
139
|
this.disposed = true;
|
|
101
140
|
clearInterval(this.refreshTimer);
|
|
102
141
|
}
|
|
103
|
-
items() {
|
|
142
|
+
items(works = this.state.listWorks()) {
|
|
104
143
|
const items = [];
|
|
105
|
-
for (const work of
|
|
144
|
+
for (const work of works) {
|
|
106
145
|
items.push({ key: `work:${work.workId}`, kind: "work", work });
|
|
107
146
|
for (const todo of work.tasks)
|
|
108
147
|
items.push({ key: `todo:${todo.taskId}`, kind: "todo", todo, workName: work.workName });
|
|
@@ -161,8 +200,64 @@ export class WorksDashboard {
|
|
|
161
200
|
...shown,
|
|
162
201
|
].slice(0, budget);
|
|
163
202
|
}
|
|
203
|
+
renderHeader(width, workCount, todoCount) {
|
|
204
|
+
const titleText = this.minimized
|
|
205
|
+
? `Works (${workCount} work${workCount === 1 ? "" : "s"}, ${todoCount} todo${todoCount === 1 ? "" : "s"})`
|
|
206
|
+
: "Works · session work and todos";
|
|
207
|
+
const title = this.theme.fg("accent", this.theme.bold(titleText));
|
|
208
|
+
const copyAction = this.copying
|
|
209
|
+
? this.theme.fg("dim", "[Copying…]")
|
|
210
|
+
: this.theme.fg("accent", this.theme.bold("[C Copy]"));
|
|
211
|
+
const toggleLabel = this.minimized ? "[M Maximize]" : "[M Minimize]";
|
|
212
|
+
const toggleAction = this.theme.fg("accent", this.theme.bold(toggleLabel));
|
|
213
|
+
const actionsWidth = visibleWidth(copyAction) + 1 + visibleWidth(toggleAction);
|
|
214
|
+
const titleWidth = Math.max(0, width - actionsWidth - 1);
|
|
215
|
+
const shownTitle = truncateToWidth(title, titleWidth, "");
|
|
216
|
+
const gap = " ".repeat(Math.max(1, width - visibleWidth(shownTitle) - actionsWidth));
|
|
217
|
+
const copyStart = 1 + visibleWidth(shownTitle) + gap.length;
|
|
218
|
+
this.copyHitRegion = { start: copyStart, end: copyStart + visibleWidth(copyAction) };
|
|
219
|
+
const toggleStart = this.copyHitRegion.end + 1;
|
|
220
|
+
this.toggleHitRegion = { start: toggleStart, end: toggleStart + visibleWidth(toggleAction) };
|
|
221
|
+
return `${shownTitle}${gap}${copyAction} ${toggleAction}`;
|
|
222
|
+
}
|
|
223
|
+
toggleMinimized() {
|
|
224
|
+
this.minimized = !this.minimized;
|
|
225
|
+
if (!this.minimized) {
|
|
226
|
+
this.message = "Dashboard maximized.";
|
|
227
|
+
this.messageColor = "warning";
|
|
228
|
+
}
|
|
229
|
+
this.tui.requestRender();
|
|
230
|
+
}
|
|
231
|
+
isHit(x, region) {
|
|
232
|
+
return region !== undefined && x >= region.start && x < region.end;
|
|
233
|
+
}
|
|
234
|
+
async copyAllAsMarkdown() {
|
|
235
|
+
if (this.copying)
|
|
236
|
+
return;
|
|
237
|
+
this.copying = true;
|
|
238
|
+
this.message = "Copying all works and todos as Markdown…";
|
|
239
|
+
this.messageColor = "warning";
|
|
240
|
+
this.tui.requestRender();
|
|
241
|
+
const works = this.state.listWorks();
|
|
242
|
+
try {
|
|
243
|
+
await copyToClipboard(formatWorksMarkdown(works));
|
|
244
|
+
const todoCount = works.reduce((total, work) => total + work.tasks.length, 0);
|
|
245
|
+
this.message = `Copied ${works.length} work${works.length === 1 ? "" : "s"} and ${todoCount} todo${todoCount === 1 ? "" : "s"} as Markdown.`;
|
|
246
|
+
this.messageColor = "success";
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
const reason = error instanceof Error && error.message ? ` ${safeSingleLine(error.message)}` : "";
|
|
250
|
+
this.message = `Could not copy works and todos.${reason}`;
|
|
251
|
+
this.messageColor = "error";
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
this.copying = false;
|
|
255
|
+
if (!this.disposed)
|
|
256
|
+
this.tui.requestRender();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
164
259
|
renderFooter(width) {
|
|
165
|
-
const text = "configured ↑/↓ select · PgUp/PgDn scroll details · confirm toggles · cancel closes";
|
|
260
|
+
const text = "C copy all · M minimize · configured ↑/↓ select · PgUp/PgDn scroll details · confirm toggles · cancel closes";
|
|
166
261
|
return truncateToWidth(this.theme.fg("muted", text), width, "");
|
|
167
262
|
}
|
|
168
263
|
}
|
package/docs/REFERENCE.md
CHANGED
|
@@ -30,6 +30,6 @@ The guidance is not added when the tracking tools have been removed from the act
|
|
|
30
30
|
|
|
31
31
|
## Interfaces
|
|
32
32
|
|
|
33
|
-
The compact panel defaults to a non-capturing floating overlay anchored at the top-right. It shows work and todo names, status icons, completion counts, and a visible row range when content exceeds the terminal-aware viewport. It hides on terminals narrower than 90 columns or shorter than 18 rows. `/works-panel
|
|
33
|
+
The compact panel defaults to a non-capturing floating overlay anchored at the top-right. It shows work and todo names, status icons, completion counts, and a visible row range when content exceeds the terminal-aware viewport. It hides on terminals narrower than 90 columns or shorter than 18 rows. In fullscreen TUI mode, its title-bar Copy action exports every work and nested todo as Markdown, while Minimize collapses the panel to a restorable title bar that keeps Copy and Maximize available. `/works-panel minimize` and `/works-panel maximize` provide a keyboard-command path and preserve the collapsed state when switching between floating and widget layouts. Overflow starts at the newest rows and follows newly added tail rows until the user scrolls upward. Mouse-wheel events over the expanded floating panel scroll it directly without taking keyboard focus; regular terminal mode shows the newest rows and uses `/works` for complete browsing and copying. Because Pi treats any persistent overlay as active, the floating mode can block display-mode changes. `/works-panel widget` switches to a right-aligned widget above the editor, renders all rows, and retains the title actions, while `/works-panel off` hides it.
|
|
34
34
|
|
|
35
|
-
`/works` opens a top-centered detailed overlay. Configured selection keys choose records, configured Page Up and Page Down keys scroll long details, the configured confirmation key toggles details, and the configured cancel key closes it.
|
|
35
|
+
`/works` opens a top-centered detailed overlay. Its top-right Copy action uses `c` to copy every work and nested todo to the system clipboard as Markdown. Its Minimize action uses `m` to collapse the overlay to a framed top bar containing live total work and todo counts, Copy, and a Maximize action; activating Maximize restores the full dashboard. In fullscreen TUI mode, Copy and Minimize/Maximize also respond to left clicks. Configured selection keys choose records, configured Page Up and Page Down keys scroll long details, the configured confirmation key toggles details, and the configured cancel key closes it.
|
package/docs/USAGE_GUIDE.md
CHANGED
|
@@ -37,12 +37,15 @@ TodoDelete taskId="T1"
|
|
|
37
37
|
|
|
38
38
|
## TUI
|
|
39
39
|
|
|
40
|
-
The panel defaults to a floating top-right layout and does not take keyboard focus. It hides on small terminals.
|
|
40
|
+
The panel defaults to a floating top-right layout and does not take keyboard focus. It hides on small terminals. In fullscreen TUI mode, click Copy in its title bar to copy every work and todo as Markdown, or click Minimize to collapse the panel to a small title bar. Copy remains available while minimized, and Maximize restores the rows. When more rows exist than fit, the floating panel starts at the newest rows; move the mouse over it and use the wheel to scroll older or newer rows without taking focus from the editor. In regular terminal mode, open `/works` to browse and copy the complete list.
|
|
41
41
|
|
|
42
|
-
Use `/works-panel widget` for a right-aligned layout above the editor that renders every row, `/works-panel floating` to return to the floating layout, or `/works-panel off` to hide it.
|
|
42
|
+
Use `/works-panel minimize` or `/works-panel maximize` when mouse input is unavailable. Use `/works-panel widget` for a right-aligned layout above the editor that renders every row and retains the clickable title actions, `/works-panel floating` to return to the floating layout, or `/works-panel off` to hide it.
|
|
43
43
|
|
|
44
|
-
Run `/works` for full details
|
|
44
|
+
Run `/works` for full details. Its top bar includes Copy and Minimize actions. In fullscreen TUI mode, click Minimize to collapse the dashboard to a top bar showing the current work and todo totals; click Maximize to restore it. The actions also have keyboard shortcuts that work in regular terminal mode.
|
|
45
45
|
|
|
46
|
+
- `c`: copy all works and todos as Markdown
|
|
47
|
+
- `m`: minimize or maximize the dashboard
|
|
48
|
+
- Fullscreen left click: activate Copy, Minimize, or Maximize
|
|
46
49
|
- Configured Up/Down keys: select
|
|
47
50
|
- Configured Page Up/Page Down keys: scroll long details
|
|
48
51
|
- Configured confirmation key: show or hide detailed information
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abhishek944/pi-tasks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Session-scoped work and todo tracking for Pi.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"./package.json": "./package.json"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@earendil-works/pi-coding-agent": ">=0.
|
|
35
|
-
"@earendil-works/pi-tui": "
|
|
34
|
+
"@earendil-works/pi-coding-agent": ">=0.85.1",
|
|
35
|
+
"@earendil-works/pi-tui": ">=0.85.1",
|
|
36
36
|
"@earendil-works/pi-ai": "*",
|
|
37
37
|
"typebox": "*"
|
|
38
38
|
},
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@biomejs/biome": "^2.4.13",
|
|
49
|
-
"@earendil-works/pi-ai": "0.
|
|
50
|
-
"@earendil-works/pi-coding-agent": "0.
|
|
51
|
-
"@earendil-works/pi-tui": "0.
|
|
49
|
+
"@earendil-works/pi-ai": "0.85.1",
|
|
50
|
+
"@earendil-works/pi-coding-agent": "0.85.1",
|
|
51
|
+
"@earendil-works/pi-tui": "0.85.1",
|
|
52
52
|
"@types/node": "^26.1.2",
|
|
53
53
|
"typebox": "1.3.16",
|
|
54
54
|
"typescript": "^7.0.2"
|