mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-29 04:32:57 +00:00
* Add WebStorm editor target * Fix rebase type errors and add TODO date tag - Await listAvailableEditorTargets() which became async on main - Wrap sendAgentMessage callback to match Promise<void> return type - Add TODO(2026-07) date to legacy editor target ids comment --------- Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
187 lines
5.4 KiB
TypeScript
187 lines
5.4 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
import { SessionInboundMessageSchema, SessionOutboundMessageSchema } from "./messages.js";
|
|
|
|
describe("workspace message schemas", () => {
|
|
test("parses fetch_workspaces_request", () => {
|
|
const parsed = SessionInboundMessageSchema.parse({
|
|
type: "fetch_workspaces_request",
|
|
requestId: "req-1",
|
|
filter: {
|
|
query: "repo",
|
|
projectId: "remote:github.com/acme/repo",
|
|
idPrefix: "/Users/me",
|
|
},
|
|
sort: [{ key: "activity_at", direction: "desc" }],
|
|
page: { limit: 50 },
|
|
subscribe: {},
|
|
});
|
|
|
|
expect(parsed.type).toBe("fetch_workspaces_request");
|
|
});
|
|
|
|
test("parses open_project_request", () => {
|
|
const parsed = SessionInboundMessageSchema.parse({
|
|
type: "open_project_request",
|
|
cwd: "/tmp/repo",
|
|
requestId: "req-open",
|
|
});
|
|
|
|
expect(parsed.type).toBe("open_project_request");
|
|
});
|
|
|
|
test("parses list_available_editors_request", () => {
|
|
const parsed = SessionInboundMessageSchema.parse({
|
|
type: "list_available_editors_request",
|
|
requestId: "req-editors",
|
|
});
|
|
|
|
expect(parsed.type).toBe("list_available_editors_request");
|
|
});
|
|
|
|
test("parses open_in_editor_request with flexible editor ids", () => {
|
|
const knownEditor = SessionInboundMessageSchema.parse({
|
|
type: "open_in_editor_request",
|
|
requestId: "req-open-webstorm",
|
|
editorId: "webstorm",
|
|
path: "/tmp/repo",
|
|
});
|
|
const unknownEditor = SessionInboundMessageSchema.parse({
|
|
type: "open_in_editor_request",
|
|
requestId: "req-open-custom",
|
|
editorId: "unknown-editor",
|
|
path: "/tmp/repo",
|
|
});
|
|
|
|
expect(knownEditor.type).toBe("open_in_editor_request");
|
|
expect(unknownEditor.type).toBe("open_in_editor_request");
|
|
});
|
|
|
|
test("parses open_in_editor_response", () => {
|
|
const parsed = SessionOutboundMessageSchema.parse({
|
|
type: "open_in_editor_response",
|
|
payload: {
|
|
requestId: "req-open-editor",
|
|
error: null,
|
|
},
|
|
});
|
|
|
|
expect(parsed.type).toBe("open_in_editor_response");
|
|
});
|
|
|
|
test("parses list_available_editors_response with unknown editor ids", () => {
|
|
const parsed = SessionOutboundMessageSchema.parse({
|
|
type: "list_available_editors_response",
|
|
payload: {
|
|
requestId: "req-editors",
|
|
editors: [
|
|
{ id: "cursor", label: "Cursor" },
|
|
{ id: "unknown-editor", label: "Unknown Editor" },
|
|
],
|
|
error: null,
|
|
},
|
|
});
|
|
|
|
expect(parsed.type).toBe("list_available_editors_response");
|
|
});
|
|
|
|
test("rejects empty editor ids", () => {
|
|
const result = SessionInboundMessageSchema.safeParse({
|
|
type: "open_in_editor_request",
|
|
requestId: "req-open-empty",
|
|
editorId: "",
|
|
path: "/tmp/repo",
|
|
});
|
|
|
|
expect(result.success).toBe(false);
|
|
});
|
|
|
|
test("rejects invalid workspace update payload", () => {
|
|
const result = SessionOutboundMessageSchema.safeParse({
|
|
type: "workspace_update",
|
|
payload: {
|
|
kind: "upsert",
|
|
workspace: {
|
|
id: "/repo",
|
|
projectId: "/repo",
|
|
projectDisplayName: "repo",
|
|
projectRootPath: "/repo",
|
|
projectKind: "non_git",
|
|
workspaceKind: "directory",
|
|
name: "",
|
|
status: "not-a-bucket",
|
|
activityAt: null,
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(result.success).toBe(false);
|
|
});
|
|
|
|
test("parses legacy fetch_agents_response checkout payloads without worktreeRoot", () => {
|
|
const result = SessionOutboundMessageSchema.safeParse({
|
|
type: "fetch_agents_response",
|
|
payload: {
|
|
requestId: "req-1",
|
|
entries: [
|
|
{
|
|
agent: {
|
|
id: "agent-1",
|
|
provider: "codex",
|
|
cwd: "C:\\repo",
|
|
model: null,
|
|
features: [],
|
|
thinkingOptionId: null,
|
|
effectiveThinkingOptionId: null,
|
|
createdAt: "2026-04-04T00:00:00.000Z",
|
|
updatedAt: "2026-04-04T00:00:00.000Z",
|
|
lastUserMessageAt: null,
|
|
status: "running",
|
|
capabilities: {
|
|
supportsStreaming: true,
|
|
supportsSessionPersistence: true,
|
|
supportsDynamicModes: true,
|
|
supportsMcpServers: true,
|
|
supportsReasoningStream: true,
|
|
supportsToolInvocations: true,
|
|
},
|
|
currentModeId: null,
|
|
availableModes: [],
|
|
pendingPermissions: [],
|
|
persistence: null,
|
|
title: "Agent 1",
|
|
labels: {},
|
|
requiresAttention: false,
|
|
attentionReason: null,
|
|
},
|
|
project: {
|
|
projectKey: "remote:github.com/acme/repo",
|
|
projectName: "acme/repo",
|
|
checkout: {
|
|
cwd: "C:\\repo",
|
|
isGit: true,
|
|
currentBranch: "main",
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
isPaseoOwnedWorktree: false,
|
|
mainRepoRoot: null,
|
|
},
|
|
},
|
|
},
|
|
],
|
|
pageInfo: {
|
|
nextCursor: null,
|
|
prevCursor: null,
|
|
hasMore: false,
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(result.success).toBe(true);
|
|
if (!result.success) {
|
|
return;
|
|
}
|
|
|
|
const checkout = result.data.payload.entries[0]?.project.checkout;
|
|
expect(checkout?.worktreeRoot).toBe("C:\\repo");
|
|
});
|
|
});
|