Add Codex clear and compact slash commands (#541)

* Add Codex clear and compact slash commands

* Stabilize queued thinking event test

* Interrupt active Codex turn before slash commands
This commit is contained in:
NightWatcher314
2026-04-29 14:15:44 +08:00
committed by GitHub
parent 0160da4bb5
commit a612be50d6
15 changed files with 460 additions and 16 deletions
+12
View File
@@ -14,6 +14,7 @@ import { CodexCollaborationModeSchema, PermissionModeSchema } from '@hapi/protoc
import { formatMessageWithAttachments } from '@/utils/attachmentFormatter';
import { getInvokedCwd } from '@/utils/invokedCwd';
import type { ReasoningEffort } from './appServerTypes';
import { parseCodexSpecialCommand } from './codexSpecialCommands';
import { listSlashCommands } from '@/modules/common/slashCommands';
import { resolveCodexSlashCommand } from './utils/slashCommands';
@@ -139,6 +140,7 @@ export async function runCodex(opts: {
try {
syncCurrentConfigFromSession();
let text = message.content.text;
let isolatedCommandText: string | null = null;
const commands = await listSlashCommands('codex', workingDirectory).catch(() => []);
const slash = resolveCodexSlashCommand(text, {
commands,
@@ -161,6 +163,12 @@ export async function runCodex(opts: {
return;
}
text = slash.text;
} else {
const specialCommand = parseCodexSpecialCommand(message.content.text);
if (specialCommand.type) {
logger.debug(`[Codex] Detected special command: ${specialCommand.type}`);
isolatedCommandText = message.content.text.trim();
}
}
text = formatMessageWithAttachments(text, message.content.attachments);
@@ -177,6 +185,10 @@ export async function runCodex(opts: {
modelReasoningEffort: currentModelReasoningEffort,
collaborationMode: currentCollaborationMode
};
if (isolatedCommandText) {
messageQueue.pushIsolateAndClear(isolatedCommandText, enhancedMode, localId);
return;
}
messageQueue.push(text, enhancedMode, localId);
} catch (error) {
logger.debug('[Codex] Failed to handle user message', error);