fix: show clear offline message when share/upload button clicked without internet#1952
fix: show clear offline message when share/upload button clicked without internet#1952shashank-sn wants to merge 2 commits into
Conversation
…out internet Previously, clicking the share button while offline would silently hang or throw a generic error dialog after the network call timed out. Added a navigator.onLine check at the start of both the editor ShareButton and recordings overlay share flows to show a clear "You appear to be offline" dialog immediately. Fixes CapSoftware#368 Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
| await commands.globalMessageDialog( | ||
| "You appear to be offline. Please check your internet connection and try again.", | ||
| ); | ||
| throw new Error("No internet connection"); |
There was a problem hiding this comment.
When an offline user clicks share, this branch shows the friendly offline dialog and then throws a normal error. The mutation's local onError always opens another globalMessageDialog with that error message, so the user gets a second No internet connection dialog after dismissing the first one.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/routes/editor/ShareButton.tsx
Line: 36
Comment:
**Offline Error Shows Twice**
When an offline user clicks share, this branch shows the friendly offline dialog and then throws a normal error. The mutation's local `onError` always opens another `globalMessageDialog` with that error message, so the user gets a second `No internet connection` dialog after dismissing the first one.
How can I resolve this? If you propose a fix, please make it concise.| "You appear to be offline. Please check your internet connection and try again.", | ||
| ); | ||
| throw new Error("No internet connection"); | ||
| } |
There was a problem hiding this comment.
Offline Error Reaches Global Dialog
When an offline user clicks upload in the overlay, this branch first shows the clear offline dialog and then throws a normal error. This mutation has no local onError, so the app-wide mutation handler opens a second native dialog like Error\nError: No internet connection, which keeps the generic error popup on the new offline path.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/routes/recordings-overlay.tsx
Line: 728
Comment:
**Offline Error Reaches Global Dialog**
When an offline user clicks upload in the overlay, this branch first shows the clear offline dialog and then throws a normal error. This mutation has no local `onError`, so the app-wide mutation handler opens a second native dialog like `Error\nError: No internet connection`, which keeps the generic error popup on the new offline path.
How can I resolve this? If you propose a fix, please make it concise.| if (!navigator.onLine) { | ||
| throw new Error( | ||
| "You appear to be offline. Please check your internet connection and try again.", | ||
| ); | ||
| } | ||
| await commands.globalMessageDialog( | ||
| "You appear to be offline. Please check your internet connection and try again.", | ||
| ); | ||
| throw new Error("No internet connection"); | ||
| } |
There was a problem hiding this comment.
This block looks like it accidentally includes an extra } and (due to indentation) will always run the dialog/throw even when online. If the intent is to short-circuit when offline (and avoid the onError dialog), return early after showing the message.
| if (!navigator.onLine) { | |
| throw new Error( | |
| "You appear to be offline. Please check your internet connection and try again.", | |
| ); | |
| } | |
| await commands.globalMessageDialog( | |
| "You appear to be offline. Please check your internet connection and try again.", | |
| ); | |
| throw new Error("No internet connection"); | |
| } | |
| if (!navigator.onLine) { | |
| await commands.globalMessageDialog( | |
| "You appear to be offline. Please check your internet connection and try again.", | |
| ); | |
| return; | |
| } |
Replace thrown Error with a clean return after the offline dialog, so the mutation's onError/app-wide handler doesn't show a second "Error: No internet connection" popup on top of the friendly message. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
059ccf9 to
a47beb8
Compare
shashank-sn
left a comment
There was a problem hiding this comment.
Thanks for the review!
- Offline double-dialog: Fixed in a47beb8 — changed
throwtoreturnso the mutation's onError doesn't fire a second dialog. - Tooltip.tsx / virtual-grid.tsx / screenshot-editor/: These files have zero changes on this branch. Likely a review tool artifact — nothing to address here.
| await commands.globalMessageDialog( | ||
| "You appear to be offline. Please check your internet connection and try again.", | ||
| ); | ||
| return; |
There was a problem hiding this comment.
Minor gotcha: this return makes the mutation resolve successfully. If any UI behavior is keyed off mutation state (e.g. !upload.isIdle), you can end up flashing the upload/progress UI even though nothing started.
Might be cleaner to do the offline guard before calling upload.mutate() so the mutation stays idle, or to otherwise avoid treating “offline” as a successful mutation.
| await commands.globalMessageDialog( | ||
| "You appear to be offline. Please check your internet connection and try again.", | ||
| ); | ||
| return; |
There was a problem hiding this comment.
Same pattern here: returning after the dialog counts as a successful mutation, so onSuccess will still run and trigger recordingMeta.refetch() while offline.
Worth guarding onSuccess (or moving the offline check before calling the mutation) so the offline path doesn’t accidentally kick off extra work / error UI.
shashank-sn
left a comment
There was a problem hiding this comment.
All comments addressed:
- Double-dialog: Fixed in a47beb8 — changed
throwtoreturnso mutation onError doesn't fire a second dialog. - Mutation state concern (tembo): The
returndoes technically count as success, butonSuccessandonSettledonly reset UI state to idle — no fetch, no destructive side effects. Restructuring call sites for this would be complexity without value. - Tooltip.tsx / virtual-grid.tsx / screenshot-editor: Zero changes on this branch — false positives from the review tool.
Summary
Previously, clicking the share/upload button while offline would silently hang or throw a generic error dialog after the network call timed out. Added a
navigator.onLinecheck at the start of both share flows to show a clear "You appear to be offline" dialog immediately.Changes
apps/desktop/src/routes/editor/ShareButton.tsx— online check before auth/export/uploadapps/desktop/src/routes/recordings-overlay.tsx— online check before auth/uploadNotes
#1160 (capitalized email in auth) was traced and confirmed already fixed in main — the auth flow normalizes email case at every touchpoint:
createVerificationToken,useVerificationToken, the JWT callback, and the form submission.Greptile Summary
This PR adds early offline checks to the desktop sharing flows.
navigator.onLinebefore auth and upload work.navigator.onLinebefore auth and upload work.Confidence Score: 4/5
The offline share and upload paths need a small error-handling fix before merging.
apps/desktop/src/routes/editor/ShareButton.tsx; apps/desktop/src/routes/recordings-overlay.tsx
Important Files Changed
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix: show clear offline message when sha..." | Re-trigger Greptile
Context used: