Codex Context Bridge is a local VS Code extension that restores Ctrl+L and Ctrl+Shift+L context attachment for editors that are not backed by a normal file: URI.
It exists for cases like:
- notebook cells opened as
vscode-notebook-cell - VS Code profile files such as
keybindings.jsonopened asvscode-userdata - other virtual editors where the stock
chatgpt.addToThreadcommand silently does nothing
The OpenAI Codex VS Code extension handles selected-line attachment through chatgpt.addToThread, but that path only works for file-backed editors.
This bridge keeps the default Codex behavior whenever it can:
- normal files still go through the native OpenAI commands
- non-file editors fall back to a temporary snapshot file
- full-document attach stays visually minimal
- partial selection attach keeps enough cell or line metadata to stay useful
Selection attach from a notebook cell or VS Code profile JSON:
Full-document attach from a non-file editor:
Ctrl+L
- For
file:editors, delegates to the nativechatgpt.addToThreadcommand. - For non-file editors, creates a temporary snapshot such as
keybindings.json [Lines 12-18].mdorsvd_practice.ipynb [Cell 8, Line 1].md.
Ctrl+Shift+L
- For
file:editors, delegates to the nativechatgpt.addFileToThreadcommand. - For non-file editors, attaches the whole document through a temporary snapshot that uses only the source filename, for example
svd_practice.ipynb.
The bridge writes temporary files only for non-file editors.
- Snapshots live under
%USERPROFILE%\.codex-context-bridge\snapshots - Each VS Code session gets its own snapshot folder
- Repeated attachments for the same source and selection reuse the same snapshot path
- Reattaching updates the snapshot content in place instead of creating numbered duplicates
- The current session folder is deleted when the extension session ends
- Session folders older than one day are removed on startup
- Legacy loose files under the snapshot root are removed on startup
This keeps the behavior simple:
- selected snippets remain readable in Codex
- whole-document chips stay clean
- snapshot files do not accumulate indefinitely under normal use
package.json: local extension manifestextension.js: command bridge and session-scoped snapshot handlinglib/snapshot.js: snapshot naming and content rulesscripts/install.ps1: installs the extension and updates keybindingsscripts/smoke-test.ps1: validates extension registration and keybinding wiringtests/snapshot.test.js: Node-based unit tests for snapshot formattingdocs/assets/: README illustrations
Run this after a Codex extension update or when reinstalling the bridge:
powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1Then reload VS Code with Developer: Reload Window.
The installer writes these bindings:
Ctrl+L->codexContextBridge.addSelectionToThreadCtrl+Shift+L->codexContextBridge.addActiveDocumentToThread
README.md,.py, and other normal files still use the native Codex flow. That is why they can show the cleaner built-in chip from the OpenAI extension.- The bridge only activates when the native extension cannot attach context because the active editor is not file-backed.
- This repository is a local workaround, not an official OpenAI project.
node .\tests\snapshot.test.js
powershell -ExecutionPolicy Bypass -File .\scripts\smoke-test.ps1
