From 5a44e2c0ad891c21652710cd187943de913dfd5f Mon Sep 17 00:00:00 2001 From: Supra4E8C Date: Sat, 21 Feb 2026 19:43:16 +0800 Subject: [PATCH] type(scope): feat(logs): restrict request trace to supported endpoints --- src/pages/LogsPage.tsx | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/pages/LogsPage.tsx b/src/pages/LogsPage.tsx index a93d19f..68a818f 100644 --- a/src/pages/LogsPage.tsx +++ b/src/pages/LogsPage.tsx @@ -187,6 +187,22 @@ const normalizeTracePath = (value?: string) => .split('?')[0] .trim(); +const TRACEABLE_EXACT_PATHS = new Set(['/v1/chat/completions', '/v1/messages', '/v1/responses']); +const TRACEABLE_PREFIX_PATHS = ['/v1beta/models']; + +const normalizeTraceablePath = (value?: string): string => { + const normalized = normalizeTracePath(value); + if (!normalized || normalized === '/') return normalized; + return normalized.replace(/\/+$/, ''); +}; + +const isTraceableRequestPath = (value?: string): boolean => { + const normalizedPath = normalizeTraceablePath(value); + if (!normalizedPath) return false; + if (TRACEABLE_EXACT_PATHS.has(normalizedPath)) return true; + return TRACEABLE_PREFIX_PATHS.some((prefix) => normalizedPath.startsWith(prefix)); +}; + const scoreTraceCandidate = ( line: ParsedLogLine, detail: UsageDetailWithEndpoint @@ -1146,6 +1162,7 @@ export function LogsPage() { }; const openTraceModal = (line: ParsedLogLine) => { + if (!isTraceableRequestPath(line.path)) return; cancelLongPress(); setTraceLogLine(line); void loadTraceUsageDetails(); @@ -1432,6 +1449,7 @@ export function LogsPage() { ) : (
{parsedVisibleLines.map((line, index) => { + const canTraceRequest = isTraceableRequestPath(line.path); const rowClassNames = [styles.logRow]; if (line.level === 'warn') rowClassNames.push(styles.rowWarn); if (line.level === 'error' || line.level === 'fatal') @@ -1523,17 +1541,19 @@ export function LogsPage() { {line.message && {line.message}} - + {canTraceRequest && ( + + )}
);