Add server health page with native controls and bounded refresh

This commit is contained in:
2026-11-07 01:43:54 +00:00
parent 81955059de
commit 8bf8cd9507
17 changed files with 1156 additions and 2 deletions
+6 -2
View File
@@ -19,7 +19,9 @@ no longer matches the app.
`tool/search_selection_probe_entry.dart` is the real `PipelinesApp` running on
an in-process fixture channel. It never contacts a server. It has run 7 (three
visits plus the artifact `release-report.txt`), run 6, pipelines 24 and 22, and
search hits for `release`. Build it once per change, from `app/`:
search hits for `release`. It also answers `server_stats`, so the Settings route
can be captured before the server command is available. Build it once per
change, from `app/`:
```sh
/Users/alan/development/flutter/bin/flutter build web \
@@ -29,7 +31,9 @@ search hits for `release`. Build it once per change, from `app/`:
URL parameters (the kit sets them from `open=` and the options):
`route=<app route>`, `q=<search>`, `platform=material|cupertino`,
`theme=light|dark`; `--params` (or a step's or script's `params`) adds fixture
options such as `chats=2&rich=1`. Without `theme`, the app follows the browser's colour
options such as `chats=2&rich=1`. Use `route=/settings` to open Settings and then
click `Server health`; the fixture channel returns `server_stats` automatically.
Without `theme`, the app follows the browser's colour
scheme. `--theme` also sets that colour scheme through Chrome emulation.
## Steps
+20
View File
@@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:pipelines_app/features/settings/health/health_screen.dart';
import 'health_probe_fixture.dart';
void main() => runApp(const _HealthProbeApp());
class _HealthProbeApp extends StatelessWidget {
const _HealthProbeApp();
@override
Widget build(BuildContext context) => MaterialApp(
title: 'Server health fixture',
debugShowCheckedModeBanner: false,
theme: ThemeData(colorSchemeSeed: Colors.blue),
darkTheme: ThemeData(
brightness: Brightness.dark,
colorSchemeSeed: Colors.blue,
),
home: HealthScreen(gateway: HealthProbeGateway()),
);
}
+95
View File
@@ -0,0 +1,95 @@
import 'package:pipelines_app/core/api_gateway.dart';
/// In-memory server_stats reply for browser captures before the server command
/// is available. It deliberately uses the production envelope shape.
class HealthProbeGateway implements ApiGateway {
@override
Stream<JsonMap> get frames => const Stream.empty();
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
if (type != 'server_stats') return {'error': 'Unknown command: $type'};
return {'server_stats': healthProbeSnapshot()};
}
}
JsonMap healthProbeSnapshot() => {
'sampled_at': DateTime.now().toUtc().toIso8601String(),
'host': {
'hostname': 'capture-host',
'os': 'linux',
'platform': 'Ubuntu',
'platform_version': '24.04',
'uptime_seconds': 86400,
'load1': 1.2,
'load5': 1.0,
'load15': 0.8,
},
'cpu': {
'model': 'Capture CPU',
'logical_cores': 8,
'physical_cores': 4,
'usage_percent': 42.5,
'load1': 1.2,
'load5': 1.0,
'load15': 0.8,
'per_core_percent': [20, 35, 42, 55, 61, 30, 48, 39],
},
'memory': {
'total_bytes': 17179869184,
'used_bytes': 7516192768,
'available_bytes': 9663676416,
'used_percent': 43.7,
'swap_total_bytes': 4294967296,
'swap_used_bytes': 536870912,
},
'storage': [
{
'mount': '/data',
'device': '/dev/sdb',
'fs_type': 'ext4',
'total_bytes': 2199023255552,
'used_bytes': 1759218604441,
'free_bytes': 439804651111,
'used_percent': 80,
},
{
'mount': '/',
'device': '/dev/sda',
'fs_type': 'ext4',
'total_bytes': 107374182400,
'used_bytes': 53687091200,
'free_bytes': 53687091200,
'used_percent': 50,
},
],
'data': {
'dir': '/var/lib/pipelines',
'db_bytes': 1073741824,
'artifacts_bytes': 12884901888,
'total_bytes': 13958643712,
},
'process': {
'pid': 42,
'started_at': '2026-11-06T12:00:00Z',
'rss_bytes': 268435456,
'cpu_percent': 4.5,
'goroutines': 84,
'heap_bytes': 134217728,
'threads': 12,
'go_version': 'go1.24.1',
'build': 'capture',
},
'gpu': {
'available': true,
'devices': [
{
'name': 'NVIDIA RTX 4070',
'vendor': 'NVIDIA',
'utilization_percent': 36,
'memory_total_bytes': 12884901888,
'memory_used_bytes': 3221225472,
'temperature_c': 54,
},
],
},
};
@@ -1,3 +1,4 @@
import 'health_probe_fixture.dart';
// Standalone fixture entry for real-browser Search result-selection evidence.
//
// Build and probe (from app/):
@@ -479,6 +480,12 @@ JsonMap? probeReply(JsonMap request) {
'build': {'version': 'Search selection probe fixture'},
'time': '2026-10-20T09:00:00Z',
};
case 'server_stats':
return {
'id': id,
'type': 'server_stats_result',
'server_stats': healthProbeSnapshot(),
};
case 'list_runs':
return {
'id': id,