fix(codex): improve local session import compatibility#995
Conversation
There was a problem hiding this comment.
Findings
- [Major] Synthetic context filter can drop real imported user prompts —
hub/src/web/routes/codexDesktop.ts:296 - [Major] Adjacent duplicate collapse is not limited to mirrored transcript sources —
hub/src/web/routes/codexDesktop.ts:823
Summary
- Review mode: initial
- Found two import-parser data-loss risks introduced by the diff. Both affect transcript fidelity during direct Codex import.
Testing
- Not run (automation); attempted
bun test hub/src/web/routes/codexDesktop.test.ts, butbunis not installed in this runner.
HAPI Bot
| return normalized.startsWith('# AGENTS.md instructions') | ||
| || normalized.includes('<INSTRUCTIONS>') | ||
| || normalized.startsWith('<environment_context>') | ||
| || lower.includes('<environment_context>') |
There was a problem hiding this comment.
[MAJOR] This now drops any response_item user message that merely contains <environment_context> anywhere in the prompt. response_item is also where real user prompts are imported, so a user asking about or pasting a transcript/XML block with that tag is silently omitted from the imported HAPI session. Keep the filter to standalone injected blocks instead of arbitrary substrings.
Suggested fix:
function shouldIgnoreInjectedResponseUserMessage(text: string): boolean {
const normalized = text.trim()
const lower = normalized.toLowerCase()
const isAgentInstructions = lower.startsWith('# agents.md instructions')
const isEnvironmentContext = lower.startsWith('<environment_context>')
&& lower.endsWith('</environment_context>')
return isAgentInstructions || isEnvironmentContext
}| continue | ||
| } | ||
| const previous = entries[entries.length - 1] | ||
| if (previous && isAdjacentDuplicateImportedMessage(previous.message, message)) { |
There was a problem hiding this comment.
[MAJOR] This duplicate check collapses any adjacent imported user/assistant messages with the same normalized text, even when both came from the same transcript source. That can remove legitimate repeated messages; the mirror bug this PR fixes is specifically an event_msg/response_item duplication, so the drop should require different sources.
Suggested fix:
function isMirroredAdjacentDuplicate(
previous: CodexImportedMessageEntry | undefined,
next: CodexImportedMessageEntry
): boolean {
return Boolean(
previous
&& previous.source !== next.source
&& isAdjacentDuplicateImportedMessage(previous.message, next.message)
)
}
// Use isMirroredAdjacentDuplicate(previous, entry) in both adjacent-dedupe branches.0e2c7be to
899c16c
Compare
There was a problem hiding this comment.
Findings
- No issues found.
Questions
- None.
Summary
- Review mode: follow-up after new commits
- Previous HAPI Bot findings from
0e2c7bee2988a57ff640944ce1e6a583e687c8f8were rechecked against current head899c16c223334d3d5f1a5e6b29816b29d757d0eb; no current diff findings above 80% confidence. - Residual risk: local test automation could not be run in this runner.
Testing
- Not run (automation);
bun --versionfailed withbun: command not found. git diff --checkpassed.
HAPI Bot
|
Verified locally. All tests passed successfully.
Additionally verified the Codex import behavior manually:
|
fix(codex): improve local session import compatibility