Skip to content

Codex CLI Agent Adapter [Spec + Impl] - #12

Merged
rhuss merged 11 commits into
mainfrom
081-codex-adapter
Jul 12, 2026
Merged

rhuss merged 11 commits into
mainfrom
081-codex-adapter

Conversation

@rhuss

@rhuss rhuss commented Jul 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add Codex CLI agent adapter implementing the full Agent interface. Follows the same hooks-based pattern as Claude Code and OpenCode adapters.

Key changes:

  • New codex.go (238 lines): CodexAgent struct with InstallHooks (writes ~/.codex/hooks.json), TranslateEvent, CredentialSpecs (OPENAI_API_KEY)
  • New codex_test.go (498 lines, 76 tests): Full coverage of all Agent methods
  • Indicator: ◆ (black diamond), distinct from Claude (✳) and OpenCode (❯)
  • 8 hook events registered: SessionStart, PreToolUse, PostToolUse, PermissionRequest, UserPromptSubmit, Stop, SubagentStart, SubagentStop
  • README and configuration reference updated

Artifacts

  • Spec: specs/081-codex-adapter/spec.md
  • Plan: specs/081-codex-adapter/plan.md
  • Tasks: specs/081-codex-adapter/tasks.md

Assisted-By: 🤖 Claude Code


Open in Devin Review

Summary by CodeRabbit

  • New Features

    • Added Codex CLI integration, including session activity tracking, hook management, and OpenAI credential support.
    • Added sidebar auto-sort, placing active sessions above paused sessions with a visual separator.
    • Added configurable minimum speech duration for voice input.
  • Bug Fixes

    • Improved voice transcription by filtering Whisper hallucinations, repetition artifacts, and speaker-label prefixes.
    • Refined voice command detection with clearer multi-word triggers.
  • Documentation

    • Updated configuration and integration guidance for Codex CLI and sidebar auto-sort.

rhuss added 10 commits July 11, 2026 08:35
Add three layers of hallucination mitigation:

1. Server-side: Send anti-hallucination parameters (temperature=0,
   entropy/logprob thresholds, beam_size=1) on every whisper-server request.

2. VAD: Add MinSpeechDuration (default 0.3s) that requires minimum
   above-threshold audio before emitting an utterance. Drops noise spikes
   (clicks, door slams) that previously triggered hallucinated transcriptions.

3. Post-transcription: Detect asterisk-enclosed artifacts (*sigh*),
   14-phrase YouTube hallucination blocklist (Thank you for watching, etc.),
   and repetition loop detector for stuck decoder output.

Assisted-By: 🤖 Claude Code
Whisper sometimes outputs a leading hyphen when it interprets audio as
dialogue or subtitle continuation from its YouTube training data.
Strip the leading "- " or "-" prefix before further processing.

Assisted-By: 🤖 Claude Code
Whisper hallucinates subtitle-style speaker labels ("-Name." or
"- Name:") at the start of utterances from its YouTube training data.
Detect the pattern (dash + capitalized word + punctuation) and strip
it along with the dash, keeping only the actual speech content.

Assisted-By: 🤖 Claude Code
Change default command phrases from single words to two-word phrases:
- submit: "send" -> "send it"
- attend: "next" -> "go next"
- submit_attend: "ship" -> "ship it"

Two-word phrases improve Whisper recognition accuracy and stay
comfortably above the 300ms MinSpeechDuration threshold. Users can
still configure single-word commands via custom command maps.

Assisted-By: 🤖 Claude Code
Assisted-By: 🤖 Claude Code
Implement virtual two-zone partitioning in the sidebar: active (non-paused)
sessions appear above a visual separator line, paused sessions below it.
Recently-unpaused sessions are placed at the end of the active zone for
predictable, minimal movement. The manual three-tier sort (S key) continues
to work within the active zone when auto-sort is enabled.

Configurable via the `auto_sort` KDL plugin parameter (default: true).
When disabled, sidebar behavior is identical to pre-feature state.

Spec: 080-sidebar-auto-sort
Deep Review: 10/10 findings fixed (3 Critical, 7 Important)
Tests: 385 passed across 3 suites

Assisted-By: 🤖 Claude Code
Use cols.min(40) for the auto-sort pause zone separator, matching
the header separator width instead of cols-2 which was narrower.

