Skip to content

Send the last five minutes of activity from the device, and stop NotFound being a dead end - #159

Merged
zhollis21 merged 8 commits into
mainfrom
feature/112-diagnostic-log-export
Sep 5, 2026
Merged

zhollis21 merged 8 commits into
mainfrom
feature/112-diagnostic-log-export

Conversation

@zhollis21

@zhollis21 zhollis21 commented Sep 3, 2026 •

Copy link
Copy Markdown
Owner

Closes #112. Closes #158.

Two issues, one PR, because they are the same story: I hit a bug on my phone — tapping into manga kept saying the entry didn't exist, then it worked fine later — and there was no way to find out what happened. #112 is the missing pipeline. #158 is the reason that particular failure left no trace even for the parts we already had.

#112 — sending the last five minutes

The catch in the original issue still held: a Release build's file log is capped at Warning, while every trace worth reading (NAVTRACE, PageState, CACHE, AUTH, the HTTP pairs) is Information. A share button built against that file would have delivered exactly the wrong thing.

So this adds a third logging provider — DiagnosticsLogBuffer, an in-memory ring holding ~5 minutes at Information, bounded by both age and entry count, in every build config. No disk writes, so an install that never reports anything pays only the memory.

Why not the alternatives the issue listed. Always persisting Information to the file log makes every install pay a write cost and shrinks the already-small 256 KB Release window. Reading logcat is tempting — the traces are already there at Debug even in Release — but it lives in the app project where no unit test reaches, and the buffer is shared with the whole system.

Surviving a process death. The ring dies with the process, so DiagnosticsSessionFlusher snapshots it to logs/previous-session.log from the three global exception handlers and OnPause, and clears it on resume — only if this process wrote it. Clearing unconditionally would delete a dead process's crash flush on the very launch the user opens to report it; not clearing at all would send every line twice. That rule is why the flusher is in Core: it's wrong in two directions and neither is visible from outside.

Delivery is Sentry only. Its silence is handled at the UI end instead — a sheet states what's about to be collected before anything is collected, and the confirmation names the same window back. The sheet takes an optional note, sent as SentryFeedback linked to the event. Reachable from Settings (signed-in and signed-out — a sign-in failure is worth reporting) and from the Report action on any error card.

#158 — why that bug left no evidence

NotFound was the only ApiErrorKind that was both non-retryable and suppressed from Sentry, and the two reinforced each other: the details string was forced empty, ErrorStateView gates Copy/Share on that string, and canRetry was hard-coded false. So the error a user can least explain was the only one they could neither retry nor report.

On top of that, ClassifyGraphQlError matched "Not Found" as a substring anywhere in server text — enough to turn any transient failure containing those two words into a permanent dead end. It now matches AniList's own "Not Found." message exactly.

NotFound now reaches Sentry, deliberately: the frequency data is what was missing. Fingerprint it down if it proves noisy. The automatic retry in AniListClient.SendAsync still excludes it — only the user-facing button changed.

The bit worth reviewing carefully

SentryScrubber runs on SetBeforeSend over the SentryEvent and does not walk attachments. The report reaches Sentry as an attachment, by a route SetBeforeSend never inspects, and the free-text note takes a third route again. So the single SensitiveText.Redact pass in DiagnosticsReportBuilder.Build is the only thing between the log and Sentry. It has its own test section.

Verified on device

Built with -p:CiBuild=true, synthesised a NotFound via #125 fault injection, and pulled the results back out of Sentry:

  • The card now renders Try Again, Show technical details and Report a problem. All three were absent before.
  • Four reports arrived, grouped as ANISPRINKLES-2E, each with an anisprinkles-diagnostics.log attachment (8.6–9.8 KB). I downloaded three and read them.
  • Contents are the full Information lead-up — including FAULT failing GetMediaAsync as NotFound and NAVTRACE MediaDetails not found on AniList in 94ms (media 21) — none of which the Release file log would have kept.
  • The typed note appears under its own header and reached Sentry as linked feedback.

Redaction is not device-verified: the CI build's stub auth never emits a bearer token, so there was nothing to redact. Unit tests are the only coverage there.

Two things the verification caught

The Settings card over-promised. It said "you'll see exactly what gets sent first," but the sheet lists categories, not the 8.6 KB payload. Reworded, with a test that reads the XAML and fails if it comes back.

A cross-reference I built didn't work, so it's gone. The report header was meant to name the automatic exception event. It was always blank, and tracing it turned up something worth knowing: ErrorReportService.Record's explicit SentrySdk.CaptureException never creates the event — MinimumEventLevel defaults to Error, so the preceding LogError already captured it (confirmed by mechanism: SentryLogger on our events), and the second call is dropped by DuplicateEventDetectionEventProcessor. Worse, Hub.CaptureEvent assigns scope.LastEventId = id unguarded, so the dropped call overwrites the good id — which is why SentrySdk.LastEventId was empty too. Both my attempts failed for that one cause. Swapping the two lines would fix it but produce a barer Sentry event (losing the Context tag and message), so I removed the feature instead and wrote the finding into AGENTS.md and the call site.

Review feedback (8851757, dd52676, faf7033)

All three Copilot findings were fair:

  • Both Report entry points swallowed a DI failure silently, so a tap could do nothing with no indication why. Near-unreachable — the views only render once the container is built — but that's a weak defence for a feature whose whole promise is that the user knows what happened. Both now show a best-effort toast, via Toast directly rather than IUserFeedback, since that seam comes from the container that just failed to resolve.
  • DiagnosticsLogBuffer.Clear() is gone. Its only caller anywhere was its own test, and its doc was wrong rather than merely vague — it claimed clearing the ring is what stops a flush duplicating lines, when that's actually ClearIfOwnedByThisProcess clearing the session file. (DiagnosticsSessionLog.Clear() stays; two real callers.)
  • DiagnosticsReportPopup's summary was stale, still describing a null cancel from before the Cancelled sentinel replaced CloseAsync(null!).
  • The log-line comment overstated its own contract. An appended exception keeps its stack trace's line breaks, so a record starts on its own line but need not end on one — while the comment said "one record per line" flatly. The behaviour is deliberate and matches FileLoggerProvider: the only consumer of a report is a person, and folding a 20-frame trace onto one line is much worse for them (.NET already indents continuation frames). The comment now says that, with a test pinning it as intent. The related claim that redaction relies on whole lines was also wrong — it runs one pass over the entire report, and Bearer\s+… matches across a newline, now covered by a test that wraps a token over a break.
  • The classifier justified itself with a contract this PR removed. Its comment called NotFound "the only kind that is non-retryable AND suppressed from Sentry" in the present tense — true before NotFound is a dead end: no Sentry event, no shareable details, no retry, and any "Not Found" substring triggers it #158, and untrue by the time anyone reads it. Now dated: that state is what forced the exact match, and NotFound is a dead end: no Sentry event, no shareable details, no retry, and any "Not Found" substring triggers it #158 ended it. The match still stands on its own terms (misclassifying arbitrary server text suppresses the automatic retry in AniListClient.SendAsync, and tells the user something was removed from AniList when it never was), so those are stated separately rather than resting on the old behaviour.

Notes

  • No new AniList operations, so no CIAniListClient twin needed.
  • Settings gained a card; CI has already regenerated the screenshots (9e93056).
  • 1602 unit tests, zero warnings. Each commit builds and tests green independently.

Zach Hollis added 2 commits September 3, 2026 07:19
Chasing a real incident: tapping into manga repeatedly gave "Entry
Unavailable — we couldn't find this on AniList" for a stretch, then the
same titles loaded fine later. Nothing was recorded anywhere that could
say what actually happened, and working out why led here.

NotFound was the only ApiErrorKind that was simultaneously non-retryable
and suppressed from Sentry, and the two reinforced each other:

  - DetailsPageModelBase forced the details string empty on this path,
    and ErrorStateView gates its Copy/Share actions on that string being
    non-empty — so the card offered nothing to send.
  - canRetry was hard-coded false, so there was nothing to press either.
  - ClassifyGraphQlError matched "Not Found" as a substring anywhere in
    server-supplied text, so any transient failure containing those two
    words landed here.

Together that made the error a user can least explain the only one they
could neither retry nor report, and left no evidence to tell a genuine
404 from a transient blip misfiled as one.

The classifier now matches AniList's own "Not Found." message exactly,
allowing for the trailing period and surrounding whitespace. Unknown is
the honest answer for text we don't recognise, and it stays retryable and
reported. NotFound itself is now handled like every other failure: retry
offered, report produced. A real 404 costs one user-initiated request
when they tap Retry; a misclassified transient used to cost the whole
page with no recourse.

One deliberate consequence: routing it through ErrorReportService means
NotFound now reaches Sentry. That is the frequency data we were missing.
Fingerprint it down if it proves noisy.

The automatic retry in AniListClient.SendAsync still excludes NotFound —
only the user-facing button changed.

Closes #158
There was no way to get diagnostics off a phone, and the log a Release
build keeps would not have helped if there had been: the file sink is
capped at Warning, while every trace worth reading — NAVTRACE, PageState,
CACHE, AUTH, the HTTP request/response pairs — is Information. A share
button built against it would have delivered a file missing exactly what
makes a report diagnosable.

Adds a third logging provider, DiagnosticsLogBuffer: an in-memory ring
holding roughly the last five minutes at Information, bounded by age and
by entry count, in every build config. It touches no disk, so an install
that never reports anything pays only the memory.

This beat always persisting Information to the file log, which would make
every install pay a write cost and *shrink* the already-small 256 KB
Release window. It beat reading logcat — where the traces already are, at
Debug, in Release — because that lives in the app project where no unit
test can reach it, and its buffer is shared with the rest of the system.

The ring dies with the process, so DiagnosticsSessionFlusher writes a
snapshot to logs/previous-session.log from the three global exception
handlers and MainActivity.OnPause, and clears it again on resume — but
only when this process wrote it. A file left by a process that actually
died is the thing worth sending, and clearing it on the next launch would
delete the crash before the user could report it. That ownership rule is
the reason the flusher sits in Core rather than in the Activity: it is
wrong in two directions, and neither would be visible from outside.

Delivery is Sentry only. Its silence is covered at the UI end instead: a
sheet states what is about to be collected before anything is collected,
and the confirmation names the same window back. The sheet also takes an
optional note, sent as SentryFeedback linked to the event, so the user's
own account of what happened arrives as a user report rather than buried
in an event body. Reachable from Settings — in both the signed-in and
signed-out states, since a sign-in failure is worth reporting — and from
the Report action on any error card.

The redaction pass in DiagnosticsReportBuilder is load-bearing and easy
to miss: SentryScrubber runs on SetBeforeSend over the SentryEvent and
does NOT walk attachments, so it is not the backstop here. The report
reaches Sentry as an attachment, by a route SetBeforeSend never inspects,
and the free-text note takes a third route again.

Verified on device against a synthesised NotFound (#125 fault injection):
the report arrived in Sentry with its attachment, carrying the full
Information-level lead-up including the failure itself.

Closes #112
Copilot AI lite review requested due to automatic review settings September 3, 2026 11:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new reporting UI paths currently swallow DI-resolution failures silently and a couple of new doc comments misstate runtime behavior, which should be corrected before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a user-initiated diagnostics reporting pipeline (last ~5 minutes of in-app activity + previous-session snapshot) delivered via Sentry, and removes the “NotFound is a dead end” behavior by making NotFound retryable/reportable and tightening the NotFound classifier match.

Changes:

  • Introduces DiagnosticsLogBuffer (in-memory ILoggerProvider) + DiagnosticsSessionLog/Flusher persistence, plus a DiagnosticsReportCoordinator flow that collects only after user consent and sends via IDiagnosticsSink (Sentry).
  • Updates details-page error handling so ApiErrorKind.NotFound is treated like other failures for retry/reporting, and narrows GraphQL NotFound classification to AniList’s exact "Not Found."-style messages.
  • Adds Settings + error-card UI entry points for reporting, plus extensive unit tests guarding consent, retention, redaction, persistence, and classifier behavior.
File summaries
File Description
tests/AniSprinkles.UnitTests/MediaDetailsPageModelTests.cs Updates NotFound expectations: retry + non-empty details.
tests/AniSprinkles.UnitTests/Fakes/StubAppEnvironment.cs Adds IAppEnvironment test double for report headers.
tests/AniSprinkles.UnitTests/Fakes/ScriptedDialogService.cs Extends dialog fake with diagnostics report sheet support.
tests/AniSprinkles.UnitTests/Fakes/RecordingDiagnosticsSink.cs Adds sink fake to capture would-be Sentry sends.
tests/AniSprinkles.UnitTests/DiagnosticsSessionLogTests.cs Adds coverage for persistence semantics and “never throw” behavior.
tests/AniSprinkles.UnitTests/DiagnosticsSessionFlusherTests.cs Adds coverage for flush/ownership clearing rules.
tests/AniSprinkles.UnitTests/DiagnosticsReportCoordinatorTests.cs Adds end-to-end flow tests: consent-first, send/failed/cancel, re-entrancy.
tests/AniSprinkles.UnitTests/DiagnosticsReportBuilderTests.cs Adds report formatting + redaction assertions (attachments path).
tests/AniSprinkles.UnitTests/DiagnosticsLogBufferTests.cs Adds retention/count bounds, formatting, concurrency safety tests.
tests/AniSprinkles.UnitTests/DiagnosticsDisclosureTests.cs Pins disclosure + UI wording promises against implementation.
tests/AniSprinkles.UnitTests/DetailsSpineTests.cs Updates base details spine expectations for NotFound retry/reportability.
tests/AniSprinkles.UnitTests/AniListErrorClassifierTests.cs Adds tests for exact NotFound matching and ordering vs outage detection.
src/AniSprinkles/Views/SettingsLoadedContentView.xaml Adds Settings “Report a problem” card to the authenticated view.
src/AniSprinkles/Views/ErrorStateView.xaml Adds always-available “Report a problem” affordance on error cards.
src/AniSprinkles/Views/ErrorStateView.xaml.cs Implements per-error “one report” behavior and DI resolution for reporting.
src/AniSprinkles/Views/DiagnosticsReportView.xaml New Settings card UI for reporting diagnostics (signed-in + signed-out).
src/AniSprinkles/Views/DiagnosticsReportView.xaml.cs New handler to invoke the coordinator from Settings.
src/AniSprinkles/Views/DiagnosticsReportPopup.xaml New disclosure + optional description popup UI.
src/AniSprinkles/Views/DiagnosticsReportPopup.xaml.cs Popup behavior: cancel vs send signaling to caller.
src/AniSprinkles/Utilities/DiagnosticsFlush.cs Platform shim to safely flush/clear session log from lifecycle/handlers.
src/AniSprinkles/Services/Maui/MauiDialogService.cs Implements IDialogService.ShowDiagnosticsReportAsync.
src/AniSprinkles/Services/Maui/MauiAppEnvironment.cs MAUI Essentials-backed IAppEnvironment implementation with safe fallbacks.
src/AniSprinkles/Platforms/Android/MainActivity.cs Flushes on pause, clears owned flush on resume; flushes on Android unhandled exception raiser.
src/AniSprinkles/Pages/SettingsPage.xaml Adds diagnostics card to signed-out Settings view.
src/AniSprinkles/MauiProgram.cs Registers diagnostics logger provider + coordinator dependencies in DI and logging pipeline.
src/AniSprinkles/App.xaml.cs Flushes diagnostics on global exception handlers before other work.
src/AniSprinkles.Core/Services/SentryDiagnosticsSink.cs Sentry delivery implementation: event + attachment + feedback + bounded flush.
src/AniSprinkles.Core/Services/ErrorReportService.cs Documents Sentry logger vs CaptureException dedupe behavior at call site.
src/AniSprinkles.Core/Services/DiagnosticsSessionLog.cs Adds disk snapshot store for “previous session” lines with non-throwing semantics.
src/AniSprinkles.Core/Services/DiagnosticsSessionFlusher.cs Adds ownership rule for clearing previous-session file only when safe.
src/AniSprinkles.Core/Services/DiagnosticsReportBuilder.cs Builds/redacts the report text (single-pass redaction over full payload).
src/AniSprinkles.Core/Services/DiagnosticsLogBuffer.cs Adds in-memory ring provider (retention + max entries; thread-safe snapshot).
src/AniSprinkles.Core/Services/AniListErrorClassifier.cs Narrows NotFound classification to exact AniList message shape.
src/AniSprinkles.Core/Services/AniListApiException.cs Updates NotFound docs to reflect retry/report behavior and classifier rule.
src/AniSprinkles.Core/Services/Abstractions/IDialogService.cs Adds diagnostics report choice type + new dialog API.
src/AniSprinkles.Core/Services/Abstractions/IDiagnosticsSink.cs Adds sink abstraction so tests can assert sends (Sentry SDK can no-op silently).
src/AniSprinkles.Core/Services/Abstractions/IAppEnvironment.cs Adds environment abstraction so Core report flow remains testable off-device.
src/AniSprinkles.Core/PageModels/DiagnosticsReportCoordinator.cs Implements consent → snapshot → build/redact → send → confirm flow + re-entrancy guard.
src/AniSprinkles.Core/PageModels/DetailsPageModelBase.cs Makes NotFound retryable/reportable by routing it through ErrorReportService.Record.
AGENTS.md Documents the new diagnostics pipeline and updated NotFound behavior.
.claude/skills/project-architecture/SKILL.md Updates architecture notes to mention NotFound manual-retry nuance.
Review details
  • Files reviewed: 41/41 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

📱 UI Screenshots

✅ Authenticated UI — screenshots rendered via compile-time CI stub services with hardcoded data. No OAuth token required.

View Workflow Run →

Anime Library Manga Library Discover View All (Browse) Search One Piece Details Toei Animation (Studio) Luffy (Character) Mayumi Tanaka (Staff) Settings
Anime Library Manga Library Discover View All (Browse) Search One Piece Details Toei Animation (Studio) Luffy (Character) Mayumi Tanaka (Staff) Settings

Three findings from review, all fair:

The two Report entry points swallowed a DI-resolution failure and
re-enabled the button, so a tap could do nothing at all with no
indication why. The path is close to unreachable — both views only render
once the container is built — but "close to unreachable" is a weak
defence for a feature whose entire promise is that the user knows what
happened. Both now show a best-effort toast. It goes through Toast
directly rather than IUserFeedback on purpose: that seam comes from the
container that just failed to resolve.

DiagnosticsLogBuffer.Clear() had no runtime caller, and its doc claimed
clearing was what stopped a flush writing the same lines twice. It isn't
— DiagnosticsSessionFlusher.ClearIfOwnedByThisProcess clears the session
*file*, and the ring is deliberately left intact. Rather than correct the
comment, the method is gone: the only caller anywhere was its own test,
the "we might want it for sign-out" case is one we explicitly decided
against, and it managed to grow a wrong doc inside a day of being unused.

DiagnosticsReportPopup's class summary still said it closes with null on
cancel, from before the Cancelled sentinel replaced that to avoid a null!
suppression — contradicted by the sentinel's own doc six lines below.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

DiagnosticsLogBuffer can emit multi-line entries via raw exception.ToString(), breaking the “one record per line” contract and potentially corrupting persisted/report formatting.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 41/51 changed files
  • Comments generated: 1
  • Review effort level: Lite

github-actions Bot and others added 3 commits September 3, 2026 16:21
An appended exception keeps its stack trace's line breaks, so a record
starts on its own line but does not always end on one. The comment next
to it claimed "one record per line" flatly, which was not true and read
as an oversight rather than a decision.

It is a decision. The only thing that reads a report is a person, and a
20-frame trace folded onto a single line is far worse for them than a
wrapped one — .NET already indents continuation frames, so a continuation
is still distinguishable from the next record at a glance. FileLoggerProvider
has always behaved this way; the buffer mirrors it deliberately.

Adds a test pinning that exceptions keep their breaks, so the intent is
explicit alongside the message-flattening test that sits next to it.

Also tightens the redaction comment in DiagnosticsReportBuilder, which
justified its single whole-text pass on "every line is written whole".
That was the wrong reason for a right decision. The real reason is that
scanning the whole string makes line structure irrelevant: `Bearer\s+…`
matches `\s` across a newline, so a credential wrapped over a break is
still caught. Now covered by a test rather than asserted in prose.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

AniListErrorClassifier’s comment still claims NotFound is suppressed from Sentry/non-retryable, which no longer matches the new #158 behavior and should be corrected to avoid future misinterpretation.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 41/51 changed files
  • Comments generated: 1
  • Review effort level: Lite

…moved

The comment justifying the exact "Not Found." match described NotFound as
"the only kind that is non-retryable AND suppressed from Sentry" — in the
present tense, in the same PR that removed both properties. A reader would
have taken it as the current contract and reasoned from it.

Rewritten to say what actually happened: that state is what forced the
tightening, and #158 ended it. The exact match still stands on its own
terms, so those are stated separately rather than resting on the old
behaviour — calling arbitrary server text a missing id suppresses the
automatic retry in AniListClient.SendAsync (IsTransient covers Network,
Authentication and Unknown, never NotFound) and tells the user something
was removed from AniList when it never was.
@zhollis21
zhollis21 merged commit 4c682a3 into main Sep 5, 2026
4 checks passed
@zhollis21
zhollis21 deleted the feature/112-diagnostic-log-export branch September 5, 2026 13:50
zhollis21 added a commit that referenced this pull request Nov 19, 2026
…ound being a dead end (#159)

* Stop treating every "Not Found" as a permanent, unreportable dead end

Chasing a real incident: tapping into manga repeatedly gave "Entry
Unavailable — we couldn't find this on AniList" for a stretch, then the
same titles loaded fine later. Nothing was recorded anywhere that could
say what actually happened, and working out why led here.

NotFound was the only ApiErrorKind that was simultaneously non-retryable
and suppressed from Sentry, and the two reinforced each other:

  - DetailsPageModelBase forced the details string empty on this path,
    and ErrorStateView gates its Copy/Share actions on that string being
    non-empty — so the card offered nothing to send.
  - canRetry was hard-coded false, so there was nothing to press either.
  - ClassifyGraphQlError matched "Not Found" as a substring anywhere in
    server-supplied text, so any transient failure containing those two
    words landed here.

Together that made the error a user can least explain the only one they
could neither retry nor report, and left no evidence to tell a genuine
404 from a transient blip misfiled as one.

The classifier now matches AniList's own "Not Found." message exactly,
allowing for the trailing period and surrounding whitespace. Unknown is
the honest answer for text we don't recognise, and it stays retryable and
reported. NotFound itself is now handled like every other failure: retry
offered, report produced. A real 404 costs one user-initiated request
when they tap Retry; a misclassified transient used to cost the whole
page with no recourse.

One deliberate consequence: routing it through ErrorReportService means
NotFound now reaches Sentry. That is the frequency data we were missing.
Fingerprint it down if it proves noisy.

The automatic retry in AniListClient.SendAsync still excludes NotFound —
only the user-facing button changed.

Closes #158

* Let a user send the last five minutes of activity from the device

There was no way to get diagnostics off a phone, and the log a Release
build keeps would not have helped if there had been: the file sink is
capped at Warning, while every trace worth reading — NAVTRACE, PageState,
CACHE, AUTH, the HTTP request/response pairs — is Information. A share
button built against it would have delivered a file missing exactly what
makes a report diagnosable.

Adds a third logging provider, DiagnosticsLogBuffer: an in-memory ring
holding roughly the last five minutes at Information, bounded by age and
by entry count, in every build config. It touches no disk, so an install
that never reports anything pays only the memory.

This beat always persisting Information to the file log, which would make
every install pay a write cost and *shrink* the already-small 256 KB
Release window. It beat reading logcat — where the traces already are, at
Debug, in Release — because that lives in the app project where no unit
test can reach it, and its buffer is shared with the rest of the system.

The ring dies with the process, so DiagnosticsSessionFlusher writes a
snapshot to logs/previous-session.log from the three global exception
handlers and MainActivity.OnPause, and clears it again on resume — but
only when this process wrote it. A file left by a process that actually
died is the thing worth sending, and clearing it on the next launch would
delete the crash before the user could report it. That ownership rule is
the reason the flusher sits in Core rather than in the Activity: it is
wrong in two directions, and neither would be visible from outside.

Delivery is Sentry only. Its silence is covered at the UI end instead: a
sheet states what is about to be collected before anything is collected,
and the confirmation names the same window back. The sheet also takes an
optional note, sent as SentryFeedback linked to the event, so the user's
own account of what happened arrives as a user report rather than buried
in an event body. Reachable from Settings — in both the signed-in and
signed-out states, since a sign-in failure is worth reporting — and from
the Report action on any error card.

The redaction pass in DiagnosticsReportBuilder is load-bearing and easy
to miss: SentryScrubber runs on SetBeforeSend over the SentryEvent and
does NOT walk attachments, so it is not the backstop here. The report
reaches Sentry as an attachment, by a route SetBeforeSend never inspects,
and the free-text note takes a third route again.

Verified on device against a synthesised NotFound (#125 fault injection):
the report arrived in Sentry with its attachment, carrying the full
Information-level lead-up including the failure itself.

Closes #112

* CI: Update UI screenshots [skip ci]

* PR feedback: never let a Report tap do nothing, and drop an unused Clear

Three findings from review, all fair:

The two Report entry points swallowed a DI-resolution failure and
re-enabled the button, so a tap could do nothing at all with no
indication why. The path is close to unreachable — both views only render
once the container is built — but "close to unreachable" is a weak
defence for a feature whose entire promise is that the user knows what
happened. Both now show a best-effort toast. It goes through Toast
directly rather than IUserFeedback on purpose: that seam comes from the
container that just failed to resolve.

DiagnosticsLogBuffer.Clear() had no runtime caller, and its doc claimed
clearing was what stopped a flush writing the same lines twice. It isn't
— DiagnosticsSessionFlusher.ClearIfOwnedByThisProcess clears the session
*file*, and the ring is deliberately left intact. Rather than correct the
comment, the method is gone: the only caller anywhere was its own test,
the "we might want it for sign-out" case is one we explicitly decided
against, and it managed to grow a wrong doc inside a day of being unused.

DiagnosticsReportPopup's class summary still said it closes with null on
cancel, from before the Cancelled sentinel replaced that to avoid a null!
suppression — contradicted by the sentinel's own doc six lines below.

* CI: Update UI screenshots [skip ci]

* Say what the log-line contract actually is, rather than overstating it

An appended exception keeps its stack trace's line breaks, so a record
starts on its own line but does not always end on one. The comment next
to it claimed "one record per line" flatly, which was not true and read
as an oversight rather than a decision.

It is a decision. The only thing that reads a report is a person, and a
20-frame trace folded onto a single line is far worse for them than a
wrapped one — .NET already indents continuation frames, so a continuation
is still distinguishable from the next record at a glance. FileLoggerProvider
has always behaved this way; the buffer mirrors it deliberately.

Adds a test pinning that exceptions keep their breaks, so the intent is
explicit alongside the message-flattening test that sits next to it.

Also tightens the redaction comment in DiagnosticsReportBuilder, which
justified its single whole-text pass on "every line is written whole".
That was the wrong reason for a right decision. The real reason is that
scanning the whole string makes line structure irrelevant: `Bearer\s+…`
matches `\s` across a newline, so a credential wrapped over a break is
still caught. Now covered by a test rather than asserted in prose.

* CI: Update UI screenshots [skip ci]

* Date the classifier's reasoning instead of asserting a contract we removed

The comment justifying the exact "Not Found." match described NotFound as
"the only kind that is non-retryable AND suppressed from Sentry" — in the
present tense, in the same PR that removed both properties. A reader would
have taken it as the current contract and reasoned from it.

Rewritten to say what actually happened: that state is what forced the
tightening, and #158 ended it. The exact match still stands on its own
terms, so those are stated separately rather than resting on the old
behaviour — calling arbitrary server text a missing id suppresses the
automatic retry in AniListClient.SendAsync (IsTransient covers Network,
Authentication and Unknown, never NotFound) and tells the user something
was removed from AniList when it never was.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants