Files
paseo/packages/app/e2e/workspace-setup-runtime.spec.ts
T
Mohamed Boudra 060f3d457c refactor: remove terminal agent concept entirely
Remove the "agent can be a terminal" branching from the entire codebase.
An agent is now always a session-backed chat agent. Standalone terminal
infrastructure (terminal component, ANSI handling, terminal-stream-protocol)
is preserved.

Server: delete ManagedTerminalAgent, AgentKind, TerminalExitDetails,
launchTerminalAgent, registerTerminalAgent, handleTerminalAgentExited,
supportsTerminalMode capability, buildTerminalCreate/ResumeCommand from
all providers, terminal agent persistence/projections.

App: delete terminal-agent-panel.tsx, terminal-agent-reopen-store.ts,
terminal/terminalExit fields on agent state, "Terminal Agents" launcher
section, terminal-agent workspace setup flow, terminal badge in agent list.

CLI: remove terminal column from ls, terminal-agent error from send.

60 files changed, -3592 lines
2026-04-02 10:55:54 +07:00

141 lines
4.1 KiB
TypeScript

import { existsSync } from "node:fs";
import { expect, test } from "./fixtures";
import { createTempGitRepo } from "./helpers/workspace";
import {
connectWorkspaceSetupClient,
createChatAgentFromWorkspaceSetup,
createStandaloneTerminalFromWorkspaceSetup,
createWorkspaceFromSidebar,
findWorktreeWorkspaceForProject,
openHomeWithProject,
type WorkspaceSetupDaemonClient,
} from "./helpers/workspace-setup";
async function openWorkspaceSetupDialogFromSidebar(
page: import("@playwright/test").Page,
repoPath: string,
): Promise<void> {
await openHomeWithProject(page, repoPath);
await createWorkspaceFromSidebar(page, repoPath);
}
async function expectCreatedWorkspaceRoute(
client: WorkspaceSetupDaemonClient,
originalProjectPath: string,
) {
await expect
.poll(
async () => {
try {
return await findWorktreeWorkspaceForProject(client, originalProjectPath);
} catch {
return null;
}
},
{ timeout: 30_000 },
)
.not.toBeNull();
const workspace = await findWorktreeWorkspaceForProject(client, originalProjectPath);
expect(workspace.workspaceDirectory).not.toBe(originalProjectPath);
expect(existsSync(workspace.workspaceDirectory)).toBe(true);
return workspace;
}
async function waitForNewWorkspaceAgent(
client: WorkspaceSetupDaemonClient,
expectedWorkspaceDirectory: string,
agentIdsBefore: Set<string>,
) {
await expect
.poll(
async () => {
const payload = await client.fetchAgents();
return (
payload.entries.find(
(entry) =>
!agentIdsBefore.has(entry.agent.id) &&
entry.agent.cwd === expectedWorkspaceDirectory,
)?.agent ?? null
);
},
{ timeout: 30_000 },
)
.not.toBeNull();
const payload = await client.fetchAgents();
const agent =
payload.entries.find(
(entry) =>
!agentIdsBefore.has(entry.agent.id) && entry.agent.cwd === expectedWorkspaceDirectory,
)?.agent ?? null;
if (!agent) {
throw new Error(`Expected a new agent for workspace ${expectedWorkspaceDirectory}`);
}
return agent;
}
test.describe("Workspace setup runtime authority", () => {
test.describe.configure({ retries: 1 });
test("first chat agent attaches to the created workspace", async ({ page }) => {
test.setTimeout(90_000);
const client = await connectWorkspaceSetupClient();
const repo = await createTempGitRepo("workspace-setup-chat-");
try {
await client.openProject(repo.path);
await openWorkspaceSetupDialogFromSidebar(page, repo.path);
const agentIdsBefore = new Set((await client.fetchAgents()).entries.map((entry) => entry.agent.id));
await createChatAgentFromWorkspaceSetup(page, {
message: `workspace-setup-chat-${Date.now()}`,
});
const workspace = await expectCreatedWorkspaceRoute(client, repo.path);
const agent = await waitForNewWorkspaceAgent(
client,
workspace.workspaceDirectory,
agentIdsBefore,
);
expect(agent.cwd).toBe(workspace.workspaceDirectory);
expect(agent.cwd).not.toBe(repo.path);
} finally {
await client.close();
await repo.cleanup();
}
});
test("first terminal attaches to the created workspace", async ({ page }) => {
test.setTimeout(90_000);
const client = await connectWorkspaceSetupClient();
const repo = await createTempGitRepo("workspace-setup-terminal-");
try {
await client.openProject(repo.path);
await openWorkspaceSetupDialogFromSidebar(page, repo.path);
await createStandaloneTerminalFromWorkspaceSetup(page);
const workspace = await expectCreatedWorkspaceRoute(client, repo.path);
await expect
.poll(
async () =>
(await client.listTerminals(workspace.workspaceDirectory)).terminals.length > 0,
{ timeout: 30_000 },
)
.toBe(true);
expect(
(await client.listTerminals(repo.path)).terminals.length,
).toBe(0);
} finally {
await client.close();
await repo.cleanup();
}
});
});