Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/desktop/src/lib/electron-app/factories/app/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export async function makeAppSetup(
// Always prevent in-app navigation for external URLs
if (url.startsWith("http://") || url.startsWith("https://")) {
event.preventDefault();
shell.openExternal(url);
shell.openExternal(url).catch((error) => {
console.error("[app] Failed to open external URL:", url, error);
});
}
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export function createWindow({ id, ...settings }: WindowProps) {
// Open external URLs in the system browser instead of Electron
window.webContents.setWindowOpenHandler(({ url }) => {
if (url.startsWith("http://") || url.startsWith("https://")) {
shell.openExternal(url);
shell.openExternal(url).catch((error) => {
console.error("[window] Failed to open external URL:", url, error);
});
return { action: "deny" };
}
return { action: "deny" };
Expand Down
13 changes: 12 additions & 1 deletion apps/desktop/src/lib/trpc/routers/external/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { settings } from "@superset/local-db";
import { TRPCError } from "@trpc/server";
import { clipboard, shell } from "electron";
import { localDb } from "main/lib/local-db";
import { z } from "zod";
Expand Down Expand Up @@ -38,7 +39,17 @@ async function openPathInApp(
export const createExternalRouter = () => {
return router({
openUrl: publicProcedure.input(z.string()).mutation(async ({ input }) => {
await shell.openExternal(input);
try {
await shell.openExternal(input);
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : "Unknown error";
console.error("[external/openUrl] Failed to open URL:", input, error);
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: errorMessage,
});
}
}),

openInFinder: publicProcedure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { toast } from "@superset/ui/sonner";
import { CanvasAddon } from "@xterm/addon-canvas";
import { ClipboardAddon } from "@xterm/addon-clipboard";
import { FitAddon } from "@xterm/addon-fit";
Expand Down Expand Up @@ -135,6 +136,12 @@ export function createTerminalInstance(
const urlLinkProvider = new UrlLinkProvider(xterm, (_event, uri) => {
trpcClient.external.openUrl.mutate(uri).catch((error) => {
console.error("[Terminal] Failed to open URL:", uri, error);
toast.error("Failed to open URL", {
description:
error instanceof Error
? error.message
: "Could not open URL in browser",
});
});
});
xterm.registerLinkProvider(urlLinkProvider);
Expand Down
Loading