Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions cli/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,6 @@ export const App = ({
)
}

// Render chat history screen when requested
if (showChatHistory) {
return (
<ChatHistoryScreen
onSelectChat={handleResumeChat}
onCancel={closeChatHistory}
onNewChat={handleNewChat}
/>
)
}

// Use key to force remount when resuming a different chat from history
const chatKey = resumeChatId ?? 'current'

Expand All @@ -316,6 +305,10 @@ export const App = ({
initialMode={initialMode}
gitRoot={gitRoot}
onSwitchToGitRoot={handleSwitchToGitRoot}
showChatHistory={showChatHistory}
onSelectChat={handleResumeChat}
onCancelChatHistory={closeChatHistory}
onNewChat={handleNewChat}
/>
)
}
Expand All @@ -336,6 +329,10 @@ interface AuthedSurfaceProps {
initialMode: AgentMode | undefined
gitRoot: string | null | undefined
onSwitchToGitRoot: () => void
showChatHistory: boolean
onSelectChat: (chatId: string) => void
onCancelChatHistory: () => void
onNewChat: () => void
}

/**
Expand All @@ -359,6 +356,10 @@ const AuthedSurface = ({
initialMode,
gitRoot,
onSwitchToGitRoot,
showChatHistory,
onSelectChat,
onCancelChatHistory,
onNewChat,
}: AuthedSurfaceProps) => {
const { session, error: sessionError } = useFreebuffSession()

Expand Down Expand Up @@ -388,6 +389,20 @@ const AuthedSurface = ({
return <WaitingRoomScreen session={session} error={sessionError} />
}

// Chat history renders inside AuthedSurface so the freebuff session stays
// mounted while the user browses history. Unmounting this surface would
// DELETE the session row and drop the user back into the waiting room on
// return.
if (showChatHistory) {
return (
<ChatHistoryScreen
onSelectChat={onSelectChat}
onCancel={onCancelChatHistory}
onNewChat={onNewChat}
/>
)
}

return (
<Chat
key={chatKey}
Expand Down
Loading