From d4d297b69e84f63d0ad5ead840368af333bf2dcf Mon Sep 17 00:00:00 2001 From: Local Dev Date: Thu, 8 Oct 2026 01:08:38 +0200 Subject: [PATCH] Theseus: an add-on's link to a sidebar app's site opens in that app An add-on's "Send on Telegram" used to open web.telegram.org in a new tab. Theseus already has Telegram and WhatsApp in the sidebar, signed in, so a link to the site of an app on the strip now opens in its panel at that address (a share screen, a chat). Everything else still opens in a tab. --- main.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index c94fc3df..0c3799d5 100644 --- a/main.js +++ b/main.js @@ -3158,7 +3158,14 @@ function initAddons() { }, hostRequire: (name) => require(name), hostImport: (name) => import(require("node:url").pathToFileURL(require.resolve(name)).href), - openTab: (url) => { if (win) createTab(url); }, + // A link to a sidebar app's site (an add-on's "Send on Telegram") opens + // in that app's panel, where the user is already signed in. + openTab: (url) => { + if (!win) return; + const L = quickLinkFor(url); + if (L && quickPanel) return openQuickPanel(L.id, url); + createTab(url); + }, // openSettings: routes through the existing "open-settings" IPC handler // so the same section-hint validation applies. Add-ons hit this when they // want to point users at Passwords, Extensions, etc. @@ -9328,7 +9335,18 @@ function closeLeftPanel() { emitQuickLinksState(); try { leftPanel?.webContents.send("sidebar-visibility", false); } catch {} } -function openQuickPanel(id) { +// The sidebar app for a URL's site (web.telegram.org -> Telegram), if the +// strip is on and has one. +function quickLinkFor(url) { + if (!settings.quickLinksShow) return null; + let host; + try { host = new URL(url).host; } catch { return null; } + return (settings.quickLinks || []).find((L) => { try { return new URL(L.url).host === host; } catch { return false; } }) || null; +} + +// at: an address on the app's site to show (a share screen, a chat), even +// when the panel already has that site open. +function openQuickPanel(id, at) { const L = (settings.quickLinks || []).find((x) => x.id === id); if (!quickPanel || !L || !L.url) return; if (leftPanelId) closeLeftPanel(); @@ -9340,7 +9358,8 @@ function openQuickPanel(id) { // avoids blowing away the user's state (open chat, scroll position) // when they click the icon to reopen the panel they just closed. const sameHost = (() => { try { return cur && new URL(cur).host === new URL(L.url).host; } catch { return false; } })(); - if (!sameHost) quickPanel.webContents.loadURL(L.url); + if (at) quickPanel.webContents.loadURL(at); + else if (!sameHost) quickPanel.webContents.loadURL(L.url); } catch (e) { console.warn("[quicklinks] loadURL failed:", e?.message); } raisePanelGrip(); layout();