fix(ui): implement cached startup pre-flight check in SessionService and propagate errors in StaleBanner
This commit is contained in:
+8
-5
@@ -33,11 +33,14 @@ class StaleBanner extends StatelessWidget {
|
||||
size: 18,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'⚠ status snapshot stale (last ok: $lastOkText)',
|
||||
style: const TextStyle(
|
||||
color: AppColors.warning,
|
||||
fontWeight: FontWeight.w600,
|
||||
Expanded(
|
||||
child: Text(
|
||||
'⚠ status snapshot stale (last ok: $lastOkText)${poll.error != null ? ' — Error: ${poll.error}' : ''}',
|
||||
style: const TextStyle(
|
||||
color: AppColors.warning,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
BIN
Binary file not shown.
+20
@@ -27,7 +27,27 @@ class SessionService {
|
||||
this.timeout = const Duration(seconds: 5),
|
||||
});
|
||||
|
||||
bool _preflightChecked = false;
|
||||
|
||||
Future<void> _checkPreflight() async {
|
||||
if (_preflightChecked) return;
|
||||
|
||||
final bashResult = await runCommand(['bash', '--version'], timeout: timeout);
|
||||
if (bashResult.rc != 0) {
|
||||
throw StatusFetchException('preflight failed: bash is missing or not executable');
|
||||
}
|
||||
|
||||
final tmuxResult = await runCommand(['tmux', '-V'], timeout: timeout);
|
||||
if (tmuxResult.rc != 0) {
|
||||
throw StatusFetchException('preflight failed: tmux is missing or not executable');
|
||||
}
|
||||
|
||||
_preflightChecked = true;
|
||||
}
|
||||
|
||||
Future<SessionsSnapshot> fetchSnapshot() async {
|
||||
await _checkPreflight();
|
||||
|
||||
final result = await runCommand(
|
||||
['bash', statusScriptPath, '--json'],
|
||||
timeout: timeout,
|
||||
|
||||
Reference in New Issue
Block a user