From dd2be2dd350b440b6ab017d41c1ca79bbf56cb1b Mon Sep 17 00:00:00 2001 From: Antuz tap Date: Thu, 22 Oct 2026 18:32:03 +0000 Subject: [PATCH 1/6] ci: exercise existing Desktop QA artifact in disposable cloud macOS --- .github/scripts/desktop_qa_cloud_smoke.mjs | 94 ++++++++++++++++++++ .github/scripts/desktop_qa_screen.swift | 26 ++++++ .github/workflows/desktop-qa-cloud-smoke.yml | 83 +++++++++++++++++ 3 files changed, 203 insertions(+) create mode 100644 .github/scripts/desktop_qa_cloud_smoke.mjs create mode 100644 .github/scripts/desktop_qa_screen.swift create mode 100644 .github/workflows/desktop-qa-cloud-smoke.yml diff --git a/.github/scripts/desktop_qa_cloud_smoke.mjs b/.github/scripts/desktop_qa_cloud_smoke.mjs new file mode 100644 index 0000000..4ad464b --- /dev/null +++ b/.github/scripts/desktop_qa_cloud_smoke.mjs @@ -0,0 +1,94 @@ +// Disposable Desktop-only smoke. No phone, signer, wallet data or signing action. +import { createCipheriv, randomBytes } from 'node:crypto'; +import { createRequire } from 'node:module'; +import { execFileSync, spawn } from 'node:child_process'; +import { readFileSync, writeFileSync, rmSync, mkdirSync } from 'node:fs'; +import { join } from 'node:path'; + +const requireClient = createRequire(join(process.env.CLIENT_DIR, 'package.json')); +const { io } = requireClient('socket.io-client'); +const temp = process.env.RUNNER_TEMP; +const evidence = process.env.EVIDENCE_DIR; +const screenTool = join(temp, 'desktop-qa-screen'); +const screenshot = join(temp, 'desktop-private-screen.png'); +const report = { + source: 'ef050663d33be51f25fb10310d5a0549b111e273', artifact_id: 11615331902, + workflow_run_id: 37928395053, state: 'INCOMPLETE', tests: {}, + limits: 'Desktop-only disposable cloud smoke; phone pairing, QR camera scanning, reconnect/retry/rotation matrix, physical signer and PSBT round trip NOT RUN. No Continue click, wallet data, signing or broadcast.', +}; +let app; +let socket; +let launchError = false; +const pause = ms => new Promise(resolve => setTimeout(resolve, ms)); +const record = (name, ok) => { report.tests[name] = ok ? 'PASS' : 'FAIL'; if (!ok) throw new Error(name); }; +function inspect() { + execFileSync('/usr/sbin/screencapture', ['-x', '-t', 'png', screenshot], { stdio: 'ignore' }); + return JSON.parse(execFileSync(screenTool, [screenshot], { encoding: 'utf8' })); +} +function includes(view, value) { return view.text.some(item => item.text.toLowerCase().includes(value.toLowerCase())); } +async function until(check, label, seconds = 35) { + const end = Date.now() + seconds * 1000; + while (Date.now() < end) { + const view = inspect(); + if (check(view)) return view; + await pause(1000); + } + throw new Error(label); +} +function encrypt(key, data) { + const iv = randomBytes(12); + const cipher = createCipheriv('aes-256-gcm', Buffer.from(key, 'hex'), iv); + const encrypted = Buffer.concat([cipher.update(JSON.stringify(data)), cipher.final()]); + return { iv: iv.toString('hex'), encryptedData: encrypted.toString('hex'), authTag: cipher.getAuthTag().toString('hex') }; +} +try { + mkdirSync(evidence, { recursive: true }); + app = spawn(process.env.APP_BINARY, [], { stdio: 'ignore' }); + app.on('error', () => { launchError = true; }); + await pause(2000); + record('native_process_launch', !launchError && Boolean(app.pid) && app.exitCode === null); + const welcome = await until(view => includes(view, 'Get Started'), 'Welcome/channel readiness unavailable'); + record('live_channel_welcome_ready', true); + const button = welcome.text.find(item => item.text.toLowerCase().includes('get started')); + // Match screenshot pixel coordinates to the current display logical dimensions. + const display = execFileSync('/usr/bin/swift', ['-e', 'import AppKit; let f=NSScreen.main!.frame; print("\(f.width) \(f.height)")'], {encoding: 'utf8'}).trim().split(' ').map(Number); + execFileSync(screenTool, ['click', String(button.x * display[0] / welcome.width), String(button.y * display[1] / welcome.height)], { stdio: 'ignore' }); + const paired = await until(view => view.qr.some(value => /^[0-9a-f]{64}$/.test(value)), 'QR readiness/click unavailable'); + const key = paired.qr.find(value => /^[0-9a-f]{64}$/.test(value)); + const { createHash } = await import('node:crypto'); + const room = createHash('sha256').update(key).digest('hex'); + record('fresh_qr_rendered', true); + socket = io('https://channel.bitcoinkeeper.app/', { transports: ['websocket', 'polling'], reconnection: false, timeout: 15000 }); + await new Promise((resolve, reject) => { socket.once('connect', resolve); socket.once('connect_error', () => reject(new Error('Disposable channel sender unavailable'))); }); + const send = requestData => socket.emit('JOIN_CHANNEL', { room, network: 'TESTNET', requestData }); + const request = { action: 'ADD_DEVICE', signerType: 'LEDGER', accountNumber: 0 }; + const altered = encrypt(key, request); + altered.authTag = (altered.authTag[0] === '0' ? '1' : '0') + altered.authTag.slice(1); + send(altered); + await pause(3000); + const rejected = inspect(); + record('altered_tag_keeps_qr_without_connect_modal', rejected.qr.includes(key) && !includes(rejected, 'Connect Ledger')); + send({ action: 'ADD_DEVICE', signerType: 'LEDGER' }); + await pause(2000); + const plain = inspect(); + record('plaintext_keeps_qr_without_connect_modal', plain.qr.includes(key) && !includes(plain, 'Connect Ledger')); + send(encrypt(key, { action: 'ADD_DEVICE' })); + const malformed = await until(view => includes(view, 'Signer type was not provided'), 'Authenticated malformed-action error unavailable', 15); + record('malformed_authenticated_action_shows_error_without_connect_modal', !includes(malformed, 'Connect Ledger')); + send(encrypt(key, request)); + const valid = await until(view => includes(view, 'Connect Ledger'), 'Valid encrypted request did not open Connect Ledger', 15); + record('valid_encrypted_add_device_opens_connect_ledger', !includes(valid, 'Signer type was not provided')); + record('native_process_remains_running', app.exitCode === null); + report.state = 'PASSED_DESKTOP_ONLY'; +} catch (error) { + // Only fixed labels are emitted; screen contents, QR keys and rooms stay private. + report.state = 'BLOCKED_OR_FAILED'; + report.failure = String(error.message).slice(0, 200); + process.exitCode = 1; +} finally { + socket?.disconnect(); + app?.kill('SIGTERM'); + rmSync(screenshot, { force: true }); + writeFileSync(join(evidence, 'desktop-cloud-smoke.json'), JSON.stringify(report, null, 2) + '\n'); + console.log(JSON.stringify(report, null, 2)); +} diff --git a/.github/scripts/desktop_qa_screen.swift b/.github/scripts/desktop_qa_screen.swift new file mode 100644 index 0000000..42b7f61 --- /dev/null +++ b/.github/scripts/desktop_qa_screen.swift @@ -0,0 +1,26 @@ +import AppKit +import Vision +import CoreGraphics + +if CommandLine.arguments.count == 4 && CommandLine.arguments[1] == "click" { + guard let x = Double(CommandLine.arguments[2]), let y = Double(CommandLine.arguments[3]) else { fatalError("Invalid click") } + let point = CGPoint(x: x, y: y) + CGEvent(mouseEventSource: nil, mouseType: .leftMouseDown, mouseCursorPosition: point, mouseButton: .left)?.post(tap: .cghidEventTap) + CGEvent(mouseEventSource: nil, mouseType: .leftMouseUp, mouseCursorPosition: point, mouseButton: .left)?.post(tap: .cghidEventTap) +} else { + guard CommandLine.arguments.count == 2, let image = NSImage(contentsOfFile: CommandLine.arguments[1]), + let cg = image.cgImage(forProposedRect: nil, context: nil, hints: nil) else { fatalError("Expected screenshot") } + let text = VNRecognizeTextRequest() + text.recognitionLevel = .accurate + let barcodes = VNDetectBarcodesRequest() + barcodes.symbologies = [.qr] + try VNImageRequestHandler(cgImage: cg).perform([text, barcodes]) + let words: [[String: Any]] = (text.results ?? []).compactMap { observation in + guard let candidate = observation.topCandidates(1).first else { return nil } + let b = observation.boundingBox + return ["text": candidate.string, "x": b.midX * Double(cg.width), "y": (1 - b.midY) * Double(cg.height)] + } + let values = (barcodes.results ?? []).compactMap { $0.payloadStringValue } + let value: [String: Any] = ["text": words, "qr": values, "width": cg.width, "height": cg.height] + FileHandle.standardOutput.write(try JSONSerialization.data(withJSONObject: value)) +} diff --git a/.github/workflows/desktop-qa-cloud-smoke.yml b/.github/workflows/desktop-qa-cloud-smoke.yml new file mode 100644 index 0000000..7032842 --- /dev/null +++ b/.github/workflows/desktop-qa-cloud-smoke.yml @@ -0,0 +1,83 @@ +name: Desktop disposable cloud acceptance + +# Deliberately distinct from release/dev-release: never activates PGP workflow_run. +on: + push: + branches: [codex/r4-desktop-cloud-smoke-20261022] + paths: + - .github/workflows/desktop-qa-cloud-smoke.yml + - .github/scripts/desktop_qa_* + +permissions: + contents: read + actions: read + +jobs: + existing-qa-smoke: + runs-on: macos-latest + timeout-minutes: 12 + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + persist-credentials: false + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 + with: + node-version: '22' + - name: Fetch immutable existing QA artifact and verify source identity + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + umask 077 + mkdir -p "$RUNNER_TEMP/desktop-qa" "$RUNNER_TEMP/desktop-evidence" + gh api repos/KeeperCommunity/keeper-desktop/actions/artifacts/11615331902 > "$RUNNER_TEMP/desktop-qa/artifact.json" + python3 - "$RUNNER_TEMP/desktop-qa/artifact.json" <<'PY' + import json,sys + a=json.load(open(sys.argv[1])) + assert a['id']==11615331902 and not a['expired'] + assert a['workflow_run']['id']==37928395053 + assert a['workflow_run']['head_sha']=='ef050663d33be51f25fb10310d5a0549b111e273' + PY + gh api repos/KeeperCommunity/keeper-desktop/actions/artifacts/11615331902/zip > "$RUNNER_TEMP/desktop-qa/original.zip" + echo "2a3ca33dd9a539323f41639d98fb36ab8d2cdc670f1b17b20f861b3528eaeea5 $RUNNER_TEMP/desktop-qa/original.zip" | shasum -a 256 -c - + ditto -x -k "$RUNNER_TEMP/desktop-qa/original.zip" "$RUNNER_TEMP/desktop-qa" + echo "9ae0c39eefafd85a9234bf7a599f75e3b13a481ab0ad7f9418eee66990c34a69 $RUNNER_TEMP/desktop-qa/keeper-desktop-r3-qa.zip" | shasum -a 256 -c - + ditto -x -k "$RUNNER_TEMP/desktop-qa/keeper-desktop-r3-qa.zip" "$RUNNER_TEMP/desktop-qa" + python3 - "$RUNNER_TEMP/desktop-qa" "$RUNNER_TEMP/desktop-evidence" <<'PY' + import hashlib,json,plistlib,sys + from pathlib import Path + base=Path(sys.argv[1]); app=base/'Keeper Desktop R3 QA.app' + info=plistlib.loads((app/'Contents/Info.plist').read_bytes()) + binary=(app/'Contents/MacOS'/info['CFBundleExecutable']).read_bytes() + assert info['CFBundleIdentifier']=='com.keeper.desktop.r3qa' + assert info['CFBundleShortVersionString']=='0.2.6-qa.1' + assert hashlib.sha256(binary).hexdigest()=='13e252b7a7f339d24e327d8d14d7956946f21b929c037970edffa9e6e90fcb70' + assert b'https://channel.bitcoinkeeper.app/' in binary + assert b'https://keeper-channel.herokuapp.com/' not in binary + evidence=json.loads((base/'desktop-qa-evidence.json').read_text()) + assert evidence['source']=='ef050663d33be51f25fb10310d5a0549b111e273' + (Path(sys.argv[2])/'original-artifact-evidence.json').write_text(json.dumps(evidence,indent=2)+'\n') + PY + codesign --verify --deep --strict "$RUNNER_TEMP/desktop-qa/Keeper Desktop R3 QA.app" + uname -m > "$RUNNER_TEMP/desktop-evidence/runner-architecture.txt" + echo 'Artifact bytes, separate QA identity, live endpoint and strict deep code signature PASS.' >> "$GITHUB_STEP_SUMMARY" + - name: Prepare disposable native screen reader and sender + run: | + set -euo pipefail + swiftc .github/scripts/desktop_qa_screen.swift -o "$RUNNER_TEMP/desktop-qa-screen" + mkdir -p "$RUNNER_TEMP/desktop-client" + npm install --prefix "$RUNNER_TEMP/desktop-client" --ignore-scripts --no-audit --no-fund socket.io-client@4.8.1 + - name: Launch exact QA app and exercise disposable channel packets + env: + APP_BINARY: ${{ runner.temp }}/desktop-qa/Keeper Desktop R3 QA.app/Contents/MacOS/Keeper Desktop R3 QA + CLIENT_DIR: ${{ runner.temp }}/desktop-client + EVIDENCE_DIR: ${{ runner.temp }}/desktop-evidence + run: node .github/scripts/desktop_qa_cloud_smoke.mjs + - name: Preserve only sanitized outcomes + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: desktop-disposable-cloud-acceptance-${{ github.sha }} + path: ${{ runner.temp }}/desktop-evidence/ + retention-days: 30 + if-no-files-found: error From 1d26d1bd80ecb17f7bc17d6ca86108dfb3bd6ea9 Mon Sep 17 00:00:00 2001 From: Antuz tap Date: Thu, 22 Oct 2026 18:34:09 +0000 Subject: [PATCH 2/6] ci: keep native smoke error reports limited to fixed labels --- .github/scripts/desktop_qa_cloud_smoke.mjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/scripts/desktop_qa_cloud_smoke.mjs b/.github/scripts/desktop_qa_cloud_smoke.mjs index 4ad464b..5997a67 100644 --- a/.github/scripts/desktop_qa_cloud_smoke.mjs +++ b/.github/scripts/desktop_qa_cloud_smoke.mjs @@ -83,7 +83,14 @@ try { } catch (error) { // Only fixed labels are emitted; screen contents, QR keys and rooms stay private. report.state = 'BLOCKED_OR_FAILED'; - report.failure = String(error.message).slice(0, 200); + const label = String(error.message); + const fixedLabels = new Set([ + ...Object.keys(report.tests), + 'Welcome/channel readiness unavailable', 'QR readiness/click unavailable', + 'Disposable channel sender unavailable', 'Authenticated malformed-action error unavailable', + 'Valid encrypted request did not open Connect Ledger', + ]); + report.failure = fixedLabels.has(label) ? label : 'Cloud runner/tool failure; no private UI data preserved'; process.exitCode = 1; } finally { socket?.disconnect(); From 49927b13e6e78f1f1a9ad58ccb4fee8d9e4ae55d Mon Sep 17 00:00:00 2001 From: Antuz tap Date: Thu, 22 Oct 2026 18:34:44 +0000 Subject: [PATCH 3/6] ci: record immutable cloud smoke execution provenance --- .github/scripts/desktop_qa_cloud_smoke.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/desktop_qa_cloud_smoke.mjs b/.github/scripts/desktop_qa_cloud_smoke.mjs index 5997a67..e8407f2 100644 --- a/.github/scripts/desktop_qa_cloud_smoke.mjs +++ b/.github/scripts/desktop_qa_cloud_smoke.mjs @@ -13,6 +13,7 @@ const screenTool = join(temp, 'desktop-qa-screen'); const screenshot = join(temp, 'desktop-private-screen.png'); const report = { source: 'ef050663d33be51f25fb10310d5a0549b111e273', artifact_id: 11615331902, + tooling_source: process.env.GITHUB_SHA, cloud_run_id: process.env.GITHUB_RUN_ID, runner_architecture: process.arch, workflow_run_id: 37928395053, state: 'INCOMPLETE', tests: {}, limits: 'Desktop-only disposable cloud smoke; phone pairing, QR camera scanning, reconnect/retry/rotation matrix, physical signer and PSBT round trip NOT RUN. No Continue click, wallet data, signing or broadcast.', }; From cd36015fe545e59dd000745e4179253c4867a082 Mon Sep 17 00:00:00 2001 From: Antuz tap Date: Thu, 22 Oct 2026 18:37:08 +0000 Subject: [PATCH 4/6] ci: use CPU Vision processing on virtual macOS graphics --- .github/scripts/desktop_qa_cloud_smoke.mjs | 8 +++++++- .github/scripts/desktop_qa_screen.swift | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/scripts/desktop_qa_cloud_smoke.mjs b/.github/scripts/desktop_qa_cloud_smoke.mjs index e8407f2..7e88d90 100644 --- a/.github/scripts/desktop_qa_cloud_smoke.mjs +++ b/.github/scripts/desktop_qa_cloud_smoke.mjs @@ -23,8 +23,14 @@ let launchError = false; const pause = ms => new Promise(resolve => setTimeout(resolve, ms)); const record = (name, ok) => { report.tests[name] = ok ? 'PASS' : 'FAIL'; if (!ok) throw new Error(name); }; function inspect() { + report.tool_stage = 'capture_screenshot'; execFileSync('/usr/sbin/screencapture', ['-x', '-t', 'png', screenshot], { stdio: 'ignore' }); - return JSON.parse(execFileSync(screenTool, [screenshot], { encoding: 'utf8' })); + report.tool_stage = 'vision_ocr_and_barcode'; + const raw = execFileSync(screenTool, [screenshot], { encoding: 'utf8' }); + report.tool_stage = 'parse_screen_reader_json'; + const view = JSON.parse(raw); + report.tool_stage = 'screen_reader_ready'; + return view; } function includes(view, value) { return view.text.some(item => item.text.toLowerCase().includes(value.toLowerCase())); } async function until(check, label, seconds = 35) { diff --git a/.github/scripts/desktop_qa_screen.swift b/.github/scripts/desktop_qa_screen.swift index 42b7f61..5347ed1 100644 --- a/.github/scripts/desktop_qa_screen.swift +++ b/.github/scripts/desktop_qa_screen.swift @@ -12,8 +12,11 @@ if CommandLine.arguments.count == 4 && CommandLine.arguments[1] == "click" { let cg = image.cgImage(forProposedRect: nil, context: nil, hints: nil) else { fatalError("Expected screenshot") } let text = VNRecognizeTextRequest() text.recognitionLevel = .accurate + // GitHub macOS VMs lack the physical scaler/Metal compute device. + text.usesCPUOnly = true let barcodes = VNDetectBarcodesRequest() barcodes.symbologies = [.qr] + barcodes.usesCPUOnly = true try VNImageRequestHandler(cgImage: cg).perform([text, barcodes]) let words: [[String: Any]] = (text.results ?? []).compactMap { observation in guard let candidate = observation.topCandidates(1).first else { return nil } From ed2220bf751c2e03dd4b4faabce28051c09a5ad3 Mon Sep 17 00:00:00 2001 From: Antuz tap Date: Thu, 22 Oct 2026 18:41:39 +0000 Subject: [PATCH 5/6] ci: diagnose hosted GUI event and QR detection limits safely --- .github/scripts/desktop_qa_cloud_smoke.mjs | 6 ++++++ .github/scripts/desktop_qa_screen.swift | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/.github/scripts/desktop_qa_cloud_smoke.mjs b/.github/scripts/desktop_qa_cloud_smoke.mjs index 7e88d90..44061af 100644 --- a/.github/scripts/desktop_qa_cloud_smoke.mjs +++ b/.github/scripts/desktop_qa_cloud_smoke.mjs @@ -30,6 +30,11 @@ function inspect() { report.tool_stage = 'parse_screen_reader_json'; const view = JSON.parse(raw); report.tool_stage = 'screen_reader_ready'; + report.last_screen_flags = { + get_started: includes(view, 'Get Started'), scan_me: includes(view, 'Scan Me'), + connect_ledger: includes(view, 'Connect Ledger'), server_error: includes(view, 'Server Error'), + qr_payload_count: view.qr.length, qr_64hex_detected: view.qr.some(value => /^[0-9a-f]{64}$/.test(value)), + }; return view; } function includes(view, value) { return view.text.some(item => item.text.toLowerCase().includes(value.toLowerCase())); } @@ -56,6 +61,7 @@ try { record('native_process_launch', !launchError && Boolean(app.pid) && app.exitCode === null); const welcome = await until(view => includes(view, 'Get Started'), 'Welcome/channel readiness unavailable'); record('live_channel_welcome_ready', true); + report.native_event_permissions = JSON.parse(execFileSync(screenTool, ['permissions'], { encoding: 'utf8' })); const button = welcome.text.find(item => item.text.toLowerCase().includes('get started')); // Match screenshot pixel coordinates to the current display logical dimensions. const display = execFileSync('/usr/bin/swift', ['-e', 'import AppKit; let f=NSScreen.main!.frame; print("\(f.width) \(f.height)")'], {encoding: 'utf8'}).trim().split(' ').map(Number); diff --git a/.github/scripts/desktop_qa_screen.swift b/.github/scripts/desktop_qa_screen.swift index 5347ed1..bc2c38d 100644 --- a/.github/scripts/desktop_qa_screen.swift +++ b/.github/scripts/desktop_qa_screen.swift @@ -1,12 +1,16 @@ import AppKit import Vision import CoreGraphics +import ApplicationServices if CommandLine.arguments.count == 4 && CommandLine.arguments[1] == "click" { guard let x = Double(CommandLine.arguments[2]), let y = Double(CommandLine.arguments[3]) else { fatalError("Invalid click") } let point = CGPoint(x: x, y: y) CGEvent(mouseEventSource: nil, mouseType: .leftMouseDown, mouseCursorPosition: point, mouseButton: .left)?.post(tap: .cghidEventTap) CGEvent(mouseEventSource: nil, mouseType: .leftMouseUp, mouseCursorPosition: point, mouseButton: .left)?.post(tap: .cghidEventTap) +} else if CommandLine.arguments.count == 2 && CommandLine.arguments[1] == "permissions" { + let value = ["accessibility_trusted": AXIsProcessTrusted(), "post_events_authorized": CGPreflightPostEventAccess(), "screen_capture_authorized": CGPreflightScreenCaptureAccess()] + FileHandle.standardOutput.write(try JSONSerialization.data(withJSONObject: value)) } else { guard CommandLine.arguments.count == 2, let image = NSImage(contentsOfFile: CommandLine.arguments[1]), let cg = image.cgImage(forProposedRect: nil, context: nil, hints: nil) else { fatalError("Expected screenshot") } From 72c56adcb07fbe020094bee3625d899dd0ba8460 Mon Sep 17 00:00:00 2001 From: Antuz tap Date: Thu, 22 Oct 2026 18:44:34 +0000 Subject: [PATCH 6/6] ci: focus exact QA app and click settled native button bounds --- .github/scripts/desktop_qa_cloud_smoke.mjs | 19 ++++++++++++++++--- .github/scripts/desktop_qa_screen.swift | 7 +++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/scripts/desktop_qa_cloud_smoke.mjs b/.github/scripts/desktop_qa_cloud_smoke.mjs index 44061af..cb7973f 100644 --- a/.github/scripts/desktop_qa_cloud_smoke.mjs +++ b/.github/scripts/desktop_qa_cloud_smoke.mjs @@ -62,10 +62,23 @@ try { const welcome = await until(view => includes(view, 'Get Started'), 'Welcome/channel readiness unavailable'); record('live_channel_welcome_ready', true); report.native_event_permissions = JSON.parse(execFileSync(screenTool, ['permissions'], { encoding: 'utf8' })); - const button = welcome.text.find(item => item.text.toLowerCase().includes('get started')); - // Match screenshot pixel coordinates to the current display logical dimensions. + report.native_activation = JSON.parse(execFileSync(screenTool, ['activate', String(app.pid)], { encoding: 'utf8' })); + await pause(500); + // Compile/query display geometry before taking fresh, settled button bounds. const display = execFileSync('/usr/bin/swift', ['-e', 'import AppKit; let f=NSScreen.main!.frame; print("\(f.width) \(f.height)")'], {encoding: 'utf8'}).trim().split(' ').map(Number); - execFileSync(screenTool, ['click', String(button.x * display[0] / welcome.width), String(button.y * display[1] / welcome.height)], { stdio: 'ignore' }); + function clickGetStarted(view) { + const button = view.text.find(item => item.text.toLowerCase().includes('get started')); + execFileSync(screenTool, ['click', String(button.x * display[0] / view.width), String(button.y * display[1] / view.height)], { stdio: 'ignore' }); + } + const settled = await until(view => includes(view, 'Get Started'), 'Welcome/channel readiness unavailable', 10); + clickGetStarted(settled); + await pause(2000); + const afterClick = inspect(); + // One bounded first-mouse retry, only while the original welcome remains visible. + if (includes(afterClick, 'Get Started')) { + report.scoped_get_started_retry = true; + clickGetStarted(afterClick); + } const paired = await until(view => view.qr.some(value => /^[0-9a-f]{64}$/.test(value)), 'QR readiness/click unavailable'); const key = paired.qr.find(value => /^[0-9a-f]{64}$/.test(value)); const { createHash } = await import('node:crypto'); diff --git a/.github/scripts/desktop_qa_screen.swift b/.github/scripts/desktop_qa_screen.swift index bc2c38d..ee5de29 100644 --- a/.github/scripts/desktop_qa_screen.swift +++ b/.github/scripts/desktop_qa_screen.swift @@ -6,8 +6,15 @@ import ApplicationServices if CommandLine.arguments.count == 4 && CommandLine.arguments[1] == "click" { guard let x = Double(CommandLine.arguments[2]), let y = Double(CommandLine.arguments[3]) else { fatalError("Invalid click") } let point = CGPoint(x: x, y: y) + CGEvent(mouseEventSource: nil, mouseType: .mouseMoved, mouseCursorPosition: point, mouseButton: .left)?.post(tap: .cghidEventTap) + Thread.sleep(forTimeInterval: 0.15) CGEvent(mouseEventSource: nil, mouseType: .leftMouseDown, mouseCursorPosition: point, mouseButton: .left)?.post(tap: .cghidEventTap) + Thread.sleep(forTimeInterval: 0.15) CGEvent(mouseEventSource: nil, mouseType: .leftMouseUp, mouseCursorPosition: point, mouseButton: .left)?.post(tap: .cghidEventTap) +} else if CommandLine.arguments.count == 3 && CommandLine.arguments[1] == "activate" { + guard let pid = Int32(CommandLine.arguments[2]) else { fatalError("Expected PID") } + let activated = NSRunningApplication(processIdentifier: pid)?.activate(options: [.activateIgnoringOtherApps]) ?? false + FileHandle.standardOutput.write(try JSONSerialization.data(withJSONObject: ["activated_exact_app_pid": activated])) } else if CommandLine.arguments.count == 2 && CommandLine.arguments[1] == "permissions" { let value = ["accessibility_trusted": AXIsProcessTrusted(), "post_events_authorized": CGPreflightPostEventAccess(), "screen_capture_authorized": CGPreflightScreenCaptureAccess()] FileHandle.standardOutput.write(try JSONSerialization.data(withJSONObject: value))