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
47 changes: 35 additions & 12 deletions plugins/provider-pi/src/bridge/bridge.lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,39 @@ async function startThread(threadId: string): Promise<void> {
expect(response.result).toMatchObject({ providerThreadId: threadId });
}

it("stop{release} ends the child", async () => {
await startThread("thr_lc_release");
await harness.request((nextId += 1), "turn/start", {
threadId: "thr_lc_release",
providerThreadId: "thr_lc_release",
it("stop{release} ends the child after a local-file-only turn", async () => {
const threadId = "thr_lc_release";
const filePath = join(harness.workspaceDir, "notes.md");
await startThread(threadId);
const turn = await harness.request((nextId += 1), "turn/start", {
threadId,
providerThreadId: threadId,
clientRequestId: "creq_ab23456789",
input: [{ type: "text", text: "hello", mentions: [] }],
input: [
{
type: "localFile",
path: filePath,
name: "notes.md",
sizeBytes: 6,
mimeType: "text/markdown",
},
],
options: FULL_PERMISSION_OPTIONS,
});
await harness.waitForTurnBoundary("thr_lc_release", 0);
expect(turn.result).toEqual({ threadId });
await harness.waitForTurnBoundary(threadId, 0);
expect(
harness
.deltasOf(threadId)
.some(
(delta) =>
delta.kind === "item.textDelta" &&
String(delta.text).includes(`[Attached file: ${filePath}]`),
),
).toBe(true);
const stop = await harness.request((nextId += 1), "thread/stop", {
threadId: "thr_lc_release",
providerThreadId: "thr_lc_release",
threadId,
providerThreadId: threadId,
intent: "release",
activeTurnId: null,
});
Expand Down Expand Up @@ -238,9 +258,12 @@ it("accepts a prompt containing only a local image", async () => {
expect(response.result).toEqual({ threadId });
await harness.waitForTurnBoundary(threadId);
expect(
harness.deltasOf(threadId).some(
(delta) => delta.kind === "item.textDelta" && delta.text === "Response to: ",
),
harness
.deltasOf(threadId)
.some(
(delta) =>
delta.kind === "item.textDelta" && delta.text === "Response to: ",
),
).toBe(true);
});

Expand Down
111 changes: 0 additions & 111 deletions plugins/provider-pi/src/bridge/bridge.local-file.test.ts

This file was deleted.

22 changes: 16 additions & 6 deletions plugins/provider-pi/src/bridge/bridge.round2.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import {
existsSync,
mkdirSync,
mkdtempSync,
rmSync,
writeFileSync,
} from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
Expand Down Expand Up @@ -160,6 +166,7 @@ it("refuses a manual compaction while pi reports a run still streaming", async (

it("a steer consumed by the run is reported accepted and named in the reply", async () => {
const threadId = "thr_r2_steer_ok";
const filePath = join(harness.workspaceDir, "notes.md");
await harness.startThread(threadId);
turnStart(threadId, "/hold", "creq_ab23456789");
await harness.waitForDelta(threadId, (d) => d.kind === "turn.open");
Expand All @@ -168,7 +175,10 @@ it("a steer consumed by the run is reported accepted and named in the reply", as
providerThreadId: threadId,
expectedTurnId: "turn-1",
clientRequestId: "creq_cd23456789",
input: [{ type: "text", text: "take the left path", mentions: [] }],
input: [
{ type: "text", text: "take the left path", mentions: [] },
{ type: "localFile", path: filePath },
],
options: FULL_PERMISSION_OPTIONS,
});
expect(steer.result).toMatchObject({ threadId });
Expand All @@ -188,7 +198,9 @@ it("a steer consumed by the run is reported accepted and named in the reply", as
.some(
(d) =>
d.kind === "item.textDelta" &&
String(d.text).includes("Steered: take the left path"),
String(d.text).includes(
`Steered: take the left path\n[Attached file: ${filePath}]`,
),
),
).toBe(true);
expect(harness.messages.some((m) => m.method === "error")).toBe(false);
Expand Down Expand Up @@ -428,9 +440,7 @@ it("resumes at bb's requested cwd when the session header's cwd was removed", as

turnStart(threadId, '/tool bash {"command":"pwd"}', "creq_rsm2345678");
await harness.waitForDelta(threadId, (d) => d.kind === "item.close");
const opened = harness
.deltasOf(threadId)
.find((d) => d.kind === "item.open");
const opened = harness.deltasOf(threadId).find((d) => d.kind === "item.open");
expect(opened?.item).toMatchObject({
type: "command",
command: "pwd",
Expand Down
20 changes: 20 additions & 0 deletions plugins/provider-pi/src/bridge/turn-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ function extractText(input: PromptInput[]): string | undefined {
return extractPiPromptInput(input).text;
}

it("preserves local file paths with and without text", () => {
const path = "/workspace/notes.md";
const marker = `[Attached file: ${path}]`;
const file = {
type: "localFile" as const,
path,
name: "notes.md",
sizeBytes: 6,
mimeType: "text/markdown",
};

expect(
extractText([
{ type: "text", text: "Read this file.", mentions: [] },
file,
]),
).toBe(`Read this file.\n${marker}`);
expect(extractText([file])).toBe(marker);
});

it("invokes a selected skill through Pi's native command", () => {
expect(
extractText([
Expand Down
Loading