-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(assistant): Make the sidebar Max's home #28710
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR integrates Max, PostHog's AI assistant, into the application's sidebar panel, moving it from its previous location in the main navigation menu.
- Added new
SidePanelMax
component in/frontend/src/layout/navigation-3000/sidepanel/panels/SidePanelMax.tsx
with a minimalist interface and "Open as main focus" button - Modified
SidePanel.tsx
to include Max tab with dynamic icon that switches between hedgehog profile and sparkles based on panel state - Enhanced
Thread.tsx
with container queries (@container/thread) and responsive design improvements for better mobile/sidebar display - Updated
QuestionInput.tsx
andQuestionSuggestions.tsx
with improved layout and styling for sidebar integration - Added error handling and message management improvements in
maxLogic.ts
for better API response handling and thread management
13 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile
ea8b06d
to
958acf2
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
7db8699
to
ef79641
Compare
This comment was marked as outdated.
This comment was marked as outdated.
75facf1
to
6a2458a
Compare
{rating !== 'bad' && ( | ||
<LemonButton | ||
icon={rating === 'good' ? <IconThumbsUpFilled /> : <IconThumbsUp />} | ||
type="tertiary" | ||
size="small" | ||
size="xsmall" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message actions, like thumbs up, are generally more compact now. I think currently even too compact, because the xmsall icon is absolutely tiny. I'll make it a bit larger, but in a separate PR, because it's more of a design system change
const threadEl = document.getElementsByClassName('@container/thread')[0] | ||
let scrollableEl = threadEl?.parentElement // .Navigation3000__scene or .SidePanel3000__content | ||
if (scrollableEl && !scrollableEl.classList.contains('SidePanel3000__content')) { | ||
// In this case we need to go up to <main>, since .Navigation3000__scene is not scrollable | ||
scrollableEl = scrollableEl.parentElement | ||
} | ||
if (scrollableEl) { | ||
scrollableEl.scrollTo({ | ||
top: threadEl.scrollHeight, | ||
behavior: 'smooth', | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not as elegant, but this ensures we always scroll the scrollable parent of the thread in both the full-page and side-panel case
|
||
import { SidePanelTab } from '~/types' | ||
|
||
import type { sidePanelStateLogicType } from './sidePanelStateLogicType' | ||
|
||
export const WithinSidePanelContext = React.createContext<boolean>(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much like Within3000PageHeader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 19 changed files in this pull request and generated no comments.
Files not reviewed (14)
- frontend/src/scenes/max/Thread.tsx: Evaluated as low risk
- frontend/src/scenes/settings/organization/AIConsentPopoverWrapper.tsx: Evaluated as low risk
- frontend/src/scenes/scenes.ts: Evaluated as low risk
- frontend/src/layout/navigation-3000/navigationLogic.tsx: Evaluated as low risk
- frontend/src/layout/navigation-3000/sidepanel/sidePanelStateLogic.tsx: Evaluated as low risk
- frontend/src/scenes/notebooks/NotebookPanel/NotebookPanel.tsx: Evaluated as low risk
- frontend/src/lib/lemon-ui/Link/Link.tsx: Evaluated as low risk
- frontend/src/scenes/max/QuestionInput.tsx: Evaluated as low risk
- frontend/src/scenes/max/QuestionSuggestions.tsx: Evaluated as low risk
- frontend/src/types.ts: Evaluated as low risk
- frontend/src/scenes/max/Intro.tsx: Evaluated as low risk
- frontend/src/scenes/notebooks/Notebook/NotebookMeta.tsx: Evaluated as low risk
- frontend/src/layout/navigation-3000/sidepanel/sidePanelLogic.tsx: Evaluated as low risk
- frontend/src/layout/navigation-3000/sidepanel/SidePanel.tsx: Evaluated as low risk
Comments suppressed due to low confidence (1)
frontend/src/scenes/max/Max.tsx:1
- Ensure that the 'IconSidePanel' and 'IconArrowLeft' icons are correctly imported and used in the JSX.
import { IconArrowLeft, IconGear, IconSidePanel } from '@posthog/icons'
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
b58ea8e
to
136523f
Compare
📸 UI snapshots have been updated19 snapshot changes in total. 0 added, 19 modified, 0 deleted:
Triggered by this commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found two things:
- How can I access Max on mobile? The sidebar seems to be unavailable in mobile. As an option, we can just keep Max on its own page.
- Insights height is too low. It's 150px now. 240px looks much better IMO.
Neither issue blocks it from shipping though.
@@ -98,6 +98,12 @@ export const Link: React.FC<LinkProps & React.RefAttributes<HTMLElement>> = Reac | |||
href: typeof to === 'string' ? to : undefined, | |||
}) | |||
|
|||
const withinSidePanel = useContext(WithinSidePanelContext) | |||
|
|||
if (withinSidePanel && target === '_blank' && !isExternalLink(to)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the same effect is possible with event capturing on the Max's level without using the context, but this looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure, thinking more generally here as we'll now be adding more such links/actions
to: urls.max(), | ||
tag: 'beta' as const, | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we've discussed, people would expect Max to be in the sidebar navigation for some time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -350,6 +362,7 @@ export const maxLogic = kea<maxLogicType>([ | |||
actions.loadSuggestions({ refresh: 'async_except_on_cache_miss' }) | |||
} | |||
}), | |||
permanentlyMount(), // Prevent state from being reset when Max is unmounted, especially key in the side panel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to prioritize the reset button😄
📸 UI snapshots have been updated2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
Triggered by this commit. |
Problem
People don't necessarily want to always go to a full-page Max view to get insights. It'd be faster to be able to query while already doing something else, from the sidebar.
Changes
Max is in a side panel now:
This side panel can still be expanded into the full-page view.
How did you test this code?
TODO: StoriesSee UI snapshot changes.