fix: dispatch ADD_ACTIVE_SESSION event before navigating from "View All" (#6679)
Signed-off-by: Jonathan <jonathan@example.com> Co-authored-by: Zane Staggs <zane@squareup.com>
This commit is contained in:
@@ -23,17 +23,18 @@ export default function ChatSessionsContainer({
|
||||
const [searchParams] = useSearchParams();
|
||||
const currentSessionId = searchParams.get('resumeSessionId') ?? undefined;
|
||||
|
||||
if (!currentSessionId) {
|
||||
// Always render active sessions to keep SSE connections alive, even when not on /pair route
|
||||
if (!currentSessionId && activeSessions.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isActiveSession = activeSessions.some((s) => s.sessionId === currentSessionId);
|
||||
|
||||
// If the current session isn't in active sessions, we need to render it anyway
|
||||
// (handles page refresh case)
|
||||
const sessionsToRender = isActiveSession
|
||||
? activeSessions
|
||||
: [...activeSessions, { sessionId: currentSessionId }];
|
||||
// Build the list of sessions to render
|
||||
let sessionsToRender = activeSessions;
|
||||
|
||||
// If we have a currentSessionId that's not in activeSessions, add it (handles page refresh)
|
||||
if (currentSessionId && !activeSessions.some((s) => s.sessionId === currentSessionId)) {
|
||||
sessionsToRender = [...activeSessions, { sessionId: currentSessionId }];
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="relative w-full h-full">
|
||||
|
||||
@@ -116,14 +116,12 @@ const AppLayoutContent: React.FC<AppLayoutContentProps> = ({ activeSessions }) =
|
||||
/>
|
||||
</Sidebar>
|
||||
<SidebarInset>
|
||||
{isOnPairRoute ? (
|
||||
<>
|
||||
<Outlet />
|
||||
<ChatSessionsContainer setChat={setChat} activeSessions={activeSessions} />
|
||||
</>
|
||||
) : (
|
||||
<Outlet />
|
||||
)}
|
||||
<Outlet />
|
||||
{/* Always render ChatSessionsContainer to keep SSE connections alive.
|
||||
When navigating away from /pair */}
|
||||
<div className={isOnPairRoute ? 'contents' : 'hidden'}>
|
||||
<ChatSessionsContainer setChat={setChat} activeSessions={activeSessions} />
|
||||
</div>
|
||||
</SidebarInset>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user