feat: add URL-driven workspace state and streamed Codex research
This commit is contained in:
@@ -1,34 +1,34 @@
|
||||
export type SafeOwner = {
|
||||
id: number
|
||||
email: string
|
||||
name: string
|
||||
onboardingCompletedAt: number | null
|
||||
}
|
||||
id: number;
|
||||
email: string;
|
||||
name: string;
|
||||
onboardingCompletedAt: number | null;
|
||||
};
|
||||
|
||||
export type AuthState = { needsSetup: boolean; owner: SafeOwner | null }
|
||||
export type AuthState = { needsSetup: boolean; owner: SafeOwner | null };
|
||||
|
||||
type AuthInput =
|
||||
| { action: 'login'; email: string; password: string }
|
||||
| { action: "login"; email: string; password: string }
|
||||
| {
|
||||
action: 'setup'
|
||||
email: string
|
||||
password: string
|
||||
name: string
|
||||
setupToken: string
|
||||
action: "setup";
|
||||
email: string;
|
||||
password: string;
|
||||
name: string;
|
||||
setupToken: string;
|
||||
}
|
||||
| { action: 'logout' }
|
||||
| { action: 'onboard'; name: string }
|
||||
| { action: "logout" }
|
||||
| { action: "onboard"; name: string };
|
||||
|
||||
export async function authRequest(input: AuthInput): Promise<AuthState> {
|
||||
const response = await fetch('/api/auth', {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
const response = await fetch("/api/auth", {
|
||||
method: "POST",
|
||||
credentials: "same-origin",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(input),
|
||||
})
|
||||
const result = await response.json()
|
||||
});
|
||||
const result = await response.json();
|
||||
if (!response.ok) {
|
||||
throw new Error(result.error || 'Something went wrong. Please try again.')
|
||||
throw new Error(result.error || "Something went wrong. Please try again.");
|
||||
}
|
||||
return result
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user