@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
ts 64 lines 2.57 KB
Raw
1 import { expect } from "e2e";
2 import * as Effect from "effect/Effect";
3 import * as FileSystem from "effect/FileSystem";
4 import * as Path from "effect/Path";
5 import * as Schema from "effect/Schema";
6
7 import { T3_HOME } from "../e2e.config.ts";
8 import { makeState, runPromise, test, WEB } from "./t3.ts";
9
10 const SettingsJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown));
11 const decodeSettings = Schema.decodeEffect(SettingsJson);
12 const encodeSettings = Schema.encodeEffect(SettingsJson);
13
14 const threadRuntimeSettings = Effect.gen(function* () {
15 const fs = yield* FileSystem.FileSystem;
16 const settingsPath = (yield* Path.Path).join(T3_HOME, "userdata/settings.json");
17 const original = yield* fs.readFileString(settingsPath);
18 const settings = yield* decodeSettings(original);
19 return {
20 supervise: fs.writeFileString(
21 settingsPath,
22 yield* encodeSettings({ ...settings, defaultRuntimeMode: "approval-required" }),
23 ),
24 restore: fs.writeFileString(settingsPath, original),
25 };
26 });
27
28 test(
29 "An unsaved queued edit keeps its thread mention when the queued run starts",
30 WEB,
31 async ({ t3, app, screen }) => {
32 const settings = await runPromise(threadRuntimeSettings);
33 try {
34 // Supervised mode makes the approval recording wait for an answer, which holds its turn open.
35 await runPromise(settings.supervise);
36 const project = await t3.project("demo");
37 await t3.thread({ project, title: "Release notes", messages: ["Draft the notes"] });
38 const thread = await t3.thread({
39 project,
40 title: "Waiting work",
41 messages: ["Change the file"],
42 model: "approval",
43 });
44 const { cli } = makeState(T3_HOME);
45 await runPromise(cli(["thread", "send", thread.threadId, "Queued message"]));
46 await t3.open(thread);
47
48 await screen.getByRole("button", "Edit queued message").tap();
49 const composer = screen.getByRole("textbox");
50 await composer.press("End");
51 await composer.pressSequentially(" @Release");
52 await screen.getByRole("option", "Release notes", { exact: false }).tap();
53 await expect(composer).toContainText("Release notes");
54
55 await screen.getByRole("button", "Approve", { exact: true }).tap();
56 await expect(screen.getByText("was kept in the composer", { exact: false })).toBeVisible();
57 await expect(screen.getByRole("button", "Cancel editing queued message")).not.toBeVisible();
58 await app.screenshot("recovered-edit");
59 await expect(composer).toContainText("Release notes");
60 } finally {
61 await runPromise(settings.restore);
62 }
63 },
64 );