Skip to content

feat: Add background execution with --background flag and run management#385

Merged
jahvon merged 2 commits intomainfrom
feat/background-exec
Apr 13, 2026
Merged

feat: Add background execution with --background flag and run management#385
jahvon merged 2 commits intomainfrom
feat/background-exec

Conversation

@jahvon
Copy link
Copy Markdown
Member

@jahvon jahvon commented Apr 13, 2026

Add support for detaching executable runs into background processes and
managing them through the logs command. This enables long-running tasks
to execute without blocking the terminal.

  • flow exec <ref> --background spawns a detached child process and
    returns a short run ID immediately. Output is captured in the log
    archive while stdout/stderr are redirected to /dev/null.
  • flow logs --running lists active background processes with the same
    output/TUI patterns as regular execution history (yaml, json, tui).
    Stale entries whose PIDs are no longer alive are pruned automatically.
  • flow logs kill <run-id> sends SIGTERM to terminate a background run.
  • flow logs attach <run-id> tail-follows the log archive file,
    streaming output in real time until the process exits or Ctrl-C.

Implementation details:

  • BackgroundRun model and CRUD methods added to DataStore (new "background"
    BBolt bucket) with mock support.
  • Child process eagerly links its log archive path into the run record so
    attach/streaming works while execution is in progress.
  • Archive file lookup uses direct filename scan (not ListArchiveEntries)
    to avoid the empty-file skip that would block early linking.
  • Structured output (json/yaml) returns empty arrays instead of message
    strings for parsability.
  • E2E tests cover --running (empty, active, stale pruning) and attach.
  • Documentation added to execution-history guide and CLI reference pages.

@jahvon jahvon linked an issue Apr 13, 2026 that may be closed by this pull request
@jahvon jahvon changed the title feat: background executions feat: Add background execution with --background flag and run management Apr 13, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 36.50794% with 200 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/internal/exec.go 3.94% 70 Missing and 3 partials ⚠️
internal/io/logs/background.go 20.77% 60 Missing and 1 partial ⚠️
cmd/internal/logs.go 54.86% 41 Missing and 10 partials ⚠️
pkg/store/store.go 72.09% 6 Missing and 6 partials ⚠️
internal/io/logs/output.go 50.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jahvon jahvon marked this pull request as ready for review April 13, 2026 21:13
@jahvon jahvon merged commit 53b5f6e into main Apr 13, 2026
14 checks passed
@jahvon jahvon deleted the feat/background-exec branch April 13, 2026 21:13
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.

Background executions

1 participant