Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion frontend/src/scenes/max/ConversationHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function ConversationCard({ conversation, openConversation, sidePanel }: Convers
return (
<Link
className="p-4 flex flex-row bg-surface-primary rounded-lg gap-2 w-full min-h-14 items-center justify-between"
to={combineUrl(urls.max(conversation.id), { from: 'history' }).url}
to={combineUrl(urls.ai(conversation.id), { from: 'history' }).url}
onClick={(e) => {
if (sidePanel) {
e.preventDefault()
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/max/HistoryPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function HistoryPreview({ sidePanel = false }: HistoryPreviewProps): JSX.
<Link
key={conversation.id}
className="text-sm flex items-center gap-2 text-primary hover:text-accent-hover active:text-accent-active justify-between"
to={urls.max(conversation.id)}
to={urls.ai(conversation.id)}
onClick={(e) => {
if (sidePanel) {
e.preventDefault()
Expand Down
25 changes: 10 additions & 15 deletions frontend/src/scenes/max/Max.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import clsx from 'clsx'
import { BindLogic, useActions, useValues } from 'kea'
import React from 'react'

Expand Down Expand Up @@ -48,19 +49,14 @@ export function Max({ tabId }: { tabId?: string }): JSX.Element {
return <NotFound object="page" caption="You don't have access to AI features yet." />
}

if (
sidePanelOpen &&
selectedTab === SidePanelTab.Max &&
sidepanelConversationId &&
sidepanelConversationId === tabConversationId
) {
if (sidePanelOpen && selectedTab === SidePanelTab.Max && sidepanelConversationId === tabConversationId) {
return (
<SceneContent className="px-4 py-4">
<SceneContent className="px-4 py-4 min-h-[calc(100vh-var(--scene-layout-header-height)-120px)]">
<SceneTitleSection name={null} resourceType={{ type: 'chat' }} />
<div className="flex flex-col items-center justify-center w-full grow">
<IconSidePanel className="text-3xl text-muted mb-2" />
<h3 className="text-xl font-bold mb-1">This chat is currently in the sidebar</h3>
<p className="text-sm text-muted mb-2">You can navigate freely around the app, or…</p>
<h3 className="text-xl font-bold mb-1">The chat is currently in the sidebar</h3>
<p className="text-sm text-muted mb-2">You can navigate freely around the app with it, or…</p>
<LemonButton
type="secondary"
size="xsmall"
Expand Down Expand Up @@ -120,11 +116,10 @@ export const MaxInstance = React.memo(function MaxInstance({
// is at the same viewport height as the QuestionInput text that appear after going into a thread.
// This makes the transition from one view into another just that bit smoother visually.
<div
className={
sidePanel
? '@container/max-welcome relative flex flex-col gap-4 px-4 pb-7 grow'
: '@container/max-welcome relative flex flex-col gap-4 px-4 pb-7 grow min-h-[calc(100vh-var(--scene-layout-header-height)-120px)]'
}
className={clsx(
'@container/max-welcome relative flex flex-col gap-4 px-4 pb-7 grow',
!sidePanel && 'min-h-[calc(100vh-var(--scene-layout-header-height)-120px)]'
)}
>
<div className="flex-1 items-center justify-center flex flex-col gap-3">
<Intro />
Expand Down Expand Up @@ -204,7 +199,7 @@ export const MaxInstance = React.memo(function MaxInstance({
<LemonButton
size="small"
sideIcon={<IconExternal />}
to={urls.max(conversationId ?? undefined)}
to={urls.ai(conversationId ?? undefined)}
onClick={() => {
closeSidePanel()
startNewConversation()
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/scenes/max/maxLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ export const maxLogic = kea<maxLogicType>([
{
key: Scene.Max,
name: 'AI',
path: urls.max(),
path: urls.ai(),
iconType: 'chat',
},
...(conversationHistoryVisible || searchParams.from === 'history'
? [
{
key: Scene.Max,
name: 'Chat history',
path: urls.maxHistory(),
path: urls.aiHistory(),
iconType: 'chat' as const,
},
]
Expand All @@ -291,7 +291,7 @@ export const maxLogic = kea<maxLogicType>([
{
key: Scene.Max,
name: chatTitle || 'Chat',
path: urls.max(conversationId),
path: urls.ai(conversationId),
iconType: 'chat' as const,
},
]
Expand Down Expand Up @@ -442,12 +442,12 @@ export const maxLogic = kea<maxLogicType>([
}),

tabAwareUrlToAction(({ actions, values }) => ({
[urls.maxHistory()]: () => {
[urls.aiHistory()]: () => {
if (!values.conversationHistoryVisible) {
actions.toggleConversationHistory()
}
},
[urls.max()]: (_, search) => {
[urls.ai()]: (_, search) => {
if (search.ask && !search.chat && !values.question) {
window.setTimeout(() => {
// ensure maxThreadLogic is mounted
Expand All @@ -469,19 +469,19 @@ export const maxLogic = kea<maxLogicType>([
tabAwareActionToUrl(({ values }) => ({
toggleConversationHistory: () => {
if (values.conversationHistoryVisible) {
return [urls.maxHistory(), {}, router.values.location.hash]
return [urls.aiHistory(), {}, router.values.location.hash]
} else if (values.conversationId) {
return [urls.max(values.conversationId), {}, router.values.location.hash]
return [urls.ai(values.conversationId), {}, router.values.location.hash]
}
return [urls.max(), {}, router.values.location.hash]
return [urls.ai(), {}, router.values.location.hash]
},
startNewConversation: () => {
return [urls.max(), {}, router.values.location.hash]
return [urls.ai(), {}, router.values.location.hash]
},
setConversationId: ({ conversationId }) => {
// Only set the URL parameter if this is a new conversation (using frontendConversationId)
if (conversationId && conversationId === values.frontendConversationId) {
return [urls.max(conversationId), {}, router.values.location.hash, { replace: true }]
return [urls.ai(conversationId), {}, router.values.location.hash, { replace: true }]
}
// Return undefined to not update URL for existing conversations
return undefined
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/max/maxThreadLogic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ describe('maxThreadLogic', () => {

describe('processNotebookUpdate', () => {
it('navigates to notebook when not already on notebook page', async () => {
router.actions.push(urls.max())
router.actions.push(urls.ai())

// Mock openNotebook to track its calls
const openNotebookSpy = jest.spyOn(notebooksModel, 'openNotebook')
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/new-tab/NewTabScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function NewTabScene({ tabId }: { tabId?: string } = {}): JSX.Element {

const handleAskAi = (question?: string): void => {
const nextQuestion = (question ?? search).trim()
router.actions.push(urls.max(undefined, nextQuestion))
router.actions.push(urls.ai(undefined, nextQuestion))
}

// The active commands are just the items in newTabSceneDataInclude
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/new-tab/newTabSceneLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ export const newTabSceneLogic = kea<newTabSceneLogicType>([
id: 'ask-ai',
name: searchTerm ? `Ask: ${searchTerm}` : 'Ask Posthog AI anything...',
category: 'askAI',
href: urls.max(undefined, searchTerm),
href: urls.ai(undefined, searchTerm),
icon: <IconSparkles />,
record: {
type: 'ai',
Expand All @@ -840,7 +840,7 @@ export const newTabSceneLogic = kea<newTabSceneLogicType>([
id: 'open-ai',
name: 'Open',
category: 'askAI',
href: urls.max(undefined, undefined),
href: urls.ai(undefined, undefined),
icon: <IconArrowRight />,
record: {
type: 'ai',
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/scenes/scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ export const redirects: Record<
'/saved_insights': urls.savedInsights(),
'/settings': urls.settings(),
'/settings/organization-rbac': urls.settings('organization-roles'),

'/max': (_params, searchParams, hashParams) => combineUrl(urls.ai(), searchParams, hashParams).url,
'/max/history': (_params, searchParams, hashParams) => combineUrl(urls.aiHistory(), searchParams, hashParams).url,

...productRedirects,
}

Expand Down Expand Up @@ -679,8 +683,8 @@ export const routes: Record<string, [Scene | string, string]> = {
[urls.annotation(':id')]: [Scene.DataManagement, 'annotation'],
[urls.comments()]: [Scene.DataManagement, 'comments'],
[urls.projectHomepage()]: [Scene.ProjectHomepage, 'projectHomepage'],
[urls.maxHistory()]: [Scene.Max, 'maxHistory'],
[urls.max()]: [Scene.Max, 'max'],
[urls.aiHistory()]: [Scene.Max, 'maxHistory'],
[urls.ai()]: [Scene.Max, 'max'],
[urls.projectCreateFirst()]: [Scene.ProjectCreateFirst, 'projectCreateFirst'],
[urls.organizationBilling()]: [Scene.Billing, 'organizationBilling'],
[urls.organizationBillingSection(':section' as BillingSectionId)]: [
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ export const urls = {
projectCreateFirst: (): string => '/organization/create-project',
projectRoot: (): string => '/',
projectHomepage: (): string => '/home',
max: (chat?: string, ask?: string): string => combineUrl('/max', { ask, chat }).url,
maxHistory: (): string => '/max/history',
ai: (chat?: string, ask?: string): string => combineUrl('/ai', { ask, chat }).url,
aiHistory: (): string => '/ai/history',
settings: (section: SettingSectionId | SettingLevelId = 'project', setting?: SettingId): string =>
combineUrl(`/settings/${section}`, undefined, setting).url,
organizationCreationConfirm: (): string => '/organization/confirm-creation',
Expand Down
Loading