@abhishek944/pi-tasks 0.11.1 → 0.12.1

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
@@ -7,7 +7,7 @@ It adds:
7
7
  - `WorkCreate`, `WorkList`, `WorkUpdate`, and `WorkDelete`
8
8
  - `TodoCreate`, `TodoList`, `TodoUpdate`, and `TodoDelete`
9
9
  - `/works`, a detailed floating dashboard modeled after `pi-loop-monitor`'s `/monitors`
10
- - a compact floating top-right panel with work and todo names and completion percentages
10
+ - a compact floating top-right panel with work and todo names, completion percentages, and measured active time
11
11
  - main-conversation guidance that keeps normal requested work current across every Pi skill and requires each delegated agent to establish its own Work and Todo IDs before assigned work
12
12
 
13
13
  Works and todos follow the active Pi session branch. Forking or navigating the session tree restores the state for that branch. `/ask` and `/btw` conversations do not update works, todos, loops, or monitors.
@@ -31,6 +31,7 @@ The extension guides Pi to manage work automatically for normal requests that st
31
31
  ```text
32
32
  WorkCreate workName="Add task tracking" workInfo="Detailed goal, scope, constraints, and expected outcome"
33
33
  TodoCreate workId="W1" taskName="Implement state" taskInfo="Detailed task context and expected result" status="active"
34
+ TodoUpdate taskId="T1" working=true
34
35
  TodoUpdate taskId="T1" completionPercent=40 taskInfo="The state changes are implemented; rendering and verification remain."
35
36
  TodoUpdate taskId="T1" status="completed" taskInfo="Implementation is complete; typecheck and build passed."
36
37
  WorkUpdate workId="W1" workInfo="Task tracking is implemented; state and UI checks passed."
@@ -38,10 +39,18 @@ WorkUpdate workId="W1" workInfo="Task tracking is implemented; state and UI chec
38
39
 
39
40
  Run `/works` to inspect full `workInfo` and `taskInfo` in an interactive overlay.
40
41
 
41
- Works are collections with no status. Tasks use four statuses: `active` (the default), `blocked`, `completed`, and `cancelled`. Use `blocked` as soon as the next step must wait for agent output, review, an external response, user input, permission, or another obstacle. Record the dependency and resume condition in `taskInfo`; retain progress. Tasks actually executing in another agent may remain active, but dependent tasks awaiting their output are blocked. Return blocked tasks to active when the dependency resolves and work resumes. Status does not itself schedule a wake. Legacy saved task statuses `planned` and `pending` restore as active; old Work statuses are ignored. Work tools no longer accept status or a status filter. To cancel an entire Work, cancel its remaining tasks; WorkDelete still deletes the collection and its tasks.
42
+ Works are collections with no status. Tasks use four statuses: `active` (the default), `blocked`, `completed`, and `cancelled`. Use `blocked` as soon as the next step must wait for agent output, review, an external response, user input, permission, or another obstacle. Record the dependency and resume condition in `taskInfo`; retain progress. Parent delegated tasks stay blocked while awaiting worker output; the worker's own local tasks may be active. AgentCreate automatically blocks the parent task after successful creation, retaining its progress. For manual delegation, mark the parent task blocked explicitly. Return blocked tasks to active when the dependency resolves and work resumes. Status does not itself schedule a wake. Legacy saved task statuses `planned` and `pending` restore as active; old Work statuses are ignored. Work tools no longer accept status or a status filter. To cancel an entire Work, cancel its remaining tasks; WorkDelete still deletes the collection and its tasks.
42
43
 
43
44
  Pi reports approximate task progress through the existing `TodoCreate`/`TodoUpdate` tools using optional `completionPercent` (an integer from 0 to 100, or `null` for unknown). Work progress is the equal average of non-cancelled tasks, rounded down—not the fraction of finished tasks. For example, task values 100, 40, 0, 0 give work progress 35%. A missing estimate makes work progress unknown (`—`); blocked tasks retain their estimate. Completed tasks are 100%; reporting 100 without completed status is rejected. For longer tasks, the guidance asks Pi to include interim estimates after roughly 5–10 meaningful working steps or a milestone, rather than waiting until completion. Estimates remain optional and must be supported by evidence; this is guidance, not an enforced schedule. These percentages are estimates, not time predictions. The floating panel keeps percentages in a reserved right-hand column so long names cannot hide them. Existing keyboard controls are unchanged.
44
45
 
46
+ ### Active task time
47
+
48
+ The panel and `/works` reserve **Done** and **Time** columns. Select the task you are actually working on with `TodoUpdate taskId="T1" working=true`; it must be active and have `owner: self` in its details. Selecting another task pauses the previous one. Use `working=false` to pause without changing status. Select again at the beginning of each fresh run; merely creating or marking a task active never starts its timer.
49
+
50
+ The extension uses `Date.now()` to add working intervals, including thinking and foreground tools. Idle time, native retry delays between agent loops, and blocking user prompts do not count. Completion, blocking, cancellation, ownership changes, abort, and shutdown stop the timer automatically. Saved totals survive reload and branch navigation; restored tasks are paused and offline time never counts. A running time has a `▶` marker. Totals are saved on interval boundaries, not every display tick. A forced process kill can lose the current unsaved interval. Blocking prompt exclusion needs a Pi host that emits `ui_prompt_start`/`ui_prompt_end`; older hosts still pause at agent-loop boundaries.
51
+
52
+ New tasks start at `0s`; historical tasks without timing show `—` until measured, with no attempt to reconstruct earlier time. Work time sums every task's measured effort, including cancelled tasks; any unknown task makes the total unknown. It is not wall-clock duration or an estimate of remaining time. Every delegated agent times its own local tasks; the parent delegate record shows `—` because remote time is unmeasured, and makes the Work total unknown. It never treats waiting as work. Listings and copied Markdown include the same totals.
53
+
45
54
  The panel and `/works` prefix work names with IDs and task names with IDs plus ownership, such as `[W1] Locate subagent restrictions` and `[T1] [self] Inspect the implement skill`. Task ownership comes from an explicit `owner: self` or `owner: delegate` declaration at the start of a line in `taskInfo`; preserve it on updates. Missing or conflicting decisions show `[unassigned]`, without rewriting stored names or old records. Inside Herdr, `AgentCreate` automatically links its task to an underlined, clickable `[delegate]` badge; Open actions are also underlined. See [delegate pane links](docs/USAGE_GUIDE.md#delegate-pane-links) for linking and keyboard access.
46
55
 
47
56
  The panel defaults to the floating top-right layout. The compact header no longer displays the session ID. An underlined Open session action beside Copy opens this agent's artifact folder in Cursor, including existing nested delegated paths; if none exists, it creates `var/<sessionId>/`. The existing Open still opens the repository. Use `/works-panel open-session` without mouse input. Narrow headers shorten Minimize/Maximize to `[-]`/`[+]`. The `/works` dashboard title stays unchanged. Its top border centers the current repository's Git branch and staged/unstaged/untracked file counts, refreshed asynchronously with a one-second cache. Clean repositories show `clean`. In fullscreen TUI mode, its title bar has clickable Copy, Open, and Minimize/Maximize actions, and you can scroll overflowing rows directly with the mouse wheel. Open runs `cursor .` in the current session directory (the Cursor CLI must be on PATH). Open `/works` to inspect every row or copy from the keyboard. Use `/works-panel minimize`, `/works-panel maximize`, or `/works-panel open` when mouse input is unavailable. In `/works`, press `o` to open Cursor. Switch layouts with `/works-panel floating`, `/works-panel widget`, or `/works-panel off`.
@@ -34,7 +34,7 @@ export function registerAgentTools(pi, state) {
34
34
  };
35
35
  pi.registerTool({
36
36
  name: "AgentCreate", label: "AgentCreate",
37
- description: "Wrap Herdr tab creation, Pi startup and MonitorCreate. Returns actual paneId/tabId/monitorId and a prepared assignment; automatically links the task's delegate badge. Does NOT send work: confirm MonitorList shows subscription ready, then AgentSend the returned assignment. onSignal wakes the parent for worker state changes; optional onDone handles monitor termination, not task completion. No private agent registry, automatic recovery or process checks.",
37
+ description: "Wrap Herdr tab creation, Pi startup and MonitorCreate. Returns actual paneId/tabId/monitorId and a prepared assignment; automatically links the task's delegate badge and marks the parent task blocked while awaiting the worker. Does NOT send work: confirm MonitorList shows subscription ready, then AgentSend the returned assignment. onSignal wakes the parent for worker state changes; optional onDone handles monitor termination, not task completion. No private agent registry, automatic recovery or process checks.",
38
38
  promptGuidelines: ["Prefer these agent tools over CLI for supported operations; use Herdr CLI only for missing capabilities.", "Choose explicit provider/model/thinking/Fast through model-routing-policy. Create only authorized agents, never in /ask or /btw.", "After AgentCreate, confirm MonitorList shows the pane subscription ready before AgentSend. Do not add a duplicate monitor. Read actual output/files before completing tasks."],
39
39
  parameters: Type.Object({
40
40
  workId: Type.String({ pattern: "^W[1-9][0-9]*$" }), taskId: Type.String({ pattern: "^T[1-9][0-9]*$" }),
@@ -76,7 +76,7 @@ export function registerAgentTools(pi, state) {
76
76
  const currentTodo = state.getTodo(params.taskId);
77
77
  if (!currentTodo || currentTodo.workId !== params.workId)
78
78
  throw new Error("The parent task is no longer available for linking.");
79
- state.updateTodo(params.taskId, { taskInfo: withPaneLink(currentTodo.taskInfo, pane.pane_id, watched.monitorId) });
79
+ state.updateTodo(params.taskId, { status: "blocked", taskInfo: withPaneLink(currentTodo.taskInfo, pane.pane_id, watched.monitorId) });
80
80
  const assignment = `Parent session ${ctx.sessionManager.getSessionId()}, work ${params.workId}, task ${params.taskId}. Exact parentTaskDir: ${params.taskDir}. Read global implement and applicable skills. Obtain your own PI_SESSION_ID through your shell, establish your own Work and active Todo using WorkList/TodoList and create/update tools before executing, keep them current, and return your IDs, nested task artifact path, changed files, checks and blockers. Parent IDs are context, not shared records. This handoff grants no additional permissions.\n\n${params.assignment}`;
81
81
  return result("AgentCreate", { ...handles, taskDir: params.taskDir, assignment, assignmentSent: false,
82
82
  next: "Confirm MonitorList shows subscription ready, then AgentSend this assignment to the returned paneId." });
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import { GitStatusCache } from "./git-status.js";
6
6
  import { openRepository, openSession } from "./open-repository.js";
7
7
  import { TaskState } from "./state.js";
8
8
  import { safeSingleLine } from "./text.js";
9
+ import { registerTaskTiming } from "./timing.js";
9
10
  import { registerTaskTools } from "./tools.js";
10
11
  import { registerTrackingGuidance } from "./tracking.js";
11
12
  import { TasksPanelHost } from "./ui/panel.js";
@@ -15,6 +16,7 @@ export default function tasksExtension(pi) {
15
16
  const git = new GitStatusCache();
16
17
  panel = new TasksPanelHost(state, git);
17
18
  registerTaskTools(pi, state);
19
+ registerTaskTiming(pi, state);
18
20
  registerAgentTools(pi, state);
19
21
  registerTrackingGuidance(pi);
20
22
  registerTaskAutoContinue(pi, state);
package/dist/markdown.js CHANGED
@@ -1,17 +1,18 @@
1
1
  import { formatCompletion, taskCompletion, workCompletion } from "./progress.js";
2
2
  import { safeMultiline, safeSingleLine } from "./text.js";
3
+ import { formatTime, taskTime, workTime } from "./time.js";
3
4
  export function formatWorksMarkdown(works) {
4
5
  const lines = ["# Works and Todos", ""];
5
6
  if (works.length === 0)
6
7
  return `${lines.join("\n")}\n_No works or todos in this session._\n`;
7
8
  for (const work of works) {
8
- lines.push(`## ${work.workId} — ${escapeMarkdownInline(safeSingleLine(work.workName))}`, "", `**Completion:** ${formatCompletion(workCompletion(work))}`, "", "### Details", "", markdownBody(work.workInfo), "", "### Todos", "");
9
+ lines.push(`## ${work.workId} — ${escapeMarkdownInline(safeSingleLine(work.workName))}`, "", `**Completion:** ${formatCompletion(workCompletion(work))}`, `**Time (task effort):** ${formatTime(workTime(work))}`, "", "### Details", "", markdownBody(work.workInfo), "", "### Todos", "");
9
10
  if (work.tasks.length === 0) {
10
11
  lines.push("_No todos._", "");
11
12
  continue;
12
13
  }
13
14
  for (const todo of work.tasks) {
14
- lines.push(`#### ${todo.taskId} — ${escapeMarkdownInline(safeSingleLine(todo.taskName))}`, "", `**Status:** ${todo.status}`, `**Completion:** ${formatCompletion(taskCompletion(todo))}`, "", markdownBody(todo.taskInfo), "");
15
+ lines.push(`#### ${todo.taskId} — ${escapeMarkdownInline(safeSingleLine(todo.taskName))}`, "", `**Status:** ${todo.status}`, `**Completion:** ${formatCompletion(taskCompletion(todo))}`, `**Time:** ${formatTime(taskTime(todo))}${todo.workingSince === undefined ? "" : " (running)"}`, "", markdownBody(todo.taskInfo), "");
15
16
  }
16
17
  }
17
18
  return `${lines.join("\n").trimEnd()}\n`;
package/dist/state.d.ts CHANGED
@@ -10,6 +10,9 @@ export declare class TaskState {
10
10
  private todos;
11
11
  private nextWorkId;
12
12
  private nextTaskId;
13
+ private focusedTaskId;
14
+ private workingSince;
15
+ private agentRunning;
13
16
  constructor(pi: ExtensionAPI, onChange: () => void);
14
17
  restore(ctx: ExtensionContext): void;
15
18
  listWorks(filter?: {
@@ -22,11 +25,19 @@ export declare class TaskState {
22
25
  }): Todo[];
23
26
  getWork(workId: string): Work | undefined;
24
27
  getTodo(taskId: string): Todo | undefined;
28
+ private snapshot;
29
+ /** Gate the selected task on actual agent execution, not task status. */
30
+ setAgentRunning(running: boolean): void;
31
+ setWorking(taskId: string, working: boolean): void;
32
+ clearWorking(): void;
33
+ private saveInterval;
25
34
  createWork(workName: string, workInfo: string): Work;
26
35
  updateWork(workId: string, patch: Partial<Pick<Work, "workName" | "workInfo">>): Work;
27
36
  deleteWork(workId: string): boolean;
28
37
  createTodo(workId: string, taskName: string, taskInfo: string, status?: TodoStatus, completionPercent?: number | null): Todo;
29
- updateTodo(taskId: string, patch: Partial<Pick<Todo, "taskName" | "taskInfo" | "status" | "completionPercent">>): Todo;
38
+ updateTodo(taskId: string, patch: Partial<Pick<Todo, "taskName" | "taskInfo" | "status" | "completionPercent">> & {
39
+ working?: boolean;
40
+ }): Todo;
30
41
  deleteTodo(taskId: string): boolean;
31
42
  private record;
32
43
  private apply;
package/dist/state.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { taskOwner } from "./ownership.js";
1
2
  import { taskCompletion } from "./progress.js";
2
3
  import { safeSingleLine } from "./text.js";
3
4
  export const TASK_ENTRY_TYPE = "pi-tasks-state";
@@ -10,11 +11,18 @@ export class TaskState {
10
11
  todos = new Map();
11
12
  nextWorkId = 1;
12
13
  nextTaskId = 1;
14
+ focusedTaskId;
15
+ workingSince;
16
+ agentRunning = false;
13
17
  constructor(pi, onChange) {
14
18
  this.pi = pi;
15
19
  this.onChange = onChange;
16
20
  }
17
21
  restore(ctx) {
22
+ // The branch has already changed. Never append the old interval to it.
23
+ this.focusedTaskId = undefined;
24
+ this.workingSince = undefined;
25
+ this.agentRunning = false;
18
26
  this.works.clear();
19
27
  this.todos.clear();
20
28
  this.nextWorkId = 1;
@@ -44,7 +52,7 @@ export class TaskState {
44
52
  .filter((todo) => !filter?.workId || todo.workId === filter.workId)
45
53
  .filter((todo) => !filter?.status || todo.status === filter.status)
46
54
  .sort((left, right) => left.createdAt - right.createdAt)
47
- .map((todo) => ({ ...todo }));
55
+ .map((todo) => this.snapshot(todo));
48
56
  }
49
57
  getWork(workId) {
50
58
  const work = this.works.get(workId);
@@ -52,7 +60,60 @@ export class TaskState {
52
60
  }
53
61
  getTodo(taskId) {
54
62
  const todo = this.todos.get(taskId);
55
- return todo ? { ...todo } : undefined;
63
+ return todo ? this.snapshot(todo) : undefined;
64
+ }
65
+ snapshot(todo) {
66
+ return { ...todo, workingSince: todo.taskId === this.focusedTaskId ? this.workingSince : undefined };
67
+ }
68
+ /** Gate the selected task on actual agent execution, not task status. */
69
+ setAgentRunning(running) {
70
+ if (this.agentRunning === running)
71
+ return;
72
+ if (!running)
73
+ this.saveInterval();
74
+ this.agentRunning = running;
75
+ if (running && this.focusedTaskId)
76
+ this.workingSince = Date.now();
77
+ this.onChange();
78
+ }
79
+ setWorking(taskId, working) {
80
+ const todo = this.todos.get(taskId);
81
+ if (!todo)
82
+ throw new Error(`Todo ${taskId} not found.`);
83
+ if (!working) {
84
+ if (this.focusedTaskId === taskId)
85
+ this.clearWorking();
86
+ return;
87
+ }
88
+ if (todo.status !== "active" || taskOwner(todo.taskInfo) !== "self") {
89
+ throw new Error("working=true requires an active task with owner: self in this session.");
90
+ }
91
+ if (this.focusedTaskId === taskId)
92
+ return;
93
+ this.clearWorking();
94
+ if (todo.elapsedMs === undefined || todo.elapsedMs === null) {
95
+ this.record({ version: 1, type: "todo-time", at: Date.now(), taskId, elapsedMs: 0 });
96
+ }
97
+ this.focusedTaskId = taskId;
98
+ if (this.agentRunning)
99
+ this.workingSince = Date.now();
100
+ this.onChange();
101
+ }
102
+ clearWorking() {
103
+ this.saveInterval();
104
+ this.focusedTaskId = undefined;
105
+ this.onChange();
106
+ }
107
+ saveInterval() {
108
+ if (!this.focusedTaskId || this.workingSince === undefined)
109
+ return;
110
+ const todo = this.todos.get(this.focusedTaskId);
111
+ const now = Date.now();
112
+ if (todo) {
113
+ this.record({ version: 1, type: "todo-time", at: now, taskId: todo.taskId,
114
+ elapsedMs: (todo.elapsedMs ?? 0) + Math.max(0, now - this.workingSince) });
115
+ }
116
+ this.workingSince = undefined;
56
117
  }
57
118
  createWork(workName, workInfo) {
58
119
  if (this.works.size >= MAX_WORKS)
@@ -83,6 +144,8 @@ export class TaskState {
83
144
  deleteWork(workId) {
84
145
  if (!this.works.has(workId))
85
146
  return false;
147
+ if (this.focusedTaskId && this.todos.get(this.focusedTaskId)?.workId === workId)
148
+ this.clearWorking();
86
149
  this.record({ version: 1, type: "work-deleted", at: Date.now(), workId });
87
150
  return true;
88
151
  }
@@ -100,6 +163,7 @@ export class TaskState {
100
163
  taskInfo: requiredText(taskInfo, "taskInfo"),
101
164
  status,
102
165
  completionPercent: status === "completed" ? 100 : completionPercent ?? null,
166
+ elapsedMs: 0,
103
167
  createdAt: now,
104
168
  updatedAt: now,
105
169
  };
@@ -117,14 +181,25 @@ export class TaskState {
117
181
  status: patch.status,
118
182
  completionPercent: patch.completionPercent,
119
183
  });
120
- if (Object.keys(normalized).length === 0)
184
+ if (Object.keys(normalized).length === 0 && patch.working === undefined)
121
185
  throw new Error("TodoUpdate requires at least one changed field.");
122
- this.record({ version: 1, type: "todo-updated", at: Date.now(), taskId, patch: normalized });
186
+ const effective = { ...current, ...normalized };
187
+ const canWork = effective.status === "active" && taskOwner(effective.taskInfo) === "self";
188
+ if (patch.working === true && !canWork)
189
+ throw new Error("working=true requires an active task with owner: self in this session.");
190
+ if (this.focusedTaskId === taskId && (!canWork || patch.working === false))
191
+ this.clearWorking();
192
+ if (Object.keys(normalized).length > 0)
193
+ this.record({ version: 1, type: "todo-updated", at: Date.now(), taskId, patch: normalized });
194
+ if (patch.working !== undefined)
195
+ this.setWorking(taskId, patch.working);
123
196
  return this.getTodo(taskId);
124
197
  }
125
198
  deleteTodo(taskId) {
126
199
  if (!this.todos.has(taskId))
127
200
  return false;
201
+ if (this.focusedTaskId === taskId)
202
+ this.clearWorking();
128
203
  this.record({ version: 1, type: "todo-deleted", at: Date.now(), taskId });
129
204
  return true;
130
205
  }
@@ -178,6 +253,8 @@ export class TaskState {
178
253
  status,
179
254
  taskName: safeSingleLine(event.todo.taskName),
180
255
  completionPercent: taskCompletion(event.todo),
256
+ elapsedMs: validElapsed(event.todo.elapsedMs) ? event.todo.elapsedMs : null,
257
+ workingSince: undefined,
181
258
  });
182
259
  this.nextTaskId = Math.max(this.nextTaskId, numericId(event.todo.taskId) + 1);
183
260
  break;
@@ -198,12 +275,21 @@ export class TaskState {
198
275
  }
199
276
  break;
200
277
  }
278
+ case "todo-time": {
279
+ const todo = this.todos.get(event.taskId);
280
+ if (todo && validElapsed(event.elapsedMs))
281
+ this.todos.set(event.taskId, { ...todo, elapsedMs: event.elapsedMs });
282
+ break;
283
+ }
201
284
  case "todo-deleted":
202
285
  this.todos.delete(event.taskId);
203
286
  break;
204
287
  }
205
288
  }
206
289
  }
