Skip to content
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

/ai pagination #3421

Merged
merged 2 commits into from
Nov 1, 2024
Merged

/ai pagination #3421

merged 2 commits into from
Nov 1, 2024

Conversation

berekuk
Copy link
Collaborator

@berekuk berekuk commented Nov 1, 2024

Fixes #3420, took me about an hour to implement (I was able to copy-paste "load more" button logic from my side project).

AFAICT the mix of client-created workflows and preloaded workflows works fine, i.e. I was able to "load more" while a new workflow was running, and it continued to run. But there might be some subtle bugs that I didn't notice.

@berekuk berekuk requested a review from OAGr as a code owner November 1, 2024 04:50
Copy link

changeset-bot bot commented Nov 1, 2024

⚠️ No Changeset found

Latest commit: 0bdd265

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Nov 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
quri-hub ✅ Ready (Inspect) Visit Preview Nov 1, 2024 4:54am
quri-ui ✅ Ready (Inspect) Visit Preview Nov 1, 2024 4:54am
squiggle-components ✅ Ready (Inspect) Visit Preview Nov 1, 2024 4:54am
squiggle-website ✅ Ready (Inspect) Visit Preview Nov 1, 2024 4:54am

}
},
{ mode: "replace", scroll: false }
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This code is initially written for the case where we render the content based on query strings on server, in RSC.

In /ai, we simply pass the workflows to the client component, then use a react hook, and render only based on the data from that hook. So, for example,scroll: false doesn't do anything useful.

But this component is reusable - if we proceed with the plan from #3154, then we'll use it for all pagination, and it should work reliably everywhere, e.g. on the hub's front page.

PS: it's also possible to do an invisible <AutoLoadMore /> that loads when it's scrolled into the view (that's how it worked in my side project that I took this code from), but in this case, workflows are kind of heavy and an explicit button click is probably better.

@OAGr
Copy link
Contributor

OAGr commented Nov 1, 2024

Kudos for the speed on this. On a glance it looks pretty reasonable. Eager to try it soon, will merge.

@OAGr OAGr merged commit 56334eb into main Nov 1, 2024
6 checks passed
@OAGr OAGr deleted the ai-pagination branch November 1, 2024 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Squiggle AI should either have pagination, or should only return the last n=20 items
2 participants