Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mycodex/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
dist/
release/
out/
*.log
.DS_Store
95 changes: 95 additions & 0 deletions mycodex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# MyCodex

A cross-platform **desktop app for the open-source [`@openai/codex`](https://www.npmjs.com/package/@openai/codex) engine**, built with Electron.

MyCodex gives the official Codex CLI a real desktop home: a sessions sidebar, a
working-folder picker, an interrupt control, and the full Codex agent running in
an embedded terminal — so sending a message, approving a file edit, viewing a
diff, interrupting a turn, and restoring a session after a restart all happen in
one window.

> Built and tested on Linux (x86_64). Build configs for macOS and Windows are
> included; see [Cross-platform notes](#cross-platform-notes).

## Why an embedded terminal?

The Codex engine is a self-contained Rust binary that ships a rich terminal UI
(approvals, inline diffs, streaming output, `Esc` to interrupt, `codex resume`
to restore). Rather than re-implement and inevitably drift from that interaction
logic, MyCodex drives the **real** engine inside an embedded terminal
([xterm.js](https://xtermjs.org/) + [node-pty](https://github.com/microsoft/node-pty)).
You get the authentic Codex behaviour, wrapped in a native desktop shell.

## The three packaging pitfalls (and how MyCodex handles them)

These bite every Electron app that spawns a bundled CLI. MyCodex addresses all
three:

1. **GUI launches get a crippled `PATH` and no `TERM`.** Apps launched from
Finder / a desktop launcher don't inherit your login shell's environment, so
the engine (and the shell commands it runs) break. `src/main/env.js`
reconstructs a real environment by asking your login shell to print its `env`
(`$SHELL -ilc 'env'`), then layers in sane defaults (`TERM=xterm-256color`,
common `bin` dirs, UTF-8 locale) before spawning the engine.
2. **`asar:false` so the bundled binary is spawnable.** A binary packed inside
an `app.asar` archive cannot be `exec`'d. The electron-builder config sets
`"asar": false` so the engine and node-pty's helper stay as real files on
disk.
3. **node-pty's `spawn-helper` needs `+x`.** Packaging frequently drops the
executable bit on node-pty's POSIX `spawn-helper` and on the engine binary.
`scripts/fix-pty-permissions.js` re-asserts it at install time, and
`src/main/main.js` does it again at startup.

## Project layout

```
mycodex/
src/
main/
main.js Electron main process: window, IPC, PTY lifecycle
env.js Login-shell PATH/TERM reconstruction (pitfall #1)
codex.js Locate the bundled engine binary + read session files
preload/
preload.js contextBridge API (no nodeIntegration in the renderer)
renderer/
index.html App shell (sidebar + terminal pane)
renderer.js xterm wiring, sessions list, controls
styles.css Codex-style dark theme
scripts/
build-renderer.js Bundle the renderer with esbuild
fix-pty-permissions.js chmod +x spawn-helper / engine (pitfall #3)
assets/icon.png
package.json
```

## Develop / run

```bash
npm install # installs Electron, node-pty, xterm, and the engine
npm run rebuild # rebuild node-pty against Electron's ABI
npm start # bundle the renderer and launch the app
```

On first launch the embedded terminal shows the engine's sign-in screen
(ChatGPT, device code, or API key) exactly as the CLI does. Authentication is
handled entirely by the engine — MyCodex never stores or hardcodes credentials.
If you've already run `codex login`, your existing `~/.codex/auth.json` is reused
automatically.

## Build / package

```bash
npm run dist:linux # AppImage + unpacked dir under release/
```

## Cross-platform notes

`electron-builder` targets are configured for Linux (AppImage), macOS, and
Windows. The engine binary is resolved per-platform from
`@openai/codex-<platform>-<arch>` at runtime (`src/main/codex.js`), mirroring the
official launcher. macOS/Windows artifacts must be produced on (or cross-built
for) their respective platforms.

## License

MIT
Binary file added mycodex/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading