Skip to content

[NRT-822] Qt5: open Terms & Conditions and Flashcard Selector in the external browser#1317

Draft
RisingOrange wants to merge 1 commit into
mainfrom
worktree-nrt-822-qt5-external-browser
Draft

[NRT-822] Qt5: open Terms & Conditions and Flashcard Selector in the external browser#1317
RisingOrange wants to merge 1 commit into
mainfrom
worktree-nrt-822-qt5-external-browser

Conversation

@RisingOrange

Copy link
Copy Markdown
Collaborator

What & why

On Qt5 builds of Anki the embedded webview is Qt WebEngine 5.x (Chromium 77), which can't run the modern JS used by two AnkiHub pages we render in-app, so they show up blank/broken for these users:

  • Terms & Conditions — a sync-blocker: a user asked to accept (updated) terms can't, so they can't sync or use AnkiHub at all.
  • Flashcard Selector — non-functional.

These are old-macOS (10.13/10.14) users who can't upgrade to Qt6 Anki yet meet min_anki_version, so it's a supported config. Refs: TRIAGE-147, ACTV-94; Sentry JAVASCRIPT-18 / JAVASCRIPT-E / JAVASCRIPT-4 (Qt Web Engine 5.14.2).

Approach

Gate both surfaces on using_qt5() and open them in the user's external (modern) browser instead of the dead embedded engine — mirroring how the chatbot is Qt6-gated. No backend changes.

  • Flashcard Selector (flashcard_selector_dialog.py) — on Qt5, openLink(url_flashcard_selector(ah_did)) + a short toast instead of building the embedded dialog.
  • Terms & Conditions (terms_dialog.py) — on Qt5, open the terms page externally and show a new ExternalBrowserTermsDialog that detects acceptance:
    • bounded auto-poll (every 3s, up to 3min), then stops; a manual "Check now" button remains as the fallback. Both share the same check + resume logic.
    • on detection → close dialog and resume the blocked sync (errors.py).
  • Acceptance check — new AnkiHubClient.is_terms_agreement_accepted() re-issues a request guarded by HasFilledPersonalInfo (GET /users/decks/): 200 = accepted, 403 = not yet. Verified against the webapp: the terms page sets all gated fields (terms + country + study prefs) atomically, so the 403→200 flip maps exactly onto "user completed the page".

Status / open question

The Jira issue is in Ready for Design — the ExternalBrowserTermsDialog UX (auto-poll vs. manual-only, copy, whether it blocks Anki) is pending a designer's review. This PR is a draft implementation/reference, not final; the Terms dialog UI may change after design.

Test plan

  • Qt5 Anki: Terms page + Flashcard Selector open in the system browser and work.
  • After accepting terms in the browser, the add-on auto-detects (within the poll window) or via "Check now", closes the dialog, and sync proceeds.
  • Qt6 Anki: unchanged (embedded dialogs still used).
  • Verify on macOS (per repo policy for UI changes).

https://claude.ai/code/session_01E1qJDe6g6ea63Fusg9fViv

On Qt5 builds of Anki the embedded webview is Chromium 77, which can't run
the modern JS used by the AnkiHub Terms & Conditions and Flashcard Selector
pages, leaving them blank/broken. Since the Terms page blocks sync, affected
users (old macOS, can't upgrade to Qt6 Anki) are fully stuck.

Gate both surfaces on using_qt5() and open them in the user's external
browser instead:

- Flashcard Selector: openLink(full page) + toast instead of the embedded
  dialog.
- Terms & Conditions: open the terms page externally and detect acceptance
  via a new ExternalBrowserTermsDialog (bounded auto-poll + manual "Check
  now"); on detection, resume the blocked sync. Acceptance is checked with a
  new AnkiHubClient.is_terms_agreement_accepted() that re-issues a guarded
  request (200 = accepted, 403 = not yet).

No backend changes.

Claude-Session: https://claude.ai/code/session_01E1qJDe6g6ea63Fusg9fViv
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