Skip to content

Surface richer Codex activity and public output - #343

Merged
wxtsky merged 6 commits into
wxtsky:mainfrom
954708775:feature/rich-codex-hooks
Sep 23, 2026
Merged

wxtsky merged 6 commits into
wxtsky:mainfrom
954708775:feature/rich-codex-hooks

Conversation

@954708775

Copy link
Copy Markdown
Contributor

Summary

This PR makes Codex sessions more informative than a generic thinking state while preserving the boundary between public assistant output and private model internals.

  • Derives task-level statuses from Codex lifecycle and tool events.
  • Shows the latest public assistant output while a task is active.
  • Uses the display priority: active tool action, public assistant output, then thinking.
  • Adds Codex PermissionRequest hook registration so approval requests reach the existing CodeIsland approval UI.
  • Extends SSH remote support with helper protocol 0.3.0 and public-output summaries.
  • Updates the English and Simplified Chinese setup documentation.

Behavior

Local sessions

CodeIsland tails Codex rollout transcripts and extracts only model-visible assistant output. Status text updates as new public output is written, without waiting for the session to stop.

Remote sessions

The remote helper includes a bounded public-output summary in lifecycle events sent through the existing SSH socket. Remote updates are event-driven rather than token-streamed, so they refresh when Codex emits a hook event.

Privacy and safety

The transcript parser intentionally excludes:

  • reasoning and encrypted reasoning content
  • tool output
  • internal subagent messages
  • non-assistant transcript records

Extracted text is normalized and bounded before display. Existing socket permissions and session routing remain unchanged.

Implementation notes

  • Adds reusable rich-status and public-output extraction models in CodeIslandCore.
  • Preserves existing fallback behavior when a transcript is missing, incomplete, or temporarily unreadable.
  • Keeps tool activity higher priority than assistant text to avoid obscuring the current action.
  • Merges CodeIsland hooks with existing Codex hooks rather than replacing user configuration.
  • Adds no new dependencies.

Validation

  • 116 Codex-focused tests passed.
  • 189 combined targeted tests passed.
  • Release build completed successfully with ./build.sh.
  • Manual local and SSH-remote smoke checks confirmed helper 0.3.0, socket forwarding, and PermissionRequest registration.

The existing Swift 6 Sendable warnings remain unchanged and are outside this PR.

benny and others added 6 commits September 23, 2026 10:57
Register the complete public Codex hook lifecycle locally and remotely, then translate provider-specific tool calls into bounded, privacy-aware status details without changing approval routing.

Constraint: Codex requires hooks to be reviewed again whenever hooks.json content changes.

Rejected: Rely on app-server polling alone | it misses CLI tool lifecycle detail and remote sessions.

Confidence: high

Scope-risk: moderate

Directive: Keep raw toolName values for approval decisions; activityLabel is display-only.

Tested: 8 Codex rich-status tests; 940-test suite excluding one environment-dependent PID assertion; release build.

Not-tested: Signed app packaging and live hook re-trust on a deployed installation.
The compact island now follows public Codex transcript output instead of falling back to a generic thinking label between tool calls. A transient per-turn field prevents stale replies from crossing task boundaries, while remote hooks attach a bounded public transcript summary to lifecycle events.

Constraint: Remote Codex sessions can refresh only when a hook event is forwarded; this is not token-level streaming.

Rejected: Forward response_item agent_message content | it may contain private inter-agent traffic.

Confidence: high

Scope-risk: moderate

Directive: Keep the public-output parser allowlisted; never broaden it to reasoning, encrypted content, tool output, or response_item agent_message.

Tested: 116 Codex-focused tests; 189 merged feature/config tests; remote Python filter tests; release build.

Not-tested: Signed app installation and live remote s-m hook delivery.
The quick probe required the contiguous run
`"payload":{"type":"message","role":"assistant"`, but Codex serializes
model output with its Responses API id between `type` and `role`
(`{"type":"message","id":"msg_…","role":"assistant",…}`). Every real
assistant record was therefore classified irrelevant and never parsed.

Since Codex switched the TUI and `codex exec` to paginated thread
history, rollouts no longer persist `event_msg` `agent_message` either,
so on current Codex the live-output line never updated locally.

Match the message-payload, assistant-role and output_text markers
independently within the same bounded 4 KiB prefix, and add fixtures
copied from a real 0.155 rollout (id, phase, metadata passthrough),
user/developer messages with ids, and a paginated Reasoning item.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Interrupting the root Codex turn does not stop agents it spawned; they
keep running and emit SubagentStop when their turn ends. The latch
dropped that event, so the child stayed in `subagents` and the next
root Stop saw "active subagents" and pinned the card to running/Agent.

SubagentStop only removes subagent state and cannot revive an idle
parent, so exempt it from the latch.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`sanitizedSummary` rebuilt eight NSRegularExpressions on every call, and
it runs for every Codex PreToolUse / PermissionRequest description.
Hoist them into a static table; an invalid pattern now trips an
assertion in debug instead of being skipped silently.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Codex fires SubagentStop at the end of every child turn, and agent_id is
the child's thread id, reused for follow-up turns sent through
send_message / followup_task with no new SubagentStart. Now that the
installer registers SubagentStop, the reducer's closed-subagent
tombstone made CodeIsland drop every later turn's hooks and auto-deny
their PermissionRequests via shouldSuppressClosedSubagentUI.

For Codex SubagentStop, remove the subagent entry but skip the
tombstone; Codex awaits hooks in order, so no stale tool hook trails
the stop, and the next turn's hooks recreate the entry. Other
providers (single-use Claude Task ids, Cursor Tasks) keep the
tombstone.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@wxtsky
wxtsky force-pushed the feature/rich-codex-hooks branch from db2e1bb to 81a6512 Compare September 23, 2026 03:09
@wxtsky
wxtsky merged commit 890b929 into wxtsky:main Sep 23, 2026
@wxtsky

wxtsky commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Merged (890b929) — thanks a lot, @954708775. The richer Codex statuses and the careful public-output/privacy boundary are a great addition, and the redaction tests are thorough.

I checked the hook contract against codex-rs/config/src/hook_config.rs: all five new events (PreCompact / PostCompact / SubagentStart / SubagentStop / Interrupt) exist, and older Codex silently ignores event keys it doesn't know, so registration is safe. (Small note: PermissionRequest was already registered on main via #145/#306, so this PR effectively adds the other five.)

Testing against real rollouts turned up three things, which I fixed on your branch before merging:

  1. The tail fast path never matched real Codex output — real records serialize the Responses id before the role ({"type":"message","id":"msg_…","role":"assistant",…}), and since Codex moved TUI/exec to paginated history, rollouts no longer contain event_msg agent_message. Together, local live output never updated on current Codex (the fixtures passed only because they omitted id). Fixtures are now real 0.155 rollout lines.
  2. The Interrupt latch dropped SubagentStop — spawned agents keep running after the root turn is interrupted, so the next root Stop pinned the card to running.
  3. Registering SubagentStop tombstoned Codex child thread ids after their first turn — Codex fires SubagentStop per child turn and reuses the id for send_message/followup_task, so follow-up turns were dropped and their PermissionRequests auto-denied. Codex SubagentStop no longer marks the id closed.

Plus the redaction regexes are now compiled once. Ships in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants