-
Notifications
You must be signed in to change notification settings - Fork 140
feat(runner): make run --follow quiet, stream logs behind --logs #1483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Goran Gajic (gorangajic)
merged 4 commits into
main
from
goran/nova-1544-runner-run-follow-floods-the-output-keep-the-log-stream
Aug 13, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bd0b975
feat(runner): make run --follow quiet, stream logs behind --logs
gorangajic f812905
feat(runner): mirror run-events and recorder streams into run --follow
gorangajic d8acec3
docs(runner): recorder-events start at a pre-submission anchor
gorangajic a565d12
fix(runner): warn when a follow's final mirror read fails
gorangajic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@qawolf/cli": minor | ||
| --- | ||
|
|
||
| `qawolf runner run --follow` now reports only the run's status — an "in progress" line, then whether it passed or failed — instead of streaming every log line the run produces. The full log stream is available behind the new `--logs` flag, and two more flags mirror further streams into the follow as JSON lines: `--run-events` for the run's progress events and `--recorder-events` for the browser actions the runner records after an anchor taken just before submission. Each stream flag implies `--follow`. Anything parsing a followed run's stdout should expect at most one in-progress status entry by default and read the outcome from the exit code; pass `--logs` to keep receiving log lines, and follow one stream flag at a time when parsing — combined mirrors interleave without a stream label. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| import { formatRunLogLine } from "~/core/interactiveRunner/journal.js"; | ||
| import type { AuthCommandContext } from "~/shell/commandContext.js"; | ||
|
|
||
| import { | ||
| type CursorRead, | ||
| createPrintingCursor, | ||
| createUnreachableBudget, | ||
| } from "./journalCursor.js"; | ||
| import { | ||
| journalReadFailure, | ||
| readJournal, | ||
| unreachableFailure, | ||
| } from "./readJournal.js"; | ||
|
|
||
| const anchorPollIntervalMs = 1_000; | ||
|
|
||
| type RecorderAnchor = | ||
| | { ok: true; sinceSequence: number } | ||
| | { ok: false; failure: ReturnType<typeof journalReadFailure> }; | ||
|
|
||
| /** | ||
| * Where "this run's recorder events" begin: the recorder journal's current end. | ||
| * Taken before the run is submitted, so the anchor cannot sit past the run's | ||
| * first events. A runner this command just launched has a provably empty | ||
| * journal, so asking it would only wait out its boot for a knowable answer; | ||
| * only a reused runner is read. | ||
| * | ||
| * TODO NOVA-1546: the anchor exists because recorder payloads carry no runId; | ||
| * once the platform stamps them, a run filter replaces all of this. | ||
| */ | ||
| export async function resolveRecorderAnchor( | ||
| ctx: AuthCommandContext, | ||
| resolved: { runnerId: string; type: "launched" | "resolved" }, | ||
| deps: { sleep: (ms: number) => Promise<void> }, | ||
| ): Promise<RecorderAnchor> { | ||
| if (resolved.type === "launched") return { ok: true, sinceSequence: 0 }; | ||
| return anchorRecorderCursor(ctx, resolved.runnerId, deps); | ||
| } | ||
|
|
||
| /** | ||
| * An unreachable runner is retried on the follow's own grace, never guessed at: | ||
| * unreachable can mean a reused runner too busy to answer, and anchoring one at | ||
| * zero would replay its whole recorder history as this run's actions. A runner | ||
| * that never answers fails the command here, before anything is submitted and | ||
| * billed. | ||
| */ | ||
| async function anchorRecorderCursor( | ||
| ctx: AuthCommandContext, | ||
| runnerId: string, | ||
| deps: { sleep: (ms: number) => Promise<void> }, | ||
| ): Promise<RecorderAnchor> { | ||
| const unreachable = createUnreachableBudget(anchorPollIntervalMs); | ||
| for (;;) { | ||
| const anchor = await readJournal(ctx, runnerId, { | ||
| stream: "recorder", | ||
| tail: 1, | ||
| }); | ||
| if (anchor.type === "read") { | ||
| return { ok: true, sinceSequence: anchor.value.nextSequence }; | ||
| } | ||
| if (anchor.type === "failed") { | ||
| return { failure: journalReadFailure(anchor), ok: false }; | ||
| } | ||
| if (unreachable.exhausted()) { | ||
| return { failure: { ...unreachableFailure }, ok: false }; | ||
| } | ||
| await deps.sleep(anchorPollIntervalMs); | ||
| } | ||
| } | ||
|
|
||
| export type FollowStreamOptions = { | ||
| logs: boolean; | ||
| /** | ||
| * Where in the `recorder` stream this run's events begin, or undefined to not | ||
| * follow it. An anchor rather than a run filter, because recorder entries | ||
| * carry no `runId` — the recorder outlives runs, so "this run's recorder | ||
| * events" can only mean "recorded after this point". | ||
| */ | ||
| recorderSinceSequence: number | undefined; | ||
| runEvents: boolean; | ||
| runId: string; | ||
| runnerId: string; | ||
| }; | ||
|
|
||
| /** | ||
| * The mirror streams a follow prints beside `run-status`, one printing cursor | ||
| * per stream a flag asked for. Log lines print as their message; the event | ||
| * streams print each payload as one JSON line, the same rendering | ||
| * `qawolf runner events` gives them. | ||
| */ | ||
| export function createFollowPrinters( | ||
| ctx: AuthCommandContext, | ||
| options: FollowStreamOptions, | ||
| ): (() => Promise<CursorRead>)[] { | ||
| const jsonLine = (payload: unknown) => JSON.stringify(payload); | ||
| const printers: (() => Promise<CursorRead>)[] = []; | ||
| if (options.logs) { | ||
| printers.push( | ||
| createPrintingCursor( | ||
| ctx, | ||
| options.runnerId, | ||
| { runId: options.runId, stream: "run-logs" }, | ||
| formatRunLogLine, | ||
| ), | ||
| ); | ||
| } | ||
| if (options.runEvents) { | ||
| printers.push( | ||
| createPrintingCursor( | ||
| ctx, | ||
| options.runnerId, | ||
| { runId: options.runId, stream: "run-events" }, | ||
| jsonLine, | ||
| ), | ||
| ); | ||
| } | ||
| if (options.recorderSinceSequence !== undefined) { | ||
| printers.push( | ||
| createPrintingCursor( | ||
| ctx, | ||
| options.runnerId, | ||
| { sinceSequence: options.recorderSinceSequence, stream: "recorder" }, | ||
| jsonLine, | ||
| ), | ||
| ); | ||
| } | ||
| return printers; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.