11import { AsciiArt } from "@components/AsciiArt" ;
22import { useAuthStore } from "@features/auth/stores/authStore" ;
3- import { FolderPicker } from "@features/folder-picker/components/FolderPicker" ;
43import {
54 Box ,
65 Button ,
@@ -13,14 +12,11 @@ import {
1312 Spinner ,
1413 Text ,
1514} from "@radix-ui/themes" ;
16- import { logger } from "@renderer/lib/logger" ;
1715import type { CloudRegion } from "@shared/types/oauth" ;
1816import { useMutation } from "@tanstack/react-query" ;
19- import { useEffect , useState } from "react" ;
17+ import { useState } from "react" ;
2018import { IS_DEV } from "@/constants/environment" ;
2119
22- const log = logger . scope ( "auth" ) ;
23-
2420export const getErrorMessage = ( error : unknown ) => {
2521 if ( ! ( error instanceof Error ) ) {
2622 return "Failed to authenticate" ;
@@ -38,53 +34,14 @@ export const getErrorMessage = (error: unknown) => {
3834 return message ;
3935} ;
4036
41- const detectWorkspacePath = async ( ) => {
42- try {
43- const detectedPath = await window . electronAPI . findReposDirectory ( ) ;
44- if ( detectedPath ) {
45- return detectedPath ;
46- }
47- } catch ( error ) {
48- log . error ( "Failed to detect repos directory:" , error ) ;
49- }
50-
51- return null ;
52- } ;
53-
5437export function AuthScreen ( ) {
5538 const [ region , setRegion ] = useState < CloudRegion > ( "us" ) ;
56- const [ workspace , setWorkspace ] = useState ( "~/workspace" ) ;
57- const [ workspaceError , setWorkspaceError ] = useState < string | null > ( null ) ;
58-
59- const { loginWithOAuth, setDefaultWorkspace } = useAuthStore ( ) ;
6039
61- useEffect ( ( ) => {
62- detectWorkspacePath ( ) . then ( ( path ) => {
63- if ( path ) {
64- setWorkspace ( path ) ;
65- }
66- } ) ;
67- } , [ ] ) ;
40+ const { loginWithOAuth } = useAuthStore ( ) ;
6841
6942 const authMutation = useMutation ( {
70- mutationFn : async ( {
71- selectedRegion,
72- workspace,
73- } : {
74- selectedRegion : CloudRegion ;
75- workspace : string ;
76- } ) => {
77- if ( ! workspace || ! workspace . trim ( ) ) {
78- setWorkspaceError ( "Please select a clone location" ) ;
79- throw new Error ( "Clone location is required" ) ;
80- }
81-
82- // Login with OAuth first
43+ mutationFn : async ( selectedRegion : CloudRegion ) => {
8344 await loginWithOAuth ( selectedRegion ) ;
84-
85- // Then save workspace
86- setDefaultWorkspace ( workspace . trim ( ) ) ;
87- setWorkspaceError ( null ) ;
8845 } ,
8946 } ) ;
9047
@@ -93,8 +50,7 @@ export function AuthScreen() {
9350 authMutation . reset ( ) ;
9451 await window . electronAPI . oauthCancelFlow ( ) ;
9552 } else {
96- setWorkspaceError ( null ) ;
97- authMutation . mutate ( { selectedRegion : region , workspace } ) ;
53+ authMutation . mutate ( region ) ;
9854 }
9955 } ;
10056
@@ -144,28 +100,6 @@ export function AuthScreen() {
144100 </ Select . Root >
145101 </ Flex >
146102
147- < Flex direction = "column" gap = "2" >
148- < Text as = "label" size = "2" weight = "medium" color = "gray" >
149- Default clone location
150- </ Text >
151- < FolderPicker
152- value = { workspace }
153- onChange = { setWorkspace }
154- placeholder = "~/repos"
155- size = "2"
156- />
157- < Text size = "1" color = "gray" >
158- Where repositories will be cloned. This should be the
159- folder where you usually store your projects.
160- </ Text >
161- </ Flex >
162-
163- { workspaceError && (
164- < Callout . Root color = "red" >
165- < Callout . Text > { workspaceError } </ Callout . Text >
166- </ Callout . Root >
167- ) }
168-
169103 { authMutation . isError && (
170104 < Callout . Root color = "red" >
171105 < Callout . Text >
@@ -184,7 +118,6 @@ export function AuthScreen() {
184118
185119 < Button
186120 onClick = { handleSignIn }
187- disabled = { ! workspace }
188121 variant = { "classic" }
189122 size = "3"
190123 mt = "2"
0 commit comments