feat(app): the Changes tab lists the run's final changes, without a filter field

This commit is contained in:
2026-10-23 17:25:25 +01:00
parent cd86792094
commit 0c1e399e17
7 changed files with 138 additions and 253 deletions
@@ -95,7 +95,7 @@ class StageCaptureSection extends StatelessWidget {
)
else
for (final file in filtered)
_FileRow(
ChangeFileRow(
key: ValueKey('change-${stage.sequence}-${file.path}'),
file: file,
onOpen: onOpen,
@@ -105,8 +105,9 @@ class StageCaptureSection extends StatelessWidget {
}
}
class _FileRow extends StatelessWidget {
const _FileRow({super.key, required this.file, required this.onOpen});
/// One changed file: its kind, path and line counts; tapping opens its diff.
class ChangeFileRow extends StatelessWidget {
const ChangeFileRow({super.key, required this.file, required this.onOpen});
final FileChange file;
final ValueChanged<FileChange> onOpen;
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
@@ -7,7 +6,6 @@ import '../domain/change_wording.dart';
import '../domain/file_change.dart';
import '../domain/run_changes.dart';
import 'capture_section.dart';
import 'change_style.dart';
import 'file_diff_viewer.dart';
import 'visit_pager.dart';
@@ -28,6 +26,7 @@ class ChangesViewer extends StatefulWidget {
super.key,
required this.steps,
this.showSummary = true,
this.finalOnly = false,
});
/// The run detail's steps exactly as the server returned them. Each step's
@@ -43,12 +42,15 @@ class ChangesViewer extends StatefulWidget {
/// sections stay the evidence for a run without a settled final state.
final bool showSummary;
/// The run's final changes only: the summary and every changed path once,
/// as the last recorded visit left it, with no visit pages.
final bool finalOnly;
@override
State<ChangesViewer> createState() => _ChangesViewerState();
}
class _ChangesViewerState extends State<ChangesViewer> {
final _filter = TextEditingController();
late List<StageCapture> _captures;
late RunChanges _run;
@@ -88,13 +90,8 @@ class _ChangesViewerState extends State<ChangesViewer> {
setState(() => _visitIndex = next);
}
@override
void dispose() {
_filter.dispose();
super.dispose();
}
String get _query => _filter.text;
/// No filter field: the visit lists every file its capture recorded.
static const _query = '';
@override
Widget build(BuildContext context) {
@@ -131,55 +128,79 @@ class _ChangesViewerState extends State<ChangesViewer> {
Padding(
padding: const EdgeInsets.only(top: 8),
child: Text(
'The summary counts each path once, as the last recorded '
'visit left it. Each stage/visit page below lists what '
'its own capture recorded.',
widget.finalOnly
? 'Each path once, as the last recorded visit left '
'it. A stage\'s own changes are in its timeline '
'detail.'
: 'The summary counts each path once, as the last '
'recorded visit left it. Each stage/visit page '
'below lists what its own capture recorded.',
style: Theme.of(context).textTheme.bodySmall,
),
),
],
),
),
if (showSummary && hasFiles)
Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
child: _filterField(context, run),
),
if (showSummary) const Divider(height: 1),
Expanded(
child: visit == null
? SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Text(noChangeDetail(run)),
)
: SingleChildScrollView(
// Keying the body by visit keeps each page's pager and heading
// at the top instead of inheriting the previous scroll offset.
key: ValueKey<String>(
'changes-visit-${visit.stage}-${visit.sequence}',
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
// The run's final changes: every changed path once, as it ended.
if (widget.finalOnly)
Expanded(
child: run.files.isEmpty
? SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Text(noChangeDetail(run)),
)
: ListView(
key: const ValueKey<String>('changes-final'),
children: [
StageCaptureSection(
stage: visit,
query: _query,
// The page steps through the files this visit shows.
onOpen: (file) => showFileDiffViewer(
context,
file,
files: filterFileChanges(
visit.capture?.files ?? const <FileChange>[],
_query,
for (final file in run.files)
ChangeFileRow(
key: ValueKey<String>('change-final-${file.path}'),
file: file,
onOpen: (file) => showFileDiffViewer(
context,
file,
files: run.files,
),
),
),
],
),
),
),
),
if (!widget.finalOnly)
Expanded(
child: visit == null
? SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Text(noChangeDetail(run)),
)
: SingleChildScrollView(
// Keying the body by visit keeps each page's pager and heading
// at the top instead of inheriting the previous scroll offset.
key: ValueKey<String>(
'changes-visit-${visit.stage}-${visit.sequence}',
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
StageCaptureSection(
stage: visit,
query: _query,
// The page steps through the files this visit shows.
onOpen: (file) => showFileDiffViewer(
context,
file,
files: filterFileChanges(
visit.capture?.files ?? const <FileChange>[],
_query,
),
),
),
],
),
),
),
// Previous/next visit sit at the bottom right, under the visit.
if (visit != null)
if (!widget.finalOnly && visit != null)
ChangesVisitPager(
index: _visitIndex,
count: captures.length,
@@ -189,53 +210,4 @@ class _ChangesViewerState extends State<ChangesViewer> {
],
);
}
Widget _filterField(BuildContext context, RunChanges run) {
final query = _query;
final matched = query.trim().isEmpty
? run.files.length
: filterFileChanges(run.files, query).length;
// The summary counts paths while the sections below list one row per stage
// visit, so the counter names what it actually counts.
final counter = query.trim().isEmpty
? ''
: '$matched of ${run.files.length} changed '
'${run.files.length == 1 ? 'path' : 'paths'} match';
final field = usesCupertino(context)
? CupertinoSearchTextField(
controller: _filter,
placeholder: 'Filter changed files',
onChanged: (_) => setState(() {}),
)
: TextField(
controller: _filter,
decoration: InputDecoration(
labelText: 'Filter changed files',
hintText: 'Filename contains…',
prefixIcon: const Icon(Icons.search),
suffixIcon: query.isEmpty
? null
: IconButton(
tooltip: 'Clear filter',
onPressed: () {
_filter.clear();
setState(() {});
},
icon: const Icon(Icons.clear),
),
),
onChanged: (_) => setState(() {}),
);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
field,
if (counter.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(counter, style: Theme.of(context).textTheme.bodySmall),
),
],
);
}
}