// Standalone fixture entry for real-browser run-detail Artifacts evidence. // // Build and probe (from app/): // flutter build web --target tool/artifact_gallery_probe.dart --output build/probe-gallery // node tool/artifact_gallery_probe.mjs --root build/probe-gallery --out DIR // // Server-shaped fixtures only: a fake gateway answers the same get_run envelope // the app consumes. The recorded urls point at the probe's own loopback origin, // so the external Open action has a real target. No server or operator run is // touched. import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/features/artifacts/ui/artifact_gallery_page.dart'; import 'package:pipelines_app/features/runs/data/runs_repository.dart'; import 'package:pipelines_app/features/runs/ui/run_detail_view.dart'; import 'package:pipelines_app/features/runs/ui/runs_controller.dart'; class _FakeGateway implements ApiGateway { _FakeGateway(this.detail); final JsonMap detail; @override Stream get frames => const Stream.empty(); @override Future call(String type, [JsonMap fields = const {}]) { if (type != 'get_run') throw UnsupportedError(type); return Future.value({'run_detail': detail}); } } JsonMap _file( String name, { required String url, required String contentType, required int sizeBytes, }) => { 'name': name, 'url': url, 'content_type': contentType, 'size_bytes': sizeBytes, }; /// The recorded steps for one probe state. `default` carries two visits that /// both record `result.zip` plus a partial capture on the second visit. List _steps(String origin, String state) { if (state == 'unavailable') { return [ { 'stage': 'implementer', 'sequence': 1, 'status': 'completed', 'control': {'visit': 1}, }, ]; } if (state == 'empty') { return [ { 'stage': 'implementer', 'sequence': 1, 'status': 'completed', 'control': {'visit': 1}, 'artifacts': const [], }, ]; } if (state == 'unsafe' || state == 'nourl') { return [ { 'stage': 'reviewer', 'sequence': 1, 'status': 'completed', 'control': {'visit': 1}, 'artifacts': [ _file( 'result.zip', url: state == 'unsafe' ? '//evil.test/result.zip' : '', contentType: 'application/zip', sizeBytes: 2048, ), ], }, ]; } if (state == 'missing') { return [ { 'stage': 'reviewer', 'sequence': 1, 'status': 'completed', 'control': {'visit': 1}, 'artifacts': [ _file( 'missing.png', url: '$origin/fixture/missing.png', contentType: 'image/png', sizeBytes: 128, ), ], }, ]; } if (state == 'external') { return [ { 'stage': 'reviewer', 'sequence': 1, 'status': 'completed', 'control': {'visit': 1}, 'artifacts': [ _file( 'elsewhere.png', url: 'https://elsewhere.test/elsewhere.png', contentType: 'image/png', sizeBytes: 4096, ), ], }, ]; } if (state == 'documents') { return [ { 'stage': 'reviewer', 'sequence': 1, 'status': 'completed', 'control': {'visit': 1}, 'artifacts': [ _file( 'report.zip', url: '$origin/fixture/report.zip', contentType: 'application/zip', sizeBytes: 23, ), _file( 'input.md', url: '$origin/fixture/input.md', contentType: 'text/markdown', sizeBytes: 120, ), _file( 'output.md', url: '$origin/fixture/output.md', contentType: 'text/markdown', sizeBytes: 240, ), // Deliberately sniffed as text/plain: the session export must still // stay external-only. _file( 'session.html', url: '$origin/fixture/session.html', contentType: 'text/plain', sizeBytes: 512, ), ], }, { 'stage': 'reviewer', 'sequence': 2, 'status': 'completed', 'control': {'visit': 2}, 'artifacts': [ _file( 'input.md', url: '$origin/fixture/input-2.md', contentType: 'text/markdown', sizeBytes: 130, ), _file( 'memory.md', url: '$origin/fixture/memory.md', contentType: 'text/markdown', sizeBytes: 256, ), ], }, ]; } if (state == 'files') { return [ { 'stage': 'reviewer', 'sequence': 1, 'status': 'completed', 'control': {'visit': 1}, 'artifacts': [ _file( 'report.zip', url: '$origin/fixture/report.zip', contentType: 'application/zip', sizeBytes: 23, ), ], }, ]; } return [ { 'stage': 'implementer', 'sequence': 1, 'status': 'completed', 'control': {'visit': 1}, 'artifacts': [ _file( 'build.log', url: '$origin/fixture/build.log', contentType: 'text/plain; charset=utf-8', sizeBytes: 2337, ), _file( 'notes.txt', url: '$origin/fixture/notes.txt', contentType: 'text/plain', sizeBytes: 2337, ), ], }, { 'stage': 'reviewer', 'sequence': 2, 'status': 'completed', 'control': {'visit': 1}, 'artifacts': [ _file( 'result.zip', url: '$origin/fixture/result.zip', contentType: 'application/zip', sizeBytes: 2048, ), _file( 'shot.png', url: '$origin/fixture/shot.png', contentType: 'image/png', sizeBytes: 80544, ), _file( 'clip.mp4', url: '$origin/fixture/clip.mp4', contentType: 'video/mp4', sizeBytes: 40544, ), ], }, { 'stage': 'reviewer', 'sequence': 3, 'status': 'completed', 'control': {'visit': 2}, 'artifacts': [ _file( 'result.zip', url: '$origin/fixture/result-2.zip', contentType: 'application/zip', sizeBytes: 4096, ), ], 'artifacts_skipped': 2, }, ]; } JsonMap _run(String origin, String state) => { 'id': 31, 'title': 'Artifacts gallery probe', 'name': 'gallery', 'status': 'succeeded', 'steps': _steps(origin, state), }; void main() { final params = Uri.base.queryParameters; final cupertino = params['platform'] == 'cupertino'; final theme = params['theme'] == 'dark' ? Brightness.dark : Brightness.light; final origin = params['origin'] ?? 'https://artifacts.invalid'; final state = params['state'] ?? 'default'; final gallery = params['view'] == 'gallery'; final originUrl = Uri.tryParse(origin); final endpoint = originUrl == null ? '' : originUrl .replace( scheme: originUrl.scheme == 'https' ? 'wss' : 'ws', path: '/connect', query: null, ) .toString(); // Browser text scaling is a fixture input like platform and theme. final textScale = double.tryParse(params['scale'] ?? '') ?? 1; final body = _ProbeBody( run: _run(origin, state), gallery: gallery, endpoint: endpoint, ); Widget scaled(BuildContext context, Widget? app) => MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: TextScaler.linear(textScale)), child: app!, ); if (cupertino) { runApp( CupertinoApp( title: 'Artifacts probe', theme: CupertinoThemeData(brightness: theme), builder: (context, app) => Theme( data: ThemeData(platform: TargetPlatform.iOS), child: scaled(context, app), ), home: body, ), ); } else { runApp( MaterialApp( title: 'Artifacts probe', theme: ThemeData(brightness: theme, platform: TargetPlatform.android), builder: scaled, home: body, ), ); } } class _ProbeBody extends StatefulWidget { const _ProbeBody({ required this.run, required this.gallery, required this.endpoint, }); final JsonMap run; final bool gallery; final String endpoint; @override State<_ProbeBody> createState() => _ProbeBodyState(); } class _ProbeBodyState extends State<_ProbeBody> { late final _FakeGateway _gateway = _FakeGateway(widget.run); late final RunsController _controller = RunsController( RunsRepository(_gateway), ); @override void initState() { super.initState(); _controller.select(31); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { if (widget.gallery) { final steps = (widget.run['steps'] as List).cast(); return ArtifactGalleryPage( steps: steps, configuredEndpoint: widget.endpoint, ); } final detail = RunDetailView( controller: _controller, gateway: _gateway, onBack: () {}, ); if (Theme.of(context).platform == TargetPlatform.iOS) { return CupertinoPageScaffold( navigationBar: const CupertinoNavigationBar(middle: Text('Runs')), child: SafeArea(child: detail), ); } return Scaffold( appBar: AppBar(title: const Text('Runs')), body: detail, ); } }