Skip to content

Doubao-powered voice input for Linux, Wayland and Omarchy

fix(e2e): stabilize Omarchy fixture input

quanru885763b72106
diff --git a/tests/e2e/midscene.config.ts b/tests/e2e/midscene.config.ts
index 84d6311..d346922 100644
--- a/tests/e2e/midscene.config.ts
+++ b/tests/e2e/midscene.config.ts
@@ -10,6 +10,7 @@ import { createMidsceneNodes } from '@midscene/test/midscene';
interface DesktopContext {
agent?: ComputerAgent;
createAgent: () => Promise<ComputerAgent>;
+ environment: 'ubuntu' | 'omarchy';
fixtureMode?: string;
resetFixture?: (mode: string) => Promise<void>;
barConfigBackup?: string;
@@ -17,6 +18,7 @@ interface DesktopContext {
}
const sleep = (ms: number) => new Promise((done) => setTimeout(done, ms));
+const shellQuote = (value: string) => `'${value.replaceAll("'", `'"'"'`)}'`;
const stop = async (child?: ChildProcess) => {
if (!child?.pid || child.exitCode !== null || child.signalCode !== null) return;
await new Promise<void>((done) => {
@@ -92,7 +94,11 @@ const setup = defineProjectSetup<DesktopContext>({
desktopReady = true;
return agent;
};
- const context: DesktopContext = { agent: await createAgent(), createAgent };
+ const context: DesktopContext = {
+ agent: await createAgent(),
+ createAgent,
+ environment: omarchy ? 'omarchy' : 'ubuntu',
+ };
onTeardown(() => context.agent?.destroy());
const fluxbox = spawn('fluxbox', [], { detached: true, stdio: 'ignore', env: process.env });
onTeardown(() => stop(fluxbox));
@@ -105,7 +111,17 @@ const setup = defineProjectSetup<DesktopContext>({
await sleep(4000);
if (!shell) {
const stopGuestFixture = () => {
- guest('if test -s /tmp/doubao-midscene-fixture.pid; then kill "$(cat /tmp/doubao-midscene-fixture.pid)" >/dev/null 2>&1 || true; fi; rm -f /tmp/doubao-midscene-fixture.pid');
+ guest([
+ 'if test -s /tmp/doubao-midscene-fixture.pid; then',
+ 'pid="$(cat /tmp/doubao-midscene-fixture.pid)";',
+ 'kill "$pid" >/dev/null 2>&1 || true;',
+ 'for wait_step in 1 2 3 4 5; do',
+ 'kill -0 "$pid" >/dev/null 2>&1 || break; sleep 0.2;',
+ 'done;',
+ 'kill -KILL "$pid" >/dev/null 2>&1 || true;',
+ 'fi;',
+ 'rm -f /tmp/doubao-midscene-fixture.pid',
+ ].join(' '));
};
onTeardown(stopGuestFixture);
context.resetFixture = async (mode) => {
@@ -117,7 +133,12 @@ const setup = defineProjectSetup<DesktopContext>({
if (ready === '1') return;
await sleep(2000);
}
- throw new Error('Omarchy GTK fixture did not become ready');
+ const fixtureLog = guest(
+ 'tail -n 80 /tmp/doubao-midscene-fixture.log 2>/dev/null || true',
+ );
+ throw new Error(
+ `Omarchy GTK fixture did not become ready:\n${fixtureLog || '<empty fixture log>'}`,
+ );
};
}
} else {
@@ -207,10 +228,21 @@ const inputTextField = defineNode<typeof inputText, void, DesktopContext>({
inputSchema: inputText,
async execute({ context, input }) {
if (!context.agent) throw new Error('Midscene Computer Agent is not active');
- await context.agent.aiInput(input.target, {
- value: input.value,
- mode: 'replace',
- });
+ if (context.environment === 'omarchy') {
+ // Midscene still finds and focuses the visual target. Send the text from
+ // inside the Wayland guest because X11 clipboard typing stops at the VNC
+ // boundary on some TigerVNC/GitHub runner combinations.
+ await context.agent.aiTap(input.target);
+ await sleep(250);
+ guest(
+ `wtype -M ctrl -k a -m ctrl; wtype ${shellQuote(input.value)}`,
+ );
+ } else {
+ await context.agent.aiInput(input.target, {
+ value: input.value,
+ mode: 'replace',
+ });
+ }
},
});
const openSystemMenu = defineNode<typeof empty, void, DesktopContext>({