Skip to content

Commit e5717b0

Browse files
committed
improvement(desktop): run the live desktop E2E against the merged background executor
- The dormancy check accepts the app's own registrations, refused while signed out and answered as not enabled once signed in, and still forbids inbox, doorbell, claim, lease and completion - The app and realtime server run in their own sessions and stop through stop-session.sh
1 parent 1dbcec9 commit e5717b0

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

‎.github/workflows/test-build.yml‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,19 @@ jobs:
510510
# Bundle only: `bun run build` also fetches the macOS node-pty prebuilds for packaging,
511511
# which a Linux run does not use.
512512
(cd apps/desktop && bun run scripts/build.ts)
513+
# Each app runs in its own session, and stop-session.sh returns once all of it has exited.
513514
(cd apps/realtime && PORT=3023 SIM_DB_ROLE=realtime ALLOWED_ORIGINS="$NEXT_PUBLIC_APP_URL" \
514-
exec bun src/index.ts > "$report_dir/desktop-tools-realtime.log" 2>&1) &
515+
exec setsid bun src/index.ts > "$report_dir/desktop-tools-realtime.log" 2>&1) &
515516
realtime_pid=$!
516-
(cd apps/sim && exec node ../../node_modules/next/dist/bin/next dev --hostname 127.0.0.1 \
517+
(cd apps/sim && exec setsid node ../../node_modules/next/dist/bin/next dev --hostname 127.0.0.1 \
517518
--port 3021 > "$report_dir/desktop-tools-next.log" 2>&1) &
518519
server_pid=$!
519520
finish() {
520-
kill "$server_pid" "$realtime_pid" 2>/dev/null || true
521+
status=$?
522+
bash "$GITHUB_WORKSPACE/.github/scripts/stop-session.sh" "$server_pid" || status=1
523+
bash "$GITHUB_WORKSPACE/.github/scripts/stop-session.sh" "$realtime_pid" || status=1
521524
wait "$server_pid" "$realtime_pid" 2>/dev/null || true
525+
exit "$status"
522526
}
523527
trap finish EXIT
524528
started=$SECONDS

‎apps/desktop/e2e/desktop-tools-live-sim.spec.ts‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,9 @@ test.describe('desktop tools against a live Sim', () => {
539539
typeof body.desktopCapabilities === 'object' && body.desktopCapabilities !== null
540540
? body.desktopCapabilities
541541
: {}
542-
body.desktopCapabilities = { ...desktop, deviceId, executor: 1 }
542+
// The app offers its own install when it speaks the executor protocol; otherwise offer
543+
// the device registered above, as such a desktop would.
544+
body.desktopCapabilities = { deviceId, executor: 1, ...desktop }
543545
})
544546

545547
let callId = ''
@@ -570,11 +572,20 @@ test.describe('desktop tools against a live Sim', () => {
570572
const [call] = await db.toolCalls(user.chats['Round trip'])
571573
expect(call).toMatchObject({ toolName: 'read_local_file', status: 'completed' })
572574
expect(call.persistSeq).not.toBeNull()
573-
// From launch on, only the foreground claim reaches the desktop routes: no registry, inbox,
574-
// lease or completion.
575-
const desktopRoutes = proxy.seen(since, '/api/desktop/').map((entry) => entry.path)
576-
expect(desktopRoutes.length).toBeGreaterThan(0)
577-
expect(new Set(desktopRoutes)).toEqual(new Set(['/api/desktop/tool/authorize']))
575+
// From launch on, the app only registers and claims the foreground call: no inbox, doorbell,
576+
// executor claim, lease or completion. It registers once signed out (refused) and again on
577+
// sign-in, which Sim answers as not enabled and does not record.
578+
const registeredSignedIn = () =>
579+
proxy
580+
.seen(since, '/api/desktop/devices')
581+
.some((entry) => entry.method === 'POST' && entry.status === 200)
582+
await expect.poll(registeredSignedIn, { timeout: 30_000 }).toBe(true)
583+
expect(await db.desktopDeviceCount(user.userId)).toBe(0)
584+
const desktopRequests = proxy.seen(since, '/api/desktop/')
585+
const desktopRoutes = new Set(desktopRequests.map((entry) => entry.path))
586+
expect(desktopRoutes).toContain('/api/desktop/tool/authorize')
587+
desktopRoutes.delete('/api/desktop/devices')
588+
expect(desktopRoutes).toEqual(new Set(['/api/desktop/tool/authorize']))
578589
expect(proxy.rewrittenChatBodies).toBeGreaterThan(0)
579590
expect(monitor.lines.length).toBeGreaterThan(0)
580591
expect(monitor.publishesTo('desktop:inbox')).toEqual([])

0 commit comments

Comments
 (0)