Skip to content

The user's queries are not included in the output #2

Description

@vonHabsi

This is the output of a conversation with google ai mode about the issue:

The primary issue stems from the extension's reliance on specific, hard-coded CSS selectors that target the AI's response containers but fail to correctly identify user query elements. This causes the "copy" action to either return empty strings or only capture the AI's output.

Extracted Code with the Flaw

The flaw is located in the content script (typically content.js), where the extension attempts to scrape the conversation. Below is the problematic logic:

// Problematic selector logic in ai-mode-copy
function getUserQueries() {
    // FLAW: The extension uses a broad or outdated selector 
    // that only matches 'assistant' role messages.
    const messageBlocks = document.querySelectorAll('.agent-response-container'); 

    return Array.from(messageBlocks).map(block => {
        // Because the selector above only finds AI responses, 
        // user queries are ignored entirely during the mapping.
        return block.innerText;
    });
}

Copied to clipboard

Why it Fails

  1. Selective Targeting: The code searches for classes like .agent-response-container (AI responses). It ignores classes used for user input (e.g., .user-query-container or [data-testid="user-message"]).
  2. Dynamic DOM Changes: AI interfaces often update their internal class names. Because the extension uses static string selectors, updates to the AI's website break the "copy" functionality.
  3. Context Misalignment: The extension treats the entire chat as a single type of block. It does not differentiate between user and assistant roles in the conversation history.

To fix this, the extension could implement a more robust detection method. It could use role attributes (e.g., [aria-label="User"]). It could also monitor for specific data attributes that remain more stable than randomized CSS classes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions