Skip to content

Commit ae957c3

Browse files
committed
some tweaks
1 parent 807d754 commit ae957c3

File tree

2 files changed

+91
-18
lines changed

2 files changed

+91
-18
lines changed

src/main/services/oauth.ts

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,27 @@ async function startCallbackServer(authUrl: string): Promise<{
6262
"Content-Type": "text/html",
6363
});
6464
res.end(`
65-
<html>
66-
<body>
67-
<p>${
68-
isAccessDenied
69-
? "Authorization cancelled."
70-
: `Authorization failed.`
71-
}</p>
72-
<p>Return to Array. This window will close automatically.</p>
73-
<script>window.close();</script>
65+
<!DOCTYPE html>
66+
<html class="radix-themes" data-is-root-theme="true" data-accent-color="orange" data-gray-color="slate" data-has-background="true" data-panel-background="translucent" data-radius="none" data-scaling="100%">
67+
<head>
68+
<meta charset="utf-8">
69+
<title>Authorization ${isAccessDenied ? "Cancelled" : "Failed"}</title>
70+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@radix-ui/[email protected]/styles.css">
71+
<script src="https://cdn.tailwindcss.com"></script>
72+
<style>
73+
@layer utilities {
74+
.text-gray-12 { color: var(--gray-12); }
75+
.text-gray-11 { color: var(--gray-11); }
76+
.bg-gray-1 { background-color: var(--gray-1); }
77+
}
78+
</style>
79+
</head>
80+
<body class="dark bg-gray-1 h-screen overflow-hidden flex flex-col items-center justify-center m-0 gap-2">
81+
<h1 class="text-gray-12 text-xl font-semibold">${isAccessDenied ? "Authorization cancelled" : "Authorization failed"}</h1>
82+
<p class="text-gray-11 text-sm">You can close this window and return to Array</p>
83+
<script>
84+
setTimeout(() => window.close(), 500);
85+
</script>
7486
</body>
7587
</html>
7688
`);
@@ -81,21 +93,63 @@ async function startCallbackServer(authUrl: string): Promise<{
8193
if (code) {
8294
res.writeHead(200, { "Content-Type": "text/html" });
8395
res.end(`
84-
<html>
85-
<body>
86-
<p>Authorization successful! Return to Array.</p>
87-
<script>window.close();</script>
96+
<!DOCTYPE html>
97+
<html class="radix-themes" data-is-root-theme="true" data-accent-color="orange" data-gray-color="slate" data-has-background="true" data-panel-background="translucent" data-radius="none" data-scaling="100%">
98+
<head>
99+
<meta charset="utf-8">
100+
<title>Authorization Successful</title>
101+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@radix-ui/[email protected]/styles.css">
102+
<script src="https://cdn.tailwindcss.com"></script>
103+
<style>
104+
@layer utilities {
105+
.text-accent-9 { color: var(--accent-9); }
106+
.text-green-9 { color: var(--green-9); }
107+
.text-gray-11 { color: var(--gray-11); }
108+
.text-gray-12 { color: var(--gray-12); }
109+
.bg-gray-1 { background-color: var(--gray-1); }
110+
.bg-green-9 { background-color: var(--green-9); }
111+
.border-gray-6 { border-color: var(--gray-6); }
112+
}
113+
</style>
114+
</head>
115+
<body class="dark bg-gray-1 h-screen overflow-hidden flex flex-col items-center justify-center m-0 gap-2">
116+
<h1 class="text-gray-12 text-xl font-semibold">Authorization successful!</h1>
117+
<p class="text-gray-11 text-sm">You can close this window and return to Array</p>
118+
<script>
119+
setTimeout(() => window.close(), 500);
120+
</script>
88121
</body>
89122
</html>
90123
`);
91124
callbackResolve(code);
92125
} else {
93126
res.writeHead(400, { "Content-Type": "text/html" });
94127
res.end(`
95-
<html>
96-
<body>
97-
<p>Invalid request - no authorization code received.</p>
98-
<p>You can close this window.</p>
128+
<!DOCTYPE html>
129+
<html class="radix-themes" data-is-root-theme="true" data-accent-color="orange" data-gray-color="slate" data-has-background="true" data-panel-background="translucent" data-radius="none" data-scaling="100%">
130+
<head>
131+
<meta charset="utf-8">
132+
<title>Invalid Request</title>
133+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@radix-ui/[email protected]/styles.css">
134+
<script src="https://cdn.tailwindcss.com"></script>
135+
<style>
136+
@layer utilities {
137+
.text-accent-9 { color: var(--accent-9); }
138+
.text-red-9 { color: var(--red-9); }
139+
.text-gray-11 { color: var(--gray-11); }
140+
.text-gray-12 { color: var(--gray-12); }
141+
.bg-gray-1 { background-color: var(--gray-1); }
142+
.bg-gray-12 { background-color: var(--gray-12); }
143+
.border-gray-6 { border-color: var(--gray-6); }
144+
}
145+
</style>
146+
</head>
147+
<body class="dark bg-gray-1 h-screen overflow-hidden flex flex-col items-center justify-center m-0 gap-2">
148+
<h1 class="text-gray-12 text-xl font-semibold">Invalid request</h1>
149+
<p class="text-gray-11 text-sm">You can close this window and return to Array</p>
150+
<script>
151+
setTimeout(() => window.close(), 500);
152+
</script>
99153
</body>
100154
</html>
101155
`);
@@ -229,7 +283,6 @@ export async function performOAuthFlow(
229283

230284
activeCloseServer = closeServer;
231285

232-
// Open browser
233286
await shell.openExternal(localLoginUrl);
234287

235288
try {

src/renderer/features/auth/stores/authStore.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { PostHogAPIClient } from "@api/posthogClient";
22
import { queryClient } from "@renderer/lib/queryClient";
3+
import { useTabStore } from "@renderer/stores/tabStore";
34
import type { CloudRegion } from "@shared/types/oauth";
45
import { create } from "zustand";
56
import { persist } from "zustand/middleware";
@@ -116,7 +117,18 @@ export const useAuthStore = create<AuthState>()(
116117
projectId,
117118
});
118119

120+
// Clear any cached data from previous sessions AFTER setting new auth
121+
queryClient.clear();
122+
119123
get().scheduleTokenRefresh();
124+
125+
// Navigate to task list after successful authentication
126+
const taskListTab = useTabStore
127+
.getState()
128+
.tabs.find((tab) => tab.type === "task-list");
129+
if (taskListTab) {
130+
useTabStore.getState().setActiveTab(taskListTab.id);
131+
}
120132
} catch {
121133
throw new Error("Failed to authenticate with PostHog");
122134
}
@@ -291,6 +303,14 @@ export const useAuthStore = create<AuthState>()(
291303

292304
get().scheduleTokenRefresh();
293305

306+
// Navigate to task list after successful authentication
307+
const taskListTab = useTabStore
308+
.getState()
309+
.tabs.find((tab) => tab.type === "task-list");
310+
if (taskListTab) {
311+
useTabStore.getState().setActiveTab(taskListTab.id);
312+
}
313+
294314
if (state.encryptedOpenaiKey) {
295315
const decryptedOpenaiKey =
296316
await window.electronAPI.retrieveApiKey(

0 commit comments

Comments
 (0)