@abhishek944/pi-tasks 0.1.0 → 0.2.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
@@ -17,7 +17,7 @@ The coordination model is intentionally small: a work is the overall outcome, a
17
17
  ## Install
18
18
 
19
19
  ```bash
20
- pi install npm:@abhishek944/pi-tasks@0.1.0
20
+ pi install npm:@abhishek944/pi-tasks@0.2.0
21
21
  ```
22
22
 
23
23
  Restart Pi or run `/reload`.
@@ -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. 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. When its rows overflow, run `/works-panel browse`, use Up/Down or Page Up/Page Down to scroll, and press Escape to return to the editor. Switch layouts at runtime 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,12 +11,18 @@ 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 to floating, widget, or off",
14
+ description: "Set the works panel mode or browse its rows",
15
15
  handler: async (args, ctx) => {
16
16
  const requested = args.trim();
17
+ if (requested === "browse") {
18
+ const error = panel?.browse();
19
+ if (error)
20
+ ctx.ui.notify(error, "warning");
21
+ return;
22
+ }
17
23
  const mode = requested === "floating" || requested === "widget" || requested === "off" ? requested : undefined;
18
24
  if (!mode) {
19
- ctx.ui.notify("Usage: /works-panel floating|widget|off", "info");
25
+ ctx.ui.notify("Usage: /works-panel floating|widget|off|browse", "info");
20
26
  return;
21
27
  }
22
28
  panel?.setMode(mode);
@@ -13,6 +13,7 @@ export declare class TasksPanelHost {
13
13
  attach(ui: ExtensionUIContext): void;
14
14
  setMode(mode: TasksPanelMode): void;
15
15
  getMode(): TasksPanelMode;
16
+ browse(): string | undefined;
16
17
  update(): void;
17
18
  hide(): void;
18
19
  private applyMode;
package/dist/ui/panel.js CHANGED
@@ -1,4 +1,4 @@
1
- import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
1
+ import { Key, matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
2
2
  const EMPTY_COMPONENT = { render: () => [], invalidate: () => { } };
3
3
  export class TasksPanelHost {
4
4
  state;
@@ -23,6 +23,19 @@ export class TasksPanelHost {
23
23
  getMode() {
24
24
  return this.mode;
25
25
  }
26
+ browse() {
27
+ if (this.mode !== "floating")
28
+ return "Use /works-panel floating before browsing the panel.";
29
+ if (!this.tui || !this.panel || !this.handle)
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;
38
+ }
26
39
  update() {
27
40
  this.panel?.invalidate();
28
41
  this.tui?.requestRender();
@@ -42,14 +55,14 @@ export class TasksPanelHost {
42
55
  if (this.mode === "widget") {
43
56
  ui.setWidget("pi-tasks-panel", (tui, theme) => {
44
57
  this.tui = tui;
45
- this.panel = new TasksPanel(this.state, theme, "widget");
58
+ this.panel = new TasksPanel(tui, this.state, theme, "widget");
46
59
  return this.panel;
47
60
  });
48
61
  return;
49
62
  }
50
63
  ui.setWidget("pi-tasks-panel-host", (tui, theme) => {
51
64
  this.tui = tui;
52
- this.panel = new TasksPanel(this.state, theme, "floating");
65
+ this.panel = new TasksPanel(tui, this.state, theme, "floating", () => this.handle?.unfocus());
53
66
  this.handle = tui.showOverlay(this.panel, {
54
67
  anchor: "top-right",
55
68
  width: "42%",
@@ -72,13 +85,21 @@ export class TasksPanelHost {
72
85
  }
73
86
  }
74
87
  class TasksPanel {
88
+ tui;
75
89
  state;
76
90
  theme;
77
91
  placement;
78
- constructor(state, theme, placement) {
92
+ releaseFocus;
93
+ focused = false;
94
+ scrollOffset = 0;
95
+ pageSize = 1;
96
+ contentLength = 0;
97
+ constructor(tui, state, theme, placement, releaseFocus) {
98
+ this.tui = tui;
79
99
  this.state = state;
80
100
  this.theme = theme;
81
101
  this.placement = placement;
102
+ this.releaseFocus = releaseFocus;
82
103
  }
83
104
  render(width) {
84
105
  if (width < 38)
@@ -92,24 +113,72 @@ class TasksPanel {
92
113
  content.push(this.theme.fg("muted", "No works yet."));
93
114
  for (const work of works) {
94
115
  const completed = work.tasks.filter((todo) => todo.status === "completed").length;
95
- content.push(`${workIcon(work.status, this.theme)} ${this.theme.fg("text", work.workName)} ${this.theme.fg("dim", `${completed}/${work.tasks.length}`)}`);
116
+ content.push(workSummaryLine(work.status, work.workName, `${completed}/${work.tasks.length}`, innerWidth, this.theme));
96
117
  for (const todo of work.tasks)
97
118
  content.push(` ${todoIcon(todo.status, this.theme)} ${this.theme.fg(todo.status === "completed" ? "muted" : "text", todo.taskName)}`);
98
119
  }
99
- const maxContentLines = 10;
100
- const shown = content.slice(0, maxContentLines);
101
- if (content.length > shown.length)
102
- shown[shown.length - 1] = this.theme.fg("dim", `… ${content.length - shown.length + 1} more; use /works`);
120
+ this.contentLength = content.length;
121
+ const terminalRows = this.tui.terminal.rows || process.stdout.rows || 30;
122
+ this.pageSize = this.placement === "widget" ? Math.max(1, content.length) : Math.max(1, Math.floor(terminalRows * 0.48) - 4);
123
+ this.clampScrollOffset();
124
+ const shown = content.slice(this.scrollOffset, this.scrollOffset + this.pageSize);
125
+ const hasOverflow = content.length > shown.length;
126
+ const range = `${this.scrollOffset + 1}–${this.scrollOffset + shown.length}/${content.length}`;
127
+ let title = "Works";
128
+ if (this.placement === "floating" && (hasOverflow || this.scrollOffset > 0)) {
129
+ title += this.focused ? ` · ${range} · ↑↓ PgUp/PgDn · Esc` : ` · ${range} · /works-panel browse`;
130
+ }
131
+ else if (this.focused) {
132
+ title += " · Esc to return";
133
+ }
103
134
  const lines = [
104
135
  border(innerWidth, "top", this.theme),
105
- frame(this.theme.fg("accent", this.theme.bold("Works")), innerWidth, this.theme),
136
+ frame(this.theme.fg("accent", this.theme.bold(title)), innerWidth, this.theme),
106
137
  rule(innerWidth, this.theme),
107
138
  ...shown.map((line) => frame(line, innerWidth, this.theme)),
108
139
  border(innerWidth, "bottom", this.theme),
109
140
  ];
110
141
  return lines.map((line) => `${leftPad}${line}`);
111
142
  }
143
+ handleInput(data) {
144
+ if (matchesKey(data, Key.escape) || matchesKey(data, Key.ctrl("c"))) {
145
+ this.releaseFocus?.();
146
+ this.tui.requestRender();
147
+ return;
148
+ }
149
+ if (matchesKey(data, Key.up))
150
+ this.scrollBy(-1);
151
+ else if (matchesKey(data, Key.down))
152
+ this.scrollBy(1);
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);
161
+ }
112
162
  invalidate() { }
163
+ scrollBy(lines) {
164
+ this.scrollTo(this.scrollOffset + lines);
165
+ }
166
+ scrollTo(offset) {
167
+ this.scrollOffset = offset;
168
+ this.clampScrollOffset();
169
+ this.tui.requestRender();
170
+ }
171
+ clampScrollOffset() {
172
+ this.scrollOffset = Math.max(0, Math.min(this.scrollOffset, Math.max(0, this.contentLength - this.pageSize)));
173
+ }
174
+ }
175
+ function workSummaryLine(status, name, count, width, theme) {
176
+ const left = `${workIcon(status, theme)} ${theme.fg("text", name)}`;
177
+ const right = theme.fg("dim", count);
178
+ const leftWidth = Math.max(0, width - visibleWidth(right) - 1);
179
+ const shownLeft = truncateToWidth(left, leftWidth, "…");
180
+ const gap = " ".repeat(Math.max(1, width - visibleWidth(shownLeft) - visibleWidth(right)));
181
+ return `${shownLeft}${gap}${right}`;
113
182
  }
114
183
  export function workIcon(status, theme) {
115
184
  if (status === "completed")
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, and completion counts, and hides on terminals narrower than 90 columns or shorter than 18 rows. 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 `/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. `/works-panel browse` focuses the floating panel; Up/Down, Page Up/Page Down, Home, and End scroll its rows, while Escape or Ctrl+C returns focus to the editor. 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.
34
34
 
35
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.
@@ -37,7 +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. Use `/works-panel widget` for the earlier right-aligned layout above the editor, `/works-panel floating` to return to the floating layout, or `/works-panel off` to hide it.
40
+ The panel defaults to a floating top-right layout and does not take keyboard focus. It hides on small terminals. When the panel has more rows than fit, run `/works-panel browse`; then use Up/Down, Page Up/Page Down, Home, or End to scroll through every work and todo. Press Escape or Ctrl+C to return focus to the editor.
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.
41
43
 
42
44
  Run `/works` for full details:
43
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abhishek944/pi-tasks",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Session-scoped work and todo tracking for Pi.",
5
5
  "license": "MIT",
6
6
  "type": "module",