Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const App: FC = () => {
{/* Home routes */}
<Route
path="home"
element={<NewTabLayout useChatSessionOnHome={!alphaEnabled} />}
element={<NewTabLayout />}
>
{alphaEnabled ? (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,21 @@ import type { FC } from 'react'
import { Outlet, useLocation } from 'react-router'
import { ChatSessionProvider } from '@/entrypoints/sidepanel/layout/ChatSessionContext'
import { NewTabFocusGrid } from './NewTabFocusGrid'
import { shouldHideFocusGrid, shouldUseChatSession } from './route-utils'
import { shouldHideFocusGrid } from './route-utils'

interface NewTabLayoutProps {
useChatSessionOnHome?: boolean
}

export const NewTabLayout: FC<NewTabLayoutProps> = ({
useChatSessionOnHome = false,
}) => {
export const NewTabLayout: FC = () => {
const location = useLocation()
const hideGrid = shouldHideFocusGrid(location.pathname)
const useChatSession = shouldUseChatSession(
location.pathname,
useChatSessionOnHome,
)
const content = (
<>
{!hideGrid && <NewTabFocusGrid />}
<Outlet />
</>
)

if (!useChatSession) return content

return <ChatSessionProvider origin="newtab">{content}</ChatSessionProvider>
return (
<ChatSessionProvider origin="newtab">
{content}
</ChatSessionProvider>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@ import {
isAgentCommandPath,
isAgentConversationPath,
shouldHideFocusGrid,
shouldUseChatSession,
} from './route-utils'

describe('route-utils', () => {
it('treats command center routes as non-chat-session paths', () => {
it('correctly identifies agent command center routes', () => {
expect(isAgentCommandPath('/home')).toBe(true)
expect(isAgentCommandPath('/home/agents/main')).toBe(true)
expect(isAgentConversationPath('/home')).toBe(false)
expect(isAgentConversationPath('/home/agents/main')).toBe(true)
expect(shouldUseChatSession('/home')).toBe(false)
expect(shouldUseChatSession('/home', true)).toBe(true)
expect(shouldUseChatSession('/home/agents/main')).toBe(false)
expect(shouldUseChatSession('/home/chat')).toBe(true)
})

it('hides the focus grid on full-screen routes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,3 @@ export function shouldHideFocusGrid(pathname: string): boolean {
HIDE_FOCUS_GRID_PATHS.has(pathname) || isAgentConversationPath(pathname)
)
}

export function shouldUseChatSession(
pathname: string,
useChatSessionOnHome = false,
): boolean {
return (
pathname === '/home/chat' || (useChatSessionOnHome && pathname === '/home')
)
}
Loading