Skip to content

Commit 3f98988

Browse files
authored
chore(ai): Migrate /max links to /ai (#41861)
1 parent 27d876f commit 3f98988

File tree

9 files changed

+36
-36
lines changed

9 files changed

+36
-36
lines changed

frontend/src/scenes/max/ConversationHistory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function ConversationCard({ conversation, openConversation, sidePanel }: Convers
8383
return (
8484
<Link
8585
className="p-4 flex flex-row bg-surface-primary rounded-lg gap-2 w-full min-h-14 items-center justify-between"
86-
to={combineUrl(urls.max(conversation.id), { from: 'history' }).url}
86+
to={combineUrl(urls.ai(conversation.id), { from: 'history' }).url}
8787
onClick={(e) => {
8888
if (sidePanel) {
8989
e.preventDefault()

frontend/src/scenes/max/HistoryPreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function HistoryPreview({ sidePanel = false }: HistoryPreviewProps): JSX.
4545
<Link
4646
key={conversation.id}
4747
className="text-sm flex items-center gap-2 text-primary hover:text-accent-hover active:text-accent-active justify-between"
48-
to={urls.max(conversation.id)}
48+
to={urls.ai(conversation.id)}
4949
onClick={(e) => {
5050
if (sidePanel) {
5151
e.preventDefault()

frontend/src/scenes/max/Max.tsx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import clsx from 'clsx'
12
import { BindLogic, useActions, useValues } from 'kea'
23
import React from 'react'
34

4-
import { IconArrowLeft, IconChevronLeft, IconOpenSidebar, IconPlus, IconSidePanel } from '@posthog/icons'
5+
import { IconArrowLeft, IconChevronLeft, IconExpand45, IconOpenSidebar, IconPlus, IconSidePanel } from '@posthog/icons'
56
import { LemonBanner, LemonTag } from '@posthog/lemon-ui'
67

78
import { NotFound } from 'lib/components/NotFound'
@@ -48,19 +49,14 @@ export function Max({ tabId }: { tabId?: string }): JSX.Element {
4849
return <NotFound object="page" caption="You don't have access to AI features yet." />
4950
}
5051

51-
if (
52-
sidePanelOpen &&
53-
selectedTab === SidePanelTab.Max &&
54-
sidepanelConversationId &&
55-
sidepanelConversationId === tabConversationId
56-
) {
52+
if (sidePanelOpen && selectedTab === SidePanelTab.Max && sidepanelConversationId === tabConversationId) {
5753
return (
58-
<SceneContent className="px-4 py-4">
54+
<SceneContent className="px-4 py-4 min-h-[calc(100vh-var(--scene-layout-header-height)-120px)]">
5955
<SceneTitleSection name={null} resourceType={{ type: 'chat' }} />
6056
<div className="flex flex-col items-center justify-center w-full grow">
6157
<IconSidePanel className="text-3xl text-muted mb-2" />
62-
<h3 className="text-xl font-bold mb-1">This chat is currently in the sidebar</h3>
63-
<p className="text-sm text-muted mb-2">You can navigate freely around the app, or…</p>
58+
<h3 className="text-xl font-bold mb-1">The chat is currently in the sidebar</h3>
59+
<p className="text-sm text-muted mb-2">You can navigate freely around the app with it, or…</p>
6460
<LemonButton
6561
type="secondary"
6662
size="xsmall"
@@ -120,11 +116,10 @@ export const MaxInstance = React.memo(function MaxInstance({
120116
// is at the same viewport height as the QuestionInput text that appear after going into a thread.
121117
// This makes the transition from one view into another just that bit smoother visually.
122118
<div
123-
className={
124-
sidePanel
125-
? '@container/max-welcome relative flex flex-col gap-4 px-4 pb-7 grow'
126-
: '@container/max-welcome relative flex flex-col gap-4 px-4 pb-7 grow min-h-[calc(100vh-var(--scene-layout-header-height)-120px)]'
127-
}
119+
className={clsx(
120+
'@container/max-welcome relative flex flex-col gap-4 px-4 pb-7 grow',
121+
!sidePanel && 'min-h-[calc(100vh-var(--scene-layout-header-height)-120px)]'
122+
)}
128123
>
129124
<div className="flex-1 items-center justify-center flex flex-col gap-3">
130125
<Intro />
@@ -203,7 +198,8 @@ export const MaxInstance = React.memo(function MaxInstance({
203198
{!isAIOnlyMode && (
204199
<LemonButton
205200
size="small"
206-
to={urls.max(conversationId ?? undefined)}
201+
sideIcon={<IconExpand45 />}
202+
to={urls.ai(conversationId ?? undefined)}
207203
onClick={() => {
208204
closeSidePanel()
209205
startNewConversation()

frontend/src/scenes/max/maxLogic.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,15 @@ export const maxLogic = kea<maxLogicType>([
273273
{
274274
key: Scene.Max,
275275
name: 'AI',
276-
path: urls.max(),
276+
path: urls.ai(),
277277
iconType: 'chat',
278278
},
279279
...(conversationHistoryVisible || searchParams.from === 'history'
280280
? [
281281
{
282282
key: Scene.Max,
283283
name: 'Chat history',
284-
path: urls.maxHistory(),
284+
path: urls.aiHistory(),
285285
iconType: 'chat' as const,
286286
},
287287
]
@@ -291,7 +291,7 @@ export const maxLogic = kea<maxLogicType>([
291291
{
292292
key: Scene.Max,
293293
name: chatTitle || 'Chat',
294-
path: urls.max(conversationId),
294+
path: urls.ai(conversationId),
295295
iconType: 'chat' as const,
296296
},
297297
]
@@ -442,12 +442,12 @@ export const maxLogic = kea<maxLogicType>([
442442
}),
443443

444444
tabAwareUrlToAction(({ actions, values }) => ({
445-
[urls.maxHistory()]: () => {
445+
[urls.aiHistory()]: () => {
446446
if (!values.conversationHistoryVisible) {
447447
actions.toggleConversationHistory()
448448
}
449449
},
450-
[urls.max()]: (_, search) => {
450+
[urls.ai()]: (_, search) => {
451451
if (search.ask && !search.chat && !values.question) {
452452
window.setTimeout(() => {
453453
// ensure maxThreadLogic is mounted
@@ -469,19 +469,19 @@ export const maxLogic = kea<maxLogicType>([
469469
tabAwareActionToUrl(({ values }) => ({
470470
toggleConversationHistory: () => {
471471
if (values.conversationHistoryVisible) {
472-
return [urls.maxHistory(), {}, router.values.location.hash]
472+
return [urls.aiHistory(), {}, router.values.location.hash]
473473
} else if (values.conversationId) {
474-
return [urls.max(values.conversationId), {}, router.values.location.hash]
474+
return [urls.ai(values.conversationId), {}, router.values.location.hash]
475475
}
476-
return [urls.max(), {}, router.values.location.hash]
476+
return [urls.ai(), {}, router.values.location.hash]
477477
},
478478
startNewConversation: () => {
479-
return [urls.max(), {}, router.values.location.hash]
479+
return [urls.ai(), {}, router.values.location.hash]
480480
},
481481
setConversationId: ({ conversationId }) => {
482482
// Only set the URL parameter if this is a new conversation (using frontendConversationId)
483483
if (conversationId && conversationId === values.frontendConversationId) {
484-
return [urls.max(conversationId), {}, router.values.location.hash, { replace: true }]
484+
return [urls.ai(conversationId), {}, router.values.location.hash, { replace: true }]
485485
}
486486
// Return undefined to not update URL for existing conversations
487487
return undefined

frontend/src/scenes/max/maxThreadLogic.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ describe('maxThreadLogic', () => {
588588

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

593593
// Mock openNotebook to track its calls
594594
const openNotebookSpy = jest.spyOn(notebooksModel, 'openNotebook')

frontend/src/scenes/new-tab/NewTabScene.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function NewTabScene({ tabId }: { tabId?: string } = {}): JSX.Element {
2626

2727
const handleAskAi = (question?: string): void => {
2828
const nextQuestion = (question ?? search).trim()
29-
router.actions.push(urls.max(undefined, nextQuestion))
29+
router.actions.push(urls.ai(undefined, nextQuestion))
3030
}
3131

3232
// The active commands are just the items in newTabSceneDataInclude

frontend/src/scenes/new-tab/newTabSceneLogic.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ export const newTabSceneLogic = kea<newTabSceneLogicType>([
826826
id: 'ask-ai',
827827
name: searchTerm ? `Ask: ${searchTerm}` : 'Ask Posthog AI anything...',
828828
category: 'askAI',
829-
href: urls.max(undefined, searchTerm),
829+
href: urls.ai(undefined, searchTerm),
830830
icon: <IconSparkles />,
831831
record: {
832832
type: 'ai',
@@ -840,7 +840,7 @@ export const newTabSceneLogic = kea<newTabSceneLogicType>([
840840
id: 'open-ai',
841841
name: 'Open',
842842
category: 'askAI',
843-
href: urls.max(undefined, undefined),
843+
href: urls.ai(undefined, undefined),
844844
icon: <IconArrowRight />,
845845
record: {
846846
type: 'ai',

frontend/src/scenes/scenes.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,10 @@ export const redirects: Record<
596596
'/saved_insights': urls.savedInsights(),
597597
'/settings': urls.settings(),
598598
'/settings/organization-rbac': urls.settings('organization-roles'),
599+
600+
'/max': (_params, searchParams, hashParams) => combineUrl(urls.ai(), searchParams, hashParams).url,
601+
'/max/history': (_params, searchParams, hashParams) => combineUrl(urls.aiHistory(), searchParams, hashParams).url,
602+
599603
...productRedirects,
600604
}
601605

@@ -679,8 +683,8 @@ export const routes: Record<string, [Scene | string, string]> = {
679683
[urls.annotation(':id')]: [Scene.DataManagement, 'annotation'],
680684
[urls.comments()]: [Scene.DataManagement, 'comments'],
681685
[urls.projectHomepage()]: [Scene.ProjectHomepage, 'projectHomepage'],
682-
[urls.maxHistory()]: [Scene.Max, 'maxHistory'],
683-
[urls.max()]: [Scene.Max, 'max'],
686+
[urls.aiHistory()]: [Scene.Max, 'maxHistory'],
687+
[urls.ai()]: [Scene.Max, 'max'],
684688
[urls.projectCreateFirst()]: [Scene.ProjectCreateFirst, 'projectCreateFirst'],
685689
[urls.organizationBilling()]: [Scene.Billing, 'organizationBilling'],
686690
[urls.organizationBillingSection(':section' as BillingSectionId)]: [

frontend/src/scenes/urls.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ export const urls = {
8383
projectCreateFirst: (): string => '/organization/create-project',
8484
projectRoot: (): string => '/',
8585
projectHomepage: (): string => '/home',
86-
max: (chat?: string, ask?: string): string => combineUrl('/max', { ask, chat }).url,
87-
maxHistory: (): string => '/max/history',
86+
ai: (chat?: string, ask?: string): string => combineUrl('/ai', { ask, chat }).url,
87+
aiHistory: (): string => '/ai/history',
8888
settings: (section: SettingSectionId | SettingLevelId = 'project', setting?: SettingId): string =>
8989
combineUrl(`/settings/${section}`, undefined, setting).url,
9090
organizationCreationConfirm: (): string => '/organization/confirm-creation',

0 commit comments

Comments
 (0)