The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { ThreadId } from "@t3tools/contracts"; |
| 2 | import { expect } from "e2e"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | |
| 5 | import { T3_HOME } from "../e2e.config.ts"; |
| 6 | import { rpcClient, runPromise, test, WEB } from "./t3.ts"; |
| 7 | |
| 8 | test("The drawer removes a terminal closed by another client", WEB, async ({ t3, app, screen }) => { |
| 9 | const cwd = await t3.project("demo"); |
| 10 | const thread = await t3.thread({ project: cwd, title: "Shared terminals", messages: ["first"] }); |
| 11 | const threadId = ThreadId.make(thread.threadId); |
| 12 | const origin = app.baseUrl ?? ""; |
| 13 | const kept = "kept-shell"; |
| 14 | const closed = "closed-elsewhere"; |
| 15 | |
| 16 | await runPromise( |
| 17 | Effect.gen(function* () { |
| 18 | const client = yield* rpcClient(T3_HOME, origin); |
| 19 | for (const terminalId of [kept, closed]) { |
| 20 | yield* client["terminal.open"]({ threadId, terminalId, cwd }); |
| 21 | } |
| 22 | }).pipe(Effect.scoped), |
| 23 | ); |
| 24 | await t3.open(thread); |
| 25 | await screen.getByRole("button", "Toggle terminal drawer").tap(); |
| 26 | await screen.getByRole("button", kept, { exact: true }).tap(); |
| 27 | const closedTab = screen.getByRole("button", closed, { exact: true }); |
| 28 | await closedTab.waitFor(); |
| 29 | |
| 30 | await runPromise( |
| 31 | Effect.gen(function* () { |
| 32 | const client = yield* rpcClient(T3_HOME, origin); |
| 33 | yield* client["terminal.close"]({ threadId, terminalId: closed, deleteHistory: true }); |
| 34 | }).pipe(Effect.scoped), |
| 35 | ); |
| 36 | |
| 37 | await app.screenshot("after-close-from-another-client"); |
| 38 | await expect(closedTab).toBeHidden(); |
| 39 | }); |