Files
hermes-agent/apps/desktop/scripts/click-session.mjs
Brooklyn Nicholson 959c7649fd fix(updates/win): click-session poll, Intel-Mac installer docs, cua-driver opt-in autostart
click-session flake (#97982): a bare scrollIntoView() smooth scroll could be dropped under load, and the script
slept a fixed 3000ms before reading state. Extract click-session-helpers.mjs:
instant centered scroll, a bounded poll-for-composer loop instead of the
fixed sleep, and correct nested CDP envelope unwrapping (the old read logged
undefined).

Intel-Mac installer docs (#99033): the Hermes-Setup.dmg bootstrap installer
is built for Apple Silicon only, so Intel Macs hit "not supported on this
Mac". The desktop release pipeline already builds a native darwin-x64
bundle, so the docs now scope the arm64 limit to the bootstrap installer and
name the darwin-x64 bundle (or the CLI plus `hermes desktop`) as the Intel
path, in the desktop README and the platform-support build-targets section.

cua-driver autostart opt-in (#97389): Windows installs registered the
cua-driver-serve scheduled task on every install, with no opt-out, and
treated the task as an install-readiness requirement. Gate the
install-ready check and _repair_cua_driver_autostart_windows on the new
computer_use.autostart config key (default false = on-demand, fails
closed), extract the registration PowerShell into a testable helper, and
document the opt-in (EN + zh-Hans). Windows-only code path: unit tests
cover the registration args and the config gate; live Windows
verification pending.
2026-09-26 17:09:16 -05:00

62 lines
2.3 KiB
JavaScript

// Click on a session by partial title match.
//
// Two flake sources fixed (#97982): a bare scrollIntoView() whose smooth
// scroll could be dropped under load, and a fixed 3000ms post-click sleep
// that raced fast loads and wasted slow ones. The click now scrolls instantly
// ({ behavior: 'auto', block: 'center' }) and the post-click wait polls for
// the session's composer to mount — see click-session-helpers.mjs.
import {
buildFindClickExpression,
evaluateJsonValue,
pollUntil,
POST_CLICK_READY_EXPRESSION
} from './click-session-helpers.mjs'
const list = await (await fetch('http://127.0.0.1:9222/json/list')).json()
const tgt = list.find(t => t.type === 'page' && t.url.startsWith('http'))
const ws = new WebSocket(tgt.webSocketDebuggerUrl)
let id = 0
const pending = new Map()
ws.addEventListener('message', ev => {
const m = JSON.parse(ev.data)
if (m.id != null && pending.has(m.id)) {
pending.get(m.id)(m)
pending.delete(m.id)
}
})
await new Promise(r => ws.addEventListener('open', r))
const send = (method, params = {}) =>
new Promise(r => {
const i = ++id
pending.set(i, r)
ws.send(JSON.stringify({ id: i, method, params }))
})
const title = process.argv[2] || 'Phaser particle'
const r = await send('Runtime.evaluate', {
expression: buildFindClickExpression(title),
returnByValue: true
})
console.log('click raw:', JSON.stringify(r, null, 2))
// Wait for the clicked session's composer to mount — bounded polling, not a
// fixed sleep. `false` here means the session view never came up within the
// bound; the state read below then shows what the page actually looks like.
const ready = await pollUntil(send, POST_CLICK_READY_EXPRESSION)
console.log('post-click ready:', ready)
const status = await send('Runtime.evaluate', {
expression: `JSON.stringify({
url: location.href,
hasComposer: !!document.querySelector('[data-slot="composer-rich-input"]'),
threadMessages: document.querySelectorAll('[data-slot="aui_message"]').length,
bodyTextSnippet: document.body.innerText.slice(0, 500),
title: document.title
})`,
returnByValue: true
})
// Nested CDP envelope: message.result.result.value — evaluateJsonValue unwraps
// and parses it (the old `status.result.value` read logged undefined).
console.log('after click:', evaluateJsonValue(status))
ws.close()