@@ -26,6 +26,7 @@ import { useSystemThemeDetector } from './hooks/use-system-theme-detector'
2626import { useChatStore } from './state/chat-store'
2727import { flushAnalytics } from './utils/analytics'
2828import { getUserCredentials } from './utils/auth'
29+ import { LOGO } from './login/constants'
2930import { createChatScrollAcceleration } from './utils/chat-scroll-accel'
3031import { formatQueuedPreview } from './utils/helpers'
3132import { loadLocalAgents } from './utils/local-agent-registry'
@@ -42,6 +43,10 @@ type ChatVariant = 'ai' | 'user' | 'agent'
4243const MAX_VIRTUALIZED_TOP_LEVEL = 60
4344const VIRTUAL_OVERSCAN = 12
4445
46+ const LOGO_BLOCK = LOGO . split ( '\n' )
47+ . filter ( ( line ) => line . length > 0 )
48+ . join ( '\n' )
49+
4550type AgentMessage = {
4651 agentName : string
4752 agentType : string
@@ -137,17 +142,20 @@ export const App = ({
137142 const authQuery = useAuthQuery ( )
138143 const logoutMutation = useLogoutMutation ( )
139144
140- // If requireAuth is null (checking), assume not authenticated until proven otherwise
141- const [ isAuthenticated , setIsAuthenticated ] = useState (
142- requireAuth === false ? true : false ,
145+ // If requireAuth is null (checking), defer showing auth UI until resolved
146+ const initialAuthState =
147+ requireAuth === false ? true : requireAuth === true ? false : null
148+ const [ isAuthenticated , setIsAuthenticated ] = useState < boolean | null > (
149+ initialAuthState ,
143150 )
144151 const [ user , setUser ] = useState < User | null > ( null )
145152
146153 // Update authentication state when requireAuth changes
147154 useEffect ( ( ) => {
148- if ( requireAuth ! == null ) {
149- setIsAuthenticated ( ! requireAuth )
155+ if ( requireAuth = == null ) {
156+ return
150157 }
158+ setIsAuthenticated ( ! requireAuth )
151159 } , [ requireAuth ] )
152160
153161 // Update authentication state based on query results
@@ -188,18 +196,44 @@ export const App = ({
188196 useEffect ( ( ) => {
189197 if ( loadedAgentsData && messages . length === 0 ) {
190198 const agentListId = 'loaded-agents-list'
199+ const userCredentials = getUserCredentials ( )
200+ const greeting = userCredentials ?. name ?. trim ( ) . length
201+ ? `Welcome back, ${ userCredentials . name . trim ( ) } !`
202+ : null
203+
204+ const blocks : ContentBlock [ ] = [
205+ {
206+ type : 'text' ,
207+ content : '\n\n' + LOGO_BLOCK ,
208+ } ,
209+ ]
210+
211+ if ( greeting ) {
212+ blocks . push ( {
213+ type : 'text' ,
214+ content : greeting ,
215+ } )
216+ }
217+
218+ blocks . push (
219+ {
220+ type : 'text' ,
221+ content :
222+ 'Codebuff can read and write files in this repository, and run terminal commands to help you build.' ,
223+ } ,
224+ {
225+ type : 'agent-list' ,
226+ id : agentListId ,
227+ agents : loadedAgentsData . agents ,
228+ agentsDir : loadedAgentsData . agentsDir ,
229+ } ,
230+ )
231+
191232 const initialMessage : ChatMessage = {
192233 id : `system-loaded-agents-${ Date . now ( ) } ` ,
193234 variant : 'ai' ,
194235 content : '' , // Content is in the block
195- blocks : [
196- {
197- type : 'agent-list' ,
198- id : agentListId ,
199- agents : loadedAgentsData . agents ,
200- agentsDir : loadedAgentsData . agentsDir ,
201- } ,
202- ] ,
236+ blocks,
203237 timestamp : new Date ( ) . toISOString ( ) ,
204238 }
205239
@@ -298,7 +332,7 @@ export const App = ({
298332 )
299333
300334 useEffect ( ( ) => {
301- if ( ! isAuthenticated ) return
335+ if ( isAuthenticated !== true ) return
302336
303337 setInputFocused ( true )
304338
@@ -1010,7 +1044,7 @@ export const App = ({
10101044 </ box >
10111045
10121046 { /* Login Modal Overlay - show when not authenticated */ }
1013- { ! isAuthenticated && (
1047+ { isAuthenticated === false && (
10141048 < LoginModal
10151049 onLoginSuccess = { handleLoginSuccess }
10161050 theme = { theme }
0 commit comments