mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-01 10:18:37 +00:00
refactor: add handling for internal Codex metadata in conversation search
This commit is contained in:
@@ -100,6 +100,15 @@ const INTERNAL_CONTENT_PREFIXES = [
|
||||
'[Request interrupted',
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Codex includes extra internal metadata tags that should not surface as
|
||||
* user-facing searchable conversation content.
|
||||
*/
|
||||
const CODEX_INTERNAL_CONTENT_PREFIXES = [
|
||||
'<environment_context>',
|
||||
'<cwd>',
|
||||
] as const;
|
||||
|
||||
function normalizeComparablePath(inputPath: string): string {
|
||||
if (!inputPath || typeof inputPath !== 'string') {
|
||||
return '';
|
||||
@@ -156,6 +165,11 @@ function isInternalContent(content: string): boolean {
|
||||
return INTERNAL_CONTENT_PREFIXES.some((prefix) => content.startsWith(prefix));
|
||||
}
|
||||
|
||||
function isInternalCodexContent(content: string): boolean {
|
||||
const normalized = content.trimStart();
|
||||
return CODEX_INTERNAL_CONTENT_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
||||
}
|
||||
|
||||
function escapeRegex(value: string): string {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
@@ -807,7 +821,6 @@ async function parseCodexSessionMatches(
|
||||
if (entry.type === 'event_msg' && isVisibleCodexUserMessage(entry.payload as AnyRecord)) {
|
||||
text = String(entry.payload.message);
|
||||
role = 'user';
|
||||
latestUserMessageText = text;
|
||||
} else if (
|
||||
entry.type === 'event_msg'
|
||||
&& entry.payload?.type === 'agent_reasoning'
|
||||
@@ -820,9 +833,6 @@ async function parseCodexSessionMatches(
|
||||
if (payload.role === 'user') {
|
||||
text = extractCodexText(payload.content);
|
||||
role = 'user';
|
||||
if (text) {
|
||||
latestUserMessageText = text;
|
||||
}
|
||||
} else if (payload.role === 'assistant') {
|
||||
text = extractCodexText(payload.content);
|
||||
role = 'assistant';
|
||||
@@ -844,6 +854,12 @@ async function parseCodexSessionMatches(
|
||||
if (!text || !role) {
|
||||
continue;
|
||||
}
|
||||
if (isInternalCodexContent(text)) {
|
||||
continue;
|
||||
}
|
||||
if (role === 'user') {
|
||||
latestUserMessageText = text;
|
||||
}
|
||||
|
||||
const fingerprint = `${role}:${text.trim().toLowerCase()}`;
|
||||
if (seenMessageFingerprints.has(fingerprint)) {
|
||||
|
||||
Reference in New Issue
Block a user