@@ -34,7 +34,13 @@ export default function Login() {
3434 // Always call hooks unconditionally - React Hooks must be called in the same order
3535 const stackApp = useStackApp ( ) ;
3636 const app = HAS_STACK_KEYS ? stackApp : null ;
37- const { setAuth, setModelType, setLocalProxyValue } = useAuthStore ( ) ;
37+ const {
38+ setAuth,
39+ setModelType,
40+ setLocalProxyValue,
41+ setInitState,
42+ setIsFirstLaunch,
43+ } = useAuthStore ( ) ;
3844 const navigate = useNavigate ( ) ;
3945 const location = useLocation ( ) ;
4046 const { t } = useTranslation ( ) ;
@@ -98,6 +104,9 @@ export default function Login() {
98104
99105 setAuth ( { email : data . email , ...data } ) ;
100106 setLocalProxyValue ( import . meta. env . VITE_USE_LOCAL_PROXY || null ) ;
107+ setModelType ( 'custom' ) ;
108+ setInitState ( 'done' ) ;
109+ setIsFirstLaunch ( false ) ;
101110 navigate ( '/' ) ;
102111 } catch ( error : any ) {
103112 console . error ( 'Auto login failed:' , error ) ;
@@ -272,17 +281,15 @@ export default function Login() {
272281 } ;
273282 } , [ ] ) ;
274283
275- // Hybrid/app mode: get auth callback URL from Electron and open signin page
284+ // Hybrid/app mode: prepare auth callback URL on mount (don't auto- open browser)
276285 useEffect ( ( ) => {
277286 if ( IS_LOCAL_MODE ) return ;
278287
279- const openSignin = async ( ) => {
288+ const prepareCallbackUrl = async ( ) => {
280289 let cbUrl : string ;
281290 if ( import . meta. env . PROD ) {
282- // Production (packaged app): use eigent:// custom protocol
283291 cbUrl = 'eigent://auth/callback' ;
284292 } else {
285- // Dev mode: use local HTTP server (eigent:// doesn't route to existing dev process)
286293 cbUrl = 'eigent://auth/callback' ;
287294 try {
288295 const url = await window . ipcRenderer ?. invoke ( 'get-auth-callback-url' ) ;
@@ -292,14 +299,9 @@ export default function Login() {
292299 }
293300 }
294301 setCallbackUrl ( cbUrl ) ;
295- window . open (
296- `https://www.eigent.ai/signin?callbackUrl=${ encodeURIComponent ( cbUrl ) } ` ,
297- '_blank' ,
298- 'noopener,noreferrer'
299- ) ;
300302 } ;
301303
302- openSignin ( ) ;
304+ prepareCallbackUrl ( ) ;
303305 } , [ ] ) ;
304306
305307 // Render local mode: "Start Eigent" button only
@@ -341,17 +343,20 @@ export default function Login() {
341343 < div className = "mb-4 text-heading-lg font-bold text-text-heading" >
342344 { t ( 'layout.login' ) }
343345 </ div >
344- < p className = "mb-6 text-center text-label-md text-text-secondary" >
345- { t ( 'layout.logging-in' ) } ...
346- </ p >
346+ { isLoading && (
347+ < p className = "mb-6 text-center text-label-md text-text-secondary" >
348+ { t ( 'layout.logging-in' ) } ...
349+ </ p >
350+ ) }
347351 < Button
348- onClick = { ( ) =>
352+ onClick = { ( ) => {
353+ setIsLoading ( true ) ;
349354 window . open (
350355 `https://www.eigent.ai/signin?callbackUrl=${ encodeURIComponent ( callbackUrl || 'eigent://auth/callback' ) } ` ,
351356 '_blank' ,
352357 'noopener,noreferrer'
353- )
354- }
358+ ) ;
359+ } }
355360 size = "lg"
356361 variant = "primary"
357362 className = "w-full rounded-full"
0 commit comments