From 3704d34f74a74990c8a3eeabd1d074019bcc7100 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Mon, 20 Jul 2026 13:47:38 +0200 Subject: [PATCH] Fix the web instrument's arming flag, and let the wrapper redirect its paths Two things found while verifying the >=100fps done-condition at 4K. `bool.fromEnvironment` only accepts the literal `true`, so `--dart-define=TODO_FRAME_STATS=1` silently evaluated to false and the web instrument emitted nothing at all -- a whole measurement run produced no data and looked like the callback was broken. It now reads the value as a string and accepts either form. The wrapper gains --backlog-path/--log-path. Verification needs to point the server somewhere harmless: it starts an app whose store may be empty, and an empty store exports over the real ~/todo/BACKLOG.md through the very endpoint being tested. Co-Authored-By: Claude Opus 4.8 (1M context) --- bin/todo_desktop.dart | 8 ++++++-- lib/frame_stats_web.dart | 10 +++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/todo_desktop.dart b/bin/todo_desktop.dart index 094547c..a1c5027 100644 --- a/bin/todo_desktop.dart +++ b/bin/todo_desktop.dart @@ -28,10 +28,14 @@ Future main(List args) async { exit(1); } + // Overridable so a verification run cannot point at the real backlog: an + // app that starts with an empty store would export over it. final server = WrapperServer( webRoot: webRoot, - backlogPath: p.join(home, 'todo', 'BACKLOG.md'), - logPath: p.join(home, '.local', 'share', 'todo-desktop', 'todo_notes.json'), + backlogPath: + _argValue(args, '--backlog-path') ?? p.join(home, 'todo', 'BACKLOG.md'), + logPath: _argValue(args, '--log-path') ?? + p.join(home, '.local', 'share', 'todo-desktop', 'todo_notes.json'), ); await server.start(_port); stdout.writeln('todo desktop serving on http://localhost:$_port'); diff --git a/lib/frame_stats_web.dart b/lib/frame_stats_web.dart index 841dba6..f6be46e 100644 --- a/lib/frame_stats_web.dart +++ b/lib/frame_stats_web.dart @@ -12,7 +12,15 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/scheduler.dart'; /// Whether the frame-stats instrument is armed for this build. -const frameStatsEnabled = bool.fromEnvironment('TODO_FRAME_STATS'); +/// +/// Read as a string rather than `bool.fromEnvironment`, which only accepts the +/// exact literal `true` — `--dart-define=TODO_FRAME_STATS=1` silently yields +/// false and the instrument produces nothing at all. +const String _frameStatsFlag = String.fromEnvironment('TODO_FRAME_STATS'); + +/// Whether the instrument is armed (`--dart-define=TODO_FRAME_STATS=1`). +const bool frameStatsEnabled = + _frameStatsFlag == '1' || _frameStatsFlag == 'true'; const _slowFrameMs = 8; const _probePeriod = Duration(milliseconds: 16);