chore: auto focus windows post auth

This commit is contained in:
haritabh-z01 2025-12-02 21:15:55 +05:30
parent e9b32dd705
commit 5dbc44a6ca
2 changed files with 33 additions and 14 deletions

View file

@ -46,7 +46,19 @@ export class AppManager {
}
}
// Add other deep link handlers here in the future
// Auto-focus the appropriate window after handling deep link
const onboardingWindow = this.windowManager.getOnboardingWindow();
if (onboardingWindow && !onboardingWindow.isDestroyed()) {
onboardingWindow.show();
onboardingWindow.focus();
} else {
// Create or show main window
this.windowManager.createOrShowMainWindow();
const mainWindow = this.windowManager.getMainWindow();
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.focus();
}
}
} catch (error) {
logger.main.error("Error handling deep link:", error);
}

View file

@ -44,28 +44,35 @@ export function ModelSetupModal({
const [installedModelName, setInstalledModelName] = useState<string>("");
const [downloadComplete, setDownloadComplete] = useState(false);
// tRPC mutations and utils
const utils = api.useUtils();
// tRPC mutations
const loginMutation = api.auth.login.useMutation({
onSuccess: async () => {
// After login, check auth status
const authStatus = await utils.auth.getAuthStatus.fetch();
if (authStatus.isAuthenticated) {
toast.success("Successfully authenticated!");
onContinue();
} else {
setError("Authentication failed. Please try again.");
}
setIsLoading(false);
onSuccess: () => {
// Browser opened, waiting for OAuth completion via subscription
toast.info("Complete login in your browser");
},
onError: (err) => {
console.error("OAuth error:", err);
setError("Failed to authenticate. Please try again.");
setError("Failed to open login. Please try again.");
setIsLoading(false);
},
});
const downloadModelMutation = api.models.downloadModel.useMutation();
// Subscribe to auth state changes for Cloud model OAuth completion
api.auth.onAuthStateChange.useSubscription(undefined, {
onData: (authState) => {
if (authState.isAuthenticated && isLoading) {
toast.success("Successfully authenticated!");
setIsLoading(false);
onContinue();
}
},
onError: (error) => {
console.error("Auth state subscription error:", error);
},
enabled: modelType === ModelType.Cloud && isOpen,
});
// Check for existing downloaded models
const { data: downloadedModels } = api.models.getDownloadedModels.useQuery(
undefined,