@abhishek944/pi-tasks 0.8.3 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tools.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { StringEnum } from "@earendil-works/pi-ai";
2
2
  import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead } from "@earendil-works/pi-coding-agent";
3
3
  import { Type } from "typebox";
4
+ import { preservePaneLink } from "./agents/links.js";
4
5
  import { formatCompletion, taskCompletion, workCompletion } from "./progress.js";
5
6
  import { renderTaskCall, renderTaskResult, taskResult } from "./tool-result.js";
6
- const WorkStatusSchema = StringEnum(["planned", "active", "blocked", "completed", "cancelled"]);
7
- const TodoStatusSchema = StringEnum(["pending", "active", "blocked", "completed", "cancelled"]);
7
+ const StatusSchema = StringEnum(["active", "blocked", "completed", "cancelled"]);
8
+ const STATUS_GUIDANCE = "New records 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 the information field and retain progress. Keep the parent work active only while some required work can proceed; otherwise mark it blocked. Return blocked records to active when the dependency resolves and work resumes.";
8
9
  const CompletionSchema = Type.Union([Type.Integer({ minimum: 0, maximum: 100 }), Type.Null()], {
9
10
  description: "AI-reported approximate task completion, not elapsed time or a status-to-percentage mapping. Use null for unknown; reserve 100 for verified completed status. Work progress is the equal average of non-cancelled tasks.",
10
11
  });
