From ba9f9f1f25891e346180471024ab0ea99be1e6a6 Mon Sep 17 00:00:00 2001 From: Viktor Lidholt Date: Thu, 3 Dec 2026 16:38:07 +0100 Subject: [PATCH] feat: Tell a computer below the requirements so at launch, before setup. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit App Studio runs a server, a database and a Flutter app side by side, and on a computer with too little memory or too slow a processor a project is very slow to start or does not start at all. Such a computer now hears that first thing at launch — before first-run setup downloads a few GB of tools onto it. - The requirements are 16 GB of memory and 8 logical cores. Anything short of either raises "App Studio is unlikely to run on this computer", listing only what falls short, with Try Anyway and Quit. - The memory bar is 13 GiB rather than 16: a 16 GB computer never reports all of it where the figure is what the OS can use, and integrated graphics can hold back 2 GB. 12 GB, the next size down, still falls short. - The core count is a proxy for speed, chosen over a benchmark because it is instant and the same on every start. - Windows is asked for its memory directly (GetPhysicallyInstalledSystemMemory, then GlobalMemoryStatusEx), macOS through sysctl, Linux from /proc/meminfo. A reading that fails or takes over two seconds is not held against the computer, so the check can never stop the app from starting. - Try Anyway is remembered with the readings it was made for: the same computer is not asked twice, one that reads differently later is. - While the question is up it owns the window, like setup: File > Open, Open Recent and Settings are off, and no other launch question lands on it. Verified on the Windows dev laptop: the real memory and core readings, and the real app run once with an 8 GB / 4-core machine faked — the question at launch, Try Anyway to the start page, and the choice saved. The macOS and Linux readings are tested with fakes only, Quit was not pressed in the real app, and the process-tagged tests were not run locally. Co-Authored-By: Claude Fable 5.2 --- AGENTS.md | 46 +++++ lib/main.dart | 52 +++++- lib/platform/system_hardware.dart | 93 ++++++++++ lib/platform/system_requirements.dart | 169 +++++++++++++++++++ lib/platform/windows/win32_system.dart | 49 ++++++ lib/platform/windows/windows_system.dart | 8 + lib/ui/system_requirements_screen.dart | 153 +++++++++++++++++ specs/windows_vm_testing.md | 8 +- test/platform/system_hardware_test.dart | 155 +++++++++++++++++ test/platform/system_requirements_test.dart | 145 ++++++++++++++++ test/support/fake_windows_system.dart | 6 + test/ui/system_requirements_screen_test.dart | 167 ++++++++++++++++++ widgetbook/fakes/project.dart | 21 +++ widgetbook/use_cases/first_run.dart | 25 +++ 14 files changed, 1091 insertions(+), 6 deletions(-) create mode 100644 lib/platform/system_hardware.dart create mode 100644 lib/platform/system_requirements.dart create mode 100644 lib/ui/system_requirements_screen.dart create mode 100644 test/platform/system_hardware_test.dart create mode 100644 test/platform/system_requirements_test.dart create mode 100644 test/ui/system_requirements_screen_test.dart diff --git a/AGENTS.md b/AGENTS.md index 7f8162c..b7b27c4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1781,6 +1781,52 @@ make widgetbook # every screen and dialog, in every state, light and dark - **`MacAppMenu.install()` calls `MacMenuBar.reset()` first, and must keep doing so.** A hot restart replaces the Dart isolate but not the engine, its plugins or the native `NSMenu`, so without it every menu is added again on each restart — and `_recentItemIds` comes back empty, so Open Recent duplicates too. `reset()` removes exactly the items this plugin added: those are the ones carrying a String `representedObject`, which is also how the plugin finds items by id, so stock MainMenu.xib entries cannot be stripped. - **Never return `menuItem.isEnabled` from `validateMenuItem`** for an item the plugin overrode. Under automatic enabling AppKit *writes* `isEnabled` from the previous validation pass, so reading it back is a latch, not a query. MainMenu.xib ships `Preferences…` with no action at all, so AppKit disabled it before the override was installed and it could never re-enable — the Settings item was permanently greyed out. Overridden standard items are tracked in `overriddenItems` and validate to `true`; the Dart handler decides what happens when they fire. +## The requirements check — before anything else at launch + +A computer below App Studio's requirements is told so **before first-run +setup**, which would otherwise download a few GB of tools onto a machine that +cannot run a project. `main()` creates `SystemRequirementsController` before +`runApp`, and `home` shows `SystemRequirementsScreen` ahead of the setup +screen and the shell while `blocksLaunch` is true. + +- **The requirements are 16 GB of memory and 8 logical cores** + (`platform/system_requirements.dart`). Anything short of either raises the + same question — "App Studio is unlikely to run on this computer", listing + only what falls short, **Try Anyway** and **Quit** (Quit on the right, as + the default). One level, on purpose: there is no softer "may be slow" tier. +- **The memory bar is 13 GiB, not 16.** A 16 GB computer never reports all + of it where the figure is what the OS can use — Linux always — and + integrated graphics can hold back 2 GB; 12 GB, the next size down, reports + under 12. The dialog shows the figure rounded to the GB the computer was + sold with. +- **The core count is a proxy for speed, chosen over a benchmark.** It is + instant and the same on every start; a timed run varies with battery saver + and whatever else starts at login, and a wrong "unlikely to run" costs a + user. It passes every Apple Silicon Mac and four cores with two threads + each, and fails dual-core laptops and four-thread budget chips. It says + nothing about how fast a core is. +- **Reading the hardware** (`platform/system_hardware.dart`): Windows is asked + directly (`WindowsSystem.installedMemoryBytes` — + `GetPhysicallyInstalledSystemMemory`, then `GlobalMemoryStatusEx` where the + firmware does not say), macOS through `/usr/sbin/sysctl -n hw.memsize`, + Linux from `/proc/meminfo`. **A reading that fails or takes over two + seconds is null, and a null is never held against the computer**: the check + must not be what stops the app from starting. +- **Try Anyway is remembered with the readings it was made for** + (`system_requirements.tried_anyway` = `memory=8/16;processor=4/8`), so the + same computer never asks twice and one that reads differently later asks + again. It is a preference, so an uninstall forgets it. +- **While the question is up it owns the window, like setup.** + `_canOpenProjects` in `main.dart` is false for either gate, which is what + File → Open, Open Recent and Settings follow, and `_onStartPage` is false, + so no other launch question (Linux's add-to-applications, the update + check) lands on top. The screen asks again if its dialog is cleared away + rather than answered. +- **Quit is `quitApp()` (`exit(0)`)**, as in the setup dialogs: nothing has + been started yet that would need stopping. +- The Windows test VM is 8 GB and 4 vCPUs (`specs/windows_vm_testing.md`), so + every pass from a pristine snapshot starts with this question. + ## First run `main.dart` picks the whole screen from `toolchains.inventory.needsSetup`: diff --git a/lib/main.dart b/lib/main.dart index 1ba80a8..feba677 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,6 +11,7 @@ import 'platform/afunix_settle.dart'; import 'platform/compact_window.dart'; import 'platform/host.dart'; import 'platform/linux/desktop_integration.dart'; +import 'platform/system_requirements.dart'; import 'platform/window_close.dart'; import 'platform/windows/win32_system.dart'; import 'platform/windows/windows_roots.dart'; @@ -41,6 +42,7 @@ import 'ui/uninstall/uninstalled_screen.dart'; import 'uninstall/uninstaller.dart'; import 'ui/toolchain/toolchain_setup_screen.dart'; import 'ui/studio_shell.dart'; +import 'ui/system_requirements_screen.dart'; import 'widgets/nothing_pushed.dart'; Future main() async { @@ -58,6 +60,11 @@ Future main() async { final themeController = ThemeController(); await themeController.load(); + // Whether this computer is up to running a project. Read before anything + // is shown, because a computer that falls short hears so first — ahead of + // first-run setup and its downloads. + final requirements = await SystemRequirementsController.create(); + final toolchains = await ToolchainController.create(); final session = ProjectSession(); await session.loadRecents(); @@ -111,6 +118,7 @@ Future main() async { runApp( AppStudioApp( themeController: themeController, + requirements: requirements, toolchains: toolchains, session: session, process: process, @@ -130,6 +138,7 @@ class AppStudioApp extends StatefulWidget { const AppStudioApp({ super.key, required this.themeController, + required this.requirements, required this.toolchains, required this.session, required this.process, @@ -144,6 +153,10 @@ class AppStudioApp extends StatefulWidget { }); final ThemeController themeController; + + /// Whether the computer meets App Studio's requirements, and the launch + /// gate for one that does not. + final SystemRequirementsController requirements; final ToolchainController toolchains; final ProjectSession session; final ServerpodProcessController process; @@ -234,7 +247,7 @@ class _AppStudioAppState extends State { onSetAutomaticUpdates: (enabled) => unawaited(widget.updates.setAutomaticallyChecks(enabled)), automaticUpdatesEnabled: () => widget.updates.state.automaticallyChecks, - canOpenProjects: () => !_needsToolchainSetup, + canOpenProjects: () => _canOpenProjects, onCreateAndApplyMigrations: () => _withNavigatorContext( (context) => createAndApplyMigrations(context, widget.process), ), @@ -250,6 +263,7 @@ class _AppStudioAppState extends State { // re-sync when the last install lands. _menuCanOpenProjects = !_needsToolchainSetup; widget.toolchains.addListener(_onToolchainsChanged); + widget.requirements.addListener(_onRequirementsChanged); _noticedProjectPath = widget.session.projectPath; widget.session.addListener(_onSessionChanged); _lifecycle = AppLifecycleListener(onExitRequested: _onExitRequested); @@ -261,7 +275,7 @@ class _AppStudioAppState extends State { unawaited(_macMenu!.install()); // With setup done, the start page is the first screen: offer once it is // up. Otherwise the end of setup offers (`_onToolchainsChanged`). - if (!_needsToolchainSetup) { + if (!_needsToolchainSetup && !_belowRequirements) { WidgetsBinding.instance.addPostFrameCallback( (_) => _offerAddToApplications(), ); @@ -350,7 +364,7 @@ class _AppStudioAppState extends State { onSetAutomaticUpdates: (enabled) => unawaited(widget.updates.setAutomaticallyChecks(enabled)), automaticUpdatesEnabled: () => widget.updates.state.automaticallyChecks, - canOpenProjects: () => !_needsToolchainSetup, + canOpenProjects: () => _canOpenProjects, onCreateAndApplyMigrations: () => _withNavigatorContext( (context) => createAndApplyMigrations(context, widget.process), ), @@ -359,6 +373,7 @@ class _AppStudioAppState extends State { ), changes: Listenable.merge([ widget.updates, + widget.requirements, widget.toolchains, widget.previewMode, widget.desktopIntegration, @@ -399,7 +414,9 @@ class _AppStudioAppState extends State { // current for exactly that reason: a second pop here would take `home` with // it and leave an empty navigator. WidgetsBinding.instance.addPostFrameCallback((_) { - if (!mounted) return; + // Behind the requirements question nothing is swapped: that screen + // stays until it is answered, and the clear would take its question. + if (!mounted || _belowRequirements) return; _clearPushedRoutes(); // After the clear, or it would take the question with it. if (canOpen) _offerAddToApplications(); @@ -407,6 +424,17 @@ class _AppStudioAppState extends State { _syncMenu(); } + /// "Try Anyway" on the requirements question: the gate lifts and setup or + /// the start page takes the screen, as if the app had just opened on it. + void _onRequirementsChanged() { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!mounted || _belowRequirements) return; + _clearPushedRoutes(); + if (!_needsToolchainSetup) _offerAddToApplications(); + }); + _syncMenu(); + } + /// Linux, as an AppImage nobody added to the app menu: asks whether to, /// once per run, over the start page and never among setup's dialogs. /// @@ -428,6 +456,7 @@ class _AppStudioAppState extends State { bool _onStartPage() => mounted && widget.session.projectPath == null && + !_belowRequirements && !_needsToolchainSetup && _uninstalled == null && nothingPushedOver(_navigatorKey); @@ -445,6 +474,13 @@ class _AppStudioAppState extends State { /// [ToolchainController.needsSetup]. bool get _needsToolchainSetup => widget.toolchains.needsSetup; + /// The requirements question owns the window: the computer falls short and + /// the user has not yet chosen to go on. + bool get _belowRequirements => widget.requirements.blocksLaunch; + + /// What File → Open, Open Recent and Settings follow: neither gate is up. + bool get _canOpenProjects => !_needsToolchainSetup && !_belowRequirements; + /// Opening a project auto-starts the server, so this is the moment the long /// first compile begins — say so before it looks like a hang. void _onSessionChanged() { @@ -608,6 +644,7 @@ class _AppStudioAppState extends State { _lifecycle?.dispose(); widget.updates.removeListener(_syncMenu); widget.toolchains.removeListener(_onToolchainsChanged); + widget.requirements.removeListener(_onRequirementsChanged); widget.session.removeListener(_onSessionChanged); _macMenu?.dispose(); // Same teardown Sparkle runs before it relaunches, so the two paths cannot @@ -633,6 +670,7 @@ class _AppStudioAppState extends State { widget.previewMode.dispose(); widget.logView.dispose(); widget.desktopIntegration.dispose(); + widget.requirements.dispose(); super.dispose(); } @@ -641,6 +679,7 @@ class _AppStudioAppState extends State { return ListenableBuilder( listenable: Listenable.merge([ widget.themeController, + widget.requirements, widget.toolchains, widget.previewMode, ]), @@ -674,6 +713,11 @@ class _AppStudioAppState extends State { // moment; the shell would otherwise keep rendering panes for a // session that is being dismantled underneath it. null when _uninstalling => const UninstallingScreen(), + // First of the two gates: a computer that cannot run a project + // should not be taken through setup's downloads to find out. + null when _belowRequirements => SystemRequirementsScreen( + requirements: widget.requirements, + ), // Before the start page, not over it: there is nothing to create or // open a project with yet. null when _needsToolchainSetup => ToolchainSetupScreen( diff --git a/lib/platform/system_hardware.dart b/lib/platform/system_hardware.dart new file mode 100644 index 0000000..af95c80 --- /dev/null +++ b/lib/platform/system_hardware.dart @@ -0,0 +1,93 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:flutter/foundation.dart'; + +import 'host.dart'; +import 'windows/win32_system.dart'; +import 'windows/windows_system.dart'; + +/// What the computer has to run App Studio with, as far as it could be read. +/// A null is a reading that failed, never a zero. +@immutable +class SystemHardware { + const SystemHardware({this.memoryBytes, this.logicalCores}); + + /// The RAM fitted, or on Linux the RAM the kernel can use — a little less. + final int? memoryBytes; + + /// Processor cores as the OS counts them: a core with two threads is two. + final int? logicalCores; +} + +/// Runs a short system command. Replaceable so tests start no process. +typedef SystemCommand = + Future Function(String executable, List arguments); + +/// Reads the computer's memory and processor count. +/// +/// Each OS has its own source for the memory, and none needs a tool that +/// might be missing: Windows is asked directly ([WindowsSystem]), macOS +/// through `sysctl`, which ships with it, and Linux from `/proc/meminfo`. +/// +/// Never throws and never takes long: launch waits on it. A reading that +/// fails or stalls comes back null, and a null is not held against the +/// computer. +Future readSystemHardware({ + HostPlatform? host, + WindowsSystem? windows, + SystemCommand? run, + String meminfoPath = '/proc/meminfo', + int? logicalCores, + Duration timeout = const Duration(seconds: 2), +}) async { + final platform = host ?? currentHost; + int? memory; + try { + memory = await _readMemory( + platform, + windows: windows, + run: run ?? (exe, args) => Process.run(exe, args), + meminfoPath: meminfoPath, + ).timeout(timeout); + } catch (_) { + memory = null; + } + int? cores; + try { + cores = logicalCores ?? Platform.numberOfProcessors; + } catch (_) { + cores = null; + } + return SystemHardware( + memoryBytes: memory != null && memory > 0 ? memory : null, + logicalCores: cores != null && cores > 0 ? cores : null, + ); +} + +Future _readMemory( + HostPlatform host, { + required WindowsSystem? windows, + required SystemCommand run, + required String meminfoPath, +}) async { + if (host.isWindows) { + return (windows ?? Win32System()).installedMemoryBytes(); + } + if (host.isMacOS) { + final result = await run('/usr/sbin/sysctl', ['-n', 'hw.memsize']); + return result.exitCode == 0 ? int.tryParse('${result.stdout}'.trim()) : null; + } + return parseMeminfoTotal(await File(meminfoPath).readAsString()); +} + +/// `MemTotal` from `/proc/meminfo`, in bytes: `MemTotal: 16303428 kB`. +int? parseMeminfoTotal(String meminfo) { + final match = RegExp( + r'^MemTotal:\s+(\d+)\s*kB', + multiLine: true, + caseSensitive: false, + ).firstMatch(meminfo); + final kilobytes = match == null ? null : int.tryParse(match[1]!); + return kilobytes == null ? null : kilobytes * 1024; +} diff --git a/lib/platform/system_requirements.dart b/lib/platform/system_requirements.dart new file mode 100644 index 0000000..4e6cdf4 --- /dev/null +++ b/lib/platform/system_requirements.dart @@ -0,0 +1,169 @@ +import 'package:flutter/foundation.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import 'system_hardware.dart'; + +/// The memory App Studio asks for, in GB as computers are sold. +const kRequiredMemoryGb = 16; + +/// The processor App Studio asks for, in logical cores. Four cores with two +/// threads each pass, as does every Apple Silicon Mac; a dual-core laptop and +/// a four-core, four-thread budget chip do not. A proxy for speed, chosen +/// because it is instant and the same on every start: it says nothing about +/// how fast each core is. +const kRequiredLogicalCores = 8; + +const _gib = 1024 * 1024 * 1024; + +/// Below this the computer does not have [kRequiredMemoryGb]. +/// +/// Not 16 GiB itself: a computer sold with 16 GB reports less wherever the +/// figure is what the OS can use rather than what is fitted — Linux always, +/// Windows when the firmware does not say — and integrated graphics can hold +/// back 2 GB of it. The next size down, 12 GB, reports under 12. +const kMemoryPassBytes = 13 * _gib; + +enum RequirementKind { memory, processor } + +/// One thing the computer has less of than App Studio asks for. +@immutable +class RequirementShortfall { + const RequirementShortfall.memory({required int foundGb}) + : kind = RequirementKind.memory, + found = foundGb, + needed = kRequiredMemoryGb; + + const RequirementShortfall.processor({required int foundCores}) + : kind = RequirementKind.processor, + found = foundCores, + needed = kRequiredLogicalCores; + + final RequirementKind kind; + + /// GB of memory, or logical cores. + final int found; + final int needed; + + String get label => switch (kind) { + RequirementKind.memory => 'Memory', + RequirementKind.processor => 'Processor', + }; + + /// What the computer has: "8 GB", "4 cores". + String get foundText => switch (kind) { + RequirementKind.memory => '$found GB', + RequirementKind.processor => found == 1 ? '1 core' : '$found cores', + }; + + /// What App Studio asks for: "16 GB needed", "8 cores needed". + String get neededText => switch (kind) { + RequirementKind.memory => '$needed GB needed', + RequirementKind.processor => '$needed cores needed', + }; + + @override + bool operator ==(Object other) => + other is RequirementShortfall && + other.kind == kind && + other.found == found && + other.needed == needed; + + @override + int get hashCode => Object.hash(kind, found, needed); + + @override + String toString() => '${kind.name}=$found/$needed'; +} + +/// Where [hardware] falls short, memory first. Empty when it meets the +/// requirements — and for whatever could not be read: a reading that failed +/// is no reason to tell someone their computer is too slow. +List findShortfalls(SystemHardware hardware) => [ + if (hardware.memoryBytes case final bytes? when bytes < kMemoryPassBytes) + RequirementShortfall.memory(foundGb: (bytes / _gib).round()), + if (hardware.logicalCores case final cores? + when cores < kRequiredLogicalCores) + RequirementShortfall.processor(foundCores: cores), +]; + +/// What the launch gate needs: whether to stand in the way, what to say, and +/// the way past. `SystemRequirementsController` is the real one; Widgetbook +/// and the tests fake it. +abstract interface class SystemRequirementsView implements Listenable { + /// Where this computer falls short. Empty on one that meets the + /// requirements. + List get shortfalls; + + /// The computer falls short and the user has not yet chosen to go on. + bool get blocksLaunch; + + /// The user's "Try Anyway": remembered, so the question is not asked again + /// on this computer. + Future tryAnyway(); +} + +/// Checks the computer against App Studio's requirements once, at launch, +/// and remembers a user who chose to go on regardless. +/// +/// **The choice is kept with the readings it was made for**, not as a bare +/// flag: the same computer never asks twice, but one that reads differently +/// later — memory taken out, a virtual machine given fewer cores — asks +/// again. It lives in preferences, so an uninstall forgets it. +class SystemRequirementsController extends ChangeNotifier + implements SystemRequirementsView { + SystemRequirementsController({ + required this.shortfalls, + this._triedAnyway = false, + }); + + /// Reads the hardware and the remembered choice. Never throws: launch + /// waits on this, and a check that cannot run must not be what stops the + /// app from starting — it then finds nothing wrong. + static Future create({ + SystemHardware? hardware, + }) async { + try { + final shortfalls = findShortfalls( + hardware ?? await readSystemHardware(), + ); + if (shortfalls.isEmpty) { + return SystemRequirementsController(shortfalls: const []); + } + final prefs = await SharedPreferences.getInstance(); + return SystemRequirementsController( + shortfalls: shortfalls, + triedAnyway: prefs.getString(_kTriedAnywayKey) == _signature(shortfalls), + ); + } catch (_) { + return SystemRequirementsController(shortfalls: const []); + } + } + + static const _kTriedAnywayKey = 'system_requirements.tried_anyway'; + + /// The shortfalls as one stored value: `memory=8/16;processor=4/8`. It + /// carries the requirement too, so raising one asks again. + static String _signature(List shortfalls) => + shortfalls.join(';'); + + @override + final List shortfalls; + + bool _triedAnyway; + + @override + bool get blocksLaunch => shortfalls.isNotEmpty && !_triedAnyway; + + @override + Future tryAnyway() async { + if (!blocksLaunch) return; + _triedAnyway = true; + notifyListeners(); + try { + final prefs = await SharedPreferences.getInstance(); + await prefs.setString(_kTriedAnywayKey, _signature(shortfalls)); + } catch (_) { + // Not remembered, then: the worst case is being asked once more. + } + } +} diff --git a/lib/platform/windows/win32_system.dart b/lib/platform/windows/win32_system.dart index af05ddc..51b1d1a 100644 --- a/lib/platform/windows/win32_system.dart +++ b/lib/platform/windows/win32_system.dart @@ -207,6 +207,33 @@ class Win32System implements WindowsSystem { int Function(int, int, Pointer, Pointer, Pointer, Pointer)>('AssocQueryStringW'); + // BOOL GetPhysicallyInstalledSystemMemory(PULONGLONG TotalMemoryInKilobytes) + static final _getPhysicallyInstalledSystemMemory = _kernel32.lookupFunction< + Int32 Function(Pointer), + int Function(Pointer)>('GetPhysicallyInstalledSystemMemory'); + + // BOOL GlobalMemoryStatusEx(LPMEMORYSTATUSEX) + static final _globalMemoryStatusEx = _kernel32.lookupFunction< + Int32 Function(Pointer<_MemoryStatusEx>), + int Function(Pointer<_MemoryStatusEx>)>('GlobalMemoryStatusEx'); + + /// The firmware's figure first: it is what was fitted. A computer whose + /// SMBIOS tables are missing or wrong — some virtual machines — fails that + /// call, and what Windows itself can use is the next best answer. + @override + int? installedMemoryBytes() => using((arena) { + final kilobytes = arena(); + if (_getPhysicallyInstalledSystemMemory(kilobytes) != 0 && + kilobytes.value > 0) { + return kilobytes.value * 1024; + } + final status = arena<_MemoryStatusEx>(); + status.ref.dwLength = sizeOf<_MemoryStatusEx>(); + if (_globalMemoryStatusEx(status) == 0) return null; + final total = status.ref.ullTotalPhys; + return total > 0 ? total : null; + }); + static const _assocfIsProtocol = 0x00001000; static const _assocstrFriendlyAppName = 4; @@ -380,6 +407,28 @@ final class _CertChainContext extends Struct { external int dwInfoStatus; } +/// MEMORYSTATUSEX. +final class _MemoryStatusEx extends Struct { + @Uint32() + external int dwLength; + @Uint32() + external int dwMemoryLoad; + @Uint64() + external int ullTotalPhys; + @Uint64() + external int ullAvailPhys; + @Uint64() + external int ullTotalPageFile; + @Uint64() + external int ullAvailPageFile; + @Uint64() + external int ullTotalVirtual; + @Uint64() + external int ullAvailVirtual; + @Uint64() + external int ullAvailExtendedVirtual; +} + /// SHELLEXECUTEINFOW (64-bit layout). final class _ShellExecuteInfo extends Struct { @Uint32() diff --git a/lib/platform/windows/windows_system.dart b/lib/platform/windows/windows_system.dart index 0b6fd41..2dd1a19 100644 --- a/lib/platform/windows/windows_system.dart +++ b/lib/platform/windows/windows_system.dart @@ -66,6 +66,11 @@ abstract interface class WindowsSystem { /// fetched yet into its root store (`windows_roots.dart` says why that /// matters). True when the chain ends in a trusted root. Future buildCertificateChain(Uint8List der); + + /// The RAM fitted in the computer, in bytes, or null when Windows cannot + /// say. What the firmware reports as installed where it does, so a 16 GB + /// computer reads as 16 GB whatever its graphics have reserved. + int? installedMemoryBytes(); } /// No registry, no prompt: every read finds nothing and every change fails. @@ -99,6 +104,9 @@ class NoWindowsSystem implements WindowsSystem { @override String? protocolHandler(String scheme) => null; + @override + int? installedMemoryBytes() => null; + @override Future buildCertificateChain(Uint8List der) async => false; } diff --git a/lib/ui/system_requirements_screen.dart b/lib/ui/system_requirements_screen.dart new file mode 100644 index 0000000..db46a74 --- /dev/null +++ b/lib/ui/system_requirements_screen.dart @@ -0,0 +1,153 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:shad/shad.dart'; + +import '../platform/system_requirements.dart'; +import '../theme/app_theme.dart'; +import '../util/quit_app.dart'; +import '../widgets/app_dialog.dart'; +import '../widgets/dialog_body.dart'; +import 'landing_scaffold.dart'; + +/// The whole screen at launch on a computer below App Studio's requirements, +/// until the user chooses to go on. +/// +/// Before first-run setup, not after it: setup downloads a few GB of tools, +/// and someone whose computer cannot run a project should hear that first. +/// Like the setup screen it owns the window — the start page's New Project +/// and Open Project have no business being reachable behind the question — +/// and its body is the landing backdrop alone, with the question a dialog +/// over it. +class SystemRequirementsScreen extends StatefulWidget { + const SystemRequirementsScreen({super.key, required this.requirements}); + + final SystemRequirementsView requirements; + + @override + State createState() => + _SystemRequirementsScreenState(); +} + +class _SystemRequirementsScreenState extends State { + @override + void initState() { + super.initState(); + // Pushing a route from inside a build is illegal. + WidgetsBinding.instance.addPostFrameCallback((_) => unawaited(_ask())); + } + + /// Asks until it is answered. The dialog cannot be dismissed, but the app + /// clears pushed routes when it swaps screens, and a question lost that way + /// would leave an empty backdrop with no way on. + Future _ask() async { + final requirements = widget.requirements; + while (true) { + if (!mounted || !requirements.blocksLaunch) return; + final tryAnyway = await showAppDialog( + context: context, + barrierDismissible: false, + builder: (context) => + SystemRequirementsDialog(shortfalls: requirements.shortfalls), + ); + if (tryAnyway ?? false) { + await requirements.tryAnyway(); + } else { + // Cleared, not answered. Whatever cleared it is replacing this screen + // (an uninstall, say) and that lands with the next frame: look again + // only after it, or the question goes up over the new screen. + await WidgetsBinding.instance.endOfFrame; + } + } + } + + @override + Widget build(BuildContext context) => + const LandingScaffold(child: SizedBox.expand()); +} + +/// Says the computer is below the requirements, by how much, and offers Try +/// Anyway or Quit. +/// +/// Pops with true for Try Anyway. Quit ends the app there and then: nothing +/// has been started yet that would need stopping. +class SystemRequirementsDialog extends StatelessWidget { + const SystemRequirementsDialog({ + super.key, + required this.shortfalls, + this.onQuit = quitApp, + }); + + final List shortfalls; + final VoidCallback onQuit; + + @override + Widget build(BuildContext context) { + final theme = ShadTheme.of(context); + final muted = theme.textTheme.muted; + const cell = EdgeInsets.only(right: 24, bottom: 6); + + return PopScope( + canPop: false, + child: ShadDialog.alert( + title: const Text('App Studio is unlikely to run on this computer'), + description: const Text( + 'App Studio runs a server, a database and your app side by side, ' + 'and needs more than this computer has:', + ), + actions: [ + ShadButton.outline( + onPressed: () => Navigator.of(context).pop(true), + child: const Text('Try Anyway'), + ), + // On the right, where the default answer goes: on a computer this + // far short, leaving is the one more likely to be right. + ShadButton(onPressed: onQuit, child: const Text('Quit')), + ], + child: DialogBody( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Table( + defaultColumnWidth: const IntrinsicColumnWidth(), + // The figure is set heavier than its labels, with its own + // line height: on a shared baseline it does not sit high. + defaultVerticalAlignment: TableCellVerticalAlignment.baseline, + textBaseline: TextBaseline.alphabetic, + children: [ + for (final shortfall in shortfalls) + TableRow( + children: [ + Padding( + padding: cell, + child: Text(shortfall.label, style: muted), + ), + Padding( + padding: cell, + child: Text( + shortfall.foundText, + style: theme.textTheme.small.medium, + ), + ), + Padding( + padding: cell.copyWith(right: 0), + child: Text(shortfall.neededText, style: muted), + ), + ], + ), + ], + ), + const SizedBox(height: 10), + Text( + 'You can try anyway, but projects may be very slow to start, ' + 'or may not start at all.', + style: muted, + ), + ], + ), + ), + ), + ); + } +} diff --git a/specs/windows_vm_testing.md b/specs/windows_vm_testing.md index 1b0231f..361a977 100644 --- a/specs/windows_vm_testing.md +++ b/specs/windows_vm_testing.md @@ -66,8 +66,12 @@ Note anything seen on screen that the report cannot show. ### Pass A — first run (snapshot `pristine`) -1. Start `appstudio.exe`. Expect the **setup screen**, then the plan: - Developer Mode, Git for Windows, Flutter, Serverpod, with versions. +1. Start `appstudio.exe`. The VM has 8 GB and 4 vCPUs, so expect **"App + Studio is unlikely to run on this computer"** first, listing both, before + anything is downloaded → *Try Anyway*. It must not come back on later + starts from the same snapshot chain. Then expect the **setup screen** and + the plan: Developer Mode, Git for Windows, Flutter, Serverpod, with + versions. 2. **Install.** Expect, in order: - a **Windows UAC prompt** for Developer Mode → *Yes*; - Git downloading, verifying, installing (no Git windows should appear); diff --git a/test/platform/system_hardware_test.dart b/test/platform/system_hardware_test.dart new file mode 100644 index 0000000..60833fa --- /dev/null +++ b/test/platform/system_hardware_test.dart @@ -0,0 +1,155 @@ +import 'dart:io'; + +import 'package:appstudio/platform/host_platform.dart'; +import 'package:appstudio/platform/system_hardware.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:path/path.dart' as p; + +import '../support/fake_windows_system.dart'; + +/// Reading the computer's memory and cores, on each OS, from any OS: no +/// process is started and nothing of the real machine is read. +void main() { + const gib = 1024 * 1024 * 1024; + + /// A `sysctl` that never runs: the test fails if it is asked. + Future noCommand(String exe, List args) => + fail('ran $exe'); + + group('Windows', () { + test('takes what Windows reports as fitted', () async { + final hardware = await readSystemHardware( + host: HostPlatform.windows, + windows: FakeWindowsSystem()..installedMemory = 16 * gib, + run: noCommand, + logicalCores: 12, + ); + + expect(hardware.memoryBytes, 16 * gib); + expect(hardware.logicalCores, 12); + }); + + test('memory Windows cannot report is unknown, not zero', () async { + final hardware = await readSystemHardware( + host: HostPlatform.windows, + windows: FakeWindowsSystem(), + run: noCommand, + logicalCores: 8, + ); + + expect(hardware.memoryBytes, isNull); + expect(hardware.logicalCores, 8); + }); + }); + + group('macOS', () { + test('asks sysctl for hw.memsize', () async { + final commands = []; + final hardware = await readSystemHardware( + host: HostPlatform.macos, + run: (exe, args) async { + commands.add('$exe ${args.join(' ')}'); + return ProcessResult(0, 0, '17179869184\n', ''); + }, + logicalCores: 10, + ); + + expect(commands, ['/usr/sbin/sysctl -n hw.memsize']); + expect(hardware.memoryBytes, 16 * gib); + }); + + test('a sysctl that fails leaves the memory unknown', () async { + final hardware = await readSystemHardware( + host: HostPlatform.macos, + run: (_, _) async => ProcessResult(0, 1, '', 'unknown oid'), + logicalCores: 10, + ); + + expect(hardware.memoryBytes, isNull); + }); + + test('a sysctl that cannot be started leaves the memory unknown', + () async { + final hardware = await readSystemHardware( + host: HostPlatform.macos, + run: (_, _) async => throw const ProcessException('sysctl', []), + logicalCores: 10, + ); + + expect(hardware.memoryBytes, isNull); + expect(hardware.logicalCores, 10); + }); + + test('a sysctl that hangs does not hold up launch', () async { + final hardware = await readSystemHardware( + host: HostPlatform.macos, + run: (_, _) => Future.delayed( + const Duration(seconds: 30), + () => ProcessResult(0, 0, '17179869184', ''), + ), + logicalCores: 10, + timeout: const Duration(milliseconds: 20), + ); + + expect(hardware.memoryBytes, isNull); + }); + }); + + group('Linux', () { + late Directory scratch; + + setUp(() async { + scratch = await Directory.systemTemp.createTemp('system_hardware'); + }); + + tearDown(() => scratch.delete(recursive: true)); + + test('reads MemTotal from /proc/meminfo', () async { + final meminfo = File(p.join(scratch.path, 'meminfo')) + ..writeAsStringSync( + 'MemTotal: 16303428 kB\n' + 'MemFree: 1203948 kB\n' + 'MemAvailable: 9120312 kB\n', + ); + + final hardware = await readSystemHardware( + host: HostPlatform.linux, + run: noCommand, + meminfoPath: meminfo.path, + logicalCores: 16, + ); + + expect(hardware.memoryBytes, 16303428 * 1024); + expect(hardware.logicalCores, 16); + }); + + test('a missing /proc/meminfo leaves the memory unknown', () async { + final hardware = await readSystemHardware( + host: HostPlatform.linux, + run: noCommand, + meminfoPath: p.join(scratch.path, 'nothing'), + logicalCores: 4, + ); + + expect(hardware.memoryBytes, isNull); + expect(hardware.logicalCores, 4); + }); + + test('a meminfo without MemTotal is not a reading', () { + expect(parseMeminfoTotal('MemFree: 1203948 kB\n'), isNull); + expect(parseMeminfoTotal(''), isNull); + }); + }); + + test('a core count of zero is unknown', () async { + final hardware = await readSystemHardware( + host: HostPlatform.windows, + windows: FakeWindowsSystem()..installedMemory = 0, + run: noCommand, + logicalCores: 0, + ); + + expect(hardware.memoryBytes, isNull); + expect(hardware.logicalCores, isNull); + }); +} diff --git a/test/platform/system_requirements_test.dart b/test/platform/system_requirements_test.dart new file mode 100644 index 0000000..0223959 --- /dev/null +++ b/test/platform/system_requirements_test.dart @@ -0,0 +1,145 @@ +import 'package:appstudio/platform/system_hardware.dart'; +import 'package:appstudio/platform/system_requirements.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + const gib = 1024 * 1024 * 1024; + + SystemHardware hardware({double? gb, int? cores}) => SystemHardware( + memoryBytes: gb == null ? null : (gb * gib).round(), + logicalCores: cores, + ); + + group('the requirements', () { + test('16 GB and 8 logical cores meet them', () { + expect(findShortfalls(hardware(gb: 16, cores: 8)), isEmpty); + expect(findShortfalls(hardware(gb: 64, cores: 24)), isEmpty); + }); + + test('a 16 GB computer passes although it never reports all 16', () { + // Linux: what the kernel can use. + expect(findShortfalls(hardware(gb: 15.4, cores: 8)), isEmpty); + // With 2 GB held back for integrated graphics. + expect(findShortfalls(hardware(gb: 13.6, cores: 8)), isEmpty); + }); + + test('12 GB and less fall short, in the GB the computer was sold with', + () { + expect( + findShortfalls(hardware(gb: 11.6, cores: 8)), + [const RequirementShortfall.memory(foundGb: 12)], + ); + expect( + findShortfalls(hardware(gb: 7.7, cores: 8)), + [const RequirementShortfall.memory(foundGb: 8)], + ); + }); + + test('fewer than 8 logical cores fall short', () { + expect( + findShortfalls(hardware(gb: 16, cores: 4)), + [const RequirementShortfall.processor(foundCores: 4)], + ); + expect(findShortfalls(hardware(gb: 16, cores: 7)), hasLength(1)); + }); + + test('both are reported, memory first', () { + expect(findShortfalls(hardware(gb: 8, cores: 4)), [ + const RequirementShortfall.memory(foundGb: 8), + const RequirementShortfall.processor(foundCores: 4), + ]); + }); + + test('a reading that failed is not held against the computer', () { + expect(findShortfalls(const SystemHardware()), isEmpty); + expect(findShortfalls(hardware(cores: 12)), isEmpty); + expect( + findShortfalls(hardware(gb: 8)), + [const RequirementShortfall.memory(foundGb: 8)], + ); + }); + + test('are worded for the dialog', () { + const memory = RequirementShortfall.memory(foundGb: 8); + expect(memory.label, 'Memory'); + expect(memory.foundText, '8 GB'); + expect(memory.neededText, '16 GB needed'); + + const processor = RequirementShortfall.processor(foundCores: 4); + expect(processor.label, 'Processor'); + expect(processor.foundText, '4 cores'); + expect(processor.neededText, '8 cores needed'); + expect( + const RequirementShortfall.processor(foundCores: 1).foundText, + '1 core', + ); + }); + }); + + group('the launch gate', () { + setUp(() => SharedPreferences.setMockInitialValues({})); + + Future launch({double gb = 8, int cores = 4}) => + SystemRequirementsController.create( + hardware: hardware(gb: gb, cores: cores), + ); + + test('is not raised on a computer that meets the requirements', () async { + final requirements = await launch(gb: 16, cores: 8); + + expect(requirements.blocksLaunch, isFalse); + expect(requirements.shortfalls, isEmpty); + }); + + test('is raised on one that falls short', () async { + final requirements = await launch(); + + expect(requirements.blocksLaunch, isTrue); + expect(requirements.shortfalls, hasLength(2)); + }); + + test('Try Anyway lifts it, and tells whoever is listening', () async { + final requirements = await launch(); + var notified = 0; + requirements.addListener(() => notified++); + + await requirements.tryAnyway(); + + expect(requirements.blocksLaunch, isFalse); + // Still known to fall short: only the question is settled. + expect(requirements.shortfalls, hasLength(2)); + expect(notified, 1); + }); + + test('Try Anyway is remembered on the next launch', () async { + await (await launch()).tryAnyway(); + + expect((await launch()).blocksLaunch, isFalse); + }); + + test('a computer that reads differently later is asked again', () async { + await (await launch(gb: 8, cores: 8)).tryAnyway(); + + // The same computer, now short on cores too — a virtual machine given + // fewer, say. + expect((await launch(gb: 8, cores: 4)).blocksLaunch, isTrue); + // And one short on something else altogether. + expect((await launch(gb: 16, cores: 4)).blocksLaunch, isTrue); + }); + + test('Try Anyway on a computer that meets them does nothing', () async { + final requirements = await launch(gb: 32, cores: 16); + var notified = 0; + requirements.addListener(() => notified++); + + await requirements.tryAnyway(); + + expect(notified, 0); + final prefs = await SharedPreferences.getInstance(); + expect(prefs.getKeys(), isEmpty); + }); + }); +} diff --git a/test/support/fake_windows_system.dart b/test/support/fake_windows_system.dart index 96e4bb0..0dd179a 100644 --- a/test/support/fake_windows_system.dart +++ b/test/support/fake_windows_system.dart @@ -84,6 +84,12 @@ class FakeWindowsSystem implements WindowsSystem { return onElevated?.call(this, executable, parameters); } + /// What [installedMemoryBytes] answers; null stands for Windows not saying. + int? installedMemory; + + @override + int? installedMemoryBytes() => installedMemory; + /// Developer Mode, as the elevated `reg add` would set it. void setDeveloperMode(bool on) => values[keyFor( RegistryRoot.localMachine, kAppModelUnlockKey, kDeveloperModeValue)] = diff --git a/test/ui/system_requirements_screen_test.dart b/test/ui/system_requirements_screen_test.dart new file mode 100644 index 0000000..8fca532 --- /dev/null +++ b/test/ui/system_requirements_screen_test.dart @@ -0,0 +1,167 @@ +import 'package:appstudio/platform/system_requirements.dart'; +import 'package:appstudio/theme/app_theme.dart'; +import 'package:appstudio/ui/system_requirements_screen.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:shad/shad.dart'; + +import '../../widgetbook/fakes/project.dart'; + +void main() { + const title = 'App Studio is unlikely to run on this computer'; + const both = [ + RequirementShortfall.memory(foundGb: 8), + RequirementShortfall.processor(foundCores: 4), + ]; + + Future pump(WidgetTester tester, Widget home) async { + tester.view.physicalSize = const Size(1280, 800); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget(ShadApp(theme: buildLightTheme(), home: home)); + await tester.pumpAndSettle(); + } + + group('the dialog', () { + Future> pumpDialog( + WidgetTester tester, { + List shortfalls = both, + VoidCallback? onQuit, + }) async { + final results = []; + await pump( + tester, + Builder( + builder: (context) => Center( + child: ShadButton( + onPressed: () async => results.add( + await showShadDialog( + context: context, + barrierDismissible: false, + builder: (_) => SystemRequirementsDialog( + shortfalls: shortfalls, + onQuit: onQuit ?? () {}, + ), + ), + ), + child: const Text('open'), + ), + ), + ), + ); + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + return results; + } + + testWidgets('says what the computer has against what is needed', + (tester) async { + await pumpDialog(tester); + + expect(find.text(title), findsOneWidget); + for (final text in const [ + 'Memory', + '8 GB', + '16 GB needed', + 'Processor', + '4 cores', + '8 cores needed', + ]) { + expect(find.text(text), findsOneWidget, reason: text); + } + expect(tester.takeException(), isNull); + }); + + testWidgets('lists only what falls short', (tester) async { + await pumpDialog( + tester, + shortfalls: const [RequirementShortfall.memory(foundGb: 12)], + ); + + expect(find.text('12 GB'), findsOneWidget); + expect(find.text('Processor'), findsNothing); + }); + + testWidgets('Quit is on the right of Try Anyway', (tester) async { + await pumpDialog(tester); + + expect( + tester.getCenter(find.text('Quit')).dx, + greaterThan(tester.getCenter(find.text('Try Anyway')).dx), + ); + }); + + testWidgets('Try Anyway answers yes', (tester) async { + final results = await pumpDialog(tester); + + await tester.tap(find.text('Try Anyway')); + await tester.pumpAndSettle(); + + expect(results, [true]); + expect(find.text(title), findsNothing); + }); + + testWidgets('Quit quits, and nothing else', (tester) async { + var quits = 0; + final results = await pumpDialog(tester, onQuit: () => quits++); + + await tester.tap(find.text('Quit')); + await tester.pumpAndSettle(); + + expect(quits, 1); + expect(results, isEmpty); + }); + + testWidgets('Escape does not answer for the user', (tester) async { + final results = await pumpDialog(tester); + + await tester.sendKeyEvent(LogicalKeyboardKey.escape); + await tester.pumpAndSettle(); + + expect(find.text(title), findsOneWidget); + expect(results, isEmpty); + }); + }); + + group('the screen', () { + testWidgets('asks as soon as it is up', (tester) async { + await pump( + tester, + SystemRequirementsScreen( + requirements: FakeSystemRequirements(shortfalls: both), + ), + ); + + expect(find.text(title), findsOneWidget); + }); + + testWidgets('Try Anyway is passed on, and the question goes', + (tester) async { + final requirements = FakeSystemRequirements(shortfalls: both); + await pump(tester, SystemRequirementsScreen(requirements: requirements)); + + await tester.tap(find.text('Try Anyway')); + await tester.pumpAndSettle(); + + expect(requirements.triedAnyway, 1); + expect(requirements.blocksLaunch, isFalse); + expect(find.text(title), findsNothing); + }); + + testWidgets('a question the app cleared away is asked again', + (tester) async { + final requirements = FakeSystemRequirements(shortfalls: both); + await pump(tester, SystemRequirementsScreen(requirements: requirements)); + + // What `_clearPushedRoutes` does when the app swaps its screen. + tester + .state(find.byType(Navigator)) + .popUntil((route) => route.isFirst); + await tester.pumpAndSettle(); + + expect(find.text(title), findsOneWidget); + expect(requirements.triedAnyway, 0); + }); + }); +} diff --git a/widgetbook/fakes/project.dart b/widgetbook/fakes/project.dart index 3d21856..bfce0d0 100644 --- a/widgetbook/fakes/project.dart +++ b/widgetbook/fakes/project.dart @@ -4,6 +4,7 @@ library; import 'dart:async'; +import 'package:appstudio/platform/system_requirements.dart'; import 'package:appstudio/process/database_repair_view.dart'; import 'package:appstudio/process/full_restart_view.dart'; import 'package:appstudio/process/new_project_view.dart'; @@ -221,6 +222,26 @@ class FakeDatabaseRepair extends ChangeNotifier implements DatabaseRepairView { } } +/// A computer that falls short by [shortfalls], until Try Anyway. +class FakeSystemRequirements extends ChangeNotifier + implements SystemRequirementsView { + FakeSystemRequirements({required this.shortfalls}); + + @override + final List shortfalls; + + int triedAnyway = 0; + + @override + bool get blocksLaunch => shortfalls.isNotEmpty && triedAnyway == 0; + + @override + Future tryAnyway() async { + triedAnyway++; + notifyListeners(); + } +} + class FakeExternalEditors extends ChangeNotifier implements ExternalEditorsView { FakeExternalEditors({this.editors = const [], this.canOpen = true}); diff --git a/widgetbook/use_cases/first_run.dart b/widgetbook/use_cases/first_run.dart index a60bd34..6d04fd5 100644 --- a/widgetbook/use_cases/first_run.dart +++ b/widgetbook/use_cases/first_run.dart @@ -1,8 +1,10 @@ +import 'package:appstudio/platform/system_requirements.dart'; import 'package:appstudio/toolchain/install_plan.dart'; import 'package:appstudio/toolchain/tool_status.dart'; import 'package:appstudio/toolchain/tool_version.dart'; import 'package:appstudio/ui/toolchain/toolchain_notices.dart'; import 'package:appstudio/ui/toolchain/toolchain_setup_dialog.dart'; +import 'package:appstudio/ui/system_requirements_screen.dart'; import 'package:appstudio/ui/toolchain/toolchain_setup_screen.dart'; import 'package:flutter/widgets.dart'; import 'package:widgetbook/widgetbook.dart'; @@ -71,6 +73,29 @@ DialogUseCase _onLanding(Widget dialog) => final firstRunFolder = WidgetbookFolder( name: 'First run', children: [ + WidgetbookComponent( + name: 'Below requirements', + useCases: [ + for (final (name, shortfalls) in const [ + ( + 'Memory and processor', + [ + RequirementShortfall.memory(foundGb: 8), + RequirementShortfall.processor(foundCores: 4), + ], + ), + ('Memory only', [RequirementShortfall.memory(foundGb: 12)]), + ('Processor only', [RequirementShortfall.processor(foundCores: 4)]), + ]) + WidgetbookUseCase( + name: name, + // Quit is `exit(0)` in the app; here it would close Widgetbook. + builder: (_) => _onLanding( + SystemRequirementsDialog(shortfalls: shortfalls, onQuit: () {}), + ), + ), + ], + ), WidgetbookComponent( name: 'Setup screen', useCases: [