Doubao-powered voice input for Linux, Wayland and Omarchy
ci: run Midscene inside Omarchy VM
quanru4a1c5806e2c7
diff --git a/.github/workflows/midscene-experimental.yml b/.github/workflows/midscene-experimental.ymlindex 4f580ca..9541f9c 100644--- a/.github/workflows/midscene-experimental.yml+++ b/.github/workflows/midscene-experimental.yml@@ -18,9 +18,17 @@ concurrency:jobs:omarchy-vm:- name: Install real Omarchy in a headless VM+ name: Run Midscene in a real Omarchy VMruns-on: ubuntu-latesttimeout-minutes: 70+ env:+ MIDSCENE_MODEL_API_KEY: ${{ secrets.MIDSCENE_MODEL_API_KEY }}+ MIDSCENE_MODEL_NAME: ${{ secrets.MIDSCENE_MODEL_NAME }}+ MIDSCENE_MODEL_BASE_URL: ${{ secrets.MIDSCENE_MODEL_BASE_URL }}+ MIDSCENE_MODEL_FAMILY: ${{ secrets.MIDSCENE_MODEL_FAMILY }}+ MIDSCENE_MODEL_REASONING_ENABLED: ${{ secrets.MIDSCENE_MODEL_REASONING_ENABLED }}+ MIDSCENE_COMPUTER_HEADLESS_LINUX: "true"+ MIDSCENE_REPLANNING_CYCLE_LIMIT: "40"steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:@@ -29,6 +37,28 @@ jobs:- name: Install Omarchy VMrun: tests/midscene/install-omarchy-vm.sh+ - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0+ with:+ node-version: "22"+ cache: npm+ cache-dependency-path: tests/midscene/package-lock.json++ - name: Require Midscene model configuration+ run: |+ test -n "$MIDSCENE_MODEL_API_KEY"+ test -n "$MIDSCENE_MODEL_NAME"+ test -n "$MIDSCENE_MODEL_BASE_URL"+ test -n "$MIDSCENE_MODEL_FAMILY"++ - name: Install Midscene and VNC bridge+ run: |+ sudo apt-get install -y --no-install-recommends \+ fluxbox tigervnc-viewer x11-xserver-utils xvfb+ npm --prefix tests/midscene ci --include=optional --ignore-scripts++ - name: Run real Omarchy Midscene E2E+ run: tests/midscene/run-omarchy-midscene.sh+- name: Upload installer evidenceif: always()uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1@@ -37,3 +67,12 @@ jobs:path: .midscene-omarchy/omarchy-iso/test-runs/**/runs/**if-no-files-found: warnretention-days: 3++ - name: Upload Omarchy Midscene report+ if: always()+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: omarchy-midscene-e2e-report+ path: tests/midscene/midscene_run/+ if-no-files-found: warn+ retention-days: 7diff --git a/tests/midscene/README.md b/tests/midscene/README.mdindex ffded83..dedce09 100644--- a/tests/midscene/README.md+++ b/tests/midscene/README.md@@ -21,13 +21,15 @@ Omarchy 4.0.3 was installed successfully on a GitHub-hosted runner inThe run took 13 minutes 41 seconds, including about 55 seconds to transfer theISO.-After that probe is stable, the next stages are:+The manual experimental workflow now continues from that installed base image:1. Boot a throwaway overlay from the installed base image.-2. install and enable this checkout as `md.lifeos.doubao-say` in the guest.+2. Copy this checkout to `md.lifeos.doubao-say` in the guest and run Omarchy's+ plugin validator.3. Run deterministic GTK UI fixtures with `@midscene/computer` on ordinaryUbuntu for every trusted change.-4. Run a smaller Omarchy/Hyprland Midscene suite manually in the guest.+4. Run the same focused Midscene onboarding suite through VNC in the real+ Omarchy/Hyprland guest session.The ordinary Ubuntu stage maps the real GTK onboarding window inside theheadless Midscene desktop. Its synthetic fixture performs no login, recording,diff --git a/tests/midscene/e2e/omarchy-onboarding.test.ts b/tests/midscene/e2e/omarchy-onboarding.test.tsnew file mode 100644index 0000000..4710066--- /dev/null+++ b/tests/midscene/e2e/omarchy-onboarding.test.ts@@ -0,0 +1,94 @@+import { spawn, type ChildProcess } from 'node:child_process';+import { afterAll, beforeAll, describe, it, vi } from 'vitest';+import {+ type ComputerAgent,+ agentFromComputer,+} from '@midscene/computer';++vi.setConfig({ testTimeout: 8 * 60 * 1000, hookTimeout: 2 * 60 * 1000 });++const sleep = (milliseconds: number) =>+ new Promise((resolvePromise) => setTimeout(resolvePromise, milliseconds));++const stopProcessGroup = (child?: ChildProcess) => {+ if (!child?.pid) return;+ try {+ process.kill(-child.pid, 'SIGTERM');+ } catch {+ // The viewer may already have exited after a test failure.+ }+};++describe.skipIf(process.env.OMARCHY_E2E !== 'true')(+ 'Doubao Say onboarding on Omarchy',+ () => {+ let agent: ComputerAgent;+ let fluxbox: ChildProcess;+ let viewer: ChildProcess;++ beforeAll(async () => {+ agent = await agentFromComputer({+ aiContexts: {+ aiAct:+ 'You are testing the English Doubao Say GTK onboarding window ' ++ 'inside a real Omarchy Hyprland virtual machine shown through a VNC viewer. ' ++ 'Interact only with the Doubao Say window and use visible labels.',+ },+ xvfbResolution: '1280x960x24',+ });++ fluxbox = spawn('fluxbox', [], {+ detached: true,+ stdio: 'ignore',+ env: process.env,+ });+ await sleep(1000);++ viewer = spawn(+ 'vncviewer',+ ['-FullScreen=1', '-RemoteResize=0', '-ViewOnly=0', '127.0.0.1:5905'],+ {+ detached: true,+ stdio: 'ignore',+ env: process.env,+ },+ );+ await sleep(4000);+ });++ afterAll(() => {+ stopProcessGroup(viewer);+ stopProcessGroup(fluxbox);+ });++ it('runs the onboarding flow in the real Omarchy desktop session', async () => {+ await agent.aiAct(+ 'Verify the Omarchy desktop visibly contains the Doubao Say window on the Microphone step with a Next button in its fixed top navigation.',+ );+ await agent.aiAct(+ 'Click Next in the Doubao Say fixed top navigation and wait until the current step is Trigger key.',+ );+ await agent.aiAct(+ 'Stay on the Trigger key step and do not click Previous or Next. Scroll down inside the light-gray central content panel until the Voice polishing heading and its controls are visible.',+ );+ await agent.aiAct(+ 'On the current Trigger key step, click Test endpoint in the visible Voice polishing section and wait for the endpoint result.',+ );+ await agent.aiAct(+ 'Verify a visible message says the endpoint works and includes Synthetic endpoint response.',+ );+ await agent.aiAct(+ 'Click Next in the fixed top navigation and wait for the Voice test step.',+ );+ await agent.aiAct(+ 'Verify the Voice test heading and introductory text are visible near the top of the content, proving that navigation reset the previous scroll position.',+ );+ await agent.aiAct(+ 'Scroll within the content if needed and click Finish setup.',+ );+ await agent.aiAct(+ 'Verify the Finish setup button changed to a disabled visible status saying Setup completed by the synthetic E2E fixture.',+ );+ });+ },+);diff --git a/tests/midscene/run-omarchy-midscene.sh b/tests/midscene/run-omarchy-midscene.shnew file mode 100755index 0000000..87a4995--- /dev/null+++ b/tests/midscene/run-omarchy-midscene.sh@@ -0,0 +1,110 @@+#!/bin/bash+set -euo pipefail++readonly ROOT_DIR="$PWD"+readonly WORK_DIR="$ROOT_DIR/.midscene-omarchy"+readonly HARNESS_DIR="$WORK_DIR/omarchy-iso"+readonly ISO_PATH="$WORK_DIR/omarchy-4.0.3.iso"+readonly BASE_DIR="$HARNESS_DIR/test-runs/omarchy-4.0.3"+readonly SSH_KEY="$BASE_DIR/id_ed25519"+readonly SSH_PORT=2222+readonly PLUGIN_DIR="/home/omarchy/.config/omarchy/plugins/md.lifeos.doubao-say"+readonly SHIM_DIR="$(mktemp -d)"++VM_PID=""++cleanup() {+ if [[ -n $VM_PID ]]; then+ kill "$VM_PID" 2>/dev/null || true+ fi+ rm -rf "$SHIM_DIR"+}+trap cleanup EXIT++ssh_guest() {+ ssh -i "$SSH_KEY" -p "$SSH_PORT" \+ -o BatchMode=yes \+ -o IdentitiesOnly=yes \+ -o StrictHostKeyChecking=no \+ -o UserKnownHostsFile=/dev/null \+ -o ConnectTimeout=10 \+ -o LogLevel=ERROR \+ [email protected] "$@"+}++ssh_session() {+ local command="$1"+ ssh_guest "export XDG_RUNTIME_DIR=/run/user/\$(id -u); \+ export DBUS_SESSION_BUS_ADDRESS=unix:path=\$XDG_RUNTIME_DIR/bus; \+ export HYPRLAND_INSTANCE_SIGNATURE=\$(ls -t \$XDG_RUNTIME_DIR/hypr | head -1); \+ export WAYLAND_DISPLAY=\$(find \$XDG_RUNTIME_DIR -maxdepth 1 -name 'wayland-*' ! -name '*.lock' -printf '%f\\n' | head -1); \+ export OMARCHY_PATH=/usr/share/omarchy; \+ export PATH=\$OMARCHY_PATH/bin:\$PATH; \+ $command" </dev/null+}++test -s "$ISO_PATH"+test -s "$BASE_DIR/base.qcow2"+test -s "$SSH_KEY"++# Reuse the pinned official harness's VM, login and session routines. Replace+# only its post-login acceptance body so this job can hand the live desktop to+# Midscene instead of running Omarchy's unrelated upstream acceptance suite.+readonly SESSION_HARNESS="$HARNESS_DIR/bin/omarchy-midscene-session"+cp "$HARNESS_DIR/bin/omarchy-iso-test" "$SESSION_HARNESS"+sed -i '/^acceptance_phase() {/,/^}/c\+acceptance_phase() {\+ log "Booting Omarchy session for Doubao Say Midscene E2E"\+ qemu-img create -f qcow2 -b "$BASE_DISK" -F qcow2 "$RUN_DIR/run.qcow2" >/dev/null\+ start_vm "$RUN_DIR/run.qcow2" "$RUN_DIR/serial.log"\+ establish_session\+ capture_console "success-session-ready-for-midscene"\+}' "$SESSION_HARNESS"++printf '#!/bin/sh\nexit 0\n' >"$SHIM_DIR/omarchy-pkg-add"+printf '#!/bin/sh\nexec convert "$@"\n' >"$SHIM_DIR/magick"+chmod 0755 "$SHIM_DIR/omarchy-pkg-add" "$SHIM_DIR/magick"++PATH="$SHIM_DIR:$PATH" "$SESSION_HARNESS" "$ISO_PATH" \+ --reuse-base \+ --keep-running \+ --memory 4096 \+ --no-preview++readonly RUN_DIR="$(find "$BASE_DIR/runs" -mindepth 1 -maxdepth 1 -type d | sort | tail -1)"+VM_PID="$(cat "$RUN_DIR/qemu.pid")"+kill -0 "$VM_PID"++# Put this exact checkout at its real Omarchy plugin location, validate the+# manifest with Omarchy, then launch the deterministic GTK fixture in the+# guest's actual Hyprland session.+tar -C "$ROOT_DIR" --exclude='__pycache__' -cf - \+ LICENSE README.md manifest.json install.sh install-user.sh setup-omarchy.sh start.sh \+ omarchy src tests/midscene/gtk_fixture.py | \+ ssh_guest "rm -rf '$PLUGIN_DIR' && mkdir -p '$PLUGIN_DIR' && tar -C '$PLUGIN_DIR' -xf -"++ssh_session "omarchy plugin validate '$PLUGIN_DIR'"+ssh_session "rm -rf /tmp/doubao-midscene-config; \+ mkdir -p /tmp/doubao-midscene-config; \+ export PYTHONPATH='$PLUGIN_DIR/src'; \+ export XDG_CONFIG_HOME=/tmp/doubao-midscene-config; \+ export PYTHONDONTWRITEBYTECODE=1; \+ setsid -f python3 '$PLUGIN_DIR/tests/midscene/gtk_fixture.py' \+ >/tmp/doubao-midscene-fixture.log 2>&1"++for _attempt in $(seq 1 30); do+ if ssh_session "grep -q 'READY: synthetic Doubao Say GTK fixture' /tmp/doubao-midscene-fixture.log && \+ hyprctl -j clients | jq -e '[.[] | select(.title == \"Doubao Say\")] | length == 1'" \+ >/dev/null 2>&1; then+ break+ fi+ sleep 2+done++ssh_session "grep -q 'READY: synthetic Doubao Say GTK fixture' /tmp/doubao-midscene-fixture.log"+ssh_session "hyprctl -j clients | jq -e '[.[] | select(.title == \"Doubao Say\")] | length == 1'"++OMARCHY_E2E=true npm --prefix tests/midscene test -- \+ e2e/omarchy-onboarding.test.ts++ssh_session "hyprctl -j clients | jq -e '[.[] | select(.title == \"Doubao Say\")] | length == 1'"