hooks: restore Codex session actions under shared app-server - #223
Open
khoi wants to merge 16 commits into
Open
Conversation
Hook hosts do not inherit pane paths, so the environment-based command can skip delivery. Embed the canonical bundled CLI path in a marked shell wrapper while retaining legacy ownership for repair and removal.
Hook processes can outlive pane context, so inherited environment and workspace alone cannot identify the session owner. Query every live app, rank only safe evidence, and reject incomplete or ambiguous matches. Carry the selected pane's full process identity through final delivery so PID reuse cannot bind a session to stale detection. Bound discovery and delivery within the hook deadline.
Separate emitter queries from detected-process delivery and centralize durable root parsing. Require unique working-directory evidence so ambiguous panes fail closed.
Darwin rejects receive-timeout updates after a peer closes even when response bytes remain buffered. Set the first timeout before the request, then accept EINVAL only on later refreshes so the deadline stays enforced.
Codex session starts can run outside their terminal pane and carry stale process context. Document the evidence order, ambiguity rules, fixed socket namespace, and transcript boundary so the app, CLI, website, and installed skill describe the same behavior.
Codex now runs hooks from a shared app-server whose child environment can carry a stale pane, socket, or thread. Runtime path lookup could also skip the bridge before routing began. Invoke the bundled CLI directly, discover each compatible app, and bind only when live process, title, workspace, or guarded fork evidence selects one pane. Keep incomplete and ambiguous rounds fail-closed.
A fork starts with the same workspace as its parent and Codex reports it as a startup, so cwd alone cannot prove pane ownership. Document the guarded parent-session signal and the incompatible-instance rule.
…-pane-context % Conflicts: % apps/mac/supaterm/Features/Terminal/TerminalAgentLaunchOptions.swift % apps/mac/supaterm/Support/CodexSettingsInstaller.swift % apps/mac/supatermE2E/CodexE2ETests.swift % docs/coding-agents-integration.md % integrations/supaterm-skills
🛠️ Tuist Run Report 🛠️Tests 🧪
Builds 🔨
|
Shared app-server routing must use the same process identity, socket lookup, and argument parsing in the app and CLI. Keep each rule in one place so multi-instance candidate selection stays complete and cannot drift between callers.
The fork routing test sent its first prompt through the terminal after the new session had loaded. The shared host could interrupt that input, leaving the prompt as an unsent draft. Pass the initial prompt to the fork command so session startup triggers the hook and model turn as one operation.
The narrow fork pane inserts spaces when it wraps the response. Waiting for the exact rendered text can time out even after the model exchange finishes. Poll the fake server's existing completion check so the test waits on the request it owns instead of terminal layout.
The agent E2E job installs pinned tools after the setup action finishes. That later mise process had no token and could exhaust GitHub's public API limit before tests began. Keep the workflow token scoped to the agent test step that needs it.
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 run hooks from a shared app-server instead of the pane's TUI process. The resulting
SessionStartmay inherit no Supaterm socket, another pane's session ID, or a runtime environment that cannot find the installed bridge. Supaterm then never binds the new Codex session to its pane, so Copy Session ID and Fork Session disappear from the agent panel.Relying on inherited pane context cannot distinguish two Codex sessions hosted by the same process. The hook must rediscover the live Supaterm instances and prove which pane owns the session without reading the Codex transcript.
What changed
The managed hook now invokes the bundled
spexecutable by absolute path and discards stale CLI overrides. Root Codex starts query every live app instance and select a pane from exact process identity, terminal title, workspace, and global fork lineage; ambiguous evidence fails closed. Socket discovery now uses the private Darwin per-user temporary root and removes only dead-process endpoints.Note
This does not read Codex transcripts or guess between ambiguous workspace-only panes. Nested sessions cannot replace an owned root session unless exact process or fork-lineage evidence proves the change.
Verification
A real Codex 0.151 E2E launched two sessions through one shared app-server and bound each session to its launching pane. The focused suite covers 173 routing, socket, launch-parser, state-restore, and hook-install cases; live app-server handshake and trust installation also pass.