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 { 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 { 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 | "A recurring task reports when its queued occurrence is held", |
| 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("scheduled-hold"); |
| 37 | await t3.thread({ project, title: "Earlier work", messages: ["Start"] }); |
| 38 | const thread = await t3.thread({ |
| 39 | project, |
| 40 | title: "Waiting scheduled thread", |
| 41 | messages: ["Ask a question"], |
| 42 | model: "approval", |
| 43 | }); |
| 44 | |
| 45 | await t3.open("/settings/scheduled-tasks"); |
| 46 | await screen.getByRole("button", "New task").tap(); |
| 47 | await screen.getByRole("textbox", "Name").fill("Held recurring task"); |
| 48 | await screen.getByRole("combobox", "Destination").tap(); |
| 49 | await screen.getByRole("option", "One thread, continuing the conversation").tap(); |
| 50 | await screen.getByRole("combobox", "Destination thread").tap(); |
| 51 | await screen.getByRole("option", "Waiting scheduled thread").tap(); |
| 52 | await screen.getByRole("textbox", "Prompt").fill("Scheduled check prompt"); |
| 53 | await screen.getByRole("button", "Every interval").tap(); |
| 54 | await screen.getByRole("spinbutton", "Run every").fill("1"); |
| 55 | await screen.getByRole("button", "Create task").tap(); |
| 56 | |
| 57 | await t3.open(thread); |
| 58 | await screen.getByRole("button", "Approve", { exact: true }).waitFor(); |
| 59 | await screen |
| 60 | .getByRole("button", "Automation Held recurring task") |
| 61 | .waitFor({ timeout: 100_000 }); |
| 62 | // Stopping the active turn holds the queued scheduled occurrence. |
| 63 | await screen.getByRole("button", "Stop generation").tap(); |
| 64 | await screen.getByRole("button", "Resume thread").waitFor(); |
| 65 | await screen.getByRole("button", "Edit queued message").waitFor(); |
| 66 | |
| 67 | await app.open("/settings/scheduled-tasks"); |
| 68 | await expect( |
| 69 | screen.getByText( |
| 70 | "A previous occurrence is held in the thread queue. Resume or remove it to run this task again.", |
| 71 | ), |
| 72 | ).toBeVisible({ timeout: 100_000 }); |
| 73 | await app.screenshot("held-scheduled-task"); |
| 74 | } finally { |
| 75 | await runPromise(settings.restore); |
| 76 | } |
| 77 | }, |
| 78 | ); |