dev said over 2 years ago on Infinite Scrolling with Hotwire :
To prevent endless, looping from the last element of the collection to the first element
(Approach 2 - no-JS)

<%= turbo_stream.append "posts" do %>
   <%= render partial: "posts/post", collection: @posts %>
 <% end %>
<% unless @pagy.page == @pagy.last %>
  <%= turbo_stream.replace "pagination" do %>
    <%= turbo_frame_tag "pagination", src: posts_path(page: @pagy.next, format: :turbo_stream), loading: :lazy %>
  <% end %>
<% end %>


To reset the infinite list and clear the page params:
(Approach 1 - Stimulus Controller)

  <%= link_to 'Posts', root_path(only_path: true), class: 'text-decoration-none text-reset fs-2' %>