3ee5d0e407
Split the export model/classification from the session wording, add the no-session, selected-repair and missing-evidence coverage, and update the parity matrix and R4 note. The visit probe now passes the scheme name its fixture reads, asserts the painted theme before capture and re-captures the export states.
197 lines
6.3 KiB
Dart
197 lines
6.3 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../../ui/adaptive/host.dart';
|
|
import '../../artifacts/domain/artifact_record.dart';
|
|
import '../../artifacts/domain/artifact_url.dart';
|
|
import '../../artifacts/ui/artifact_external_open.dart';
|
|
import 'run_detail_visit_session_state.dart';
|
|
|
|
/// The visit's recorded session pointer, its recorded export state and, when
|
|
/// the visit exported one, a read-only external open of that document.
|
|
///
|
|
/// The state comes from [detailVisitSession], so a legacy `session.html`, a
|
|
/// repair, a still-running session and a failed one each report what the server
|
|
/// recorded. Complete, partial, missing, skipped, repair and unrecognised
|
|
/// states each keep the server's own word and diagnostic; recorded repair
|
|
/// attempts and their open-option labels are shown read-only and make no
|
|
/// request. The open goes through the landed safe-link helper: the recorded url
|
|
/// is resolved by [resolveArtifactUrl] and passed to [openArtifactExternally]
|
|
/// without being fetched, rewritten or previewed. A refusal is reported.
|
|
class RunVisitSession extends StatefulWidget {
|
|
const RunVisitSession({
|
|
super.key,
|
|
required this.step,
|
|
required this.configuredEndpoint,
|
|
this.openExternal = openArtifactExternally,
|
|
});
|
|
|
|
final JsonMap step;
|
|
final String configuredEndpoint;
|
|
final ArtifactExternalOpen openExternal;
|
|
|
|
@override
|
|
State<RunVisitSession> createState() => _RunVisitSessionState();
|
|
}
|
|
|
|
class _RunVisitSessionState extends State<RunVisitSession> {
|
|
String? _status;
|
|
|
|
Future<void> _open(ResolvedArtifactUrl resolved) async {
|
|
final opened = await widget.openExternal(resolved.uri);
|
|
if (!mounted) return;
|
|
setState(
|
|
() => _status = opened
|
|
? 'Link opened externally.'
|
|
: 'Could not open the link.',
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final session = detailVisitSession(widget.step);
|
|
final export = session.export;
|
|
final resolved = export == null
|
|
? null
|
|
: resolveArtifactUrl(widget.configuredEndpoint, export.artifact.url);
|
|
final note = export?.statusNote;
|
|
final fact = session.exportFact;
|
|
final showReason =
|
|
export != null &&
|
|
fact?.reason != null &&
|
|
fact!.state != VisitSessionExportState.repair;
|
|
final children = <Widget>[
|
|
if (session.sessionId != null)
|
|
_SessionFact(label: 'Session', value: session.sessionId!),
|
|
if (fact != null)
|
|
_SessionFact(
|
|
key: const Key('run-visit-session-export'),
|
|
label: 'Export',
|
|
value: fact.word,
|
|
),
|
|
if (showReason)
|
|
_SessionFact(
|
|
key: const Key('run-visit-session-export-reason'),
|
|
label: 'Reason',
|
|
value: fact.reason!,
|
|
),
|
|
if (export != null && note != null) Text(note),
|
|
..._repairFacts(session.repairs),
|
|
if (export == null)
|
|
Text(session.message)
|
|
else if (resolved == null)
|
|
const Text(visitSessionEndpointMissing)
|
|
else
|
|
_openButton(export.artifact, resolved),
|
|
if (_status != null)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8),
|
|
child: Semantics(liveRegion: true, child: Text(_status!)),
|
|
),
|
|
];
|
|
if (usesCupertinoHost(context)) {
|
|
return ListView(
|
|
key: const Key('run-visit-body-session'),
|
|
children: [
|
|
CupertinoListSection.insetGrouped(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: _spaced(children),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
return ListView(
|
|
key: const Key('run-visit-body-session'),
|
|
padding: const EdgeInsets.all(16),
|
|
children: _spaced(children),
|
|
);
|
|
}
|
|
|
|
Widget _openButton(ArtifactRecord export, ResolvedArtifactUrl resolved) {
|
|
final label = 'Open ${export.name.isEmpty ? 'session.html' : export.name}';
|
|
if (usesCupertinoHost(context)) {
|
|
return CupertinoButton(
|
|
padding: EdgeInsets.zero,
|
|
onPressed: () => _open(resolved),
|
|
child: Text(label),
|
|
);
|
|
}
|
|
return Align(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
child: TextButton(onPressed: () => _open(resolved), child: Text(label)),
|
|
);
|
|
}
|
|
|
|
/// Recorded repair attempts, in the pane's own fact rows. Nothing here is a
|
|
/// control: the repair request belongs to its own action and is not wired.
|
|
List<Widget> _repairFacts(List<VisitSessionRepair> repairs) {
|
|
final facts = <Widget>[];
|
|
for (var index = 0; index < repairs.length; index += 1) {
|
|
final repair = repairs[index];
|
|
facts.add(
|
|
_SessionFact(
|
|
key: ValueKey('run-visit-session-repair-$index'),
|
|
label: 'Repair',
|
|
value: repair.label,
|
|
),
|
|
);
|
|
final option = repair.option;
|
|
if (option != null) {
|
|
facts.add(
|
|
_SessionFact(
|
|
key: ValueKey('run-visit-session-repair-option-$index'),
|
|
label: 'Repair option',
|
|
value: option,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
return facts;
|
|
}
|
|
|
|
List<Widget> _spaced(List<Widget> children) => [
|
|
for (var index = 0; index < children.length; index += 1) ...[
|
|
if (index > 0) const SizedBox(height: 8),
|
|
children[index],
|
|
],
|
|
];
|
|
}
|
|
|
|
class _SessionFact extends StatelessWidget {
|
|
const _SessionFact({super.key, required this.label, required this.value});
|
|
|
|
final String label;
|
|
final String value;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final cupertino = CupertinoTheme.of(context);
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
label,
|
|
style: usesCupertinoHost(context)
|
|
? cupertino.textTheme.tabLabelTextStyle.copyWith(
|
|
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
|
)
|
|
: (theme.textTheme.labelMedium ?? const TextStyle()).copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
Text(value),
|
|
],
|
|
);
|
|
}
|
|
}
|