@@ -285,17 +285,6 @@ export const App = ({
285285 )
286286 }
287287
288- // Render chat history screen when requested
289- if ( showChatHistory ) {
290- return (
291- < ChatHistoryScreen
292- onSelectChat = { handleResumeChat }
293- onCancel = { closeChatHistory }
294- onNewChat = { handleNewChat }
295- />
296- )
297- }
298-
299288 // Use key to force remount when resuming a different chat from history
300289 const chatKey = resumeChatId ?? 'current'
301290
@@ -316,6 +305,10 @@ export const App = ({
316305 initialMode = { initialMode }
317306 gitRoot = { gitRoot }
318307 onSwitchToGitRoot = { handleSwitchToGitRoot }
308+ showChatHistory = { showChatHistory }
309+ onSelectChat = { handleResumeChat }
310+ onCancelChatHistory = { closeChatHistory }
311+ onNewChat = { handleNewChat }
319312 />
320313 )
321314}
@@ -336,6 +329,10 @@ interface AuthedSurfaceProps {
336329 initialMode : AgentMode | undefined
337330 gitRoot : string | null | undefined
338331 onSwitchToGitRoot : ( ) => void
332+ showChatHistory : boolean
333+ onSelectChat : ( chatId : string ) => void
334+ onCancelChatHistory : ( ) => void
335+ onNewChat : ( ) => void
339336}
340337
341338/**
@@ -359,6 +356,10 @@ const AuthedSurface = ({
359356 initialMode,
360357 gitRoot,
361358 onSwitchToGitRoot,
359+ showChatHistory,
360+ onSelectChat,
361+ onCancelChatHistory,
362+ onNewChat,
362363} : AuthedSurfaceProps ) => {
363364 const { session, error : sessionError } = useFreebuffSession ( )
364365
@@ -388,6 +389,20 @@ const AuthedSurface = ({
388389 return < WaitingRoomScreen session = { session } error = { sessionError } />
389390 }
390391
392+ // Chat history renders inside AuthedSurface so the freebuff session stays
393+ // mounted while the user browses history. Unmounting this surface would
394+ // DELETE the session row and drop the user back into the waiting room on
395+ // return.
396+ if ( showChatHistory ) {
397+ return (
398+ < ChatHistoryScreen
399+ onSelectChat = { onSelectChat }
400+ onCancel = { onCancelChatHistory }
401+ onNewChat = { onNewChat }
402+ />
403+ )
404+ }
405+
391406 return (
392407 < Chat
393408 key = { chatKey }
0 commit comments