Skip to content

feat(max): showcase capabilities - #32556

Merged
skoob13 merged 27 commits into
masterfrom
feat/max-suggestions
May 28, 2025
Merged

skoob13 merged 27 commits into
masterfrom
feat/max-suggestions

Conversation

@skoob13

@skoob13 skoob13 commented May 22, 2025 •

Copy link
Copy Markdown
Contributor

Problem

One of the pieces of feedback we frequently get is that it is not clear what Max can and cannot do. Let's replace random suggestions with a hardcoded list of suggestions where Max excels.

Changes

  • Create the suggestions list (verified).
  • Add nested menus.

Demo

2025-05-26 11 18 57

Mobile

2025-05-26 11 19 40

Did you write or update any docs for this change?

  • I've added or updated the docs
  • I've reached out for help from the docs team
  • No docs needed for this change

How did you test this code?

Manual testing & a new story

@skoob13
skoob13 requested a review from a team May 22, 2025 19:07

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR enhances Max AI's user interface by replacing random suggestions with a structured, categorized menu system to better showcase its capabilities.

  • Added maxQuestionSuggestionsLogic.tsx with predefined categories (SQL, Product Analytics, Docs, etc.) and their specific suggestions
  • Implemented two-level navigation in QuestionSuggestions.tsx with category selection and detailed suggestions
  • Added new animation effects in QuestionSuggestions.scss for staggered suggestion appearance
  • Enhanced focus management in maxLogic.tsx with new focusCounter reducer and focusInput action
  • Added ThreadWithOpenedSuggestions story to test the new suggestion system

8 file(s) reviewed, 8 comment(s)
Edit PR Review Bot Settings | Greptile

Comment thread frontend/src/scenes/max/Max.stories.tsx Resolved
Comment thread frontend/src/scenes/max/Max.stories.tsx Resolved
Comment thread frontend/src/scenes/max/Max.tsx Resolved
@posthog-bot

Copy link
Copy Markdown
Contributor

📸 UI snapshots have been updated

12 snapshot changes in total. 0 added, 12 modified, 0 deleted:

  • chromium: 0 added, 12 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@kappa90 kappa90 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful. Just left some minor UX comments.

I also noticed that the suggestions are center-aligned, I think it makes sense to always aligns them to the left (like in ChatGPT).

disabledReason={!dataProcessingAccepted ? 'Please accept OpenAI processing data' : undefined}
center
>
Let's get started with me learning about your project!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need this button to trigger the onboarding manually.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the onboarding be triggered when any of the product analytics suggestions are clicked?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a button to also run it directly, but yeah you're right, now that we have direct product analytics suggestions, we can keep it this way.

)
}

function useClickOutside<T extends HTMLElement>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still on a fan of this. I think on ChatGPT it works well because there's lots of space around the suggestions, but Max lives in a tiny sidebar, so clicking "outside" is kinda difficult.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This experience should be more obvious and easier with the UI. You typically expect to be able to click anywhere to close an autocomplete.

