Skip to content

feat(workflows): inspect completed runs from resume - #1758

Merged
lavaman131 merged 2 commits into
mainfrom
feat/1532-completed-workflow-resume
Jul 13, 2026
Merged

feat(workflows): inspect completed runs from resume#1758
lavaman131 merged 2 commits into
mainfrom
feat/1532-completed-workflow-resume

Conversation

@lavaman131

@lavaman131 lavaman131 commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds successful completed workflows to the existing /workflow resume experience. Completed targets appear in the same picker as live and durable resumable runs, use green ✓ completed styling, and open an authoritative read-only workflow snapshot with retained stage-chat follow-up instead of re-dispatching workflow execution.

Changes

  • Added a separate completed-workflow durable catalog and open path, keeping completed runs out of resumability predicates and re-dispatch logic.
  • Retained successful file-backed durable state for completed inspection while preserving pruning for cancelled and explicitly non-resumable terminal failures.
  • Reconstructs immutable completed run/stage detail from authoritative durable handles and checkpoints.
  • Lazily reopens retained Atomic stage transcripts for contextual follow-up chat without changing the workflow status or replaying stages, tasks, tools, prompts, or side effects.
  • Hides stale completed rows unless they have authoritative checkpoint state and at least one usable retained stage conversation; validates regular, parseable, context-bearing transcripts after merging repeated stage checkpoints.
  • Resolves explicit full IDs and prefixes across eligible live, durable resumable, and completed targets as one namespace, with full-ID precedence and clear ambiguous, missing, and stale diagnostics.
  • Prevents retained local completed snapshots from bypassing durable validation or replacing authoritative completed detail.
  • Preserves paused, recoverable-failed, blocked, quit-shadow, crash-recovery, and active-running resume/connect behavior; cancelled, killed, skipped, and non-resumable failures remain excluded.
  • Updated workflow docs and both package changelogs.

Acceptance Criteria

  • Mixed no-argument picker contains resumable and completed workflows in one list.
  • Completed rows use the existing success color and ✓ completed label.
  • Completed selection and explicit completed IDs/prefixes open detail/chat without workflow re-execution.
  • Stale completed state is hidden from discovery and explicitly diagnosed.
  • Prefix ambiguity is detected across the mixed target namespace.
  • Existing resumable workflow paths remain on their prior control/dispatch routes.
  • Normal /resume, atomic -r, and --continue internal-session behavior is unchanged.

Validation

  • Focused durable/completed/resume tests: 197 passed
  • Integration suite: 248 passed, 1 skipped (installed-package Node extension test requires a built package and real Node)
  • Pre-commit and pre-push full unit test hooks: passed
  • bun run typecheck: passed
  • bun run lint: passed
  • bun run check:file-length: passed
  • git diff --check: passed

Fixes #1532

Verified proof

Rebased onto latest origin/main and force-pushed with lease.

Tmux-captured inline behavior:

✓ workflow resume selector > globally orders mixed rows and renders completed rows with a green semantic
✓ workflow resume selector > uses latest stage activity and deterministic ids for equal-time ties
✓ workflow resume selector > deduplicates before sorting and keeps live then durable precedence
✓ workflow resume selector > closes when the custom selector mount throws or rejects
✓ completed workflow inspection > opens immutable detail and appends follow-up chat without durable re-dispatch
✓ completed workflow inspection > refreshes a retained chat handle when authoritative transcript detail changes
✓ completed workflow inspection > removes a retained chat handle when its transcript becomes invalid
✓ completed workflow inspection > opens a retained internal stage transcript without exposing it in ordinary history

10 pass
0 fail

Greptile Summary

This PR adds completed workflow inspection to the existing /workflow resume flow. The main changes are:

  • Adds a separate completed-workflow durable catalog and read-only open path.
  • Shows live, durable resumable, and completed targets in one deduplicated selector.
  • Opens completed runs from authoritative durable checkpoints without re-dispatching workflow execution.
  • Retains successful file-backed completed state while continuing to prune cancelled and non-resumable terminal state.
  • Reopens retained stage transcripts for follow-up chat without changing the completed workflow status.
  • Updates docs, changelogs, and tests for mixed target resolution, stale filtering, and selector behavior.

Confidence Score: 5/5

Safe to merge with low risk.

No issues were identified in the reviewed changes. The completed inspection path stays separate from durable re-dispatch, validates stale or invalid completed state before opening, and preserves existing live and durable resume behavior.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • Ran the focused unit tests across six files and confirmed all tests passed (82 pass, 0 fail).
  • Ran the integration entrypoint tests and confirmed all tests passed (21 pass, 0 fail).
  • No broader suite, install, or Docker-dependent validation was performed, per the request.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
packages/workflows/src/durable/completed-catalog.ts Introduces authoritative completed workflow discovery, stale filtering, checkpoint-to-snapshot reconstruction, and retained transcript validation.
packages/workflows/src/durable/completed-inspection.ts Adds read-only completed workflow opening and lazy retained stage chat handle registration without re-dispatching workflow execution.
packages/workflows/src/durable/file-backend.ts Retains successful completed file-backed workflow state and lists completed rows for inspection while still pruning cancelled and non-resumable terminal files.
packages/workflows/src/extension/workflow-durable-resume-command.ts Routes /workflow resume targets between durable resume and completed inspection, including mixed catalog formatting and ambiguity handling.
packages/workflows/src/extension/workflow-run-control-command.ts Integrates live, durable, and completed target resolution into run-control resume while preserving existing live resume and connect paths.
packages/workflows/src/tui/workflow-resume-selector.ts Builds mixed resume selector items with recency sorting, live/durable/completed precedence, and safe close behavior on selector failures.
test/unit/workflow-completed-inspection.test.ts Covers completed inspection snapshot opening, retained chat refresh/removal, active-run refusal, and internal transcript handling.
test/unit/workflow-resume-selector.test.ts Covers mixed selector ordering, deduplication, completed styling, and selector mount failure settlement.
test/unit/workflow-run-control-completed-resume.test.ts Covers command routing for completed, live, durable, stale, ambiguous, and excluded resume targets.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant Command as /workflow resume
participant Runtime
participant Backend as Durable Backend
participant Selector as Mixed Selector
participant Store
participant Overlay

User->>Command: /workflow resume [id-or-prefix]
Command->>Runtime: prepare durable resumable + completed catalogs
Runtime->>Backend: hydrate/list resumable and completed handles
Backend-->>Runtime: live durable rows + openable completed rows
Runtime-->>Command: mixed resume catalog
alt no explicit target
    Command->>Selector: open live + durable + completed picker
    Selector-->>Command: selected live/durable/completed target
end
alt durable resumable target
    Command->>Runtime: resumeDurableWorkflow(id)
    Runtime->>Backend: mark running and replay checkpoints
    Runtime-->>Command: resumed run id
    Command->>Overlay: open resumed workflow
else completed target
    Command->>Runtime: openCompletedDurableWorkflow(id)
    Runtime->>Backend: load authoritative handle + checkpoints
    Runtime->>Store: record immutable completed snapshot
    Runtime-->>Command: opened completed run id
    Command->>Overlay: open read-only detail/chat snapshot
end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant User
participant Command as /workflow resume
participant Runtime
participant Backend as Durable Backend
participant Selector as Mixed Selector
participant Store
participant Overlay

User->>Command: /workflow resume [id-or-prefix]
Command->>Runtime: prepare durable resumable + completed catalogs
Runtime->>Backend: hydrate/list resumable and completed handles
Backend-->>Runtime: live durable rows + openable completed rows
Runtime-->>Command: mixed resume catalog
alt no explicit target
    Command->>Selector: open live + durable + completed picker
    Selector-->>Command: selected live/durable/completed target
end
alt durable resumable target
    Command->>Runtime: resumeDurableWorkflow(id)
    Runtime->>Backend: mark running and replay checkpoints
    Runtime-->>Command: resumed run id
    Command->>Overlay: open resumed workflow
else completed target
    Command->>Runtime: openCompletedDurableWorkflow(id)
    Runtime->>Backend: load authoritative handle + checkpoints
    Runtime->>Store: record immutable completed snapshot
    Runtime-->>Command: opened completed run id
    Command->>Overlay: open read-only detail/chat snapshot
end
Loading

Reviews (4): Last reviewed commit: "fix(workflows): harden completed resume ..." | Re-trigger Greptile

@mintlify

mintlify Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
bastani 🟢 Ready View Preview Jul 12, 2026, 7:56 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

Comment thread packages/workflows/src/extension/workflow-durable-resume-command.ts
@flora131
flora131 force-pushed the feat/1532-completed-workflow-resume branch from b5362a6 to 4ac93e7 Compare July 13, 2026 03:42
@lavaman131

