Skip to content

About

Experimental reversible KaTeX patch for the Codex desktop Markdown file editor

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codex desktop Markdown math patch

An experimental, reversible patch that adds KaTeX rendering to the right-side Markdown file editor in Codex desktop for Windows.

Verified Markdown math rendering

The conversation renderer already supports math, but the file editor is a separate CodeMirror 6 surface. This patch adds a CodeMirror replacement widget to that surface and reuses the KaTeX bundle already shipped with Codex.

What it supports

  • Inline math: $...$ and \(...\)
  • Display math: standalone $$...$$ and \[...\], including multiline input
  • Source editing: click into a rendered expression to reveal its Markdown
  • Safe exclusions: fenced code, inline code, URLs, HTML, escaped dollars, ordinary currency, and unmatched delimiters are not rendered
  • KaTeX safety settings: trust: false, with invalid input falling back to the original source

The repository contains no OpenAI application binaries. It generates a parallel portable copy and never modifies the signed Store installation.

Tested version

  • Windows package: OpenAI.Codex_26.715.7063.0_x64
  • Desktop application bundle: 26.715.52143

The patcher checks version-specific structural anchors and fails closed if a future build changes them. Rebuild the portable copy after every Codex update.

Build a portable patched copy

Requirements: Windows PowerShell and Node.js 20 or newer.

git clone https://github.com/2667741708/codex-markdown-math-patch.git
Set-Location -LiteralPath .\codex-markdown-math-patch
npm test

$codexPackage = Get-AppxPackage OpenAI.Codex
$installedApp = Join-Path $codexPackage.InstallLocation "app"
$portableApp = Join-Path $env:LOCALAPPDATA "CodexMathPatch\app"

.\scripts\build-portable.ps1 `
  -InstalledAppPath $installedApp `
  -Destination $portableApp

The destination must not already exist. This is intentional: the script never deletes or overwrites a previous portable installation.

Start it with a separate Chromium profile:

$portableApp = Join-Path $env:LOCALAPPDATA "CodexMathPatch\app"
$portableProfile = Join-Path $env:LOCALAPPDATA "CodexMathPatch\profile"

.\scripts\start-portable.ps1 `
  -PortableRoot $portableApp `
  -UserDataPath $portableProfile

Open examples/math-preview.md in the right panel to verify the result.

To go back to the official client, close the portable window and launch Codex normally. Removing the portable app/profile directories uninstalls the patch; the Store package remains unchanged.

Patch only an ASAR copy

For analysis or custom packaging:

node .\scripts\patch-asar.mjs `
  --source "C:\path\to\original\app.asar" `
  --output "C:\path\to\patched-app.asar"

node .\scripts\verify-patched-asar.mjs `
  "C:\path\to\patched-app.asar"

The patcher copies the source archive, changes exactly one fixed-size review-file-source-tab-*.js entry, and leaves the original archive untouched. To make the injected bundle fit that entry, it removes only React-Intl description metadata and the source-map comment, then pads the entry to its original byte length.

Why this is a patch instead of an upstream PR

The public openai/codex repository contains the CLI and related open-source components, but not the Codex desktop webview source that implements review-file-source-tab. A direct upstream source PR is therefore not currently possible. This repository is a tested proof of concept for the desktop team to port into its source tree.

See docs/architecture.md for how the right-side panel selects and renders different file types, and where the math extension is inserted.

Limitations

  • This is an unofficial binary-level experiment, not an OpenAI release.
  • It is intentionally pinned to the tested bundle structure.
  • The separate browser profile may require signing in again.
  • Native updater warnings can appear in a portable run; use the Store client for normal updates and rebuild the patch afterward.
  • Do not redistribute a generated portable directory or app.asar; those are proprietary OpenAI application files.

About

Experimental reversible KaTeX patch for the Codex desktop Markdown file editor

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages