feat(codex): preview generated images in chat (#630)

This commit is contained in:
MapleStoryIdle
2026-05-17 11:52:03 +08:00
committed by GitHub
parent 84ba7044a8
commit 86780e94d0
15 changed files with 429 additions and 5 deletions
+23
View File
@@ -13,6 +13,7 @@ import type { CodexSession } from './session';
import type { EnhancedMode } from './loop';
import { hasCodexCliOverrides } from './utils/codexCliOverrides';
import { AppServerEventConverter } from './utils/appServerEventConverter';
import { registerGeneratedImage } from '@/modules/common/generatedImages';
import { registerAppServerPermissionHandlers } from './utils/appServerPermissionAdapter';
import { buildThreadStartParams, buildTurnStartParams } from './utils/appServerConfig';
import type { ThreadGoal, ThreadGoalStatus } from './appServerTypes';
@@ -1968,6 +1969,28 @@ class CodexRemoteLauncher extends RemoteLauncherBase {
});
}
}
if (msgType === 'generated_image') {
const sourceImageId = asString(msg.image_id ?? msg.imageId ?? msg.id);
const imageId = randomUUID();
const savedPath = asString(msg.saved_path ?? msg.savedPath);
if (savedPath) {
const image = registerGeneratedImage({
id: imageId,
path: savedPath,
fileName: asString(msg.file_name ?? msg.fileName),
mimeType: asString(msg.mime_type ?? msg.mimeType)
});
messageBuffer.addMessage(`Generated image: ${image.fileName}`, 'assistant');
session.sendAgentMessage({
type: 'generated-image',
imageId: image.id,
sourceImageId,
fileName: image.fileName,
mimeType: image.mimeType,
id: randomUUID()
});
}
}
if (msgType === 'exec_command_begin' || msgType === 'exec_approval_request') {
const callId = asString(msg.call_id ?? msg.callId);
if (callId) {