lavaman131 commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

Verified proof

Rebased onto latest origin/main and force-pushed with lease.

Tmux-captured inline behavior:

✓ workflow resume selector > globally orders mixed rows and renders completed rows with a green semantic
✓ workflow resume selector > uses latest stage activity and deterministic ids for equal-time ties
✓ workflow resume selector > deduplicates before sorting and keeps live then durable precedence
✓ workflow resume selector > closes when the custom selector mount throws or rejects
✓ completed workflow inspection > opens immutable detail and appends follow-up chat without durable re-dispatch
✓ completed workflow inspection > refreshes a retained chat handle when authoritative transcript detail changes
✓ completed workflow inspection > removes a retained chat handle when its transcript becomes invalid
✓ completed workflow inspection > opens a retained internal stage transcript without exposing it in ordinary history

10 pass
0 fail

@flora131
flora131 force-pushed the feat/1532-completed-workflow-resume branch from 4ac93e7 to e47a6fb Compare July 13, 2026 22:13
@lavaman131
lavaman131 merged commit 2a2e90d into main Jul 13, 2026
10 checks passed
@lavaman131
lavaman131 deleted the feat/1532-completed-workflow-resume branch July 13, 2026 22:21
flora131 added a commit that referenced this pull request Jul 15, 2026
…replay, and send

Generalize the completed-workflow-inspection detached-handle pattern (#1758) into a shared post-mortem stage-chat resolver so any eligible terminal agent stage with a valid retained Atomic session reopens as an interactive follow-up conversation — not only completed-inspection, but also generic /workflow attach and /workflow connect, restored/replayed durable snapshots after a process restart, and workflow send.

Adds ensurePostMortemStageHandle: reuses an existing non-disposed handle, validates the retained sessionFile is an existing readable context-bearing transcript, and lazily reopens it through a detached, single-flight StageControlRegistry.getOrCreateDetached handle keyed by the real runId/stageId. Follow-ups append in place; run/stage status, results, timings, checkpoints, replay metadata, and graph topology stay immutable, and post-mortem chat can never resume/retry/rewind/pause/re-dispatch execution. Stages without a valid retained agent session keep the read-only transcript; recoverably failed stages keep execution-resume semantics.

Refs: #1811
Assistant-model: Claude Opus 4.8
flora131 added a commit that referenced this pull request Jul 15, 2026
…replay, and send (#1811) (#1813)

* feat(workflows): unify post-mortem stage chat across attach, restore/replay, and send

Generalize the completed-workflow-inspection detached-handle pattern (#1758) into a shared post-mortem stage-chat resolver so any eligible terminal agent stage with a valid retained Atomic session reopens as an interactive follow-up conversation — not only completed-inspection, but also generic /workflow attach and /workflow connect, restored/replayed durable snapshots after a process restart, and workflow send.

Adds ensurePostMortemStageHandle: reuses an existing non-disposed handle, validates the retained sessionFile is an existing readable context-bearing transcript, and lazily reopens it through a detached, single-flight StageControlRegistry.getOrCreateDetached handle keyed by the real runId/stageId. Follow-ups append in place; run/stage status, results, timings, checkpoints, replay metadata, and graph topology stay immutable, and post-mortem chat can never resume/retry/rewind/pause/re-dispatch execution. Stages without a valid retained agent session keep the read-only transcript; recoverably failed stages keep execution-resume semantics.

Refs: #1811
Assistant-model: Claude Opus 4.8

* fix(workflows): reject post-mortem execution resume

Assistant-model: GPT-5.6 Sol

* fix(workflows): clarify terminal send delivery

Assistant-model: GPT-5.6 Sol

* fix(workflows): queue terminal auto sends

Route automatic delivery on a streaming post-mortem stage to follow-up instead of rejecting it as an explicit execution steer.

Assistant-model: GPT-5.6 Sol

* fix(workflows): bypass exact resume catalog scan

Resolve exact compatible live workflow IDs before enumerating the completed durable catalog, avoiding unbounded resume latency from unrelated retained runs.

Assistant-model: GPT-5.6 Sol

* test(workflows): isolate nested attach setup

Initialize slash-command resources before seeding the shared workflow store so concurrent test cleanup cannot erase the nested attach fixture during module loading.

Assistant-model: GPT-5.6 Sol

* fix(workflows): fence post-mortem session boundaries

Assistant-model: GPT-5.6 Sol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show completed workflows in /workflow resume

2 participants