Skip to content

fix: show clear offline message when share/upload button clicked without internet#1952

Open
shashank-sn wants to merge 2 commits into
CapSoftware:mainfrom
shashank-sn:fix/offline-share-handling
Open

fix: show clear offline message when share/upload button clicked without internet#1952
shashank-sn wants to merge 2 commits into
CapSoftware:mainfrom
shashank-sn:fix/offline-share-handling

Conversation

@shashank-sn

@shashank-sn shashank-sn commented Jun 29, 2026

Copy link
Copy Markdown

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.onLine check 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/upload
  • apps/desktop/src/routes/recordings-overlay.tsx — online check before auth/upload

Notes

#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.

  • Editor share/upload now checks navigator.onLine before auth and upload work.
  • Recordings overlay upload now checks navigator.onLine before auth and upload work.
  • Both paths show a clearer offline message before continuing error handling.

Confidence Score: 4/5

The offline share and upload paths need a small error-handling fix before merging.

  • The new offline checks show the intended friendly message.
  • The same offline error then flows into existing mutation error dialogs.
  • Users can still see duplicate or generic error popups on the changed paths.

apps/desktop/src/routes/editor/ShareButton.tsx; apps/desktop/src/routes/recordings-overlay.tsx

Important Files Changed

Filename Overview
apps/desktop/src/routes/editor/ShareButton.tsx Adds the offline guard before the editor upload flow, but the handled offline case still reaches the mutation error dialog.
apps/desktop/src/routes/recordings-overlay.tsx Adds the offline guard before overlay upload, but the thrown offline error still reaches the global mutation error dialog.
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/desktop/src/routes/editor/ShareButton.tsx:36
**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.

### Issue 2 of 2
apps/desktop/src/routes/recordings-overlay.tsx:728
**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.

Reviews (1): Last reviewed commit: "fix: show clear offline message when sha..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

Context used:

  • Context used - CLAUDE.md (source)
  • Context used - AGENTS.md (source)

…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");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

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");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Comment thread apps/desktop/src/routes/editor/ShareButton.tsx
Comment on lines +32 to +41
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");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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>
@shashank-sn shashank-sn force-pushed the fix/offline-share-handling branch from 059ccf9 to a47beb8 Compare June 29, 2026 02:24

@shashank-sn shashank-sn left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!

  • Offline double-dialog: Fixed in a47beb8 — changed throw to return so 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 shashank-sn left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All comments addressed:

  • Double-dialog: Fixed in a47beb8 — changed throw to return so mutation onError doesn't fire a second dialog.
  • Mutation state concern (tembo): The return does technically count as success, but onSuccess and onSettled only 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.

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