Skip to content

Add new two commands monitor & shift#351

Open
mohitarora8181 wants to merge 5 commits into
openai:mainfrom
mohitarora8181:new_commands_monitor_add_shift
Open

Add new two commands monitor & shift#351
mohitarora8181 wants to merge 5 commits into
openai:mainfrom
mohitarora8181:new_commands_monitor_add_shift

Conversation

@mohitarora8181
Copy link
Copy Markdown

This pull request introduces a comprehensive session and history tracking system for Codex handoff and monitoring workflows in the Claude plugin. It adds new commands for session management, implements persistent recording and compaction of session history, and integrates a background hook to automatically log assistant turns and touched files. These changes enable seamless handoff between Claude and Codex, improved context sharing, and robust session resumption.

New Command Definitions and Session Management:

  • Added /codex:monitor command for starting or resuming Codex background sessions, with logic for session selection, fresh starts, and user prompts when multiple sessions exist.
  • Added /codex:shift command to hand off the current session to Codex, including session selection, merging, and launching a Codex terminal, with user prompts for multiple sessions and support for merging all sessions.

Session and History Tracking Library:

  • Implemented shift-history.mjs, a library for managing shift sessions: creating/resuming sessions, recording entries (assistant summaries and touched files), compacting and merging session history, and formatting context for Codex prompts.

Automated Session Logging Hook:

  • Added shift-history-hook.mjs, a hook that runs after each Claude turn to append a summary and touched files to the active shift session’s history log, ensuring session context is always up to date.
  • Registered the new hook in the plugin’s hooks.json to fire on each Stop event.

Key Features:

  • Persistent JSONL logs and compacted summaries for each session.
  • Automatic detection and logging of files touched (tracked and untracked).
  • Robust error handling to ensure hooks never block Claude.
  • User-friendly session selection and merging for seamless handoff.

@mohitarora8181 mohitarora8181 requested a review from a team May 26, 2026 18:00
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d6b1d5d3b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread plugins/codex/commands/monitor.md Outdated

**1 session** — auto-resume it, no question needed:
```bash
CLAUDE_PLUGIN_DATA="${CLAUDE_PLUGIN_DATA}" node "${CLAUDE_PLUGIN_ROOT}/scripts/codex-companion.mjs" monitor --resume-session <that-session-id>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve model/effort flags when resuming monitor sessions

The resume flow drops user-supplied runtime flags: if someone runs /codex:monitor --resume --model ... --effort ..., this step re-invokes monitor --resume-session <id> without forwarding those flags, so the monitor silently runs with default model/effort. This makes the command behave differently depending on session count and can violate explicit user configuration.

Useful? React with 👍 / 👎.

Comment on lines +1266 to +1267
const diffStat = spawnSync("git", ["diff", "--stat", "HEAD"], { cwd, encoding: "utf8" });
const diffFull = spawnSync("git", ["diff", "HEAD"], { cwd, encoding: "utf8" });
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include untracked files in shift handoff artifacts

The shift package is built from git diff ... HEAD, which excludes untracked files; in practice, newly created files that were never staged are omitted from both the Changed Files summary and Full Diff block. This causes incomplete handoff context whenever work includes brand-new files, even though those files are often the most important context for Codex to continue correctly.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97c869f02e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread plugins/codex/scripts/codex-companion.mjs
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bedccf9cb1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


// Build untracked diff by running git diff --no-index /dev/null <file> for each
const untrackedDiffParts = [];
for (const file of untrackedFiles.slice(0, 20)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include every untracked file diff in shift packages

When a handoff includes more than 20 newly-created files, the Changed Files section still lists all untracked paths but the Full Diff silently includes only the first 20 because of this slice. That makes /codex:shift produce an incomplete package for common scaffolding or generated-file changes, so the resumed Codex thread can miss brand-new source files without any indication that the diff was truncated.

Useful? React with 👍 / 👎.

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