Skip to content

fix(android): finish the account sign-in when its return is in the fragment - #4215

Merged
devswha merged 2 commits into
mainfrom
fix/android-callback-fragment
Nov 19, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/android-callback-fragment

Conversation

@devswha

@devswha devswha commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Summary

Signing in to the account from the Android app never finished: after the browser came back, the
page kept its sign-in button busy forever.

The account service returns to ovis://account/callback with state and code (or error) in
the URL fragment (#code=...&state=..., #error=access_denied&state=...).
OvisAuthPlugin.handleOnNewIntent read only the query, so it found no state, returned early,
and the pending authenticate call never settled. native.ts already accepts either form, but it
never received the URL. iOS forwards the whole URL and is not affected.

Change

  • OvisAuthPlugin.isOwnReturn(url, expectedState) is a new pure static method in the same file.
    It reads a non-empty fragment, else the query, matching nativeSignIn in
    src/lib/account/native.ts.
  • Unchanged behaviour:
    • The exact ovis / account / /callback match.
    • The original-state check.
    • The rule that only a return carrying a code or an error settles the call. A return naming
      a different state, or another address, still leaves the sign-in waiting.
  • handleOnNewIntent now calls this method; resolving and releasing the call is unchanged.
  • Changelog fragment: changelog.d/android-signin-callback-fragment.md.

Validation

  • ./gradlew :app:testDebugUnitTest (in app/android, JDK 21): 71 tests, 0 failures, including
    the new OvisAuthReturnTest (12 tests):

    • fragment success
    • fragment denial
    • query success
    • a different state, including a decoy state in a later part of the URL (not settled)
    • another path, host or scheme (ignored)
    • no code or error, and no pending state (ignored)
    • the parse rules:
      • the fragment is read before the query
      • an empty fragment falls back to the query
      • an address with no fields is ignored
      • the first state named wins, as with URLSearchParams.get
      • names and values are percent-decoded
      • a malformed escape is ignored
  • Each parse rule was broken once in a scratch copy, and OvisAuthReturnTest went red every
    time:

    • reading the query first
    • not skipping an empty fragment
    • accepting an address with no fields
    • letting the last state win
    • skipping percent-decoding (once for values, once for names)
  • The settle-once guards in handleOnNewIntent (no waiting call; the call is cleared before it
    resolves) need a Capacitor bridge, so the JVM tests do not reach them. The emulator run below
    covers them instead.

  • The IllegalArgumentException catch in isOwnReturn stays. On the JDK, new URI(...) rejects
    a malformed % escape before URLDecoder sees it: removing the catch kept every test green,
    including the malformed-escape test. The device's own java.net.URI was not checked for the
    same behaviour, and the catch makes a hostile link fail closed instead of crashing the app.

  • ./gradlew :app:assembleDebug: OK.

  • Emulator (Android API image, debug build): the test called OvisAuth.authenticate from the
    app's WebView with a dummy https address and a known state. It then sent intents with
    adb shell am start -a android.intent.action.VIEW -d ...:

    • #error=access_denied with another state: still waiting.
    • ovis://account/elsewhere#... with the right state: still waiting.
    • #error=access_denied with the right state: resolved with that URL.
    • #code=... with the right state, in a new call: resolved with that URL.

    The test did not drive the hosted account page itself (the app opens it only from a PC's link),
    and it did not complete a real GitHub sign-in.

  • Not run: bun run check fast (no web, server or shared code changed). The iOS app is unchanged.

Installed Android builds still need this update. The account service is unchanged.

…agment

The account service sends state and code or error in the fragment of
ovis://account/callback. OvisAuthPlugin read only the query, so the
waiting sign-in never settled and the page stayed busy. Read a non-empty
fragment, else the query, as native.ts does; keep the exact
scheme/host/path match and the original-state check, and settle only a
matching return that carries a code or an error.
Assert that the fragment is read before the query, an empty fragment
falls back to the query, an address with no fields is ignored, the first
state named wins, names and values are percent-decoded, and a malformed
escape is ignored.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an Android sign-in issue that could leave the app loading after returning from the browser. Sign-in results are now recognized for successful and denied attempts.

Android sign-in callback handling now checks callback URLs and reads result parameters from a non-empty fragment, falling back to the query. Tests cover accepted and rejected returns.

Changes: Android sign-in callback

Layer / File(s) Summary
Callback validation and completion
app/android/app/src/main/java/sh/ovis/app/OvisAuthPlugin.java, app/android/app/src/test/java/sh/ovis/app/OvisAuthReturnTest.java, changelog.d/android-signin-callback-fragment.md
isOwnReturn validates the callback address, state, and presence of a code or error parameter. It reads a non-empty fragment before the query and rejects malformed input. handleOnNewIntent resolves the pending call only for accepted returns. Tests cover callback parsing and rejection cases. The changelog records the Android sign-in callback fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to e2ceb

This change lets Android sign-in finish when the account service returns its result in the URL fragment, instead of staying pending. The matching rules for callbacks are unchanged. No merge-blocking risk is evident. Real end-to-end sign-in was not exercised in the reported testing.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the Android account sign-in now finishes when the return arrives in the URL fragment. It matches the raw summary, the PR objectives, and the description.
Description check Passed The description follows the template. It has a Summary and a Change section that explain the problem, the fix, and the unchanged behaviour. The Validation section lists the Gradle test and build runs,…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description follows the template. It has a Summary and a Change section that explain the problem, the fix, and the unchanged behaviour. The Validation section lists the Gradle test and build runs, an emulator run, and the skipped checks. The template's reference to contract tests does not apply, since no HTTP or WS code changed, and the description says so only implicitly. The description is complete overall.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 802ed09 and e2ceba1.

Files selected for processing: 3

  • app/android/app/src/main/java/sh/ovis/app/OvisAuthPlugin.java
  • app/android/app/src/test/java/sh/ovis/app/OvisAuthReturnTest.java
  • changelog.d/android-signin-callback-fragment.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.

@devswha
devswha merged commit 7ea0e00 into main Nov 19, 2026
15 checks passed
@devswha

devswha commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head e2ceba107. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit reviewed this head.

Lane reviews at 9f67372: fresh omo reviewer CLEAR (JVM 65/0, emulator checks) and Codex gpt-6.2-sol-fast CLEAR; e2ceba1 adds only JVM asserts for the reviewer's LOW (5/5 mutations caught); CodeRabbit reviewed this head; merged by the relay owner on the owner's word ("둘다해").

@devswha
devswha deleted the fix/android-callback-fragment branch November 19, 2026 07:53
devswha added a commit that referenced this pull request Nov 19, 2026
…4219)

## Summary

Records the Android store build that carries the sign-in fix #4215, so
the next build does not reuse a version code Play already holds (as
#4205 did for 1.0.3).

- **Android:** `app/android/app/build.gradle` raises `versionCode` 10 ->
11 and `versionName` 1.0.3 -> 1.0.4. 1.0.4 (11) is the bundle built from
`main` at `7ea0e00c` (#4215) with only this bump on top. It was
published to the internal testing track and sent to Google Play's
production review on 2026-11-19.
- **Docs:** the version rows in `app/store/android.md` show these
numbers and name the last upload.
- **iOS:** unchanged.

Why 1.0.4 needed an Android build: #4215 (the app finishes the account
sign-in when the account service returns its result in the callback's
fragment) is Android native code (`OvisAuthPlugin.java`). Between v0.5.5
and `7ea0e00c` it is the only native change under `app/`; the 1.0.3
record (#4205) is the other commit there.

Nothing here builds or uploads. The next upload raises Android to
`versionCode` 12.

## Validation

- The 1.0.4 (11) bundle: `bundleRelease` with the upload key and
google-services.json (the four Firebase values are in the bundle's
resources); `keytool -printcert` shows the upload key; the merged
manifest reads versionCode 11 / versionName 1.0.4; `testReleaseUnitTest`
passed (97 tests, 0 failures, including `OvisAuthReturnTest` from
#4215).
- No emulator launch this time: the web shell and every other native
file are the same as 1.0.3, which passed that check.
- `bun run check fast` (this PC): workflow syntax, generated types and
themes, typecheck and build passed. Unit tests: 19286 pass, 1 fail. The
failure is `scripts/conventions.test.ts` "the tools typecheck > excludes
no more files than at the ratchets' base", which came from the checkout,
not this change: the checkout's `origin/main` is another repository's
main, so the ratchet base was `0a91d143`, 272 commits back, whose
`tsconfig.tools.json` has no exclude list. Re-run with the public base,
`RATCHET_BASE=7ea0e00c bun test scripts/conventions.test.ts`: 33 pass, 0
fail. The change is two gradle numbers and a doc table; no test reads
`versionCode` or `versionName`.
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