Add goose://resume session deep link (#9343)
This commit is contained in:
@@ -420,6 +420,15 @@ if (process.platform !== 'darwin') {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parsedUrl.hostname === 'resume') {
|
||||||
|
app.whenReady().then(async () => {
|
||||||
|
const recentDirs = loadRecentDirs();
|
||||||
|
const openDir = recentDirs.length > 0 ? recentDirs[0] : null;
|
||||||
|
await createResumeChatWindow(parsedUrl, openDir || undefined);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// For non-bot URLs, continue with normal handling
|
// For non-bot URLs, continue with normal handling
|
||||||
handleProtocolUrl(protocolUrl);
|
handleProtocolUrl(protocolUrl);
|
||||||
}
|
}
|
||||||
@@ -448,6 +457,26 @@ if (process.platform !== 'darwin') {
|
|||||||
const pendingDeepLinks = new Map<number, string>(); // windowId -> deep link URL
|
const pendingDeepLinks = new Map<number, string>(); // windowId -> deep link URL
|
||||||
let openUrlHandledLaunch = false;
|
let openUrlHandledLaunch = false;
|
||||||
|
|
||||||
|
function getResumeSessionId(parsedUrl: URL): string | null {
|
||||||
|
try {
|
||||||
|
const sessionId = decodeURIComponent(parsedUrl.pathname.replace(/^\/+/, '')).trim();
|
||||||
|
return sessionId || null;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createResumeChatWindow(parsedUrl: URL, dir?: string): Promise<boolean> {
|
||||||
|
const resumeSessionId = getResumeSessionId(parsedUrl);
|
||||||
|
if (!resumeSessionId) {
|
||||||
|
log.warn('[Main] Ignoring goose://resume URL without a session id');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
await createChat(app, { dir, resumeSessionId });
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
async function handleProtocolUrl(url: string) {
|
async function handleProtocolUrl(url: string) {
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
@@ -458,6 +487,9 @@ async function handleProtocolUrl(url: string) {
|
|||||||
if (parsedUrl.hostname === 'new-session') {
|
if (parsedUrl.hostname === 'new-session') {
|
||||||
await createChat(app, { dir: openDir || undefined });
|
await createChat(app, { dir: openDir || undefined });
|
||||||
return;
|
return;
|
||||||
|
} else if (parsedUrl.hostname === 'resume') {
|
||||||
|
await createResumeChatWindow(parsedUrl, openDir || undefined);
|
||||||
|
return;
|
||||||
} else if (parsedUrl.hostname === 'bot' || parsedUrl.hostname === 'recipe') {
|
} else if (parsedUrl.hostname === 'bot' || parsedUrl.hostname === 'recipe') {
|
||||||
const existingWindows = BrowserWindow.getAllWindows();
|
const existingWindows = BrowserWindow.getAllWindows();
|
||||||
const targetWindow =
|
const targetWindow =
|
||||||
@@ -528,6 +560,12 @@ app.on('open-url', async (_event, url) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parsedUrl.hostname === 'resume') {
|
||||||
|
log.info('[Main] Detected resume URL, creating session resume window');
|
||||||
|
openUrlHandledLaunch = await createResumeChatWindow(parsedUrl, openDir || undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle bot/recipe URLs by directly creating a new window
|
// Handle bot/recipe URLs by directly creating a new window
|
||||||
if (parsedUrl.hostname === 'bot' || parsedUrl.hostname === 'recipe') {
|
if (parsedUrl.hostname === 'bot' || parsedUrl.hostname === 'recipe') {
|
||||||
log.info('[Main] Detected bot/recipe URL, creating new chat window');
|
log.info('[Main] Detected bot/recipe URL, creating new chat window');
|
||||||
|
|||||||
Reference in New Issue
Block a user