onClick={() => {
// If it's a product-based skill, open the URL first
if (group.url && !router.values.currentLocation.pathname.includes(group.url)) {
router.actions.push(group.url)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an edge case where this is slightly annoying: you're editing an insight, click by mistake on a suggestion, you get the alert: "You have unsaved changes", and you click yes by mistake because you're not reading the alert text like 90% of the people out there (including me) 😄 There's no way to solve it, it's just that one wouldn't necessarily expect Max's suggestions to also redirect to a different page (although it makes sense).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Product-based flows will solve it👀 It's probably fine for now unless you think otherwise.

label: 'What are the top referring domains?',
},
{
label: 'Calculate a conversion rate for <events or features>',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly difficult to understand, specifically the "or features" part, since there is no "feature" concept within PostHog (yet). Maybe we can just write "Calculate a conversion rate for..." and it prefills the input, like you did.

tooltip: 'Max can generate insights from natural language and tweak existing ones.',
},
{
label: 'Docs',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can "suggest" to Max that it should always answers these by searching the docs. It could be an additional field in askMax, which forces the Root to use a specific tool. This also applies to the insight questions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those questions are prompted in a way that should always trigger their flows. Did you experience a situation when it hadn't triggered a flow?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't, I was just wondering if it would make sense to add some "guardrails".

icon: <IconPlug />,
suggestions: [
{
label: 'How can I set up the session replay in <a framework or language>',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overflows:

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@skoob13
skoob13 force-pushed the feat/max-suggestions branch from 38e25de to 81c73b6 Compare May 26, 2025 09:32
@posthog-bot

Copy link
Copy Markdown
Contributor

📸 UI snapshots have been updated

14 snapshot changes in total. 0 added, 14 modified, 0 deleted:

Caution

Detected flapping snapshots

These snapshots have auto-updated more than once since the last human commit:

  • scenes-app-max-ai--thread-with-opened-suggestions--dark.png (chromium, shard 1)
  • scenes-app-max-ai--thread-with-opened-suggestions--light.png (chromium, shard 1)
  • scenes-app-max-ai--welcome--dark.png (chromium, shard 1)
  • scenes-app-max-ai--welcome--light.png (chromium, shard 1)
  • scenes-app-max-ai--welcome-feature-preview-auto-enrolled--dark.png (chromium, shard 1)
  • scenes-app-max-ai--welcome-feature-preview-auto-enrolled--light.png (chromium, shard 1)
  • scenes-app-max-ai--welcome-loading-suggestions--dark.png (chromium, shard 1)
  • scenes-app-max-ai--welcome-loading-suggestions--light.png (chromium, shard 1)
  • scenes-app-max-ai--welcome-suggestions-available--dark.png (chromium, shard 1)
  • scenes-app-max-ai--welcome-suggestions-available--light.png (chromium, shard 1)
  • scenes-app-max-ai--welcome-with-latest-conversations--dark.png (chromium, shard 1)
  • scenes-app-max-ai--welcome-with-latest-conversations--light.png (chromium, shard 1)

The flippy-flappies are deadly and must be fixed ASAP. They're productivity killers.
Run pnpm storybook locally and make the fix now.
(Often, the cause is ResizeObserver being used instead of the better CSS container queries.)

  • chromium: 0 added, 14 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@skoob13
skoob13 requested a review from Twixes May 26, 2025 09:49
@skoob13

skoob13 commented May 26, 2025

Copy link
Copy Markdown
Contributor Author

@Twixes are the snapshots above actually flapping? It looks like they're generated for the first time.

@github-actions

github-actions Bot commented May 26, 2025 •

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 3.72 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 3.72 MB

compressed-size-action

@Twixes Twixes left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet stuff, now with some suggestions for making things even smoother ;)

Comment thread frontend/src/scenes/max/maxLogic.tsx Outdated
Comment on lines +917 to +918
label: 'How can I set up the session replay in a framework or language',
content: 'How can I set up the session replay in ',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To bump up Em's point, I think the suggestions will be more intuitive the other way, and we can probably standardize this so that it's not needed to have label and content separate.

We can keep just label in this format:
How can I set up the session replay in <framework or language>? or Write an SQL query to …

This way we can handle angled brackets <> and the ellipsis … as markup in terms of the resulting content:

  • angled brackets <> – the opening bracket <, and everything after it, is stripped, so the content automatically becomes just How can I set up the session replay in
  • ellipsis … – just gets removed, so only Write an SQL query to remains

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed to me like overkill for the hardcoded suggestions. Nevertheless, it's implemented now👍

return scrollableEl
}

export const QUESTION_SUGGESTIONS_DATA: readonly SuggestionGroup[] = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the idea to use verbs instead to signify things to do, but it seems to wordy after trying:
Screenshot 2025-05-26 at 23 03 31

Real polish suggestions though:

  1. let's add an ellipsis after "Ask Max…"
  2. Let's use sentence case in accordance with our style, which applies even to product names, i.e. "Product analytics" rather than "Product Analytics"
  3. To me, it'd be slightly more intuitive to still put "Product analytics" first, since that's the broadest use case for Max.
  4. "Set up" is vague, "SDK setup" would be clearer. I'd put it second to last
  5. "Docs" feel like they should be at the end, since they're the the least in-product of these items, if that makes sense

Comment thread frontend/src/scenes/max/maxLogic.tsx Outdated
icon: <IconHogQL />,
suggestions: [
{
label: 'Generate an SQL query to',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly friendlier wording: "Write an SQL query to …"

Comment thread frontend/src/scenes/max/maxLogic.tsx Outdated
},
],
url: urls.sqlEditor(),
tooltip: 'Max can generate SQL queries using your PostHog data and the data warehouse.',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tooltip: 'Max can generate SQL queries using your PostHog data and the data warehouse.',
tooltip: 'Max can generate SQL queries for your PostHog data, both analytics and the data warehouse.',

Comment thread frontend/src/scenes/max/maxLogic.tsx Outdated
label: 'How can I capture an exception?',
},
],
tooltip: 'Max can help you find the right documentation pieces.',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"pieces" is slightly odd

Suggested change
tooltip: 'Max can help you find the right documentation pieces.',
tooltip: 'Max has access to PostHog docs and can help you get the most out of PostHog.',

Comment thread pnpm-lock.yaml Resolved
Comment thread frontend/src/scenes/max/maxLogic.tsx Outdated
Comment on lines +748 to +751
suggestionGroups: [
() => [], // Kea selector typing hint
(): readonly SuggestionGroup[] => QUESTION_SUGGESTIONS_DATA,
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, doesn't look like we need this to be a selector

Comment thread frontend/src/scenes/max/maxLogic.tsx Outdated
Comment on lines +755 to +758
(index, groups): SuggestionGroup | undefined => {
if (index === null) {
return undefined
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I always find null to be a clearer indication of an intended lack of result than undefined.

{activeSuggestionGroup && !isFloating && (
<ToggleGroup
type="single"
className="absolute inset-x-2 top-full grid auto-rows-auto p-1 border-x border-b rounded-b backdrop-blur-sm bg-[var(--glass-bg-3000)] z-10"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For visual harmony, we need to round with -lg, because we're wrapping a collection of elements that are each rounded with the base radius – this looks slightly off:

Screenshot 2025-05-26 at 23 54 24
Suggested change
className="absolute inset-x-2 top-full grid auto-rows-auto p-1 border-x border-b rounded-b backdrop-blur-sm bg-[var(--glass-bg-3000)] z-10"
className="absolute inset-x-2 top-full grid auto-rows-auto p-1 border-x border-b rounded-lg-b backdrop-blur-sm bg-[var(--glass-bg-3000)] z-10"

Comment on lines +7 to +17
@keyframes QuestionSuggestion__slide-in-fade-down {
from {
opacity: 0;
transform: translateY(-0.5rem);
}

to {
opacity: 1;
transform: translateY(0);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose a CSSTransition instead, as currently we only have an entry animation, but jarringly exit is just abrupt disappearance

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants