@herbertgao/pi-extensions 2026.11.13 → 2026.11.14
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 +10 -0
- package/README.md +4 -4
- package/node_modules/@herbertgao/pi-inline-skill-commands/README.md +6 -2
- package/node_modules/@herbertgao/pi-inline-skill-commands/package.json +1 -1
- package/node_modules/@herbertgao/pi-inline-skill-commands/src/index.ts +41 -15
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +10 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +37 -7
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +113 -34
- package/node_modules/@herbertgao/pi-subagents/package.json +9 -4
- package/node_modules/@herbertgao/pi-subagents/skills/workflow-authoring/SKILL.md +147 -0
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +48 -32
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +16 -8
- package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +16 -6
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +99 -7
- package/node_modules/@herbertgao/pi-subagents/src/mention.ts +5 -7
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +26 -0
- package/node_modules/@herbertgao/pi-subagents/src/structured-output.ts +13 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +55 -8
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-card-redraw.ts +86 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-card.ts +5 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-dialog.ts +478 -115
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-menu.ts +77 -6
- package/node_modules/@herbertgao/pi-subagents/src/workflow/agent-detail.ts +148 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +88 -14
- package/node_modules/@herbertgao/pi-subagents/src/workflow/journal.ts +8 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/json-schema.ts +507 -57
- package/node_modules/@herbertgao/pi-subagents/src/workflow/progress.ts +41 -11
- package/node_modules/@herbertgao/pi-subagents/src/workflow/runtime.ts +106 -34
- package/node_modules/@herbertgao/pi-subagents/src/workflow/task.ts +43 -5
- package/node_modules/@herbertgao/pi-subagents/src/workflow/tool-description.ts +93 -153
- package/node_modules/@herbertgao/pi-subagents/src/workflow/worker-source.ts +283 -71
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +288 -177
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
- package/node_modules/@pi-plugins/fast-mode/package.json +7 -7
- package/node_modules/pi-lens/CHANGELOG-USER.md +6 -6
- package/node_modules/pi-lens/CHANGELOG.md +132 -0
- package/node_modules/pi-lens/README.md +2 -0
- package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +1 -0
- package/node_modules/pi-lens/dist/{chunk-LGH2HHZG.js → chunk-25CAONWT.js} +36 -25
- package/node_modules/pi-lens/dist/{chunk-ZQSSO7LO.js → chunk-2DWNYVUN.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-YCR6ZYTE.js → chunk-2RQREVGO.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-VWEBZ2JV.js → chunk-2XALJI2K.js} +40 -40
- package/node_modules/pi-lens/dist/{chunk-PQXUZYTQ.js → chunk-2YQ5LI7R.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-VSQT6IHZ.js → chunk-35UJUF27.js} +18 -4
- package/node_modules/pi-lens/dist/{chunk-OLWGYBYT.js → chunk-3IWMNN2S.js} +17 -17
- package/node_modules/pi-lens/dist/chunk-3UTDLQWO.js +88 -0
- package/node_modules/pi-lens/dist/chunk-3Z7Z3B7V.js +27 -0
- package/node_modules/pi-lens/dist/{chunk-UNP6Y4JV.js → chunk-4E4OCW3L.js} +16 -16
- package/node_modules/pi-lens/dist/{chunk-37IDWT6O.js → chunk-4GLSO2EM.js} +13 -11
- package/node_modules/pi-lens/dist/{chunk-QV3JPCMK.js → chunk-5HVDD7IA.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-ZRQMENT4.js → chunk-62PIU4TO.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-3TSMQZG6.js → chunk-6MDWNZ7E.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-WLD6BGON.js → chunk-6MWX2J5H.js} +4 -0
- package/node_modules/pi-lens/dist/{chunk-SCU62JLX.js → chunk-6MZLS6CK.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-B42AIWPJ.js → chunk-7BWPQZHE.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-I3NZVAMN.js → chunk-7JMEPY6P.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-7DPXUPRF.js → chunk-7ORBRDFY.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-6E5QLMWI.js → chunk-7WAQ3K26.js} +23 -23
- package/node_modules/pi-lens/dist/{chunk-2H5GHZKC.js → chunk-AB26NAHA.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-BBSDJTOV.js → chunk-AFSG6YUB.js} +13 -13
- package/node_modules/pi-lens/dist/{chunk-XDNWR7SG.js → chunk-ALTHJUZO.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-UN72ZAJ5.js → chunk-AOEVZXR6.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-HRLF35WL.js → chunk-ARTCVE6I.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-LQQNFCQJ.js → chunk-B2QO7GHY.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-I2FYOZNW.js → chunk-BJGWP4UX.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-G53LBDNU.js → chunk-BKJ6WZKP.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-P5MSLVUW.js → chunk-BQ72NQQM.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-K7O6AHSJ.js → chunk-BWGNVM33.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-ADYQRETD.js → chunk-BYIEU4E4.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-7ZVTFLCC.js → chunk-CDAJQBKJ.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-BKWFDWYM.js → chunk-D3UQWOCB.js} +16 -16
- package/node_modules/pi-lens/dist/{chunk-3PAS2ERX.js → chunk-DHFJS2I4.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-KNSOA43J.js → chunk-DKXIUGNA.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-LOEJFTF2.js → chunk-DLGJYQML.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-VGRGW4UL.js → chunk-DNJJVKJZ.js} +31 -31
- package/node_modules/pi-lens/dist/{chunk-5HBQL7DH.js → chunk-EBXCYEII.js} +3 -3
- package/node_modules/pi-lens/dist/chunk-EH6EHFW2.js +73 -0
- package/node_modules/pi-lens/dist/{chunk-W26QZ3OM.js → chunk-EKQDQPX6.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-TWEOJE3D.js → chunk-EXHSWN3P.js} +844 -377
- package/node_modules/pi-lens/dist/{chunk-4IZZEN63.js → chunk-F7BFIENK.js} +33 -33
- package/node_modules/pi-lens/dist/{chunk-ZI7YHV6I.js → chunk-FD4LJQ6Y.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-RIH3UBK4.js → chunk-GFCPPCNR.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-5JB4WENL.js → chunk-GIK6VUCY.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-PPQHMSPH.js → chunk-GNK2IHVG.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-CXQYK4YT.js → chunk-H6DNTQ4V.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-NGNBJIUO.js → chunk-HERQPNY6.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-INBK3HIT.js → chunk-HFIFEH46.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-J2ZB5MDS.js → chunk-HKRESBMC.js} +20 -20
- package/node_modules/pi-lens/dist/{chunk-AZG5UJYY.js → chunk-HMXWZUQW.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-XSC3BCN3.js → chunk-HOWHAKXO.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-7CLWC2UH.js → chunk-HUWW77QY.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-KZ732ZVW.js → chunk-IO6P3NBP.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-7WKVCZI4.js → chunk-J7VNGHLN.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-QE7BJQ6K.js → chunk-JGCBMCCS.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-PFJLYRO3.js → chunk-KIQSNH3F.js} +34 -34
- package/node_modules/pi-lens/dist/{chunk-JGUDT5KD.js → chunk-KSQJBGRO.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-RJ3APNIP.js → chunk-KXKM2DFP.js} +4 -4
- package/node_modules/pi-lens/dist/chunk-L3Q72QGQ.js +25 -0
- package/node_modules/pi-lens/dist/{chunk-6GLMMGCX.js → chunk-LDPY22FS.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-3PO4YYOX.js → chunk-M3QGXGY4.js} +3793 -3814
- package/node_modules/pi-lens/dist/{chunk-NNEQOC3U.js → chunk-MET776XM.js} +9 -7
- package/node_modules/pi-lens/dist/{chunk-X33QECRJ.js → chunk-MKQFSW2Q.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-7U36VQL6.js → chunk-MKW7ZUTT.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-PQF6YGYB.js → chunk-N2U644ZW.js} +4 -18
- package/node_modules/pi-lens/dist/{chunk-DI4AZZNY.js → chunk-NAACKIKT.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-O6LCSHHI.js → chunk-NHHS5T52.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-DCA2MXVQ.js → chunk-NIZKGBOU.js} +51 -27
- package/node_modules/pi-lens/dist/{chunk-PKWEBMCA.js → chunk-NNDZ7DOP.js} +194 -111
- package/node_modules/pi-lens/dist/{chunk-Q7J3JYJ2.js → chunk-NZ7NSKIW.js} +13 -13
- package/node_modules/pi-lens/dist/{chunk-S6MCMD27.js → chunk-OG3UCAHV.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-3QXFUP6T.js → chunk-OHTHVILU.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-NHA5K226.js → chunk-P7EV5ISR.js} +17 -2
- package/node_modules/pi-lens/dist/{chunk-L6BDRYUK.js → chunk-PVV27TOX.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-HIRBC72R.js → chunk-Q32RJDYC.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-QE5DJ7MX.js → chunk-Q4UQNTLB.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-SDYLT45T.js → chunk-QQGZY2BR.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-QMWKSYWB.js → chunk-S247BOH2.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-ARTYCUGF.js → chunk-S7KUDW73.js} +121 -18
- package/node_modules/pi-lens/dist/{chunk-6CFSDLHE.js → chunk-SJ2SR432.js} +17 -17
- package/node_modules/pi-lens/dist/{chunk-CQY2HEH7.js → chunk-SL4G67AP.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-LVLPA32Q.js → chunk-T2D2WWP6.js} +48 -11
- package/node_modules/pi-lens/dist/{chunk-HIJ4CHFF.js → chunk-T7KHGEJ5.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-74AMPWNC.js → chunk-TABDCX35.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-TFSBHRL2.js +25 -0
- package/node_modules/pi-lens/dist/{chunk-KNJH6WJQ.js → chunk-TQKWR5AZ.js} +7 -7
- package/node_modules/pi-lens/dist/chunk-TWAQFMLW.js +110 -0
- package/node_modules/pi-lens/dist/{chunk-TKOFTLGB.js → chunk-UARVPNAU.js} +33 -33
- package/node_modules/pi-lens/dist/chunk-UWBD3JMH.js +56 -0
- package/node_modules/pi-lens/dist/{chunk-K4Z7MK6T.js → chunk-VEF3GFOL.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-4DAHGU3V.js → chunk-W2JPGW7Q.js} +27 -25
- package/node_modules/pi-lens/dist/{chunk-CZJGAOKL.js → chunk-W2YHHNY3.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-R4L7KZ7R.js → chunk-WA6U2URH.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-OZQQ3AIR.js → chunk-WAK2AXQQ.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-DFKOA74L.js → chunk-WH6O4IFD.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-27JQHK7Y.js → chunk-WJ7GY5WJ.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-KXGTLAUW.js → chunk-WWZLT6AM.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-O2MHF7QM.js → chunk-XRLZ75YY.js} +38 -38
- package/node_modules/pi-lens/dist/chunk-XWWFESYZ.js +27 -0
- package/node_modules/pi-lens/dist/chunk-XZSXSM4K.js +27 -0
- package/node_modules/pi-lens/dist/{chunk-C5PLBTNR.js → chunk-Y2LIOCA7.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-AXAR5ZW2.js → chunk-YIEHUKX2.js} +84 -169
- package/node_modules/pi-lens/dist/{chunk-B2OXE4AH.js → chunk-YOMLAKU6.js} +182 -180
- package/node_modules/pi-lens/dist/{chunk-MOAVEPC4.js → chunk-YV7XVYSJ.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-ZULZS2I6.js → chunk-ZVQUYCBU.js} +996 -365
- package/node_modules/pi-lens/dist/index.js +4911 -2376
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +8 -8
- package/node_modules/pi-lens/dist/mcp/cli.js +40 -40
- package/node_modules/pi-lens/dist/mcp/server.js +321 -234
- package/node_modules/pi-lens/dist/mcp/worker.js +58 -58
- package/node_modules/pi-lens/dist/probes/installer.js +21 -21
- package/node_modules/pi-lens/docs/ci-bot-pr-checks.md +18 -9
- package/node_modules/pi-lens/docs/ci.md +7 -0
- package/node_modules/pi-lens/docs/defect-shapes.md +43 -28
- package/node_modules/pi-lens/docs/globalconfig.md +1 -0
- package/node_modules/pi-lens/docs/invariants/dispatch-runners.md +15 -0
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +3 -3
- package/node_modules/pi-lens/docs/lsp-idle-eviction.md +3 -2
- package/node_modules/pi-lens/docs/module-report-read-symbol.md +6 -2
- package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +3 -2
- package/node_modules/pi-lens/docs/pi-lens-orchestration.md +2 -1
- package/node_modules/pi-lens/docs/pi-lens-subagent.md +2 -1
- package/node_modules/pi-lens/docs/servercapabilities.md +1 -1
- package/node_modules/pi-lens/docs/settings.md +1 -0
- package/node_modules/pi-lens/docs/usage.md +1 -0
- package/node_modules/pi-lens/package.json +1 -1
- package/package.json +7 -5
- package/node_modules/pi-lens/dist/chunk-2H7NFZ4Q.js +0 -25
- package/node_modules/pi-lens/dist/chunk-5YJXF2IS.js +0 -56
- package/node_modules/pi-lens/dist/chunk-GCSDF5IE.js +0 -27
- package/node_modules/pi-lens/dist/chunk-H5API74E.js +0 -67
- package/node_modules/pi-lens/dist/chunk-HBX55MWO.js +0 -27
- package/node_modules/pi-lens/dist/chunk-JOIKBUQN.js +0 -88
- package/node_modules/pi-lens/dist/chunk-M2YMBT5G.js +0 -73
- package/node_modules/pi-lens/dist/chunk-MJRGPEQ5.js +0 -25
- package/node_modules/pi-lens/dist/chunk-TFKN5EIR.js +0 -27
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* Opening an agent swaps the panes: that phase's agents move left and the
|
|
17
|
-
* right becomes the agent's Prompt / Activity / Outcome detail.
|
|
17
|
+
* right becomes the agent's Prompt / Activity / Outcome detail. Activity lists
|
|
18
|
+
* the child's tool calls from its transcript (`AgentDetail`, injected through
|
|
19
|
+
* the source); `⏎` expands all three sections, and `→` expands and focuses
|
|
20
|
+
* the detail so `↑↓` scroll it rather than moving between agents.
|
|
18
21
|
*
|
|
19
22
|
* A phase with no agents yet shows its number and nothing else. The single-pane
|
|
20
23
|
* layout this replaced spelled that out as "Not started yet"; the left pane is
|
|
@@ -28,7 +31,7 @@
|
|
|
28
31
|
* the card draws a static `⟳`.
|
|
29
32
|
*
|
|
30
33
|
* **The phases pane is stranger still**: a phase that has not finished shows
|
|
31
|
-
* *its number*, not a glyph. That is deliberate
|
|
34
|
+
* *its number*, not a glyph. That is deliberate.
|
|
32
35
|
*
|
|
33
36
|
* **The layout is pure.** `layoutWorkflowDialog` returns coloured segments and
|
|
34
37
|
* `handleWorkflowDialogKey` maps a keypress to the next state plus an optional
|
|
@@ -49,6 +52,7 @@ import {
|
|
|
49
52
|
visibleWidth,
|
|
50
53
|
wrapTextWithAnsi,
|
|
51
54
|
} from "@earendil-works/pi-tui"
|
|
55
|
+
import type { AgentDetail, AgentDetailItem } from "../workflow/agent-detail.js"
|
|
52
56
|
import type { WorkflowMeta } from "../workflow/meta.js"
|
|
53
57
|
import {
|
|
54
58
|
buildPhaseGroups,
|
|
@@ -62,6 +66,7 @@ import {
|
|
|
62
66
|
type WorkflowEntry,
|
|
63
67
|
} from "../workflow/progress.js"
|
|
64
68
|
import { SPINNER, type Theme } from "./agent-widget.js"
|
|
69
|
+
import { createViewerKeys, type ViewerKeys } from "./viewer-keys.js"
|
|
65
70
|
import {
|
|
66
71
|
ASCII_GLYPHS,
|
|
67
72
|
clampLine,
|
|
@@ -84,23 +89,44 @@ const DEFAULT_WIDTH = 80
|
|
|
84
89
|
const LEFT_PANE_WIDTH = 18
|
|
85
90
|
|
|
86
91
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* it stops growing so a 200-agent fan-out scrolls inside the pane instead of
|
|
91
|
-
* pasting 200 rows into the conversation.
|
|
92
|
+
* Rows between the frame's top and bottom edges when the caller does not know
|
|
93
|
+
* the terminal's height. The overlay passes its own, from
|
|
94
|
+
* {@link workflowDialogBodyRows}.
|
|
92
95
|
*/
|
|
93
96
|
export const DEFAULT_PANE_BODY_ROWS = 22
|
|
97
|
+
/** Fewest rows the frame will draw: below this a pane stops reading as a pane. */
|
|
98
|
+
export const MIN_PANE_BODY_ROWS = 6
|
|
99
|
+
/** Share of the terminal's height the overlay takes. */
|
|
100
|
+
export const WORKFLOW_DIALOG_HEIGHT_PCT = 85
|
|
101
|
+
/** Lines around the frame's body: the header's three, the frame's two edges, the footer. */
|
|
102
|
+
export const WORKFLOW_DIALOG_CHROME_ROWS = 6
|
|
103
|
+
|
|
94
104
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
105
|
+
* The frame's body height for a terminal `rows` tall: the overlay's share of
|
|
106
|
+
* it, less the chrome. Fixed for a given terminal, so the box keeps its size
|
|
107
|
+
* however much the panes hold — moving the selection, expanding the detail or
|
|
108
|
+
* a phase filling up never makes it jump. Never below `MIN_PANE_BODY_ROWS`:
|
|
109
|
+
* in a very small terminal that floor wins, and the overlay's `maxHeight`
|
|
110
|
+
* cuts the footer off.
|
|
100
111
|
*/
|
|
101
|
-
export
|
|
112
|
+
export function workflowDialogBodyRows(rows: number): number {
|
|
113
|
+
return Math.max(
|
|
114
|
+
MIN_PANE_BODY_ROWS,
|
|
115
|
+
Math.floor((rows * WORKFLOW_DIALOG_HEIGHT_PCT) / 100) -
|
|
116
|
+
WORKFLOW_DIALOG_CHROME_ROWS,
|
|
117
|
+
)
|
|
118
|
+
}
|
|
102
119
|
/** Prompt lines shown before `expand` is offered. */
|
|
103
120
|
export const PROMPT_COLLAPSED_LINES = 4
|
|
121
|
+
/** Outcome rows shown before `expand` is offered. */
|
|
122
|
+
export const OUTCOME_COLLAPSED_LINES = 12
|
|
123
|
+
/** Most recent tool calls the collapsed Activity lists; earlier ones are counted. */
|
|
124
|
+
export const ACTIVITY_COLLAPSED_CALLS = 8
|
|
125
|
+
/**
|
|
126
|
+
* Result lines shown under each call in the expanded transcript, so one
|
|
127
|
+
* 2000-line `cat` cannot bury every call after it.
|
|
128
|
+
*/
|
|
129
|
+
export const ACTIVITY_RESULT_LINES = 8
|
|
104
130
|
/** Spinner cadence. Unlike the card's 1s header tick, this row really animates. */
|
|
105
131
|
export const WORKFLOW_DIALOG_SPINNER_MS = 80
|
|
106
132
|
|
|
@@ -132,8 +158,19 @@ export interface WorkflowDialogGlyphs {
|
|
|
132
158
|
}
|
|
133
159
|
/** Trailing marker on a title the pane was too narrow to hold. */
|
|
134
160
|
ellipsis: string
|
|
161
|
+
/** `⏺` — one tool call in the Activity section. */
|
|
162
|
+
call: string
|
|
163
|
+
/** `⎿` — the first line of a call's result in the expanded transcript. */
|
|
164
|
+
result: string
|
|
165
|
+
/** The scrolled detail's `1–26 of 35 ↓` label: range dash, then the arrows. */
|
|
166
|
+
rangeDash: string
|
|
167
|
+
moreAbove: string
|
|
168
|
+
moreBelow: string
|
|
135
169
|
/** How the footer names the arrow keys and Enter. */
|
|
136
170
|
upDown: string
|
|
171
|
+
/** How the footer names the keys that move focus between the agent list and the detail. */
|
|
172
|
+
left: string
|
|
173
|
+
right: string
|
|
137
174
|
enter: string
|
|
138
175
|
}
|
|
139
176
|
|
|
@@ -155,7 +192,14 @@ export const UNICODE_DIALOG_GLYPHS: WorkflowDialogGlyphs = {
|
|
|
155
192
|
bottomTee: "┴",
|
|
156
193
|
},
|
|
157
194
|
ellipsis: "…",
|
|
195
|
+
call: "⏺",
|
|
196
|
+
result: "⎿",
|
|
197
|
+
rangeDash: "–",
|
|
198
|
+
moreAbove: "↑",
|
|
199
|
+
moreBelow: "↓",
|
|
158
200
|
upDown: "↑↓",
|
|
201
|
+
left: "←",
|
|
202
|
+
right: "→",
|
|
159
203
|
enter: "⏎",
|
|
160
204
|
}
|
|
161
205
|
|
|
@@ -178,12 +222,19 @@ export const ASCII_DIALOG_GLYPHS: WorkflowDialogGlyphs = {
|
|
|
178
222
|
bottomTee: "+",
|
|
179
223
|
},
|
|
180
224
|
ellipsis: "~",
|
|
225
|
+
call: "*",
|
|
226
|
+
result: "|",
|
|
227
|
+
rangeDash: "-",
|
|
228
|
+
moreAbove: "^",
|
|
229
|
+
moreBelow: "v",
|
|
181
230
|
upDown: "up/down",
|
|
231
|
+
left: "left",
|
|
232
|
+
right: "right",
|
|
182
233
|
enter: "enter",
|
|
183
234
|
}
|
|
184
235
|
|
|
185
236
|
/**
|
|
186
|
-
* The
|
|
237
|
+
* The dialog's glyphs and colours — keyed on the *display* state.
|
|
187
238
|
*
|
|
188
239
|
* Claude Code's `permission` colour has no pi equivalent; a blocked agent is
|
|
189
240
|
* waiting on the user, so it maps to `warning` (selection maps to `accent`).
|
|
@@ -269,9 +320,34 @@ export interface WorkflowDialogState {
|
|
|
269
320
|
selectedAgent: number
|
|
270
321
|
level: WorkflowDialogLevel
|
|
271
322
|
filter: WorkflowDialogFilter
|
|
272
|
-
|
|
323
|
+
/** Prompt, Activity and Outcome all expanded — one toggle, as in Claude Code. */
|
|
324
|
+
expanded: boolean
|
|
325
|
+
/** First detail row shown; clamped on read against what the pane holds. */
|
|
326
|
+
detailScroll: number
|
|
327
|
+
/**
|
|
328
|
+
* `→` moved focus into the detail, so `↑↓` scroll it instead of moving
|
|
329
|
+
* between agents. Only in effect while the detail overflows the pane — see
|
|
330
|
+
* {@link detailHasFocus} — and cleared by the component's next render when
|
|
331
|
+
* it does not, and by `⏎`/`e`.
|
|
332
|
+
*/
|
|
333
|
+
detailFocused: boolean
|
|
273
334
|
}
|
|
274
335
|
|
|
336
|
+
/** Focus is on the detail and there is something there to scroll. */
|
|
337
|
+
const detailHasFocus = (state: WorkflowDialogState, maxDetailScroll: number) =>
|
|
338
|
+
state.level === "agent" && state.detailFocused && maxDetailScroll > 0
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* `⏎`/`e` on the detail. Drops the focus as well: only `→` focuses, so an
|
|
342
|
+
* expand that follows a collapse must not bring back a focus `→` gave earlier.
|
|
343
|
+
*/
|
|
344
|
+
const toggleExpanded = (state: WorkflowDialogState): WorkflowDialogState => ({
|
|
345
|
+
...state,
|
|
346
|
+
expanded: !state.expanded,
|
|
347
|
+
detailScroll: 0,
|
|
348
|
+
detailFocused: false,
|
|
349
|
+
})
|
|
350
|
+
|
|
275
351
|
export function initialWorkflowDialogState(
|
|
276
352
|
initialPhaseIndex = 0,
|
|
277
353
|
): WorkflowDialogState {
|
|
@@ -280,7 +356,9 @@ export function initialWorkflowDialogState(
|
|
|
280
356
|
selectedAgent: 0,
|
|
281
357
|
level: "phases",
|
|
282
358
|
filter: "all",
|
|
283
|
-
|
|
359
|
+
expanded: false,
|
|
360
|
+
detailScroll: 0,
|
|
361
|
+
detailFocused: false,
|
|
284
362
|
}
|
|
285
363
|
}
|
|
286
364
|
|
|
@@ -291,6 +369,11 @@ export interface WorkflowDialogSource {
|
|
|
291
369
|
meta?: WorkflowMeta
|
|
292
370
|
/** Agents the runtime has scheduled, which can exceed those that reported. */
|
|
293
371
|
agentCount?: number
|
|
372
|
+
/**
|
|
373
|
+
* The child's transcript, by the entry's `recordId`. Undefined once the
|
|
374
|
+
* record has been swept, which falls back to the progress log's previews.
|
|
375
|
+
*/
|
|
376
|
+
detail?(recordId: string): AgentDetail | undefined
|
|
294
377
|
}
|
|
295
378
|
|
|
296
379
|
export interface WorkflowDialogInput extends WorkflowDialogSource {
|
|
@@ -307,10 +390,9 @@ export interface WorkflowDialogInput extends WorkflowDialogSource {
|
|
|
307
390
|
ascii?: boolean
|
|
308
391
|
spinnerFrame?: number
|
|
309
392
|
/**
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
* {@link MIN_PANE_BODY_ROWS}; this only moves the ceiling.
|
|
393
|
+
* Rows between the frame's edges, overriding {@link DEFAULT_PANE_BODY_ROWS};
|
|
394
|
+
* floored at {@link MIN_PANE_BODY_ROWS}. A height, not a cap: the frame is
|
|
395
|
+
* drawn at exactly this size whatever the panes hold.
|
|
314
396
|
*/
|
|
315
397
|
bodyRows?: number
|
|
316
398
|
}
|
|
@@ -511,6 +593,7 @@ function frameTitle(
|
|
|
511
593
|
title: string,
|
|
512
594
|
width: number,
|
|
513
595
|
glyphs: WorkflowDialogGlyphs,
|
|
596
|
+
focused = false,
|
|
514
597
|
): WorkflowCardSegment[] {
|
|
515
598
|
const room = Math.max(0, width - 2)
|
|
516
599
|
// Truncated with the marker rather than simply cut: `Discover · 1 ag…` has to
|
|
@@ -528,7 +611,7 @@ function frameTitle(
|
|
|
528
611
|
return clampLine(
|
|
529
612
|
[
|
|
530
613
|
{ text: " ", color: "dim" },
|
|
531
|
-
{ text: shown, color: "muted", bold: true },
|
|
614
|
+
{ text: shown, color: focused ? "accent" : "muted", bold: true },
|
|
532
615
|
{ text: ` ${glyphs.box.horizontal.repeat(rule)}`, color: "dim" },
|
|
533
616
|
],
|
|
534
617
|
width,
|
|
@@ -547,6 +630,10 @@ function paneFrame(options: {
|
|
|
547
630
|
rightTitle: string
|
|
548
631
|
leftRows: WorkflowCardLine[]
|
|
549
632
|
rightRows: WorkflowCardLine[]
|
|
633
|
+
/** A label set into the bottom edge under the right pane, flush right. */
|
|
634
|
+
rightFooter?: string
|
|
635
|
+
/** The right pane has the keyboard: its title is drawn in the accent colour. */
|
|
636
|
+
rightFocused?: boolean
|
|
550
637
|
width: number
|
|
551
638
|
bodyRows: number
|
|
552
639
|
glyphs: WorkflowDialogGlyphs
|
|
@@ -566,7 +653,7 @@ function paneFrame(options: {
|
|
|
566
653
|
),
|
|
567
654
|
{ text: box.topTee, color: "dim" },
|
|
568
655
|
...padTitle(
|
|
569
|
-
frameTitle(options.rightTitle, right, glyphs),
|
|
656
|
+
frameTitle(options.rightTitle, right, glyphs, options.rightFocused),
|
|
570
657
|
right,
|
|
571
658
|
box.horizontal,
|
|
572
659
|
),
|
|
@@ -587,21 +674,33 @@ function paneFrame(options: {
|
|
|
587
674
|
{ text: box.bottomLeft, color: "dim" },
|
|
588
675
|
{ text: box.horizontal.repeat(left), color: "dim" },
|
|
589
676
|
{ text: box.bottomTee, color: "dim" },
|
|
590
|
-
|
|
677
|
+
...bottomEdge(options.rightFooter, right, box.horizontal),
|
|
591
678
|
{ text: box.bottomRight, color: "dim" },
|
|
592
679
|
])
|
|
593
680
|
return lines
|
|
594
681
|
}
|
|
595
682
|
|
|
683
|
+
/** A bottom edge of `width` cells, with `label` set in flush right when it fits. */
|
|
684
|
+
function bottomEdge(
|
|
685
|
+
label: string | undefined,
|
|
686
|
+
width: number,
|
|
687
|
+
horizontal: string,
|
|
688
|
+
): WorkflowCardSegment[] {
|
|
689
|
+
const room = label === undefined ? 0 : visibleWidth(label) + 3
|
|
690
|
+
if (label === undefined || room > width)
|
|
691
|
+
return [{ text: horizontal.repeat(width), color: "dim" }]
|
|
692
|
+
return [
|
|
693
|
+
{ text: `${horizontal.repeat(width - room)} `, color: "dim" },
|
|
694
|
+
{ text: label, color: "dim" },
|
|
695
|
+
{ text: ` ${horizontal}`, color: "dim" },
|
|
696
|
+
]
|
|
697
|
+
}
|
|
698
|
+
|
|
596
699
|
/* ------------------------------------------------------------------------- *
|
|
597
700
|
* Detail sections
|
|
598
701
|
* ------------------------------------------------------------------------- */
|
|
599
702
|
|
|
600
|
-
/**
|
|
601
|
-
const previewLines = (preview: string | undefined) =>
|
|
602
|
-
preview ? preview.split("\n") : []
|
|
603
|
-
|
|
604
|
-
/** What the Activity body says. There is a count of tool calls, never a list. */
|
|
703
|
+
/** What the Activity body says when there is no transcript to list from. */
|
|
605
704
|
function activityBody(
|
|
606
705
|
entry: WorkflowAgentEntry,
|
|
607
706
|
state: WorkflowDisplayState,
|
|
@@ -700,6 +799,182 @@ function detailHeading(
|
|
|
700
799
|
const detailBody = (text: string, width: number): WorkflowCardLine =>
|
|
701
800
|
clampLine([{ text: ` ${text}`, color: "dim" }], width)
|
|
702
801
|
|
|
802
|
+
/** `3 lines` / `1 line`. */
|
|
803
|
+
const lineCount = (n: number) => `${n} line${n === 1 ? "" : "s"}`
|
|
804
|
+
|
|
805
|
+
/** `⏺ Bash(ls -la)`, its glyph coloured by how the call came out. */
|
|
806
|
+
function callRow(
|
|
807
|
+
item: AgentDetailItem,
|
|
808
|
+
width: number,
|
|
809
|
+
glyphs: WorkflowDialogGlyphs,
|
|
810
|
+
): WorkflowCardLine {
|
|
811
|
+
const color: WorkflowCardColor = !item.settled
|
|
812
|
+
? "dim"
|
|
813
|
+
: item.isError
|
|
814
|
+
? "error"
|
|
815
|
+
: "success"
|
|
816
|
+
return clampLine(
|
|
817
|
+
[
|
|
818
|
+
{ text: " " },
|
|
819
|
+
{ text: glyphs.call, color },
|
|
820
|
+
{ text: ` ${item.head}`, color: "dim" },
|
|
821
|
+
],
|
|
822
|
+
width,
|
|
823
|
+
)
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Prompt, Activity and Outcome for the selected agent.
|
|
828
|
+
*
|
|
829
|
+
* Collapsed, each section is a preview: the prompt's first lines, the most
|
|
830
|
+
* recent tool calls one per row, the outcome's first rows. Expanded — one
|
|
831
|
+
* toggle for all three, as in Claude Code — the prompt and outcome are whole
|
|
832
|
+
* and Activity becomes the transcript, each call followed by its result.
|
|
833
|
+
* The pane scrolls, so nothing here is sized to fit it.
|
|
834
|
+
*
|
|
835
|
+
* With no `detail` (the record was swept, or no caller supplied one) the
|
|
836
|
+
* sections fall back to the progress log's previews and counts.
|
|
837
|
+
*/
|
|
838
|
+
function detailSections(options: {
|
|
839
|
+
entry: WorkflowAgentEntry
|
|
840
|
+
display: WorkflowDisplayState
|
|
841
|
+
detail: AgentDetail | undefined
|
|
842
|
+
expanded: boolean
|
|
843
|
+
width: number
|
|
844
|
+
glyphs: WorkflowDialogGlyphs
|
|
845
|
+
}): { rows: WorkflowCardLine[]; expandable: boolean } {
|
|
846
|
+
const { entry, display, detail, expanded, width, glyphs } = options
|
|
847
|
+
const rows: WorkflowCardLine[] = []
|
|
848
|
+
const toggle = `${glyphs.enter} ${expanded ? "collapse" : "expand"}`
|
|
849
|
+
const wrapWidth = Math.max(1, width - 4)
|
|
850
|
+
const wrapped = (lines: readonly string[]) =>
|
|
851
|
+
lines.flatMap((line) => wrapTextWithAnsi(line, wrapWidth))
|
|
852
|
+
const more = (hidden: number, noun = "line") =>
|
|
853
|
+
detailBody(
|
|
854
|
+
`${glyphs.ellipsis} ${hidden} more ${noun}${hidden === 1 ? "" : "s"}`,
|
|
855
|
+
width,
|
|
856
|
+
)
|
|
857
|
+
|
|
858
|
+
// ---- Prompt
|
|
859
|
+
// An empty preview is absent, not one blank line.
|
|
860
|
+
const promptText = detail?.prompt ?? entry.promptPreview
|
|
861
|
+
const prompt = promptText ? promptText.split("\n") : []
|
|
862
|
+
const promptFolds = prompt.length > PROMPT_COLLAPSED_LINES
|
|
863
|
+
const promptSuffix = prompt.length > 0 ? [lineCount(prompt.length)] : []
|
|
864
|
+
if (promptFolds) promptSuffix.push(toggle)
|
|
865
|
+
rows.push([], detailHeading("Prompt", promptSuffix, width))
|
|
866
|
+
if (prompt.length === 0) {
|
|
867
|
+
rows.push(detailBody(WORKFLOW_DIALOG_COPY.availableOnceStarted, width))
|
|
868
|
+
} else if (expanded) {
|
|
869
|
+
// Wrapped once expanded: the point of expanding is to read every word.
|
|
870
|
+
for (const text of wrapped(prompt)) rows.push(detailBody(text, width))
|
|
871
|
+
} else {
|
|
872
|
+
for (const text of prompt.slice(0, PROMPT_COLLAPSED_LINES))
|
|
873
|
+
rows.push(detailBody(text, width))
|
|
874
|
+
// Named rather than silently cut: the reader has to know the prompt goes on.
|
|
875
|
+
if (promptFolds) rows.push(more(prompt.length - PROMPT_COLLAPSED_LINES))
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// ---- Activity
|
|
879
|
+
const calls = detail?.items.filter((item) => item.kind === "tool") ?? []
|
|
880
|
+
const activityFolds =
|
|
881
|
+
detail !== undefined &&
|
|
882
|
+
(calls.length > ACTIVITY_COLLAPSED_CALLS ||
|
|
883
|
+
detail.items.some((item) => item.kind === "text" || item.body.length > 0))
|
|
884
|
+
const toolCalls = entry.toolCalls ?? calls.length
|
|
885
|
+
const activitySuffix =
|
|
886
|
+
toolCalls > 0 ? [`${toolCalls} tool call${toolCalls === 1 ? "" : "s"}`] : []
|
|
887
|
+
if (activityFolds) activitySuffix.push(toggle)
|
|
888
|
+
rows.push([], detailHeading("Activity", activitySuffix, width))
|
|
889
|
+
if (detail === undefined) {
|
|
890
|
+
rows.push(detailBody(activityBody(entry, display), width))
|
|
891
|
+
} else if (expanded && detail.items.length > 0) {
|
|
892
|
+
for (const item of detail.items) {
|
|
893
|
+
if (item.kind === "text") {
|
|
894
|
+
for (const text of wrapped([item.head, ...item.body])) {
|
|
895
|
+
rows.push(clampLine([{ text: ` ${text}` }], width))
|
|
896
|
+
}
|
|
897
|
+
continue
|
|
898
|
+
}
|
|
899
|
+
rows.push(callRow(item, width, glyphs))
|
|
900
|
+
const shown = item.body.slice(0, ACTIVITY_RESULT_LINES)
|
|
901
|
+
shown.forEach((text, i) => {
|
|
902
|
+
rows.push(
|
|
903
|
+
clampLine(
|
|
904
|
+
[
|
|
905
|
+
{
|
|
906
|
+
text: ` ${i === 0 ? glyphs.result : " "} ${text}`,
|
|
907
|
+
color: "dim",
|
|
908
|
+
},
|
|
909
|
+
],
|
|
910
|
+
width,
|
|
911
|
+
),
|
|
912
|
+
)
|
|
913
|
+
})
|
|
914
|
+
const hidden = item.body.length - shown.length
|
|
915
|
+
if (hidden > 0)
|
|
916
|
+
rows.push(
|
|
917
|
+
clampLine(
|
|
918
|
+
[
|
|
919
|
+
{
|
|
920
|
+
text: ` ${glyphs.ellipsis} ${hidden} more ${hidden === 1 ? "line" : "lines"}`,
|
|
921
|
+
color: "dim",
|
|
922
|
+
},
|
|
923
|
+
],
|
|
924
|
+
width,
|
|
925
|
+
),
|
|
926
|
+
)
|
|
927
|
+
}
|
|
928
|
+
} else if (calls.length > 0) {
|
|
929
|
+
// The most recent calls, because on a live agent that is what is happening.
|
|
930
|
+
const hidden = calls.length - ACTIVITY_COLLAPSED_CALLS
|
|
931
|
+
if (hidden > 0)
|
|
932
|
+
rows.push(
|
|
933
|
+
detailBody(
|
|
934
|
+
`${glyphs.ellipsis} ${hidden} earlier call${hidden === 1 ? "" : "s"}`,
|
|
935
|
+
width,
|
|
936
|
+
),
|
|
937
|
+
)
|
|
938
|
+
for (const item of calls.slice(Math.max(0, hidden)))
|
|
939
|
+
rows.push(callRow(item, width, glyphs))
|
|
940
|
+
} else {
|
|
941
|
+
rows.push(
|
|
942
|
+
detailBody(
|
|
943
|
+
display === "queued"
|
|
944
|
+
? WORKFLOW_DIALOG_COPY.availableOnceStarted
|
|
945
|
+
: isLive(entry)
|
|
946
|
+
? WORKFLOW_DIALOG_COPY.noToolCallsYet
|
|
947
|
+
: WORKFLOW_DIALOG_COPY.noToolCalls,
|
|
948
|
+
width,
|
|
949
|
+
),
|
|
950
|
+
)
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
// ---- Outcome
|
|
954
|
+
// Wrapped, not clamped: the outcome is the thing the reader came for, and
|
|
955
|
+
// cutting it at the pane edge would hide the half that matters.
|
|
956
|
+
const outcomeText =
|
|
957
|
+
display === "done"
|
|
958
|
+
? (detail?.outcome ?? outcomeBody(entry, display))
|
|
959
|
+
: outcomeBody(entry, display)
|
|
960
|
+
const outcomeLines = outcomeText.split("\n")
|
|
961
|
+
const outcomeRows = wrapped(outcomeLines)
|
|
962
|
+
const outcomeFolds = outcomeRows.length > OUTCOME_COLLAPSED_LINES
|
|
963
|
+
const outcomeSuffix =
|
|
964
|
+
outcomeLines.length > 1 ? [lineCount(outcomeLines.length)] : []
|
|
965
|
+
if (outcomeFolds) outcomeSuffix.push(toggle)
|
|
966
|
+
rows.push([], detailHeading("Outcome", outcomeSuffix, width))
|
|
967
|
+
const shownOutcome =
|
|
968
|
+
expanded || !outcomeFolds
|
|
969
|
+
? outcomeRows
|
|
970
|
+
: outcomeRows.slice(0, OUTCOME_COLLAPSED_LINES)
|
|
971
|
+
for (const text of shownOutcome) rows.push(detailBody(text, width))
|
|
972
|
+
if (shownOutcome.length < outcomeRows.length)
|
|
973
|
+
rows.push(more(outcomeRows.length - shownOutcome.length))
|
|
974
|
+
|
|
975
|
+
return { rows, expandable: promptFolds || activityFolds || outcomeFolds }
|
|
976
|
+
}
|
|
977
|
+
|
|
703
978
|
/** The row for one agent, as it appears in whichever pane is listing agents. */
|
|
704
979
|
function agentRow(options: {
|
|
705
980
|
entry: WorkflowAgentEntry
|
|
@@ -760,13 +1035,31 @@ function rowStatSegments(entry: WorkflowAgentEntry): string[] {
|
|
|
760
1035
|
export function layoutWorkflowDialog(
|
|
761
1036
|
input: WorkflowDialogInput,
|
|
762
1037
|
): WorkflowCardLine[] {
|
|
1038
|
+
return buildWorkflowDialog(input).lines
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
/** What the last layout knew about the detail pane, which the key handler needs to scroll it. */
|
|
1042
|
+
export interface DetailPaneMetrics {
|
|
1043
|
+
/** Furthest the detail can scroll; 0 means it fits. */
|
|
1044
|
+
maxDetailScroll: number
|
|
1045
|
+
/** Rows the pane shows at once — one page. */
|
|
1046
|
+
detailPageRows: number
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* The layout plus how far the detail pane can scroll, which only the layout
|
|
1051
|
+
* knows — it depends on the width the rows wrapped at. The shell keeps it so
|
|
1052
|
+
* `↓` stops at the last row instead of piling up offset nobody can see.
|
|
1053
|
+
*/
|
|
1054
|
+
export function buildWorkflowDialog(
|
|
1055
|
+
input: WorkflowDialogInput,
|
|
1056
|
+
): { lines: WorkflowCardLine[] } & DetailPaneMetrics {
|
|
763
1057
|
const glyphs = input.ascii ? ASCII_DIALOG_GLYPHS : UNICODE_DIALOG_GLYPHS
|
|
764
1058
|
const width = workflowDialogContentWidth(input.width ?? DEFAULT_WIDTH)
|
|
765
1059
|
const now = input.now ?? Date.now()
|
|
766
1060
|
const view = resolveWorkflowDialog(input)
|
|
767
1061
|
const { state } = input
|
|
768
|
-
//
|
|
769
|
-
// there is something to measure.
|
|
1062
|
+
// The frame's body height, fixed: the panes are built against it and drawn at it.
|
|
770
1063
|
const capacity = Math.max(
|
|
771
1064
|
MIN_PANE_BODY_ROWS,
|
|
772
1065
|
input.bodyRows ?? DEFAULT_PANE_BODY_ROWS,
|
|
@@ -887,6 +1180,7 @@ export function layoutWorkflowDialog(
|
|
|
887
1180
|
|
|
888
1181
|
// ---- The detail pane, in the subview only.
|
|
889
1182
|
const detailRows: WorkflowCardLine[] = []
|
|
1183
|
+
let expandable = false
|
|
890
1184
|
if (!inPhases && entry) {
|
|
891
1185
|
const display = displayState(entry, view.workflowActive)
|
|
892
1186
|
// Prefers the canonical `provider/model-id` here — two providers can serve
|
|
@@ -932,63 +1226,18 @@ export function layoutWorkflowDialog(
|
|
|
932
1226
|
)
|
|
933
1227
|
}
|
|
934
1228
|
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
}
|
|
948
|
-
detailRows.push([])
|
|
949
|
-
detailRows.push(detailHeading("Prompt", promptSuffix, rightWidth))
|
|
950
|
-
if (prompt.length === 0) {
|
|
951
|
-
detailRows.push(
|
|
952
|
-
detailBody(WORKFLOW_DIALOG_COPY.availableOnceStarted, rightWidth),
|
|
953
|
-
)
|
|
954
|
-
} else {
|
|
955
|
-
const shown = collapsed ? prompt.slice(0, PROMPT_COLLAPSED_LINES) : prompt
|
|
956
|
-
for (const text of shown) detailRows.push(detailBody(text, rightWidth))
|
|
957
|
-
// Named rather than silently cut: the reader has to know the prompt goes on.
|
|
958
|
-
if (collapsed) {
|
|
959
|
-
const hidden = prompt.length - PROMPT_COLLAPSED_LINES
|
|
960
|
-
detailRows.push(
|
|
961
|
-
detailBody(
|
|
962
|
-
`${glyphs.ellipsis} ${hidden} more line${hidden === 1 ? "" : "s"}`,
|
|
963
|
-
rightWidth,
|
|
964
|
-
),
|
|
965
|
-
)
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
const toolCalls = entry.toolCalls ?? 0
|
|
970
|
-
detailRows.push([])
|
|
971
|
-
detailRows.push(
|
|
972
|
-
detailHeading(
|
|
973
|
-
"Activity",
|
|
974
|
-
toolCalls > 0
|
|
975
|
-
? [`${toolCalls} tool call${toolCalls === 1 ? "" : "s"}`]
|
|
976
|
-
: [],
|
|
977
|
-
rightWidth,
|
|
978
|
-
),
|
|
979
|
-
)
|
|
980
|
-
detailRows.push(detailBody(activityBody(entry, display), rightWidth))
|
|
981
|
-
|
|
982
|
-
detailRows.push([])
|
|
983
|
-
detailRows.push(detailHeading("Outcome", [], rightWidth))
|
|
984
|
-
// Wrapped, not clamped: the outcome is the thing the reader came for, and
|
|
985
|
-
// cutting it at the pane edge would hide the half that matters.
|
|
986
|
-
for (const text of wrapTextWithAnsi(
|
|
987
|
-
outcomeBody(entry, display),
|
|
988
|
-
Math.max(1, rightWidth - 4),
|
|
989
|
-
)) {
|
|
990
|
-
detailRows.push(detailBody(text, rightWidth))
|
|
991
|
-
}
|
|
1229
|
+
const detail =
|
|
1230
|
+
entry.recordId !== undefined ? input.detail?.(entry.recordId) : undefined
|
|
1231
|
+
const sections = detailSections({
|
|
1232
|
+
entry,
|
|
1233
|
+
display,
|
|
1234
|
+
detail,
|
|
1235
|
+
expanded: state.expanded,
|
|
1236
|
+
width: rightWidth,
|
|
1237
|
+
glyphs,
|
|
1238
|
+
})
|
|
1239
|
+
detailRows.push(...sections.rows)
|
|
1240
|
+
expandable = sections.expandable
|
|
992
1241
|
}
|
|
993
1242
|
|
|
994
1243
|
const phaseTitle = view.groups[view.clampedPhase]?.title ?? "Phases"
|
|
@@ -1002,7 +1251,23 @@ export function layoutWorkflowDialog(
|
|
|
1002
1251
|
// Indented one column, so the frame's left edge lines up under the name and
|
|
1003
1252
|
// the description rather than hanging off the edge of them.
|
|
1004
1253
|
const leftRows = inPhases ? phaseRows : agentRows
|
|
1005
|
-
|
|
1254
|
+
// Always the full capacity, so the box never resizes under the reader. The
|
|
1255
|
+
// list panes were built against it; the detail is the one pane that can
|
|
1256
|
+
// hold more, and it scrolls inside the frame rather than being cut by it.
|
|
1257
|
+
const bodyRows = capacity
|
|
1258
|
+
const maxDetailScroll = inPhases
|
|
1259
|
+
? 0
|
|
1260
|
+
: Math.max(0, detailRows.length - bodyRows)
|
|
1261
|
+
const scroll = clampIndex(state.detailScroll, maxDetailScroll + 1)
|
|
1262
|
+
const rightRows = inPhases
|
|
1263
|
+
? agentRows
|
|
1264
|
+
: detailRows.slice(scroll, scroll + bodyRows)
|
|
1265
|
+
// `1–26 of 35 ↓` in the bottom edge, so a pane that runs on says so.
|
|
1266
|
+
let rightFooter: string | undefined
|
|
1267
|
+
if (maxDetailScroll > 0) {
|
|
1268
|
+
const arrows = `${scroll > 0 ? glyphs.moreAbove : ""}${scroll < maxDetailScroll ? glyphs.moreBelow : ""}`
|
|
1269
|
+
rightFooter = `${scroll + 1}${glyphs.rangeDash}${scroll + rightRows.length} of ${detailRows.length} ${arrows}`
|
|
1270
|
+
}
|
|
1006
1271
|
lines.push(
|
|
1007
1272
|
...paneFrame({
|
|
1008
1273
|
leftTitle: inPhases ? "Phases" : agentPaneTitle,
|
|
@@ -1011,14 +1276,10 @@ export function layoutWorkflowDialog(
|
|
|
1011
1276
|
: (entry?.label ?? WORKFLOW_DIALOG_COPY.noAgents),
|
|
1012
1277
|
leftRows,
|
|
1013
1278
|
rightRows,
|
|
1279
|
+
rightFooter,
|
|
1280
|
+
rightFocused: detailHasFocus(state, maxDetailScroll),
|
|
1014
1281
|
width: width - 1,
|
|
1015
|
-
|
|
1016
|
-
// were built against `capacity`, so neither can exceed it and nothing
|
|
1017
|
-
// measured here is ever cut by the frame it is sizing.
|
|
1018
|
-
bodyRows: Math.min(
|
|
1019
|
-
capacity,
|
|
1020
|
-
Math.max(MIN_PANE_BODY_ROWS, leftRows.length, rightRows.length),
|
|
1021
|
-
),
|
|
1282
|
+
bodyRows,
|
|
1022
1283
|
glyphs,
|
|
1023
1284
|
}).map((line) => [{ text: " " }, ...line]),
|
|
1024
1285
|
)
|
|
@@ -1037,10 +1298,18 @@ export function layoutWorkflowDialog(
|
|
|
1037
1298
|
if (view.visibleAgents.length > 0) hints.push(`${glyphs.enter} open`)
|
|
1038
1299
|
hints.push("f filter")
|
|
1039
1300
|
} else {
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1301
|
+
// `↑↓` follow the focus: the agent list's cursor, or the detail once `→`
|
|
1302
|
+
// moved into it. `→` also expands a collapsed detail, but is advertised
|
|
1303
|
+
// only once there is something to scroll: on a collapsed one `⏎ expand`
|
|
1304
|
+
// already says so, and every hint costs what an 80-column footer drops.
|
|
1305
|
+
if (detailHasFocus(state, maxDetailScroll)) {
|
|
1306
|
+
hints.push(`${glyphs.upDown} scroll`, `${glyphs.left} agents`)
|
|
1307
|
+
} else {
|
|
1308
|
+
hints.push(`${glyphs.upDown} agent`)
|
|
1309
|
+
if (maxDetailScroll > 0) hints.push(`${glyphs.right} scroll`)
|
|
1043
1310
|
}
|
|
1311
|
+
if (expandable)
|
|
1312
|
+
hints.push(`${glyphs.enter} ${state.expanded ? "collapse" : "expand"}`)
|
|
1044
1313
|
const actions = agentActions(entry, view.workflowActive)
|
|
1045
1314
|
if (actions.skip && can("onSkipAgent")) hints.push("s skip")
|
|
1046
1315
|
if (actions.retry && can("onRetryAgent")) hints.push("r retry")
|
|
@@ -1066,7 +1335,7 @@ export function layoutWorkflowDialog(
|
|
|
1066
1335
|
clampLine([{ text: ` ${hints.join(" · ")}`, color: "dim" }], width),
|
|
1067
1336
|
)
|
|
1068
1337
|
|
|
1069
|
-
return lines
|
|
1338
|
+
return { lines, maxDetailScroll, detailPageRows: bodyRows }
|
|
1070
1339
|
}
|
|
1071
1340
|
|
|
1072
1341
|
/* ------------------------------------------------------------------------- *
|
|
@@ -1090,7 +1359,15 @@ export function handleWorkflowDialogKey(
|
|
|
1090
1359
|
data: string,
|
|
1091
1360
|
state: WorkflowDialogState,
|
|
1092
1361
|
view: ResolvedWorkflowDialog,
|
|
1362
|
+
/** From the last layout (`buildWorkflowDialog`); the default is a detail that fits. */
|
|
1363
|
+
pane: DetailPaneMetrics = { maxDetailScroll: 0, detailPageRows: 1 },
|
|
1364
|
+
/** Page and jump keys, resolved through the user's keybindings as the conversation viewer's are. */
|
|
1365
|
+
keys: ViewerKeys = createViewerKeys(),
|
|
1093
1366
|
): { state: WorkflowDialogState; action?: WorkflowDialogAction } | undefined {
|
|
1367
|
+
const { maxDetailScroll } = pane
|
|
1368
|
+
// Where the layout drew the detail: the stored offset can outrun a detail
|
|
1369
|
+
// that has since shrunk, and stepping from it would swallow a keypress.
|
|
1370
|
+
const scroll = Math.min(state.detailScroll, maxDetailScroll)
|
|
1094
1371
|
// Ctrl+C is the reflex for backing out of a full-screen overlay, so it closes
|
|
1095
1372
|
// outright from EITHER level — the conversation viewer's #255 fix, which this
|
|
1096
1373
|
// dialog is reached the same way as. Deliberately not folded into the `esc`
|
|
@@ -1101,17 +1378,79 @@ export function handleWorkflowDialogKey(
|
|
|
1101
1378
|
// Back one level before out of the dialog: `esc` in the subview returns to
|
|
1102
1379
|
// the overview, and only closes from there. Anything else would make a wrong
|
|
1103
1380
|
// turn cost the whole dialog.
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1381
|
+
// A focused detail is the innermost level, so `esc` and `←` hand focus back
|
|
1382
|
+
// to the agent list first — and fold the detail back to its compact view,
|
|
1383
|
+
// undoing the expand that `→` did on the way in.
|
|
1384
|
+
const focused = detailHasFocus(state, maxDetailScroll)
|
|
1385
|
+
const back = matchesKey(data, "escape") || matchesKey(data, "q")
|
|
1386
|
+
if (focused && (back || matchesKey(data, "left"))) {
|
|
1387
|
+
return {
|
|
1388
|
+
state: {
|
|
1389
|
+
...state,
|
|
1390
|
+
detailFocused: false,
|
|
1391
|
+
expanded: false,
|
|
1392
|
+
detailScroll: 0,
|
|
1393
|
+
},
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
const toPhases = {
|
|
1397
|
+
...state,
|
|
1398
|
+
level: "phases" as const,
|
|
1399
|
+
expanded: false,
|
|
1400
|
+
detailScroll: 0,
|
|
1401
|
+
detailFocused: false,
|
|
1402
|
+
}
|
|
1403
|
+
if (back) {
|
|
1404
|
+
if (state.level === "agent") return { state: toPhases }
|
|
1107
1405
|
return { state, action: { kind: "cancel" } }
|
|
1108
1406
|
}
|
|
1109
|
-
if (matchesKey(data, "left") && state.level === "agent")
|
|
1110
|
-
return { state:
|
|
1407
|
+
if (matchesKey(data, "left") && state.level === "agent")
|
|
1408
|
+
return { state: toPhases }
|
|
1409
|
+
// `→` goes into the detail: expanded, so there is all of it to read, and
|
|
1410
|
+
// focused, so `↑↓` scroll it. Whether the expanded detail overflows is only
|
|
1411
|
+
// known once the next layout has wrapped it; if it fits, `detailHasFocus`
|
|
1412
|
+
// stays false and the arrows keep moving between agents.
|
|
1413
|
+
if (matchesKey(data, "right") && state.level === "agent") {
|
|
1414
|
+
return {
|
|
1415
|
+
state: {
|
|
1416
|
+
...state,
|
|
1417
|
+
expanded: true,
|
|
1418
|
+
detailFocused: true,
|
|
1419
|
+
detailScroll: state.expanded ? scroll : 0,
|
|
1420
|
+
},
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
// Paging and jumps, with the conversation viewer's keys: `PgUp`/`PgDn` (or
|
|
1425
|
+
// `shift+↑`/`shift+↓`) a page, `Home`/`End` the ends. Checked before the
|
|
1426
|
+
// arrows, and active whether or not the detail has focus, since nothing else
|
|
1427
|
+
// in the subview uses them.
|
|
1428
|
+
if (state.level === "agent" && maxDetailScroll > 0) {
|
|
1429
|
+
const scrollTo = (row: number) => ({
|
|
1430
|
+
state: {
|
|
1431
|
+
...state,
|
|
1432
|
+
detailScroll: Math.min(Math.max(0, row), maxDetailScroll),
|
|
1433
|
+
},
|
|
1434
|
+
})
|
|
1435
|
+
if (keys.pageDown(data)) return scrollTo(scroll + pane.detailPageRows)
|
|
1436
|
+
if (keys.pageUp(data)) return scrollTo(scroll - pane.detailPageRows)
|
|
1437
|
+
if (keys.top(data) || matchesKey(data, "home")) return scrollTo(0)
|
|
1438
|
+
if (keys.bottom(data) || matchesKey(data, "end"))
|
|
1439
|
+
return scrollTo(maxDetailScroll)
|
|
1111
1440
|
}
|
|
1112
1441
|
|
|
1442
|
+
// `j`/`k` are `↓`/`↑`. At the overview they move the phase cursor; in the
|
|
1443
|
+
// subview they move between agents, or scroll the detail once `→` has
|
|
1444
|
+
// focused it.
|
|
1113
1445
|
const down = matchesKey(data, "j") || matchesKey(data, "down")
|
|
1114
1446
|
const up = matchesKey(data, "k") || matchesKey(data, "up")
|
|
1447
|
+
if (focused && (down || up)) {
|
|
1448
|
+
const next = Math.min(
|
|
1449
|
+
Math.max(0, scroll + (down ? 1 : -1)),
|
|
1450
|
+
maxDetailScroll,
|
|
1451
|
+
)
|
|
1452
|
+
return { state: { ...state, detailScroll: next } }
|
|
1453
|
+
}
|
|
1115
1454
|
if (down || up) {
|
|
1116
1455
|
const delta = down ? 1 : -1
|
|
1117
1456
|
if (state.level === "phases") {
|
|
@@ -1125,31 +1464,38 @@ export function handleWorkflowDialogKey(
|
|
|
1125
1464
|
: { ...state, selectedPhase: next, selectedAgent: 0 },
|
|
1126
1465
|
}
|
|
1127
1466
|
}
|
|
1467
|
+
const next = clampIndex(
|
|
1468
|
+
view.clampedAgent + delta,
|
|
1469
|
+
view.visibleAgents.length,
|
|
1470
|
+
)
|
|
1471
|
+
if (next === view.clampedAgent) return { state }
|
|
1472
|
+
// A different agent's detail starts at its top, collapsed.
|
|
1128
1473
|
return {
|
|
1129
1474
|
state: {
|
|
1130
1475
|
...state,
|
|
1131
|
-
selectedAgent:
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1476
|
+
selectedAgent: next,
|
|
1477
|
+
expanded: false,
|
|
1478
|
+
detailScroll: 0,
|
|
1479
|
+
detailFocused: false,
|
|
1135
1480
|
},
|
|
1136
1481
|
}
|
|
1137
1482
|
}
|
|
1138
1483
|
|
|
1139
1484
|
// One key, two jobs, because the two levels are what it means at each: open
|
|
1140
|
-
// the selected phase's agents, then expand the
|
|
1485
|
+
// the selected phase's agents, then expand the detail of the one you opened.
|
|
1486
|
+
// `→` opens a phase too; in the subview it moves focus instead (above).
|
|
1141
1487
|
if (matchesKey(data, "enter") || matchesKey(data, "right")) {
|
|
1142
1488
|
if (state.level === "phases") {
|
|
1143
1489
|
// Nothing to open, so nothing happens — entering an empty pane would
|
|
1144
1490
|
// strand the reader in a subview with no rows and no detail.
|
|
1145
1491
|
if (view.visibleAgents.length === 0) return { state }
|
|
1146
|
-
return {
|
|
1492
|
+
return {
|
|
1493
|
+
state: { ...state, level: "agent", expanded: false, detailScroll: 0 },
|
|
1494
|
+
}
|
|
1147
1495
|
}
|
|
1148
|
-
return { state:
|
|
1149
|
-
}
|
|
1150
|
-
if (matchesKey(data, "e")) {
|
|
1151
|
-
return { state: { ...state, promptExpanded: !state.promptExpanded } }
|
|
1496
|
+
return { state: toggleExpanded(state) }
|
|
1152
1497
|
}
|
|
1498
|
+
if (matchesKey(data, "e")) return { state: toggleExpanded(state) }
|
|
1153
1499
|
|
|
1154
1500
|
// The one key that opens something instead of changing the run, so unlike
|
|
1155
1501
|
// skip/retry it works at both levels and on a settled agent: reading what a
|
|
@@ -1213,6 +1559,8 @@ export class WorkflowDialog implements Component {
|
|
|
1213
1559
|
private spinnerFrame = 0
|
|
1214
1560
|
private timer: ReturnType<typeof setInterval> | undefined
|
|
1215
1561
|
private closed = false
|
|
1562
|
+
/** How far the detail may scroll, and its page size, as of the last render. */
|
|
1563
|
+
private pane: DetailPaneMetrics = { maxDetailScroll: 0, detailPageRows: 1 }
|
|
1216
1564
|
|
|
1217
1565
|
constructor(
|
|
1218
1566
|
private tui: TUI,
|
|
@@ -1221,6 +1569,7 @@ export class WorkflowDialog implements Component {
|
|
|
1221
1569
|
private done: (result: undefined) => void,
|
|
1222
1570
|
private actions: WorkflowDialogActions = {},
|
|
1223
1571
|
initialPhaseIndex = 0,
|
|
1572
|
+
private keys: ViewerKeys = createViewerKeys(),
|
|
1224
1573
|
) {
|
|
1225
1574
|
this.state = initialWorkflowDialogState(initialPhaseIndex)
|
|
1226
1575
|
this.timer = setInterval(() => {
|
|
@@ -1236,6 +1585,8 @@ export class WorkflowDialog implements Component {
|
|
|
1236
1585
|
data,
|
|
1237
1586
|
this.state,
|
|
1238
1587
|
resolveWorkflowDialog(input),
|
|
1588
|
+
this.pane,
|
|
1589
|
+
this.keys,
|
|
1239
1590
|
)
|
|
1240
1591
|
if (!result) return
|
|
1241
1592
|
this.state = result.state
|
|
@@ -1244,7 +1595,7 @@ export class WorkflowDialog implements Component {
|
|
|
1244
1595
|
}
|
|
1245
1596
|
|
|
1246
1597
|
render(width: number): string[] {
|
|
1247
|
-
const lines =
|
|
1598
|
+
const { lines, maxDetailScroll, detailPageRows } = buildWorkflowDialog({
|
|
1248
1599
|
...this.source(),
|
|
1249
1600
|
state: this.state,
|
|
1250
1601
|
// Derived from what was actually injected, so the footer advertises only
|
|
@@ -1259,7 +1610,19 @@ export class WorkflowDialog implements Component {
|
|
|
1259
1610
|
},
|
|
1260
1611
|
width,
|
|
1261
1612
|
spinnerFrame: this.spinnerFrame,
|
|
1613
|
+
// Sized to the overlay's share of the terminal, so the whole dialog fits
|
|
1614
|
+
// its `maxHeight` (bar a very small terminal) and keeps one height
|
|
1615
|
+
// while it is open.
|
|
1616
|
+
bodyRows: workflowDialogBodyRows(this.tui.terminal.rows),
|
|
1262
1617
|
})
|
|
1618
|
+
this.pane = { maxDetailScroll, detailPageRows }
|
|
1619
|
+
// A focus with nothing to scroll is dropped, not kept dormant: otherwise a
|
|
1620
|
+
// running agent whose transcript later outgrows the pane would turn `↑↓`
|
|
1621
|
+
// into scroll keys under the reader, with no keypress. The render right
|
|
1622
|
+
// after `→` already measures the expanded detail, so a detail that
|
|
1623
|
+
// overflows keeps the focus `→` gave it.
|
|
1624
|
+
if (this.state.detailFocused && maxDetailScroll === 0)
|
|
1625
|
+
this.state = { ...this.state, detailFocused: false }
|
|
1263
1626
|
return styleWorkflowCardLines(lines, this.theme)
|
|
1264
1627
|
}
|
|
1265
1628
|
|