Skip to content

Import Codex CLI tab-status (gnachman/iTerm2#673), gated behind spawnterm.codex_status#65

Merged
carvalhoviniciusluiz merged 1 commit into
masterfrom
feat/60-import-673
Jul 22, 2026
Merged

Import Codex CLI tab-status (gnachman/iTerm2#673), gated behind spawnterm.codex_status#65
carvalhoviniciusluiz merged 1 commit into
masterfrom
feat/60-import-673

Conversation

@carvalhoviniciusluiz

Copy link
Copy Markdown
Owner

Closes #60

Summary

Imports upstream gnachman#673 ("Show Codex CLI activity in tab status") into the fork, gated behind a new spawnTerm feature flag so it is OFF by default.

Codex (OpenAI) does not emit iTerm's OSC 21337 status protocol; it signals working/idle state by prefixing the OSC 0/1/2 terminal title with a braille-spinner glyph while crunching and dropping it when idle. This PR:

  • Adds a pure decoder (CodexTitleStatusDecoder) for the braille-spinner title prefix (U+2800–U+28FF + space), and a foreground-job-gated adaptor (CodexTitleStatusAdaptor) that synthesizes the equivalent iTermSessionTabStatus (Working/Idle) only when codex is the foreground job.
  • Introduces a new Title Changed event-trigger category (iTermTriggerMatchTypeEventTitleChanged) with an optional titleRegex filter, selectable/configurable like the other event triggers.
  • Adds an always-on built-in Codex Status trigger (CodexStatusTrigger) seeded by EventTriggerEvaluator, riding the Title Changed event; its side effect flows through a new triggerSession:applyCodexTitleStatusWithTitle: delegate method (VT100Screen / VT100ScreenMutableState) to -[PTYSession screenApplyCodexTitleStatusWithTitle:].
  • Synthesized status carries a source tag so it never overwrites a real OSC 21337 emitter and is excluded from window-restoration arrangements.

Feature flag (default OFF)

New capability spawnterm.codex_status ("Codex Tab Status"), added in all three synced places — spawnterm/flags/spawnterm-flag, spawnterm/flags/spawnterm_flag.py, sources/Settings/iTermSpawnTermCapabilities.m — plus spawnterm/docs/feature-flags.md. Toggled in Settings → General → AI → spawnTerm. Shell/Python parity tests (test_flags.sh) stay green (26/26).

Gate point: the Codex-activity → tab-status behavior is gated at the single choke point -[PTYSession screenApplyCodexTitleStatusWithTitle:] on isEnabledForCapability:@"codex_status". Both the trigger callback path and the foreground-job-change path funnel through it, so OFF ⇒ no synthesized Codex tab-status side effects (stock behavior).

Conflict resolution (this is the most invasive import — edits iTerm2 core)

  • PTYSession.m — our prior Tier 4.C — user-var sidecar persistence (fork-direct) #51 (user-var sidecar: screenSetUserVar:, userVarSidecar, replay, GC, dealloc) and Tier 4.A — optional delivery ack on async_send_text (fork-direct) #49 (writeTask:completion: threading) changes are fully preserved; verified present post-merge. The Show Codex CLI activity in tab status gnachman/iTerm2#673 hooks are purely additive (a call in setCurrentForegroundJobProcessInfo:, the trigger fire in screenSetWindowTitle:, and the new screenApplyCodexTitleStatusWithTitle: method).
  • Trigger.h — added the triggerSession:applyCodexTitleStatusWithTitle: delegate declaration alongside existing ones; no conflict with fork additions.
  • ITAddressBookMgr.h — new enum member landed as iTermTriggerMatchTypeEventTitleChanged = 116 (fork already had …VariableChanged = 115, no collision).
  • Applied via the squashed net diff (gh pr diff 673) to avoid the 4-commit series' internal churn (the PR reworks its own initial hook onto the trigger system). Hand-fixed rejects in iTermEventTriggerEvaluator.swift and iTermSessionTabStatus.swift (fork context drift: our fork uses RLog, has backgroundTasks/broadcastsChanges additions) preserving all fork code. New Swift files registered via tools/add_file_to_xcodeproj.rb into iTerm2SharedARC; ModernTests auto-included via the synchronized group.

Build status (HONEST)

Not verified as a green build — the environment cannot compile iTerm2. tools/build.sh aborts in the dependency phase, before any target sources compile, with:

Companion/CompanionCore/Sources/CNoise/shim/cnoise_stubs.c:27:10: error: 'noise/protocol.h' file not found (in target 'CNoise' from project 'CompanionCore')

This is the known toolchain/submodule mismatch (Xcode 26.2 vs prebuilt-deps 26.5), unrelated to these changes. The change set was verified correct-by-inspection: PTYSession.m preserves #51+#49 and adds gnachman#673; every imported symbol resolves against the fork (iTermSessionTabStatus(sessionID:), hasActiveStatus, apply(_:), maybePostTabStatusNotificationWithPreviousStatusText:, sessionTabStatusDidChange:, iTermVariableKeySessionForegroundJobAncestors, the Trigger scheduler API, iTermTriggerMatchTypeEventTitleChanged); no .rej/leakage; no submodule/ThirdParty/version-stamp changes.

Provenance

Adapted from upstream gnachman#673.

🤖 Generated with Claude Code

Bring in upstream "Show Codex CLI activity in tab status": Codex (OpenAI)
does not emit OSC 21337; it signals working/idle by prefixing the OSC
0/1/2 terminal title with a braille-spinner glyph. A pure decoder
(CodexTitleStatusDecoder) plus a foreground-job-gated adaptor
(CodexTitleStatusAdaptor) synthesize the equivalent iTermSessionTabStatus,
driven by a new always-on built-in "Codex Status" trigger riding a new
"Title Changed" event-trigger category.

Gated behind a new per-user spawnTerm feature flag `spawnterm.codex_status`
(default OFF), toggled in Settings > General > AI > spawnTerm. The gate is
enforced at the single choke point -[PTYSession
screenApplyCodexTitleStatusWithTitle:]: when OFF, no synthesized Codex tab
status is applied and behavior is stock. Flag added in all three synced
places (spawnterm-flag, spawnterm_flag.py, iTermSpawnTermCapabilities.m)
plus feature-flags.md; shell/python parity tests stay green.

PTYSession.m merge preserves our prior #51 (user-var sidecar) and #49
(writeTask:completion: threading) changes; the gnachman#673 hooks are purely
additive. New Trigger.h delegate method, VT100Screen side-effect plumbing,
and the Title Changed event UI are included.

Adapted from upstream gnachman#673

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@carvalhoviniciusluiz

Copy link
Copy Markdown
Owner Author

Review by tech-lead — code APPROVED by inspection; build UNVERIFIED (environment).

Import mais invasivo (upstream gnachman#673). Boa decisão: usou o net diff squashado (a série de 4 commits se sobrescrevia). Verifiquei o merge crítico em PTYSession.m:

@carvalhoviniciusluiz
carvalhoviniciusluiz merged commit 7ae7cca into master Jul 22, 2026
@carvalhoviniciusluiz
carvalhoviniciusluiz deleted the feat/60-import-673 branch July 22, 2026 19:58
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.

Import upstream #673 — Codex CLI activity in tab status (flag: codex_status)

1 participant