fix(app): expose exact visit turn documents in Session
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../artifacts/domain/artifact_capture.dart';
|
||||
import '../../artifacts/domain/artifact_document.dart';
|
||||
import '../../artifacts/domain/artifact_groups.dart';
|
||||
import '../../artifacts/domain/artifact_record.dart';
|
||||
import '../../artifacts/domain/gallery_navigation.dart';
|
||||
import '../../artifacts/ui/artifact_document_section.dart';
|
||||
import '../../artifacts/ui/artifact_viewer_page.dart';
|
||||
import '../../graph/domain/stage_visits.dart';
|
||||
import 'run_detail_visit_recorded.dart';
|
||||
|
||||
/// Raw turn documents, never the Summary's interpreted step input/output maps.
|
||||
/// Only this step's inventory enters the viewer or its Previous/Next controls.
|
||||
/// The session export remains with the session metadata and repair controls.
|
||||
class RunVisitDocuments extends StatelessWidget {
|
||||
const RunVisitDocuments({
|
||||
super.key,
|
||||
required this.step,
|
||||
required this.run,
|
||||
required this.configuredEndpoint,
|
||||
});
|
||||
|
||||
final JsonMap step;
|
||||
final JsonMap run;
|
||||
final String configuredEndpoint;
|
||||
|
||||
int _visitNumber() {
|
||||
final steps = run['steps'];
|
||||
final stage = '${step['stage'] ?? ''}';
|
||||
final visits =
|
||||
visitsByStage(
|
||||
steps is List ? steps.cast<JsonMap>() : <JsonMap>[step],
|
||||
)[stage] ??
|
||||
<JsonMap>[];
|
||||
final position = visits.indexWhere(
|
||||
(candidate) =>
|
||||
identical(candidate, step) ||
|
||||
candidate['sequence'] == step['sequence'],
|
||||
);
|
||||
return displayVisit(step, position < 0 ? 0 : position);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final capture = ArtifactCapture.fromStep(step);
|
||||
if (!capture.isAvailable) {
|
||||
return const Text('Turn documents · capture unavailable');
|
||||
}
|
||||
final recorded = visitDocuments(step);
|
||||
// Unlike the gallery, Session must explain even an entirely empty capture.
|
||||
final documents = recorded.isEmpty
|
||||
? const [
|
||||
ArtifactDocument(
|
||||
name: 'input.md',
|
||||
record: null,
|
||||
absence: noInputDocument,
|
||||
),
|
||||
ArtifactDocument(
|
||||
name: 'output.md',
|
||||
record: null,
|
||||
absence: noOutputDocument,
|
||||
),
|
||||
ArtifactDocument(
|
||||
name: 'memory.md',
|
||||
record: null,
|
||||
absence: noMemoryDocument,
|
||||
),
|
||||
]
|
||||
: recorded.where((doc) => !doc.externalOnly).toList(growable: false);
|
||||
final group = ArtifactGroup(
|
||||
stageKey: recordedText(step['stage']) ?? '',
|
||||
visit: _visitNumber(),
|
||||
artifacts: const [],
|
||||
documents: documents,
|
||||
);
|
||||
void select(ArtifactGroup group, ArtifactRecord artifact) {
|
||||
final page = ArtifactViewerPage(
|
||||
groups: [group],
|
||||
selectedIdentity: artifactVisitIdentityOf(group, artifact),
|
||||
configuredEndpoint: configuredEndpoint,
|
||||
);
|
||||
Navigator.of(context).push<void>(
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoPageRoute<void>(builder: (_) => page)
|
||||
: MaterialPageRoute<void>(builder: (_) => page),
|
||||
);
|
||||
}
|
||||
|
||||
return ArtifactDocumentSection(group: group, onSelected: select);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import '../../artifacts/domain/artifact_url.dart';
|
||||
import '../../artifacts/ui/artifact_external_open.dart';
|
||||
import '../actions/session_export_repair_action.dart';
|
||||
import 'run_detail_visit_recorded.dart';
|
||||
import 'run_detail_visit_documents.dart';
|
||||
import 'run_detail_visit_session_state.dart';
|
||||
|
||||
/// The visit's recorded session pointer, its recorded export state and, when
|
||||
@@ -105,6 +106,11 @@ class _RunVisitSessionState extends State<RunVisitSession> {
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Semantics(liveRegion: true, child: Text(_status!)),
|
||||
),
|
||||
RunVisitDocuments(
|
||||
step: widget.step,
|
||||
run: widget.run,
|
||||
configuredEndpoint: widget.configuredEndpoint,
|
||||
),
|
||||
];
|
||||
if (usesCupertinoHost(context)) {
|
||||
return ListView(
|
||||
|
||||
Reference in New Issue
Block a user