Skip to content

Conversation

@brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Feb 11, 2026

Summary by CodeRabbit

  • New Features
    • Added login requirement for message submission
    • Login modal appears when unauthenticated users attempt to submit
    • Previously typed messages are automatically resubmitted after successful authentication
    • Support for multiple identity providers for sign-in

@github-actions
Copy link
Contributor

@brendan-kellam your pull request is missing a changelog!

@claude
Copy link

claude bot commented Feb 11, 2026

Code Review

I found one issue that should be addressed:

Missing error handling for JSON.parse

Location: packages/web/src/app/[domain]/askgh/[owner]/[repo]/components/landingPage.tsx:73

The JSON.parse call lacks try/catch error handling. If the sessionStorage value is corrupted or tampered with, this will throw an unhandled SyntaxError that crashes the component during the useEffect execution.

While the data is written by the same code via JSON.stringify, sessionStorage can be modified by users via browser DevTools, browser extensions, or other scripts on the same origin. An unhandled exception here would leave the user on a broken page after successful OAuth authentication.

Suggested fix:

try {
    const message = JSON.parse(stored) as Descendant[];
    // Restore the message content to the editor by replacing all nodes
    // Remove all existing nodes
    while (editor.children.length > 0) {
        Transforms.removeNodes(editor, { at: [0] });
    }
    // Insert the restored content at the beginning
    Transforms.insertNodes(editor, message, { at: [0] });

    // Allow the UI to render the restored text before auto-submitting
    createNewChatThread(message, selectedSearchScopes);
} catch (error) {
    console.error('Failed to restore pending message:', error);
    sessionStorage.removeItem(PENDING_MESSAGE_KEY);
    // Optionally notify the user that their message couldn't be restored
}

Reference:

if (stored) {
hasRestoredPendingMessage.current = true;
sessionStorage.removeItem(PENDING_MESSAGE_KEY);
const message = JSON.parse(stored) as Descendant[];
// Restore the message content to the editor by replacing all nodes
// Remove all existing nodes
while (editor.children.length > 0) {
Transforms.removeNodes(editor, { at: [0] });
}
// Insert the restored content at the beginning
Transforms.insertNodes(editor, message, { at: [0] });
// Allow the UI to render the restored text before auto-submitting
createNewChatThread(message, selectedSearchScopes);
}


Summary: Checked for bugs and CLAUDE.md compliance. Found 1 issue requiring attention.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

Adds authentication-aware submission flow: unauthenticated submissions open a login modal and persist the pending message to sessionStorage; after authentication the pending message is restored into the Slate editor and auto-submitted. Introduces a new LoginModal component and passes providers/isAuthenticated from the page to LandingPage.

Changes

Cohort / File(s) Summary
Landing Page & Auth UX
packages/web/src/app/[domain]/askgh/[owner]/[repo]/components/landingPage.tsx
Added providers and isAuthenticated props to LandingPage. Submission now checks auth, stores pending message in sessionStorage and opens a LoginModal when unauthenticated; restores pending message into Slate editor (using Transforms/useSlate) and auto-submits after auth. Added pending message key constant and replaced direct onSubmit with handleSubmit.
Login Modal Component
packages/web/src/app/[domain]/askgh/[owner]/[repo]/components/loginModal.tsx
New client-side LoginModal component rendering a Dialog and AuthMethodSelector; accepts isOpen, onOpenChange, providers, and callbackUrl.
Page-level Auth Integration
packages/web/src/app/[domain]/askgh/[owner]/[repo]/page.tsx
Fetches session via auth() and identity providers via getIdentityProviderMetadata(); passes providers and isAuthenticated={!!session?.user} to LandingPage.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant LandingPage
    participant LoginModal
    participant Auth
    participant SlateEditor as Slate Editor
    participant ThreadService

    User->>LandingPage: Submit message (unauthenticated)
    LandingPage->>LandingPage: Check isAuthenticated
    LandingPage->>LandingPage: Store pending message in sessionStorage
    LandingPage->>LoginModal: Open modal with providers
    User->>Auth: Authenticate via provider
    Auth-->>LandingPage: Authentication successful (session)
    LandingPage->>LandingPage: Retrieve pending message from sessionStorage
    LandingPage->>SlateEditor: Clear content, insert restored message
    LandingPage->>ThreadService: Create thread / submit message
    ThreadService-->>User: Chat thread created / response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bkellam/fix-SOU-110

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@brendan-kellam brendan-kellam merged commit c402b63 into main Feb 11, 2026
9 checks passed
@brendan-kellam brendan-kellam deleted the bkellam/fix-SOU-110 branch February 11, 2026 02:42
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.

1 participant