Compare commits

..

No commits in common. "0c76dfd839e2d119f148dbc02769c35d3c2b60d8" and "96637388432e97b643b4d6c573dc3bb49b7859a4" have entirely different histories.

17 changed files with 29 additions and 93 deletions

View File

@ -108,9 +108,7 @@ jobs:
run: | run: |
flutter build apk --release \ flutter build apk --release \
--build-name="${{ steps.ver.outputs.semver }}" \ --build-name="${{ steps.ver.outputs.semver }}" \
--build-number="${{ steps.vc.outputs.code }}" \ --build-number="${{ steps.vc.outputs.code }}"
--dart-define=APP_BUILD="${{ steps.vc.outputs.code }}" \
--dart-define=APP_VERSION="${{ steps.ver.outputs.semver }}"
# Fail closed. `findByName("release") ?: debug` silently falls back to # Fail closed. `findByName("release") ?: debug` silently falls back to
# the debug key if key.properties is misplaced, producing a green build # the debug key if key.properties is misplaced, producing a green build

View File

@ -111,11 +111,11 @@ repos:
# direct URLs for one distribution, so any pin that drifts from # direct URLs for one distribution, so any pin that drifts from
# the manifest becomes an unresolvable hook environment rather # the manifest becomes an unresolvable hook environment rather
# than merely an old one. # than merely an old one.
- gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.15.1#subdirectory=gatelock - gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.14.0#subdirectory=gatelock
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync - crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync
- freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays - freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays
- sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.5#subdirectory=sickdays - sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.5#subdirectory=sickdays
- rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.2.0#subdirectory=rtdb_relay - rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.1.1#subdirectory=rtdb_relay
- claude-agent-sdk==0.2.183 - claude-agent-sdk==0.2.183
- httpx==0.28.1 - httpx==0.28.1
- mcp>=2,<3 - mcp>=2,<3

View File

@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.9.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-all.zip

View File

@ -3,9 +3,6 @@
library; library;
import 'dart:async'; import 'dart:async';
import 'package:crdt_sync_flutter/crdt_sync_flutter.dart'
show AppErrors, AppErrorsConfig, AppErrorsRouteObserver, installAppErrors;
import 'package:diet_guard_app/screens/log_meal_screen.dart'; import 'package:diet_guard_app/screens/log_meal_screen.dart';
import 'package:diet_guard_app/services/app_settings_service.dart'; import 'package:diet_guard_app/services/app_settings_service.dart';
import 'package:diet_guard_app/services/background_tasks.dart'; import 'package:diet_guard_app/services/background_tasks.dart';
@ -13,7 +10,6 @@ import 'package:diet_guard_app/services/body_service.dart';
import 'package:diet_guard_app/services/budget_history_service.dart'; import 'package:diet_guard_app/services/budget_history_service.dart';
import 'package:diet_guard_app/services/claude_relay_client.dart'; import 'package:diet_guard_app/services/claude_relay_client.dart';
import 'package:diet_guard_app/services/claude_relay_firebase.dart'; import 'package:diet_guard_app/services/claude_relay_firebase.dart';
import 'package:diet_guard_app/services/firebase_client.dart' show openFirebase;
import 'package:diet_guard_app/services/foodbank_service.dart'; import 'package:diet_guard_app/services/foodbank_service.dart';
import 'package:diet_guard_app/services/frame_stats.dart'; import 'package:diet_guard_app/services/frame_stats.dart';
import 'package:diet_guard_app/services/kuchnia_credential_service.dart'; import 'package:diet_guard_app/services/kuchnia_credential_service.dart';
@ -27,27 +23,9 @@ import 'package:material_ui/material_ui.dart';
Future<void> main() async { Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
// Every error and every wait over 1 s goes to the PC's app-errors ingest,
// which files a board ticket (kuhyx/utils DOCS-app-errors.md). The release
// build passes the versionCode and name as dart-defines (release-apk.yml).
final errors = await installAppErrors(
const AppErrorsConfig(
app: 'diet-guard',
repo: 'kuhyx/diet-guard',
package: 'diet_guard_app',
// 0 unless the release build passes --dart-define=APP_BUILD.
// ignore: avoid_redundant_argument_values
build: int.fromEnvironment('APP_BUILD'),
version: String.fromEnvironment('APP_VERSION'),
),
);
// Before anything that stamps an Hlc or syncs: until this resolves, the // Before anything that stamps an Hlc or syncs: until this resolves, the
// device id falls back to the pre-migration role constant. // device id falls back to the pre-migration role constant.
final deviceId = await initSyncDeviceId(); await initSyncDeviceId();
errors.connect(
sink: () async => (await openFirebase())?.patchValues,
deviceId: () async => deviceId,
);
await LogStorageService.init(); await LogStorageService.init();
await AppSettingsService.init(); await AppSettingsService.init();
await BudgetHistoryService.init(); await BudgetHistoryService.init();
@ -77,25 +55,19 @@ Future<void> main() async {
// coverage:ignore-start // coverage:ignore-start
if (frameStatsEnabled) startFrameStats(); if (frameStatsEnabled) startFrameStats();
// coverage:ignore-end // coverage:ignore-end
runApp(DietGuardApp(errors: errors)); runApp(const DietGuardApp());
} }
/// Root widget for the Diet Guard companion app. /// Root widget for the Diet Guard companion app.
class DietGuardApp extends StatelessWidget { class DietGuardApp extends StatelessWidget {
/// Creates the [DietGuardApp] root widget. /// Creates the [DietGuardApp] root widget.
const DietGuardApp({this.errors, super.key}); const DietGuardApp({super.key});
/// App-wide error reporting; null in widget tests.
final AppErrors? errors;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
title: 'Diet Guard', title: 'Diet Guard',
theme: buildAppTheme(), theme: buildAppTheme(),
navigatorObservers: [
if (errors case final errors?) AppErrorsRouteObserver(errors),
],
home: const LogMealScreen(), home: const LogMealScreen(),
); );
} }

View File

@ -9,7 +9,6 @@ library;
import 'dart:async'; import 'dart:async';
import 'package:crdt_sync_flutter/crdt_sync_flutter.dart' show WaitWatch;
import 'package:diet_guard_app/models/day_status.dart'; import 'package:diet_guard_app/models/day_status.dart';
import 'package:diet_guard_app/models/period_average.dart'; import 'package:diet_guard_app/models/period_average.dart';
import 'package:diet_guard_app/screens/history_screen.dart'; import 'package:diet_guard_app/screens/history_screen.dart';
@ -154,7 +153,7 @@ class _CalendarScreenState extends State<CalendarScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (_loading) { if (_loading) {
return const Scaffold(body: WaitWatch.centered('calendar.load')); return const Scaffold(body: Center(child: CircularProgressIndicator()));
} }
return Scaffold( return Scaffold(
appBar: AppBar(), appBar: AppBar(),

View File

@ -8,7 +8,6 @@ library;
import 'dart:async'; import 'dart:async';
import 'package:crdt_sync_flutter/crdt_sync_flutter.dart' show WaitWatch;
import 'package:diet_guard_app/models/food_bank_record.dart'; import 'package:diet_guard_app/models/food_bank_record.dart';
import 'package:diet_guard_app/services/foodbank_service.dart'; import 'package:diet_guard_app/services/foodbank_service.dart';
import 'package:diet_guard_app/widgets/food_bank/fb_add_entry_dialog.dart'; import 'package:diet_guard_app/widgets/food_bank/fb_add_entry_dialog.dart';
@ -184,7 +183,7 @@ class _FoodBankScreenState extends State<FoodBankScreen> {
], ],
), ),
body: all == null body: all == null
? const WaitWatch.centered('food_bank.load') ? const Center(child: CircularProgressIndicator())
: _displayed.isEmpty : _displayed.isEmpty
? Center( ? Center(
child: Icon( child: Icon(

View File

@ -8,7 +8,6 @@ library;
import 'dart:async'; import 'dart:async';
import 'package:crdt_sync_flutter/crdt_sync_flutter.dart' show WaitWatch;
import 'package:diet_guard_app/services/firebase_client.dart'; import 'package:diet_guard_app/services/firebase_client.dart';
import 'package:diet_guard_app/services/github_client_factory.dart'; import 'package:diet_guard_app/services/github_client_factory.dart';
import 'package:diet_guard_app/services/sync_health.dart'; import 'package:diet_guard_app/services/sync_health.dart';
@ -101,7 +100,7 @@ class _GitHubMirrorScreenState extends State<GitHubMirrorScreen>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (_loading) { if (_loading) {
return const Scaffold(body: WaitWatch.centered('github_mirror.load')); return const Scaffold(body: Center(child: CircularProgressIndicator()));
} }
return Scaffold( return Scaffold(
// No title and no explanatory paragraph: the code glyph that opened this // No title and no explanatory paragraph: the code glyph that opened this

View File

@ -7,7 +7,6 @@ library;
import 'dart:async'; import 'dart:async';
import 'package:crdt_sync_flutter/crdt_sync_flutter.dart' show WaitWatch;
import 'package:diet_guard_app/models/food_entry.dart'; import 'package:diet_guard_app/models/food_entry.dart';
import 'package:diet_guard_app/screens/edit_entry_screen.dart'; import 'package:diet_guard_app/screens/edit_entry_screen.dart';
import 'package:diet_guard_app/services/log_storage_service.dart'; import 'package:diet_guard_app/services/log_storage_service.dart';
@ -190,7 +189,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
], ],
), ),
body: allEntries == null body: allEntries == null
? const WaitWatch.centered('history.load') ? const Center(child: CircularProgressIndicator())
: _displayed.isEmpty : _displayed.isEmpty
? Center( ? Center(
child: Icon( child: Icon(

View File

@ -15,7 +15,6 @@
/// encrypted either. /// encrypted either.
library; library;
import 'package:crdt_sync_flutter/crdt_sync_flutter.dart' show WaitWatch;
import 'package:diet_guard_app/services/kuchnia_client.dart'; import 'package:diet_guard_app/services/kuchnia_client.dart';
import 'package:diet_guard_app/services/kuchnia_credential_service.dart'; import 'package:diet_guard_app/services/kuchnia_credential_service.dart';
import 'package:diet_guard_app/services/kuchnia_import.dart'; import 'package:diet_guard_app/services/kuchnia_import.dart';
@ -189,12 +188,9 @@ class _KuchniaSettingsSectionState extends State<KuchniaSettingsSection> {
IconButton.outlined( IconButton.outlined(
onPressed: canFetch && !_busy ? _fetch : null, onPressed: canFetch && !_busy ? _fetch : null,
icon: _busy icon: _busy
? const WaitWatch( ? const SizedBox.square(
operation: 'kuchnia.sync', dimension: 20,
child: SizedBox.square( child: CircularProgressIndicator(strokeWidth: 2),
dimension: 20,
child: CircularProgressIndicator(strokeWidth: 2),
),
) )
: const Icon( : const Icon(
Icons.local_shipping_outlined, Icons.local_shipping_outlined,

View File

@ -8,7 +8,6 @@
/// send or log. /// send or log.
library; library;
import 'package:crdt_sync_flutter/crdt_sync_flutter.dart' show WaitWatch;
import 'package:diet_guard_app/ui/theme.dart'; import 'package:diet_guard_app/ui/theme.dart';
import 'package:material_ui/material_ui.dart'; import 'package:material_ui/material_ui.dart';
@ -128,13 +127,10 @@ class MealActionRow extends StatelessWidget {
); );
Widget _claudeFace() => switch (claude) { Widget _claudeFace() => switch (claude) {
ClaudeButtonState.sending => const WaitWatch( ClaudeButtonState.sending => const SizedBox(
operation: 'claude.estimate', width: 24,
child: SizedBox( height: 24,
width: 24, child: CircularProgressIndicator(strokeWidth: 3),
height: 24,
child: CircularProgressIndicator(strokeWidth: 3),
),
), ),
ClaudeButtonState.queued => const Icon( ClaudeButtonState.queued => const Icon(
Icons.hourglass_top, Icons.hourglass_top,

View File

@ -166,11 +166,11 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: crdt_sync_flutter path: crdt_sync_flutter
ref: "crdt_sync_flutter-v0.9.0" ref: "crdt_sync_flutter-v0.8.3"
resolved-ref: dfc5d07f5225ed15609f9709748ed2efd6cc4d1d resolved-ref: "6e3f86ef0d73ba45db975bf03915fecce8a60f98"
url: "https://github.com/kuhyx/utils" url: "https://github.com/kuhyx/utils"
source: git source: git
version: "0.9.0" version: "0.8.3"
cross_file: cross_file:
dependency: transitive dependency: transitive
description: description:

View File

@ -2,7 +2,7 @@ name: diet_guard_app
description: "Companion phone app for diet_guard: log meals on the go." description: "Companion phone app for diet_guard: log meals on the go."
publish_to: 'none' publish_to: 'none'
version: 1.0.178+1 version: 1.0.177+1
environment: environment:
sdk: ^3.12.2 sdk: ^3.12.2
@ -18,7 +18,7 @@ dependencies:
crdt_sync_flutter: crdt_sync_flutter:
git: git:
url: https://github.com/kuhyx/utils url: https://github.com/kuhyx/utils
ref: crdt_sync_flutter-v0.9.0 ref: crdt_sync_flutter-v0.8.3
path: crdt_sync_flutter path: crdt_sync_flutter
crypto: 3.0.8 crypto: 3.0.8
cryptography: 2.9.0 cryptography: 2.9.0

View File

@ -52,14 +52,9 @@ _logger = logging.getLogger(__name__)
FETCH_TIMEOUT_S = 5.0 FETCH_TIMEOUT_S = 5.0
#: Names served lazily by ``__getattr__`` (read statically by
#: scripts/check_patch_targets.py when the catering client cannot import).
_LAZY_ATTRS = ("refresh_delivery",)
def __getattr__(name: str) -> object: def __getattr__(name: str) -> object:
"""Resolve the deferred catering import on first attribute access.""" """Resolve the deferred catering import on first attribute access."""
if name not in _LAZY_ATTRS: if name != "refresh_delivery":
msg = f"module {__name__!r} has no attribute {name!r}" msg = f"module {__name__!r} has no attribute {name!r}"
raise AttributeError(msg) raise AttributeError(msg)
return import_module("diet_guard._kuchnia_import").refresh_delivery return import_module("diet_guard._kuchnia_import").refresh_delivery

View File

@ -3,7 +3,7 @@
The phone sends a food description and/or a photo. A worker on the PC runs The phone sends a food description and/or a photo. A worker on the PC runs
Claude on kuhy's Max subscription, **logs the meal at once (no review)** and Claude on kuhy's Max subscription, **logs the meal at once (no review)** and
answers the phone. Transport is Firebase RTDB through the shared answers the phone. Transport is Firebase RTDB through the shared
`rtdb_relay` package (`kuhyx/utils`, tag `rtdb-relay-v0.2.0`), the same wire `rtdb_relay` package (`kuhyx/utils`, tag `rtdb-relay-v0.1.1`), the same wire
format as the tutor app. No VPN, no open port, only kuhy's Google account. format as the tutor app. No VPN, no open port, only kuhy's Google account.
This file is the contract both halves build against. The fixture This file is the contract both halves build against. The fixture

View File

@ -4,7 +4,7 @@ version = "1.0.0"
description = "Tkinter/systemd log-to-unlock meal gate with calorie/macro budget tracking" description = "Tkinter/systemd log-to-unlock meal gate with calorie/macro budget tracking"
requires-python = ">=3.14" requires-python = ">=3.14"
dependencies = [ dependencies = [
"gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.15.1#subdirectory=gatelock", "gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.14.0#subdirectory=gatelock",
"crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync", "crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync",
"freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays", "freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays",
"holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds", "holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds",
@ -13,7 +13,7 @@ dependencies = [
"defusedxml==0.7.1", "defusedxml==0.7.1",
"httpx==0.28.1", "httpx==0.28.1",
"requests==2.34.2", "requests==2.34.2",
"rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.2.0#subdirectory=rtdb_relay", "rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.1.1#subdirectory=rtdb_relay",
] ]
# Optional extras. The `mcp` group is ONLY needed by the MCP server # Optional extras. The `mcp` group is ONLY needed by the MCP server

View File

@ -7,7 +7,7 @@ coverage==7.17.3
crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync
defusedxml==0.7.1 defusedxml==0.7.1
freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays
gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.15.1#subdirectory=gatelock gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.14.0#subdirectory=gatelock
holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds
httpx==0.28.1 httpx==0.28.1
hypothesis==6.170.15 hypothesis==6.170.15
@ -23,6 +23,6 @@ pytest-sugar==1.1.1
pytest-xdist==3.8.0 pytest-xdist==3.8.0
pytest-xvfb==3.1.1 pytest-xvfb==3.1.1
requests==2.34.2 requests==2.34.2
rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.2.0#subdirectory=rtdb_relay rtdb-relay @ git+https://github.com/kuhyx/utils@rtdb-relay-v0.1.1#subdirectory=rtdb_relay
ruff==0.17.5 ruff==0.17.5
sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.5#subdirectory=sickdays sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.5#subdirectory=sickdays

View File

@ -65,21 +65,6 @@ def _third_party_missing(exc: ImportError) -> bool:
return isinstance(exc, ModuleNotFoundError) and not missing.startswith(PACKAGE) return isinstance(exc, ModuleNotFoundError) and not missing.startswith(PACKAGE)
def _lazy_names(value: ast.expr | None) -> list[str]:
"""The names a PEP 562 ``_LAZY_ATTRS`` table (dict keys or a tuple) serves."""
if isinstance(value, ast.Dict):
items: list[ast.expr | None] = list(value.keys)
elif isinstance(value, (ast.Tuple, ast.List, ast.Set)):
items = list(value.elts)
else:
return []
return [
i.value
for i in items
if isinstance(i, ast.Constant) and isinstance(i.value, str)
]
def defined_statically(parts: list[str], split: int) -> bool: def defined_statically(parts: list[str], split: int) -> bool:
"""Whether ``parts[split]`` is a top-level name of module ``parts[:split]``. """Whether ``parts[split]`` is a top-level name of module ``parts[:split]``.
@ -96,8 +81,6 @@ def defined_statically(parts: list[str], split: int) -> bool:
elif isinstance(node, (ast.Assign, ast.AnnAssign)): elif isinstance(node, (ast.Assign, ast.AnnAssign)):
targets = node.targets if isinstance(node, ast.Assign) else [node.target] targets = node.targets if isinstance(node, ast.Assign) else [node.target]
names = [t.id for t in targets if isinstance(t, ast.Name)] names = [t.id for t in targets if isinstance(t, ast.Name)]
if "_LAZY_ATTRS" in names:
names += _lazy_names(node.value)
elif isinstance(node, (ast.Import, ast.ImportFrom)): elif isinstance(node, (ast.Import, ast.ImportFrom)):
names = [(a.asname or a.name).split(".")[0] for a in node.names] names = [(a.asname or a.name).split(".")[0] for a in node.names]
else: else: