Skip to content

Commit 1bddd39

Browse files
committed
Keep freebuff session alive when browsing /history
Rendering ChatHistoryScreen at the App level unmounted AuthedSurface, which triggered useFreebuffSession cleanup (DELETE + clear session) and sent the user back to the waiting room on return. Move the history screen inside AuthedSurface so the session stays mounted.
1 parent 21d5dd3 commit 1bddd39

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

cli/src/app.tsx

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)