@abhishek944/pi-tasks 0.3.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 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. When its rows overflow, it shows the newest rows; in fullscreen TUI mode, scroll directly over the panel with the mouse wheel. Open `/works` to inspect every row in regular terminal mode. Switch layouts at runtime with `/works-panel floating`, `/works-panel widget`, or `/works-panel off`.
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
@@ -14,9 +14,14 @@ export default function tasksExtension(pi) {
14
14
  description: "Set the works panel display mode",
15
15
  handler: async (args, ctx) => {
16
16
  const requested = args.trim();
17
+ if (requested === "minimize" || requested === "maximize") {
18
+ panel?.setMinimized(requested === "minimize");
19
+ ctx.ui.notify(`Works panel: ${requested}d`, "info");
20
+ return;
21
+ }
17
22
  const mode = requested === "floating" || requested === "widget" || requested === "off" ? requested : undefined;
18
23
  if (!mode) {
19
- ctx.ui.notify("Usage: /works-panel floating|widget|off", "info");
24
+ ctx.ui.notify("Usage: /works-panel floating|widget|off|minimize|maximize", "info");
20
25
  return;
21
26
  }
22
27
  panel?.setMode(mode);
@@ -0,0 +1,2 @@
1
+ import type { WorkWithTodos } from "./types.js";
2
+ export declare function formatWorksMarkdown(works: WorkWithTodos[]): string;
@@ -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
+ }
@@ -1,4 +1,4 @@
1
- import type { ExtensionUIContext, Theme } from "@earendil-works/pi-coding-agent";
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,10 +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;
17
+ setMinimized(minimized: boolean): void;
16
18
  update(): void;
17
19
  hide(): void;
18
20
  private applyMode;
package/dist/ui/panel.js CHANGED
@@ -1,4 +1,7 @@
1
+ import { copyToClipboard } from "@earendil-works/pi-coding-agent";
1
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,6 +27,11 @@ export class TasksPanelHost {
23
27
  getMode() {
24
28
  return this.mode;
25
29
  }
30
+ setMinimized(minimized) {
31
+ this.minimized = minimized;
32
+ this.panel?.setMinimized(minimized);
33
+ this.tui?.requestRender();
34
+ }
26
35
  update() {
27
36
  this.panel?.invalidate();
28
37
  this.tui?.requestRender();
@@ -42,14 +51,18 @@ export class TasksPanelHost {
42
51
  if (this.mode === "widget") {
43
52
  ui.setWidget("pi-tasks-panel", (tui, theme) => {
44
53
  this.tui = tui;
45
- 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));
46
57
  return this.panel;
47
58
  });
48
59
  return;
49
60
  }
50
61
  ui.setWidget("pi-tasks-panel-host", (tui, theme) => {
51
62
  this.tui = tui;
52
- 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));
53
66
  this.handle = tui.showOverlay(this.panel, {
54
67
  anchor: "top-right",
55
68
  width: "42%",
@@ -76,15 +89,24 @@ class TasksPanel {
76
89
  state;
77
90
  theme;
78
91
  placement;
92
+ minimized;
93
+ onMinimizedChange;
94
+ notify;
79
95
  scrollOffset = 0;
80
96
  pageSize = 1;
81
97
  contentLength = 0;
82
98
  followTail = true;
83
- constructor(tui, state, theme, placement) {
99
+ copying = false;
100
+ copyHitRegion;
101
+ toggleHitRegion;
102
+ constructor(tui, state, theme, placement, minimized, onMinimizedChange, notify) {
84
103
  this.tui = tui;
85
104
  this.state = state;
86
105
  this.theme = theme;
87
106
  this.placement = placement;
107
+ this.minimized = minimized;
108
+ this.onMinimizedChange = onMinimizedChange;
109
+ this.notify = notify;
88
110
  }
89
111
  render(width) {
90
112
  if (width < 38)
@@ -93,6 +115,14 @@ class TasksPanel {
93
115
  const boxWidth = this.placement === "floating" ? width : Math.min(54, Math.max(38, Math.floor(width * 0.44)));
94
116
  const innerWidth = boxWidth - 2;
95
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
+ }
96
126
  const content = [];
97
127
  if (works.length === 0)
98
128
  content.push(this.theme.fg("muted", "No works yet."));
@@ -124,9 +154,10 @@ class TasksPanel {
124
154
  ? ` · ${range} · wheel to scroll`
125
155
  : ` · ${range} · latest · /works for all`;
126
156
  }
157
+ const header = this.renderHeader(title, innerWidth, leftPad.length);
127
158
  const lines = [
128
159
  border(innerWidth, "top", this.theme),
129
- frame(this.theme.fg("accent", this.theme.bold(title)), innerWidth, this.theme),
160
+ frame(header, innerWidth, this.theme),
130
161
  rule(innerWidth, this.theme),
131
162
  ...shown.map((line) => frame(line, innerWidth, this.theme)),
132
163
  border(innerWidth, "bottom", this.theme),
@@ -134,12 +165,69 @@ class TasksPanel {
134
165
  return lines.map((line) => `${leftPad}${line}`);
135
166
  }
136
167
  handleMouse(event) {
137
- if (this.placement !== "floating" || event.type !== "wheel" || !event.wheelDelta)
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
+ }
177
+ }
178
+ if (this.minimized || this.placement !== "floating" || event.type !== "wheel" || !event.wheelDelta)
138
179
  return undefined;
139
180
  const changed = this.scrollBy(event.wheelDelta < 0 ? -1 : 1);
140
181
  return { handled: true, render: changed };
141
182
  }
142
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
+ }
143
231
  scrollBy(lines) {
144
232
  return this.scrollTo(this.scrollOffset + lines);
145
233
  }
@@ -1,5 +1,6 @@
1
1
  import { copyToClipboard } from "@earendil-works/pi-coding-agent";
2
2
  import { matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
3
+ import { formatWorksMarkdown } from "../markdown.js";
3
4
  import { safeMultiline, safeSingleLine } from "../text.js";
4
5
  import { border, frame, rule, todoIcon, workIcon } from "./panel.js";
5
6
  const CHROME_LINES = 8;
@@ -260,25 +261,3 @@ export class WorksDashboard {
260
261
  return truncateToWidth(this.theme.fg("muted", text), width, "");
261
262
  }
262
263
  }
263
- function formatWorksMarkdown(works) {
264
- const lines = ["# Works and Todos", ""];
265
- if (works.length === 0)
266
- return `${lines.join("\n")}\n_No works or todos in this session._\n`;
267
- for (const work of works) {
268
- lines.push(`## ${work.workId} — ${escapeMarkdownInline(safeSingleLine(work.workName))}`, "", `**Status:** ${work.status}`, "", "### Details", "", markdownBody(work.workInfo), "", "### Todos", "");
269
- if (work.tasks.length === 0) {
270
- lines.push("_No todos._", "");
271
- continue;
272
- }
273
- for (const todo of work.tasks) {
274
- lines.push(`#### ${todo.taskId} — ${escapeMarkdownInline(safeSingleLine(todo.taskName))}`, "", `**Status:** ${todo.status}`, "", markdownBody(todo.taskInfo), "");
275
- }
276
- }
277
- return `${lines.join("\n").trimEnd()}\n`;
278
- }
279
- function markdownBody(value) {
280
- return safeMultiline(value).join("\n").trim() || "_No details provided._";
281
- }
282
- function escapeMarkdownInline(value) {
283
- return value.replace(/([-\\`*_[\]{}()<>#+.!|])/g, "\\$1");
284
- }
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. Overflow starts at the newest rows and follows newly added tail rows until the user scrolls upward. In fullscreen TUI mode, mouse-wheel events over the panel scroll it directly without taking keyboard focus; regular terminal mode shows the newest rows and uses `/works` for complete browsing. 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 and renders all rows, while `/works-panel off` hides it.
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
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.
@@ -37,9 +37,9 @@ 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. When more rows exist than fit, it starts at the newest rows. In fullscreen TUI mode, move the mouse over the panel and use the wheel to scroll older or newer rows without taking focus from the editor. In regular terminal mode, open `/works` to browse the complete list.
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
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abhishek944/pi-tasks",
3
- "version": "0.3.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",