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

Thread persistence: Maintain thread state across page refreshes using URL #177

Open
ahmad2b opened this issue Nov 4, 2024 · 0 comments
Open
Assignees

Comments

@ahmad2b
Copy link
Contributor

ahmad2b commented Nov 4, 2024

Problem

When users refresh the page by accident, they lose their current thread. This can be frustrating because they have to:

  • Open the chat history
  • Find their thread
  • Open it again
  • Try to remember where they were

This happens every time the page refreshes because we use useState to store the threadId.

Solution

Let's fix this by using the URL to keep track of active threadId. For example:

  • Use URLs like /thread/<thread_id> for each thread
  • When someone refreshes the page, we can check the URL
  • Load their thread automatically
  • Put them right back where they were

Why this matters

  • Thread state persists across page refreshes
  • No more frustration from accidental refreshes
  • Offers a Reliable user experience
  • Users can even bookmark their threads

Technical Approach

  1. Add a simple URL pattern like /thread/<thread_id>
  2. On initial load, check the URL for thread_id
  3. If thread_id exists, load the corresponding thread
  4. Update the URL whenever users switch threads

Questions

  • Should the back button work with thread history?
  • What should we show if the thread ID in the URL is wrong?
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

No branches or pull requests

1 participant