Vscode extension steals focus when vscode starts and extension gets loaded

Open 💬 4 comments Opened Nov 30, 2025 by JohnnyBill
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the VS Code extension are you using?

0.5.46

What subscription do you have?

ChatGPT Pro

Which IDE are you using?

VS Code

What platform is your computer?

Ubuntu 24.04

What issue are you seeing?

When i start vscode, i often open an integrated terminal and start typing in it immediately, before the codex extension on the right sidebar has finished loading. When the extension finished loading, it steals the focus from the terminal. That's quite annoying. "chatgpt.openOnStartup": false, Doesn't help either, because the secondary sidebar state get's stored by VSCode. The extension just shouldn't steal focus on the initial load.

What steps can reproduce the bug?

Put codex in the secondary sidebar, close vscode, open it again, start typing in an editor or terminal window and see what happens with the focus when the extension finishes loading

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 9 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #126

Powered by Codex Action

magist3r · 1 day ago

Still reproducible with current versions:

  • Codex IDE extension: openai.chatgpt 26.820.60940 (linux-x64)
  • VS Code: 1.134.0
  • Platform: Linux x64
  • "chatgpt.openOnStartup": false

Reproduction:

  1. Leave Codex in the secondary sidebar and close VS Code.
  2. Start VS Code again.
  3. Immediately focus the integrated terminal and begin typing, for example into a masked password/credential prompt.
  4. When the restored Codex webview finishes loading, keyboard focus moves to the Codex composer.

This is more than an annoyance: text intended for a masked terminal prompt can instead be entered into the visible Codex composer, and pressing Enter can submit that credential.

chatgpt.openOnStartup: false does not prevent this because VS Code restores the secondary-sidebar state and the composer takes focus when its webview mounts.

Expected behavior: restoring or mounting the Codex webview during IDE startup must not move keyboard focus. The composer should only receive focus after an explicit user action targeting Codex.

magist3r · 1 day ago

Confirmed workaround: the startup focus grab stopped after changing the primary composer's bundled prop from:

- disableAutoFocus:ce!=="default"
+ disableAutoFocus:!0

After making that single replacement in the installed extension's webview bundle, I validated the JavaScript syntax and ran Developer: Reload Window. The Codex composer then stopped stealing keyboard focus when the extension finished loading during VS Code startup.

This indicates that the primary composer is mounted with autofocus enabled in its default mode, independently of chatgpt.openOnStartup. These settings had not prevented the behavior:

"chatgpt.openOnStartup": false,
"workbench.secondarySideBar.defaultVisibility": "hidden"

This is only an unofficial workaround. Editing a bundled extension file is version-specific, and an extension update or reinstall will overwrite it. The proper fix should prevent composer autofocus during extension startup unless the user explicitly focuses Codex.

alexr-oai · 13 hours ago

Hi all, thanks for reporting this, and thanks @magist3r for the detailed reproduction and analysis.
We've reproduced the issue and merged a fix. When VS Code restores the Codex sidebar at startup, the composer should no longer take focus away from the editor or terminal. Explicit actions such as opening Codex or starting a new chat will still focus the composer.
I'll update this issue with the extension version once the fix is released.