Skip to content

Conversation

@zkytech
Copy link

@zkytech zkytech commented Nov 20, 2025

📋 Summary

This PR implements support for the /clear special command in the Codex, bringing it to feature parity with the Claude. The /clear command now properly resets the session state

🎯 Motivation

Previously, the /clear command was only fully implemented in the Claude Code. The Codex lacked the ability to handle this command, creating an inconsistent user experience across different AI backends. This PR addresses that gap.

🔧 Changes Made

Modified Files

src/codex/runCodex.ts

Key Changes:

  • Import added: Added parseSpecialCommand from @/parsers/specialCommands
  • Message queue handling (Lines ~179-184): Parse incoming messages for special commands and use pushIsolateAndClear for /clear commands
  • Session reset logic (Lines ~625-646): Added comprehensive /clear command handling that:
    • Clears the client session
    • Resets session state flags (wasCreated, currentModeHash)
    • Resets all processors (permission handler, reasoning processor, diff processor)
    • Updates thinking state and keep-alive
    • Sends status message to user
    • Emits ready event to continue processing

Impact: Enables Codex to properly handle session resets via the /clear command.

src/claude/runClaude.ts

Key Changes:

  • Line 275: Fixed debug log message from /compact to /clear for accuracy
  • Line 307: Removed trailing whitespace

Impact: Minor code cleanup and improved logging accuracy.

src/parsers/specialCommands.ts

Key Changes:

  • Code formatting improvements (removed trailing whitespace)
  • No functional changes

Impact: Code quality improvement.

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