Skip to content

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

AI Page Journeys #3131

wants to merge 6 commits into from

Conversation

zenoachtig
Copy link
Contributor

Screen.Recording.2025-04-09.at.16.27.00.mov

Copy link

changeset-bot bot commented Apr 9, 2025

🦋 Changeset detected

Latest commit: d8cfb10

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
gitbook Minor

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

Copy link
Member

@taranvohra taranvohra left a 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';
Copy link
Member

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() {
Copy link
Member

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?

Comment on lines +55 to +81
(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]);
Copy link
Member

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();
Copy link
Member

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

Comment on lines +59 to +70
},
// {
// 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.`,
// },
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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';
Copy link
Member

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

Comment on lines +84 to +85
<AdaptiveContext.Provider
value={{ journeys, selectedJourney, setSelectedJourney, loading, open, setOpen }}
Copy link
Member

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

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.

2 participants