Skip to content

WIP: QR code prompt queue #736

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

Closed
wants to merge 2 commits into from
Closed

WIP: QR code prompt queue #736

wants to merge 2 commits into from

Conversation

thomshutt
Copy link
Contributor

@thomshutt thomshutt commented May 30, 2025

PR Type

Enhancement


Description

  • Add QR code generation in Share dialog

  • Enable QR code download and copy link

  • Introduce qrcode library and track events

  • Update dependencies for QR code support


Changes walkthrough 📝

Relevant files
Enhancement
ShareModal.tsx
Add QR code generation and UI                                                       

apps/app/components/welcome/featured/ShareModal.tsx

  • Imported Separator, Download, QrCode, and qrcode library
  • Added state for qrCodeDataUrl and isGeneratingQR
  • Implemented handleGenerateQR and handleDownloadQR functions
  • Updated UI: separate Share Link and QR Code sections with loading
    states
  • +129/-32
    Dependencies
    package.json
    Add QR code dependencies                                                                 

    apps/app/package.json

  • Added qrcode and @types/qrcode dependencies
  • Ensured library versions for QR code generation
  • +2/-0     
    pnpm-lock.yaml
    Update lockfile for QR code packages                                         

    pnpm-lock.yaml

  • Updated lockfile with qrcode and @types/qrcode entries
  • Included new package resolutions and integrity hashes
  • +15/-0   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link

    vercel bot commented May 30, 2025

    The latest updates on your projects. Learn more about Vercel for Git ↗︎

    Name Status Preview Comments Updated (UTC)
    pipelines-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 4:18pm

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Hardcoded QR content

    QR code is currently generated for a fixed URL ("https://google.com") rather than the dynamically created share link. Ensure the QR encodes the actual shareUrl.

    const handleGenerateQR = async () => {
      setIsGeneratingQR(true);
      try {
        // For now, using google.com as requested
        const qrDataUrl = await QRCodeLib.toDataURL("https://google.com", {
          width: 200,
          margin: 2,
          color: {
            dark: "#000000",
            light: "#FFFFFF",
          },
        });
        setQrCodeDataUrl(qrDataUrl);
    Share link dependency

    handleGenerateQR does not verify that shareUrl is available before generating a QR code. Consider disabling QR generation until a link is created or automatically generating the share link first.

    const handleGenerateQR = async () => {
      setIsGeneratingQR(true);
      try {
        // For now, using google.com as requested
        const qrDataUrl = await QRCodeLib.toDataURL("https://google.com", {
          width: 200,
          margin: 2,
          color: {
            dark: "#000000",
            light: "#FFFFFF",
          },
        });
        setQrCodeDataUrl(qrDataUrl);
        track("daydream_qr_code_generated", {
          is_authenticated: authenticated,
          stream_id: stream?.id,
        });
      } catch (error) {
        toast.error("Failed to generate QR code");
        console.error(error);
      } finally {
        setIsGeneratingQR(false);
      }
    };

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Generate QR for actual share URL

    Instead of generating a QR code for a hard-coded URL, use the actual shareUrl and
    guard against it being null. This ensures users scan the correct link. If shareUrl
    is missing, bail out or show an error.

    apps/app/components/welcome/featured/ShareModal.tsx [88-95]

    -const qrDataUrl = await QRCodeLib.toDataURL("https://google.com", {
    +if (!shareUrl) {
    +  toast.error("Please create a share link first");
    +  return;
    +}
    +const qrDataUrl = await QRCodeLib.toDataURL(shareUrl, {
       width: 200,
       margin: 2,
       color: {
         dark: "#000000",
         light: "#FFFFFF",
       },
     });
    Suggestion importance[1-10]: 9

    __

    Why: It fixes a critical bug where the QR code always points to google.com instead of the real shareUrl, ensuring users scan the correct link.

    High
    General
    Disable QR button without link

    Prevent the QR code button from being clickable until a share link exists. Add
    !shareUrl to the disabled condition so users cannot generate a QR before creating
    the link.

    apps/app/components/welcome/featured/ShareModal.tsx [203-206]

     <Button
       onClick={handleGenerateQR}
    -  disabled={isGeneratingQR}
    +  disabled={!shareUrl || isGeneratingQR}
       variant="outline"
       className="w-full rounded-md"
     >
    Suggestion importance[1-10]: 5

    __

    Why: It correctly prevents users from generating a QR code before a shareUrl exists, improving UX without major functional impact.

    Low
    Reset QR data on link reset

    Clear any existing QR code data when resetting the share URL to avoid showing an
    outdated QR. Add setQrCodeDataUrl(null) alongside resetting shareUrl.

    apps/app/components/welcome/featured/ShareModal.tsx [47-48]

     useEffect(() => {
       setShareUrl(null);
    +  setQrCodeDataUrl(null);
     }, []);
    Suggestion importance[1-10]: 5

    __

    Why: Clearing qrCodeDataUrl alongside shareUrl avoids stale QR images when the modal mounts, enhancing correctness.

    Low

    @thomshutt thomshutt closed this Jun 9, 2025
    @thomshutt thomshutt deleted the qr-code-prompt-queue branch June 9, 2025 21:33
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant