codex icon indicating copy to clipboard operation
codex copied to clipboard

[Linux/Desktop] Copy button in Deep Research and in-app browser fails with DOMException

Open ryan-winkler opened this issue 2 weeks ago • 1 comments

Summary: Clicking the Copy button in a Deep Research report (mcp_app_sandbox) or in the built-in browser fails with DOMException (NotAllowedError). The session uses browser permission mode, but setPermissionCheckHandler still runs and returns false for clipboard writes.

What version of the Codex App are you using (From "About Codex" dialog)?

26.1111.21308 (openai-codex-desktop 26.1111.21308-1 on Arch Linux, --ozone-platform=wayland)

What subscription do you have?

Plus / Pro

What platform is your computer?

Linux 7.2.15-1-omarchy x86_64 unknown (Arch Linux, Hyprland 0.56.2, Wayland)

What issue are you seeing?

When I click Copy in a Deep Research report (connector_openai_deep_research), nothing copies to the clipboard. The desktop log records this error:

INFO mcp_app_sandbox.console_message level="error" line=410 message="Failed to copy report contents [object DOMException]" sourceId="https://connector-id-<redacted>.web-sandbox.oaiusercontent.com/"
WARN App reported a runtime error connectorId=connector_openai_deep_research errorMessage="Failed to copy report contents"

Root cause in 26.1111.21308

I checked .vite/build/early-bootstrap-226-2f6bd181558008cf.js and found three causes:

  1. setPermissionCheckHandler overrides browser permission mode: In dl(partition), e.permissionHandling is "browser". The if ("browser" === e.permissionHandling) block sets setPermissionPromptHandler and will-request-permission, but there is no else before the Electron handlers:

    if ("browser" === e.permissionHandling) {
      // sets setPermissionPromptHandler and will-request-permission
    }
    let allowLocalNetwork = (wcId, perm, url) => {
      let state = wcId == null ? null : getSandboxState(wcId);
      return "electron" === e.permissionHandling && "local-network" === perm && ...;
    };
    e.setPermissionRequestHandler((wc, perm, cb, details) =>
      cb(allowLocalNetwork(wc.id, perm, details.requestingUrl))
    );
    e.setPermissionCheckHandler((wc, perm, url) =>
      allowLocalNetwork(wc?.id, perm, url)
    );
    

    When e.permissionHandling is "browser", "electron" === e.permissionHandling is false. Both handlers return false and block Chromium's "clipboard-sanitized-write" check for navigator.clipboard.writeText().

    The built-in browser session (persist:codex-browser-app) has the same bug:

    e.setPermissionPromptHandler(this.options.onPermissionPrompt);
    e.setPermissionRequestHandler((e, t, r) => { r(false); });
    e.setPermissionCheckHandler(() => false);
    
  2. clipboardWrite does not map "clipboard-sanitized-write": In .vite/build/early-bootstrap.js, clipboardWrite maps only "clipboard-write". Chromium checks "clipboard-sanitized-write" for navigator.clipboard.writeText(). Also, connector_openai_deep_research does not declare clipboardWrite, so will-request-permission calls e.preventDefault().

  3. Deep Research also blocks report downloads: In the same widget, clicking Download opens a ?app=skybridge iframe that fails CSP (frame-src 'none'). The sandbox session also cancels will-download (mcp_app_sandbox.download_blocked).

What steps can reproduce the bug?

  1. Start the ChatGPT / Codex app (26.1111.21308) on Linux with --ozone-platform=wayland.
  2. Open a chat with a Deep Research report (connector_openai_deep_research).
  3. Click the Copy button in the report.
  4. Run wl-paste and check ~/.local/state/codex/logs/.../codex-desktop-*.log.

What is the expected behavior?

Clicking Copy in Deep Research or in the built-in browser copies the plain text to the system clipboard.

Additional information

When I allow "clipboard-sanitized-write" and "clipboard-write" in those permission handlers locally, the Copy button works as expected.

ryan-winkler avatar Nov 18 '26 16:11 ryan-winkler

The missing else explains the copy failure, and it has a wider blast radius than this button.

Both handlers are installed unconditionally, so the sandbox keeps a check handler that answers false for every permission, not just clipboard. Media capture, notifications, fullscreen and clipboard read are denied the same way, and because the check handler suppresses any prompt, the sandbox sees a plain denial with no user-visible reason. Anything that depends on a permission granted through the browser path is affected, not only Deep Research.

Two details matter in the fix. Delegate from both handlers, since a check can be answered before a request is raised depending on the permission and platform. And match the exact permission string: Electron distinguishes clipboard read, clipboard write, and the sanitized write name used on some platforms, so a delegate that whitelists one name still denies the call.

As a second layer, the sandbox page can fall back to the legacy execCommand copy path inside the iframe when the async call rejects, which keeps the button working even when the host bridge is misconfigured.

media-ctrl avatar Nov 18 '26 17:11 media-ctrl