#13
Fix CI log output and follow polling
Summary
- include every
actionLogsentry in humantry ci logsoutput, ordered by the first log timestamp, before the process stdout/stderr streams - implement
try ci logs --followas real polling until the API reportsdone - emit only appended bytes while following and ignore a temporarily shorter/stale snapshot so already printed output is not duplicated
- keep JSON follow output machine-readable by printing the final payload once
Verification
cargo fmt --checkcargo test --test trylle_cli_commands_mock ci_logs_cargo test --lib- the new integration tests cover joined human output, repeated polling, appended-byte cursors, and a shorter intermediate snapshot
The unrelated base tests
pr_view_human_output_renders_markdown_body_after_checks and
npm_check_json_reports_the_scoped_installation also fail on the untouched
master checkout. The latter still expects version 1.1.0 while the current
checkout reports 1.1.3.
Activity
4trylle-botreviewed4mo ago
938d637 into master3mo ago
First-pass review from an automated senior-engineer reviewer. No approval / change request — just observations for a human to weigh.
What changed
try ci logs/try ci watchnow render through a sharedemit_ci_logs→ci_log_componentspath that also surfaces everyactionLogsentry, ordered by the first RFC3339 timestamp in each body, beforestdout/stderr(src/trylle/mod.rs:2136).try ci logs --followis now real:follow_ci_logspolls/v1/ci/jobs/{run_id}/logson an interval until the payload reports"done": true(src/trylle/mod.rs:2130). The flag existed before but was silently ignored (the old arm matchedLogs { .., }).CiLogCursor::delta; JSON follow suppresses intermediate payloads and prints the final one once.TRYLLE_CLI_CI_LOG_POLL_INTERVAL_MS(default 1000ms), which is also what makes the new tests fast.Risk areas
CiLogCursor::deltare-emits the entire body on any non-prefix change (src/trylle/mod.rs:2118). TheSome(_) | Nonearm fires whenever the new body is neither a superset-prefix nor a stale prefix of the previous one — e.g. a log tail rewritten in place (\rprogress bars, ANSI re-render) or a server-side reformat. In that case the whole current body is reprinted, duplicating bytes already streamed, which is exactly the behavior--followis meant to avoid. Normal append-only logs are prefix-stable so this won't trigger for them, but it's the one path where the dedup contract breaks. Worth a comment or a test covering a divergent snapshot.follow_ci_logs(poll-until-done, print once) has no test. It's the branch most likely to regress silently since it produces no incremental output.follow_ci_logsloops untildone == true; a payload that never setsdone(or omits it) polls forever with no cap or backoff. Acceptable for an interactive--follow, but there's no ceiling if the API stalls.ci_log_componentssorts action logs by timestamp but always emits all action logs, thenstdout, thenstderr. Interleaving between an action log and process stdout is lost even when timestamps would interleave them. Matches the PR's stated intent; flagging so it's a conscious choice.Suggested follow-ups
CiCommand::Watch(src/trylle/mod.rs:2067) throughfollow_ci_logs: its help says "Watch a CI run until it completes," but it remains a single one-shot fetch (unchanged by this PR). The polling helper now exists to make it actually watch.The two unrelated base-test failures called out in the PR body (
pr_view_human_output_renders_markdown_body_after_checks,npm_check_json_reports_the_scoped_installation) aren't touched by this diff and match a pre-existing version-string drift onmaster.