mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-31 09:25:32 +08: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',
|
'[Request interrupted',
|
||||||
] as const;
|
] 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 {
|
function normalizeComparablePath(inputPath: string): string {
|
||||||
if (!inputPath || typeof inputPath !== 'string') {
|
if (!inputPath || typeof inputPath !== 'string') {
|
||||||
return '';
|
return '';
|
||||||
@@ -156,6 +165,11 @@ function isInternalContent(content: string): boolean {
|
|||||||
return INTERNAL_CONTENT_PREFIXES.some((prefix) => content.startsWith(prefix));
|
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 {
|
function escapeRegex(value: string): string {
|
||||||
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
}
|
}
|
||||||
@@ -807,7 +821,6 @@ async function parseCodexSessionMatches(
|
|||||||
if (entry.type === 'event_msg' && isVisibleCodexUserMessage(entry.payload as AnyRecord)) {
|
if (entry.type === 'event_msg' && isVisibleCodexUserMessage(entry.payload as AnyRecord)) {
|
||||||
text = String(entry.payload.message);
|
text = String(entry.payload.message);
|
||||||
role = 'user';
|
role = 'user';
|
||||||
latestUserMessageText = text;
|
|
||||||
} else if (
|
} else if (
|
||||||
entry.type === 'event_msg'
|
entry.type === 'event_msg'
|
||||||
&& entry.payload?.type === 'agent_reasoning'
|
&& entry.payload?.type === 'agent_reasoning'
|
||||||
@@ -820,9 +833,6 @@ async function parseCodexSessionMatches(
|
|||||||
if (payload.role === 'user') {
|
if (payload.role === 'user') {
|
||||||
text = extractCodexText(payload.content);
|
text = extractCodexText(payload.content);
|
||||||
role = 'user';
|
role = 'user';
|
||||||
if (text) {
|
|
||||||
latestUserMessageText = text;
|
|
||||||
}
|
|
||||||
} else if (payload.role === 'assistant') {
|
} else if (payload.role === 'assistant') {
|
||||||
text = extractCodexText(payload.content);
|
text = extractCodexText(payload.content);
|
||||||
role = 'assistant';
|
role = 'assistant';
|
||||||
@@ -844,6 +854,12 @@ async function parseCodexSessionMatches(
|
|||||||
if (!text || !role) {
|
if (!text || !role) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (isInternalCodexContent(text)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (role === 'user') {
|
||||||
|
latestUserMessageText = text;
|
||||||
|
}
|
||||||
|
|
||||||
const fingerprint = `${role}:${text.trim().toLowerCase()}`;
|
const fingerprint = `${role}:${text.trim().toLowerCase()}`;
|
||||||
if (seenMessageFingerprints.has(fingerprint)) {
|
if (seenMessageFingerprints.has(fingerprint)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user