Skip to content

Manage idling when connected via Codex Desktop via codex API (CRW-126… - #393

Merged
rgrunber merged 1 commit into
7.123.xfrom
codex-idling-7.123.x
Oct 15, 2026
Merged

rgrunber merged 1 commit into
7.123.xfrom
codex-idling-7.123.x

Conversation

@rgrunber

Copy link
Copy Markdown
Contributor

…26) (#390)

Extends CLI Watcher with a pluggable ActivitySource architecture and a new codex-app-server source, so workspaces stay alive while a user is actively working through Codex Desktop / the Codex VS Code extension / any other codex app-server client - not just via a TTY-attached shell.

  • ActivitySource interface + admin-controlled source selection (CLI_ACTIVITY_TRACKER_ACTIVITY_SOURCES), with the existing TTY-based detection unchanged as the tty source (on by default).
  • New codex-app-server source (opt-in): connects to a running codex app-server's own JSON-RPC control socket and polls thread/loaded/list + thread/read, gating activity on how recently the most-recently-updated loaded thread's updatedAt timestamp was touched. Only requires that the app-server's --listen unix://... socket is reachable, found via /proc comm+cmdline discovery (codex_app_server_discovery.go). Falls back to resolving the daemon-assigned default socket path (${CODEX_HOME:-$HOME/.codex}/app-server-control/app-server-control.sock) via the target process's own environment when codex was started with a bare --listen unix:// (no explicit path)
  • Gates activity on updatedAt freshness rather than the thread's status field. Does not honor gracePeriod/maxProcessAge.
  • The JSON-RPC client sets both read and write deadlines (5s) so a hung app-server cannot stall the watcher's scan loop; a transport-level thread/read failure drops the cached connection and stops the scan (next tick dials fresh), while JSON-RPC error responses (e.g. a thread that just disappeared) are logged and the scan continues.
  • Logs the full scan reasoning at verbose level - loaded-thread IDs, each thread's status/activeFlags/updatedAt as it's checked, per-thread read failures, and the freshness decision either way - so an admin can tell the source is actually reaching the app-server, not just whether it found something.
  • Covers the decision logic with unit tests and integration-style tests against a fake codex app-server served over a real Unix socket. Adds a protocol-compatibility test that runs against whatever codex CLI is actually installed (skipped if none is found) and checks that the Thread/ThreadStatus schema and the method names this client depends on still match, so a future codex protocol change fails this test loudly instead of breaking detection silently at runtime.

Enable with CLI_ACTIVITY_TRACKER_ACTIVITY_SOURCES=tty,codex-app-server (or just codex-app-server, since tty stays on by default unless explicitly disabled) on the workspace container. See CLI-WATCHER.md's new "Activity Sources" section for the full syntax and admin/.noidle split.

Issue: https://redhat.atlassian.net/browse/CRW-12626

Assisted-By: Claude Sonnet 5 noreply@anthropic.com
Assisted-By: OpenCode: MiMo-V2.6-Flash Free

Reviewed-by: Roland Grunberg rgrunber@redhat.com

…26) (#390)

Extends CLI Watcher with a pluggable ActivitySource architecture and a new
codex-app-server source, so workspaces stay alive while a user is actively
working through Codex Desktop / the Codex VS Code extension / any other
codex app-server client - not just via a TTY-attached shell.

- ActivitySource interface + admin-controlled source selection
  (CLI_ACTIVITY_TRACKER_ACTIVITY_SOURCES), with the existing TTY-based
  detection unchanged as the tty source (on by default).
- New codex-app-server source (opt-in): connects to a running codex
  app-server's own JSON-RPC control socket and polls thread/loaded/list +
  thread/read, gating activity on how recently the most-recently-updated
  loaded thread's updatedAt timestamp was touched. Only requires that
  the app-server's --listen unix://... socket is reachable, found via
  /proc comm+cmdline discovery (codex_app_server_discovery.go). Falls
  back to resolving the daemon-assigned default socket path
  (${CODEX_HOME:-$HOME/.codex}/app-server-control/app-server-control.sock)
  via the target process's own environment when codex was started with a
  bare --listen unix:// (no explicit path)
- Gates activity on updatedAt freshness rather than the thread's status
  field. Does not honor gracePeriod/maxProcessAge.
- The JSON-RPC client sets both read and write deadlines (5s) so a hung
  app-server cannot stall the watcher's scan loop; a transport-level
  thread/read failure drops the cached connection and stops the scan
  (next tick dials fresh), while JSON-RPC error responses (e.g. a thread
  that just disappeared) are logged and the scan continues.
- Logs the full scan reasoning at verbose level - loaded-thread IDs, each
  thread's status/activeFlags/updatedAt as it's checked, per-thread read
  failures, and the freshness decision either way - so an admin can tell
  the source is actually reaching the app-server, not just whether it
  found something.
- Covers the decision logic with unit tests and integration-style tests
  against a fake codex app-server served over a real Unix socket. Adds a
  protocol-compatibility test that runs against whatever codex CLI is
  actually installed (skipped if none is found) and checks that the
  Thread/ThreadStatus schema and the method names this client depends on
  still match, so a future codex protocol change fails this test loudly
  instead of breaking detection silently at runtime.

Enable with CLI_ACTIVITY_TRACKER_ACTIVITY_SOURCES=tty,codex-app-server
(or just codex-app-server, since tty stays on by default unless
explicitly disabled) on the workspace container. See CLI-WATCHER.md's new
"Activity Sources" section for the full syntax and admin/.noidle split.

Issue: https://redhat.atlassian.net/browse/CRW-12626

Assisted-By: Claude Sonnet 5 <noreply@anthropic.com>
Assisted-By: OpenCode: MiMo-V2.6-Flash Free
Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
Reviewed-by: Roland Grunberg <rgrunber@redhat.com>
@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 92f4fe4c-bba5-451d-b302-cdc4dfccb676

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@rgrunber
rgrunber merged commit 1a4309e into 7.123.x Oct 15, 2026
10 checks passed
@rgrunber
rgrunber deleted the codex-idling-7.123.x branch October 15, 2026 21:00
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