feat(app): wire native cancel and track complete port acceptance
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../actions/cancel_run_action.dart';
|
||||
import '../actions/title_action.dart';
|
||||
|
||||
/// Native actions on the loaded run, all using the app's one gateway and
|
||||
/// applying only accepted server detail through the same controller callback.
|
||||
class RunDetailActions extends StatelessWidget {
|
||||
const RunDetailActions({
|
||||
super.key,
|
||||
required this.run,
|
||||
required this.gateway,
|
||||
required this.onRunChanged,
|
||||
});
|
||||
|
||||
final JsonMap run;
|
||||
final ApiGateway gateway;
|
||||
final ValueChanged<JsonMap> onRunChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Wrap(
|
||||
children: [
|
||||
RunTitleAction(run: run, gateway: gateway, onRunChanged: onRunChanged),
|
||||
CancelRunAction(run: run, gateway: gateway, onRunChanged: onRunChanged),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import 'run_detail_content.dart';
|
||||
Widget buildCupertinoRunDetail({
|
||||
required BuildContext context,
|
||||
required JsonMap run,
|
||||
required Widget titleAction,
|
||||
required Widget headerActions,
|
||||
required bool detailLoading,
|
||||
required String? error,
|
||||
required bool copying,
|
||||
@@ -65,7 +65,7 @@ Widget buildCupertinoRunDetail({
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: titleAction,
|
||||
child: headerActions,
|
||||
),
|
||||
),
|
||||
if (detailLoading) const _CupertinoNotice('Refreshing run details…'),
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'run_detail_content.dart';
|
||||
Widget buildMaterialRunDetail({
|
||||
required BuildContext context,
|
||||
required JsonMap run,
|
||||
required Widget titleAction,
|
||||
required Widget headerActions,
|
||||
required bool detailLoading,
|
||||
required String? error,
|
||||
required bool copying,
|
||||
@@ -42,7 +42,7 @@ Widget buildMaterialRunDetail({
|
||||
Chip(label: Text(runStatusLabel(run))),
|
||||
Text('Run ${run['id']}'),
|
||||
Text('Pipeline ${detailPipeline(run)}'),
|
||||
titleAction,
|
||||
headerActions,
|
||||
],
|
||||
),
|
||||
if (detailLoading) const _Notice('Refreshing run details…'),
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../actions/title_action.dart';
|
||||
import 'run_detail_actions.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import 'run_detail_cupertino.dart';
|
||||
import 'run_detail_material.dart';
|
||||
@@ -40,7 +40,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
final run = widget.controller.detail;
|
||||
if (run == null) return _placeholder(context, cupertino: cupertino);
|
||||
final prompt = detailPrompt(run);
|
||||
final titleAction = RunTitleAction(
|
||||
final headerActions = RunDetailActions(
|
||||
run: run,
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.controller.acceptRunDetail,
|
||||
@@ -49,7 +49,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
? buildCupertinoRunDetail(
|
||||
context: context,
|
||||
run: run,
|
||||
titleAction: titleAction,
|
||||
headerActions: headerActions,
|
||||
detailLoading: widget.controller.detailLoading,
|
||||
error: widget.controller.error,
|
||||
copying: _copying,
|
||||
@@ -60,7 +60,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
: buildMaterialRunDetail(
|
||||
context: context,
|
||||
run: run,
|
||||
titleAction: titleAction,
|
||||
headerActions: headerActions,
|
||||
detailLoading: widget.controller.detailLoading,
|
||||
error: widget.controller.error,
|
||||
copying: _copying,
|
||||
|
||||
@@ -114,12 +114,32 @@ class RunsController extends ChangeNotifier {
|
||||
if (id == null) return;
|
||||
var changed = false;
|
||||
if (detail?['id'] == id) {
|
||||
++_detailGeneration;
|
||||
_cancelDetailRefresh();
|
||||
detail = run;
|
||||
detailLoading = false;
|
||||
error = null;
|
||||
changed = true;
|
||||
}
|
||||
final index = runs.indexWhere((row) => row['id'] == id);
|
||||
if (index >= 0) {
|
||||
runs = [...runs]..[index] = {...runs[index], 'title': run['title'] ?? ''};
|
||||
// A cancel/decision reply changes lifecycle fields as well as title.
|
||||
// Keep sparse/unknown summary fields, without copying bulky detail-only
|
||||
// payloads into the held list or inventing missing values.
|
||||
const detailOnly = {
|
||||
'steps',
|
||||
'input',
|
||||
'output',
|
||||
'graph',
|
||||
'usage',
|
||||
'notifications',
|
||||
};
|
||||
runs = [...runs]
|
||||
..[index] = {
|
||||
...runs[index],
|
||||
for (final entry in run.entries)
|
||||
if (!detailOnly.contains(entry.key)) entry.key: entry.value,
|
||||
};
|
||||
changed = true;
|
||||
}
|
||||
if (changed) notifyListeners();
|
||||
|
||||
Reference in New Issue
Block a user