Add URL-based chat navigation and history support#7
Merged
Conversation
|
🚅 Deployed to the padtask-pr-7 environment in padtask
|
When editing a task list, the URL now updates to #/chat/<sessionId>. On page refresh, the app reads the hash to restore the correct chat instead of always defaulting to the most recently created one. Also handles browser back/forward navigation via hashchange listener. https://claude.ai/code/session_017c7u8u7fjaozmihE6THSNz
16 tests covering getChatIdFromUrl, updateUrl, loadChats, createNewChat, switchToChat, and an integration test verifying refresh preserves the active chat via the URL hash. https://claude.ai/code/session_017c7u8u7fjaozmihE6THSNz
1eb97c5 to
dcc0483
Compare
URLs now look like #/chat/1712428800000-abc123xyz instead of #/chat/session-1712428800000-abc123xyz. https://claude.ai/code/session_017c7u8u7fjaozmihE6THSNz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds URL-based navigation for chat sessions, allowing users to bookmark, share, and navigate between chats using browser history. The chat ID is now reflected in the URL hash and synchronized across navigation actions.
Key Changes
getChatIdFromUrl()andupdateUrl()functions to parse and update the URL hash with the current chat ID in the format#/chat/{chatId}loadChats()to check the URL for a specific chat ID and load that chat if it exists, falling back to the most recent chatcreateNewChat()to update the URL when a new chat is createdswitchToChat()to update the URL when switching between existing chatshashchangeevent listener to handle browser back/forward button clicks, automatically switching to the appropriate chat when the URL hash changesImplementation Details
#/chat/{chatId}) to maintain compatibility with single-page application architecturehistory.replaceState()to avoid creating unnecessary history entries during initial loadshashchangeevent listener includes validation to ensure the chat exists before switchinghttps://claude.ai/code/session_017c7u8u7fjaozmihE6THSNz