feat: improve workflow detail pager#92
Conversation
QuintinShaw
left a comment
There was a problem hiding this comment.
Really nice work — the pager, the syntax highlighting, and the caching (bounded LRU, content-keyed) are all clean, and the 923-test suite is green.
One blocking issue before merge, in the result-dedup change. persistRun now strips agents[].result for any non-terminal run (keepsResumeJournal is true for running/paused/failed), leaving the full value only in the journal. But persistedToSnapshot — the cold-read path used whenever getRun() misses, i.e. after a pi restart or from another session — only reads agents[].result/resultPreview and never consults p.journal. So once you restart pi and open /workflows on a previously failed/paused/interrupted run, its completed agents show only the truncated preview, even though the full result is still on disk in the journal. It's not a crash and the bytes aren't lost, but it's a durability/UX regression vs main (which persisted the full result into agents[]) and it undercuts exactly the after-the-fact inspection the pager is for. Same-session live views are unaffected.
Suggested fix: in persistedToSnapshot, when a done agent has no result, reconstruct it from p.journal by positional call index (journal .index is the call index — the same match resume() already relies on). A regression test that persists a non-terminal run, re-reads it via a fresh manager, and asserts the pager sees the full result would lock it in — the current tests only exercise completed/live paths.
Two minor, optional: Right on an already-open pager toggles it closed (the description frames Right as "open"); and the shared historyRenderTimer can drop a coalesced history update when you switch agents mid-window (self-heals on the next event). It also needs a quick rebase onto current main (disjoint files, should be clean).
Happy to take the journal-fallback fix myself and push to your branch if you'd prefer — your call.
fdf32f3 to
c35bfbc
Compare
|
@QuintinShaw Fix is in
|
Summary
agentHistoryrefreshes, cache expensive rendering/run reads, and document the new navigator controlsDetails
The full pager can be opened from any agent detail with
Enter/Right. It supports:j/kor arrow keys for line scrollingPgUp/PgDn(plus common control-key aliases) for page scrollingg/GorHome/Endfor boundary jumpstfor live tail/follow modeEnterorEscto return to the compact summaryMarkdown results use Pi's Markdown renderer. Structured results are rendered as highlighted JSON, saved workflow scripts as JavaScript, raw
readhistory inherits syntax highlighting from the requested file path, andwritecalls render their target path and source directly instead of dumping a raw JSON argument envelope.To keep large run histories responsive, each navigator frame shares one persisted snapshot, persistence briefly caches repeated list reads, Markdown/highlighting output is cached per overlay, and history redraws are limited to the selected agent. Terminal runs also store each full agent result only once instead of duplicating it in both the agent snapshot and resume journal.
Testing
npm test— 942 tests passedCompatibility
WorkflowAgentSnapshot.resultis optionalresultPreviewwhen no full result is available