-
Notifications
You must be signed in to change notification settings - Fork 4k
AI Page Journeys #3131
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
base: main
Are you sure you want to change the base?
AI Page Journeys #3131
Conversation
🦋 Changeset detectedLatest commit: d8cfb10 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of the deployments: Version 1
Version 2
Test content |
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.
few comments but looks good overall
import { usePageContext } from '../PageContext'; | ||
import { Emoji } from '../primitives'; | ||
import { type SuggestedPage, useAdaptiveContext } from './AdaptiveContext'; | ||
import { streamNextPageSuggestions } from './server-actions/streamNextPageSuggestions'; |
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.
Lets export it from server-actions
so we don't have to do nested imports like this
import { type SuggestedPage, useAdaptiveContext } from './AdaptiveContext'; | ||
import { streamNextPageSuggestions } from './server-actions/streamNextPageSuggestions'; | ||
|
||
export function AINextPageSuggestions() { |
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.
Can we add a quick one liner comment?
(async () => { | ||
const stream = await streamPageJourneySuggestions({ | ||
count: JOURNEY_COUNT, | ||
currentPage: { | ||
id: currentPage.pageId, | ||
title: currentPage.title, | ||
}, | ||
currentSpace: { | ||
id: currentPage.spaceId, | ||
}, | ||
allSpaces: spaces, | ||
visitedPages, | ||
}); | ||
|
||
for await (const journey of stream) { | ||
if (canceled) return; | ||
|
||
setJourneys((prev) => [...prev, journey]); | ||
} | ||
|
||
setLoading(false); | ||
})(); | ||
|
||
return () => { | ||
canceled = true; | ||
}; | ||
}, [currentPage.pageId, currentPage.spaceId, currentPage.title, visitedPages, spaces]); |
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.
Are we using this Provider anywhere else apart from AIPageJourneySuggestions
? If not then let's move this logic to that component
import { useAdaptiveContext } from './AdaptiveContext'; | ||
import { AdaptivePaneHeader } from './AdaptivePaneHeader'; | ||
export function AdaptivePane() { | ||
const { open } = useAdaptiveContext(); |
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.
okay we are. let's call this hook useAdaptiveContextJourneys
}, | ||
// { | ||
// role: AIMessageRole.Developer, | ||
// content: `Other spaces in the documentation are: ${allSpaces | ||
// .map( | ||
// (space) => ` | ||
// - "${space.title}" (ID ${space.id})` | ||
// ) | ||
// .join('\n')} | ||
|
||
// Feel free to create journeys across spaces.`, | ||
// }, |
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.
let's remove it, we always have it in the git history :)
}; | ||
currentSpace: { | ||
id: string; | ||
// title: string; |
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.
same thing
}; | ||
currentSpace: { | ||
id: string; | ||
// title: string; |
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.
same thing
import { tcls } from '@/lib/tailwind'; | ||
|
||
import { AdaptivePane } from '../Adaptive/AdaptivePane'; |
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.
let's export from Adaptive
so you don' have to nest imports like this
<AdaptiveContext.Provider | ||
value={{ journeys, selectedJourney, setSelectedJourney, loading, open, setOpen }} |
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.
let's pull out the value in an useMemo
to avoid unnecessarily re-rendering the whole tree under the provider
30ecadc
to
d8cfb10
Compare
Screen.Recording.2025-04-09.at.16.27.00.mov