@abhishek944/pi-tasks 0.16.0 → 0.17.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.
@@ -10,11 +10,22 @@ import { panes, props, run, setShared, shared, theme } from "herdr";
10
10
  const STATUSES = [
11
11
  { value: "all", label: "All statuses" },
12
12
  { value: "active", label: "Active" },
13
- { value: "blocked", label: "Blocked" },
13
+ { value: "blocked", label: "Blocked (all)" },
14
+ { value: "blocked-user", label: "Blocked on you" },
15
+ { value: "blocked-agent", label: "Waiting on agents" },
14
16
  { value: "completed", label: "Completed" },
15
17
  { value: "cancelled", label: "Cancelled" },
16
18
  ];
17
19
 
20
+ const DECISION_STATUSES = [
21
+ { value: "all", label: "All" },
22
+ { value: "pending", label: "Pending" },
23
+ { value: "expired", label: "Expired" },
24
+ { value: "answered", label: "Answered" },
25
+ { value: "failed", label: "Failed" },
26
+ { value: "invalid", label: "Invalid" },
27
+ ];
28
+
18
29
  export default class TasksHeader extends BaseHeader {
19
30
  init(props, cx) {
20
31
  super.init?.(props, cx);
@@ -69,95 +80,99 @@ export default class TasksHeader extends BaseHeader {
69
80
 
70
81
  // The content copy cannot name its own pane, so this pane's header publishes the selected status
71
82
  // under a pane-scoped key; the Tasks view reads the same key through the pane id it is given.
72
- statusKey(id) {
73
- return "pi-tasks-status:" + id;
83
+ statusKey(id, kind) {
84
+ return "pi-" + kind + "-status:" + id;
74
85
  }
75
86
 
76
- statusValue(id) {
77
- const value = shared(this.statusKey(id));
78
- return STATUSES.some((item) => item.value === value) ? value : "all";
87
+ statusValue(id, kind, statuses) {
88
+ const value = shared(this.statusKey(id, kind));
89
+ return statuses.some((item) => item.value === value) ? value : kind === "decisions" ? "pending" : "all";
79
90
  }
80
91
 
81
92
  // Open state is shared with this pane's view, which closes the menu when the pointer goes down
82
93
  // anywhere in the task list: Herdr's Select owns Escape and its own dismissal, but a click
83
94
  // outside this mod never reaches it.
84
- statusOpenKey(id) {
85
- return "pi-tasks-status-open:" + id;
95
+ statusOpenKey(id, kind) {
96
+ return "pi-" + kind + "-status-open:" + id;
86
97
  }
87
98
 
88
- statusOpen(id) {
89
- return shared(this.statusOpenKey(id)) === true;
99
+ statusOpen(id, kind) {
100
+ return shared(this.statusOpenKey(id, kind)) === true;
90
101
  }
91
102
 
92
- setStatusOpen(id, open) {
93
- setShared(this.statusOpenKey(id), open);
103
+ setStatusOpen(id, kind, open) {
104
+ setShared(this.statusOpenKey(id, kind), open);
94
105
  }
95
106
 
96
- statusControl(id, t) {
97
- const value = this.statusValue(id);
98
- const current = STATUSES.find((item) => item.value === value) ?? STATUSES[0];
99
- const open = this.statusOpen(id);
107
+ statusControl(id, t, counts, kind, statuses) {
108
+ const noun = kind === "tasks" ? "Task" : "Decision";
109
+ const label = (entry) => counts ? `${entry.label} (${counts[entry.value]})` : entry.label;
110
+ const value = this.statusValue(id, kind, statuses);
111
+ const current = statuses.find((item) => item.value === value) ?? statuses[0];
112
+ const open = this.statusOpen(id, kind);
100
113
  const choose = (entry, cx) => {
101
- setShared(this.statusKey(id), entry.value);
102
- this.setStatusOpen(id, false);
103
- this.statusIndex = Math.max(0, STATUSES.findIndex((item) => item.value === entry.value));
114
+ setShared(this.statusKey(id, kind), entry.value);
115
+ this.setStatusOpen(id, kind, false);
116
+ this.statusIndex = Math.max(0, statuses.findIndex((item) => item.value === entry.value));
104
117
  this.statusTrigger.focus();
105
118
  cx.notify();
106
119
  };
107
120
  const close = (cx) => {
108
- this.setStatusOpen(id, false);
121
+ this.setStatusOpen(id, kind, false);
109
122
  this.statusTrigger.focus();
110
123
  cx.notify();
111
124
  };
112
125
  const trigger = h_flex().id("tasks-status-trigger-" + id).h(26).w(120).flex_none().min_w(0).px(8).gap(4).items_center()
113
126
  .bg(t.background).rounded(6).border(1).border_color(t.input)
114
127
  .track_focus(this.statusTrigger).tab_index(0).cursor_pointer()
115
- .accessibility_label("Task status: " + current.label).tooltip("Show only tasks with one status")
128
+ .accessibility_label(noun + " status: " + label(current)).tooltip("Show only " + kind + " with one status")
116
129
  .focus((style) => style.border_color(t.accent))
117
130
  .on_mouse_down("left", (_event, cx) => cx.stop_propagation())
118
131
  .on_click((_event, cx) => {
119
132
  cx.stop_propagation();
120
- const next = !this.statusOpen(id);
121
- this.setStatusOpen(id, next);
122
- if (next) this.statusIndex = Math.max(0, STATUSES.findIndex((item) => item.value === value));
133
+ const next = !open;
134
+ this.setStatusOpen(id, kind, next);
135
+ if (next) this.statusIndex = Math.max(0, statuses.findIndex((item) => item.value === value));
123
136
  (next ? this.statusContent : this.statusTrigger).focus();
124
137
  cx.notify();
125
138
  })
126
- .child(div().flex_1().min_w(0).truncate().text_size(12).text_color(t.foreground).child(current.label))
139
+ .child(div().flex_1().min_w(0).truncate().text_size(12).text_color(t.foreground).child(label(current)))
127
140
  .child(div().flex_none().text_size(11).text_color(t.muted).child("⌄"));
128
141
  // Anchoring to the trigger and growing down-right is the one placement this 32px pane header
129
142
  // supports: an anchor above the trigger would land outside the window.
130
143
  const menu = v_flex().id("tasks-status-menu-" + id).w(190).min_w(0).p(5).gap(1).rounded(6)
131
144
  .border(1).border_color(t.input).bg(t.popover).text_color(t.foreground)
132
- .track_focus(this.statusContent).role("list_box").accessibility_label("Task status")
145
+ .track_focus(this.statusContent).role("list_box").accessibility_label(noun + " status")
146
+ // GPUI observes presses outside the painted menu across the window, including other mods.
147
+ .on_mouse_down_out((_event, cx) => { this.setStatusOpen(id, kind, false); cx.notify(); })
133
148
  .on_key_down((event, cx) => {
134
149
  if (event.key === "up" || event.key === "down") {
135
150
  const step = event.key === "down" ? 1 : -1;
136
- this.statusIndex = (this.statusIndex + step + STATUSES.length) % STATUSES.length;
151
+ this.statusIndex = (this.statusIndex + step + statuses.length) % statuses.length;
137
152
  cx.stop_propagation(); cx.notify();
138
153
  } else if (event.key === "enter" || event.key === "return") {
139
- choose(STATUSES[this.statusIndex], cx); cx.stop_propagation();
154
+ choose(statuses[this.statusIndex], cx); cx.stop_propagation();
140
155
  } else if (event.key === "escape") {
141
156
  close(cx); cx.stop_propagation();
142
157
  }
143
158
  })
144
- .children(STATUSES.map((entry, index) => h_flex().id("tasks-status-option-" + id + entry.value).h(30).flex_none().min_w(0).px(6).gap(6).items_center()
145
- .rounded(4).role("list_box_option").accessibility_label(entry.label).selected(entry.value === value)
159
+ .children(statuses.map((entry, index) => h_flex().id("tasks-status-option-" + id + entry.value).h(30).flex_none().min_w(0).px(6).gap(6).items_center()
160
+ .rounded(4).role("list_box_option").accessibility_label(label(entry)).selected(entry.value === value)
146
161
  .when(index === this.statusIndex, (row) => row.aria_active_descendant())
147
162
  .bg(index === this.statusIndex ? t.selected : t.popover).hover((style) => style.bg(t.hover))
148
163
  .cursor_pointer()
149
164
  .on_mouse_down("left", (_event, cx) => cx.stop_propagation())
150
165
  .on_click((_event, cx) => { cx.stop_propagation(); choose(entry, cx); })
151
166
  .child(div().w(12).flex_none().text_size(12).text_color(t.foreground).child(entry.value === value ? "✓" : ""))
152
- .child(div().flex_1().min_w(0).truncate().text_size(12).child(entry.label))));
153
- const select = Select.new("tasks-status-" + id).accessibility_label("Task status").open(open)
167
+ .child(div().flex_1().min_w(0).truncate().text_size(12).child(label(entry)))));
168
+ const select = Select.new("tasks-status-" + id).accessibility_label(noun + " status").open(open)
154
169
  .track_focus(this.statusTrigger).content_focus_handle(this.statusContent)
155
170
  .on_open_change((next, cx) => {
156
- this.setStatusOpen(id, next);
157
- if (next) this.statusIndex = Math.max(0, STATUSES.findIndex((item) => item.value === value));
171
+ this.setStatusOpen(id, kind, next);
172
+ if (next) this.statusIndex = Math.max(0, statuses.findIndex((item) => item.value === value));
158
173
  cx.notify();
159
174
  })
160
- .on_confirm((_event, cx) => choose(STATUSES[this.statusIndex], cx))
175
+ .on_confirm((_event, cx) => choose(statuses[this.statusIndex], cx))
161
176
  .on_dismiss((_event, cx) => close(cx))
162
177
  .child(Popup.new("tasks-status-popup-" + id, trigger).anchor("bottom_right")
163
178
  .when(open, (el) => el.content(menu)));
@@ -168,25 +183,30 @@ export default class TasksHeader extends BaseHeader {
168
183
  const id = props()?.pane;
169
184
  const pane = panes().find((item) => item.pane === id);
170
185
  if (pane?.mod === "pi-loop-monitor" && pane.terminal === null) return this.activityHeader(id);
171
- if (pane?.mod !== "pi-tasks" || pane.terminal !== null) return super.render(cx);
186
+ if ((pane?.mod !== "pi-tasks" && pane?.mod !== "pi-decisions") || pane.terminal !== null) return super.render(cx);
187
+ const kind = pane.mod === "pi-tasks" ? "tasks" : "decisions";
188
+ const title = kind === "tasks" ? "Tasks" : "Decisions";
172
189
  const t = theme();
190
+ const counts = shared("pi-" + kind + "-counts:" + id);
191
+ const statuses = kind === "tasks" ? STATUSES : DECISION_STATUSES;
192
+ const validCounts = counts && statuses.every(({ value }) => Number.isSafeInteger(counts[value]) && counts[value] >= 0) ? counts : null;
173
193
  return h_flex().id("tasks-header-" + id).size_full().px(10).items_center().gap(8)
174
194
  .bg(t.background).border_b(1).border_color(t.border).text_size(12)
175
195
  .on_click(() => {
176
- if (this.statusOpen(id)) this.setStatusOpen(id, false);
196
+ if (this.statusOpen(id, kind)) this.setStatusOpen(id, kind, false);
177
197
  run("pane.focus", { pane: id });
178
198
  })
179
- .child(div().flex_1().min_w(0).truncate().text_color(t.muted).child("Tasks"))
180
- .child(this.statusControl(id, t))
199
+ .child(div().flex_1().min_w(0).truncate().text_color(t.muted).child(validCounts ? `${title} (${validCounts.all})` : title))
200
+ .child(this.statusControl(id, t, validCounts, kind, statuses))
181
201
  .child(Button.new("tasks-close-" + id).size(32).flex_none().rounded(4).cursor_pointer()
182
202
  .text_size(22).text_color(t.muted).hover((style) => style.bg(t.hover).text_color(t.foreground))
183
203
  .focus((style) => style.bg(t.selected).text_color(t.accent))
184
- .accessibility_label("Close Tasks view").tooltip("Close Tasks only; Pi, agents and tracking continue").tab_stop(true)
204
+ .accessibility_label("Close " + title + " view").tooltip(kind === "tasks" ? "Close Tasks only; Pi, agents and tracking continue" : "Close Decisions only; Pi and agents continue").tab_stop(true)
185
205
  .on_mouse_down("left", (_event, cx) => cx.stop_propagation())
186
206
  .on_click((_event, cx) => {
187
207
  cx.stop_propagation();
188
208
  const target = panes().find((item) => item.pane === id);
189
- if (target?.mod === "pi-tasks" && target.terminal === null) run("pane.close", { pane: id });
209
+ if (target?.mod === "pi-" + kind && target.terminal === null) run("pane.close", { pane: id });
190
210
  }).child("×"));
191
211
  }
192
212
  }
@@ -5,7 +5,8 @@ import { agents, panes, props, readTextFile, run, setShared, shared, terminals,
5
5
 
6
6
  const SESSION = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
7
7
  const TERMINAL = /^(?:[A-Za-z0-9][A-Za-z0-9._-]*\/)?t[0-9a-z]+$/;
8
- const STATUSES = ["active", "blocked", "completed", "cancelled"];
8
+ const STATUSES = ["active", "blocked", "completed", "closed", "cancelled"];
9
+ const FILTERS = ["all", "active", "blocked", "blocked-user", "blocked-agent", "completed", "cancelled"];
9
10
  const DEPENDENCIES = ["user-decision", "another-agent"];
10
11
  const DEPENDENCY_LABELS = { "user-decision": "User decision", "another-agent": "Another agent" };
11
12
  // The pane this view is drawn in; the opener publishes it because a pane content copy
@@ -27,7 +28,7 @@ function delegate(todo) {
27
28
  }
28
29
 
29
30
  function completion(todo) {
30
- if (todo.status === "completed") return 100;
31
+ if (todo.status === "completed" || todo.status === "closed") return 100;
31
32
  return number(todo.completionPercent) && todo.completionPercent < 100 ? todo.completionPercent : null;
32
33
  }
33
34
 
@@ -63,6 +64,47 @@ function duration(ms) {
63
64
  return seconds < 60 ? `${seconds}s` : minutes < 60 ? `${minutes}m ${String(seconds % 60).padStart(2, "0")}s` : hours < 1000 ? `${hours}h ${String(minutes % 60).padStart(2, "0")}m` : `${Math.floor(hours / 24)}d`;
64
65
  }
65
66
 
67
+ // Legacy blocked records have no blockedAt: omit the age entirely, never an invented or zero one.
68
+ function blockedAge(todo, now = Date.now()) {
69
+ if (todo.status !== "blocked" || !number(todo.blockedAt)) return null;
70
+ return Math.max(0, now - todo.blockedAt);
71
+ }
72
+
73
+ // Null, not a label: callers drop the age when this record does not store one.
74
+ function ageLabel(ms) {
75
+ if (ms === null) return null;
76
+ const minutes = Math.floor(ms / 60000);
77
+ if (minutes < 60) return `${minutes}m`;
78
+ const hours = Math.floor(minutes / 60);
79
+ return hours < 48 ? `${hours}h` : `${Math.floor(hours / 24)}d`;
80
+ }
81
+
82
+ function blockedLabel(todo, now = Date.now()) {
83
+ if (todo.status !== "blocked") return null;
84
+ const dependency = todo.dependentOn === "user-decision" ? "Blocked on you" : todo.dependentOn === "another-agent" ? "Waiting on agents" : "Blocked";
85
+ const age = ageLabel(blockedAge(todo, now));
86
+ return age === null ? dependency : dependency + " · " + age;
87
+ }
88
+
89
+ // A filter names an outcome, not always one stored status. Verified work is completed first and
90
+ // then closed, so Completed lists both: a closed task is finished work that must not disappear
91
+ // from the view the person uses to find finished work.
92
+ function matchesFilter(todo, filter) {
93
+ if (filter === "all") return true;
94
+ if (filter === "completed") return todo.status === "completed" || todo.status === "closed";
95
+ if (filter === "blocked-user") return todo.status === "blocked" && todo.dependentOn === "user-decision";
96
+ if (filter === "blocked-agent") return todo.status === "blocked" && todo.dependentOn === "another-agent";
97
+ return todo.status === filter;
98
+ }
99
+
100
+ // The list and the header counts read this one selection, so a count always equals what its entry
101
+ // shows. All statuses stays the live view a running session needs; finished-and-closed and
102
+ // cancelled records are listed by their own entries instead of by every view.
103
+ function visibleTodos(todos, filter) {
104
+ if (filter !== "all") return todos.filter((todo) => matchesFilter(todo, filter));
105
+ return todos.filter((todo) => todo.status !== "closed" && todo.status !== "cancelled");
106
+ }
107
+
66
108
  function validate(value, sessionId) {
67
109
  if (!object(value) || value.version !== 1 || value.sessionId !== sessionId || !text(value.cwd) || !number(value.updatedAt)
68
110
  || typeof value.agentRunning !== "boolean" || !Array.isArray(value.works) || value.works.length > 100
@@ -76,9 +118,13 @@ function validate(value, sessionId) {
76
118
  for (const todo of value.todos) {
77
119
  if (!object(todo) || !/^T[1-9][0-9]*$/.test(todo.taskId) || tasks.has(todo.taskId) || !works.has(todo.workId)
78
120
  || !text(todo.taskName) || !text(todo.taskInfo) || !STATUSES.includes(todo.status)
121
+ || (todo.worktree !== undefined && (typeof todo.worktree !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(todo.worktree)))
79
122
  || (todo.blockedReason != null && typeof todo.blockedReason !== "string")
80
123
  || (todo.dependentOn !== undefined && (todo.status !== "blocked" || !DEPENDENCIES.includes(todo.dependentOn)))
124
+ || (todo.blockedAt !== undefined && (todo.status !== "blocked" || !number(todo.blockedAt)))
125
+ || (todo.decisionQuestionId !== undefined && (todo.status !== "blocked" || todo.dependentOn !== "user-decision" || typeof todo.decisionQuestionId !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(todo.decisionQuestionId)))
81
126
  || (todo.finalThoughts !== undefined && !text(todo.finalThoughts))
127
+ || (todo.goal !== undefined && (!object(todo.goal) || !text(todo.goal.goal) || !Array.isArray(todo.goal.criteria) || !todo.goal.criteria.every(text)))
82
128
  || (todo.workingSince !== undefined && !number(todo.workingSince))
83
129
  || (todo.delegatedTimes !== undefined && (!Array.isArray(todo.delegatedTimes) || todo.delegatedTimes.some((source) => !object(source) || (source.elapsedMs !== null && !number(source.elapsedMs)))))) throw new Error("Invalid task in the task snapshot.");
84
130
  tasks.add(todo.taskId);
@@ -150,12 +196,14 @@ export default class Tasks extends View {
150
196
  const next = validate(JSON.parse(content), this.sessionId);
151
197
  if (this.closed) return;
152
198
  this.document = next;
199
+ this.publishCounts(next);
153
200
  this.error = "";
154
201
  const ids = new Set(next.todos.map((todo) => todo.taskId));
155
202
  for (const id of this.expanded) if (!ids.has(id)) this.expanded.delete(id);
156
203
  if (!ids.has(this.selected)) this.selected = null;
157
204
  } catch (error) {
158
205
  this.document = null;
206
+ this.publishCounts(null);
159
207
  this.error = error instanceof Error ? error.message : String(error);
160
208
  } finally {
161
209
  this.loading = false;
@@ -166,7 +214,15 @@ export default class Tasks extends View {
166
214
  }
167
215
  }
168
216
 
169
- close() { this.closed = true; }
217
+ publishCounts(document) {
218
+ if (this.paneId === null) return;
219
+ // Keys are the filter values the header offers, so its lookup by value and the count it shows
220
+ // cannot drift from the rows a selection lists.
221
+ const counts = document ? Object.fromEntries(FILTERS.map((filter) => [filter, visibleTodos(document.todos, filter).length])) : null;
222
+ setShared("pi-tasks-counts:" + this.paneId, counts);
223
+ }
224
+
225
+ close() { this.publishCounts(null); this.closed = true; }
170
226
 
171
227
  // A pane content copy is given only its creation props, so the opener publishes the hosting pane
172
228
  // id beside the snapshot. A pane opened before that hand-off existed carries no `paneFile` prop,
@@ -184,7 +240,12 @@ export default class Tasks extends View {
184
240
  published = PANE.test(value) ? value : null;
185
241
  } catch { published = null; }
186
242
  }
187
- this.paneId = published ?? this.paneFromInventory();
243
+ const next = published ?? this.paneFromInventory();
244
+ if (this.paneId !== next) {
245
+ this.publishCounts(null);
246
+ this.paneId = next;
247
+ this.publishCounts(null);
248
+ }
188
249
  }
189
250
 
190
251
  paneFromInventory() {
@@ -198,7 +259,7 @@ export default class Tasks extends View {
198
259
 
199
260
  statusFilter() {
200
261
  const value = this.paneId === null ? "all" : shared("pi-tasks-status:" + this.paneId);
201
- return STATUSES.includes(value) ? value : "all";
262
+ return FILTERS.includes(value) ? value : "all";
202
263
  }
203
264
 
204
265
  // The header owns the menu, so a press in this view must dismiss it: Herdr closes a Select on
@@ -235,7 +296,8 @@ export default class Tasks extends View {
235
296
 
236
297
  state(todo) {
237
298
  return this.running(todo) ? "Running" : todo.status === "blocked" ? "Blocked"
238
- : todo.status === "completed" ? "Completed" : todo.status === "cancelled" ? "Cancelled" : "Active; not running";
299
+ : todo.status === "completed" ? "Completed" : todo.status === "closed" ? "Closed"
300
+ : todo.status === "cancelled" ? "Cancelled" : "Active; not running";
239
301
  }
240
302
 
241
303
  button(id, label, accessible, callback, t, underlineFocus = false) {
@@ -291,7 +353,7 @@ export default class Tasks extends View {
291
353
  return svg("mods/pi-tasks/spinner.svg").size(11).flex_none().text_color(t.working)
292
354
  .spin(900).role("image").accessibility_label(state).tooltip(state);
293
355
  }
294
- const mark = state === "Blocked" ? "!" : state === "Completed" ? "✓" : state === "Cancelled" ? "×" : "○";
356
+ const mark = state === "Blocked" ? "!" : state === "Completed" || state === "Closed" ? "✓" : state === "Cancelled" ? "×" : "○";
295
357
  return div().w(11).flex_none().text_size(12).text_center()
296
358
  .text_color(state === "Blocked" ? t.blocked : state === "Completed" ? t.done : t.dim)
297
359
  .role("image").accessibility_label(state).tooltip(state).child(mark);
@@ -304,7 +366,7 @@ export default class Tasks extends View {
304
366
  return "Unknown effort; no complete measurement is recorded, not zero";
305
367
  }
306
368
  const state = this.running(todo) && todo.workingSince !== undefined ? "Running own measurement"
307
- : todo.status === "completed" || todo.status === "cancelled" ? "Stopped own measurement" : "Saved measurement; not currently running";
369
+ : todo.status === "completed" || todo.status === "closed" || todo.status === "cancelled" ? "Stopped own measurement" : "Saved measurement; not currently running";
308
370
  return state + (todo.delegatedTimes?.length ? "; includes imported delegate effort once" : "; own measured effort");
309
371
  }
310
372
 
@@ -330,6 +392,8 @@ export default class Tasks extends View {
330
392
  if (event.click_count === 1) this.toggleTask(todo, cx);
331
393
  }, t).text_size(this.width < 450 ? 11 : 12.5).font_medium())
332
394
  .child(div().flex_none().text_size(this.width < 450 ? 9 : 11).text_color(t.dim).child(todo.taskId))
395
+ .when(todo.status === "blocked", (element) => element.child(div().flex_none().text_size(10).text_color(t.blocked)
396
+ .child(this.width < 450 ? (ageLabel(blockedAge(todo)) ?? blockedLabel(todo)) : blockedLabel(todo))))
333
397
  .when(Boolean(link), (element) => element.child(this.button("agent-" + todo.taskId, "Agent ↗",
334
398
  "Focus existing linked agent for " + todo.taskName, (cx) => this.openAgent(todo, cx), t)
335
399
  .flex_none().px(5).h(23).text_size(this.width < 450 ? 9 : 10).border(1).border_color(t.input).text_color(t.accent))))
@@ -339,11 +403,18 @@ export default class Tasks extends View {
339
403
  if (this.expanded.has(todo.taskId)) {
340
404
  const thoughts = this.finalThoughts(todo);
341
405
  const dependency = todo.status === "blocked" ? DEPENDENCY_LABELS[todo.dependentOn] : undefined;
406
+ const age = todo.status === "blocked" ? ageLabel(blockedAge(todo)) : null;
342
407
  const detail = v_flex().id("description-" + todo.taskId).flex_none().min_w(0).ml(this.width < 450 ? 20 : 38)
343
408
  .pl(23).pr(10).py(10).gap(8).border_l(1).border_color(t.input).text_size(12).text_color(t.muted);
409
+ if (todo.goal) {
410
+ detail.child(div().min_w(0).whitespace_normal().child("Goal: " + todo.goal.goal));
411
+ detail.child(div().min_w(0).text_size(10).text_color(t.dim).child("Acceptance criteria"));
412
+ for (const criterion of todo.goal.criteria) detail.child(div().min_w(0).whitespace_normal().child("• " + criterion));
413
+ }
344
414
  detail.child(h_flex().min_w(0).gap(8).items_center()
345
415
  .child(div().flex_none().text_size(10).text_color(t.dim).child("Final thoughts"))
346
- .when(dependency !== undefined, (row) => row.child(div().min_w(0).truncate().text_size(10).text_color(t.blocked).child("Dependent on: " + dependency))));
416
+ .when(dependency !== undefined, (row) => row.child(div().min_w(0).truncate().text_size(10).text_color(t.blocked).child("Dependent on: " + dependency)))
417
+ .when(age !== null, (row) => row.child(div().flex_none().text_size(10).text_color(t.blocked).child("Blocked for: " + age))));
347
418
  detail.child(div().min_w(0).whitespace_normal().text_color(todo.status === "blocked" ? t.blocked : t.muted)
348
419
  .child(thoughts || "No final thoughts recorded."));
349
420
  elements.push(detail);
@@ -374,14 +445,19 @@ export default class Tasks extends View {
374
445
  this.filter = filter;
375
446
  this.scroll.scroll_to_item(0);
376
447
  }
448
+ // A Work is drawn only while it has a task this selection lists, so a Work with no tasks or no
449
+ // match leaves no empty heading. Records stay untouched.
377
450
  const rows = [...this.document.works].reverse().map((work) => {
378
451
  const todos = this.document.todos.filter((todo) => todo.workId === work.workId);
379
- return { work, todos, shown: filter === "all" ? todos : todos.filter((todo) => todo.status === filter) };
380
- }).filter((row) => filter === "all" || row.shown.length > 0);
452
+ return { work, todos, shown: visibleTodos(todos, filter) };
453
+ }).filter((row) => row.shown.length > 0);
381
454
  const list = v_flex().id("pi-task-list").flex_1().min_h(0).min_w(0).overflow_y_scrollbar().px(this.width < 450 ? 10 : 20).pt(22).pb(20)
382
455
  .track_scroll(this.scroll);
383
456
  if (!rows.length) {
384
- return this.dismissOnPress(root.child(list.child(div().px(10).py(6).text_color(t.muted).child("No " + filter + " tasks."))));
457
+ // The trigger beside this pane already names the selected status, so the empty state does not
458
+ // repeat it, and a split blocked entry never leaks its stored value into the copy.
459
+ return this.dismissOnPress(root.child(list.child(div().px(10).py(6).text_color(t.muted)
460
+ .child(filter === "all" ? "No tasks yet." : "No matching tasks."))));
385
461
  }
386
462
  for (const [index, { work, todos, shown }] of rows.entries()) {
387
463
  if (index) list.child(div().h(1).flex_none().my(16).bg(t.border));
@@ -406,7 +482,6 @@ export default class Tasks extends View {
406
482
  .child(div().w(columns.progress).flex_none().text_right().text_size(this.width < 450 ? 9 : 10).whitespace_nowrap().child("Progress"))
407
483
  .child(div().w(columns.time).flex_none().text_right().whitespace_nowrap().child("Effort")));
408
484
  for (const todo of shown) list.children(this.taskRow(todo, t, columns));
409
- if (!shown.length) list.child(div().px(28).py(6).text_color(t.dim).child("No tasks yet."));
410
485
  }
411
486
  return this.dismissOnPress(root.child(list));
412
487
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abhishek944/pi-tasks",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Session-scoped work and todo tracking for Pi.",
5
5
  "license": "MIT",
6
6
  "type": "module",