290
+ function validElapsed(value) {
291
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
292
+ }
207
293
  function validateCompletion(status, value) {
208
294
  if (value === undefined || value === null)
209
295
  return;
@@ -252,7 +338,7 @@ function parseEvent(value) {
252
338
  const candidate = value;
253
339
  if (candidate.version !== 1 || typeof candidate.type !== "string")
254
340
  return undefined;
255
- if (!["work-created", "work-updated", "work-deleted", "todo-created", "todo-updated", "todo-deleted"].includes(candidate.type))
341
+ if (!["work-created", "work-updated", "work-deleted", "todo-created", "todo-updated", "todo-deleted", "todo-time"].includes(candidate.type))
256
342
  return undefined;
257
343
  return value;
258
344
  }
package/dist/time.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { Todo, WorkWithTodos } from "./types.js";
2
+ /** Measured task effort, not time since task creation. */
3
+ export declare function taskTime(todo: Todo, now?: number): number | null;
4
+ /** Cancelled tasks still consumed effort. Unknown historical time stays unknown. */
5
+ export declare function workTime(work: WorkWithTodos, now?: number): number | null;
6
+ export declare function formatTime(elapsedMs: number | null): string;
package/dist/time.js ADDED
@@ -0,0 +1,34 @@
1
+ import { taskOwner } from "./ownership.js";
2
+ /** Measured task effort, not time since task creation. */
3
+ export function taskTime(todo, now = Date.now()) {
4
+ // Parent delegate records have no remote timing source. Keep local intervals
5
+ // stored, but never present a local subtotal as the full delegated effort.
6
+ if (taskOwner(todo.taskInfo) === "delegate" || todo.elapsedMs === undefined || todo.elapsedMs === null)
7
+ return null;
8
+ return todo.elapsedMs + (todo.workingSince === undefined ? 0 : Math.max(0, now - todo.workingSince));
9
+ }
10
+ /** Cancelled tasks still consumed effort. Unknown historical time stays unknown. */
11
+ export function workTime(work, now = Date.now()) {
12
+ let total = 0;
13
+ for (const todo of work.tasks) {
14
+ const elapsed = taskTime(todo, now);
15
+ if (elapsed === null)
16
+ return null;
17
+ total += elapsed;
18
+ }
19
+ return work.tasks.length ? total : null;
20
+ }
21
+ export function formatTime(elapsedMs) {
22
+ if (elapsedMs === null)
23
+ return "—";
24
+ const seconds = Math.floor(elapsedMs / 1_000);
25
+ if (seconds < 60)
26
+ return `${seconds}s`;
27
+ const minutes = Math.floor(seconds / 60);
28
+ if (minutes < 60)
29
+ return `${minutes}m ${String(seconds % 60).padStart(2, "0")}s`;
30
+ const hours = Math.floor(minutes / 60);
31
+ if (hours < 1_000)
32
+ return `${hours}h ${String(minutes % 60).padStart(2, "0")}m`;
33
+ return `${Math.floor(hours / 24)}d`;
34
+ }
@@ -0,0 +1,4 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import type { TaskState } from "./state.js";
3
+ /** Runtime activity gates timing; task status never implies execution. */
4
+ export declare function registerTaskTiming(pi: ExtensionAPI, state: TaskState): void;
package/dist/timing.js ADDED
@@ -0,0 +1,47 @@
1
+ import { areTrackingToolsActive } from "./tracking.js";
2
+ /** Runtime activity gates timing; task status never implies execution. */
3
+ export function registerTaskTiming(pi, state) {
4
+ let running = false;
5
+ let prompts = 0;
6
+ let detachAbort;
7
+ const sync = () => state.setAgentRunning(running && prompts === 0 && areTrackingToolsActive(pi));
8
+ const pause = () => {
9
+ running = false;
10
+ detachAbort?.();
11
+ detachAbort = undefined;
12
+ sync();
13
+ };
14
+ const reset = () => {
15
+ pause();
16
+ prompts = 0;
17
+ state.clearWorking();
18
+ };
19
+ // A fresh prompt must explicitly select its task instead of inheriting focus.
20
+ pi.on("before_agent_start", () => { reset(); });
21
+ pi.on("agent_start", (_event, ctx) => {
22
+ running = true;
23
+ const signal = ctx.signal;
24
+ if (signal?.aborted) {
25
+ reset();
26
+ return;
27
+ }
28
+ if (signal) {
29
+ signal.addEventListener("abort", reset, { once: true });
30
+ detachAbort = () => signal.removeEventListener("abort", reset);
31
+ }
32
+ sync();
33
+ });
34
+ // Close every loop interval, including older hosts without agent_settled.
35
+ // Native automatic continuation may resume the focus on its next agent_start.
36
+ pi.on("agent_end", pause);
37
+ pi.on("agent_settled", reset);
38
+ pi.on("ui_prompt_start", () => { prompts += 1; sync(); });
39
+ pi.on("ui_prompt_end", () => { prompts = Math.max(0, prompts - 1); sync(); });
40
+ pi.on("session_before_switch", reset);
41
+ pi.on("session_before_fork", reset);
42
+ pi.on("session_before_tree", reset);
43
+ pi.on("session_shutdown", reset);
44
+ // restore() discards runtime state; these only reset the lifecycle gate.
45
+ pi.on("session_start", reset);
46
+ pi.on("session_tree", reset);
47
+ }
package/dist/tools.js CHANGED
@@ -3,7 +3,9 @@ import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead } from "
3
3
  import { Type } from "typebox";
4
4
  import { preservePaneLink } from "./agents/links.js";
5
5
  import { formatCompletion, taskCompletion, workCompletion } from "./progress.js";
6
+ import { formatTime, taskTime, workTime } from "./time.js";
6
7
  import { renderTaskCall, renderTaskResult, taskResult } from "./tool-result.js";
8
+ import { areTrackingToolsActive } from "./tracking.js";
7
9
  const StatusSchema = StringEnum(["active", "blocked", "completed", "cancelled"]);
8
10
  const STATUS_GUIDANCE = "New tasks default to active. Use blocked immediately when the next step must wait for agent output, review, an external response, user input, permission, or another obstacle. Record the dependency and resume condition in taskInfo and retain progress. Return blocked tasks to active when the dependency resolves and work resumes. Works are collections and have no status.";
