mac: restore Codex session actions - #204
Open
khoi wants to merge 20 commits into
Open
Conversation
Reject transcriptless and nested Codex session starts before they can replace a pane's root session. Clear inherited Codex thread context at pane boundaries and remove the working-directory heuristic. Cover ownership rules, panel actions, socket transport, pane environments, and two-pane behavior.
🛠️ Tuist Run Report 🛠️Tests 🧪
Builds 🔨
|
Keep the nested-session test's distinct working directory while relying on the decoder tests for empty transcript normalization.
Manual hook payloads without persistence metadata succeed at the CLI but do not bind a panel session. Document the required signal and inherited thread guard in both the internal design and shipped agent guide.
…ership % Conflicts: % integrations/supaterm-skills
The shared hook host no longer inherits pane identity or the bundled CLI path, so valid starts could not bind to a terminal. Shell parsing also blocked the old command before it reached the CLI. Install a shell-safe bridge and route contextless starts to the one live process whose working directory matches. Keep ambiguous sessions unbound so one app cannot claim another app's session.
The --cd option changes the hook workspace without changing the process working directory. Resolve absolute, relative, long, and short forms against the launch directory before routing contextless session starts.
…ership % Conflicts: % apps/mac/SupatermCLIShared/SupatermAgentHook.swift
Codex now runs session hooks from a shared app-server process that has no pane context and may inherit another thread ID. Process and workspace matching alone can therefore miss the pane that owns the session. Use the hook payload as the session source and the exact terminal title as routing evidence. Keep process and workspace fallbacks for older clients, and preserve the inherited-session guard when a nested process owns the pane.
The managed hook command relied on the hook process inheriting the home used during installation. Shared hook hosts and CI can run with another home, so the shell never reached the installed bridge. Bind the command and ownership policy to the install home. Keep the hook optional when the bridge is unavailable and preserve its process lineage for pane routing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Codex 0.151 can emit
SessionStartfrom a shared host with no Supaterm pane context. Its PID may also sit outside the pane process tree. When process working-directory inspection fails, Supaterm could not find the pane even though the terminal knew its current directory. The panel never received the session ID, so Fork and Copy session ID stayed hidden.Even after routing a hook, Supaterm could bind the session to the short-lived hook emitter. Process cleanup then removed the session when that process exited.
The prior E2E pinned Codex 0.150.1, checked screen states, and never asserted first-prompt session binding. The new binding assertion first exposed lost process evidence. Once that was fixed, CI exposed a second fault: the installed command resolved the bridge through the hook process's
$HOME, which need not match the home used during installation.Installer tests used the same ambient home and did not execute the exact command written to settings under a different
HOME. Local runs inherited the expected value. The real E2E caught the launch fault only after the earlier routing fault stopped hiding it.What changed
The hook uses Codex's
session_id, requires only a non-emptytranscript_path, and never opens or parses the transcript.Contextless routing now uses, in order:
Detection resolves the effective Codex workspace while it reads the process invocation, then retains only that path with the exact process identity. Later unreadable scans cannot erase it; a changed agent or process start drops it. Hook routing uses this evidence before trying a fresh process query. It never stores the command line.
Process-derived workspace stays authoritative, including
-Cand--cd. Absolute declared paths do not depend on process working-directory access; relative paths still do. If process-derived routing evidence is unavailable, Supaterm uses the pane terminal's reported directory. Ambiguous, mismatched, and unknown owners still reject the hook.The selected pane anchors the session to its detected Codex process, then its foreground process. Supaterm uses the hook emitter only when it proves related and no stable pane process exists.
New panes clear inherited
CODEX_THREAD_ID. Nested sessions still require the inherited ID to match the hook payload.The installer writes the absolute, shell-escaped bridge path into every hook command. The bridge keeps the hook process lineage used for pane routing, drains input and succeeds when unavailable, uses an absolute bundled CLI fallback, and never depends on pane or hook-host environment. One home-scoped command policy now owns generation, health, upgrade, rollback, and removal.
Verification
make mac-checkmake mac-test-xcodebuildcodex: Copy session ID showedCopied; Fork session right opened a pane that confirmed the source threadHOME, special characters in the install path, andsh,bash,zsh, andfish-Cand--cdform, missing process working directories, relative paths, process priority, terminal fallback, mismatch, and unknown workspace statesNote
Codex emits a usable
SessionStartafter the first prompt. Session actions appear then, not on the untouched welcome screen.