265 lines
7.2 KiB
Dart
265 lines
7.2 KiB
Dart
// Standalone fixture entry for real-browser Changes evidence.
|
|
//
|
|
// Build and probe (from app/):
|
|
// flutter build web --target tool/changes_probe_entry.dart --output build/probe-web
|
|
// node tool/changes_probe.mjs --root build/probe-web --out DIR
|
|
//
|
|
// These are server-shaped fixtures for rendering only. They are not a live run
|
|
// and never mutate a server.
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:pipelines_app/core/api_gateway.dart';
|
|
import 'package:pipelines_app/features/changes/changes.dart';
|
|
|
|
const _multiHunkPatch =
|
|
'--- "a/lib/features/changes/domain/unified_patch.dart"\n'
|
|
'+++ "b/lib/features/changes/domain/unified_patch.dart"\n'
|
|
'@@ -12,6 +12,7 @@\n'
|
|
' class ParsedPatch {\n'
|
|
' const ParsedPatch({\n'
|
|
' required this.raw,\n'
|
|
'+ required this.headerLines,\n'
|
|
' required this.hunks,\n'
|
|
' });\n'
|
|
' \n'
|
|
'@@ -48,5 +49,5 @@\n'
|
|
'-PatchHunk? _parseHunkHeader(String line) {\n'
|
|
'+_HunkStart? _parseHunkHeader(String line) {\n'
|
|
" if (!line.startsWith('@@')) return null;\n"
|
|
" final end = line.indexOf('@@', 2);\n"
|
|
' if (end < 0) return null;\n'
|
|
' final ranges = _tokenizeRanges(line.substring(2, end));\n';
|
|
|
|
const _addedPatch =
|
|
'--- "/dev/null"\n'
|
|
'+++ "b/lib/features/changes/widgets/file_diff_viewer.dart"\n'
|
|
'@@ -0,0 +1,5 @@\n'
|
|
'+class FileDiffViewer extends StatefulWidget {\n'
|
|
'+ const FileDiffViewer({super.key, required this.file});\n'
|
|
'+\n'
|
|
'+ final FileChange file;\n'
|
|
'+}\n';
|
|
|
|
const _deletedPatch =
|
|
'--- "a/docs/legacy-notes.md"\n'
|
|
'+++ "/dev/null"\n'
|
|
'@@ -1,2 +0,0 @@\n'
|
|
'-# Legacy notes\n'
|
|
'-Removed with the viewer.\n';
|
|
|
|
const _truncatedPatch =
|
|
'--- "a/logs/capture.log"\n'
|
|
'+++ "b/logs/capture.log"\n'
|
|
'@@ -1,2 +1,3 @@\n'
|
|
'-capture started\n'
|
|
'+capture started\n'
|
|
'+and truncated mid-line';
|
|
|
|
List<JsonMap> probeSteps() => [
|
|
{
|
|
'sequence': 1,
|
|
'stage': 'implementer',
|
|
'status': 'completed',
|
|
'file_changes': {
|
|
'status': 'partial',
|
|
'scope': 'Git tracked and nonignored files in the run directory',
|
|
'skipped': 2,
|
|
'omitted': 0,
|
|
'diagnostic':
|
|
'Excluded protected, symlinked, oversized or unreadable files; this '
|
|
'is not a complete workspace diff.',
|
|
'files': [
|
|
{
|
|
'path': 'lib/features/changes/domain/unified_patch.dart',
|
|
'kind': 'modified',
|
|
'patch': _multiHunkPatch,
|
|
'before_mode': '0644',
|
|
'after_mode': '0644',
|
|
},
|
|
{
|
|
'path': 'assets/pipelines-mark.png',
|
|
'kind': 'modified',
|
|
'binary': true,
|
|
},
|
|
{
|
|
'path': 'scripts/capture.sh',
|
|
'kind': 'modified',
|
|
'before_mode': '0644',
|
|
'after_mode': '0755',
|
|
},
|
|
{
|
|
'path': 'docs/legacy-notes.md',
|
|
'kind': 'deleted',
|
|
'patch': _deletedPatch,
|
|
'before_mode': '0644',
|
|
},
|
|
{
|
|
'path': 'logs/capture.log',
|
|
'kind': 'modified',
|
|
'patch': _truncatedPatch,
|
|
'truncated': true,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
'sequence': 2,
|
|
'stage': 'reviewer',
|
|
'status': 'completed',
|
|
'file_changes': {
|
|
'status': 'complete',
|
|
'scope': 'Git tracked and nonignored files in the run directory',
|
|
'skipped': 0,
|
|
'omitted': 0,
|
|
'diagnostic': '',
|
|
'files': [
|
|
{
|
|
'path': 'lib/features/changes/widgets/file_diff_viewer.dart',
|
|
'kind': 'added',
|
|
'patch': _addedPatch,
|
|
'after_mode': '0644',
|
|
},
|
|
{
|
|
'path': 'lib/features/changes/domain/unified_patch.dart',
|
|
'kind': 'modified',
|
|
'patch': _multiHunkPatch,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
'sequence': 3,
|
|
'stage': 'ui_reviewer',
|
|
'status': 'completed',
|
|
'file_changes': null,
|
|
},
|
|
{
|
|
'sequence': 4,
|
|
'stage': 'committer',
|
|
'status': 'completed',
|
|
'file_changes': {
|
|
'status': 'unavailable',
|
|
'skipped': 0,
|
|
'omitted': 0,
|
|
'diagnostic':
|
|
'Workspace snapshot unavailable; changes could not be compared.',
|
|
'files': <JsonMap>[],
|
|
},
|
|
},
|
|
{
|
|
'sequence': 5,
|
|
'stage': 'verifier',
|
|
'status': 'completed',
|
|
'file_changes': {
|
|
'status': 'complete',
|
|
'scope': 'Git tracked and nonignored files in the run directory',
|
|
'skipped': 0,
|
|
'omitted': 0,
|
|
'diagnostic': '',
|
|
'files': <JsonMap>[],
|
|
},
|
|
},
|
|
];
|
|
|
|
/// A compact fixture whose only purpose is visit numbering: the same stages
|
|
/// appear more than once, one visit records an explicit `control.visit`, and
|
|
/// every capture is empty so the sections stay on one phone screen.
|
|
List<JsonMap> probeVisitSteps() => [
|
|
{
|
|
'sequence': 1,
|
|
'stage': 'implementer',
|
|
'status': 'completed',
|
|
'file_changes': {
|
|
'status': 'complete',
|
|
'scope': 'Git tracked and nonignored files in the run directory',
|
|
'files': <JsonMap>[],
|
|
},
|
|
},
|
|
{
|
|
'sequence': 2,
|
|
'stage': 'reviewer',
|
|
'status': 'completed',
|
|
'file_changes': {
|
|
'status': 'complete',
|
|
'scope': 'Git tracked and nonignored files in the run directory',
|
|
'files': <JsonMap>[],
|
|
},
|
|
},
|
|
{
|
|
'sequence': 3,
|
|
'stage': 'implementer',
|
|
'status': 'completed',
|
|
'file_changes': {
|
|
'status': 'complete',
|
|
'scope': 'Git tracked and nonignored files in the run directory',
|
|
'files': <JsonMap>[],
|
|
},
|
|
},
|
|
{
|
|
'sequence': 4,
|
|
'stage': 'reviewer',
|
|
'status': 'completed',
|
|
'control': {'visit': 6},
|
|
'file_changes': {
|
|
'status': 'complete',
|
|
'scope': 'Git tracked and nonignored files in the run directory',
|
|
'files': <JsonMap>[],
|
|
},
|
|
},
|
|
];
|
|
|
|
void main() {
|
|
final params = Uri.base.queryParameters;
|
|
final cupertino = params['platform'] == 'cupertino';
|
|
final brightness = params['theme'] == 'light'
|
|
? Brightness.light
|
|
: Brightness.dark;
|
|
final steps = params['visits'] == '1' ? probeVisitSteps() : probeSteps();
|
|
if (cupertino) {
|
|
runApp(
|
|
CupertinoApp(
|
|
title: 'Changes probe',
|
|
theme: CupertinoThemeData(brightness: brightness),
|
|
home: _ProbeHome(cupertino: true, steps: steps),
|
|
),
|
|
);
|
|
} else {
|
|
runApp(
|
|
MaterialApp(
|
|
title: 'Changes probe',
|
|
theme: ThemeData(
|
|
brightness: brightness,
|
|
// Chrome on macOS reports a macOS default platform; the fixture
|
|
// states Material explicitly so both control sets are capturable.
|
|
platform: TargetPlatform.android,
|
|
),
|
|
home: _ProbeHome(cupertino: false, steps: steps),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ProbeHome extends StatelessWidget {
|
|
const _ProbeHome({required this.cupertino, required this.steps});
|
|
|
|
final bool cupertino;
|
|
final List<JsonMap> steps;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final viewer = ChangesViewer(steps: steps);
|
|
if (cupertino) {
|
|
return CupertinoPageScaffold(
|
|
navigationBar: const CupertinoNavigationBar(
|
|
middle: Text('Changes probe'),
|
|
),
|
|
child: SafeArea(child: viewer),
|
|
);
|
|
}
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Changes probe')),
|
|
body: viewer,
|
|
);
|
|
}
|
|
}
|