Update terminal activity E2E for finished attention
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import type { TerminalActivityState } from "@getpaseo/protocol/terminal-activity";
|
||||
import type { TerminalActivity, TerminalActivityState } from "@getpaseo/protocol/terminal-activity";
|
||||
import { createTempGitRepo } from "./workspace";
|
||||
import { navigateToTerminal, setupDeterministicPrompt } from "./terminal-perf";
|
||||
import { connectSeedClient, type SeedDaemonClient } from "./seed-client";
|
||||
@@ -84,6 +84,7 @@ export class TerminalE2EHarness {
|
||||
async waitForTerminalActivity(input: {
|
||||
terminalId: string;
|
||||
state: TerminalActivityState | null;
|
||||
attentionReason?: TerminalActivity["attentionReason"] | null;
|
||||
timeoutMs?: number;
|
||||
}): Promise<void> {
|
||||
const timeoutMs = input.timeoutMs ?? 10_000;
|
||||
@@ -91,13 +92,21 @@ export class TerminalE2EHarness {
|
||||
while (Date.now() < deadline) {
|
||||
const result = await this.client.listTerminals(this.tempRepo.path);
|
||||
const terminal = result.terminals.find((entry) => entry.id === input.terminalId);
|
||||
if ((terminal?.activity?.state ?? null) === input.state) {
|
||||
const activity = terminal?.activity ?? null;
|
||||
const attentionMatches =
|
||||
input.attentionReason === undefined ||
|
||||
(activity?.attentionReason ?? null) === input.attentionReason;
|
||||
if ((activity?.state ?? null) === input.state && attentionMatches) {
|
||||
return;
|
||||
}
|
||||
await sleep(50);
|
||||
}
|
||||
const attentionSuffix =
|
||||
input.attentionReason === undefined
|
||||
? ""
|
||||
: ` with attention ${input.attentionReason ?? "none"}`;
|
||||
throw new Error(
|
||||
`Timed out waiting for terminal ${input.terminalId} activity state ${input.state ?? "unknown"}`,
|
||||
`Timed out waiting for terminal ${input.terminalId} activity state ${input.state ?? "unknown"}${attentionSuffix}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { test, expect, type Page } from "./fixtures";
|
||||
import { TerminalE2EHarness, type TerminalInstance } from "./helpers/terminal-dsl";
|
||||
|
||||
type HookActivityState = "running" | "idle" | "needs-input";
|
||||
type TabStatusBucket = "running" | "needs_input" | "none";
|
||||
type TabStatusBucket = "running" | "needs_input" | "attention" | "none";
|
||||
|
||||
const TERMINAL_ACTIVITY_REPORTER_SCRIPT = `
|
||||
const fs = require("node:fs");
|
||||
@@ -52,16 +52,21 @@ async function reportActivity(state) {
|
||||
});
|
||||
`;
|
||||
|
||||
function internalActivityState(state: HookActivityState): "working" | "idle" | "attention" {
|
||||
function internalActivityState(state: HookActivityState): "working" | "idle" {
|
||||
if (state === "running") return "working";
|
||||
if (state === "needs-input") return "attention";
|
||||
return "idle";
|
||||
}
|
||||
|
||||
function tabStatusBucket(state: HookActivityState): TabStatusBucket {
|
||||
if (state === "running") return "running";
|
||||
if (state === "needs-input") return "needs_input";
|
||||
return "none";
|
||||
return "attention";
|
||||
}
|
||||
|
||||
function expectedAttentionReason(state: HookActivityState): "finished" | "needs_input" | null {
|
||||
if (state === "idle") return "finished";
|
||||
if (state === "needs-input") return "needs_input";
|
||||
return null;
|
||||
}
|
||||
|
||||
function terminalTab(page: Page, terminalId: string) {
|
||||
@@ -96,6 +101,7 @@ class ControlledActivityTerminal {
|
||||
await this.harness.waitForTerminalActivity({
|
||||
terminalId: this.terminal.id,
|
||||
state: internalActivityState(state),
|
||||
attentionReason: expectedAttentionReason(state),
|
||||
timeoutMs: 15_000,
|
||||
});
|
||||
}
|
||||
@@ -166,6 +172,7 @@ test.describe("Terminal activity indicators", () => {
|
||||
await harness.waitForTerminalActivity({
|
||||
terminalId: activityTerminal.terminal.id,
|
||||
state: "idle",
|
||||
attentionReason: null,
|
||||
timeoutMs: 15_000,
|
||||
});
|
||||
await expectTerminalTabStatus(page, activityTerminal.terminal.id, "none");
|
||||
|
||||
Reference in New Issue
Block a user