@@ -15,7 +16,7 @@ export function registerTaskTools(pi, state) {
15
16
  pi.registerTool({
16
17
  name: "WorkCreate",
17
18
  label: "WorkCreate",
18
- description: `Create a session-scoped work item. Use detailed workInfo that preserves the goal, context, scope, constraints, decisions, and expected outcome. ${DETAILS_GUIDANCE}`,
19
+ description: `Create a session-scoped work item. Use detailed workInfo that preserves the goal, context, scope, constraints, decisions, and expected outcome. ${STATUS_GUIDANCE} ${DETAILS_GUIDANCE}`,
19
20
  promptSnippet: "Create a session-scoped work item before starting substantial actionable work",
20
21
  promptGuidelines: [
21
22
  "Use WorkCreate for normal requests that start new work in the main conversation; never use it during /ask or /btw.",
@@ -25,7 +26,7 @@ export function registerTaskTools(pi, state) {
25
26
  parameters: Type.Object({
26
27
  workName: NameSchema,
27
28
  workInfo: InfoSchema,
28
- status: Type.Optional(WorkStatusSchema),
29
+ status: Type.Optional(StatusSchema),
29
30
  }, { additionalProperties: false }),
30
31
  execute(_id, params) {
31
32
  const work = state.createWork(params.workName, params.workInfo, params.status);
@@ -40,7 +41,7 @@ export function registerTaskTools(pi, state) {
40
41
  description: "List session-scoped works and their associated todos. Optional limit returns the newest N matching works after filtering, in chronological order; omitted returns all. Results include detailed workInfo and taskInfo and are truncated at 50KB or 2000 lines.",
41
42
  parameters: Type.Object({
42
43
  workId: Type.Optional(Type.String()),
43
- status: Type.Optional(WorkStatusSchema),
44
+ status: Type.Optional(StatusSchema),
44
45
  limit: Type.Optional(Type.Integer({ minimum: 1, description: "Return only the newest N matching works; omit for all." })),
45
46
  }, { additionalProperties: false }),
46
47
  execute(_id, params) {
@@ -55,14 +56,14 @@ export function registerTaskTools(pi, state) {
55
56
  pi.registerTool({
56
57
  name: "WorkUpdate",
57
58
  label: "WorkUpdate",
58
- description: `Update a work's name, detailed information, or status. Use before implementation to mark relevant work active and after progress to keep its detailed context current. ${DETAILS_GUIDANCE}`,
59
+ description: `Update a work's name, detailed information, or status. Use before implementation to mark relevant work active and after progress to keep its detailed context current. ${STATUS_GUIDANCE} ${DETAILS_GUIDANCE}`,
59
60
  promptSnippet: "Update work status and detailed context as actionable work progresses",
60
61
  promptGuidelines: ["Use WorkUpdate and TodoUpdate before and after actionable main-conversation work; never update tracking during /ask or /btw.", DETAILS_GUIDANCE],
61
62
  parameters: Type.Object({
62
63
  workId: Type.String(),
63
64
  workName: Type.Optional(NameSchema),
64
65
  workInfo: Type.Optional(InfoSchema),
65
- status: Type.Optional(WorkStatusSchema),
66
+ status: Type.Optional(StatusSchema),
66
67
  }, { additionalProperties: false, minProperties: 2 }),
67
68
  execute(_id, params) {
68
69
  const work = state.updateWork(params.workId, { workName: params.workName, workInfo: params.workInfo, status: params.status });
@@ -90,7 +91,7 @@ export function registerTaskTools(pi, state) {
90
91
  pi.registerTool({
91
92
  name: "TodoCreate",
92
93
  label: "TodoCreate",
93
- description: `Create a todo under an existing work, optionally reporting approximate completionPercent (0 for known unstarted work, null for unknown). For longer tasks, use TodoUpdate for interim estimates after roughly 5–10 meaningful working steps or a milestone; do not wait until completion. taskInfo must contain enough detailed context, scope, constraints, expected outcome, and verification guidance to execute the task without guessing. ${DETAILS_GUIDANCE}`,
94
+ description: `Create a todo under an existing work, optionally reporting approximate completionPercent (0 for known unstarted work, null for unknown). For longer tasks, use TodoUpdate for interim estimates after roughly 5–10 meaningful working steps or a milestone; do not wait until completion. taskInfo must contain enough detailed context, scope, constraints, expected outcome, and verification guidance to execute the task without guessing. ${STATUS_GUIDANCE} ${DETAILS_GUIDANCE}`,
94
95
  promptSnippet: "Create detailed todos under the current work before implementation",
95
96
  promptGuidelines: [
96
97
  "Use TodoCreate only under an existing work and only for actionable main-conversation work; never use it during /ask or /btw.",
@@ -101,7 +102,7 @@ export function registerTaskTools(pi, state) {
101
102
  workId: Type.String(),
102
103
  taskName: NameSchema,
103
104
  taskInfo: InfoSchema,
104
- status: Type.Optional(TodoStatusSchema),
105
+ status: Type.Optional(StatusSchema),
105
106
  completionPercent: Type.Optional(CompletionSchema),
106
107
  }, { additionalProperties: false }),
107
108
  execute(_id, params) {
@@ -118,7 +119,7 @@ export function registerTaskTools(pi, state) {
118
119
  parameters: Type.Object({
119
120
  taskId: Type.Optional(Type.String()),
120
121
  workId: Type.Optional(Type.String()),
121
- status: Type.Optional(TodoStatusSchema),
122
+ status: Type.Optional(StatusSchema),
122
123
  limit: Type.Optional(Type.Integer({ minimum: 1, description: "Return only the newest N matching todos; omit for all." })),
123
124
  }, { additionalProperties: false }),
124
125
  execute(_id, params) {
@@ -133,18 +134,19 @@ export function registerTaskTools(pi, state) {
133
134
  pi.registerTool({
134
135
  name: "TodoUpdate",
135
136
  label: "TodoUpdate",
136
- 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. ${DETAILS_GUIDANCE}`,
137
+ 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}`,
137
138
  promptSnippet: "Keep todo status and detailed context synchronized with active work",
138
139
  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],
139
140
  parameters: Type.Object({
140
141
  taskId: Type.String(),
141
142
  taskName: Type.Optional(NameSchema),
142
143
  taskInfo: Type.Optional(InfoSchema),
143
- status: Type.Optional(TodoStatusSchema),
144
+ status: Type.Optional(StatusSchema),
144
145
  completionPercent: Type.Optional(CompletionSchema),
145
146
  }, { additionalProperties: false, minProperties: 2 }),
146
147
  execute(_id, params) {
147
- const todo = state.updateTodo(params.taskId, { taskName: params.taskName, taskInfo: params.taskInfo, status: params.status, completionPercent: params.completionPercent });
148
+ const taskInfo = params.taskInfo === undefined ? undefined : preservePaneLink(state.getTodo(params.taskId)?.taskInfo ?? "", params.taskInfo);
149
+ const todo = state.updateTodo(params.taskId, { taskName: params.taskName, taskInfo, status: params.status, completionPercent: params.completionPercent });
148
150
  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) }));
149
151
  },
150
152
  renderCall: renderTaskCall("TodoUpdate"),
package/dist/tracking.js CHANGED
@@ -5,21 +5,32 @@ Work is the overall outcome being pursued. A todo is a concrete step that belong
5
5
  For every normal user request that starts or continues work, keep the session's work and todo records synchronized. Do not skip tracking because the work looks small.
6
6
  Write workInfo and taskInfo in normal prose with full sentences and spaces between words. Conversational brevity modes must not compress stored records or concatenate words.
7
7
 
8
+ Every delegated subagent, at every delegation depth, must use these tools to create or resume its own session-local Work and Todos before assigned work. Do not begin assigned work without a real workId and an active taskId for the current step. Keep these records current and return the IDs with results, checks, and blockers. Parent assignment IDs are context, not shared records: IDs are session-scoped. Record the parent assignment in the worker's details; do not mutate the parent's session records. Include this requirement in every subagent prompt. If tracking tools or IDs are unavailable, report the blocker and do not begin delegated work; a parent-owned Todo or Markdown checklist is not a substitute. Do not invent IDs or backdate tracking. This is an instruction, not a runtime enforcement hook, and does not change the /ask or /btw exceptions.
9
+
10
+ Shared workflow contract:
11
+ - Every tracked Work, including each subagent's local Work, follows the global implement skill for coordination. Read it before execution, or reuse it if already active; do not recursively invoke it. Specialized skills retain their scope and safety limits: research/review stay read-only and planning does not authorize implementation. If the skill is unavailable, report the blocker rather than executing without it.
12
+ - Before execution, read the full current sessionId through the agent's own shell tool using printf '%s\\n' "$PI_SESSION_ID". Require a nonempty safe component matching [A-Za-z0-9][A-Za-z0-9_-]* and real tool-returned Work/Task IDs. Missing tools, identity, or IDs block execution; never substitute the parent's identity or invent IDs. Reading instructions, obtaining identity, and establishing tracking are startup steps.
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
+ - 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
+ - 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.
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
+
8
19
  Before implementation, investigation, or any other requested work:
9
20
  1. Use WorkList and TodoList to find the relevant existing records and avoid duplicates.
10
21
  2. If no suitable work exists, create one with WorkCreate. Otherwise use WorkUpdate to refresh its detailed workInfo and mark it active.
11
- 3. Create or update the work's todos so they match the requested scope. Keep taskInfo detailed and self-contained.
22
+ 3. Create or update the work's todos so they match the requested scope. New works and todos default to active; the only statuses are active, blocked, completed, and cancelled. Keep taskInfo detailed and self-contained.
12
23
  4. Mark the todo being attempted active with TodoUpdate before doing that work.
13
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.
14
25
 
15
26
  During and after the attempt:
16
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.
17
28
  - When available, use LoopCreate only when work needs a future or repeated wake. Do not create a loop for ordinary synchronous work.
18
- - A loop or monitor does not replace work and todo status. Update the related todo when its result is known.
29
+ - A loop or monitor does not replace work and todo 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. Work 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 records active and update their context.
19
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.
20
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).
21
32
  - Percentages are approximate completion, not ETA or proof. Never mark a parent complete to conceal unfinished tasks, and never change statuses merely because a percentage looks complete.
22
- - Keep the work active while required todos remain, blocked when progress cannot continue, and completed only when its required todos are complete.
33
+ - Keep the work active only while some required work can proceed. If all remaining required work must wait on dependencies, mark the parent work blocked too and record the reason and resume condition in workInfo. Complete the work only when its required todos are complete.
23
34
  - Never create or update works, todos, loops, or monitors during /ask, /btw, or any BTW side thread.`;
24
35
  export function areTrackingToolsActive(pi) {
25
36
  const active = new Set(pi.getActiveTools());
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export type WorkStatus = "planned" | "active" | "blocked" | "completed" | "cancelled";
2
- export type TodoStatus = "pending" | "active" | "blocked" | "completed" | "cancelled";
1
+ export type WorkStatus = "active" | "blocked" | "completed" | "cancelled";
2
+ export type TodoStatus = WorkStatus;
3
3
  export interface Work {
4
4
  workId: string;
5
5
  workName: string;
@@ -1,4 +1,5 @@
1
1
  import { type ExtensionUIContext, type Theme } from "@earendil-works/pi-coding-agent";
2
+ import { type DelegateLink } from "../agents/links.js";
2
3
  import type { GitSnapshot, GitStatusCache } from "../git-status.js";
3
4
  import type { TaskState } from "../state.js";
4
5
  import type { TodoStatus, WorkStatus } from "../types.js";
@@ -13,8 +14,9 @@ export declare class TasksPanelHost {
13
14
  private mode;
14
15
  private minimized;
15
16
  private cwd;
17
+ private sessionId;
16
18
  constructor(state: TaskState, git: GitStatusCache);
17
- attach(ui: ExtensionUIContext, cwd: string): void;
19
+ attach(ui: ExtensionUIContext, cwd: string, sessionId: string): void;
18
20
  setMode(mode: TasksPanelMode): void;
19
21
  getMode(): TasksPanelMode;
20
22
  setMinimized(minimized: boolean): void;
@@ -23,7 +25,16 @@ export declare class TasksPanelHost {
23
25
  private applyMode;
24
26
  private hideCurrent;
25
27
  }
26
- export declare function progressName(name: string, completion: number | null, width: number): string;
28
+ export declare function recordId(id: string, theme: Theme): string;
29
+ export declare function ownerBadge(taskInfo: string, theme: Theme, linked?: boolean): string;
30
+ export type DelegateHitRegion = {
31
+ start: number;
32
+ end: number;
33
+ y: number;
34
+ link: DelegateLink;
35
+ };
36
+ export declare function delegateHitRegion(link: DelegateLink | undefined, start: number, line: string, y: number, leftPad?: number): DelegateHitRegion | undefined;
37
+ export declare function progressName(name: string, completion: number | null, width: number, prefix?: string): string;
27
38
  export declare function workIcon(status: WorkStatus, theme: Theme): string;
28
39
  export declare function todoIcon(status: TodoStatus, theme: Theme): string;
29
40
  export declare function frame(content: string, innerWidth: number, theme: Theme): string;
package/dist/ui/panel.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { stripVTControlCharacters } from "node:util";
2
2
  import { copyToClipboard } from "@earendil-works/pi-coding-agent";
3
- import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
3
+ import { sliceByColumn, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
4
+ import { delegateLink, focusPane } from "../agents/links.js";
4
5
  import { formatWorksMarkdown } from "../markdown.js";
5
- import { openRepository } from "../open-repository.js";
6
+ import { openRepository, openSession } from "../open-repository.js";
7
+ import { taskOwner } from "../ownership.js";
6
8
  import { formatCompletion, taskCompletion, workCompletion } from "../progress.js";
7
9
  import { safeSingleLine } from "../text.js";
8
10
  const EMPTY_COMPONENT = { render: () => [], invalidate: () => { } };
@@ -18,13 +20,15 @@ export class TasksPanelHost {
18
20
  mode = "floating";
19
21
  minimized = false;
20
22
  cwd = "";
23
+ sessionId = "Session unavailable";
21
24
  constructor(state, git) {
22
25
  this.state = state;
23
26
  this.git = git;
24
27
  }
25
- attach(ui, cwd) {
28
+ attach(ui, cwd, sessionId) {
26
29
  this.hideCurrent();
27
30
  this.cwd = cwd;
31
+ this.sessionId = safeSingleLine(sessionId) || "Session unavailable";
28
32
  this.ui = ui;
29
33
  this.applyMode();
30
34
  }
@@ -62,7 +66,7 @@ export class TasksPanelHost {
62
66
  this.tui = tui;
63
67
  this.panel = new TasksPanel(tui, this.state, theme, "widget", this.minimized, (minimized) => {
64
68
  this.minimized = minimized;
65
- }, (message, type) => ui.notify(message, type), this.cwd, this.git);
69
+ }, (message, type) => ui.notify(message, type), this.cwd, this.git, this.sessionId);
66
70
  return this.panel;
67
71
  });
68
72
  return;
@@ -71,7 +75,7 @@ export class TasksPanelHost {
71
75
  this.tui = tui;
72
76
  this.panel = new TasksPanel(tui, this.state, theme, "floating", this.minimized, (minimized) => {
73
77
  this.minimized = minimized;
74
- }, (message, type) => ui.notify(message, type), this.cwd, this.git);
78
+ }, (message, type) => ui.notify(message, type), this.cwd, this.git, this.sessionId);
75
79
  this.handle = tui.showOverlay(this.panel, {
76
80
  anchor: "top-right",
77
81
  width: "42%",
@@ -108,18 +112,22 @@ class TasksPanel {
108
112
  notify;
109
113
  cwd;
110
114
  git;
115
+ sessionId;
111
116
  scrollOffset = 0;
112
117
  pageSize = 1;
113
118
  contentLength = 0;
114
119
  followTail = true;
115
120
  copying = false;
116
121
  opening = false;
122
+ openingDelegate = false;
123
+ delegateHits = [];
117
124
  disposed = false;
118
125
  unsubscribeGit;
119
126
  copyHitRegion;
120
127
  openHitRegion;
128
+ sessionHitRegion;
121
129
  toggleHitRegion;
122
- constructor(tui, state, theme, placement, minimized, onMinimizedChange, notify, cwd, git) {
130
+ constructor(tui, state, theme, placement, minimized, onMinimizedChange, notify, cwd, git, sessionId) {
123
131
  this.tui = tui;
124
132
  this.state = state;
125
133
  this.theme = theme;
@@ -129,8 +137,10 @@ class TasksPanel {
129
137
  this.notify = notify;
130
138
  this.cwd = cwd;
131
139
  this.git = git;
140
+ this.sessionId = sessionId;
132
141
  }
133
142
  render(width) {
143
+ this.delegateHits = [];
134
144
  if (this.placement === "widget")
135
145
  this.setVisible(width >= 38);
136
146
  if (width < 38)
@@ -140,7 +150,7 @@ class TasksPanel {
140
150
  const innerWidth = boxWidth - 2;
141
151
  const leftPad = this.placement === "widget" ? " ".repeat(Math.max(0, width - boxWidth)) : "";
142
152
  if (this.minimized) {
143
- const header = this.renderHeader("Works", innerWidth, leftPad.length);
153
+ const header = this.renderHeader(innerWidth, leftPad.length);
144
154
  return [
145
155
  gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
146
156
  frame(header, innerWidth, this.theme),
@@ -149,14 +159,18 @@ class TasksPanel {
149
159
  }
150
160
  const contentWidth = innerWidth - PROGRESS_COLUMN_WIDTH;
151
161
  const content = [];
162
+ const delegateRows = new Map();
152
163
  if (works.length === 0)
153
164
  content.push(progressColumn(this.theme.fg("muted", "No works yet."), null, innerWidth, this.theme));
154
165
  for (const work of works) {
155
166
  const completed = work.tasks.filter((todo) => todo.status === "completed").length;
156
- const summary = workSummaryLine(work.status, work.workName, `${completed}/${work.tasks.length}`, contentWidth, this.theme);
167
+ const summary = workSummaryLine(work.status, work.workName, `${completed}/${work.tasks.length}`, contentWidth, this.theme, work.workId);
157
168
  content.push(progressColumn(summary, workCompletion(work), innerWidth, this.theme));
158
169
  for (const todo of work.tasks) {
159
- const label = ` ${todoIcon(todo.status, this.theme)} ${this.theme.fg(todo.status === "completed" ? "muted" : "text", safeSingleLine(todo.taskName))}`;
170
+ const agent = delegateLink(todo.taskInfo);
171
+ const lead = ` ${todoIcon(todo.status, this.theme)} ${recordId(todo.taskId, this.theme)} `;
172
+ const label = `${lead}${ownerBadge(todo.taskInfo, this.theme, Boolean(agent))} ${this.theme.fg(todo.status === "completed" ? "muted" : "text", safeSingleLine(todo.taskName))}`;
173
+ delegateRows.set(content.length, { agent, start: visibleWidth(lead) });
160
174
  content.push(progressColumn(label, taskCompletion(todo), innerWidth, this.theme));
161
175
  }
162
176
  }
@@ -174,15 +188,20 @@ class TasksPanel {
174
188
  this.clampScrollOffset();
175
189
  }
176
190
  const shown = content.slice(this.scrollOffset, this.scrollOffset + this.pageSize);
191
+ shown.forEach((line, index) => {
192
+ const row = delegateRows.get(this.scrollOffset + index);
193
+ if (!row)
194
+ return;
195
+ const hit = delegateHitRegion(row.agent, row.start, line, 3 + index, leftPad.length);
196
+ if (hit)
197
+ this.delegateHits.push(hit);
198
+ });
177
199
  const hasOverflow = content.length > this.pageSize;
178
200
  const range = `${this.scrollOffset + 1}–${this.scrollOffset + shown.length}/${content.length}`;
179
- let title = "Works";
180
- if (this.placement === "floating" && hasOverflow) {
181
- title += this.tui.mode === "fullscreen"
182
- ? ` · ${range}`
183
- : ` · ${range} · latest · /works for all`;
184
- }
185
- const header = this.renderHeader(title, innerWidth, leftPad.length);
201
+ const suffix = this.placement === "floating" && hasOverflow
202
+ ? this.tui.mode === "fullscreen" ? ` · ${range}` : ` · ${range} · latest · /works for all`
203
+ : "";
204
+ const header = this.renderHeader(innerWidth, leftPad.length, suffix);
186
205
  const lines = [
187
206
  gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
188
207
  frame(header, innerWidth, this.theme),
@@ -195,7 +214,23 @@ class TasksPanel {
195
214
  handleMouse(event) {
196
215
  if (this.disposed)
197
216
  return undefined;
198
- if (event.type === "click" && event.button === "left" && event.y === 1) {
217
+ if (event.type === "press" && event.button === "left") {
218
+ const delegateHit = this.delegateHits.some((region) => event.y === region.y && this.isHit(event.x, region));
219
+ const headerHit = event.y === 1 && [this.copyHitRegion, this.sessionHitRegion, this.openHitRegion, this.toggleHitRegion].some((region) => this.isHit(event.x, region));
220
+ // Own the gesture so Pi does not turn repeated control clicks into text selection.
221
+ if (delegateHit || headerHit)
222
+ return { handled: true };
223
+ }
224
+ // Legacy mouse releases omit the button; Pi still normalizes the gesture as a click.
225
+ const primaryClick = event.type === "click" && (event.button === "left" || event.button === "none");
226
+ if (primaryClick) {
227
+ const hit = this.delegateHits.find((region) => event.y === region.y && this.isHit(event.x, region));
228
+ if (hit) {
229
+ void this.openLinkedDelegate(hit.link);
230
+ return { handled: true, render: true };
231
+ }
232
+ }
233
+ if (primaryClick && event.y === 1) {
199
234
  if (this.isHit(event.x, this.toggleHitRegion)) {
200
235
  this.setMinimized(!this.minimized);
201
236
  return { handled: true, render: true };
@@ -204,6 +239,10 @@ class TasksPanel {
204
239
  void this.copyAllAsMarkdown();
205
240
  return { handled: true, render: true };
206
241
  }
242
+ if (this.isHit(event.x, this.sessionHitRegion)) {
243
+ void this.openInCursor(true);
244
+ return { handled: true, render: true };
245
+ }
207
246
  if (this.isHit(event.x, this.openHitRegion)) {
208
247
  void this.openInCursor();
209
248
  return { handled: true, render: true };
@@ -239,43 +278,66 @@ class TasksPanel {
239
278
  this.onMinimizedChange(minimized);
240
279
  this.tui.requestRender();
241
280
  }
242
- renderHeader(titleText, width, leftPadWidth) {
243
- const title = this.theme.fg("accent", this.theme.bold(titleText));
281
+ renderHeader(width, leftPadWidth, suffix = "") {
244
282
  const copyAction = this.copying
245
283
  ? this.theme.fg("dim", "[Copying…]")
246
284
  : this.theme.fg("accent", this.theme.bold("[Copy]"));
247
- const openAction = this.theme.fg(this.opening ? "dim" : "accent", this.theme.bold("[Open]"));
248
- const toggleLabel = this.minimized ? "[Maximize]" : "[Minimize]";
285
+ const sessionAction = this.theme.fg(this.opening ? "dim" : "accent", this.theme.underline(this.theme.bold("[Open session]")));
286
+ const openAction = this.theme.fg(this.opening ? "dim" : "accent", this.theme.underline(this.theme.bold("[Open]")));
287
+ const fixedWidth = visibleWidth(copyAction) + visibleWidth(sessionAction) + visibleWidth(openAction) + 3;
288
+ const fullToggle = this.minimized ? "[Maximize]" : "[Minimize]";
289
+ const toggleLabel = fixedWidth + visibleWidth(fullToggle) <= width ? fullToggle : this.minimized ? "[+]" : "[-]";
249
290
  const toggleAction = this.theme.fg("accent", this.theme.bold(toggleLabel));
250
- const actionsWidth = visibleWidth(copyAction) + 1 + visibleWidth(openAction) + 1 + visibleWidth(toggleAction);
291
+ const actionsWidth = fixedWidth + visibleWidth(toggleAction);
251
292
  const titleWidth = Math.max(0, width - actionsWidth - 1);
252
- const shownTitle = truncateToWidth(title, titleWidth, "");
253
- const gap = " ".repeat(Math.max(1, width - visibleWidth(shownTitle) - actionsWidth));
254
- const copyStart = leftPadWidth + 1 + visibleWidth(shownTitle) + gap.length;
293
+ const context = truncateToWidth(this.theme.fg("dim", suffix.replace(/^\s*·\s*/, "")), titleWidth, "…");
294
+ const gap = " ".repeat(Math.max(0, width - visibleWidth(context) - actionsWidth));
295
+ const copyStart = leftPadWidth + 1 + visibleWidth(context) + gap.length;
255
296
  this.copyHitRegion = { start: copyStart, end: copyStart + visibleWidth(copyAction) };
256
- const openStart = this.copyHitRegion.end + 1;
297
+ const sessionStart = this.copyHitRegion.end + 1;
298
+ this.sessionHitRegion = { start: sessionStart, end: sessionStart + visibleWidth(sessionAction) };
299
+ const openStart = this.sessionHitRegion.end + 1;
257
300
  this.openHitRegion = { start: openStart, end: openStart + visibleWidth(openAction) };
258
301
  const toggleStart = this.openHitRegion.end + 1;
259
302
  this.toggleHitRegion = { start: toggleStart, end: toggleStart + visibleWidth(toggleAction) };
260
- return `${shownTitle}${gap}${copyAction} ${openAction} ${toggleAction}`;
303
+ return `${context}${gap}${copyAction} ${sessionAction} ${openAction} ${toggleAction}`;
261
304
  }
262
305
  isHit(x, region) {
263
306
  return region !== undefined && x >= region.start && x < region.end;
264
307
  }
265
- async openInCursor() {
308
+ async openLinkedDelegate(link) {
309
+ if (this.openingDelegate)
310
+ return;
311
+ this.openingDelegate = true;
312
+ try {
313
+ await focusPane(link.paneId, this.cwd);
314
+ }
315
+ catch (error) {
316
+ const reason = error instanceof Error ? safeSingleLine(error.message) : "Unknown error.";
317
+ if (!this.disposed)
318
+ this.notify(`Could not open delegate. ${reason}`, "error");
319
+ }
320
+ finally {
321
+ this.openingDelegate = false;
322
+ }
323
+ }
324
+ async openInCursor(session = false) {
266
325
  if (this.opening)
267
326
  return;
268
327
  this.opening = true;
269
328
  this.tui.requestRender();
270
329
  try {
271
- await openRepository(this.cwd);
330
+ if (session)
331
+ await openSession(this.cwd, this.sessionId);
332
+ else
333
+ await openRepository(this.cwd);
272
334
  if (!this.disposed)
273
- this.notify("Opened repository in Cursor.", "info");
335
+ this.notify(session ? "Opened session artifacts in Cursor." : "Opened repository in Cursor.", "info");
274
336
  }
275
337
  catch (error) {
276
338
  const reason = error instanceof Error ? ` ${safeSingleLine(error.message)}` : "";
277
339
  if (!this.disposed)
278
- this.notify(`Could not open Cursor. Check that cursor is installed on PATH.${reason}`, "error");
340
+ this.notify(session ? `Could not open session artifacts in Cursor.${reason}` : `Could not open Cursor. Check that cursor is installed on PATH.${reason}`, "error");
279
341
  }
280
342
  finally {
281
343
  this.opening = false;
@@ -321,9 +383,22 @@ class TasksPanel {
321
383
  return Math.max(0, this.contentLength - this.pageSize);
322
384
  }
323
385
  }
324
- export function progressName(name, completion, width) {
386
+ export function recordId(id, theme) {
387
+ return theme.fg(id.startsWith("W") ? "accent" : "syntaxType", `[${safeSingleLine(id)}]`);
388
+ }
389
+ export function ownerBadge(taskInfo, theme, linked = false) {
390
+ const owner = taskOwner(taskInfo);
391
+ const label = owner === "delegate" && linked ? theme.underline(`[${owner}]`) : `[${owner}]`;
392
+ return theme.fg(owner === "self" ? "success" : owner === "delegate" ? "warning" : "muted", label);
393
+ }
394
+ export function delegateHitRegion(link, start, line, y, leftPad = 0) {
395
+ if (!link || stripVTControlCharacters(sliceByColumn(line, start, 10)) !== "[delegate]")
396
+ return undefined;
397
+ return { start: leftPad + 1 + start, end: leftPad + 1 + start + 10, y, link };
398
+ }
399
+ export function progressName(name, completion, width, prefix = "") {
325
400
  const suffix = ` · ${formatCompletion(completion)}`;
326
- return `${truncateToWidth(safeSingleLine(name), Math.max(0, width - visibleWidth(suffix)), "…")}${suffix}`;
401
+ return `${truncateToWidth(`${prefix}${safeSingleLine(name)}`, Math.max(0, width - visibleWidth(suffix)), "…")}${suffix}`;
327
402
  }
328
403
  function progressColumn(content, completion, width, theme) {
329
404
  const contentWidth = width - PROGRESS_COLUMN_WIDTH;
@@ -332,10 +407,10 @@ function progressColumn(content, completion, width, theme) {
332
407
  const value = theme.fg(completion === null ? "muted" : "accent", formatCompletion(completion).padStart(PROGRESS_VALUE_WIDTH));
333
408
  return `${left}${padding}${theme.fg("border", " │ ")}${value}`;
334
409
  }
335
- function workSummaryLine(status, name, count, width, theme) {
410
+ function workSummaryLine(status, name, count, width, theme, workId) {
336
411
  const right = theme.fg("dim", count);
337
412
  const leftWidth = Math.max(0, width - visibleWidth(right) - 1);
338
- const left = `${workIcon(status, theme)} ${theme.fg("text", safeSingleLine(name))}`;
413
+ const left = `${workIcon(status, theme)} ${recordId(workId, theme)} ${theme.fg("text", safeSingleLine(name))}`;
339
414
  const shownLeft = truncateToWidth(left, leftWidth, "…");
340
415
  const gap = " ".repeat(Math.max(1, width - visibleWidth(shownLeft) - visibleWidth(right)));
341
416
  return `${shownLeft}${gap}${right}`;
@@ -21,6 +21,8 @@ export declare class WorksDashboard implements Component, Focusable {
21
21
  private messageColor;
22
22
  private copying;
23
23
  private opening;
24
+ private openingDelegate;
25
+ private delegateHits;
24
26
  private minimized;
25
27
  private readonly unsubscribeGit;
26
28
  private openHitRegion;
@@ -43,6 +45,7 @@ export declare class WorksDashboard implements Component, Focusable {
43
45
  private renderHeader;
44
46
  private toggleMinimized;
45
47
  private isHit;
48
+ private openLinkedDelegate;
46
49
  private openInCursor;
47
50
  private copyAllAsMarkdown;
48
51
  private renderFooter;