wingmirror Download
Docs Codex

Docs · Agents

Connecting Codex

The Codex lines are in the setup window and the menu only if the folder ~/.codex exists. Connecting takes two steps, and the second is done in Codex.

1. Connect

Press Connect in the setup window, or choose Connect Codex… in the menu and confirm. The "Done" message lists the backups and reminds you of step 2.

In ~/.codex/hooks.json, one entry is added for each of nine events. Each runs /bin/sh '~/Library/Application Support/Wingmirror/hooks/codex-hook.sh' <path> (with the full path written out), which posts the event to http://127.0.0.1:7317/hooks/codex/<path>.

EventPathDoes Codex wait?What it is for
SessionStartsession-startNoThe session appears on the panel.
SessionEndsession-endNoThe card goes idle and stays for an hour. The Codex app shuts a thread down soon after its turn ends and opens it again when you pick it up, so an end there is rarely the end of the work. Use Hide card to clear one sooner.
UserPromptSubmit, Stop, InterruptturnNoA turn has begun, ended or been interrupted.
PreToolUsetool-startNoWhat the session is doing: the line on a working card.
PostToolUsetool-doneNoA tool has finished.
SubagentStophelper-doneNoA helper has finished.
PermissionRequestpermissionYes, up to 600 sThe request is held until you tap Approve or Deny, and the script prints the answer for Codex. With no answer it prints nothing and Codex asks in its own way.

The eight that only report are marked asynchronous, with a five-second timeout, or three seconds for SessionEnd and Interrupt, the most Codex allows those two. Entries that were already in the file, from you or from another tool, are left as they were and in their place. The file is copied to hooks.json.wingmirror-backup-<date>-<time> first; if there was no file, one is made. The file is written back as indented JSON with its keys in alphabetical order, so the order of its keys may change, but nothing in it is lost.

In ~/.codex/config.toml, if that file exists, codex-notify.sh is put first in the top-level notify list, as earlier versions of Wingmirror did, with whatever was there left after it and still run. It is backed up first as well. The app ignores what arrives this way once any hook has been heard, since both would describe the same session.

2. Trust the hooks in Codex

Codex runs a hook only after you have reviewed and trusted it. Until you do, the menu reads "Codex: Connected" but the hooks send nothing: at most a session shows when one of its turns ends, through the notify entry, with no line saying what it is doing and no approvals.

  • In the Codex desktop app: Settings → Hooks.
  • In the terminal: type /hooks.

Codex may ask again after an update of Wingmirror: the script the hooks run is replaced with the new version's when the app opens, and Codex notices that what it trusted has changed.

What a Codex card shows

A Codex session shows from its start, with its project, its model, what it is doing, and its permission requests with Approve and Deny. Codex asks twice at the same moment for one request; the panel shows that as one card, and one tap answers both.

What it does not show:

  • No context figure. Nothing Codex sends carries one. Its token totals are not read either.
  • Local sessions only. Hooks do not run for cloud tasks, so those never appear.
  • Terminal brings the Codex app, or failing that a terminal app, to the front. It does not select a tab.
  • The Git widget does not follow Codex sessions.

A Codex session sends nothing between events, so it is kept on the panel through its silences until it says it has ended, or for a day without a word.

Updating the Codex connection

The menu's Codex line says which of four states the connection is in:

LineWhat to do
Codex: ConnectedNothing.
Codex: Partly ConnectedRepair Codex Connection. Some of this version's hooks are missing.
Codex: Connected the Old Way, with "Shows a session only when a turn ends" under itUpdate Codex Connection…. Only the notify entry is there, from a version before hooks.
Codex: Not ConnectedConnect Codex…

In the second and third cases the app also asks "Update the Codex connection?" when it opens, with Update and Later. After any of these, trust the hooks in Codex again (step 2).

Disconnecting Codex

Choose Disconnect Codex. Wingmirror's entries are taken out of hooks.json and everything else in it stays; if the file was made by Wingmirror and holds nothing else, it is deleted. notify in config.toml goes back to exactly the text that was there. Both files are backed up first. From a terminal:

/Applications/Wingmirror.app/Contents/MacOS/Wingmirror hooks install codex
/Applications/Wingmirror.app/Contents/MacOS/Wingmirror hooks uninstall codex

With the app not running, Codex behaves as if nothing were installed.

Edit source on GitHub README.md#connecting-codex