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

Inconsistent Display and Copy of Sources in Search Results #331

Open
RazeBerry opened this issue Aug 25, 2024 · 0 comments
Open

Inconsistent Display and Copy of Sources in Search Results #331

RazeBerry opened this issue Aug 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@RazeBerry
Copy link

RazeBerry commented Aug 25, 2024

Bug Report: Inconsistent Copying of Sources in Search Results

Description:
There is an intermittent issue with the copy functionality in the search results. When users click the copy button after results are generated, the copied text sometimes does not include the URL sources as expected. Instead, the copied text ends with 'false'.

Steps to Reproduce:

  1. Perform a search query.
  2. Wait for the results to be generated.
  3. Click the copy button.
  4. Paste the copied content into a text editor.

Expected Behavior:
The copied text should include the full response along with the URL sources at the end.

Actual Behavior:
Intermittently, the copied text ends with 'false' instead of the URL sources.

Frequency:
This issue occurs inconsistently. It's not reproducible 100% of the time, which suggests a potential race condition or asynchronous data handling problem.

Potential Causes:

  1. Race condition between source retrieval and copy action.
  2. Asynchronous loading of sources not completing before copy action.
  3. Incorrect handling of empty or undefined sources in the copy function.

Relevant Code:
The issue likely involves the Copy component in ui/components/MessageActions/Copy.tsx:

const Copy = ({
  message,
  initialMessage,
}: {
  message: Message;
  initialMessage: string;
}) => {
  const [copied, setCopied] = useState(false);

  return (
    <button
      onClick={() => {
        const contentToCopy = `${initialMessage}${message.sources && message.sources.length > 0 && `\n\nCitations:\n${message.sources?.map((source: any, i: any) => `[${i + 1}] ${source.metadata.url}`).join(`\n`)}`}`;
        navigator.clipboard.writeText(contentToCopy);
        setCopied(true);
        setTimeout(() => setCopied(false), 1000);
      }}
      className="p-2 text-black/70 dark:text-white/70 rounded-xl hover:bg-light-secondary dark:hover:bg-dark-secondary transition duration-200 hover:text-black dark:hover:text-white"
    >
      {copied ? <Check size={18} /> : <ClipboardList size={18} />}
    </button>
  );
};

Additional Context:

  • There might be a problem with how the sources are being emitted from the backend or received in the frontend.
@RazeBerry RazeBerry added the bug Something isn't working label Aug 25, 2024
@RazeBerry RazeBerry changed the title Clicking Copy button fails with no sources urls copied (or empty URLs returned?). Inconsistent Copying of Sources in Search Results Aug 25, 2024
@RazeBerry RazeBerry changed the title Inconsistent Copying of Sources in Search Results Inconsistent Display and Copy of Sources in Search Results Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant