Skip to content

[Bug]: preview_click returns success in hidden tabs but does not dispatch the click #3717

Description

@gregbartell

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. Start T3 Code Desktop.

  2. Open a Codex-backed thread with the T3 preview MCP tools available.

  3. Save this minimal page as background-click-repro.html:

    <!doctype html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <title>T3 Preview Background Click Repro</title>
      </head>
      <body>
        <h1>T3 Preview Background Click Repro</h1>
        <p>Selected: <strong id="selected">Alpha</strong></p>
        <p>Click count: <strong id="count">0</strong></p>
        <button id="alpha" type="button" aria-pressed="true">Alpha</button>
        <button id="beta" type="button" aria-pressed="false">Beta</button>
        <script>
          let count = 0;
          const selected = document.querySelector("#selected");
          const countNode = document.querySelector("#count");
          const buttons = Array.from(document.querySelectorAll("button"));
          for (const button of buttons) {
            button.addEventListener("click", () => {
              count += 1;
              selected.textContent = button.textContent;
              countNode.textContent = String(count);
              for (const candidate of buttons) {
                candidate.setAttribute(
                  "aria-pressed",
                  candidate === button ? "true" : "false",
                );
              }
            });
          }
        </script>
      </body>
    </html>
  4. Serve the directory containing that file:

    python -m http.server 8000
  5. Open the page in a new hidden/background tab:

    {
      "show": false,
      "reuseExistingTab": false,
      "url": "http://localhost:8000/background-click-repro.html"
    }
  6. Verify evaluation works and capture the initial page state:

    ({
      selected: document.querySelector("#selected").textContent,
      count: document.querySelector("#count").textContent,
      betaMatches: document.querySelectorAll("#beta").length
    })

    Expected initial result:

    {
      "selected": "Alpha",
      "count": "0",
      "betaMatches": 1
    }
  7. Click the Beta button with a text locator:

    {
      "locator": "text=Beta",
      "timeoutMs": 15000
    }
  8. Check the page state again with the expression from step 6.

  9. Repeat with the preflighted CSS selector:

    {
      "selector": "#beta",
      "timeoutMs": 15000
    }
  10. Check the page state again.

Expected behavior

If a hidden/background tab supports navigation and evaluation, preview_click should dispatch clicks to matching elements in that tab or return a clear unsupported-state error.

After either preview_click call above, the page state should be:

{
  "selected": "Beta",
  "count": "1",
  "betaMatches": 1
}

It should not return a success-shaped result when the page did not receive the click.

Actual behavior

The hidden tab loaded normally and preview_evaluate worked.

The text-locator click returned null, but the page state stayed unchanged:

{
  "selected": "Alpha",
  "count": "0",
  "betaMatches": 1
}

The CSS selector was preflighted to match exactly one element. The CSS click also returned null without changing the page state:

{
  "selected": "Alpha",
  "count": "0",
  "betaMatches": 1
}

In an earlier run against a more complex page, a later retry timed out and evaluation on that background tab also began timing out. The minimal repro above focuses on the deterministic part: hidden-tab clicks can return null without dispatching.

Impact

Major degradation or frequent failure

Version or commit

T3 Code desktop 0.0.28-1 via t3code-bin AUR package.

Environment

Arch Linux x86_64, kernel 7.0.13-arch1-1, T3 Code desktop AppImage package via t3code-bin, Codex provider.

Logs or stack traces

No stack trace. The failing calls return null while the page state remains unchanged.

Screenshots, recordings, or supporting files

Minimal repro page attached above. A screenshot is not needed; the selected and count fields show whether the click dispatched.

Workaround

Use hidden/background tabs for navigation, waits, and evaluation only. Use a shown tab for click-heavy flows, and verify every click effect with preview_evaluate or preview_status.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions