Skip to content

Show diffs in the release build again - #190

Merged
markusressel merged 1 commit into
masterfrom
fix/diff-op-r8
Nov 14, 2026
Merged

markusressel merged 1 commit into
masterfrom
fix/diff-op-r8

Conversation

@markusressel

Copy link
Copy Markdown
Member

Markus saw "Something went wrong. Please try again." when he opened a history entry in release-737. It wasn't specific to agent commits: every diff failed in release builds. Debug builds worked.

Root cause: DiffOp took its JSON names (" ", "-", "+") from @Json on the enum constants. Moshi's codegen makes no enum adapters, so the reflective enum adapter reads those annotations at runtime. R8 drops them (the release dex has no field annotations on DiffOp), so Moshi expected "CONTEXT" and threw on " ". userMessage() maps a parse error on a 200 response to the generic text. This affected the history diff and the hunks of "changed since your last visit".

Fix:

  • DiffLineModel keeps the sign as text (@Json(name = "op") val sign: String), which the generated adapter parses without reflection.
  • op is computed from the sign, and an unknown sign shows as unchanged.
  • The constructor with a DiffOp stays for the callers.

Test: EnumJsonNamesTest fails if an enum in the REST models takes JSON names from annotations again. It fails without the fix.

Verified:

  • An R8 build for x86_64, signed with a throwaway key, ran on the emulator against a local backend. That backend held the exact two versions of "PID Tuning.md" from production, with the new one written over MCP with an app token.
  • Before the fix, every entry showed the error. After the fix, the diff shows.

🤖 Generated with Claude Code

DiffOp took its JSON names from @JSON on the enum constants. Moshi reads
those by reflection, and R8 drops them in the release build, so every
diff of the history and of the changes since the last visit failed with
"Something went wrong". The sign is now kept as text and parsed by the
generated adapter. A test keeps enums with @JSON names out of the API
models.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@markusressel
markusressel merged commit 530a789 into master Nov 14, 2026
3 checks passed
@markusressel
markusressel deleted the fix/diff-op-r8 branch November 14, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant