Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
13 changes: 13 additions & 0 deletions .claude/skills/ani-debug/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ MediaDetails additionally emits its own `load#N` lines (`LoadAsync enter`, `skip
### AUTH token-check (app log)
`AUTH token-check: absent | expired, signing out | valid` fires at every `AuthService.GetAccessTokenAsync` call. The "expired, signing out" path wipes SecureStorage and flips `IsAuthenticated` to false — a routine token-refresh check becoming a full sign-out. On resume after background, this is the common trigger for `PageState: Content → Unauthenticated → InitialLoading → Content`.

### FAULT (app log / logcat, Debug only)
`FAULT armed op=… kind=… scope=…(N) delay=…ms layer=… graphql=…` on arming (logcat only — the
receiver logs through `Android.Util.Log` because a broadcast can precede DI), then
`FAULT delaying <Operation> by <ms>ms` and `FAULT failing <Operation> as <Kind>` per affected call.
`FAULT http answering <Operation> with <status>` is the HTTP seam.

**Read these before diagnosing anything else in a session where faults were armed** — an injected
failure looks identical to a real one in every downstream trace (`PageState`, `LISTTRACE`, the outage
banner), because that is precisely the point. A `FAULT cleared` line, or an app restart, disarms.

Absence of `FAULT` lines in a Debug build is normal: injection ships disarmed. See `/run-anisprinkles`
for the `driver.ps1 fault` verbs.

## Drill-in

When the summary flags something, go deeper without re-running the collector:
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/project-architecture/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tests/AniSprinkles.UnitTests/ project-references Core
```

- **`src/AniSprinkles.Core/`** — `Models/`, `Utilities/`, non-platform `Services/`, `Services/Abstractions/`, `Converters/`, `Icons/`, and **all** `PageModels/`. Plain TFM so the unit tests can project-reference it. References neither `CommunityToolkit.Maui` nor `IconFont.Maui.FluentIcons`, on purpose.
- **`src/AniSprinkles/`** — `Pages/`, `Views/`, `Behaviors/`, `Platforms/`, `MauiProgram.cs`, `AuthService`, `AiringNotificationService`, the CI/ErrorSim stubs, and the `Services/Maui/` adapters implementing Core's abstractions.
- **`src/AniSprinkles/`** — `Pages/`, `Views/`, `Behaviors/`, `Platforms/`, `MauiProgram.cs`, `AuthService`, `AiringNotificationService`, the CI stubs, the Android fault-injection receiver, and the `Services/Maui/` adapters implementing Core's abstractions.

**Keep them siblings — don't nest a project inside another project's folder.** Core briefly lived at `src/AniSprinkles.Core/` while the app was still `src/AniSprinkles.csproj`, and the app's default globs swept up 602 of Core's sources plus its `obj/` generated assembly attributes. It fails as `CS0579: Duplicate 'TargetFrameworkAttribute'`, which reads like a corrupt build rather than a layout problem. `<DefaultItemExcludes>` does suppress it (one property, honoured by `Compile`/`None`/`EmbeddedResource`/`MauiXaml` alike) if you ever need the trick elsewhere — but the sibling layout means nothing needs suppressing.

Expand Down
46 changes: 46 additions & 0 deletions .claude/skills/run-anisprinkles/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,54 @@ Then drive it. Every command is `driver.ps1 <command> [args]`:
| `goto <tab>` | switch tabs: `Library`\|`Discover`\|`Search`\|`Feed`\|`Settings` — a plain label tap, so it works from inside a pushed details stack too |
| `search` | shortcut for `goto Search` |
| `logcat [n]` / `applog` | app-PID logcat tail / the on-device rotating file log |
| `fault <op> <kind> [scope]` | arm a fault on the **running** app — no rebuild (#125) |
| `fault clear` | disarm |

`driver.ps1 help` prints the same list.

### Driving error states — `fault`

Error and retry states used to be unreachable on device: the old `-p:ErrorSim=true` build failed
*every* call, so My Anime and Discover died before you could navigate to the page you wanted to
break. `fault` decorates the client instead of replacing it, so it composes with the CI fixtures —
a real screen loads, then the next call fails.

```powershell
driver.ps1 fault GetMedia ServiceOutage next # details page → error; Try Again then SUCCEEDS
driver.ps1 fault GetStudio NotFound always # studio page stays broken until cleared
driver.ps1 fault any delay next -delay 4000 # 4s latency, no failure — opens timing windows
driver.ps1 fault clear
```

- `op` — `any`, or a prefix whose meaning depends on the layer:
- `-layer client` (default) — an `IAniListClient` method name; `GetStudio` matches `GetStudioAsync`
- `-layer http` — the GraphQL `operationName`; use `Studio`, `Media`, `MediaCharactersPage`

**They are not interchangeable, and a miss is silent.** `fault GetStudio … -layer http` matches
nothing, because over the wire that operation is called `Studio`. Nor does stripping `Get`/`Async`
save you: `GetMyAnimeListAsync` is `MediaListCollection` and `SearchAnimePageAsync` is `Search`.
When a targeted http profile misses, the handler logs `FAULT http no match` naming the operation it
actually saw — grep for that if an armed fault seems to do nothing.
- `kind` — `ServiceOutage` | `Network` | `Authentication` | `RateLimited` | `NotFound` | `Unknown`,
or `delay` for latency without failure
- `scope` — `next` (default) | `always` | `firstn:N` | `everynth:N`, all deterministic

**`scope next` is the one that proves recovery**, because the fault is spent on the first call and
**Try Again** genuinely succeeds. That path — on all four details pages, plus `FavouriteToggleRunner`
and `ListOperationRunner`'s rollback snackbars — had never run on a device before this existed.

**`-delay` with no kind is how you reproduce lifecycle and debounce bugs.** The CI stubs return
instantly, so cancellation and `IsBusy`/`CanLoadMore` windows are zero-width on device; a delay is
what opens them. Arm one, navigate away mid-load, and watch whether `LoggingHandler`'s `HTTP POST` /
`HTTP 200` lines stop (#132).

`-layer http` moves injection inside the `HttpClient` pipeline so `AniListRateLimitHandler`,
`SendAsync`'s retry-once and `AniListErrorClassifier` run for real — but it needs a real signed-in
session and does **not** work with a `-p:CiBuild=true` build. Add `-graphql` there to answer HTTP 200
with a GraphQL `errors` array, which is how AniList reports many failures.

Faults are disarmed at every app start, and none of this exists in a Release build.

**The loop that works:** `dump` to see what is on screen → `tap`/`tap-desc` the
text you saw → `wait-for` the text you expect next → `shot` → `dump` again.
Never `shot` straight after a `tap` that navigates (see Gotchas).
Expand Down Expand Up @@ -289,6 +334,7 @@ works — that is what the driver above is for.
| `'X' never appeared within Ns` right after typing a query | The keyboard is covering the tab bar — `driver.ps1 back`, then `goto`. |
| `More than one device attached — set ANDROID_SERIAL to choose` | Two emulators/devices online. Pick one with `ANDROID_SERIAL=<serial>`, or shut the other down. `driver.ps1 env` lists them. |
| `sys.boot_completed never reached 1 after 180s` | The emulator attached to adb but never finished booting. Check the emulator window; a wipe-data from Device Manager usually clears it. |
| `AVD <name> never attached to adb`, and `emulator`/`qemu-system-x86_64` are running but idle (well under 1s CPU, no port in the 5554-5600 range listening) | A stale AVD lock. qemu starts, finds the AVD claimed, and hangs instead of exiting — so each retry silently adds another hung pair. Kill every `emulator`/`qemu*` process, then delete `~/.android/avd/<name>.avd/*.lock` (`hardware-qemu.ini.lock`, `multiinstance.lock`) and boot again. Run `emulator -verbose` to confirm: it prints `Running multiple emulators with the same AVD`. Check acceleration first with `emulator -accel-check` to rule out WHPX. |
| `df 'C:/Program Files/Git/data': No such file` | Git Bash path mangling — `MSYS_NO_PATHCONV=1`. |
| App runs but shows the signed-out screen | You built without `-p:CiBuild=true`. Rebuild with `driver.ps1 build`. |
| App dies instantly, `SIGABRT`, no .NET stack | APK is ~19 MB not ~97 MB — a plain `dotnet build` overwrote it. `driver.ps1 build`. |
Expand Down
80 changes: 80 additions & 0 deletions .claude/skills/run-anisprinkles/driver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,31 @@ AniSprinkles driver — pwsh .claude/skills/run-anisprinkles/driver.ps1 <command

logcat [lines] App-PID logcat tail (default 200)
applog Pull the on-device rotating file log

fault <op> <kind> [scope] Arm fault injection on the RUNNING app — no rebuild (#125)
op : 'any', or a prefix whose meaning depends on -layer:
-layer client : IAniListClient method name
e.g. GetStudio, LoadMediaCharactersPage
-layer http : GraphQL operationName
e.g. Studio, Media, MediaCharactersPage
These are NOT interchangeable — GetMyAnimeListAsync is
'MediaListCollection' over the wire, SearchAnimePageAsync
is 'Search'. A prefix that misses fires nothing; the http
handler logs the operation it saw so you can see why.
kind : ServiceOutage|Network|Authentication|RateLimited|
Comment thread
zhollis21 marked this conversation as resolved.
Resolved
NotFound|Unknown, or 'delay' for latency without failure
scope : next (default) | always | firstn:N | everynth:N
-delay <ms> Latency before the call resolves. For RateLimited
at -layer http this becomes Retry-After instead.
-layer client|http
client (default) decorates IAniListClient and composes
with the CI stubs — a real screen loads, the next call
breaks. http injects into the pipeline so the rate-limit
handler and error classifier actually run (needs a real
signed-in session; does NOT work with -p:CiBuild=true).
-graphql Answer HTTP 200 with a GraphQL errors array
instead of a status code (http layer only)
fault clear Disarm. Faults are disarmed at every app start.
"@ | Write-Host
}

Expand Down Expand Up @@ -466,6 +491,60 @@ function Cmd-AppLog {
AdbOut run-as $Package cat files/logs/anisprinkles.log
}

# Arms runtime fault injection on the already-running app (#125). Replaces the old
# -p:ErrorSim=true build flag, which meant a ~3 minute rebuild per error kind and produced a
# build where EVERY call failed, so the screen you wanted to break was unreachable.
#
# The receiver is targeted by explicit component rather than by action alone: an implicit
# broadcast to a manifest-declared receiver is not delivered reliably on modern Android, and
# the component name is pinned in C# precisely so it can be named here.
function Cmd-Fault {
param([string[]]$Argv)

$component = "$Package/.FaultReceiver"
$action = 'com.RainbowSprinkles.FAULT'

if ($Argv.Count -ge 1 -and $Argv[0].ToLowerInvariant() -eq 'clear') {
Adb shell am broadcast -n $component -a $action --ez clear true *> $null
Say 'fault cleared'
return
}

# Pull the optional flags out, leaving <op> <kind> <scope> as positionals.
$positional = @()
$delay = 0
$layer = 'client'
$graphql = $false
for ($i = 0; $i -lt $Argv.Count; $i++) {
$token = $Argv[$i]
if ($token -match '^-{1,2}delay$') { $i++; $delay = [int]$Argv[$i] }
elseif ($token -match '^-{1,2}layer$') { $i++; $layer = $Argv[$i] }
elseif ($token -match '^-{1,2}graphql$') { $graphql = $true }
else { $positional += $token }
}

if ($positional.Count -lt 1) {
throw 'fault needs an op, e.g. driver.ps1 fault GetStudio NotFound next (or: fault clear)'
}

$op = $positional[0]
$kind = if ($positional.Count -ge 2) { $positional[1] } else { 'delay' }
$scope = if ($positional.Count -ge 3) { $positional[2] } else { 'next' }

$cmd = @('shell', 'am', 'broadcast', '-n', $component, '-a', $action)
# 'any' and 'delay' are the driver's spelling for "omit this extra" — the receiver reads an
# absent op as "match everything" and an absent kind as "delay without failing".
if ($op -ne 'any') { $cmd += @('--es', 'op', $op) }
if ($kind -ne 'delay') { $cmd += @('--es', 'kind', $kind) }
$cmd += @('--es', 'scope', $scope)
$cmd += @('--es', 'layer', $layer)
if ($delay -gt 0) { $cmd += @('--ei', 'delay', "$delay") }
if ($graphql) { $cmd += @('--ez', 'graphql', 'true') }

Adb @cmd *> $null
Say "fault armed: op=$op kind=$kind scope=$scope delay=${delay}ms layer=$layer graphql=$graphql"
}

# --------------------------------------------------------------- dispatch

$a = @($Args)
Expand Down Expand Up @@ -515,5 +594,6 @@ switch ($cmd) {
'goto' { Cmd-Goto ($a -join ' ') }
'logcat' { if ($a[0]) { Cmd-Logcat ([int]$a[0]) } else { Cmd-Logcat } }
'applog' { Cmd-AppLog }
'fault' { Cmd-Fault $a }
default { Write-Host "Unknown command '$Command'`n"; Cmd-Help; exit 1 }
}
Loading