@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 59 lines 2.21 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
6 import { T3_HOME } from "../e2e.config.ts";
7 import { runPromise, test, WEB } from "./t3.ts";
8
9 // A saved rule that binds Enter to the command palette only while the right panel is closed.
10 const panelConditionedEnter = Effect.gen(function* () {
11 const fs = yield* FileSystem.FileSystem;
12 const keybindingsPath = (yield* Path.Path).join(T3_HOME, "userdata/keybindings.json");
13 const original = (yield* fs.exists(keybindingsPath))
14 ? yield* fs.readFileString(keybindingsPath)
15 : null;
16 return {
17 save: fs.writeFileString(
18 keybindingsPath,
19 '[{ "key": "enter", "command": "commandPalette.toggle", "when": "!rightPanelOpen" }]\n',
20 ),
21 restore:
22 original === null
23 ? fs.remove(keybindingsPath, { force: true })
24 : fs.writeFileString(keybindingsPath, original),
25 };
26 });
27
28 test(
29 "Enter sends from the composer while the right panel is open and a rule binds it when closed",
30 WEB,
31 async ({ t3, app, screen }) => {
32 const keybindings = await runPromise(panelConditionedEnter);
33 try {
34 await runPromise(keybindings.save);
35 const project = await t3.project("demo");
36 const thread = await t3.thread({ project, title: "Panel work", messages: ["Start"] });
37
38 // The settings list shows the rule once the server has loaded the saved file.
39 await t3.open("/settings/keybindings");
40 await screen
41 .getByRole("button", "Edit shortcut for Command Palette: Toggle: Enter")
42 .waitFor();
43
44 await t3.open(thread);
45 await screen.getByRole("button", "Toggle right panel").tap();
46 await screen.getByRole("button", { name: "Toggle right panel", pressed: true }).waitFor();
47
48 const composer = screen.getByTestId("composer-editor");
49 await composer.tap();
50 await composer.pressSequentially("Hello with the panel open");
51 await composer.press("Enter");
52 await app.screenshot("after-enter");
53 await expect(composer).toHaveText("");
54 await expect(screen.getByText("Hello with the panel open")).toBeVisible();
55 } finally {
56 await runPromise(keybindings.restore);
57 }
58 },
59 );