feat: offer the raw log while a check is still running
commit
6877ba8feat: offer the raw log while a check is still running
The download link only appeared once a check settled, so anyone watching a long-running check live had no way to grab the log until it finished. check_recording_download now falls back to the live buffer when the settled recording does not exist yet, and the live view links to it while output has arrived.
Assisted-by: Claude:claude-sonnet-5
Reviews
No reviews of this commit yet — record a verdict below.
Start a review
crates/git-ents-server/src/web/mod.rs
@@ -523,7 +523,7 @@
pages::check_live_fragment(repo, commit, name, live_runs).await
}
Some((&"checks", &[commit, name, "download"])) => {
- pages::check_recording_download(repo, commit, name).await
+ pages::check_recording_download(repo, commit, name, live_runs).await
}
Some((&"issues", &[])) => pages::issues_page(repo, &meta, auth.as_ref())
.await
crates/git-ents-server/src/web/pages.rs
@@ -1082,11 +1082,15 @@
let body = if super::render::is_in_progress(outcome.status) {
let key = (repo.to_owned(), commit_oid, name.to_owned());
let fragment_url = format!("/{rel}/checks/{commit}/{name}/live");
- let initial =
- super::render::live_fragment_body(git_effect::engine::live_snapshot(live_runs, &key));
+ let live = git_effect::engine::live_snapshot(live_runs, &key);
+ let initial = super::render::live_fragment_body(live.clone());
+ let download_href = format!("/{rel}/checks/{commit}/{name}/download");
html! {
p.shell-note {
"This check is still " (outcome.status.to_string()) "; the view below updates live."
+ @if live.is_some() {
+ " " a.btn-quiet href=(download_href) download { "Download raw log so far" }
+ }
}
style { (PreEscaped(crate::asciidoc::TERMINAL_VIEW_CSS)) }
div #live-terminal data-live-check=(fragment_url) { (initial) }
@@ -1145,17 +1149,30 @@
}
/// Download a check's raw asciicast recording, for replaying outside the
-/// browser (`asciinema play <file>`) or archiving. 404s under the same
-/// conditions as [`check_recording_page`] (no run recorded, or none for
-/// `name`), and also when the settled run has no recording to hand out.
-pub(super) async fn check_recording_download(repo: &Path, commit: &str, name: &str) -> Response {
+/// browser (`asciinema play <file>`) or archiving. While the check is still
+/// running this hands out the live buffer captured so far instead of the
+/// (not yet existing) settled recording. 404s under the same conditions as
+/// [`check_recording_page`] (no run recorded, or none for `name`), and also
+/// when neither a settled recording nor a live buffer is available.
+pub(super) async fn check_recording_download(
+ repo: &Path,
+ commit: &str,
+ name: &str,
+ live_runs: &git_effect::engine::LiveRegistry,
+) -> Response {
let Some(commit_oid) = ObjectId::from_hex(commit.as_bytes()).ok() else {
return not_found().into_response();
};
- let Some(recording) = latest_outcome(repo, commit_oid, name)
- .await
- .and_then(|outcome| outcome.recording)
- else {
+ let Some(outcome) = latest_outcome(repo, commit_oid, name).await else {
+ return not_found().into_response();
+ };
+ let live = super::render::is_in_progress(outcome.status)
+ .then(|| {
+ let key = (repo.to_owned(), commit_oid, name.to_owned());
+ git_effect::engine::live_snapshot(live_runs, &key)
+ })
+ .flatten();
+ let Some(recording) = live.or(outcome.recording) else {
return not_found().into_response();
};
let short_commit = commit.get(..8).unwrap_or(commit);