fix(ui): poll for out-of-band email confirmation #180
Reference in New Issue
Block a user
Delete Branch "feature/email-confirm-poll-fallback"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on #179 (branched off it — both touch
Profile.svelte, which would conflict as independent branches). Until #179 merges, this PR's diff also shows its commitc1805e5; review the second commitfb7490fhere. Merge #179 first, then this.Root cause (systematic-debugging)
An add-email confirmation can complete out of band — the recipient taps the one-tap link in the email, which confirms in another browser/session. The backend already publishes a
notifyprofilere-fetch signal for exactly this (handlers_auth.gohandleEmailConfirmLink), and the client already re-fetches on it (app.svelte.ts).But the live stream is single-shot with no replay: a Mini App backgrounded while the user is in their mail app tapping the link drops the stream and misses the event (the gateway hub has no subscriber to deliver to), and the reconnect on foreground does not re-sync — so the open code form stayed until a manual reload. On Telegram Desktop the app is never backgrounded, so the push works and there is no bug there.
Fix (client-only fallback — the push half already exists)
While an add-email confirmation is pending (a code was sent, no email yet), poll
profile.geton a 4s interval and on foreground regain until the address lands; the$effectstops the moment the email appears. The live push still updates instantly when foregrounded — this only covers the backgrounded-miss gap. No backend/proto/fbs/wire change (theprofileevent kind already exists).Tests
New mock e2e (
social.spec.ts) attaches the email without emitting a live event (newwindow.__mock.clearEmail/confirmEmailOutOfBandseams), so it exercises the poll, not the push, and asserts the code form collapses into the email row. Verified failing pre-fix, green post-fix.Verification (local)
pnpm check— 0 errors / 0 warningspnpm test:unit— 396 passedpnpm test:e2e— 190 passed (Chromium + WebKit), incl. the new test on bothpnpm build— okDocs:
ARCHITECTURE.md§10 notes the single-shot gap + the poll fallback.