Support deep link for Dyad Pro (#25)

This commit is contained in:
Will Chen
2025-04-26 10:58:11 -07:00
committed by GitHub
parent 4848b2f085
commit eda2f9206d
6 changed files with 174 additions and 30 deletions

View File

@@ -8,6 +8,7 @@ import { updateElectronApp } from "update-electron-app";
import log from "electron-log";
import { readSettings, writeSettings } from "./main/settings";
import { handleSupabaseOAuthReturn } from "./supabase_admin/supabase_return_handler";
import { handleDyadProReturn } from "./main/pro";
log.errorHandler.startCatching();
log.eventLogger.startLogging();
@@ -185,6 +186,32 @@ function handleDeepLinkReturn(url: string) {
});
return;
}
// dyad://dyad-pro-return?key=123&budget_reset_at=2025-05-26T16:31:13.492000Z&max_budget=100
if (parsed.hostname === "dyad-pro-return") {
const apiKey = parsed.searchParams.get("key");
// UTC time
// budget_reset_at: '2025-05-26T16:31:13.492000Z'
const budgetResetAt = parsed.searchParams.get("budget_reset_at");
const maxBudget = Number(parsed.searchParams.get("max_budget"));
if (!apiKey) {
dialog.showErrorBox(
"Invalid URL",
"Expected key, budget_reset_at, and max_budget"
);
return;
}
handleDyadProReturn({
apiKey,
budgetResetAt,
maxBudget,
});
// Send message to renderer to trigger re-render
mainWindow?.webContents.send("deep-link-received", {
type: parsed.hostname,
url,
});
return;
}
dialog.showErrorBox("Invalid deep link URL", url);
}