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, 04:45 UTC
| 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | |
| 3 | import { extractToolActivityPresentation } from "./toolPresentation.ts"; |
| 4 | |
| 5 | describe("extractToolActivityPresentation", () => { |
| 6 | it("recovers computer-use presentation for retained calls without result metadata", () => { |
| 7 | const item = { |
| 8 | type: "dynamic_tool", |
| 9 | toolName: "js", |
| 10 | input: { code: "await sky.get_app_state(app);" }, |
| 11 | }; |
| 12 | expect(extractToolActivityPresentation(item)).toEqual({ |
| 13 | toolSurface: "computer", |
| 14 | toolSource: { key: "computer-use", name: "Computer Use", kind: "computer" }, |
| 15 | }); |
| 16 | expect(extractToolActivityPresentation({ ...item, toolSurface: "browser" })).toEqual({ |
| 17 | toolSurface: "browser", |
| 18 | }); |
| 19 | expect( |
| 20 | extractToolActivityPresentation({ ...item, input: { code: "await fs.readFile(path);" } }), |
| 21 | ).toEqual({}); |
| 22 | }); |
| 23 | |
| 24 | it("replaces a failed Sky call's generic node REPL source", () => { |
| 25 | const source = { key: "mcp:node_repl", name: "node repl", kind: "integration" }; |
| 26 | const item = { |
| 27 | type: "dynamic_tool", |
| 28 | toolName: "node_repl.js", |
| 29 | title: "js", |
| 30 | status: "failed", |
| 31 | toolSource: source, |
| 32 | input: { |
| 33 | title: "Restrict the breakpoint to Git actions", |
| 34 | code: "await sky.type_text({app:'T3 Code (Nightly)',text:'debug(ga.run)'});", |
| 35 | }, |
| 36 | }; |
| 37 | expect(extractToolActivityPresentation(item)).toEqual({ |
| 38 | toolSurface: "computer", |
| 39 | toolSource: { key: "computer-use", name: "Computer Use", kind: "computer" }, |
| 40 | }); |
| 41 | expect( |
| 42 | extractToolActivityPresentation({ |
| 43 | ...item, |
| 44 | input: { code: "await fetch('http://127.0.0.1/json/list');" }, |
| 45 | }), |
| 46 | ).toEqual({ toolSource: source }); |
| 47 | }); |
| 48 | |
| 49 | it("retains valid image paths independently of redacted output", () => { |
| 50 | expect( |
| 51 | extractToolActivityPresentation({ viewedImagePath: " /workspace/reference.webp " }), |
| 52 | ).toEqual({ viewedImagePath: "/workspace/reference.webp" }); |
| 53 | for (const viewedImagePath of [ |
| 54 | "/workspace/README.md", |
| 55 | "/workspace/a.png\nother", |
| 56 | "x".repeat(4097) + ".png", |
| 57 | ]) |
| 58 | expect(extractToolActivityPresentation({ viewedImagePath })).toEqual({}); |
| 59 | }); |
| 60 | |
| 61 | it("does not infer presentation from provider-specific payload data", () => { |
| 62 | expect( |
| 63 | extractToolActivityPresentation({ |
| 64 | data: { |
| 65 | item: { |
| 66 | arguments: { code: 'await sky.click({ app: "Finder" })' }, |
| 67 | result: { |
| 68 | _meta: { |
| 69 | "codex/toolSurface": { |
| 70 | kind: "computerUse", |
| 71 | app: { kind: "displayName", displayName: "Finder" }, |
| 72 | }, |
| 73 | }, |
| 74 | }, |
| 75 | }, |
| 76 | }, |
| 77 | }), |
| 78 | ).toEqual({}); |
| 79 | }); |
| 80 | }); |