mirror of
https://github.com/block/goose.git
synced 2026-07-09 16:09:22 +00:00
Add goose://resume session deep link (#9343)
This commit is contained in:
parent
cd68f068f3
commit
133466b6f8
1 changed files with 38 additions and 0 deletions
|
|
@ -420,6 +420,15 @@ if (process.platform !== 'darwin') {
|
|||
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
|
||||
handleProtocolUrl(protocolUrl);
|
||||
}
|
||||
|
|
@ -448,6 +457,26 @@ if (process.platform !== 'darwin') {
|
|||
const pendingDeepLinks = new Map<number, string>(); // windowId -> deep link URL
|
||||
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) {
|
||||
if (!url) return;
|
||||
|
||||
|
|
@ -458,6 +487,9 @@ async function handleProtocolUrl(url: string) {
|
|||
if (parsedUrl.hostname === 'new-session') {
|
||||
await createChat(app, { dir: openDir || undefined });
|
||||
return;
|
||||
} else if (parsedUrl.hostname === 'resume') {
|
||||
await createResumeChatWindow(parsedUrl, openDir || undefined);
|
||||
return;
|
||||
} else if (parsedUrl.hostname === 'bot' || parsedUrl.hostname === 'recipe') {
|
||||
const existingWindows = BrowserWindow.getAllWindows();
|
||||
const targetWindow =
|
||||
|
|
@ -528,6 +560,12 @@ app.on('open-url', async (_event, url) => {
|
|||
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
|
||||
if (parsedUrl.hostname === 'bot' || parsedUrl.hostname === 'recipe') {
|
||||
log.info('[Main] Detected bot/recipe URL, creating new chat window');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue