Files
pipelines/app/lib/features/runs/ui/run_detail_visit.dart
T
alan fe24f228fe fix(app): one relative-time style, day-aware durations, consistent visit wording
Review r2 findings P2-4, P2-5, P3-13: a shared relative-time helper for
every list row's time, formatDuration switches to days past 24h ('9d
16h'), the stage page uses one visit numbering, drops a repeated stage
heading and fixes '1 files', and search run hits read 'Run 1'.
Implemented by pipeline run #205/#207 (Terra); its UIReview blocked on a
fixture without timestamps, verified by the manager.
2026-10-31 12:29:16 +00:00

104 lines
3.3 KiB
Dart

import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import 'run_detail_content.dart';
import 'run_detail_visit_facts_view.dart';
import 'run_detail_visit_sections.dart';
/// The selected recorded visit's page body: its sections under floating
/// tabs. The page's bar carries the stage and its coordinates
/// ([runVisitSubtitle]); the Summary section leads with the visit's facts.
class RunVisitPane extends StatefulWidget {
const RunVisitPane({
super.key,
required this.run,
required this.visit,
required this.visitIndex,
required this.step,
required this.runSteps,
required this.gateway,
required this.onRunChanged,
required this.configuredEndpoint,
required this.cupertino,
required this.onClose,
});
final JsonMap run;
final DetailVisit visit;
/// The visit's index in [runSteps], so the artifacts section can open exactly
/// this visit's gallery group.
final int visitIndex;
final JsonMap step;
final List<JsonMap> runSteps;
/// The app's shared gateway and the accepted-detail fold for the session's
/// export-only repair. The visit never opens its own socket.
final ApiGateway gateway;
final ValueChanged<JsonMap> onRunChanged;
final String configuredEndpoint;
final bool cupertino;
final VoidCallback onClose;
@override
State<RunVisitPane> createState() => _RunVisitPaneState();
}
class _RunVisitPaneState extends State<RunVisitPane> {
RunVisitSection _section = RunVisitSection.summary;
@override
void didUpdateWidget(covariant RunVisitPane oldWidget) {
super.didUpdateWidget(oldWidget);
// A different visit starts at its first section, like a newly opened pane.
if (oldWidget.visit.sequence != widget.visit.sequence ||
oldWidget.visit.stage != widget.visit.stage) {
_section = RunVisitSection.summary;
}
}
@override
Widget build(BuildContext context) {
// The section fills the page and scrolls behind the page's top bar (which
// names the stage and its visit) and the floating tabs, padding its
// content clear of both at rest. Summary leads with the visit's facts.
return KeyedSubtree(
key: const Key('run-visit-pane'),
child: FloatingBarOverlay(
bar: RunVisitSectionStrip(
selected: _section,
onSelected: (section) => setState(() => _section = section),
),
child: runVisitSectionBody(
section: _section,
run: widget.run,
step: widget.step,
visitIndex: widget.visitIndex,
stageKey: widget.visit.stage,
runSteps: widget.runSteps,
gateway: widget.gateway,
onRunChanged: widget.onRunChanged,
configuredEndpoint: widget.configuredEndpoint,
cupertino: widget.cupertino,
facts: RunVisitFactsView(step: widget.step),
),
),
);
}
}
/// The page bar's subtitle for a recorded visit: its per-stage visit, then the run
/// it belongs to (`Visit 2 · Run 7 · Nightly report`).
String runVisitSubtitle(JsonMap run, DetailVisit visit) {
final runId = '${run['id'] ?? ''}'.trim();
final title = detailTitle(run);
return [
'Visit ${visit.visit}',
if (runId.isNotEmpty) 'Run $runId',
if (title.isNotEmpty && title != 'Run $runId') title,
].join(' · ');
}