pi-better-harness 0.56.0 → 0.57.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/CHANGELOG.md +15 -0
- package/README.md +4 -2
- package/extensions/task-context/dynamic-workflow-view.ts +2 -2
- package/extensions/task-context/index.ts +76 -26
- package/extensions/task-context/plan-state.ts +5 -1
- package/extensions/task-context/plan-widget.ts +41 -5
- package/extensions/task-context/types.ts +1 -0
- package/extensions/task-context/workflow-plan.ts +12 -6
- package/extensions/task-context/workflow-view.ts +16 -20
- package/node_modules/pi-better-background-tasks/package.json +1 -1
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-arm64.gz +0 -0
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-arm64.json +1 -1
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-x64.gz +0 -0
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-x64.json +1 -1
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-arm64.gz +0 -0
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-arm64.json +1 -1
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-x64.gz +0 -0
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-x64.json +1 -1
- package/node_modules/pi-better-background-tasks/src/observed-waits.ts +24 -13
- package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/assignment-changes.ts +33 -0
- package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/background-parent-callbacks.ts +5 -0
- package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/result-supervision.ts +23 -1
- package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/schema.ts +28 -11
- package/node_modules/pi-better-background-tasks/src/shared-operation-coordinator/src/store.ts +9 -3
- package/node_modules/pi-better-goal/package.json +1 -1
- package/node_modules/pi-better-goal/src/index.ts +8 -2
- package/node_modules/pi-better-goal/src/task-context.ts +4 -2
- package/node_modules/pi-better-subagents/managed-launch-client.ts +15 -1
- package/node_modules/pi-better-subagents/package.json +1 -1
- package/node_modules/pi-better-subagents/registry.ts +30 -23
- package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-arm64.gz +0 -0
- package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-arm64.json +1 -1
- package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-x64.gz +0 -0
- package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-x64.json +1 -1
- package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-arm64.gz +0 -0
- package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-arm64.json +1 -1
- package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-x64.gz +0 -0
- package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-x64.json +1 -1
- package/node_modules/pi-better-subagents/shared-operation-coordinator/src/assignment-changes.ts +33 -0
- package/node_modules/pi-better-subagents/shared-operation-coordinator/src/background-parent-callbacks.ts +5 -0
- package/node_modules/pi-better-subagents/shared-operation-coordinator/src/result-supervision.ts +23 -1
- package/node_modules/pi-better-subagents/shared-operation-coordinator/src/schema.ts +28 -11
- package/node_modules/pi-better-subagents/shared-operation-coordinator/src/store.ts +9 -3
- package/node_modules/pi-better-subagents/worker-waits.ts +3 -14
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.57.0] - 2026-11-26
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Drag the divider between workflow tasks and the diagram, or enter `/todo split 3:2` to set their relative widths. The session branch remembers the split.
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Workflow panels open with equal column widths. Each task fits on one row and shows its status with an icon. Narrow terminals stack the list and diagram.
|
|
12
|
+
- Bundle Goal 0.17.1, Background Tasks 0.21.2, and Subagents 0.39.2.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Reuse session history during divider drags and skip visual Goal inspection in headless sessions. Switching branches during a drag discards the unfinished resize.
|
|
17
|
+
|
|
3
18
|
## [0.56.0] - 2026-11-26
|
|
4
19
|
|
|
5
20
|
### Changed
|
package/README.md
CHANGED
|
@@ -45,8 +45,10 @@ work. Any of `doneWhen`, `boundaries` and `todo` may be omitted. Set
|
|
|
45
45
|
clients using the legacy `outcome` field remain supported.
|
|
46
46
|
|
|
47
47
|
Todo uses the same workflow view for a bound task plan and a dynamic workflow.
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
The task list and diagram start at equal widths. Drag their divider in fullscreen Pi
|
|
49
|
+
or enter `/todo split 3:2` to give the task list three fifths of the available width.
|
|
50
|
+
The session remembers the ratio across reloads. Use `/todo split 1:1` to restore equal columns.
|
|
51
|
+
Below 36 terminal columns, the diagram follows the task list.
|
|
50
52
|
|
|
51
53
|
Existing Plan session histories restore as Todo. Workflow task-plan files and
|
|
52
54
|
revision checks continue to govern workflow-owned plans. See the [usage guide](docs/usage.md#goal--todo).
|
|
@@ -33,7 +33,7 @@ function diagramNodes(run: WorkflowRun, selected?: string): WorkflowNode[] {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export function renderDynamicFrame(run: WorkflowRun, width: number, theme: WorkflowTheme, expanded: boolean, header: CompactTaskHeader, selected?: string): WorkflowFrame {
|
|
36
|
+
export function renderDynamicFrame(run: WorkflowRun, width: number, theme: WorkflowTheme, expanded: boolean, header: CompactTaskHeader, selected?: string, leftShare = 0.5): WorkflowFrame {
|
|
37
37
|
const size = Math.max(1, Math.floor(width));
|
|
38
38
|
const rows = run.steps.map(step => {
|
|
39
39
|
const state = phase(run, step);
|
|
@@ -51,7 +51,7 @@ export function renderDynamicFrame(run: WorkflowRun, width: number, theme: Workf
|
|
|
51
51
|
...header, subtitle: run.objective, runtime: header.runtime ?? { subject: "workflow", status: run.evidence ? "complete" : "active" },
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
const frame = renderWorkflowFrame(rows, diagramNodes(run, selected), heading, size, theme, expanded);
|
|
54
|
+
const frame = renderWorkflowFrame(rows, diagramNodes(run, selected), heading, size, theme, expanded, leftShare);
|
|
55
55
|
const step = run.steps.find(s => s.id === selected);
|
|
56
56
|
if (step) {
|
|
57
57
|
const entry = run.history.filter(h => h.step === step.id).at(-1);
|
|
@@ -31,9 +31,9 @@ import {
|
|
|
31
31
|
import { renderCompactPlan } from "./plan-render.js";
|
|
32
32
|
import { createPlanWidget } from "./plan-widget.js";
|
|
33
33
|
import { installLegacyPlanMask, type LegacyPlanMask } from "./legacy-plan-mask.js";
|
|
34
|
-
import { COMPACT_PLAN_ROWS } from "./plan-presentation.js";
|
|
34
|
+
import { COMPACT_PLAN_ROWS, plainPlanTheme } from "./plan-presentation.js";
|
|
35
35
|
import {
|
|
36
|
-
readRushPlan, renderRushPlan, workflowBinding,
|
|
36
|
+
readRushPlan, renderRushFrame, renderRushPlan, workflowBinding,
|
|
37
37
|
WORKFLOW_PLAN_ENTRY, visibleRushUnits, type RushPlan, type WorkflowPlanBinding,
|
|
38
38
|
} from "./workflow-plan.js";
|
|
39
39
|
import { cancelledRowsClearDelay, observeCancelledRows } from "./cancelled-rows.js";
|
|
@@ -134,6 +134,7 @@ const PLAN_ACTIONS: readonly AutocompleteItem[] = [
|
|
|
134
134
|
{ value: "show", label: "show", description: "Restore automatic Todo display" },
|
|
135
135
|
{ value: "expand", label: "expand", description: "Show all steps in the Todo widget" },
|
|
136
136
|
{ value: "collapse", label: "collapse", description: "Show up to five relevant steps" },
|
|
137
|
+
{ value: "split ", label: "split", description: "Set workflow task and diagram widths, e.g. split 3:2 or split 1:1" },
|
|
137
138
|
{ value: "pin auto", label: "pin auto", description: "Use automatic Todo pinning" },
|
|
138
139
|
{ value: "pin on", label: "pin on", description: "Keep Todo pinned" },
|
|
139
140
|
{ value: "pin off", label: "pin off", description: "Keep Todo unpinned" },
|
|
@@ -158,9 +159,9 @@ export function ledgerArgumentCompletions(argumentPrefix: string): AutocompleteI
|
|
|
158
159
|
return matches.length > 0 ? [...matches] : null;
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
function workflowPlanOwner(ctx: ExtensionContext): string | null {
|
|
162
|
+
function workflowPlanOwner(ctx: ExtensionContext, entries = ctx.sessionManager.getBranch()): string | null {
|
|
162
163
|
let owner: string | null = null;
|
|
163
|
-
for (const entry of
|
|
164
|
+
for (const entry of entries) {
|
|
164
165
|
if (entry.type !== "custom" || entry.customType !== "pi-better-workflow") continue;
|
|
165
166
|
const data = entry.data as { version?: unknown; kind?: unknown; owner?: { name?: unknown; planOwner?: unknown } } | null;
|
|
166
167
|
if (data?.version !== 1) continue;
|
|
@@ -206,10 +207,12 @@ export default function taskContextExtension(pi: ExtensionAPI): void {
|
|
|
206
207
|
let currentPlan: PlanSnapshot | null = null;
|
|
207
208
|
let displayMode: PlanDisplayMode = "auto";
|
|
208
209
|
let expanded = false;
|
|
210
|
+
let leftShare = 0.5;
|
|
209
211
|
let displayedWorkflowOwner: string | null = null;
|
|
210
212
|
let rushBinding: WorkflowPlanBinding | null = null;
|
|
211
213
|
let rushPlan: RushPlan | null = null;
|
|
212
214
|
let rushError: string | null = null;
|
|
215
|
+
let invalidateWidget: (() => void) | undefined;
|
|
213
216
|
let refreshWidget: ((force?: boolean) => void) | undefined;
|
|
214
217
|
let completedPlanClearTimer: ReturnType<typeof setTimeout> | undefined;
|
|
215
218
|
let cancelledRowsTimer: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -456,6 +459,7 @@ export default function taskContextExtension(pi: ExtensionAPI): void {
|
|
|
456
459
|
() => { syncTools(); refresh(true); });
|
|
457
460
|
|
|
458
461
|
const restore = (ctx: ExtensionContext): void => {
|
|
462
|
+
invalidateWidget?.();
|
|
459
463
|
const entries = ctx.sessionManager.getBranch();
|
|
460
464
|
sessionContext = ctx;
|
|
461
465
|
dynamic.restore(ctx);
|
|
@@ -482,6 +486,7 @@ export default function taskContextExtension(pi: ExtensionAPI): void {
|
|
|
482
486
|
if (rushBinding) loadRushPlan(ctx);
|
|
483
487
|
displayMode = state.displayMode;
|
|
484
488
|
expanded = state.expanded;
|
|
489
|
+
leftShare = state.leftShare;
|
|
485
490
|
refresh(true);
|
|
486
491
|
scheduleCompletedPlanClear();
|
|
487
492
|
};
|
|
@@ -506,6 +511,13 @@ export default function taskContextExtension(pi: ExtensionAPI): void {
|
|
|
506
511
|
refresh(true);
|
|
507
512
|
};
|
|
508
513
|
|
|
514
|
+
const saveWorkflowSplit = (share: number): void => {
|
|
515
|
+
if (share === leftShare) return;
|
|
516
|
+
pi.appendEntry(EXTENSION_NAME, { version: 1, kind: "workflow-split", leftShare: share, at: Math.floor(Date.now() / 1_000) });
|
|
517
|
+
leftShare = share;
|
|
518
|
+
refresh(true);
|
|
519
|
+
};
|
|
520
|
+
|
|
509
521
|
const installWidget = (ctx: ExtensionContext): void => {
|
|
510
522
|
if (!ctx.hasUI) return;
|
|
511
523
|
const startControl: GoalPanelStartRequest = { action: "probe" };
|
|
@@ -513,18 +525,36 @@ export default function taskContextExtension(pi: ExtensionAPI): void {
|
|
|
513
525
|
setNavigatorPanel(ctx,
|
|
514
526
|
EXTENSION_NAME,
|
|
515
527
|
(tui, theme) => {
|
|
516
|
-
const
|
|
528
|
+
const readWidgetState = () => {
|
|
529
|
+
const entries = ctx.sessionManager.getBranch();
|
|
530
|
+
return {
|
|
531
|
+
goal: reconstructGoalSnapshot(entries), owner: workflowPlanOwner(ctx, entries),
|
|
532
|
+
binding: rushBinding ? workflowBinding(entries) : null,
|
|
533
|
+
};
|
|
534
|
+
};
|
|
535
|
+
let branchState: ReturnType<typeof readWidgetState> | undefined;
|
|
536
|
+
let branchLeaf: string | null | undefined;
|
|
537
|
+
const localRefresh = (force = false): void => {
|
|
538
|
+
if (force) branchState = undefined;
|
|
539
|
+
tui.requestRender(force);
|
|
540
|
+
};
|
|
517
541
|
refreshWidget = localRefresh;
|
|
518
|
-
let
|
|
542
|
+
let workflowFrame: WorkflowFrame | undefined;
|
|
519
543
|
let renderedRun: string | undefined;
|
|
520
544
|
let selectedStep: string | undefined;
|
|
521
545
|
let startButton: { y: number; left: number; right: number; task: Outcome } | undefined;
|
|
522
546
|
const widget = createPlanWidget(
|
|
523
|
-
(width: number, disclosure?: string): string[] => {
|
|
524
|
-
|
|
547
|
+
(width: number, disclosure?: string, previewShare = leftShare): string[] => {
|
|
548
|
+
workflowFrame = undefined;
|
|
525
549
|
startButton = undefined;
|
|
526
|
-
if (displayMode === "hidden"
|
|
527
|
-
const
|
|
550
|
+
if (displayMode === "hidden") return [];
|
|
551
|
+
const leaf = ctx.sessionManager.getLeafId?.();
|
|
552
|
+
if (!branchState || leaf === undefined || leaf !== branchLeaf) {
|
|
553
|
+
branchState = readWidgetState();
|
|
554
|
+
branchLeaf = leaf;
|
|
555
|
+
}
|
|
556
|
+
if (displayedWorkflowOwner !== branchState.owner) return [];
|
|
557
|
+
const { goal } = branchState;
|
|
528
558
|
const boundGoal = goal && outcome?.goalId === goal.goalId ? goal : null;
|
|
529
559
|
const header: CompactTaskHeader = {
|
|
530
560
|
subtitle: outcome?.objective, disclosure,
|
|
@@ -540,20 +570,22 @@ export default function taskContextExtension(pi: ExtensionAPI): void {
|
|
|
540
570
|
? renderCompactTaskHeader(undefined, width, theme as never, header) : [];
|
|
541
571
|
if (displayedWorkflowOwner || rushBinding) {
|
|
542
572
|
if (!rushBinding || (displayedWorkflowOwner && rushBinding.owner !== displayedWorkflowOwner) ||
|
|
543
|
-
!
|
|
573
|
+
!branchState.binding) return heading();
|
|
544
574
|
const fg = typeof theme?.fg === "function"
|
|
545
575
|
? (color: string, value: string) => theme.fg(color as never, value)
|
|
546
|
-
:
|
|
547
|
-
|
|
576
|
+
: plainPlanTheme.fg;
|
|
577
|
+
if (!rushPlan) return heading();
|
|
578
|
+
workflowFrame = renderRushFrame(rushPlan, width, { fg }, rushBinding.owner, !displayedWorkflowOwner, expanded, header, previewShare);
|
|
579
|
+
return workflowFrame.lines;
|
|
548
580
|
}
|
|
549
581
|
const run = dynamic.run();
|
|
550
582
|
if (run) {
|
|
551
583
|
if (renderedRun !== run.id) selectedStep = undefined;
|
|
552
584
|
renderedRun = run.id;
|
|
553
|
-
|
|
585
|
+
workflowFrame = renderDynamicFrame(run, width, theme, expanded, {
|
|
554
586
|
disclosure, ledger: header.ledger, runtime: goal && goal.goalId === run.goalId ? goalHeaderRuntime(goal) : undefined,
|
|
555
|
-
}, selectedStep);
|
|
556
|
-
return
|
|
587
|
+
}, selectedStep, previewShare);
|
|
588
|
+
return workflowFrame.lines;
|
|
557
589
|
}
|
|
558
590
|
return currentPlan ? renderCompactPlan(currentPlan, width, theme as never, expanded, header) : heading();
|
|
559
591
|
},
|
|
@@ -573,16 +605,19 @@ export default function taskContextExtension(pi: ExtensionAPI): void {
|
|
|
573
605
|
pi.events.emit(GOAL_PANEL_START_EVENT, { action: "start", sessionId, objective: button.task.objective } satisfies GoalPanelStartRequest);
|
|
574
606
|
};
|
|
575
607
|
}
|
|
576
|
-
const step =
|
|
608
|
+
const step = workflowFrame?.stepAt(x, y);
|
|
577
609
|
if (!step || dynamic.run()?.id !== renderedRun) return undefined;
|
|
578
610
|
return () => { selectedStep = selectedStep === step ? undefined : step; };
|
|
579
611
|
},
|
|
612
|
+
{ resizeAt: (x, y) => workflowFrame?.resizeAt(x, y), save: saveWorkflowSplit },
|
|
580
613
|
);
|
|
614
|
+
invalidateWidget = widget.invalidate;
|
|
581
615
|
return {
|
|
582
616
|
...widget,
|
|
583
617
|
dispose() {
|
|
584
618
|
startButton = undefined;
|
|
585
|
-
|
|
619
|
+
widget.invalidate();
|
|
620
|
+
if (refreshWidget === localRefresh) { refreshWidget = undefined; invalidateWidget = undefined; }
|
|
586
621
|
},
|
|
587
622
|
};
|
|
588
623
|
},
|
|
@@ -871,13 +906,23 @@ export default function taskContextExtension(pi: ExtensionAPI): void {
|
|
|
871
906
|
setExpanded(input === "expand");
|
|
872
907
|
return;
|
|
873
908
|
}
|
|
909
|
+
if (/^split(?:\s|$)/.test(input)) {
|
|
910
|
+
const ratio = /^split\s+(\d+)\s*:\s*(\d+)$/.exec(input);
|
|
911
|
+
const left = Number(ratio?.[1]), right = Number(ratio?.[2]);
|
|
912
|
+
if (!Number.isSafeInteger(left + right) || left <= 0 || right <= 0) {
|
|
913
|
+
ctx.ui.notify("Use /todo split LEFT:RIGHT with positive integers, e.g. /todo split 3:2.", "warning");
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
saveWorkflowSplit(left / (left + right));
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
874
919
|
const pinMode = input.match(/^pin\s+(auto|on|off)$/)?.[1] as PlanDisplayMode | undefined;
|
|
875
920
|
if (pinMode) {
|
|
876
921
|
setDisplayMode(pinMode);
|
|
877
922
|
ctx.ui.notify(`Todo display: ${pinMode}.`, "info");
|
|
878
923
|
return;
|
|
879
924
|
}
|
|
880
|
-
ctx.ui.notify("Usage: /todo [clear|hide|show|expand|collapse|pin auto|pin on|pin off]", "warning");
|
|
925
|
+
ctx.ui.notify("Usage: /todo [clear|hide|show|expand|collapse|split LEFT:RIGHT|pin auto|pin on|pin off]", "warning");
|
|
881
926
|
},
|
|
882
927
|
});
|
|
883
928
|
|
|
@@ -987,7 +1032,7 @@ export default function taskContextExtension(pi: ExtensionAPI): void {
|
|
|
987
1032
|
request.ledgerBlocker = error instanceof Error ? error.message : String(error);
|
|
988
1033
|
}
|
|
989
1034
|
}
|
|
990
|
-
if (
|
|
1035
|
+
if (!request.workflowOwnsPlan) {
|
|
991
1036
|
request.openSteps = currentPlan?.steps.filter(step => step.status !== "completed").map(step => step.step);
|
|
992
1037
|
}
|
|
993
1038
|
}
|
|
@@ -1004,14 +1049,17 @@ export default function taskContextExtension(pi: ExtensionAPI): void {
|
|
|
1004
1049
|
return;
|
|
1005
1050
|
}
|
|
1006
1051
|
if (request.action === "inspect") {
|
|
1007
|
-
|
|
1052
|
+
request.display = false;
|
|
1053
|
+
if (!sessionContext?.hasUI || displayMode === "hidden" || !request.goalId ||
|
|
1054
|
+
typeof request.width !== "number" || !Number.isFinite(request.width) || request.width <= 0) return;
|
|
1008
1055
|
const run = !displayedWorkflowOwner && !rushBinding ? dynamic.run() : undefined;
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1056
|
+
if (request.goalId !== (run ? run.goalId : outcome?.goalId)) return;
|
|
1057
|
+
const entries = sessionContext.sessionManager.getBranch();
|
|
1058
|
+
const goal = reconstructGoalSnapshot(entries);
|
|
1059
|
+
request.display = goal?.goalId === request.goalId && canRenderTaskRuntime(request.width, goalHeaderRuntime(goal)) &&
|
|
1060
|
+
displayedWorkflowOwner === workflowPlanOwner(sessionContext, entries);
|
|
1061
|
+
return;
|
|
1013
1062
|
}
|
|
1014
|
-
if (request.action === "inspect") return;
|
|
1015
1063
|
if (request.action === "bind") {
|
|
1016
1064
|
if (request.goalId && request.objective?.trim() === outcome?.objective && outcome?.status === "active" && !outcome.goalId) {
|
|
1017
1065
|
saveOutcome({ ...outcome, goalId: request.goalId });
|
|
@@ -1096,6 +1144,8 @@ export default function taskContextExtension(pi: ExtensionAPI): void {
|
|
|
1096
1144
|
if (typeof unsubscribeWorkflow === "function") unsubscribeWorkflow();
|
|
1097
1145
|
if (typeof unsubscribeSettings === "function") unsubscribeSettings();
|
|
1098
1146
|
if (typeof unsubscribeTask === "function") unsubscribeTask();
|
|
1147
|
+
invalidateWidget?.();
|
|
1148
|
+
invalidateWidget = undefined;
|
|
1099
1149
|
refreshWidget = undefined;
|
|
1100
1150
|
sessionContext = undefined;
|
|
1101
1151
|
try {
|
|
@@ -17,6 +17,7 @@ export interface ReconstructedPlanState {
|
|
|
17
17
|
plan: PlanSnapshot | null;
|
|
18
18
|
displayMode: PlanDisplayMode;
|
|
19
19
|
expanded: boolean;
|
|
20
|
+
leftShare: number;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
function nowSeconds(): number {
|
|
@@ -178,14 +179,16 @@ export function reconstructPlanState(entries: Iterable<SessionEntryLike>): Recon
|
|
|
178
179
|
let plan: PlanSnapshot | null = null;
|
|
179
180
|
let displayMode: PlanDisplayMode = "auto";
|
|
180
181
|
let expanded = false;
|
|
182
|
+
let leftShare = 0.5;
|
|
181
183
|
for (const entry of entries) {
|
|
182
184
|
if (entry.type !== "custom" || entry.customType !== EXTENSION_NAME || !isPlanEntry(entry.data)) continue;
|
|
183
185
|
if (entry.data.kind === "set") plan = entry.data.plan;
|
|
184
186
|
else if (entry.data.kind === "clear") plan = null;
|
|
185
187
|
else if (entry.data.kind === "display") displayMode = entry.data.mode;
|
|
188
|
+
else if (entry.data.kind === "workflow-split") leftShare = entry.data.leftShare;
|
|
186
189
|
else expanded = entry.data.expanded;
|
|
187
190
|
}
|
|
188
|
-
return { plan, displayMode, expanded };
|
|
191
|
+
return { plan, displayMode, expanded, leftShare };
|
|
189
192
|
}
|
|
190
193
|
|
|
191
194
|
function isPlanEntry(value: unknown): value is PlanEntry {
|
|
@@ -193,6 +196,7 @@ function isPlanEntry(value: unknown): value is PlanEntry {
|
|
|
193
196
|
const candidate = value as Partial<PlanEntry>;
|
|
194
197
|
if (candidate.version !== 1) return false;
|
|
195
198
|
if (candidate.kind === "clear") return true;
|
|
199
|
+
if (candidate.kind === "workflow-split") return typeof candidate.leftShare === "number" && candidate.leftShare > 0 && candidate.leftShare < 1;
|
|
196
200
|
if (candidate.kind === "expansion") return typeof candidate.expanded === "boolean";
|
|
197
201
|
if (candidate.kind === "display") {
|
|
198
202
|
return candidate.mode === "auto" || candidate.mode === "on" || candidate.mode === "off" || candidate.mode === "hidden";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Component } from "@earendil-works/pi-tui";
|
|
2
|
-
|
|
2
|
+
import type { WorkflowFrame } from "./workflow-view.js";
|
|
3
3
|
|
|
4
4
|
// Structural typing keeps keyboard-only Pi versions compatible with the fullscreen mouse API.
|
|
5
5
|
interface PlanMouseEvent {
|
|
@@ -8,27 +8,63 @@ interface PlanMouseEvent {
|
|
|
8
8
|
x: number;
|
|
9
9
|
y: number;
|
|
10
10
|
width: number;
|
|
11
|
+
screenX?: number;
|
|
12
|
+
screenY?: number;
|
|
11
13
|
shift?: boolean;
|
|
12
14
|
alt?: boolean;
|
|
13
15
|
ctrl?: boolean;
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
interface PlanMouseResult {
|
|
19
|
+
handled: true;
|
|
20
|
+
render: boolean;
|
|
21
|
+
capture?: boolean;
|
|
22
|
+
target?: { component: Component; originX: number; originY: number; width: number; height: number };
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
export function createPlanWidget(
|
|
17
|
-
render: (width: number, disclosure?: string) => string[],
|
|
26
|
+
render: (width: number, disclosure?: string, previewShare?: number) => string[],
|
|
18
27
|
isFoldable: () => boolean,
|
|
19
28
|
isExpanded: () => boolean,
|
|
20
29
|
toggle: () => void,
|
|
21
30
|
actionAt?: (x: number, y: number) => (() => void) | undefined,
|
|
22
|
-
|
|
31
|
+
divider?: { resizeAt: WorkflowFrame["resizeAt"]; save(share: number): void },
|
|
32
|
+
): Component & { handleMouse(event: PlanMouseEvent): PlanMouseResult | undefined } {
|
|
23
33
|
let lines: string[] = [];
|
|
34
|
+
let drag: { start: number; width: number; shareAt(x: number): number; preview?: number } | undefined;
|
|
24
35
|
return {
|
|
25
36
|
render(width) {
|
|
26
|
-
|
|
37
|
+
if (drag && drag.width !== width) drag = undefined;
|
|
38
|
+
lines = render(width, isFoldable() ? isExpanded() ? "▾" : "▸" : undefined, drag?.preview);
|
|
27
39
|
return lines.length ? ["", ...lines] : [];
|
|
28
40
|
},
|
|
29
41
|
handleMouse(event) {
|
|
42
|
+
if (drag && (event.type === "drag" || event.type === "release")) {
|
|
43
|
+
const share = event.x === drag.start ? undefined : drag.shareAt(event.x);
|
|
44
|
+
const changed = share !== drag.preview;
|
|
45
|
+
drag.preview = share;
|
|
46
|
+
if (event.type === "release") {
|
|
47
|
+
drag = undefined;
|
|
48
|
+
if (share !== undefined) divider?.save(share);
|
|
49
|
+
}
|
|
50
|
+
return { handled: true, render: changed };
|
|
51
|
+
}
|
|
30
52
|
if ((event.type !== "click" && event.type !== "press") || event.button !== "left" || event.shift || event.alt || event.ctrl ||
|
|
31
53
|
event.x < 0 || event.x >= event.width || event.y < 1 || event.y > lines.length) return undefined;
|
|
54
|
+
const shareAt = divider?.resizeAt(event.x, event.y - 1);
|
|
55
|
+
if (shareAt) {
|
|
56
|
+
if (event.type === "click") return { handled: true, render: false };
|
|
57
|
+
drag = { start: event.x, width: event.width, shareAt };
|
|
58
|
+
// Capture this widget with its local origin inside the composite navigator panel.
|
|
59
|
+
if (event.screenX === undefined || event.screenY === undefined) return { handled: true, capture: true, render: false };
|
|
60
|
+
return {
|
|
61
|
+
handled: true, render: false, capture: true,
|
|
62
|
+
target: {
|
|
63
|
+
component: this, originX: event.screenX - event.x, originY: event.screenY - event.y,
|
|
64
|
+
width: event.width, height: lines.length + 1,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
32
68
|
const action = actionAt?.(event.x, event.y - 1) ?? (isFoldable() ? toggle : undefined);
|
|
33
69
|
if (!action) return undefined;
|
|
34
70
|
// Pi synthesizes click only for a component that handled the initial press.
|
|
@@ -36,6 +72,6 @@ export function createPlanWidget(
|
|
|
36
72
|
action();
|
|
37
73
|
return { handled: true, render: true };
|
|
38
74
|
},
|
|
39
|
-
invalidate() { lines = []; },
|
|
75
|
+
invalidate() { lines = []; drag = undefined; },
|
|
40
76
|
};
|
|
41
77
|
}
|
|
@@ -40,4 +40,5 @@ export type PlanEntry =
|
|
|
40
40
|
| { version: 1; kind: "set"; plan: PlanSnapshot; at: number }
|
|
41
41
|
| { version: 1; kind: "clear"; at: number }
|
|
42
42
|
| { version: 1; kind: "display"; mode: PlanDisplayMode; at: number }
|
|
43
|
+
| { version: 1; kind: "workflow-split"; leftShare: number; at: number }
|
|
43
44
|
| { version: 1; kind: "expansion"; expanded: boolean; at: number };
|
|
@@ -5,7 +5,7 @@ import type { CompactTaskHeader } from "./compact-task-header.js";
|
|
|
5
5
|
import { workflowDiagram, type DiagramPart, type WorkflowNode } from "./workflow-diagram.js";
|
|
6
6
|
import {
|
|
7
7
|
alignedPlanLabels, plainPlanTheme, planRowTitleColor, planText, renderPlanHeading, renderPlanPresentation, statusStyle,
|
|
8
|
-
type DisplayStatus, type PlanPresentation,
|
|
8
|
+
type DisplayStatus, type PlanRenderTheme, type PlanPresentation,
|
|
9
9
|
} from "./plan-presentation.js";
|
|
10
10
|
|
|
11
11
|
export const WORKFLOW_PLAN_ENTRY = "pi-better-workflow-plan";
|
|
@@ -375,12 +375,19 @@ export function renderRushPlan(
|
|
|
375
375
|
header?: CompactTaskHeader,
|
|
376
376
|
): string[] {
|
|
377
377
|
const theme = fg ? { fg } : plainPlanTheme;
|
|
378
|
-
const presentation = presentRushPlan(plan, owner, readOnly);
|
|
379
|
-
const nodes = issueWorkflowNodes(plan);
|
|
380
378
|
if (full) {
|
|
381
|
-
const
|
|
379
|
+
const presentation = presentRushPlan(plan, owner, readOnly);
|
|
380
|
+
const graph = workflowDiagram(issueWorkflowNodes(plan), Math.max(1, width - 2));
|
|
382
381
|
return renderPlanPresentation({ ...presentation, metadata: [...(presentation.metadata ?? []), ...graph] }, width, theme, true);
|
|
383
382
|
}
|
|
383
|
+
return renderRushFrame(plan, width, theme, owner, readOnly, expanded, header).lines;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export function renderRushFrame(
|
|
387
|
+
plan: RushPlan, width: number, theme: PlanRenderTheme, owner: string, readOnly: boolean,
|
|
388
|
+
expanded: boolean, header?: CompactTaskHeader, leftShare = 0.5,
|
|
389
|
+
) {
|
|
390
|
+
const presentation = presentRushPlan(plan, owner, readOnly);
|
|
384
391
|
const heading = renderPlanHeading(presentation, width, theme, header);
|
|
385
392
|
const labels = alignedPlanLabels(presentation.rows);
|
|
386
393
|
const rows = presentation.rows.map((row, index) => {
|
|
@@ -392,8 +399,7 @@ export function renderRushPlan(
|
|
|
392
399
|
{ color: "dim", text: labels[index]! + " " },
|
|
393
400
|
{ color: planRowTitleColor(row.status), text: row.title },
|
|
394
401
|
],
|
|
395
|
-
badge: { color: style.color, text: row.statusLabel ?? style.label },
|
|
396
402
|
};
|
|
397
403
|
});
|
|
398
|
-
return renderWorkflowFrame(rows,
|
|
404
|
+
return renderWorkflowFrame(rows, issueWorkflowNodes(plan), heading, width, theme, expanded, leftShare);
|
|
399
405
|
}
|
|
@@ -8,22 +8,26 @@ interface WorkflowTask {
|
|
|
8
8
|
id?: string;
|
|
9
9
|
status: DisplayStatus;
|
|
10
10
|
label: DiagramPart[];
|
|
11
|
-
badge?: DiagramPart;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export interface WorkflowFrame {
|
|
15
14
|
lines: string[];
|
|
16
15
|
stepAt(x: number, y: number): string | undefined;
|
|
16
|
+
resizeAt(x: number, y: number): ((nextX: number) => number) | undefined;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function renderWorkflowFrame(
|
|
20
20
|
tasks: WorkflowTask[], nodes: WorkflowNode[], heading: string[],
|
|
21
|
-
width: number, theme: WorkflowTheme, expanded: boolean,
|
|
21
|
+
width: number, theme: WorkflowTheme, expanded: boolean, leftShare = 0.5,
|
|
22
22
|
): WorkflowFrame {
|
|
23
23
|
const size = Math.max(1, Math.floor(width));
|
|
24
24
|
const split = size >= 36 && nodes.length > 0;
|
|
25
|
-
const
|
|
26
|
-
const
|
|
25
|
+
const gutter = " │ ";
|
|
26
|
+
const available = size - visibleWidth(gutter);
|
|
27
|
+
const fitColumn = (cells: number) => Math.max(12, Math.min(available - 12, cells));
|
|
28
|
+
// Round to the nearest terminal cell, giving a tied cell to the diagram.
|
|
29
|
+
const listWidth = split ? fitColumn(Math.ceil(available * leftShare - 0.5)) : size;
|
|
30
|
+
const graphWidth = split ? available - listWidth : size;
|
|
27
31
|
const styled = (part: DiagramPart) => {
|
|
28
32
|
const value = theme.fg(part.color, planText(part.text));
|
|
29
33
|
return part.selected ? theme.underline?.(value) ?? theme.fg("accent", value) : value;
|
|
@@ -39,36 +43,28 @@ export function renderWorkflowFrame(
|
|
|
39
43
|
if (index > previous + 1) omitted(index - previous - 1);
|
|
40
44
|
const task = tasks[index]!;
|
|
41
45
|
const label = task.label.map(styled).join("");
|
|
42
|
-
|
|
43
|
-
if (badge && visibleWidth(label) + 2 + visibleWidth(badge) <= listWidth) {
|
|
44
|
-
list.push({ line: label + " " + badge, id: task.id });
|
|
45
|
-
} else {
|
|
46
|
-
list.push({ line: truncateToWidth(label, listWidth), id: task.id });
|
|
47
|
-
if (badge) {
|
|
48
|
-
const indent = " ".repeat(Math.min(2, listWidth - 1));
|
|
49
|
-
const available = listWidth - indent.length;
|
|
50
|
-
// Keep short statuses readable at the split threshold. External status text can be arbitrarily long.
|
|
51
|
-
const wrapped = visibleWidth(badge) <= available * 2 ? wrapTextWithAnsi(badge, available) : [];
|
|
52
|
-
const badgeLines = wrapped.length > 0 && wrapped.length <= 2 ? wrapped : [truncateToWidth(badge, available)];
|
|
53
|
-
for (const line of badgeLines) list.push({ line: indent + line, id: task.id });
|
|
54
|
-
}
|
|
55
|
-
}
|
|
46
|
+
list.push({ line: label, id: task.id });
|
|
56
47
|
previous = index;
|
|
57
48
|
}
|
|
58
49
|
if (previous < tasks.length - 1) omitted(tasks.length - previous - 1);
|
|
59
50
|
|
|
60
51
|
const lines = [...heading];
|
|
61
52
|
if (split) {
|
|
62
|
-
const
|
|
53
|
+
const divider = theme.fg("dim", gutter);
|
|
63
54
|
for (let i = 0; i < Math.max(list.length, graph.length); i++) {
|
|
64
55
|
const left = truncateToWidth(list[i]?.line ?? "", listWidth);
|
|
65
|
-
lines.push(left + " ".repeat(listWidth - visibleWidth(left)) +
|
|
56
|
+
lines.push(left + " ".repeat(listWidth - visibleWidth(left)) + divider + (graph[i] ?? ""));
|
|
66
57
|
}
|
|
67
58
|
} else {
|
|
68
59
|
lines.push(...list.map(row => row.line), ...graph);
|
|
69
60
|
}
|
|
61
|
+
const bodyEnd = lines.length;
|
|
70
62
|
return {
|
|
71
63
|
lines: lines.map(line => truncateToWidth(line, size)),
|
|
64
|
+
resizeAt(x, y) {
|
|
65
|
+
if (!split || y < heading.length || y >= bodyEnd || Math.abs(x - (listWidth + 1)) > 1) return;
|
|
66
|
+
return nextX => fitColumn(listWidth + nextX - x) / available;
|
|
67
|
+
},
|
|
72
68
|
stepAt: (x, y) => x >= 0 && x < listWidth ? list[y - heading.length]?.id : undefined,
|
|
73
69
|
};
|
|
74
70
|
}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"c02d951603064af3401fd640dfd2c05b18ae97299509a55db82d58aa5c69a2f0","piSdkVersion":"1.4.0","nodeVersion":"24.14.1","platform":"darwin-arm64","dependencyLockDigest":"300f19071b0e3f4e68220f42d7976b92dc6a629dd2719325fb7fad41781164c8","protocolVersion":1,"serverVersion":"0.8.2","contentId":"d72a5f1211f34ae97dc84b1c891a38714ab7c41c429332549d4a115af142cd9c"},"sha256":"0286673fe48ab8553727b4794b39721ddb96573b9c31b885918ee4d1df0c1a68"}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"c02d951603064af3401fd640dfd2c05b18ae97299509a55db82d58aa5c69a2f0","piSdkVersion":"1.4.0","nodeVersion":"24.14.1","platform":"darwin-x64","dependencyLockDigest":"300f19071b0e3f4e68220f42d7976b92dc6a629dd2719325fb7fad41781164c8","protocolVersion":1,"serverVersion":"0.8.2","contentId":"0357f903ca7cbcc813194f224e3e1816c0abade6322e8d1321f4b07c8df4a08c"},"sha256":"3f9e9896c4c7b46b6a147e618883616aef287eb5c5a54cb214175354a4741d9b"}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"c02d951603064af3401fd640dfd2c05b18ae97299509a55db82d58aa5c69a2f0","piSdkVersion":"1.4.0","nodeVersion":"24.14.1","platform":"linux-arm64","dependencyLockDigest":"300f19071b0e3f4e68220f42d7976b92dc6a629dd2719325fb7fad41781164c8","protocolVersion":1,"serverVersion":"0.8.2","contentId":"9f205935cb4aee5fb4d817661f86939716c909213b47775c2dcf83f9755122d1"},"sha256":"e02abd34422fba070bc44c59ab190ee61f69b9f2a6c9d926e64485461bfb48ad"}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"build":{"format":1,"sourceDigest":"
|
|
1
|
+
{"build":{"format":1,"sourceDigest":"c02d951603064af3401fd640dfd2c05b18ae97299509a55db82d58aa5c69a2f0","piSdkVersion":"1.4.0","nodeVersion":"24.14.1","platform":"linux-x64","dependencyLockDigest":"300f19071b0e3f4e68220f42d7976b92dc6a629dd2719325fb7fad41781164c8","protocolVersion":1,"serverVersion":"0.8.2","contentId":"36ab9cbfc092b10d96f6d83473057fd4552929ff53ec3972caee1ed83ef50242"},"sha256":"2cfa925caa8783e13a9b92dbe0e8fcac28bbe048978bbdbb08c9f4de78ab2bf1"}
|