Files
Vetting/internal/web/templates/active_step.templ
T
josh 17ec55cb85
CI / Lint + build + test (push) Successful in 1m34s
Release / detect (push) Successful in 4s
Release / build-live-image (push) Has been skipped
Release / bundle (push) Successful in 1m5s
chore: cleanup sprint — dead CSS, dedup helpers, handler refactor
Remove ~126 lines of orphaned CSS from tile slim-down and old detail
layout. Consolidate 4 duplicate duration formatters into shared
elapsed()/fmtElapsed() helpers. Break 160-line Result handler into
focused sub-functions. Implement real Hub.Shutdown() (was a no-op).
Standardize agent error responses to JSON. Replace panic() in router
init with error return. Extract magic numbers as named constants.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-21 20:39:38 -04:00

75 lines
2.3 KiB
Plaintext

package templates
import (
"fmt"
"vetting/internal/model"
)
// ActiveStepData is the per-stage payload for the expanded step panel.
// The handler builds one per stage in DefaultStageOrder and hands it to
// ActiveStep so the template stays free of any slicing logic.
type ActiveStepData struct {
RunID int64
Stage model.Stage
SubSteps []model.SubStep
LogReplay string
Open bool
}
// ActiveStep renders one stage's expanded panel: the header summary
// (state badge, stage name, duration), any sub-step rows, a per-step
// search box, and a live log pane scoped to that stage's SSE topic.
// Uses <details open?={ d.Open }> so the server-picked default stage
// opens automatically on page load; app.js takes over after that for
// SSE-driven auto-advance.
templ ActiveStep(d ActiveStepData) {
<details class={ "step", "step-" + string(d.Stage.State) } open?={ d.Open } data-stage={ d.Stage.Name }>
<summary class="step-summary">
<span class={ "stage-dot", "stage-dot-" + string(d.Stage.State) }>{ stageMarker(string(d.Stage.State)) }</span>
<span class="step-name">{ d.Stage.Name }</span>
<span class="step-duration">{ stageDurationFromStage(d.Stage) }</span>
</summary>
<div class="step-body">
if len(d.SubSteps) > 0 {
<ol class="substep-list">
for _, ss := range d.SubSteps {
@SubStepRow(ss)
}
</ol>
}
<div class="log-search-wrap">
<input class="log-search" type="search" placeholder="Search this step" data-step={ d.Stage.Name }/>
</div>
<div
class="log-pane"
id={ fmt.Sprintf("log-%d-%s", d.RunID, d.Stage.Name) }
sse-swap={ fmt.Sprintf("log-%d-%s", d.RunID, d.Stage.Name) }
hx-swap="beforeend show:bottom"
>
@templ.Raw(d.LogReplay)
</div>
</div>
</details>
}
// SubStepsForStage filters a flat []SubStep to just the entries for one
// stage. Used by host_detail when wiring ActiveStepData — keeps the
// filtering logic testable and off the template surface.
func SubStepsForStage(all []model.SubStep, stageName string) []model.SubStep {
out := make([]model.SubStep, 0, len(all))
for _, ss := range all {
if ss.StageName == stageName {
out = append(out, ss)
}
}
return out
}
func stageDurationFromStage(s model.Stage) string {
if d := elapsed(s.StartedAt, s.CompletedAt); d >= 0 {
return fmtElapsed(d, false)
}
return ""
}