9
11
  const CompletionSchema = Type.Union([Type.Integer({ minimum: 0, maximum: 100 }), Type.Null()], {
@@ -131,20 +133,23 @@ export function registerTaskTools(pi, state) {
131
133
  pi.registerTool({
132
134
  name: "TodoUpdate",
133
135
  label: "TodoUpdate",
134
- description: `Update a todo's name, detailed information, status, or completionPercent. For longer tasks, include an optional completionPercent estimate after roughly 5–10 meaningful working steps or a milestone, not just at completion or in status-only updates. Explain evidence and remaining work in taskInfo; use null when unknown and never increase a percentage without evidence. Blocking retains progress. Reserve completed/100 for verified completion. ${STATUS_GUIDANCE} ${DETAILS_GUIDANCE}`,
136
+ description: `Update a todo's name, detailed information, status, completionPercent, or working selection. Set working=true immediately before working on an active owner: self task; it pauses any previously selected task. Set working=false to pause without changing status. Timing is calculated automatically, never estimated. Re-select with working=true on each fresh run. Delegated agents time their own local tasks; never select a parent delegate task. For longer tasks, include an optional completionPercent estimate after roughly 5–10 meaningful working steps or a milestone, not just at completion or in status-only updates. Explain evidence and remaining work in taskInfo; use null when unknown and never increase a percentage without evidence. Blocking retains progress. Reserve completed/100 for verified completion. ${STATUS_GUIDANCE} ${DETAILS_GUIDANCE}`,
135
137
  promptSnippet: "Keep todo status and detailed context synchronized with active work",
136
- promptGuidelines: ["Use TodoUpdate immediately before and after working on a todo in the main conversation; never update tracking during /ask or /btw.", "During longer tasks, include an evidence-based completionPercent estimate after roughly 5–10 meaningful working steps or a milestone; do not wait until completion or only update status. Estimates remain optional: use null when unknown, and leave a percentage unchanged if there is no new evidence. Explain evidence and remaining work in taskInfo; only verified completed tasks may reach 100. Work completion is calculated automatically from tasks.", DETAILS_GUIDANCE],
138
+ promptGuidelines: ["Use TodoUpdate with working=true immediately before working on an active owner: self task, including when resuming on a fresh run. Use working=false when pausing without a status change. Only one local task is timed; runtime idle and user waits pause automatically. Never update tracking during /ask or /btw.", "During longer tasks, include an evidence-based completionPercent estimate after roughly 5–10 meaningful working steps or a milestone; do not wait until completion or only update status. Estimates remain optional: use null when unknown, and leave a percentage unchanged if there is no new evidence. Explain evidence and remaining work in taskInfo; only verified completed tasks may reach 100. Work completion is calculated automatically from tasks.", DETAILS_GUIDANCE],
137
139
  parameters: Type.Object({
138
140
  taskId: Type.String(),
139
141
  taskName: Type.Optional(NameSchema),
140
142
  taskInfo: Type.Optional(InfoSchema),
141
143
  status: Type.Optional(StatusSchema),
142
144
  completionPercent: Type.Optional(CompletionSchema),
145
+ working: Type.Optional(Type.Boolean({ description: "Select this active owner: self task for automatic timing, or pause it. Selection switches away from the previously timed task. No timestamps or duration estimates are accepted." })),
143
146
  }, { additionalProperties: false, minProperties: 2 }),
144
147
  execute(_id, params) {
148
+ if (params.working !== undefined && !areTrackingToolsActive(pi))
149
+ throw new Error("Task timing is available only in tracked main-conversation work, not /ask or /btw.");
145
150
  const taskInfo = params.taskInfo === undefined ? undefined : preservePaneLink(state.getTodo(params.taskId)?.taskInfo ?? "", params.taskInfo);
146
- const todo = state.updateTodo(params.taskId, { taskName: params.taskName, taskInfo, status: params.status, completionPercent: params.completionPercent });
147
- return Promise.resolve(taskResult(`Updated todo ${todo.taskId}: ${todo.taskName} · ${formatCompletion(taskCompletion(todo))} [${todo.status}]`, "todo-update", { taskId: todo.taskId, workId: todo.workId, completionPercent: taskCompletion(todo) }));
151
+ const todo = state.updateTodo(params.taskId, { taskName: params.taskName, taskInfo, status: params.status, completionPercent: params.completionPercent, working: params.working });
152
+ return Promise.resolve(taskResult(`Updated todo ${todo.taskId}: ${todo.taskName} · ${formatCompletion(taskCompletion(todo))} · ${formatTime(taskTime(todo))}${todo.workingSince === undefined ? "" : " running"} [${todo.status}]`, "todo-update", { taskId: todo.taskId, workId: todo.workId, completionPercent: taskCompletion(todo), elapsedMs: taskTime(todo), working: todo.workingSince !== undefined }));
148
153
  },
149
154
  renderCall: renderTaskCall("TodoUpdate"),
150
155
  renderResult: renderTaskResult,
@@ -169,7 +174,7 @@ function formatWorks(works) {
169
174
  if (works.length === 0)
170
175
  return "No works found in this session.";
171
176
  return works.map((work) => [
172
- `${work.workId} ${work.workName} · ${formatCompletion(workCompletion(work))}`,
177
+ `${work.workId} ${work.workName} · ${formatCompletion(workCompletion(work))} · Time: ${formatTime(workTime(work))}`,
173
178
  `Work info:\n${work.workInfo}`,
174
179
  work.tasks.length ? `Todos:\n${formatTodos(work.tasks)}` : "Todos: none",
175
180
  ].join("\n")).join("\n\n---\n\n");
@@ -177,7 +182,7 @@ function formatWorks(works) {
177
182
  function formatTodos(todos) {
178
183
  if (todos.length === 0)
179
184
  return "No todos found.";
180
- return todos.map((todo) => `${todo.taskId} [${todo.status}] ${todo.taskName} · ${formatCompletion(taskCompletion(todo))}\nWork: ${todo.workId}\nTask info:\n${todo.taskInfo}`).join("\n\n");
185
+ return todos.map((todo) => `${todo.taskId} [${todo.status}] ${todo.taskName} · ${formatCompletion(taskCompletion(todo))} · Time: ${formatTime(taskTime(todo))}${todo.workingSince === undefined ? "" : " (running)"}\nWork: ${todo.workId}\nTask info:\n${todo.taskInfo}`).join("\n\n");
181
186
  }
182
187
  function bounded(text) {
183
188
  const result = truncateHead(text, { maxBytes: DEFAULT_MAX_BYTES, maxLines: DEFAULT_MAX_LINES });
package/dist/tracking.js CHANGED
@@ -13,20 +13,20 @@ Shared workflow contract:
13
13
  - Root task artifacts use repository-relative var/<sessionId>/<workId>/<taskId>/, not system /var/. A delegated worker appends its own <childSessionId>/<childWorkId>/<childTaskId>/ beneath the exact parentTaskDir supplied in its assignment, recursively. Keep resolved paths inside the repository's var/, including through symlinks. Record canonical paths and parent IDs in taskInfo, pass them unchanged in handoffs, and return them with results. Validate ownership before reuse after resume or branch navigation; do not overwrite artifacts just because numeric IDs match. Create artifacts only when useful; feature names are descriptions, not path keys. Do not migrate existing artifacts implicitly. Follow implement for the detailed contract and report incompatible helper paths rather than inventing arguments.
14
14
  - For every task, start taskInfo with owner: self or owner: delegate followed by a short reason before execution. Preserve this explicit declaration when updating taskInfo; the panel reads this line to show the ownership badge, with unassigned for missing or conflicting decisions. Delegate only when scope/acceptance criteria are clear, ownership can be isolated, inputs and prerequisites are ready, and useful parallelism or expertise outweighs startup and integration costs. Respect skill-specific delegation restrictions and required tracking/monitor tools. Keep small, tightly coupled, shared-interface, or expensive-to-explain work with one owner. Delegating agents retain responsibility for monitoring, integration, verification, and cleanup; children apply the same rule when allowed to delegate. No arbitrary worker, file-count, or depth thresholds.
15
15
  - Herdr subagent root panes are named exactly with the parent's delegated Task ID, such as T34, with no brackets, descriptions, Work IDs, or other prefixes. This is a display label, not the child's session or local Task ID. Use returned resource IDs for lifecycle operations because pane names can repeat across sessions; rename an owned worker pane when assigning it a different parent Todo.
16
- - Prefer pi-tasks AgentCreate/List/Status/Output/Send/Interrupt/Close/Focus CLI wrappers for supported Herdr operations; use CLI only for unavailable capabilities. AgentCreate takes an existing owner: delegate task, canonical taskDir, explicit model flags and onSignal/optional onDone instructions, creates the pane and monitor, and automatically links the delegate badge. It does not send work: confirm MonitorList shows subscription ready, then AgentSend the returned assignment to the actual paneId. Follow-ups keep that same monitor/callbacks. onSignal handles worker state changes; onDone means the monitor process ended, not the task finished. Do not add duplicate monitors, infer completion from signals or close workers before follow-ups finish. Use AgentClose only with paneId/monitorId values for resources you created. Wrappers assume panes are not repurposed and add no registry, process checks or automatic recovery.
16
+ - Prefer pi-tasks AgentCreate/List/Status/Output/Send/Interrupt/Close/Focus CLI wrappers for supported Herdr operations; use CLI only for unavailable capabilities. AgentCreate takes an existing owner: delegate task, canonical taskDir, explicit model flags and onSignal/optional onDone instructions, creates the pane and monitor, automatically links the delegate badge, and marks the parent task blocked while awaiting the worker. It does not send work: confirm MonitorList shows subscription ready, then AgentSend the returned assignment to the actual paneId. Follow-ups keep that same monitor/callbacks. onSignal handles worker state changes; onDone means the monitor process ended, not the task finished. Do not add duplicate monitors, infer completion from signals or close workers before follow-ups finish. Use AgentClose only with paneId/monitorId values for resources you created. Wrappers assume panes are not repurposed and add no registry, process checks or automatic recovery.
17
17
  - Pi-tasks owns task records/progress and task-owned agent tool orchestration; implement owns coordination and artifact paths; Herdr owns panes/processes and pi-loop-monitor owns supervision. The shared skill/path guidance is instruction-only, not automatic cross-session shared records; Agent tools simply wrap the CLI and existing monitor tools. Plain conversation, /ask, and /btw remain outside this workflow.
18
18
 
19
19
  Before implementation, investigation, or any other requested work:
20
20
  1. Use WorkList and TodoList to find the relevant existing records and avoid duplicates.
21
21
  2. If no suitable work exists, create one with WorkCreate. Otherwise use WorkUpdate when its scope or shared context needs refreshing.
22
22
  3. Create or update the work's todos so they match the requested scope. Works have no status. New todos default to active; task statuses are active, blocked, completed, and cancelled. Keep taskInfo detailed and self-contained.
23
- 4. Mark the todo being attempted active with TodoUpdate before doing that work.
23
+ 4. Mark the todo being attempted active with TodoUpdate before doing that work. For an owner: self task, include working=true to select it for automatic time measurement on every fresh run. Only one local task can be timed; selecting another pauses the previous one. Use working=false when pausing without changing status. Idle, blocking user prompts, and terminal statuses pause automatically. Delegated agents time their own local tasks; a parent delegate record is not a running local task. Never estimate or submit durations.
24
24
  5. completionPercent on TodoCreate/TodoUpdate is optional. When estimating, use an approximate integer from 0 to 100 based on actual work and verification, not elapsed time or a fixed mapping from status. Use 0 for genuinely unstarted tasks and null when unknown. Never invent progress to make a work look further along.
25
25
 
26
26
  During and after the attempt:
27
27
  - When available, use MonitorCreate only when a command should continue in the background; inspect it with MonitorList and do not poll it with shell sleep loops.
28
28
  - When available, use LoopCreate only when work needs a future or repeated wake. Do not create a loop for ordinary synchronous work.
29
- - A loop or monitor does not replace task status. Mark a task blocked immediately when its next step must wait for another agent’s output, review, an external response, user input, permission, or another obstacle. Record which dependency it awaits and what will unblock it in taskInfo; preserve its progress. Tasks actually executing in another agent may remain active, but dependent tasks awaiting that output are blocked. When the dependency resolves and work resumes, mark the affected tasks active and update their context.
29
+ - A loop or monitor does not replace task status. Mark a task blocked immediately when its next step must wait for another agent’s output, review, an external response, user input, permission, or another obstacle. Record which dependency it awaits and what will unblock it in taskInfo; preserve its progress. Parent delegated tasks stay blocked while awaiting worker output; the worker's own local tasks may be active. AgentCreate marks the parent task blocked automatically after successful creation. For manual delegation, mark the parent task blocked explicitly. When the dependency resolves and work resumes, mark the affected tasks active and update their context.
30
30
  - During longer tasks, include an evidence-based completionPercent estimate in TodoUpdate after roughly 5–10 meaningful working steps or a milestone. Do not wait until completion or only update status when an estimate is possible. Explain the evidence and remaining work in taskInfo. Estimates remain optional: use null when unknown, and leave a percentage unchanged if there is no new evidence. Keep estimates current, including after scope changes. Work completion is derived as the equal average of non-cancelled task percentages; any unknown child makes it unknown. Do not set an independent work percentage.
31
31
  - Mark the todo completed, blocked, or cancelled as appropriate and update taskInfo with important current context. Only use completed/100 after verification. Blocking retains the last percentage; it does not erase completed effort. Reopening a completed task needs a fresh estimate (otherwise it becomes unknown).
32
32
  - Percentages are approximate completion, not ETA or proof. Never change task statuses merely because a percentage looks complete.
package/dist/types.d.ts CHANGED
@@ -13,6 +13,10 @@ export interface Todo {
13
13
  taskInfo: string;
14
14
  status: TodoStatus;
15
15
  completionPercent?: number | null;
16
+ /** Accumulated measured time; missing/null means historical time is unknown. */
17
+ elapsedMs?: number | null;
18
+ /** Current interval start, exposed only in live snapshots, never restored. */
19
+ workingSince?: number;
16
20
  createdAt: number;
17
21
  updatedAt: number;
18
22
  }
@@ -46,6 +50,12 @@ export type TaskEvent = {
46
50
  at: number;
47
51
  taskId: string;
48
52
  patch: Partial<Pick<Todo, "taskName" | "taskInfo" | "status" | "completionPercent">>;
53
+ } | {
54
+ version: 1;
55
+ type: "todo-time";
56
+ at: number;
57
+ taskId: string;
58
+ elapsedMs: number;
49
59
  } | {
50
60
  version: 1;
51
61
  type: "todo-deleted";
@@ -4,6 +4,7 @@ import type { GitSnapshot, GitStatusCache } from "../git-status.js";
4
4
  import type { TaskState } from "../state.js";
5
5
  import type { TodoStatus } from "../types.js";
6
6
  export type TasksPanelMode = "floating" | "widget" | "off";
7
+ export declare function metricsContentWidth(width: number): number;
7
8
  export declare class TasksPanelHost {
8
9
  private readonly state;
9
10
  private readonly git;
@@ -35,6 +36,8 @@ export type DelegateHitRegion = {
35
36
  };
36
37
  export declare function delegateHitRegion(link: DelegateLink | undefined, start: number, line: string, y: number, leftPad?: number): DelegateHitRegion | undefined;
37
38
  export declare function progressName(name: string, completion: number | null, width: number, prefix?: string): string;
39
+ export declare function metricsColumn(content: string, completion: number | null, elapsed: number | null, running: boolean, width: number, theme: Theme): string;
40
+ export declare function metricsHeader(width: number, theme: Theme): string;
38
41
  export declare function todoIcon(status: TodoStatus, theme: Theme): string;
39
42
  export declare function frame(content: string, innerWidth: number, theme: Theme): string;
40
43
  export declare function rule(innerWidth: number, theme: Theme): string;
package/dist/ui/panel.js CHANGED
@@ -7,9 +7,14 @@ import { openRepository, openSession } from "../open-repository.js";
7
7
  import { taskOwner } from "../ownership.js";
8
8
  import { formatCompletion, taskCompletion, workCompletion } from "../progress.js";
9
9
  import { safeSingleLine } from "../text.js";
10
+ import { formatTime, taskTime, workTime } from "../time.js";
10
11
  const EMPTY_COMPONENT = { render: () => [], invalidate: () => { } };
11
12
  const PROGRESS_VALUE_WIDTH = 4;
12
- const PROGRESS_COLUMN_WIDTH = PROGRESS_VALUE_WIDTH + 3;
13
+ const TIME_VALUE_WIDTH = 8;
14
+ const METRICS_COLUMN_WIDTH = PROGRESS_VALUE_WIDTH + TIME_VALUE_WIDTH + 6;
15
+ export function metricsContentWidth(width) {
16
+ return Math.max(0, width - METRICS_COLUMN_WIDTH);
17
+ }
13
18
  export class TasksPanelHost {
14
19
  state;
15
20
  git;
@@ -79,7 +84,7 @@ export class TasksPanelHost {
79
84
  this.handle = tui.showOverlay(this.panel, {
80
85
  anchor: "top-right",
81
86
  width: "42%",
82
- minWidth: 38,
87
+ minWidth: 48,
83
88
  maxHeight: "48%",
84
89
  margin: { top: 1, right: 1 },
85
90
  nonCapturing: true,
@@ -123,6 +128,7 @@ class TasksPanel {
123
128
  delegateHits = [];
124
129
  disposed = false;
125
130
  unsubscribeGit;
131
+ refreshTimer;
126
132
  copyHitRegion;
127
133
  openHitRegion;
128
134
  sessionHitRegion;
@@ -142,11 +148,11 @@ class TasksPanel {
142
148
  render(width) {
143
149
  this.delegateHits = [];
144
150
  if (this.placement === "widget")
145
- this.setVisible(width >= 38);
146
- if (width < 38)
151
+ this.setVisible(width >= 48);
152
+ if (width < 48)
147
153
  return [];
148
154
  const works = this.state.listWorks();
149
- const boxWidth = this.placement === "floating" ? width : Math.min(54, Math.max(38, Math.floor(width * 0.44)));
155
+ const boxWidth = this.placement === "floating" ? width : Math.min(54, Math.max(48, Math.floor(width * 0.44)));
150
156
  const innerWidth = boxWidth - 2;
151
157
  const leftPad = this.placement === "widget" ? " ".repeat(Math.max(0, width - boxWidth)) : "";
152
158
  if (this.minimized) {
@@ -157,26 +163,26 @@ class TasksPanel {
157
163
  border(innerWidth, "bottom", this.theme),
158
164
  ].map((line) => `${leftPad}${line}`);
159
165
  }
160
- const contentWidth = innerWidth - PROGRESS_COLUMN_WIDTH;
166
+ const contentWidth = metricsContentWidth(innerWidth);
161
167
  const content = [];
162
168
  const delegateRows = new Map();
163
169
  if (works.length === 0)
164
- content.push(progressColumn(this.theme.fg("muted", "No works yet."), null, innerWidth, this.theme));
170
+ content.push(metricsColumn(this.theme.fg("muted", "No works yet."), null, null, false, innerWidth, this.theme));
165
171
  for (const work of works) {
166
172
  const completed = work.tasks.filter((todo) => todo.status === "completed").length;
167
173
  const summary = workSummaryLine(work.workName, `${completed}/${work.tasks.length}`, contentWidth, this.theme, work.workId);
168
- content.push(progressColumn(summary, workCompletion(work), innerWidth, this.theme));
174
+ content.push(metricsColumn(summary, workCompletion(work), workTime(work), work.tasks.some((todo) => todo.workingSince !== undefined), innerWidth, this.theme));
169
175
  for (const todo of work.tasks) {
170
176
  const agent = delegateLink(todo.taskInfo);
171
177
  const lead = ` ${todoIcon(todo.status, this.theme)} ${recordId(todo.taskId, this.theme)} `;
172
178
  const label = `${lead}${ownerBadge(todo.taskInfo, this.theme, Boolean(agent))} ${this.theme.fg(todo.status === "completed" ? "muted" : "text", safeSingleLine(todo.taskName))}`;
173
179
  delegateRows.set(content.length, { agent, start: visibleWidth(lead) });
174
- content.push(progressColumn(label, taskCompletion(todo), innerWidth, this.theme));
180
+ content.push(metricsColumn(label, taskCompletion(todo), taskTime(todo), todo.workingSince !== undefined, innerWidth, this.theme));
175
181
  }
176
182
  }
177
183
  this.contentLength = content.length;
178
184
  const terminalRows = this.tui.terminal.rows || process.stdout.rows || 30;
179
- this.pageSize = this.placement === "widget" ? Math.max(1, content.length) : Math.max(1, Math.floor(terminalRows * 0.48) - 4);
185
+ this.pageSize = this.placement === "widget" ? Math.max(1, content.length) : Math.max(1, Math.floor(terminalRows * 0.48) - 5);
180
186
  if (this.placement === "widget") {
181
187
  this.scrollOffset = 0;
182
188
  this.followTail = true;
@@ -192,7 +198,7 @@ class TasksPanel {
192
198
  const row = delegateRows.get(this.scrollOffset + index);
193
199
  if (!row)
194
200
  return;
195
- const hit = delegateHitRegion(row.agent, row.start, line, 3 + index, leftPad.length);
201
+ const hit = delegateHitRegion(row.agent, row.start, line, 4 + index, leftPad.length);
196
202
  if (hit)
197
203
  this.delegateHits.push(hit);
198
204
  });
@@ -205,9 +211,10 @@ class TasksPanel {
205
211
  const lines = [
206
212
  gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
207
213
  frame(header, innerWidth, this.theme),
208
- this.theme.fg("border", `├${"─".repeat(contentWidth + 1)}┬${"─".repeat(PROGRESS_VALUE_WIDTH + 1)}┤`),
214
+ metricsRule(innerWidth, "middle", this.theme),
215
+ frame(metricsHeader(innerWidth, this.theme), innerWidth, this.theme),
209
216
  ...shown.map((line) => frame(line, innerWidth, this.theme)),
210
- this.theme.fg("border", `└${"─".repeat(contentWidth + 1)}┴${"─".repeat(PROGRESS_VALUE_WIDTH + 1)}┘`),
217
+ metricsRule(innerWidth, "bottom", this.theme),
211
218
  ];
212
219
  return lines.map((line) => `${leftPad}${line}`);
213
220
  }
@@ -265,10 +272,17 @@ class TasksPanel {
265
272
  return;
266
273
  if (visible) {
267
274
  this.unsubscribeGit ??= this.git.subscribe(() => this.tui.requestRender());
275
+ this.refreshTimer ??= setInterval(() => {
276
+ if (!this.minimized && this.state.listTodos().some((todo) => todo.workingSince !== undefined))
277
+ this.tui.requestRender();
278
+ }, 1_000);
279
+ this.refreshTimer.unref?.();
268
280
  }
269
281
  else {
270
282
  this.unsubscribeGit?.();
271
283
  this.unsubscribeGit = undefined;
284
+ clearInterval(this.refreshTimer);
285
+ this.refreshTimer = undefined;
272
286
  }
273
287
  }
274
288
  setMinimized(minimized) {
@@ -406,12 +420,24 @@ export function progressName(name, completion, width, prefix = "") {
406
420
  const suffix = ` · ${formatCompletion(completion)}`;
407
421
  return `${truncateToWidth(`${prefix}${safeSingleLine(name)}`, Math.max(0, width - visibleWidth(suffix)), "…")}${suffix}`;
408
422
  }
409
- function progressColumn(content, completion, width, theme) {
410
- const contentWidth = width - PROGRESS_COLUMN_WIDTH;
423
+ export function metricsColumn(content, completion, elapsed, running, width, theme) {
424
+ const value = theme.fg(completion === null ? "muted" : "accent", formatCompletion(completion).padStart(PROGRESS_VALUE_WIDTH));
425
+ const time = truncateToWidth(`${running ? "▶" : ""}${formatTime(elapsed)}`, TIME_VALUE_WIDTH, "…");
426
+ return metricsRow(content, value, theme.fg(running ? "accent" : elapsed === null ? "muted" : "dim", time.padStart(TIME_VALUE_WIDTH)), width, theme);
427
+ }
428
+ export function metricsHeader(width, theme) {
429
+ return metricsRow(theme.fg("dim", "Task / Work"), theme.fg("dim", "Done"), theme.fg("dim", "Time".padStart(TIME_VALUE_WIDTH)), width, theme);
430
+ }
431
+ function metricsRow(content, completion, time, width, theme) {
432
+ const contentWidth = metricsContentWidth(width);
411
433
  const left = truncateToWidth(content, contentWidth, "…");
412
434
  const padding = " ".repeat(Math.max(0, contentWidth - visibleWidth(left)));
413
- const value = theme.fg(completion === null ? "muted" : "accent", formatCompletion(completion).padStart(PROGRESS_VALUE_WIDTH));
414
- return `${left}${padding}${theme.fg("border", " │ ")}${value}`;
435
+ const separator = theme.fg("border", " │ ");
436
+ return truncateToWidth(`${left}${padding}${separator}${completion}${separator}${time}`, width, "");
437
+ }
438
+ function metricsRule(width, edge, theme) {
439
+ const contentWidth = metricsContentWidth(width);
440
+ return theme.fg("border", `${edge === "middle" ? "├" : "└"}${"─".repeat(contentWidth + 1)}${edge === "middle" ? "┬" : "┴"}${"─".repeat(PROGRESS_VALUE_WIDTH + 2)}${edge === "middle" ? "┬" : "┴"}${"─".repeat(TIME_VALUE_WIDTH + 1)}${edge === "middle" ? "┤" : "┘"}`);
415
441
  }
416
442
  function workSummaryLine(name, count, width, theme, workId) {
417
443
  const right = theme.fg("dim", count);
@@ -5,8 +5,9 @@ import { formatWorksMarkdown } from "../markdown.js";
5
5
  import { openRepository } from "../open-repository.js";
6
6
  import { formatCompletion, taskCompletion, workCompletion } from "../progress.js";
7
7
  import { safeMultiline, safeSingleLine } from "../text.js";
8
- import { border, delegateHitRegion, frame, gitBorder, ownerBadge, progressName, recordId, rule, todoIcon } from "./panel.js";
9
- const CHROME_LINES = 8;
8
+ import { formatTime, taskTime, workTime } from "../time.js";
9
+ import { border, delegateHitRegion, frame, gitBorder, metricsColumn, metricsHeader, ownerBadge, progressName, recordId, rule, todoIcon } from "./panel.js";
10
+ const CHROME_LINES = 9;
10
11
  export class WorksDashboard {
11
12
  tui;
12
13
  theme;
@@ -78,13 +79,13 @@ export class WorksDashboard {
78
79
  const listHeight = Math.max(0, bodyHeight - details.length);
79
80
  if (listHeight > 0)
80
81
  this.keepSelectionVisible(items, listHeight);
81
- const rows = items.slice(this.scrollOffset, this.scrollOffset + listHeight).map((item, index) => this.renderRow(item, innerWidth, 4 + index));
82
+ const rows = items.slice(this.scrollOffset, this.scrollOffset + listHeight).map((item, index) => this.renderRow(item, innerWidth, 5 + index));
82
83
  while (rows.length < listHeight)
83
84
  rows.push("");
84
85
  const selected = items.find((item) => item.key === this.selectedKey);
85
86
  if (selected?.kind === "todo" && details[1] !== undefined) {
86
87
  const start = visibleWidth(`${recordId(selected.todo.taskId, this.theme)} `);
87
- const hit = delegateHitRegion(delegateLink(selected.todo.taskInfo), start, details[1], 5 + listHeight);
88
+ const hit = delegateHitRegion(delegateLink(selected.todo.taskInfo), start, details[1], 6 + listHeight);
88
89
  if (hit)
89
90
  this.delegateHits.push(hit);
90
91
  }
@@ -93,6 +94,7 @@ export class WorksDashboard {
93
94
  frame(header, innerWidth, this.theme),
94
95
  frame(this.theme.fg("dim", summary), innerWidth, this.theme),
95
96
  rule(innerWidth, this.theme),
97
+ frame(metricsHeader(innerWidth, this.theme), innerWidth, this.theme),
96
98
  ...[...rows, ...details].map((line) => frame(line, innerWidth, this.theme)),
97
99
  rule(innerWidth, this.theme),
98
100
  frame(this.theme.fg(this.messageColor, truncateToWidth(this.message, innerWidth, "")), innerWidth, this.theme),
@@ -235,12 +237,12 @@ export class WorksDashboard {
235
237
  if (item.kind === "work") {
236
238
  const done = item.work.tasks.filter((todo) => todo.status === "completed").length;
237
239
  const metadata = this.theme.fg("dim", `${done}/${item.work.tasks.length} completed`);
238
- const nameWidth = width - visibleWidth(prefix) - 1 - visibleWidth(metadata);
239
- return truncateToWidth(`${prefix}${this.theme.bold(progressName(item.work.workName, workCompletion(item.work), nameWidth, `${recordId(item.work.workId, this.theme)} `))} ${metadata}`, width, "");
240
+ const label = `${prefix}${this.theme.bold(`${recordId(item.work.workId, this.theme)} ${safeSingleLine(item.work.workName)}`)} ${metadata}`;
241
+ return metricsColumn(label, workCompletion(item.work), workTime(item.work), item.work.tasks.some((todo) => todo.workingSince !== undefined), width, this.theme);
240
242
  }
241
243
  const metadata = this.theme.fg("dim", item.todo.status);
242
- const nameWidth = width - visibleWidth(prefix) - 5 - visibleWidth(metadata);
243
- const line = truncateToWidth(`${prefix} ${todoIcon(item.todo.status, this.theme)} ${progressName(item.todo.taskName, taskCompletion(item.todo), nameWidth, `${recordId(item.todo.taskId, this.theme)} ${ownerBadge(item.todo.taskInfo, this.theme, Boolean(delegateLink(item.todo.taskInfo)))} `)} ${metadata}`, width, "");
244
+ const label = `${prefix} ${todoIcon(item.todo.status, this.theme)} ${recordId(item.todo.taskId, this.theme)} ${ownerBadge(item.todo.taskInfo, this.theme, Boolean(delegateLink(item.todo.taskInfo)))} ${safeSingleLine(item.todo.taskName)} ${metadata}`;
245
+ const line = metricsColumn(label, taskCompletion(item.todo), taskTime(item.todo), item.todo.workingSince !== undefined, width, this.theme);
244
246
  const start = visibleWidth(`${prefix} ${todoIcon(item.todo.status, this.theme)} ${recordId(item.todo.taskId, this.theme)} `);
245
247
  const hit = delegateHitRegion(delegateLink(item.todo.taskInfo), start, line, y);
246
248
  if (hit)
@@ -283,6 +285,7 @@ export class WorksDashboard {
283
285
  return [
284
286
  this.theme.fg("accent", this.theme.bold(`DETAILS${position}`)),
285
287
  truncateToWidth(heading, width, ""),
288
+ this.theme.fg("dim", `Time${item.kind === "work" ? " (task effort)" : ""}: ${formatTime(item.kind === "work" ? workTime(item.work) : taskTime(item.todo))}`),
286
289
  ...shown,
287
290
  ].slice(0, budget);
288
291
  }
package/docs/REFERENCE.md CHANGED
@@ -20,11 +20,11 @@ Limits:
20
20
 
21
21
  A work contains `workId`, `workName`, `workInfo`, `createdAt`, and `updatedAt`. It is a collection with no stored or derived lifecycle status. Work tools do not accept status, and WorkList has no status filter. The public WorkStatus type is removed; consumers should use TodoStatus for task lifecycle.
22
22
 
23
- A todo contains `taskId`, `workId`, `taskName`, `taskInfo`, `status`, optional `completionPercent`, `createdAt`, and `updatedAt`. Todo status is `active`, `blocked`, `completed`, or `cancelled`; new todos default to `active`.
23
+ A todo contains `taskId`, `workId`, `taskName`, `taskInfo`, `status`, optional `completionPercent`, optional `elapsedMs`, runtime-only optional `workingSince`, `createdAt`, and `updatedAt`. Todo status is `active`, `blocked`, `completed`, or `cancelled`; new todos default to `active`.
24
24
 
25
25
  The public list shape assembles each work with `tasks: Todo[]`; tasks are stored separately to avoid duplicate state. Work progress is derived, not independently stored or editable.
26
26
 
27
- `Blocked` includes waiting for another agent’s output, review, an external response, user input, permission, or a genuine obstacle. Mark dependent tasks blocked immediately, with the dependency and resume condition in their information field. Tasks actually executing in a delegated agent can remain active. Resume affected tasks as active when the dependency resolves and work resumes. Works do not have status; cancelling a collection means explicitly cancelling its remaining tasks. These are agent instructions, not automatic dependency detection or a wake mechanism.
27
+ `Blocked` includes waiting for another agent’s output, review, an external response, user input, permission, or a genuine obstacle. Mark dependent tasks blocked immediately, with the dependency and resume condition in their information field. Parent delegated tasks stay blocked while awaiting worker output; the worker's own local tasks may be active. AgentCreate automatically blocks the parent task after successful creation, retaining its progress. For manual delegation, mark the parent task blocked explicitly. Resume affected tasks as active when the dependency resolves and work resumes. Works do not have status; cancelling a collection means explicitly cancelling its remaining tasks. These are agent instructions, not automatic dependency detection or a wake mechanism.
28
28
 
29
29
  Replay accepts version-1 Work events with or without status, ignores retired Work statuses and status-only patches, and preserves IDs, details, timestamps and tasks without rewriting history. Work updates containing name/context changes still apply. Task replay normalizes legacy `planned` and `pending` statuses to `active` in both creation and update events; task tools accept only the four current statuses. Older clients that require Work status cannot read new status-free Work creation events correctly: upgrade readers before sharing new history, and retain session files before rollback.
30
30
 
@@ -38,7 +38,19 @@ Replay accepts version-1 Work events with or without status, ignores retired Wor
38
38
  - Any unknown eligible task makes the work unknown (`—`); unknown is not silently 0. With no eligible tasks (empty Work or only cancelled tasks), work is unknown.
39
39
  - Work progress reaches 100 only when all eligible tasks are completed; there is no parent status override. Progress never changes task statuses or auto-continuation eligibility.
40
40
  - Optional progress fields are additive to version-1 branch events. Legacy completed tasks show 100%; other legacy tasks remain unknown until reported. Invalid optional progress is sanitized on replay without discarding the task.
41
- - Dashboard, compact panel, list output and copied Markdown share these calculations. The compact panel reserves a narrow right-hand percentage column with a divider; names truncate independently. `/works` retains inline `· N%` labels and unchanged navigation. Percentages do not predict remaining time; no subtasks, weights or separate navigation sidebar are added.
41
+ - Dashboard, compact panel, list output and copied Markdown share these calculations. The compact panel and `/works` reserve separated Done and Time columns; names truncate independently and navigation is unchanged. Percentages do not predict remaining time; no subtasks, weights or separate navigation sidebar are added.
42
+
43
+ ### Measured time
44
+
45
+ `TodoUpdate` accepts optional `working: boolean`, separate from status and progress. `true` selects an active `owner: self` task in this session; a missing task, non-active status, or other ownership is rejected before changing state. The selected task is exclusive per session. `false` pauses that task without changing status; it does not interrupt a different selected task. Changing status away from active, changing ownership away from self, or deleting the task/Work closes its interval. The field is an operation, not persistent task status; callers cannot provide elapsed duration or timestamps.
46
+
47
+ TaskState owns focus, an agent-running gate, and an in-memory interval timestamp. Snapshot `workingSince` exists only during a running interval. Saved `elapsedMs` is a non-negative safe integer; version-1 `todo-time` custom entries save cumulative totals without altering status, completion, or the task's descriptive `updatedAt`. Replay accepts old entries and sanitizes invalid duration fields to unknown. Restored records never restore running focus or count offline time. New tasks start at zero; older records remain unknown until selected, which begins measurement from that point rather than reconstructing history. Negative intervals following a backward wall-clock change clamp to zero; forward clock corrections can affect measured time because the agreed clock is Date.now().
48
+
49
+ `registerTaskTiming` gates focus with agent start/end and nested blocking user-prompt events. Every new `before_agent_start` clears prior selection; native loop continuations can retain selection until final settlement. Abort signals close the interval immediately. Settlement, shutdown, and pre-navigation boundaries close and clear selection. Tool execution and model thinking within an agent loop count; idle and native retry waits between loops do not. Hosts without blocking-prompt events cannot exclude an in-loop extension dialog, but retain loop-boundary pauses. There is no per-second persistence, heartbeat, or crash-recovery registry: forced termination may lose the uncommitted interval.
50
+
51
+ `taskTime`, `workTime`, and `formatTime` supply shared display calculations. Work time sums all tasks, including cancelled tasks, because already-spent effort is real; an empty Work or any unknown task yields unknown. This differs deliberately from completion, which excludes cancelled tasks and averages rather than sums. Delegated workers measure their own session-local self tasks. Parent delegate task records display unknown and propagate unknown to Work totals; they do not import child timing or use prompt-to-completion duration as a substitute. Stored local intervals survive ownership changes but are not displayed as the full delegated duration. No cross-session task registry or parent monitor timing bridge is added.
52
+
53
+ Compact floating/widget views refresh running durations once per second while visible and dispose the render timer on hide. `/works` reuses its existing refresh interval. Neither timer writes session entries. Both views reserve Done and Time columns with name clipping, a running marker, and explicit unknown duration. The compact box minimum is 48 columns so the task prefix does not consume the entire name area; widget views hide below that width. Lists, dashboard details, and copied Markdown show the same measured totals.
42
54
 
43
55
  ## Tracking behavior
44
56
 
@@ -88,7 +100,7 @@ Agent tools are thin, bounded, shell-free Herdr CLI wrappers using actual paneId
88
100
 
89
101
  AgentCreate creates a dedicated unfocused tab, starts Pi with the supplied model flags and calls the existing MonitorCreate through ctx.executeTool with onSignal and optional onDone unchanged. It returns paneId/tabId/monitorId, assignmentSent:false and the prepared assignment. The AI must confirm MonitorList shows subscription ready before explicit AgentSend. Follow-up sends do not replace the monitor. AgentClose calls MonitorStop with the supplied monitorId, then closes the supplied pane; callers must use only resources they created. AgentList returns the CLI inventory, including unrelated agents. No subprocess runs during rendering.
90
102
 
91
- AgentCreate stores herdr-pane and herdr-monitor lines in existing taskInfo; task tools persist and restore these details. TodoUpdate preserves existing link lines for delegate-to-delegate detail edits unless explicit replacement metadata is supplied, so ordinary progress/status descriptions do not silently disable navigation. Changing ownership, explicit `herdr-pane: none`, or AgentClose can unlink. delegateLink interprets an unambiguous valid pane ID for owner:delegate inside Herdr. AgentClose removes matching delegate links. No task schema change or automatic task completion is introduced. The onSignal/onDone callbacks remain entirely owned by pi-loop-monitor; onDone means its process ended, not that worker work is complete.
103
+ AgentCreate marks the parent task blocked and stores herdr-pane and herdr-monitor lines in existing taskInfo after successful agent startup and monitor creation; task tools persist and restore these details. TodoUpdate preserves existing link lines for delegate-to-delegate detail edits unless explicit replacement metadata is supplied, so ordinary progress/status descriptions do not silently disable navigation. Changing ownership, explicit `herdr-pane: none`, or AgentClose can unlink. delegateLink interprets an unambiguous valid pane ID for owner:delegate inside Herdr. AgentClose removes matching delegate links. No task schema change or automatic task completion is introduced. The onSignal/onDone callbacks remain entirely owned by pi-loop-monitor; onDone means its process ended, not that worker work is complete.
92
104
 
93
105
  Delegate navigation and AgentFocus first focus the pane, then explicitly activate the tab returned by Herdr; pane-focus success alone does not guarantee that the visible client switched tabs.
94
106
 
@@ -7,7 +7,7 @@ For every normal request that starts or continues work, Pi should:
7
7
  1. Find existing work and todos.
8
8
  2. Create the relevant Work collection, or refresh its shared context when needed.
9
9
  3. Create or update detailed todos for the requested scope.
10
- 4. Mark the current todo active before starting it.
10
+ 4. Mark the current todo active before starting it. For an `owner: self` task, include `working=true` to select it for automatic timing; re-select at the start of each fresh run.
11
11
  5. During longer tasks, report interim progress after roughly 5–10 meaningful working steps or a milestone, when an estimate is possible.
12
12
  6. Mark the todo blocked immediately if its next step must wait on a dependency; otherwise update it after the attempt as active, completed, or cancelled.
13
13
  7. Keep status on tasks only; update Work context when scope or shared decisions change.
@@ -55,7 +55,7 @@ Every subagent must create or resume its own session-local Work and Todos before
55
55
 
56
56
  Works are collections with no status. Tasks use only `active`, `blocked`, `completed`, and `cancelled`. New tasks default to `active`; saved legacy task statuses `planned` and `pending` restore as active but are no longer accepted by tools. Old Work statuses are ignored during replay; no saved history is rewritten.
57
57
 
58
- Use `blocked` immediately when a task cannot proceed until another agent produces output, a review finishes, an external response arrives, the user responds, permission is granted, or another obstacle is resolved. Record which dependency it awaits and what will unblock it in `taskInfo`; retain its current completion estimate. Tasks actually executing in another agent may remain active, but downstream tasks waiting for that output are blocked.
58
+ Use `blocked` immediately when a task cannot proceed until another agent produces output, a review finishes, an external response arrives, the user responds, permission is granted, or another obstacle is resolved. Record which dependency it awaits and what will unblock it in `taskInfo`; retain its current completion estimate. Parent delegated tasks stay blocked while awaiting worker output; the worker's own local tasks may be active. AgentCreate automatically blocks the parent task after successful creation, retaining its progress. For manual delegation, mark the parent task blocked explicitly.
59
59
 
60
60
  When the dependency resolves and work resumes, mark the affected tasks active. Do not assign status to the parent Work. To cancel the whole collection, cancel its remaining tasks explicitly. Neither blocked status nor changing it schedules a wake automatically; use the appropriate monitor or event when an automatic notification is needed.
61
61
 
@@ -107,6 +107,20 @@ TodoDelete taskId="T1"
107
107
 
108
108
  `TodoList` returns all matching todos when `limit` is omitted. A positive integer `limit` selects the newest matching todos after filters, displayed oldest-to-newest. The result shows how many todos were returned and how many matched in total. Both list tools can still truncate very long text output at 50KB or 2,000 lines.
109
109
 
110
+ ### Active task time
111
+
112
+ ```text
113
+ TodoUpdate taskId="T1" status="active" working=true
114
+ TodoUpdate taskId="T2" working=true
115
+ TodoUpdate taskId="T2" working=false
116
+ ```
117
+
118
+ The first call selects T1; the second pauses T1 and selects T2; the third pauses T2 without changing its status. `working=true` requires an active task with `owner: self` in its details. Creation and active status alone do not start timing. The model selects the task, but never submits timestamps or estimates of duration.
119
+
120
+ Time is saved total milliseconds plus `Date.now() - workingSince` while running. The extension saves each interval when paused, switched, or finished, not on every one-second display refresh. Thinking and foreground tool execution count. Idle periods, retry delays between agent loops, and blocking extension UI prompts pause timing. Blocking, completion, cancellation, changing away from self ownership, abort, and shutdown close the interval. Select again at the beginning of each new run. A restored session or branch always starts paused and excludes offline time. Abrupt process termination can lose the unsaved current interval; there is no background checkpoint writer. Blocking prompt exclusion requires a Pi host emitting `ui_prompt_start` and `ui_prompt_end`; older hosts retain loop-boundary timing.
121
+
122
+ The compact panel and `/works` show reserved Done and Time columns; `▶` beside a duration means it is running. New tasks show `0s`. Legacy tasks without timing show `—`; selecting one begins measurement from now, not from its creation date. Work time sums task effort, including cancelled tasks; any unknown duration makes its total unknown. This is not elapsed wall-clock time and does not predict completion. Each delegated agent times its own local self tasks; parent delegate records show `—` because remote time is unmeasured, making the Work total unknown rather than a misleading local-only subtotal. List tools and copied Markdown include durations too.
123
+
110
124
  ### Completion percentages
111
125
 
112
126
  During longer tasks, Pi should include a `completionPercent` estimate in `TodoUpdate` after roughly 5–10 meaningful working steps or a milestone, rather than waiting until completion or only updating status. Explain the evidence and remaining work in `taskInfo`. Estimates remain optional: use `null` when unknown, and leave a percentage unchanged if there is no new evidence. This is model-facing guidance, not an enforced schedule or an automatic percentage increase. These are approximate AI-reported values, not a fixed percentage for each status and not a time prediction. Use an integer 0–100 or `null` for unknown. Completed status means verified completion and displays 100%; 100 without completed status is rejected. Partial progress requires reopening a completed task; reopening without a fresh estimate makes it unknown. Blocking retains the current estimate.
@@ -126,7 +140,7 @@ The task covers the panel label and its documentation.
126
140
 
127
141
  ### Delegate pane links
128
142
 
129
- `[delegate]` describes the ownership decision; it does not launch an agent. AgentCreate automatically adds `herdr-pane: <paneId>` and `herdr-monitor: <monitorId>` lines to the parent task's existing details. TodoUpdate keeps those lines when both old and new ownership stay delegate and the new details do not supply replacement link metadata. Explicit metadata takes precedence; changing ownership or AgentClose can clear the link. Set `herdr-pane: none` to explicitly unlink without changing ownership. No new task schema or private agent registry is added. AgentClose clears matching links without changing ownership or completion.
143
+ `[delegate]` describes the ownership decision; it does not launch an agent. After successful agent startup and monitor creation, AgentCreate automatically marks the parent task blocked and adds `herdr-pane: <paneId>` and `herdr-monitor: <monitorId>` lines to its existing details. The completion estimate is retained; earlier creation failures do not change its status. TodoUpdate keeps those lines when both old and new ownership stay delegate and the new details do not supply replacement link metadata. Explicit metadata takes precedence; changing ownership or AgentClose can clear the link. Set `herdr-pane: none` to explicitly unlink without changing ownership. No new task schema or private agent registry is added. AgentClose clears matching links without changing ownership or completion.
130
144
 
131
145
  ## Agent tools
132
146
 
@@ -173,7 +187,7 @@ Navigation directly focuses the linked paneId through Herdr. Closed panes, missi
173
187
 
174
188
  The compact panel no longer displays the session ID. Before Copy, its header shows nonzero task-state counts across all Works: `3!` blocked, `2▶` active, `5✓` completed, and `1×` cancelled, using the same icon colors as task rows. Counts update in floating, widget and minimized layouts; narrow headers shorten the toggle and truncate the summary when needed. Its underlined `[Open session]` action sits immediately after Copy in floating, widget and minimized layouts. It opens this agent's existing artifact directory under repository `var/` in Cursor, including a nested delegated session folder. If no folder exists, it creates `var/<full-sessionId>/`; multiple matching folders report an ambiguity rather than guessing. Session identity comes from Pi's context, not a pane name. Folder resolution and Cursor launch happen only on activation, never during rendering. `/works-panel open-session` is the keyboard-command alternative. The existing Open action still opens the repository. Narrow compact headers use `[-]`/`[+]` for Minimize/Maximize so all actions fit. The `/works` dashboard retains its existing title and controls.
175
189
 
176
- The panel defaults to a floating top-right layout and does not take keyboard focus. A slim, separated right-hand column keeps work and task percentages aligned and visible even when names are long; the left side retains names, task status icons and Work task-counts. Work rows have no status icons. It hides on small terminals. The top border centers repository-wide Git status: `git main · S2 U3 ?1` means two staged files, three unstaged files, and one untracked file; a file with both staged and unstaged edits counts in both. A clean repository shows `git main · clean`. Long branches shorten before counts. Detached HEAD shows `@` plus the short commit. Git remains visible while minimized and adds no content row.
190
+ The panel defaults to a floating top-right layout and does not take keyboard focus. Its minimum box width is 48 columns to leave room for names beside both metrics; the widget hides below 48 columns. Separated right-hand Done and Time columns keep work/task percentages and measured durations aligned and visible even when names are long; the left side retains names, task status icons and Work task-counts. Work rows have no status icons. It hides on small terminals. The top border centers repository-wide Git status: `git main · S2 U3 ?1` means two staged files, three unstaged files, and one untracked file; a file with both staged and unstaged edits counts in both. A clean repository shows `git main · clean`. Long branches shorten before counts. Detached HEAD shows `@` plus the short commit. Git remains visible while minimized and adds no content row.
177
191
 
178
192
  The asynchronous Git cache refreshes every second while a view is attached; file-changing tool results expire it sooner without blanking the last snapshot. Initial reads show `git loading…`; outside Git the border is plain, and initial failures show `git unavailable`. Later refresh failures retain the last snapshot until a successful read. Polling is read-only and stops when both the panel and dashboard are closed/off.
179
193
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abhishek944/pi-tasks",
3
- "version": "0.11.1",
3
+ "version": "0.12.1",
4
4
  "description": "Session-scoped work and todo tracking for Pi.",
5
5
  "license": "MIT",
6
6
  "type": "module",