@devries-cameron20 / t3code Mirror · read-only / commits / 5bd2d0cb82
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 13:30 UTC

fix(client-runtime): derive MCP download names before URI suffixes (#30712)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Johan Vaz committed Nov 15, 2026 at 07:55 UTC 5bd2d0cb82a1fb40cda9bd84561daa2b8227e972
2 files changed +20 -1
packages/client-runtime/src/mcpApps/host.test.ts
+19
@@ -387,5 +387,24 @@ describe("makeMcpAppHost", () => {
387 expect(sent.find((m) => m.id === 2)?.result).toEqual({});
388 expect(sent.find((m) => m.id === 3)?.result).toEqual({ isError: true });
389 expect(sent.find((m) => m.id === 4)?.error).toMatchObject({ code: -32602 });
390 +
391 + const unnamedUris = [
392 + "https://example.invalid/report.csv?version=2",
393 + "https://example.invalid/report.csv#page=2",
394 + "https://example.invalid/report.csv?next=/noise.json#page=3",
395 + ];
396 + for (const [index, uri] of unnamedUris.entries()) {
397 + const id = `download-${index}`;
398 + const downloadIndex = downloads.length;
399 + host.receive({
400 + jsonrpc: "2.0",
401 + id,
402 + method: "ui/download-file",
403 + params: { contents: [{ ...embedded, resource: { ...embedded.resource, uri } }] },
404 + });
405 + await flush();
406 + expect(downloads[downloadIndex]?.[0]).toMatchObject({ _tag: "embedded", name: "report.csv" });
407 + expect(sent.find((m) => m.id === id)?.result).toEqual({});
408 + }
409 });
410 });
packages/client-runtime/src/mcpApps/host.ts
+1 -1
@@ -480,7 +480,7 @@ function downloadName(uri: unknown, name: unknown): string {
480 typeof name === "string" && name.trim() !== ""
481 ? name
482 : typeof uri === "string"
483 - ? (uri.split(/[/?#]/).findLast(Boolean) ?? "download")
483 + ? (uri.split(/[?#]/, 1)[0]?.split("/").findLast(Boolean) ?? "download")
484 : "download";
485 let safe = "";
486 for (const char of raw) {