|
9 | 9 | reasoningReplayConversationIdFromResponsesRequest, |
10 | 10 | sessionIdHeaderFromRequest, |
11 | 11 | summarizeConversationLogs, |
| 12 | + unwrapLogConversationQuery, |
12 | 13 | } from "../../src/server/request-log-conversation"; |
13 | 14 | import { |
14 | 15 | filterRequestLogs, |
@@ -71,6 +72,29 @@ describe("matchesLogConversationId", () => { |
71 | 72 | expect(matchesLogConversationId(stored, "codex://other/x")).toBe(false); |
72 | 73 | expect(matchesLogConversationId(stored, "codex://threads/")).toBe(false); |
73 | 74 | }); |
| 75 | + |
| 76 | + test("unwraps codex://threads links carrying query or fragment metadata", () => { |
| 77 | + const threadId = "019f6482-67d5-77c2-a643-02daddaa7115"; |
| 78 | + const stored = digest32(threadId); |
| 79 | + for (const paste of [ |
| 80 | + `codex://threads/${threadId}?hostId=durable`, |
| 81 | + `codex://threads/${threadId}?hostId=remote-control%3Aexample-environment`, |
| 82 | + `codex://threads/${threadId}/?hostId=durable&view=full`, |
| 83 | + `codex://threads/${threadId}#section`, |
| 84 | + ]) { |
| 85 | + expect(matchesLogConversationId(stored, paste)).toBe(true); |
| 86 | + expect(matchesLogConversationId(threadId, paste)).toBe(true); |
| 87 | + } |
| 88 | + }); |
| 89 | + |
| 90 | + test("rejects malformed or oversized codex://threads pastes without backtracking", () => { |
| 91 | + const stored = digest32("019f6482-67d5-77c2-a643-02daddaa7115"); |
| 92 | + const slashFlood = `codex://threads/${"/".repeat(4000)}\u2028x`; |
| 93 | + expect(unwrapLogConversationQuery(slashFlood)).toBe(slashFlood.trim()); |
| 94 | + expect(matchesLogConversationId(stored, slashFlood)).toBe(false); |
| 95 | + expect(matchesLogConversationId(stored, "codex://threads/id/extra")).toBe(false); |
| 96 | + expect(matchesLogConversationId(stored, `codex://threads/${"a".repeat(600)}`)).toBe(false); |
| 97 | + }); |
74 | 98 | }); |
75 | 99 |
|
76 | 100 | describe("sessionIdHeaderFromRequest", () => { |
@@ -211,6 +235,12 @@ describe("request log conversation persistence / filter", () => { |
211 | 235 | ]; |
212 | 236 | const params = new URLSearchParams(`conversationId=${encodeURIComponent(`codex://threads/${threadId}`)}`); |
213 | 237 | expect(filterRequestLogs(logs, params).map(e => e.requestId)).toEqual(["a"]); |
| 238 | + for (const hostId of ["durable", "remote-control%3Aexample-environment"]) { |
| 239 | + const withHost = new URLSearchParams( |
| 240 | + `conversationId=${encodeURIComponent(`codex://threads/${threadId}?hostId=${hostId}`)}`, |
| 241 | + ); |
| 242 | + expect(filterRequestLogs(logs, withHost).map(e => e.requestId)).toEqual(["a"]); |
| 243 | + } |
214 | 244 | }); |
215 | 245 |
|
216 | 246 | test("hydrated usage rows keep conversationId", () => { |
|
0 commit comments