UX/UI Issue: Forced conversion of pasted text into file attachments

,

Issue Description:
When pasting large amounts of text (1000+ lines) into the input field, the system automatically converts it into a text file attachment (.txt) instead of inserting it as raw text within the message body or code block.

Identified Errors and UX Flaws:

  1. Incorrect Positioning: The attachment/file is always appended to the very end of the message, ignoring the specific cursor position where the paste was intended.
  2. “Inline Media” Malfunction: Using the “Inline media” option expands the file content at the end of the message, not at the insertion point. This makes it impossible to insert large code snippets or logs into the middle of a structured message.
  3. Encoding Issues: The automatic conversion to a file corrupts character encoding when pasting text with non-Latin characters (e.g., Chinese symbols), rendering the data unreadable.

Regression:
Prior to recent updates, text of any length was pasted directly as raw text at the cursor position, which allowed for a correct workflow. The current behavior blocks normal interaction with code and logs.

Request:
Make the automatic text-to-file conversion an optional/toggleable feature. It is necessary to restore the ability to paste large amounts of raw text directly into the specific cursor position without forced conversion to attachments.

I found a temporary workaround for this issue. You can bypass this “text-to-file” conversion using a Tampermonkey userscript. This script intercepts the paste event and forces the browser to insert raw text directly into the cursor position, preventing Google’s scripts from triggering the file creation logic.

How to use:

  1. Install the Tampermonkey extension for Chrome:
  2. Click on the Tampermonkey icon in your browser and select “Create a new script”.
  3. Delete the default template and paste the code provided below.
  4. Press Ctrl+S to save.
  5. Refresh the AI Studio page.

Now, large text blocks will be pasted as raw text exactly where your cursor is.

The Script:

// ==UserScript==
// @name         AI Studio - Disable Auto-File Conversion
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Prevents Google AI Studio from converting long text pastes into files. Inserts raw text instead.
// @author       Alex(GoD) aka WyccStreams
// @match        https://aistudio.google.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Intercepting the paste event
    window.addEventListener('paste', function(e) {
        // Get text data from clipboard
        const text = (e.clipboardData || window.clipboardData).getData('text');
        
        // Only trigger for long texts (e.g., more than 800 characters)
        if (!text || text.length < 800) return;

        // Stop Google's default scripts from intercepting the paste and creating a file
        e.preventDefault();
        e.stopImmediatePropagation();

        const target = e.target;
        
        // Check if the target is a textarea or editable field
        if (target.tagName === 'TEXTAREA' || target.contentEditable === 'true') {
            const start = target.selectionStart;
            const end = target.selectionEnd;
            const oldText = target.value || "";

            // Insert text at current cursor position
            const newText = oldText.slice(0, start) + text + oldText.slice(end);
            target.value = newText;

            // Restore cursor position to the end of inserted text
            target.selectionStart = target.selectionEnd = start + text.length;

            // Trigger 'input' event so the site's UI updates (Angular/React sync)
            const inputEvent = new Event('input', { bubbles: true });
            target.dispatchEvent(inputEvent);

            // Optional: trigger change event
            const changeEvent = new Event('change', { bubbles: true });
            target.dispatchEvent(changeEvent);

            // Manual height adjustment for autosizing textareas
            target.style.height = 'auto';
            target.style.height = target.scrollHeight + 'px';
        }
    }, true);
})();