Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions crates/toolpath-desktop/frontend/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions crates/toolpath-desktop/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"check": "svelte-check --tsconfig ./tsconfig.json"
"check": "svelte-check --tsconfig ./tsconfig.json",
"test": "vitest run",
"test:watch": "vitest"
},
"dependencies": {
"@tauri-apps/api": "^2",
Expand All @@ -22,6 +24,7 @@
"svelte": "^5",
"svelte-check": "^4",
"typescript": "^5",
"vite": "^6"
"vite": "^6",
"vitest": "^4.1.5"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { describe, expect, it } from "vitest";
import { classify, readStructural } from "../classify";
import type { StepRef } from "../types";

// Minimal StepRef fixture — only the fields classify/readStructural read.
// `structural` is the flattened wire shape (see StructuralChange in Rust:
// `#[serde(rename = "type")]` on the tag + `#[serde(flatten)]` on extra).
function stepWith(structural: Record<string, unknown>): StepRef {
return {
step: { id: "s", actor: "agent:claude-code" },
change: { "convo://turn": { structural } },
};
}

describe("classify", () => {
it("returns 'user' for a conversation.append with role=user", () => {
const s = stepWith({ type: "conversation.append", role: "user", text: "hi" });
expect(classify(s).kind).toBe("user");
});

it("returns 'assistant' for a conversation.append with role=assistant", () => {
const s = stepWith({
type: "conversation.append",
role: "assistant",
text: "hello",
});
expect(classify(s).kind).toBe("assistant");
});

it("returns 'tool' for tool.invoke", () => {
const s = stepWith({ type: "tool.invoke", name: "Edit" });
const c = classify(s);
expect(c.kind).toBe("tool");
expect(c.toolName).toBe("Edit");
});

it("returns 'system' for unknown types", () => {
const s = stepWith({ type: "conversation.init", model: "claude-opus-4-7" });
expect(classify(s).kind).toBe("system");
});
});

describe("readStructural", () => {
it("prefers a tool.invoke payload over a non-conversation sibling artifact", () => {
// Claude multi-artifact case: a tool.invoke step also writes a file
// artifact whose `structural` is something unrelated (not in the
// CONVERSATION_TYPES set). readStructural should pick the tool.invoke.
const step: StepRef = {
step: { id: "s", actor: "agent:claude-code" },
change: {
"file:///tmp/out.txt": {
structural: { type: "file.write", bytes: 42 },
},
"tool://Edit": {
structural: { type: "tool.invoke", name: "Edit" },
},
},
};
const s = readStructural(step);
expect(s?.type).toBe("tool.invoke");
expect(s?.name).toBe("Edit");
});
});
Loading
Loading