Assisted-By: 🤖 Claude Code
Assisted-By: 🤖 Claude Code
Assisted-By: 🤖 Claude Code
@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@rhuss, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 01782105-23d6-4a9c-9702-dc5060cfe1cf

📥 Commits

Reviewing files that changed from the base of the PR and between 219f6bc and 873b129.

📒 Files selected for processing (9)
  • README.md
  • cc-deck/internal/agent/codex.go
  • cc-deck/internal/agent/codex_test.go
  • docs/modules/reference/pages/configuration.adoc
  • specs/081-codex-adapter/checklists/requirements.md
  • specs/081-codex-adapter/plan.md
  • specs/081-codex-adapter/review-findings.md
  • specs/081-codex-adapter/spec.md
  • specs/081-codex-adapter/tasks.md
📝 Walkthrough

Walkthrough

This PR adds Codex CLI agent support, implements configurable active/paused sidebar auto-sorting with separators, and updates voice detection, transcription, command handling, and Whisper artifact filtering.

Changes

Codex CLI agent integration

Layer / File(s) Summary
Agent adapter and hook lifecycle
cc-deck/internal/agent/codex.go
Registers CodexAgent, manages ~/.codex/hooks.json, translates hook events, and declares OpenAI credentials and domains.
Adapter tests
cc-deck/internal/agent/codex_test.go
Covers identity, hook installation and removal, idempotency, malformed files, event translation, and credential declarations.
Codex specifications and documentation
specs/081-codex-adapter/*, README.md, docs/modules/reference/pages/configuration.adoc
Documents the adapter plan, requirements, review findings, supported agent lists, credentials, and hook configuration.

Sidebar auto-sort

Layer / File(s) Summary
Configuration and state transitions
cc-zellij-plugin/src/config.rs, cc-zellij-plugin/src/controller/{actions,events,state}.rs
Adds auto_sort, tracks recently unpaused panes, and cleans tail state during pause, deletion, sorting, and session cleanup.
Render ordering and protocol
cc-zellij-plugin/src/controller/render_broadcast.rs, cc-zellij-plugin/src/lib.rs
Partitions active and paused sessions, applies stable ordering, and adds separator_after_index to render payloads.
Sidebar rendering and tests
cc-zellij-plugin/src/sidebar_plugin/*, cc-zellij-plugin/src/controller/render_broadcast.rs
Renders the active/paused separator, reserves its row, and tests ordering, disabled behavior, and lifecycle cases.
Auto-sort specifications and documentation
specs/080-sidebar-auto-sort/*, README.md, docs/modules/{reference,using}/pages/configuration.adoc
Defines and documents the virtual two-zone sorting behavior and configuration.

Voice pipeline

Layer / File(s) Summary
Detection and transcription behavior
cc-deck/internal/voice/{audio,relay,stopword,transcriber_http,vad}.go
Adds minimum speech-duration gating, Whisper inference fields, speaker-label cleanup, hallucination detection, repetition-loop detection, and multi-word command triggers.
Voice tests
cc-deck/internal/voice/*_test.go
Updates relay and stopword expectations and adds coverage for short and sufficiently long speech segments.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 65.17% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a Codex CLI agent adapter with both spec and implementation work.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 081-codex-adapter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

"hit the bell",
"leave a comment",
"bye bye",
"goodbye",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Single-word hallucination filter silently discards legitimate voice dictation containing "goodbye"

Any dictated text containing the word "goodbye" is silently dropped as a whisper artifact (strings.Contains(lower, "goodbye") at cc-deck/internal/voice/stopword.go:78-79), because "goodbye" was added as a single-word entry to the hallucination list alongside multi-word phrases, so dictation like "say goodbye to that approach" is permanently lost.

Impact: Users dictating sentences that naturally contain the word "goodbye" will have their speech silently discarded with no feedback.

Substring matching on a common single word causes false positives

The whisperHallucinations list at cc-deck/internal/voice/stopword.go:10-25 contains entries like "thank you for watching" and "please subscribe" which are multi-word phrases unlikely to appear in legitimate coding dictation. However, "goodbye" (line 24) is a single common English word.

The check at lines 77-80 uses strings.Contains(lower, phrase), which means any sentence containing "goodbye" as a substring matches:

  • "say goodbye to that approach" → filtered
  • "goodbye for now" → filtered
  • "we can say goodbye to manual testing" → filtered

All other hallucination entries are multi-word phrases (2+ words) that are extremely unlikely in coding dictation context. The single-word "goodbye" breaks this pattern.

The existing test at cc-deck/internal/voice/stopword_test.go:35 ("So thank you for watching and goodbye") would pass even without "goodbye" in the list because "thank you for watching" also matches, so the "goodbye" entry has no independent test coverage for its intended case, and no test validates that legitimate sentences containing "goodbye" are preserved.

Suggested change
"goodbye",
"bye bye",
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (4)
cc-deck/internal/voice/transcriber_http.go (1)

64-74: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider making inference parameters configurable.

The five parameters (temperature, entropy_thold, logprob_thold, no_speech_thold, beam_size) are hardcoded. The struct already supports configurable prompt via SetPrompt; inference parameters could follow the same pattern to allow tuning for different Whisper server configurations. The current defaults are sensible, so this can be deferred.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cc-deck/internal/voice/transcriber_http.go` around lines 64 - 74, The
inference parameters in the multipart field-writing loop are hardcoded,
preventing runtime tuning. Add configurable fields and setters to the
transcriber configuration, following the existing SetPrompt pattern, while
preserving the current values as defaults; update the loop to serialize the
configured temperature, entropy_thold, logprob_thold, no_speech_thold, and
beam_size values.
cc-deck/internal/agent/codex_test.go (1)

10-507: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider adding tests for IsInstalled() and DetectConfig().

These are the only Agent methods without test coverage. DetectConfig can be tested by overriding codexHooksPathFunc to point to a temp dir and verifying the returned path. IsInstalled is harder to test without mocking exec.LookPath, so it may be acceptable to skip.

💚 Suggested test for DetectConfig
func TestCodexAgentDetectConfig(t *testing.T) {
	dir := t.TempDir()
	hooksPath := filepath.Join(dir, ".codex", "hooks.json")

	origFunc := codexHooksPathFunc
	codexHooksPathFunc = func() string { return hooksPath }
	defer func() { codexHooksPathFunc = origFunc }()

	a := &CodexAgent{}

	// Before creating ~/.codex, DetectConfig should return ""
	if cfg := a.DetectConfig(); cfg != "" {
		t.Errorf("DetectConfig() = %q before dir creation, want empty", cfg)
	}

	// Create ~/.codex dir
	if err := os.MkdirAll(filepath.Join(dir, ".codex"), 0o755); err != nil {
		t.Fatalf("mkdir: %v", err)
	}

	// After creating ~/.codex, DetectConfig should return the path
	want := filepath.Join(dir, ".codex")
	if cfg := a.DetectConfig(); cfg != want {
		t.Errorf("DetectConfig() = %q, want %q", cfg, want)
	}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cc-deck/internal/agent/codex_test.go` around lines 10 - 507, Add test
coverage for CodexAgent.DetectConfig by overriding codexHooksPathFunc to use a
temporary hooks path, asserting it returns empty before the parent .codex
directory exists and the expected directory path after creation. IsInstalled may
remain untested because exec.LookPath is not mockable in the current design.
cc-deck/internal/agent/codex.go (1)

131-153: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider renaming CWD to Cwd for consistency with NormalizedPayload.

The codexHookPayload.CWD field uses all-caps while NormalizedPayload.Cwd uses CamelCase. Go's initialism convention allows all-caps for common acronyms (URL, ID, HTTP), but CWD is uncommon and the shared NormalizedPayload struct already uses Cwd. Aligning the naming improves readability at the assignment site (Cwd: hook.Cwd vs Cwd: hook.CWD).

♻️ Proposed naming alignment
 type codexHookPayload struct {
 	SessionID string `json:"session_id,omitempty"`
 	HookEvent string `json:"hook_event_name"`
 	ToolName  string `json:"tool_name,omitempty"`
-	CWD       string `json:"cwd,omitempty"`
+	Cwd       string `json:"cwd,omitempty"`
 }

And update the assignment in TranslateEvent:

 	return &NormalizedPayload{
 		Agent:     c.Name(),
 		SessionID: hook.SessionID,
 		HookEvent: hook.HookEvent,
 		ToolName:  hook.ToolName,
-		Cwd:       hook.CWD,
+		Cwd:       hook.Cwd,
 	}, nil
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cc-deck/internal/agent/codex.go` around lines 131 - 153, Rename the
codexHookPayload field CWD to Cwd and update its JSON-backed field reference in
TranslateEvent, preserving the existing "cwd" JSON tag and normalized payload
behavior.
cc-zellij-plugin/src/sidebar_plugin/render.rs (1)

38-75: 📐 Maintainability & Code Quality | 🔵 Trivial

Consider extracting the separator/viewport math into a testable helper.

This diff's pure index arithmetic (separator detection, effective-available sizing) has no unit test coverage in this cohort (only render_broadcast.rs/state.rs are tested per the PR stack). Given the subtlety flagged above, extracting these calculations into a small pure function taking (sessions, payload, available, lines_per_session) would make them independently testable without needing a real terminal/ANSI harness.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cc-zellij-plugin/src/sidebar_plugin/render.rs` around lines 38 - 75, Extract
the separator detection and viewport sizing logic from the render flow into a
small pure helper accepting sessions, payload, available, and lines_per_session.
Have the helper return the separator index plus the calculated effective
availability/max-visible values, then use those results in the surrounding
render function and add focused unit tests for the separator and sizing
boundaries.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cc-deck/internal/agent/codex.go`:
- Around line 200-203: Update defaultCodexHooksPath to handle the error returned
by os.UserHomeDir, returning an empty string on failure like DetectConfig
instead of constructing a relative .codex/hooks.json path; preserve the existing
filepath.Join behavior when the home directory is available.

In `@cc-zellij-plugin/src/sidebar_plugin/render.rs`:
- Around line 70-75: Update the `effective_available` calculation to subtract
the separator row only when `visible_range` contains `separator_after_index`;
otherwise retain the full `available` value. Keep `max_visible` based on this
corrected capacity so pages without a rendered separator can display the
additional session.

In `@specs/080-sidebar-auto-sort/spec.md`:
- Around line 57-65: Update the paused-session handling in the hook logic within
hooks.rs so Working/PostToolUse events are processed before the paused-session
early return. Clear the session’s paused state and append its pane to
auto_sort_tail when it becomes active, while preserving the existing guard
behavior for events that should remain paused.

In `@specs/081-codex-adapter/spec.md`:
- Around line 52-53: Update the Codex credential-detection acceptance criteria
to use the implemented "openai" auth-mode name instead of "api" in both
scenarios, and align any related tests with this same mode identifier.
- Around line 118-123: Standardize the Codex hooks minimum version to v0.124.0
throughout the Codex adapter specification, including assumptions, tasks, and
configuration documentation. Replace inconsistent references such as v0.46.0,
v0.143+, and v0.1.2505+; mention any earlier experimental release separately
only if it remains relevant.

In `@specs/081-codex-adapter/tasks.md`:
- Around line 7-9: Update the fenced code block in the task flow diagram to
declare an appropriate language, such as text, while preserving the diagram
content unchanged.
- Around line 86-90: Update the Codex hook configuration documentation task in
the referenced section to require Codex CLI v0.124.0 instead of v0.143+,
preserving the location, auto-configuration, and registered-events details.

---

Nitpick comments:
In `@cc-deck/internal/agent/codex_test.go`:
- Around line 10-507: Add test coverage for CodexAgent.DetectConfig by
overriding codexHooksPathFunc to use a temporary hooks path, asserting it
returns empty before the parent .codex directory exists and the expected
directory path after creation. IsInstalled may remain untested because
exec.LookPath is not mockable in the current design.

In `@cc-deck/internal/agent/codex.go`:
- Around line 131-153: Rename the codexHookPayload field CWD to Cwd and update
its JSON-backed field reference in TranslateEvent, preserving the existing "cwd"
JSON tag and normalized payload behavior.

In `@cc-deck/internal/voice/transcriber_http.go`:
- Around line 64-74: The inference parameters in the multipart field-writing
loop are hardcoded, preventing runtime tuning. Add configurable fields and
setters to the transcriber configuration, following the existing SetPrompt
pattern, while preserving the current values as defaults; update the loop to
serialize the configured temperature, entropy_thold, logprob_thold,
no_speech_thold, and beam_size values.

In `@cc-zellij-plugin/src/sidebar_plugin/render.rs`:
- Around line 38-75: Extract the separator detection and viewport sizing logic
from the render flow into a small pure helper accepting sessions, payload,
available, and lines_per_session. Have the helper return the separator index
plus the calculated effective availability/max-visible values, then use those
results in the surrounding render function and add focused unit tests for the
separator and sizing boundaries.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 56e98126-4735-408c-8bb9-f0fd34c0f9b4

📥 Commits

Reviewing files that changed from the base of the PR and between 6fba30f and 219f6bc.

📒 Files selected for processing (36)
  • README.md
  • brainstorm/00-overview.md
  • brainstorm/080-sidebar-auto-sort.md
  • brainstorm/081-codex-agent-adapter.md
  • cc-deck/internal/agent/codex.go
  • cc-deck/internal/agent/codex_test.go
  • cc-deck/internal/voice/audio.go
  • cc-deck/internal/voice/relay.go
  • cc-deck/internal/voice/relay_test.go
  • cc-deck/internal/voice/stopword.go
  • cc-deck/internal/voice/stopword_test.go
  • cc-deck/internal/voice/transcriber_http.go
  • cc-deck/internal/voice/vad.go
  • cc-deck/internal/voice/vad_test.go
  • cc-zellij-plugin/src/config.rs
  • cc-zellij-plugin/src/controller/actions.rs
  • cc-zellij-plugin/src/controller/events.rs
  • cc-zellij-plugin/src/controller/render_broadcast.rs
  • cc-zellij-plugin/src/controller/state.rs
  • cc-zellij-plugin/src/lib.rs
  • cc-zellij-plugin/src/sidebar_plugin/integration_tests.rs
  • cc-zellij-plugin/src/sidebar_plugin/render.rs
  • cc-zellij-plugin/src/sidebar_plugin/test_helpers.rs
  • docs/modules/reference/pages/configuration.adoc
  • docs/modules/using/pages/configuration.adoc
  • specs/080-sidebar-auto-sort/checklists/requirements.md
  • specs/080-sidebar-auto-sort/plan.md
  • specs/080-sidebar-auto-sort/research.md
  • specs/080-sidebar-auto-sort/review-findings.md
  • specs/080-sidebar-auto-sort/spec.md
  • specs/080-sidebar-auto-sort/tasks.md
  • specs/081-codex-adapter/checklists/requirements.md
  • specs/081-codex-adapter/plan.md
  • specs/081-codex-adapter/review-findings.md
  • specs/081-codex-adapter/spec.md
  • specs/081-codex-adapter/tasks.md

Comment on lines +200 to +203
func defaultCodexHooksPath() string {
home, _ := os.UserHomeDir()
return filepath.Join(home, ".codex", "hooks.json")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Handle os.UserHomeDir() error in defaultCodexHooksPath.

DetectConfig (line 30-32) handles the error from os.UserHomeDir() and returns "" on failure. defaultCodexHooksPath silently ignores it with _, which produces a relative path (.codex/hooks.json) if HOME is unset. This could write to an unexpected location.

🛡️ Proposed fix
 func defaultCodexHooksPath() string {
-	home, _ := os.UserHomeDir()
+	home, err := os.UserHomeDir()
+	if err != nil {
+		return filepath.Join(os.TempDir(), ".codex", "hooks.json")
+	}
 	return filepath.Join(home, ".codex", "hooks.json")
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func defaultCodexHooksPath() string {
home, _ := os.UserHomeDir()
return filepath.Join(home, ".codex", "hooks.json")
}
func defaultCodexHooksPath() string {
home, err := os.UserHomeDir()
if err != nil {
return filepath.Join(os.TempDir(), ".codex", "hooks.json")
}
return filepath.Join(home, ".codex", "hooks.json")
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cc-deck/internal/agent/codex.go` around lines 200 - 203, Update
defaultCodexHooksPath to handle the error returned by os.UserHomeDir, returning
an empty string on failure like DetectConfig instead of constructing a relative
.codex/hooks.json path; preserve the existing filepath.Join behavior when the
home directory is available.

Comment on lines +70 to +75
let effective_available = if separator_after_index.is_some() {
available.saturating_sub(1)
} else {
available
};
let max_visible = effective_available.checked_div(lines_per_session).unwrap_or(0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file='cc-zellij-plugin/src/sidebar_plugin/render.rs'

echo '--- outline ---'
ast-grep outline "$file" --view expanded || true

echo '--- relevant lines ---'
sed -n '1,240p' "$file" | cat -n | sed -n '1,240p'

echo '--- search symbols ---'
rg -n "separator_after_index|visible_range|max_visible|lines_per_session|sep_idx|available" "$file"

Repository: cc-deck/cc-deck

Length of output: 16198


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file='cc-zellij-plugin/src/sidebar_plugin/render.rs'

echo '--- visible_range ---'
sed -n '524,571p' "$file" | cat -n

echo '--- tests around visible_range ---'
sed -n '846,955p' "$file" | cat -n

echo '--- quick behavior probe for capacity math ---'
python3 - <<'PY'
def max_visible(available, has_sep, lps=3):
    effective = available - 1 if has_sep else available
    return effective // lps

for available in range(0, 13):
    if available % 3 == 0 and available > 0:
        print(available, max_visible(available, True), max_visible(available, False))
PY

Repository: cc-deck/cc-deck

Length of output: 6879


Separator row should only be reserved when it’s on the current page. effective_available subtracts 1 whenever an active/paused split exists, but visible_range can land entirely on one side of that split, so the separator never renders and the reserved row is wasted instead of showing another session. This drops one session whenever available is a multiple of lines_per_session.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cc-zellij-plugin/src/sidebar_plugin/render.rs` around lines 70 - 75, Update
the `effective_available` calculation to subtract the separator row only when
`visible_range` contains `separator_after_index`; otherwise retain the full
`available` value. Keep `max_visible` based on this corrected capacity so pages
without a rendered separator can display the additional session.

Comment on lines +57 to +65
### Edge Cases

- What happens when the last active session is paused? The separator disappears since all sessions are now in the paused zone. No empty active zone is shown.
- What happens when a new session is created while auto-sort is active? It appears at the end of the active zone (above the separator).
- What happens when a session is deleted while auto-sort is active? It is removed normally. If it was the only paused session, the separator disappears.
- What happens when a paused session receives an event that changes its status back to Working? It moves to the active zone (above the separator) at the bottom of the active zone, same as unpausing.
- What happens when the plugin starts and some sessions are already paused? Auto-sort immediately applies the two-zone split on the first render. Sessions already in the Paused state appear below the separator from the start.
- What happens if the auto-sort config value changes between plugin restarts? The new value takes effect on the next plugin load. No mid-session config reload is supported.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for event handling code that processes hook events for paused sessions.
# Look for where session.paused is set to false outside of handle_pause and handle_switch.
rg -nC5 'paused\s*=\s*false' cc-zellij-plugin/src/controller/ --type rust

Repository: cc-deck/cc-deck

Length of output: 3360


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant controller code paths for paused-session transitions and tail management.
sed -n '1,220p' cc-zellij-plugin/src/controller/events.rs
printf '\n--- actions.rs ---\n'
sed -n '1,140p' cc-zellij-plugin/src/controller/actions.rs
printf '\n--- auto_sort_tail references ---\n'
rg -nC3 'auto_sort_tail|paused\s*=\s*false|last_event_ts' cc-zellij-plugin/src/controller/ --type rust

Repository: cc-deck/cc-deck

Length of output: 45040


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the hook transition logic around Working events and paused-session updates.
sed -n '100,240p' cc-zellij-plugin/src/controller/hooks.rs
printf '\n--- later hook transitions ---\n'
sed -n '240,420p' cc-zellij-plugin/src/controller/hooks.rs
printf '\n--- tests mentioning paused / Working / auto_sort_tail in hooks.rs ---\n'
rg -nC3 'Working|paused|auto_sort_tail' cc-zellij-plugin/src/controller/hooks.rs --type rust

Repository: cc-deck/cc-deck

Length of output: 21031


Paused hook transitions never reach auto-sort
cc-zellij-plugin/src/controller/hooks.rs returns early for paused sessions, so a hook-driven Working event never clears paused or appends the pane to auto_sort_tail. If paused sessions should re-enter the active zone on Working/PostToolUse, handle that before the paused-session guard.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@specs/080-sidebar-auto-sort/spec.md` around lines 57 - 65, Update the
paused-session handling in the hook logic within hooks.rs so Working/PostToolUse
events are processed before the paused-session early return. Clear the session’s
paused state and append its pane to auto_sort_tail when it becomes active, while
preserving the existing guard behavior for events that should remain paused.

Comment thread specs/081-codex-adapter/spec.md Resolved
Comment on lines +118 to +123
## Assumptions

- Codex CLI's hooks system (confirmed in source at `codex-rs/hooks/`, `codex-rs/config/src/hook_config.rs`) is available in recent versions. Users on older versions (e.g., v0.46.0) will need to upgrade for hooks support.
- The Codex hook JSON payload structure is compatible with the existing `NormalizedPayload` model. Fields like `session_id` and `cwd` map directly.
- The `~/.codex/hooks.json` format uses a `{"hooks": {EventName: [MatcherGroup]}}` structure where each `MatcherGroup` has a `hooks` array of handler configs with `type`, `command`, `async`, and optional `matcher` fields.
- The existing `cc-deck hook --agent <name>` command accepts any registered agent name, so `--agent codex` works with no changes to the hook command itself.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

What Codex CLI version introduced hooks.json support, and what minimum version should cc-deck document?

💡 Result:

The Codex CLI introduced support for hooks.json files as the primary mechanism for configuring hooks early in its development, and the feature was later solidified with the graduation of hooks to stable status in Codex CLI version 0.124.0 [1]. Regarding cc-deck documentation, it should specify a minimum requirement of Codex CLI version 0.124.0 [1]. While hooks.json support existed prior to this, version 0.124.0 is the definitive release where hooks graduated from experimental to stable, enabling them by default when a hooks.json file is discovered and introducing standardized, production-grade configuration patterns [1]. Documentation targeting this version ensures compatibility with the stable feature set, including subsequent improvements to hook discovery, observation of MCP tools, and inline configuration support [1][2].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Relevant version mentions ==\n'
rg -n "hooks support|hooks\.json|v0\.46\.0|0\.124\.0|minimum version|Codex CLI" specs . || true

printf '\n== Spec file excerpt ==\n'
sed -n '100,140p' specs/081-codex-adapter/spec.md

printf '\n== Candidate docs with Codex hooks ==\n'
fd -a -t f -g '*codex*' . || true

Repository: cc-deck/cc-deck

Length of output: 30157


🌐 Web query:

Codex CLI hooks support minimum version official docs release notes v0.46.0 v0.124.0 v0.143.0 v0.1.2505

💡 Result:

Codex CLI introduced experimental lifecycle hooks in version v0.114.0 (March 2026) [1][2][3]. These hooks transitioned to a stable, production-grade feature in version v0.124.0 (released April 23, 2026) [2][4][5]. Key details regarding Codex CLI hook versions and support: 1. Initial Release (Experimental): Hooks were first shipped in v0.114.0 [1][3]. During the experimental phase, users were required to manually enable the feature via the configuration flag codex_hooks = true in their config.toml [6][2]. 2. Graduated to Stable: As of v0.124.0, hooks are considered stable and are enabled by default when a hooks.json file is discovered [2][4][5]. Inline configuration within config.toml and requirements.toml was also introduced in this version [2][5]. 3. Version-Specific Hook Support: - v0.114.0: Introduced SessionStart and Stop hooks [6]. - v0.116.0: Introduced UserPromptSubmit hook [6]. - v0.117.0: Introduced PreToolUse and PostToolUse hooks [6]. - v0.122.0: Introduced PermissionRequest hook [6]. - v0.124.0: Stability update; added support for observing MCP tools and apply_patch [2][5]. - v0.130.0: Introduced PreCompact and PostCompact hooks [6]. The version v0.46.0 was released before the hook system existed, and v0.143.0 (released July 8, 2026) includes further general improvements but post-dates the stabilization of the hook system [7][8][4]. There is no official release version v0.1.2505; this identifier likely refers to a timestamp or internal build reference rather than a standard semver release [7][9]. Always consult the official changelog at developers.openai.com/codex/changelog for the most current information [7][4].

Citations:


Standardize the Codex hooks minimum version.
Use v0.124.0 consistently across the spec, tasks, and configuration docs; the current mix of v0.46.0, v0.143+, and v0.1.2505+ is inconsistent. If the earlier experimental release matters, call it out separately.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@specs/081-codex-adapter/spec.md` around lines 118 - 123, Standardize the
Codex hooks minimum version to v0.124.0 throughout the Codex adapter
specification, including assumptions, tasks, and configuration documentation.
Replace inconsistent references such as v0.46.0, v0.143+, and v0.1.2505+;
mention any earlier experimental release separately only if it remains relevant.

Comment on lines +7 to +9
```
Task 1 (Agent implementation) ──> Task 2 (Tests) ──> Task 3 (Documentation)
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a language to the fenced code block.

This triggers markdownlint MD040. Use an appropriate language such as text.

Proposed fix
-```
+```text
 Task 1 (Agent implementation) ──> Task 2 (Tests) ──> Task 3 (Documentation)
-```
+```
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
Task 1 (Agent implementation) ──> Task 2 (Tests) ──> Task 3 (Documentation)
```
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 7-7: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@specs/081-codex-adapter/tasks.md` around lines 7 - 9, Update the fenced code
block in the task flow diagram to declare an appropriate language, such as text,
while preserving the diagram content unchanged.

Source: Linters/SAST tools

Comment on lines +86 to +90
2. In `docs/modules/reference/pages/configuration.adoc`, add a section documenting the Codex hook configuration:
- Location: `~/.codex/hooks.json`
- Auto-configured by `cc-deck config plugin install`
- Lists the registered events
- Notes that Codex CLI v0.143+ is required for hooks support

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

What Codex CLI version introduced hooks.json support, and what minimum version should cc-deck document?

💡 Result:

Codex CLI introduced hooks.json support in version 0.114.0, which was released in March 2026 [1][2]. While hooks were initially experimental and defined exclusively in hooks.json [1][3], they were later promoted to stable status in version 0.124.0, which added support for inline hook configuration in config.toml [3][4]. For documentation purposes, cc-deck should document a minimum version of v0.124.0 for Codex CLI [3]. This version is recommended as the baseline because it stabilized the hooks engine and resolved significant configuration issues—specifically, the transition from the experimental hooks.json-only model to the current stable format that supports both external files and inline configurations [3][5]. Documentation targeting version 0.124.0 ensures users are on a stable release where hooks are enabled by default and follow the standardized configuration schema [3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## Files mentioning Codex hooks or version constraints\n'
rg -n --hidden --glob '!**/.git/**' -e 'hooks\.json|0\.143|0\.124|Codex CLI' specs docs . || true

printf '\n## Target spec file around the cited lines\n'
sed -n '70,100p' specs/081-codex-adapter/tasks.md

printf '\n## Nearby docs configuration context if present\n'
fd -H -t f 'configuration.adoc' docs specs . | head -n 20

Repository: cc-deck/cc-deck

Length of output: 50372


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## Target spec excerpt\n'
sed -n '80,95p' specs/081-codex-adapter/tasks.md

printf '\n## Codex adapter spec references\n'
rg -n --hidden --glob '!**/.git/**' -e 'Codex CLI|hooks\.json|0\.143|0\.124|0\.114|v0\.' specs docs cc-deck | sed -n '1,200p'

printf '\n## Codex-related docs files\n'
fd -H -t f -g '*codex*' specs docs cc-deck | sed -n '1,200p'

Repository: cc-deck/cc-deck

Length of output: 26565


Use v0.124.0 for Codex hooks support.

v0.143+ is higher than the hooks baseline used elsewhere in the spec; lower this so the docs do not overstate the required Codex CLI version.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@specs/081-codex-adapter/tasks.md` around lines 86 - 90, Update the Codex hook
configuration documentation task in the referenced section to require Codex CLI
v0.124.0 instead of v0.143+, preserving the location, auto-configuration, and
registered-events details.

Implement a Codex CLI adapter that enables cc-deck to detect and interact
with OpenAI Codex CLI sessions. Adds codex.go with session detection,
command execution, and configuration support, along with comprehensive
unit tests. Updates documentation and README.

Assisted-By: 🤖 Claude Code
@rhuss
rhuss force-pushed the 081-codex-adapter branch from 219f6bc to 873b129 Compare July 12, 2026 14:15
@rhuss
rhuss merged commit 017a4a6 into main Jul 12, 2026
7 of 11 checks passed
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.

1 participant