Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2ac4f44
Bridge ILogger to logcat on Android (#23)
Apr 18, 2026
55f63d5
Enable Release file logging + document ILogger conventions (#23)
Apr 18, 2026
7ac869b
Inject INavigationService, IPreferences, IDispatcher into PageModels …
Apr 18, 2026
e4cd4b0
Batch MediaListSection mutations during pull-to-refresh merge (#59)
Apr 18, 2026
648fd37
CI: Update UI screenshots [skip ci]
github-actions[bot] Apr 18, 2026
8641b95
Register IPreferences in DI + address PR #61 review feedback
Apr 19, 2026
28febaf
Expand ani-review checklist with engineering hygiene sections
Apr 19, 2026
5b5a4a5
CI: Update UI screenshots [skip ci]
github-actions[bot] Apr 19, 2026
1154fd3
Materialize new MediaListSection before publishing to observers
Apr 19, 2026
77ce662
CI: Update UI screenshots [skip ci]
github-actions[bot] Apr 19, 2026
95dde97
Add regression test for new-section materialization
Apr 19, 2026
6be5175
CI: Update UI screenshots [skip ci]
github-actions[bot] Apr 19, 2026
6b10922
Enhance bulk update handling in MediaListSection and improve test ass…
Apr 19, 2026
87c3f12
CI: Update UI screenshots [skip ci]
github-actions[bot] Apr 19, 2026
0ac5028
Enhance logging in AndroidLogcatLoggerProvider and improve bulk updat…
Apr 19, 2026
5263d4b
Merge branch 'chore/logging-tests-batching' of https://github.com/zho…
Apr 19, 2026
b43a676
CI: Update UI screenshots [skip ci]
github-actions[bot] Apr 19, 2026
e9505c2
Enhance documentation for ApplyFilter method and improve resource man…
Apr 19, 2026
5832be2
CI: Update UI screenshots [skip ci]
github-actions[bot] Apr 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .claude/skills/ani-review/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,65 @@ Review all code written in this session against the checklist below. Fix every i

- Verified what exceptions methods actually throw before catching them

**Public API surface**

- Changes to public/internal types considered for callers inside and outside the session's scope
- Breaking changes to shared types flagged explicitly

**Error handling**

- Failures visible to the user (via `ErrorReportService` / Sentry / UI state) rather than silently swallowed
- `catch { }` and `catch (Exception) { logger.LogDebug(...) }` patterns scrutinized — is swallowing actually correct here?

**Logging**

- New error paths have log statements at the right level
- No logging inside tight loops or hot paths that could flood logcat/file log
- Log messages use structured parameters, not string interpolation

**Tests**

- New behavior has new tests; changed behavior has updated tests
- Bug fixes include a regression test that fails without the fix
- Tests cover failure paths, not just the happy path

**Build & test health**

- `dotnet build` passes with zero warnings
- `dotnet test` green locally before presenting
- No `#pragma warning disable` or `!` null-suppressions added without a comment explaining why

**Dead code**

- After refactors: removed usings, unreferenced private members, unused parameters, orphaned files
- No commented-out code left behind

**Scope discipline**

- Change stays within what the task required — no opportunistic renames, reorders, or unrelated fixups bundled in. If unrelated issues are spotted during the work, note them and consider filing an issue rather than fixing them in the same change
- No half-finished work (stubbed methods, `throw new NotImplementedException()`, empty branches) unless tracked by an issue referenced in a comment

**Conventions**

- New code matches surrounding style (naming, file organization, access modifiers, async patterns)
- New abstractions follow existing patterns rather than introducing parallel ones

**Comments and docs**

- Match the final code, not an earlier draft

**TODOs**

- No new `TODO` / `FIXME` / `HACK` left behind unless tracked in an issue (reference the issue number)

**All callers/call sites**

- Checked existing code that interacts with what changed

**Commit-readiness**

- If multiple commits are planned, each builds and tests green on its own

**Documentation**

- Check all repo docs for sections that need updating based on the changes: `README.md`, `AGENTS.md`, `CLAUDE.md`, and any relevant skill files under `.claude/skills/` (e.g. `project-architecture`, `airing-notifications`, `ani-debug`)
Expand Down
11 changes: 7 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
## Architecture

- **.NET MAUI Android-only** app (`net10.0-android`; `SupportedOSPlatformVersion` 31.0), single project in `src/`. App ID: `com.RainbowSprinkles.AniSprinkles`.
- **MVVM** via CommunityToolkit.Mvvm: PageModels extend `ObservableObject`, use `[ObservableProperty]`, `[RelayCommand]`, `[NotifyPropertyChangedFor]`. Shell flyout navigation (`my-anime`, `settings`) with a programmatic `media-details` route. Navigate via `Shell.Current.GoToAsync` with lightweight query params — never full objects.
- **MVVM** via CommunityToolkit.Mvvm: PageModels extend `ObservableObject`, use `[ObservableProperty]`, `[RelayCommand]`, `[NotifyPropertyChangedFor]`. Shell flyout navigation (`my-anime`, `settings`) with a programmatic `media-details` route. PageModels navigate through the injected `INavigationService` (routes + lightweight query params — never full objects); persist state via the injected `IPreferences`; marshal pool-thread continuations back to the UI via the injected `IDispatcher`. View-facing UX calls (`Shell.Current.DisplayAlertAsync`, `ShowPopupAsync`, `Browser.Default`) are allowed to keep using MAUI statics because they only run inside view-attached paths.
- **DI**: Services and flyout PageModels (`MyAnimePageModel`, `SettingsPageModel`) are singleton. All Pages and `MediaDetailsPageModel` are transient. See `/project-architecture` for the full DI table and page patterns.
- **Services**: `AuthService` (OAuth + SecureStorage), `AniListClient` (GraphQL + viewer ID cache), `ErrorReportService` (Sentry + `ILogger` + token redaction), `FileLoggerProvider` (rotating async file log, Debug only), `LoggingHandler` (HTTP DelegatingHandler), `AiringNotificationService` (WorkManager periodic check). See `/airing-notifications` for the notification subsystem.
- **Services**: `AuthService` (OAuth + SecureStorage), `AniListClient` (GraphQL + viewer ID cache), `ErrorReportService` (Sentry + `ILogger` + token redaction), `FileLoggerProvider` (rotating async file log, Debug = 1 MB × 3 / Release = 256 KB × 3), `AndroidLogcatLoggerProvider` (bridges `ILogger` → `adb logcat` on Android), `LoggingHandler` (HTTP DelegatingHandler), `AiringNotificationService` (WorkManager periodic check). See `/airing-notifications` for the notification subsystem.
- **Global usings** (`GlobalUsings.cs`): `Models`, `PageModels`, `Pages`, `Services`, `IconFont.Maui.FluentIcons`. `Converters` and `Utilities` require explicit `using`.
- **Key NuGet packages**: `Microsoft.Maui.Controls`, `CommunityToolkit.Mvvm`, `CommunityToolkit.Maui`, `Sentry.Maui`, `Syncfusion.Maui.Toolkit`, `IconFont.Maui.FluentIcons`.

Expand Down Expand Up @@ -45,7 +45,7 @@ dotnet test tests/AniSprinkles.UnitTests/AniSprinkles.UnitTests.csproj -c Debug

- **CI**: GitHub Actions `android-release.yml` triggers on Release publication (or manual `workflow_dispatch`). `promote-release.yml` promotes between Play Console tracks (internal → alpha → beta → production).
- **Version scheme**: `ApplicationDisplayVersion` from release tag semver (`vX.Y.Z` → `X.Y.Z`); `ApplicationVersion` (versionCode) from `YYMMDDNNN` (date + run_number mod 1000).
- **Unit tests** — `tests/AniSprinkles.UnitTests/` (xUnit, `net10.0`). Pure-algorithm tests only; the project link-compiles specific source files from `src/` rather than project-referencing the MAUI app (the main `net10.0-android` TFM is not a valid reference target for plain `net10.0`). If you add tests that need MAUI types, either link-compile a non-MAUI partial, or pass concrete dependencies in as parameters the way `MediaListSectionsMerger` does. `tests/AniSprinkles.UITests/` is still a scaffold for future device tests.
- **Unit tests** — `tests/AniSprinkles.UnitTests/` (xUnit, `net10.0`, NSubstitute). Pure-algorithm tests only; the project link-compiles specific source files from `src/` rather than project-referencing the MAUI app (the main `net10.0-android` TFM is not a valid reference target for plain `net10.0`). `Microsoft.Maui.Essentials` and `Microsoft.Maui.Core` resolve on `net10.0` and supply `IPreferences` / `IDispatcher` for test doubles; `Microsoft.Maui.Controls` and `CommunityToolkit.Maui` do not, so PageModel tests require link-compiling a non-UX partial (deferred until PageModels are split or an `AniSprinkles.Core` class library is extracted). `tests/AniSprinkles.UITests/` is still a scaffold for future device tests.

## CI Stubs (`-p:CiBuild=true`)

Expand All @@ -64,7 +64,10 @@ The project must build with **zero warnings**. Do not introduce new warnings; fi
## Project Conventions

- **MAUI-first guidance**: do not mix WPF/Xamarin.Forms/Blazor/React patterns unless explicitly requested. Verify MAUI APIs against official Microsoft docs and current project code before recommending.
- **Logging**: `ILogger` with structured messages. Debug file logs guarded with `#if DEBUG`. Bearer tokens always redacted.
- **Logging**: `ILogger<T>` injected via DI is the canonical path for all app code. Use structured messages. Bearer tokens are always redacted.
- Provider wiring lives in `MauiProgram.cs`. `FileLoggerProvider` runs in both Debug (1 MB × 3 at `LogLevel.Debug`) and Release (256 KB × 3 at `LogLevel.Warning`). `AndroidLogcatLoggerProvider` bridges ILogger output into `adb logcat` on Android in all build configs (`AddDebug()` does not reach logcat on .NET MAUI Android). `AddDebug()` stays Debug-only.
- Exception: `Platforms/Android/MainActivity.cs` and `Platforms/Android/AiringCheckWorker.cs` call `Android.Util.Log` directly because they run before the MAUI DI container is guaranteed to be built (activity lifecycle callbacks; post-reboot WorkManager). Inline comments document this at the call sites. Do not introduce new direct-`Android.Util.Log` callers elsewhere — use ILogger.
- On-device log file: `{AppDataDirectory}/logs/anisprinkles.log` (+ `.1`, `.2` archives). Pull via `adb shell run-as com.RainbowSprinkles.AniSprinkles cat files/logs/anisprinkles.log` or use `/ani-debug`.
- **Telemetry**: Sentry crash reporting only (`SendDefaultPii = false`, `TracesSampleRate = 0.0`). Use `ErrorReportService.Record()` for handled exceptions.
- **User prefs**: `AppSettings` (static, `Utilities/`) persists title language, score format, adult content toggle, and section order via `Preferences`.

Expand Down
Binary file modified screenshots/01_my_anime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/02_one_piece_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/03_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
global using AniSprinkles.PageModels;
global using AniSprinkles.Pages;
global using AniSprinkles.Services;
global using AniSprinkles.Services.Abstractions;
global using IconFont.Maui.FluentIcons;
58 changes: 51 additions & 7 deletions src/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using AniSprinkles.Services.Maui;
using CommunityToolkit.Maui;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using Syncfusion.Maui.Toolkit.Hosting;
#if ANDROID
using AniSprinkles.Platforms.Android;
#endif

namespace AniSprinkles;

Expand Down Expand Up @@ -34,22 +39,61 @@ public static MauiApp CreateMauiApp()
fonts.AddFont("SegoeUI-Semibold.ttf", "SegoeSemibold");
});

#if DEBUG
var logDirectory = Path.Combine(FileSystem.Current.AppDataDirectory, "logs");
#if DEBUG
// Debug builds keep full verbosity for the solo-dev install. Re-evaluate the
// app-namespace level before first public release.
var fileLogMinimumLevel = LogLevel.Debug;
const long fileLogMaxBytes = 1024 * 1024; // 1 MB
const int fileLogRetainedFiles = 3;
builder.Logging.AddFilter("Microsoft", LogLevel.Warning);
builder.Logging.AddFilter("System", LogLevel.Warning);
builder.Logging.AddFilter("Sentry", LogLevel.Warning);
// Debug-level app logs are intentionally kept on for pre-production development
// (solo-dev install). Re-evaluate before first public release. Framework namespaces
// (Microsoft/System/Sentry) stay capped at Warning to avoid firehose output.
builder.Logging.AddProvider(new FileLoggerProvider(logDirectory, minimumLevel: LogLevel.Debug));
builder.Logging.AddFilter<FileLoggerProvider>(string.Empty, LogLevel.Debug);
builder.Logging.AddDebug();
#else
// Release builds keep a small on-device ring buffer for user-shared diagnostics.
// Sentry already captures Warning+ to the cloud; this is the offline fallback and
// hard-capped so it can't grow silently on long-running installs.
var fileLogMinimumLevel = LogLevel.Warning;
const long fileLogMaxBytes = 256 * 1024; // 256 KB
const int fileLogRetainedFiles = 3;
#endif

builder.Logging.AddProvider(new FileLoggerProvider(
logDirectory,
minimumLevel: fileLogMinimumLevel,
maxFileSizeBytes: fileLogMaxBytes,
retainedFiles: fileLogRetainedFiles));
builder.Logging.AddFilter<FileLoggerProvider>(string.Empty, fileLogMinimumLevel);
builder.Logging.AddFilter<FileLoggerProvider>("Microsoft", LogLevel.Warning);
builder.Logging.AddFilter<FileLoggerProvider>("System", LogLevel.Warning);
builder.Logging.AddFilter<FileLoggerProvider>("Sentry", LogLevel.Warning);
builder.Logging.AddDebug();

#if ANDROID
// AddDebug() does NOT bridge to logcat on .NET MAUI Android (verified empirically).
// Without this provider, adb logcat shows nothing from the Microsoft.Extensions.Logging
// pipeline. Registered for all build configs so device diagnostics work in Release too.
//
// Logcat is on-device developer diagnostics — kept at Debug independent of the file
// logger's per-config minimum. Release file logging stays capped at Warning (Sentry +
// 256 KB ring buffer), but `adb logcat` should still surface full ILogger output when
// a dev is attached to a Release build on a test device.
const LogLevel logcatMinimumLevel = LogLevel.Debug;
builder.Logging.AddProvider(new AndroidLogcatLoggerProvider(logcatMinimumLevel));
builder.Logging.AddFilter<AndroidLogcatLoggerProvider>(string.Empty, logcatMinimumLevel);
builder.Logging.AddFilter<AndroidLogcatLoggerProvider>("Microsoft", LogLevel.Warning);
builder.Logging.AddFilter<AndroidLogcatLoggerProvider>("System", LogLevel.Warning);
builder.Logging.AddFilter<AndroidLogcatLoggerProvider>("Sentry", LogLevel.Warning);
Comment thread
zhollis21 marked this conversation as resolved.
Resolved
#endif

// MAUI auto-registers IDispatcher via UseMauiApp, but IPreferences is only exposed as
// the static Preferences.Default — DI has no default, so resolving any PageModel that
// takes IPreferences throws InvalidOperationException at startup. Register it explicitly.
// TimeProvider is also not auto-registered; adding TryAddSingleton keeps DI-first code
// paths testable via FakeTimeProvider without forcing tests to discover a default.
builder.Services.TryAddSingleton<IPreferences>(_ => Preferences.Default);
builder.Services.TryAddSingleton(TimeProvider.System);
builder.Services.AddSingleton<INavigationService, MauiShellNavigationService>();
builder.Services.AddSingleton<ErrorReportService>();
builder.Services.AddTransient<LoggingHandler>();
builder.Services.AddSingleton(sp =>
Expand Down
6 changes: 4 additions & 2 deletions src/PageModels/MediaDetailsPageModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public partial class MediaDetailsPageModel : ObservableObject
private readonly IAniListClient _aniListClient;
private readonly IAuthService _authService;
private readonly ErrorReportService _errorReportService;
private readonly INavigationService _navigationService;
private readonly ILogger<MediaDetailsPageModel> _logger;
private int? _loadedMediaId;
private int _loadRequestSequence;
Expand Down Expand Up @@ -90,11 +91,12 @@ public partial class MediaDetailsPageModel : ObservableObject
[ObservableProperty]
private double _sliderProgress;

public MediaDetailsPageModel(IAniListClient aniListClient, IAuthService authService, ErrorReportService errorReportService, ILogger<MediaDetailsPageModel> logger)
public MediaDetailsPageModel(IAniListClient aniListClient, IAuthService authService, ErrorReportService errorReportService, INavigationService navigationService, ILogger<MediaDetailsPageModel> logger)
{
_aniListClient = aniListClient;
_authService = authService;
_errorReportService = errorReportService;
_navigationService = navigationService;
_logger = logger;
}

Expand Down Expand Up @@ -757,7 +759,7 @@ private async Task NavigateToMedia(int mediaId)
return;
}

await Shell.Current.GoToAsync("media-details", animate: false, new Dictionary<string, object>
await _navigationService.GoToAsync("media-details", animate: false, new Dictionary<string, object>
{
["mediaId"] = mediaId,
});
Expand Down
Loading
Loading