Redirect bare /repo to /repo/ci and inline sh-event meta
Bare /<repo> now 307s to /<repo>/ci so clicking the repo crumb lands
somewhere useful. Drops the sh-N index prefix and folds duration/exit
into a meta span next to the command line, so each sh event leads
with what it ran.
change wumntxmotmywqqyspqkvxmpynvzqlorp
commit 37672cf9c5d7e3ade989049726bd8040058ce3a8
author Alpha Chen <alpha@kejadlen.dev>
date
parent zxrppkop
diff --git a/src/quire/web/handlers.rs b/src/quire/web/handlers.rs
index 59051b3..a83bd1e 100644
--- a/src/quire/web/handlers.rs
+++ b/src/quire/web/handlers.rs
@@ -3,13 +3,17 @@
 use askama::Template;
 use axum::extract::{Path as AxumPath, State};
 use axum::http::StatusCode;
-use axum::response::{Html, IntoResponse, Response};
+use axum::response::{Html, IntoResponse, Redirect, Response};
 
 use super::db;
 use super::templates::*;
 use crate::Quire;
 use crate::error::display_chain;
 
+pub async fn repo_redirect(AxumPath(repo): AxumPath<String>) -> Redirect {
+    Redirect::temporary(&format!("/{}/ci", repo.trim_end_matches(".git")))
+}
+
 /// Render a template into an HTML response, returning 500 on render failure.
 fn render<T: Template>(tmpl: &T) -> Response {
     match tmpl.render() {
@@ -156,7 +160,6 @@ pub async fn run_detail(
                 None => String::new(),
             };
             detail_sh_events.push(DetailShEvent {
-                index: sh_n,
                 started_at_ms: ev.started_at_ms,
                 finished_at_ms: ev.finished_at_ms,
                 exit_code: ev.exit_code,
diff --git a/src/quire/web/mod.rs b/src/quire/web/mod.rs
index 4c142a2..46f147c 100644
--- a/src/quire/web/mod.rs
+++ b/src/quire/web/mod.rs
@@ -20,6 +20,7 @@ use crate::Quire;
 /// `.layer(middleware::from_fn(auth::require_auth))`).
 pub fn router(quire: Quire) -> axum::Router {
     axum::Router::new()
+        .route("/{repo}", axum::routing::get(handlers::repo_redirect))
         .route("/{repo}/ci", axum::routing::get(handlers::run_list))
         .route(
             "/{repo}/ci/{run_id}",
diff --git a/src/quire/web/templates.rs b/src/quire/web/templates.rs
index 4c1fe75..e0c7378 100644
--- a/src/quire/web/templates.rs
+++ b/src/quire/web/templates.rs
@@ -183,7 +183,6 @@ impl DetailJob {
 }
 
 pub struct DetailShEvent {
-    pub index: usize,
     pub started_at_ms: i64,
     pub finished_at_ms: i64,
     pub exit_code: i32,
diff --git a/templates/ci/run_detail.html b/templates/ci/run_detail.html
index 70285ed..19aee8b 100644
--- a/templates/ci/run_detail.html
+++ b/templates/ci/run_detail.html
@@ -29,10 +29,9 @@
   </div>
   {% for sh in job.sh_events %}
   <div class="ci-sh">
-    <div class="ci-sh-meta">
-      sh-{{ sh.index }} · {{ sh.duration_display() }} · exit {{ sh.exit_code }}
+    <div class="ci-sh-cmd">
+      {{ sh.cmd_display() }} <span class="ci-sh-meta">{{ sh.duration_display() }}{% if sh.exit_code != 0 %} · exit {{ sh.exit_code }}{% endif %}</span>
     </div>
-    <div class="ci-sh-cmd">{{ sh.cmd_display() }}</div>
     {% if !sh.log_content.is_empty() %}
     <pre class="ci-sh-log">{{ sh.log_content }}</pre>
     {% endif %}