Skip to content

Conversation

brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Jul 31, 2025

Fixes a 413 content too large error when starting a new chat with many repositories selected. The fix was to set the chat state in session storage instead of as a query param.

Summary by CodeRabbit

  • New Features

    • Chat state is now stored in session storage instead of the URL, providing a cleaner and more private user experience.
  • Refactor

    • Updated internal handling of chat state to use session storage, removing reliance on URL query parameters.
  • Bug Fixes

    • Fixed an error causing "413 content too large" when starting a new chat with many repositories selected.

@brendan-kellam brendan-kellam requested a review from msukkari July 31, 2025 23:22
Copy link

coderabbitai bot commented Jul 31, 2025

Walkthrough

The chat state management in the application has been refactored to use session storage instead of URL query parameters. This change affects the chat thread panel component, the chat state constant definition, and the custom hook for creating new chat threads. The updates replace URL-based state handling with session storage logic. Additionally, a changelog entry was added to document a fix related to a "413 content too large" error when starting new chats with many repositories.

Changes

Cohort / File(s) Change Summary
Chat Thread Panel Component
packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx
Replaced URL query parameter logic with session storage for chat state; removed router and search param usage.
Chat State Constant
packages/web/src/features/chat/types.ts
Renamed the chat state constant from SET_CHAT_STATE_QUERY_PARAM to SET_CHAT_STATE_SESSION_STORAGE_KEY.
Create New Chat Thread Hook
packages/web/src/features/chat/useCreateNewChatThread.ts
Updated to store chat state in session storage instead of the URL; replaced constant and added session storage logic.
Changelog
CHANGELOG.md
Added fix entry for "413 content too large" error when starting new chat with many repositories selected, linked to PR #416.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant useCreateNewChatThread
    participant SessionStorage
    participant ChatThreadPanel

    User->>useCreateNewChatThread: Initiate new chat thread
    useCreateNewChatThread->>SessionStorage: Store chat state (inputMessage, selectedSearchScopes)
    useCreateNewChatThread->>ChatThreadPanel: Navigate to chat thread (without query params)
    ChatThreadPanel->>SessionStorage: Retrieve chat state
    ChatThreadPanel->>ChatThreadPanel: Restore inputMessage and selectedSearchScopes
    ChatThreadPanel->>SessionStorage: Clear chat state
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A bunny hops through fields of state,
No more URLs to navigate!
Session storage holds the key,
For chat threads now, it's query-free.
With simpler flows and tidier code,
This rabbit grins on the review road.
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dc8dfd and 552f5cb.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bkellam/fix_413_on_chat_creation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

This comment has been minimized.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx (1)

49-49: Update error message to reflect session storage usage.

The error message still references "URL" but should be updated to reflect that we're now reading from session storage.

-            console.error('Invalid message in URL');
+            console.error('Invalid chat state in session storage');
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 77593a9 and 5dc8dfd.

📒 Files selected for processing (3)
  • packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx (2 hunks)
  • packages/web/src/features/chat/types.ts (1 hunks)
  • packages/web/src/features/chat/useCreateNewChatThread.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*

📄 CodeRabbit Inference Engine (.cursor/rules/style.mdc)

Filenames should always be camelCase. Exception: if there are filenames in the same directory with a format other than camelCase, use that format to keep things consistent.

Files:

  • packages/web/src/features/chat/types.ts
  • packages/web/src/features/chat/useCreateNewChatThread.ts
  • packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx
🔇 Additional comments (10)
packages/web/src/features/chat/types.ts (1)

161-161: LGTM! Clear and descriptive constant rename.

The constant rename from SET_CHAT_STATE_QUERY_PARAM to SET_CHAT_STATE_SESSION_STORAGE_KEY accurately reflects the shift from URL query parameters to session storage, improving code clarity and maintainability.

packages/web/src/features/chat/useCreateNewChatThread.ts (4)

13-14: LGTM! Proper imports for session storage approach.

The imports correctly reflect the shift to session storage with the updated constant name and the addition of useSessionStorage hook.


22-22: LGTM! Clean session storage initialization.

The useSessionStorage hook is properly initialized with the correct key and null default value. This approach will prevent the "413 content too large" error by avoiding large URL query parameters.


41-46: LGTM! Simplified state management and URL construction.

The direct assignment to session storage is much cleaner than the previous URL query parameter approach. The simplified URL construction without query parameters will resolve the 413 error while maintaining the same functionality.


50-50: LGTM! Correctly updated dependency array.

The dependency array properly includes setChatState to ensure the callback is updated when the session storage setter changes.

packages/web/src/app/[domain]/chat/[id]/components/chatThreadPanel.tsx (5)

5-5: LGTM! Proper import updates for session storage.

The imports correctly reflect the transition from URL-based to session storage-based state management.


10-10: LGTM! Clean import replacement.

Replacing useRouter and useSearchParams with useSessionStorage aligns perfectly with the new session storage approach.


33-33: LGTM! Consistent session storage usage.

The session storage initialization matches the pattern used in the hook, ensuring consistency across the codebase.


41-48: LGTM! Clean session storage state management.

The logic correctly reads from session storage and sets the component state. The approach is much simpler than the previous URL parsing logic.


51-54: LGTM! Proper cleanup and dependency management.

The session storage is properly cleared in the finally block to prevent stale state, and the dependency array correctly includes the necessary dependencies.

@brendan-kellam brendan-kellam merged commit 163e558 into main Jul 31, 2025
6 checks passed
@brendan-kellam brendan-kellam deleted the bkellam/fix_413_on_chat_creation branch July 31, 2025 23:38
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