Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(desktop): trust Pi task folders (#90900)

Jonathan Mieloode06809982a0
diff --git a/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-rpc-client-factory.test.ts b/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-rpc-client-factory.test.ts
index 2b7c42f62254..4a4ae14966cc 100644
--- a/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-rpc-client-factory.test.ts
+++ b/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-rpc-client-factory.test.ts
@@ -95,7 +95,6 @@ describe("DesktopPiRpcClientFactory", () => {
additionalDirectories: ["/tmp/shared"],
channelMode: true,
},
- projectTrusted: true,
}),
).resolves.toBe(client);
expect(authProxy.start).toHaveBeenCalledWith(
@@ -125,7 +124,6 @@ describe("DesktopPiRpcClientFactory", () => {
url: "http://127.0.0.1:4321/posthog",
},
},
- projectTrusted: true,
taskContext: {
projectId: 1,
apiHost: "https://eu.posthog.com",
diff --git a/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-rpc-client-factory.ts b/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-rpc-client-factory.ts
index 9199774dd7fd..82524d747040 100644
--- a/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-rpc-client-factory.ts
+++ b/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-rpc-client-factory.ts
@@ -73,7 +73,6 @@ export class DesktopPiRpcClientFactory implements PiRpcClientFactory {
return createPiRpcClient({
model: input.model,
sessionFile: input.sessionFile,
- projectTrusted: input.projectTrusted,
taskContext,
enrichment: {
apiUrl: enrichmentApiUrl,
diff --git a/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-runtime-factory.test.ts b/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-runtime-factory.test.ts
index 51a4c220871c..04b404e008c8 100644
--- a/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-runtime-factory.test.ts
+++ b/products/desktop/apps/code/src/main/platform-adapters/desktop-pi-runtime-factory.test.ts
@@ -13,14 +13,12 @@ describe("DesktopPiRuntimeFactory", () => {
const runtime = await factory.create({
taskContext: { taskId: "task-1", cwd: "/workspace" },
- projectTrusted: true,
});
expect(runtime).toBeInstanceOf(PiRuntime);
expect(runtime.client).toBe(client);
expect(clientFactory.create).toHaveBeenCalledWith({
taskContext: { taskId: "task-1", cwd: "/workspace" },
- projectTrusted: true,
});
});
});
diff --git a/products/desktop/apps/code/tests/e2e/tests/pi-enrichment.spec.ts b/products/desktop/apps/code/tests/e2e/tests/pi-enrichment.spec.ts
index 93ea0bd3020c..ec7414b527ad 100644
--- a/products/desktop/apps/code/tests/e2e/tests/pi-enrichment.spec.ts
+++ b/products/desktop/apps/code/tests/e2e/tests/pi-enrichment.spec.ts
@@ -230,7 +230,6 @@ test.describe("Pi enrichment", () => {
environment: "local",
},
model: "claude-haiku-4-5",
- projectTrusted: false,
providerOptions: { apiKey: "gateway-test-key", baseUrl },
enrichment: {
apiUrl: baseUrl,
diff --git a/products/desktop/apps/code/tests/e2e/tests/pi-extension.spec.ts b/products/desktop/apps/code/tests/e2e/tests/pi-extension.spec.ts
index f1ac200b89f4..ca70e53c50be 100644
--- a/products/desktop/apps/code/tests/e2e/tests/pi-extension.spec.ts
+++ b/products/desktop/apps/code/tests/e2e/tests/pi-extension.spec.ts
@@ -35,7 +35,7 @@ const HOME_ENVIRONMENT_KEYS = [
] as const;
test.describe("Pi extensions", () => {
- test("loads a real extension and completes its UI round trip", async ({
+ test("loads a project extension and completes its UI round trip", async ({
electronApp,
}) => {
const { e2eHome, resourcesPath } = await electronApp.evaluate(
@@ -53,12 +53,8 @@ test.describe("Pi extensions", () => {
);
expect(existsSync(rpcHostPath)).toBe(true);
- const extensionsDirectory = path.join(
- e2eHome,
- ".pi",
- "agent",
- "extensions",
- );
+ const workspace = path.join(e2eHome, "extension-workspace");
+ const extensionsDirectory = path.join(workspace, ".pi", "extensions");
await mkdir(extensionsDirectory, { recursive: true });
await writeFile(
path.join(extensionsDirectory, "extension-e2e.ts"),
@@ -83,12 +79,11 @@ test.describe("Pi extensions", () => {
cliPath: rpcHostPath,
taskContext: {
taskId: "pi-extension-e2e",
- cwd: e2eHome,
+ cwd: workspace,
projectId: 1,
apiHost: "https://us.posthog.com",
environment: "local",
},
- projectTrusted: false,
providerOptions: { apiKey: "unused-e2e-key" },
});
client.onEvent((event) => {
diff --git a/products/desktop/packages/agent/src/pi/rpc-client.test.ts b/products/desktop/packages/agent/src/pi/rpc-client.test.ts
index 7fe22123f77f..66d75194e557 100644
--- a/products/desktop/packages/agent/src/pi/rpc-client.test.ts
+++ b/products/desktop/packages/agent/src/pi/rpc-client.test.ts
@@ -133,57 +133,6 @@ describe("createPiRpcClient", () => {
).toBeUndefined();
});
- it("passes repository trust over the private bootstrap pipe", async () => {
- const directory = await mkdtemp(join(tmpdir(), "pi-project-trust-"));
- const hostPath = join(directory, "host.mjs");
- const capturePath = join(directory, "bootstrap.json");
- await writeFile(
- hostPath,
- `
-import { readFileSync, writeFileSync } from "node:fs";
-
-writeFileSync(${JSON.stringify(capturePath)}, readFileSync(3, "utf8"));
-process.stdin.resume();
-`,
- );
- const client = createPiRpcClient({
- cliPath: hostPath,
- taskContext: taskContext(directory),
- projectTrusted: true,
- extensions: ["auto-publish"],
- providerOptions: { apiKey: "proxy-key" },
- enrichment: {
- apiUrl: "http://127.0.0.1:5678",
- publicApiUrl: "https://us.posthog.com",
- projectId: 2,
- apiKey: "enrichment-proxy-key",
- },
- });
-
- try {
- await client.start();
- await vi.waitFor(async () => {
- await expect(readFile(capturePath, "utf8")).resolves.toBe(
- JSON.stringify({
- providerOptions: { apiKey: "proxy-key" },
- enrichment: {
- apiUrl: "http://127.0.0.1:5678",
- publicApiUrl: "https://us.posthog.com",
- projectId: 2,
- apiKey: "enrichment-proxy-key",
- },
- projectTrusted: true,
- taskContext: taskContext(directory),
- extensions: ["auto-publish"],
- }),
- );
- });
- } finally {
- await client.stop();
- await rm(directory, { recursive: true });
- }
- });
-
it("passes requested extensions privately and enables Electron's Node mode", async () => {
const directory = await mkdtemp(join(tmpdir(), "pi-electron-node-mode-"));
const hostPath = join(directory, "host.mjs");
diff --git a/products/desktop/packages/agent/src/pi/rpc-client.ts b/products/desktop/packages/agent/src/pi/rpc-client.ts
index 714503045a76..9d956fa916e5 100644
--- a/products/desktop/packages/agent/src/pi/rpc-client.ts
+++ b/products/desktop/packages/agent/src/pi/rpc-client.ts
@@ -59,7 +59,6 @@ export interface PiRpcBootstrap {
enrichment?: PiEnrichmentConfig;
runtimeMcpServers?: PiRuntimeMcpServers;
mcpToolPolicies?: McpToolPolicy[];
- projectTrusted?: boolean;
taskContext: TaskContext;
extensions?: PiRuntimeExtension[];
/** Local checkout of the org's context wiki, when one is mounted. */
@@ -444,7 +443,6 @@ export type PiRpcClientOptions = Pick<RpcClientOptions, "cliPath" | "model"> & {
enrichment?: PiEnrichmentConfig;
runtimeMcpServers?: PiRuntimeMcpServers;
mcpToolPolicies?: McpToolPolicy[];
- projectTrusted?: boolean;
taskContext: TaskContext;
extensions?: PiRuntimeExtension[];
contextWikiPath?: string;
@@ -457,7 +455,6 @@ export function createPiRpcClient(options: PiRpcClientOptions): PiRpcClient {
enrichment,
runtimeMcpServers,
mcpToolPolicies,
- projectTrusted,
taskContext,
extensions,
contextWikiPath,
@@ -480,7 +477,6 @@ export function createPiRpcClient(options: PiRpcClientOptions): PiRpcClient {
enrichment,
runtimeMcpServers,
mcpToolPolicies,
- projectTrusted: projectTrusted ?? false,
taskContext,
extensions,
contextWikiPath,
diff --git a/products/desktop/packages/agent/src/pi/rpc-host.ts b/products/desktop/packages/agent/src/pi/rpc-host.ts
index 9f0c68c53733..087d4053267f 100644
--- a/products/desktop/packages/agent/src/pi/rpc-host.ts
+++ b/products/desktop/packages/agent/src/pi/rpc-host.ts
@@ -5,7 +5,6 @@ import {
} from "@earendil-works/pi-coding-agent";
import { createHarnessRuntime, runRpcMode } from "@posthog/harness";
import { createAutoPublishExtension } from "@posthog/harness/extensions/auto-publish";
-import { createPiRuntimeTrustResolver } from "@posthog/harness/project-trust";
import type {
McpToolPermissionDecision,
McpToolPermissionRequest,
@@ -94,10 +93,7 @@ if (bootstrap.enrichment) {
const runtime = await createHarnessRuntime({
cwd,
sessionManager,
- projectTrusted: createPiRuntimeTrustResolver(
- cwd,
- bootstrap.projectTrusted ?? false,
- ),
+ projectTrusted: () => true,
resourceLoaderOptions: { extensionFactories: runtimeExtensions },
...providerOptions,
runtimeMcpServers: bootstrap.runtimeMcpServers,
diff --git a/products/desktop/packages/core/src/pi-runtime/piRunner.ts b/products/desktop/packages/core/src/pi-runtime/piRunner.ts
index af1e8ed60c98..cdf0e65086b7 100644
--- a/products/desktop/packages/core/src/pi-runtime/piRunner.ts
+++ b/products/desktop/packages/core/src/pi-runtime/piRunner.ts
@@ -3,7 +3,6 @@ import type { PiThinkingLevel } from "@posthog/agent/pi/types";
export interface PiRunInput {
taskContext: TaskContextInput;
- projectTrustPath?: string;
prompt: string;
model?: string;
thinkingLevel?: PiThinkingLevel;
@@ -11,7 +10,6 @@ export interface PiRunInput {
export interface PiResumeInput {
taskContext: Pick<TaskContextInput, "taskId" | "cwd">;
- projectTrustPath?: string;
}
export interface PiRunner {
diff --git a/products/desktop/packages/core/src/pi-runtime/piSessionController.test.ts b/products/desktop/packages/core/src/pi-runtime/piSessionController.test.ts
index 6215d46cdaf8..8306e6a6e18f 100644
--- a/products/desktop/packages/core/src/pi-runtime/piSessionController.test.ts
+++ b/products/desktop/packages/core/src/pi-runtime/piSessionController.test.ts
@@ -202,109 +202,6 @@ describe("PiSessionController", () => {
expect(client.getConversation).not.toHaveBeenCalled();
});
- it("loads repository trust and reconnects after changing it", async () => {
- let trusted = false;
- const session = createSession();
- session.getProjectTrust = vi.fn(async () => ({
- trusted,
- hasProjectResources: true,
- }));
- session.setProjectTrusted = vi.fn(async (nextTrusted) => {
- trusted = nextTrusted;
- });
- const controller = createController(session);
-
- await controller.connect("task-1");
- expect(controller.store.getState().sessions["task-1"].projectTrust).toEqual(
- {
- trusted: false,
- hasProjectResources: true,
- },
- );
- controller.store.setState((state) => ({
- sessions: {
- ...state.sessions,
- "task-1": {
- ...state.sessions["task-1"],
- queue: { steering: ["queued"], followUp: [] },
- },
- },
- }));
-
- await controller.setProjectTrusted("task-1", true);
-
- expect(session.setProjectTrusted).toHaveBeenCalledWith(true);
- expect(session.client.prompt).toHaveBeenCalledWith("queued");
- expect(controller.store.getState().sessions["task-1"].projectTrust).toEqual(
- {
- trusted: true,
- hasProjectResources: true,
- },
- );
- });
-
- it("shares an in-flight repository trust change and rejects an opposite toggle", async () => {
- let finishTransition: (() => void) | undefined;
- const session = createSession();
- session.setProjectTrusted = vi.fn(
- () =>
- new Promise<void>((resolve) => {
- finishTransition = resolve;
- }),
- );
- const controller = createController(session);
- await controller.connect("task-1");
-
- const first = controller.setProjectTrusted("task-1", true);
- const duplicate = controller.setProjectTrusted("task-1", true);
- await expect(controller.setProjectTrusted("task-1", false)).rejects.toThrow(
- "already in progress",
- );
- expect(session.setProjectTrusted).toHaveBeenCalledOnce();
-
- finishTransition?.();
- await expect(Promise.all([first, duplicate])).resolves.toEqual([
- undefined,
- undefined,
- ]);
- });
-
- it.each([
- { streaming: true, bashRunning: false },
- { streaming: false, bashRunning: true },
- ])(
- "rejects repository trust changes while Pi is busy",
- async ({ streaming, bashRunning }) => {
- const session = createSession();
- session.setProjectTrusted = vi.fn(async () => {});
- const controller = createController(session);
- await controller.connect("task-1");
- const current = controller.store.getState().sessions["task-1"];
- const status = current.status;
- if (!status) {
- throw new Error("Expected connected Pi status");
- }
- controller.store.setState((state) => ({
- sessions: {
- ...state.sessions,
- "task-1": {
- ...state.sessions["task-1"],
- status: {
- ...status,
- isStreaming: streaming,
- },
- isBashRunning: bashRunning,
- },
- },
- }));
-
- await expect(
- controller.setProjectTrusted("task-1", true),
- ).rejects.toBeInstanceOf(PiOperationError);
- expect(session.setProjectTrusted).not.toHaveBeenCalled();
- },
- );
-
it("uploads cloud follow-up attachments before sending the native message", async () => {
const session = createSession();
session.sendUserMessage = vi.fn(async () => {});
diff --git a/products/desktop/packages/core/src/pi-runtime/piSessionController.ts b/products/desktop/packages/core/src/pi-runtime/piSessionController.ts
index 4ed75a71da24..d8cfc3a3c048 100644
--- a/products/desktop/packages/core/src/pi-runtime/piSessionController.ts
+++ b/products/desktop/packages/core/src/pi-runtime/piSessionController.ts
@@ -31,7 +31,6 @@ import {
createEmptyPiControllerSession,
createPiSessionStore,
type PiControllerSessionState,
- type PiProjectTrustState,
type PiSessionError,
type PiSessionStore,
} from "./piSessionStore";
@@ -72,8 +71,6 @@ export interface PiSession {
retry?(): Promise<void>;
getQueue(): Promise<PiQueueSnapshot>;
clearQueue(): Promise<PiQueueSnapshot>;
- getProjectTrust?(): Promise<PiProjectTrustState>;
- setProjectTrusted?(trusted: boolean): Promise<void>;
sendUserMessage?(
type: "prompt" | "steer" | "follow_up",
message: string,
@@ -129,7 +126,6 @@ type PiOperation =
| "bash"
| "cancel"
| "queue"
- | "trust"
| "retry"
| "restart";
@@ -163,10 +159,6 @@ export class PiSessionController {
private readonly sessions = new Map<string, Promise<PiSession>>();
private readonly subscriptions = new Map<string, () => void>();
- private readonly projectTrustTransitions = new Map<
- string,
- { trusted: boolean; promise: Promise<void> }
- >();
private readonly liveEvents = new Map<string, AgentConversationEvent[]>();
private readonly connections = new Map<string, Promise<void>>();
private readonly readiness = new Map<string, Promise<void>>();
@@ -339,71 +331,6 @@ export class PiSessionController {
}
}
- setProjectTrusted(taskId: string, trusted: boolean): Promise<void> {
- const existing = this.projectTrustTransitions.get(taskId);
- if (existing) {
- return existing.trusted === trusted
- ? existing.promise
- : Promise.reject(
- new Error("A repository trust change is already in progress"),
- );
- }
-
- const promise = this.setProjectTrustedInternal(taskId, trusted).finally(
- () => {
- if (this.projectTrustTransitions.get(taskId)?.promise === promise) {
- this.projectTrustTransitions.delete(taskId);
- }
- },
- );
- this.projectTrustTransitions.set(taskId, { trusted, promise });
- return promise;
- }
-
- private async setProjectTrustedInternal(
- taskId: string,
- trusted: boolean,
- ): Promise<void> {
- const current = this.getSession(taskId);
- if (
- current.connectionState !== "connected" ||
- current.status?.isStreaming ||
- current.isBashRunning
- ) {
- throw this.recordOperationFailure(
- taskId,
- "trust",
- new Error(
- "Wait for Pi to connect and finish before changing repository trust",
- ),
- );
- }
-
- const taskRunId = this.taskRunIds.get(taskId);
- this.captureQueueForRestore(taskId);
- this.updateSession(taskId, {
- connectionState: "connecting",
- error: undefined,
- });
- try {
- const session = await this.getPiSession(taskId);
- if (!session.setProjectTrusted) {
- throw new Error("Pi session does not support repository trust");
- }
- await session.setProjectTrusted(trusted);
- this.resetTransport(taskId);
- await this.ensureConnected(taskId, taskRunId);
- } catch (error) {
- this.resetTransport(taskId);
- try {
- await this.ensureConnected(taskId, taskRunId);
- } catch {
- // Preserve the original trust-transition failure.
- }
- throw this.recordOperationFailure(taskId, "trust", error);
- }
- }
-
async restart(taskId: string): Promise<void> {
if (this.getSession(taskId).connectionState === "connecting") {
return;
@@ -778,12 +705,11 @@ export class PiSessionController {
const session = await this.getPiSession(taskId);
const queueRevision = this.queueRevisions.get(taskId) ?? 0;
const retainedStats = this.getSession(taskId).stats;
- const [events, status, queue, stats, projectTrust] = await Promise.all([
+ const [events, status, queue, stats] = await Promise.all([
session.getConversation(),
session.client.getState(),
session.getQueue(),
session.client.getSessionStats().catch(() => retainedStats),
- session.getProjectTrust?.(),
]);
if (this.getSessionVersion(taskId) !== connectedSessionVersion) {
return;
@@ -852,7 +778,6 @@ export class PiSessionController {
authRestoring: currentSession.authRestoring,
isBashRunning: false,
mcpToolPermissionRequests: currentSession.mcpToolPermissionRequests,
- projectTrust,
});
await this.restoreQueueIfNeeded(taskId, session, resolvedStatus);
@@ -1254,7 +1179,6 @@ export class PiSessionController {
bash: "Failed to run Pi bash command",
cancel: "Failed to stop Pi",
queue: "Failed to update queued message",
- trust: "Failed to change repository trust",
retry: "Failed to reconnect to Pi",
restart: "Failed to restart Pi",
};
diff --git a/products/desktop/packages/core/src/pi-runtime/piSessionStore.ts b/products/desktop/packages/core/src/pi-runtime/piSessionStore.ts
index 301d14615fb2..dfa0cde6e7ab 100644
--- a/products/desktop/packages/core/src/pi-runtime/piSessionStore.ts
+++ b/products/desktop/packages/core/src/pi-runtime/piSessionStore.ts
@@ -16,11 +16,6 @@ import type {
} from "@posthog/shared";
import { createStore, type StoreApi } from "zustand/vanilla";
-export interface PiProjectTrustState {
- trusted: boolean;
- hasProjectResources: boolean;
-}
-
export interface PiSessionError {
id: string;
scope: "connection" | "operation";
@@ -48,7 +43,6 @@ export interface PiControllerSessionState {
authRestoring: boolean;
isBashRunning: boolean;
mcpToolPermissionRequests: Map<string, McpToolPermissionRequest>;
- projectTrust?: PiProjectTrustState;
}
export interface PiSessionState {
diff --git a/products/desktop/packages/core/src/task-detail/taskCreationSaga.test.ts b/products/desktop/packages/core/src/task-detail/taskCreationSaga.test.ts
index 25b10360c7b9..5cd5b1b0b713 100644
--- a/products/desktop/packages/core/src/task-detail/taskCreationSaga.test.ts
+++ b/products/desktop/packages/core/src/task-detail/taskCreationSaga.test.ts
@@ -408,7 +408,6 @@ describe("TaskCreationSaga", () => {
additionalDirectories: ["/tmp/shared"],
channelMode: true,
},
- projectTrustPath: "/tmp/scratch/task-123",
prompt: "Draft a launch email",
model: "claude-sonnet",
thinkingLevel: "medium",
diff --git a/products/desktop/packages/core/src/task-detail/taskCreationSaga.ts b/products/desktop/packages/core/src/task-detail/taskCreationSaga.ts
index dc19394d35df..a89b23464f73 100644
--- a/products/desktop/packages/core/src/task-detail/taskCreationSaga.ts
+++ b/products/desktop/packages/core/src/task-detail/taskCreationSaga.ts
@@ -559,8 +559,6 @@ export class TaskCreationSaga extends Saga<
additionalDirectories: input.additionalDirectories,
channelMode: !!scratchCwd && agentCwd === scratchCwd,
},
- projectTrustPath:
- workspace?.folderPath ?? repoPath ?? scratchCwd ?? undefined,
prompt,
model: input.model,
thinkingLevel,
diff --git a/products/desktop/packages/core/src/task-detail/taskService.test.ts b/products/desktop/packages/core/src/task-detail/taskService.test.ts
index 557315ee27b3..90b3f4aae64b 100644
--- a/products/desktop/packages/core/src/task-detail/taskService.test.ts
+++ b/products/desktop/packages/core/src/task-detail/taskService.test.ts
@@ -98,7 +98,6 @@ describe("TaskService.openTask", () => {
});
expect(piRunner.resume).toHaveBeenCalledWith({
taskContext: { taskId: "task-1", cwd: "/worktrees/task-1" },
- projectTrustPath: "/repo",
});
});
diff --git a/products/desktop/packages/core/src/task-detail/taskService.ts b/products/desktop/packages/core/src/task-detail/taskService.ts
index a4d03ea687cd..f9a17ce4bfc0 100644
--- a/products/desktop/packages/core/src/task-detail/taskService.ts
+++ b/products/desktop/packages/core/src/task-detail/taskService.ts
@@ -264,7 +264,6 @@ export class TaskService {
cwd:
existingWorkspace.worktreePath ?? existingWorkspace.folderPath,
},
- projectTrustPath: existingWorkspace.folderPath,
});
}
@@ -285,10 +284,7 @@ export class TaskService {
if (runtime === "pi") {
try {
const cwd = await this.host.ensureScratchDir(taskId);
- await this.piRunner.resume({
- taskContext: { taskId, cwd },
- projectTrustPath: cwd,
- });
+ await this.piRunner.resume({ taskContext: { taskId, cwd } });
return {
success: true,
data: { task, workspace: null },
diff --git a/products/desktop/packages/host-router/src/pi-session-factory.ts b/products/desktop/packages/host-router/src/pi-session-factory.ts
index 7ef0cd4eea94..d646a951f55c 100644
--- a/products/desktop/packages/host-router/src/pi-session-factory.ts
+++ b/products/desktop/packages/host-router/src/pi-session-factory.ts
@@ -71,19 +71,6 @@ class TrpcPiSession implements PiSession {
});
}
- getProjectTrust() {
- return this.hostClient.piSession.getProjectTrust.query({
- taskId: this.taskId,
- });
- }
-
- setProjectTrusted(trusted: boolean) {
- return this.hostClient.piSession.setProjectTrusted.mutate({
- taskId: this.taskId,
- trusted,
- });
- }
-
respondToExtensionUI(
response: Parameters<NonNullable<PiSession["respondToExtensionUI"]>>[0],
) {
diff --git a/products/desktop/packages/host-router/src/routers/pi-session.router.ts b/products/desktop/packages/host-router/src/routers/pi-session.router.ts
index b853a5c58783..db3baedfa065 100644
--- a/products/desktop/packages/host-router/src/routers/pi-session.router.ts
+++ b/products/desktop/packages/host-router/src/routers/pi-session.router.ts
@@ -3,7 +3,6 @@ import { PI_SESSION_SERVICE } from "@posthog/workspace-server/services/pi-sessio
import type { PiSessionService } from "@posthog/workspace-server/services/pi-session/pi-session";
import {
piExtensionUIResponseInput,
- piProjectTrustOutput,
piQueueSnapshotOutput,
piRpcResponseSchema,
piSessionConfigInput,
@@ -14,7 +13,6 @@ import {
piSessionTaskInput,
respondMcpToolPermissionInput,
resumePiSessionInput,
- setPiProjectTrustInput,
startPiSessionInput,
} from "@posthog/workspace-server/services/pi-session/schemas";
@@ -97,19 +95,6 @@ export const piSessionRouter = router({
}
}),
- getProjectTrust: publicProcedure
- .input(piSessionTaskInput)
- .output(piProjectTrustOutput)
- .query(({ ctx, input }) =>
- getService(ctx.container).getProjectTrust(input.taskId),
- ),
-
- setProjectTrusted: publicProcedure
- .input(setPiProjectTrustInput)
- .mutation(({ ctx, input }) =>
- getService(ctx.container).setProjectTrusted(input.taskId, input.trusted),
- ),
-
respondToExtensionUI: publicProcedure
.input(piExtensionUIResponseInput)
.mutation(({ ctx, input }) =>
diff --git a/products/desktop/packages/ui/src/features/pi-sessions/PiProjectTrustBanner.test.tsx b/products/desktop/packages/ui/src/features/pi-sessions/PiProjectTrustBanner.test.tsx
deleted file mode 100644
index 71b1867f9eb6..000000000000
--- a/products/desktop/packages/ui/src/features/pi-sessions/PiProjectTrustBanner.test.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { render, screen, waitFor } from "@testing-library/react";
-import userEvent from "@testing-library/user-event";
-import { describe, expect, it, vi } from "vitest";
-import { PiProjectTrustBanner } from "./PiProjectTrustBanner";
-
-describe("PiProjectTrustBanner", () => {
- it("warns before trusting and invokes the trust callback", async () => {
- const user = userEvent.setup();
- const onTrust = vi.fn(async () => {});
-
- render(
- <PiProjectTrustBanner
- trusted={false}
- disabled={false}
- pending={false}
- onTrust={onTrust}
- onRevoke={vi.fn(async () => {})}
- />,
- );
-
- await user.click(screen.getByRole("button", { name: "Trust repository" }));
- expect(screen.getByRole("alertdialog")).toHaveTextContent(
- "run arbitrary code with your full user permissions",
- );
- expect(screen.getByRole("alertdialog")).toHaveTextContent(
- "access files and credentials",
- );
-
- await user.click(
- screen.getByRole("button", { name: "Trust and restart Pi" }),
- );
- await waitFor(() => expect(onTrust).toHaveBeenCalledOnce());
- });
-
- it("revokes trust without the dangerous confirmation", async () => {
- const user = userEvent.setup();
- const onRevoke = vi.fn(async () => {});
-
- render(
- <PiProjectTrustBanner
- trusted
- disabled={false}
- pending={false}
- onTrust={vi.fn(async () => {})}
- onRevoke={onRevoke}
- />,
- );
-
- await user.click(screen.getByRole("button", { name: "Revoke trust" }));
-
- expect(onRevoke).toHaveBeenCalledOnce();
- expect(screen.queryByRole("alertdialog")).not.toBeInTheDocument();
- });
-
- it.each([
- { disabled: true, pending: false },
- { disabled: false, pending: true },
- ])(
- "disables trust changes when disabled=$disabled and pending=$pending",
- ({ disabled, pending }) => {
- render(
- <PiProjectTrustBanner
- trusted={false}
- disabled={disabled}
- pending={pending}
- onTrust={vi.fn(async () => {})}
- onRevoke={vi.fn(async () => {})}
- />,
- );
-
- expect(
- screen.getByRole("button", { name: "Trust repository" }),
- ).toHaveAttribute("aria-disabled", "true");
- },
- );
-});
diff --git a/products/desktop/packages/ui/src/features/pi-sessions/PiProjectTrustBanner.tsx b/products/desktop/packages/ui/src/features/pi-sessions/PiProjectTrustBanner.tsx
deleted file mode 100644
index 9cbb6005c5be..000000000000
--- a/products/desktop/packages/ui/src/features/pi-sessions/PiProjectTrustBanner.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import { Warning } from "@phosphor-icons/react";
-import {
- AlertDialog,
- AlertDialogClose,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle,
- Button,
-} from "@posthog/quill";
-import { Flex, Text } from "@radix-ui/themes";
-import { useState } from "react";
-
-interface PiProjectTrustBannerProps {
- trusted: boolean;
- disabled: boolean;
- pending: boolean;
- onTrust: () => Promise<void>;
- onRevoke: () => Promise<void>;
-}
-
-export function PiProjectTrustBanner({
- trusted,
- disabled,
- pending,
- onTrust,
- onRevoke,
-}: PiProjectTrustBannerProps) {
- const [confirmOpen, setConfirmOpen] = useState(false);
-
- const trust = async () => {
- await onTrust();
- setConfirmOpen(false);
- };
-
- return (
- <>
- <Flex
- align="center"
- gap="2"
- justify="between"
- className="mb-2 rounded-md border border-border bg-surface-secondary px-3 py-2"
- >
- <Flex align="center" gap="2" className="min-w-0">
- <Warning size={16} className="shrink-0 text-warning" />
- <Text size="1" color="gray">
- {trusted
- ? "Project-local Pi resources are enabled. Changing trust restarts Pi."
- : "Project-local Pi extensions, settings, and skills are disabled."}
- </Text>
- </Flex>
- {trusted ? (
- <Button
- size="sm"
- variant="outline"
- disabled={disabled || pending}
- loading={pending}
- onClick={() => void onRevoke()}
- >
- Revoke trust
- </Button>
- ) : (
- <Button
- size="sm"
- variant="outline"
- disabled={disabled || pending}
- onClick={() => setConfirmOpen(true)}
- >
- Trust repository
- </Button>
- )}
- </Flex>
-
- <AlertDialog open={confirmOpen} onOpenChange={setConfirmOpen}>
- <AlertDialogContent className="max-w-md">
- <AlertDialogHeader>
- <AlertDialogTitle>Trust this repository?</AlertDialogTitle>
- <AlertDialogDescription>
- Project extensions run arbitrary code with your full user
- permissions. They can access files and credentials, start
- processes, and use the network. Only continue after reviewing the
- complete source and dependency tree.
- </AlertDialogDescription>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogClose
- render={<Button variant="outline">Cancel</Button>}
- />
- <Button
- variant="destructive"
- loading={pending}
- disabled={disabled || pending}
- onClick={() => void trust()}
- >
- Trust and restart Pi
- </Button>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
- </>
- );
-}
diff --git a/products/desktop/packages/ui/src/features/pi-sessions/PiSessionView.tsx b/products/desktop/packages/ui/src/features/pi-sessions/PiSessionView.tsx
index 95a315123d37..095a3daf4ae9 100644
--- a/products/desktop/packages/ui/src/features/pi-sessions/PiSessionView.tsx
+++ b/products/desktop/packages/ui/src/features/pi-sessions/PiSessionView.tsx
@@ -63,7 +63,6 @@ import {
import { useStore } from "zustand";
import { PiExtensionDialog } from "./PiExtensionDialog";
import { PiExtensionStatuses, PiExtensionWidgets } from "./PiExtensionSurfaces";
-import { PiProjectTrustBanner } from "./PiProjectTrustBanner";
import { PiQueuedMessagesDock } from "./PiQueuedMessagesDock";
import { PiMessagingModeSelector } from "./PiSessionControls";
import { PiSessionModelControls } from "./PiSessionModelControls";
@@ -417,32 +416,6 @@ function usePiRestart(
}, [controller, taskId]);
}
-function usePiProjectTrustChange(
- controller: PiSessionController,
- taskId: string,
-) {
- const [pending, setPending] = useState(false);
- const change = useCallback(
- async (trusted: boolean) => {
- setPending(true);
- try {
- await controller.setProjectTrusted(taskId, trusted);
- toast.success(
- trusted
- ? "Repository trusted and Pi restarted"
- : "Repository trust revoked and Pi restarted",
- );
- } catch (error) {
- handleControllerError(error, "Failed to change repository trust");
- } finally {
- setPending(false);
- }
- },
- [controller, taskId],
- );
- return { change, pending };
-}
-
function usePiEditQueue(
controller: PiSessionController,
taskId: string,
@@ -561,8 +534,6 @@ export function PiSessionView({ task, isCloud }: PiSessionViewProps) {
const cancelPrompt = usePiCancel(piSessionController, taskId, isBashRunning);
const retry = usePiRetry(piSessionController, taskId);
const restart = usePiRestart(piSessionController, taskId);
- const { change: changeProjectTrust, pending: projectTrustPending } =
- usePiProjectTrustChange(piSessionController, taskId);
const handleQueueForEditing = useCallback(
(queue: PiQueueSnapshot) => applyQueueToDraft(queue, draftActions, taskId),
[draftActions, taskId],
@@ -716,17 +687,6 @@ export function PiSessionView({ task, isCloud }: PiSessionViewProps) {
widgets={currentExtensionState.widgets}
placement="aboveEditor"
/>
- {session.projectTrust?.hasProjectResources && (
- <PiProjectTrustBanner
- trusted={session.projectTrust.trusted}
- disabled={
- controlsPending || session.connectionState !== "connected"
- }
- pending={projectTrustPending}
- onTrust={() => changeProjectTrust(true)}
- onRevoke={() => changeProjectTrust(false)}
- />
- )}
</>
)}
{mcpPermission ? (
diff --git a/products/desktop/packages/workspace-server/src/services/pi-session/identifiers.ts b/products/desktop/packages/workspace-server/src/services/pi-session/identifiers.ts
index 9985388420b1..5f0249a53f3e 100644
--- a/products/desktop/packages/workspace-server/src/services/pi-session/identifiers.ts
+++ b/products/desktop/packages/workspace-server/src/services/pi-session/identifiers.ts
@@ -7,10 +7,7 @@ import type { TaskContextInput } from "@posthog/agent/pi/task-system-prompt";
export interface PiRpcClientFactory {
create(
- input: Pick<
- PiRpcClientOptions,
- "model" | "sessionFile" | "projectTrusted"
- > & {
+ input: Pick<PiRpcClientOptions, "model" | "sessionFile"> & {
taskContext: TaskContextInput;
},
): Promise<PiRpcClient>;
diff --git a/products/desktop/packages/workspace-server/src/services/pi-session/pi-session.test.ts b/products/desktop/packages/workspace-server/src/services/pi-session/pi-session.test.ts
index 103dba1f3ab2..0c5b911e125a 100644
--- a/products/desktop/packages/workspace-server/src/services/pi-session/pi-session.test.ts
+++ b/products/desktop/packages/workspace-server/src/services/pi-session/pi-session.test.ts
@@ -1,12 +1,9 @@
-import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
-import { tmpdir } from "node:os";
-import { join } from "node:path";
import type { PiRpcClient } from "@posthog/agent/pi/rpc-client";
import type { RpcCommand, RpcResponse } from "@posthog/agent/pi/rpc-transport";
import type { PiRuntime } from "@posthog/agent/pi/runtime";
import type { PiExtensionEvent } from "@posthog/agent/pi/types";
import type { RootLogger } from "@posthog/di/logger";
-import { afterEach, describe, expect, it, vi } from "vitest";
+import { describe, expect, it, vi } from "vitest";
import type { ITaskMetadataRepository } from "../../db/repositories/task-metadata-repository";
import type { ProcessTrackingService } from "../process-tracking/process-tracking";
import type { PiRuntimeFactory } from "./identifiers";
@@ -31,25 +28,6 @@ function successfulResponse(command: string): RpcResponse {
} as RpcResponse;
}
-const temporaryDirectories: string[] = [];
-
-async function temporaryDirectory(): Promise<string> {
- const directory = await mkdtemp(join(tmpdir(), "posthog-pi-session-"));
- temporaryDirectories.push(directory);
- return directory;
-}
-
-afterEach(async () => {
- vi.unstubAllEnvs();
- vi.unstubAllGlobals();
- vi.restoreAllMocks();
- await Promise.all(
- temporaryDirectories
- .splice(0)
- .map((directory) => rm(directory, { force: true, recursive: true })),
- );
-});
-
describe("selectPiPoolEvictionCandidate", () => {
it("selects the least recently used idle session", () => {
expect(
@@ -253,7 +231,6 @@ describe("PiSessionService start", () => {
channelMode: true,
},
model: undefined,
- projectTrusted: false,
});
expect(setThinkingLevel).toHaveBeenCalledWith("high");
expect(setThinkingLevel.mock.invocationCallOrder[0]).toBeLessThan(
@@ -299,152 +276,6 @@ describe("PiSessionService start", () => {
});
});
-describe("PiSessionService project trust", () => {
- it("persists repository trust, stops the runtime, and applies it on resume", async () => {
- const agentDir = await temporaryDirectory();
- const repository = await temporaryDirectory();
- const worktree = join(repository, "worktree");
- const commonGitDir = join(repository, ".git");
- const worktreeGitDir = join(commonGitDir, "worktrees", "task-1");
- await mkdir(join(worktree, ".pi", "extensions"), { recursive: true });
- await mkdir(worktreeGitDir, { recursive: true });
- await writeFile(join(worktree, ".git"), `gitdir: ${worktreeGitDir}\n`);
- await writeFile(join(worktreeGitDir, "commondir"), "../..\n");
- await writeFile(
- join(worktreeGitDir, "gitdir"),
- `${join(worktree, ".git")}\n`,
- );
- vi.stubEnv("PI_CODING_AGENT_DIR", agentDir);
-
- const clients = [0, 1, 2].map(
- () =>
- ({
- start: vi.fn(async () => {}),
- stop: vi.fn(async () => {}),
- getState: vi.fn(async () => ({
- isStreaming: false,
- sessionFile: "/tmp/session.jsonl",
- sessionId: "session-1",
- })),
- setThinkingLevel: vi.fn(async () => {}),
- onMcpToolPermissionRequest: vi.fn(),
- prompt: vi.fn(async () => {}),
- }) as unknown as PiRpcClient,
- );
- let runtimeIndex = 0;
- const runtimeFactory = {
- create: vi.fn(async () => {
- const client = clients[runtimeIndex++];
- return {
- client,
- process: { pid: 123, once: vi.fn() },
- onRuntimeEvent: vi.fn(),
- onConversationEvent: vi.fn(),
- onExtensionEvent: vi.fn(),
- } as unknown as PiRuntime;
- }),
- } as PiRuntimeFactory;
- const metadata = {
- upsert: vi.fn(),
- findByTaskId: vi.fn(() => ({
- piSessionFile: "/tmp/session.jsonl",
- })),
- } as unknown as ITaskMetadataRepository;
- const processTracking = {
- register: vi.fn(),
- unregister: vi.fn(),
- } as unknown as ProcessTrackingService;
- const service = new PiSessionService(
- runtimeFactory,
- metadata,
- processTracking,
- { approveMcpTool: vi.fn() },
- rootLogger,
- );
-
- await service.start({
- taskContext: { taskId: "task-1", cwd: worktree },
- projectTrustPath: repository,
- prompt: "hello",
- });
- expect(service.getProjectTrust("task-1")).toEqual({
- trusted: false,
- hasProjectResources: true,
- });
- expect(runtimeFactory.create).toHaveBeenLastCalledWith({
- taskContext: { taskId: "task-1", cwd: worktree },
- model: undefined,
- projectTrusted: false,
- });
-
- vi.mocked(clients[0].stop).mockRejectedValueOnce(new Error("stop failed"));
- await expect(service.setProjectTrusted("task-1", true)).rejects.toThrow(
- "stop failed",
- );
- expect(service.getProjectTrust("task-1").trusted).toBe(false);
- expect(service.health("task-1").state).toBe("idle");
- expect(processTracking.unregister).not.toHaveBeenCalled();
-
- await service.resume({
- taskContext: { taskId: "task-1", cwd: worktree },
- projectTrustPath: repository,
- });
- expect(clients[0].stop).toHaveBeenCalledTimes(2);
- expect(runtimeFactory.create).toHaveBeenLastCalledWith({
- taskContext: { taskId: "task-1", cwd: worktree },
- sessionFile: "/tmp/session.jsonl",
- projectTrusted: false,
- });
-
- await service.setProjectTrusted("task-1", true);
- expect(clients[1].stop).toHaveBeenCalledOnce();
- expect(processTracking.unregister).toHaveBeenCalledWith(
- 123,
- "pi-session-stopped",
- );
-
- await service.resume({
- taskContext: { taskId: "task-1", cwd: worktree },
- projectTrustPath: repository,
- });
- expect(runtimeFactory.create).toHaveBeenLastCalledWith({
- taskContext: { taskId: "task-1", cwd: worktree },
- sessionFile: "/tmp/session.jsonl",
- projectTrusted: true,
- });
- expect(service.getProjectTrust("task-1").trusted).toBe(true);
- });
-
- it("rejects trust from a repository unrelated to the runtime cwd", async () => {
- const trustedRepository = await temporaryDirectory();
- const unrelatedRepository = await temporaryDirectory();
- const runtimeFactory = {
- create: vi.fn(),
- } as unknown as PiRuntimeFactory;
- const service = new PiSessionService(
- runtimeFactory,
- { upsert: vi.fn() } as unknown as ITaskMetadataRepository,
- {
- register: vi.fn(),
- unregister: vi.fn(),
- } as unknown as ProcessTrackingService,
- { approveMcpTool: vi.fn() },
- rootLogger,
- );
-
- await expect(
- service.start({
- taskContext: { taskId: "task-1", cwd: unrelatedRepository },
- projectTrustPath: trustedRepository,
- prompt: "hello",
- }),
- ).rejects.toThrow(
- "Pi project trust path must match the runtime repository or its registered Git worktree",
- );
- expect(runtimeFactory.create).not.toHaveBeenCalled();
- });
-});
-
describe("PiSessionService extension UI", () => {
it("streams current-session extension events and forwards responses", async () => {
const extensionHandlers: Array<(event: PiExtensionEvent) => void> = [];
diff --git a/products/desktop/packages/workspace-server/src/services/pi-session/pi-session.ts b/products/desktop/packages/workspace-server/src/services/pi-session/pi-session.ts
index 3c7c7f7d0006..5da6a6629848 100644
--- a/products/desktop/packages/workspace-server/src/services/pi-session/pi-session.ts
+++ b/products/desktop/packages/workspace-server/src/services/pi-session/pi-session.ts
@@ -1,5 +1,3 @@
-import { readFile, realpath, stat } from "node:fs/promises";
-import { isAbsolute, join, relative, resolve, sep } from "node:path";
import {
buildSessionContext,
type FileEntry,
@@ -18,11 +16,6 @@ import {
type RpcExtensionUIResponse,
} from "@posthog/agent/pi/types";
import { ROOT_LOGGER, type RootLogger } from "@posthog/di/logger";
-import {
- type PiProjectTrust,
- readPiProjectTrust,
- writePiProjectTrust,
-} from "@posthog/harness/project-trust";
import {
type AgentConversationEvent,
type McpToolPermissionDecision,
@@ -93,7 +86,6 @@ interface ManagedPiSession {
pendingMcpPermissions: Map<string, McpToolPermissionRequest>;
runtime: PiRuntime;
cwd: string;
- projectTrustPath: string;
state: PiPoolSessionState;
lastUsedAt: number;
activeRequestCount: number;
@@ -121,106 +113,6 @@ function isPiExtensionDialogRequest(
const DEFAULT_PI_HOT_POOL_SIZE = 4;
-interface GitRepositoryIdentity {
- commonDir: string;
- kind: "main" | "worktree";
-}
-
-async function resolveExistingPath(path: string): Promise<string> {
- try {
- return await realpath(path);
- } catch {
- return resolve(path);
- }
-}
-
-async function resolveGitRepositoryIdentity(
- repositoryPath: string,
-): Promise<GitRepositoryIdentity | null> {
- const resolvedRepositoryPath = await resolveExistingPath(repositoryPath);
- const gitMarker = join(resolvedRepositoryPath, ".git");
-
- try {
- const gitMarkerStat = await stat(gitMarker);
- if (gitMarkerStat.isDirectory()) {
- return {
- commonDir: await resolveExistingPath(gitMarker),
- kind: "main",
- };
- }
- if (!gitMarkerStat.isFile()) {
- return null;
- }
-
- const markerMatch = (await readFile(gitMarker, "utf8")).match(
- /^gitdir:\s*(.+)$/m,
- );
- if (!markerMatch) {
- return null;
- }
-
- const gitDir = await resolveExistingPath(
- isAbsolute(markerMatch[1])
- ? markerMatch[1]
- : resolve(resolvedRepositoryPath, markerMatch[1]),
- );
- const commonDir = await resolveExistingPath(
- resolve(
- gitDir,
- (await readFile(join(gitDir, "commondir"), "utf8")).trim(),
- ),
- );
- const gitDirRelativeToCommon = relative(commonDir, gitDir);
- if (
- gitDirRelativeToCommon.startsWith("..") ||
- isAbsolute(gitDirRelativeToCommon) ||
- !gitDirRelativeToCommon.startsWith(`worktrees${sep}`)
- ) {
- return null;
- }
-
- const registeredMarker = await resolveExistingPath(
- (await readFile(join(gitDir, "gitdir"), "utf8")).trim(),
- );
- if (registeredMarker !== (await resolveExistingPath(gitMarker))) {
- return null;
- }
-
- return { commonDir, kind: "worktree" };
- } catch {
- return null;
- }
-}
-
-async function assertProjectTrustAppliesToCwd(
- projectTrustPath: string,
- cwd: string,
-): Promise<void> {
- const [resolvedProjectTrustPath, resolvedCwd] = await Promise.all([
- resolveExistingPath(projectTrustPath),
- resolveExistingPath(cwd),
- ]);
- if (resolvedProjectTrustPath === resolvedCwd) {
- return;
- }
-
- const [trustedRepository, runtimeRepository] = await Promise.all([
- resolveGitRepositoryIdentity(resolvedProjectTrustPath),
- resolveGitRepositoryIdentity(resolvedCwd),
- ]);
- if (
- trustedRepository?.kind === "main" &&
- runtimeRepository?.kind === "worktree" &&
- trustedRepository.commonDir === runtimeRepository.commonDir
- ) {
- return;
- }
-
- throw new Error(
- "Pi project trust path must match the runtime repository or its registered Git worktree",
- );
-}
-
function readHotPoolSize(): number {
const configured = Number.parseInt(
process.env.POSTHOG_CODE_PI_HOT_POOL_SIZE ?? "",
@@ -271,21 +163,12 @@ export class PiSessionService extends TypedEventEmitter<PiSessionEvents> {
const { taskId, cwd } = input.taskContext;
await this.stopLocked(taskId);
- const projectTrustPath = input.projectTrustPath ?? cwd;
- await assertProjectTrustAppliesToCwd(projectTrustPath, cwd);
- const projectTrust = readPiProjectTrust(projectTrustPath, cwd);
const runtime = await this.runtimeFactory.create({
taskContext: input.taskContext,
model: input.model,
- projectTrusted: projectTrust.trusted,
});
const client = runtime.client;
- const session = this.registerSession(
- taskId,
- runtime,
- cwd,
- projectTrustPath,
- );
+ const session = this.registerSession(taskId, runtime, cwd);
return this.startSession(taskId, client, session, async () => {
if (input.thinkingLevel) {
@@ -321,12 +204,10 @@ export class PiSessionService extends TypedEventEmitter<PiSessionEvents> {
private async resumeLocked(input: ResumePiSessionInput): Promise<void> {
const { taskId, cwd } = input.taskContext;
const existingSession = this.sessions.get(taskId);
- const projectTrustPath = input.projectTrustPath ?? cwd;
if (
existingSession &&
!existingSession.stopFailed &&
- existingSession.cwd === cwd &&
- existingSession.projectTrustPath === projectTrustPath
+ existingSession.cwd === cwd
) {
this.touchSession(existingSession);
return;
@@ -341,20 +222,12 @@ export class PiSessionService extends TypedEventEmitter<PiSessionEvents> {
await this.stopLocked(taskId);
- await assertProjectTrustAppliesToCwd(projectTrustPath, cwd);
- const projectTrust = readPiProjectTrust(projectTrustPath, cwd);
const runtime = await this.runtimeFactory.create({
taskContext: input.taskContext,
sessionFile,
- projectTrusted: projectTrust.trusted,
});
const client = runtime.client;
- const session = this.registerSession(
- taskId,
- runtime,
- cwd,
- projectTrustPath,
- );
+ const session = this.registerSession(taskId, runtime, cwd);
await this.startSession(taskId, client, session, async () => {});
}
@@ -414,22 +287,6 @@ export class PiSessionService extends TypedEventEmitter<PiSessionEvents> {
});
}
- getProjectTrust(taskId: string): PiProjectTrust {
- const session = this.requireSession(taskId);
- return readPiProjectTrust(session.projectTrustPath, session.cwd);
- }
-
- async setProjectTrusted(taskId: string, trusted: boolean): Promise<void> {
- await this.runExclusive(taskId, async () => {
- const session = this.requireSession(taskId);
- if (session.state !== "idle" || session.activeRequestCount > 0) {
- throw new Error("Cannot change project trust while Pi is busy");
- }
- await this.stopLocked(taskId);
- writePiProjectTrust(session.projectTrustPath, trusted);
- });
- }
-
respondToExtensionUI(
taskId: string,
response: RpcExtensionUIResponse,
@@ -656,7 +513,6 @@ export class PiSessionService extends TypedEventEmitter<PiSessionEvents> {
taskId: string,
runtime: PiRuntime,
cwd: string,
- projectTrustPath: string,
): ManagedPiSession {
const pendingMcpPermissions = new Map<string, McpToolPermissionRequest>();
runtime.client.onMcpToolPermissionRequest((request) => {
@@ -669,7 +525,6 @@ export class PiSessionService extends TypedEventEmitter<PiSessionEvents> {
pendingMcpPermissions,
runtime,
cwd,
- projectTrustPath,
state: "starting",
lastUsedAt: Date.now(),
activeRequestCount: 0,
diff --git a/products/desktop/packages/workspace-server/src/services/pi-session/schemas.ts b/products/desktop/packages/workspace-server/src/services/pi-session/schemas.ts
index 8a0e8167a5fd..4fb112f32e90 100644
--- a/products/desktop/packages/workspace-server/src/services/pi-session/schemas.ts
+++ b/products/desktop/packages/workspace-server/src/services/pi-session/schemas.ts
@@ -22,7 +22,6 @@ const piTaskContextInput = z.object({
export const startPiSessionInput = z.object({
taskContext: piTaskContextInput,
- projectTrustPath: z.string().optional(),
prompt: z.string(),
model: z.string().optional(),
thinkingLevel: z.enum(PI_THINKING_LEVELS).optional(),
@@ -43,23 +42,12 @@ export const piSessionHealthOutput = z.object({
export const resumePiSessionInput = z.object({
taskContext: piTaskContextInput.pick({ taskId: true, cwd: true }),
- projectTrustPath: z.string().optional(),
});
export type ResumePiSessionInput = z.infer<typeof resumePiSessionInput>;
export const piSessionTaskInput = z.object({ taskId: z.string() });
-export const piProjectTrustOutput = z.object({
- trusted: z.boolean(),
- hasProjectResources: z.boolean(),
-});
-
-export const setPiProjectTrustInput = z.object({
- taskId: z.string(),
- trusted: z.boolean(),
-});
-
export const mcpToolPermissionRequestSchema = z.object({
requestId: z.string(),
serverName: z.string(),