Repository navigation
feat(helper): report the target app and website host with each transcript - #285
Merged
Merged
Conversation
hadrysm
force-pushed
the
feat/style-target-detection
branch
from
October 16, 2026 02:34
81ebed9 to
a0c933f
Compare
The helper now reports which app and website owned focus when capture started. Main decodes it, falling back to null on any malformed value, and ignores it until per-app styles consume it. Test mode gains voiceTest.setTarget, which sends test.target so verify can fake the next capture's target. Part of #281
dictate --app=<bundleId>[@host] calls voiceTest.setTarget before the key press, so the helper reports that app and website for the session instead of the scratch window. The result JSON and evidence file record it as app. Flag parsing moves to a pure parseDictateFlags with a table test. Part of #281
A backslash, a space, percent-encoding, or an IPv6 literal came through as the host. Classification keys on hostnames, so anything that is not one returns nil.
The node budget counted visits after every child had already been copied and wrapped, and nothing ended a read once the session was over. children(limit:) fetches at most the remaining budget through AXUIElementCopyAttributeValues, sibling iteration stops when the budget is spent, and both walks ask giveUp before each accessibility request so the 1 s hostReadBudget ends a read against a stalled browser.
Capture.start reports whether a session began. A busy or failed start no longer schedules a host read for a session that does not exist.
…say whether to detect the host
The helper never sends a target without a bundle id, so `TranscriptTarget.bundleId`
is `String` in Swift and `Schema.String` in TypeScript; `target: null` stays the
one encoding of unknown. `capture.start` gains a required `detectHost` flag so main
can keep the page-host read off sessions that cannot use it (main sends true for
now; the per-category PR wires it to cleanup state). `test.target` carries
`target: {bundleId, host} | null`, so a run can clear a pending override, and
`vv dictate` sends it on every run. The fake helper consumes the override at
`capture.start` like the real helper and answers `capture.cancel`.
Protocol stays at 11; this PR is the bump.
… its outermost web area Two defects in the host read. It re-queried the browser's current focused element on a utility queue, so a tab the user switched to during the read named the host for a session that started on another tab. And it stopped at the first AXWebArea above the focused element, which inside an iframe is the frame's own document (an about:blank editor frame, a third-party widget), not the page in the address bar. The read now starts from the focus snapshot insertion already captures, under the same input stamp: the walk goes up from the captured element, or down from the captured window for Chromium, and a result keyed on changed input publishes nil. `outermostWebArea` keeps walking to the window and reports the last web area seen; a walk cut by the deadline reports nothing rather than an inner frame. `HostRead` moves to VoiceHelperCore and lives under a lock on `InsertTarget`, so the transcript taking the target, or a capture that failed to start, settles it and the walk's `giveUp` sees that. Chrome Beta and Chrome Dev join the browser list. `PageHost.swift` now says that an IPv4 literal passes and main owns the validity rule.
hadrysm
force-pushed
the
feat/style-target-detection
branch
from
October 16, 2026 09:17
37fb235 to
457275b
Compare
…ed reads on cancel
…helper shuts down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Per-app Style (#281) needs to know what the user dictated into. The helper already reads the frontmost app at
capture.startfor insertion, so it is the one place that can name the target without adding work to the hot path. This PR makes the helper report the frontmost app's bundle id and, for a browser, the page host on everytranscriptevent. Main parses and types the field and ignores it until PR 4 classifies it.The bundle id is an in-memory read from the same
NSRunningApplicationobject insertion already uses. The host read runs only for a known browser, on a utility queue, only after a session began, with a 1 s budget checked before every accessibility request, and the transcript never waits for it. The full URL never leaves the helper and is never logged.Part of #281.
Scope
VoiceHelperCore:pageHost(_:)(http and https only, RFC 1123 hostname syntax after lowercasing, without port, userinfo, or trailing dot; an IPv4 literal passes and main's parser owns what classification may key on; IPv6 literals, percent-encoding, and non-ASCII return nil),outermostWebArea(above:maxDepth:giveUp:)andpageNode(below:maxDepth:maxNodes:giveUp:)over anAccessibilityNodeprotocol whosechildren(limit:)fetches no more than the remaining node budget,HostRead(publishkeyed on the input stamp,settle,take),TranscriptTargetwith a requiredbundleId,detectHostoncapture.start, thetest.targetcommand carryingtarget: {bundleId, host} | null, andreadyversion 11.VoiceHelper:InsertTargetgainsbundleIdand a lockedhost: HostRead;Insertion.recordTargettakes the session'sHostReadseed (a test override is.read,detectHostleaves it.pending) and reads the host from the same focus snapshot it takes for insertion when the seed is pending and the app is a known browser;TargetHost.swiftholds the browser set (Chrome Beta and Dev included) and the walk;Capturetakes the target when the transcript goes out, which settles a read still running.apps/desktop:HELPER_PROTOCOL_VERSION11,targeton the transcript schema throughnullOnInvalid(bundleId: Schema.String),detectHost: trueon everycapture.start(the per-category PR ties it to cleanup state),test.targetinHelperCommand,voiceTest.setTarget(target)in test mode, and the fake helper, which consumestest.targetatcapture.startand answerscapture.cancel.dictate --app=<bundleId>[@host],dictate-flags.mjs, SKILL.md, andfeatures/dictation.md.native/voice-helper/scripts/target-smoke.mjsprints what the helper sees for an app and page.dictation.tsdoes not read the field.Tradeoffs
AXManualAccessibilityis an Electron patch that Chrome 155 rejects. Instead of turning Chrome's accessibility tree on, the helper searches at most 3 levels and 64 nodes below the focused window for the first node with a URL, fetching children throughAXUIElementCopyAttributeValueswith the remaining budget as the limit. On Chrome that is theAXGroupunder the window, found after 2 nodes.nilrather than punycode. An IDNA table is not worth a dependency for a style hint.hostReadBudget(1 s, named inTargetHost.swift), so a stalled browser stops getting requests once the session is over. Warm reads measured under 50 ms.host: null.Blast Radius
Every dictation now carries one more field on the transcript line, and the helper and app refuse each other across the version bump, as they already do. A browser dictation adds a few accessibility calls on a utility queue after capture has started. A malformed target decodes to
nulland never drops a transcript. Nothing here persists or logs the target.Verification
swift test --filter 'PageHost|WebArea|PageNode|Protocol|CaptureStop|CaptureIdle': 26 tests pass, including the hostname table (backslash, space, percent-encoding, IPv6, hyphen and length limits), the depth and node bounds, how many children a wide node materializes, the deadline in both walks, andCapture.startreporting a busy or failed start.vp test run protocol.test.ts dictation.test.ts helper.test.ts: 173 tests pass. A transcript with a target, withtarget: null, and with each malformed shape still inserts, and no log, report, or history entry carries the bundle id or host (checked by temporarily logging the target and watching the test fail).dictate short.wav,--app=com.apple.MobileSMS, and--app=com.google.Chrome@mail.google.comall endinsertedwith the same text, andmain.loghas no occurrence of the bundle id or host.test.targetrides on the next transcript line exactly as sent, an app-only target carrieshost: null, and the capture after it reports the real frontmost app again.startMsp50 over 20dictatesessions in the same conditions:origin/main1 ms (p90 2, max 4) → this branch 2 ms (p90 2, max 2). Inside the 1 ms clock granularity.target-smoke.mjs(installed browsers: Safari, Google Chrome, Helium; Arc, Brave, Edge, Firefox, Opera, Vivaldi are not installed and are unverified):accounts.google.comAXManualAccessibilityReview round 2. Fixed the two criticals and the warnings from the thermo review: the host read now starts from the focus snapshot insertion already captures (element for the upward walk, window for Chromium) and publishes through
HostRead.publish, which drops a result whose input stamp changed, so a tab visited during the read cannot name the host; the walk returns the outermost web area, so a caret inside an iframe reports the page, not the frame;bundleIdis required on both sides;capture.startcarriesdetectHost;test.targetcarries a whole target or null andvv dictatesends it on every run; the fake helper consumes it atcapture.start; Chrome Beta and Dev are browsers;PageHost.swiftstates that an IPv4 literal passes and main owns the validity rule. Proof:swift test --filter 'WebArea|HostRead|PageHost|PageNode|Protocol|captureStart|microphoneConfigure|CaptureStop|CaptureIdle'30 tests pass; the newreportsTheOutermostWebAreaAboveAFocusedIframefails on the old walk with(found.node?.index → 2) == 4;vp test run protocol.test.ts dictation.test.ts helper.test.ts178 pass, and the newhelper.test.tscase fails when the fake consumes the override atcapture.stop(expected { bundleId: 'com.google.Chrome', … } to be nullafter a cancelled capture);tsc --noEmitclean;node --test voice-verify.test.mjs4 pass. The livedictateandtarget-smoke.mjsruns for this round are pending: the user's own Voice.app held the hotkey for the whole session and the scripts refuse while it runs. The hot path is unchanged in shape (recordTargetstill only stamps input and dispatches beforecapture.start), so the round-1startMsnumbers above stand until a live rerun.Review round 3. The real helper dropped a
test.targetoverride's host:recordTargetsettled the read to nil beforemain.swiftpublished the override, andpublishonly acts on a pending read, so everydictate --app=<browser>@<host>run went out withhost: null. The session'sHostReadis now seeded when theInsertTargetis created (recordTarget(host:)replacesdetectHost:; an override seeds.read(host), a wanted read.pending, an unwanted one.read(nil)), and the publish-after-settle line is gone. The depth bound ofoutermostWebAreanow behaves like the deadline and returns nil instead of an inner frame, withwebAreaMaxDepthraised from 25 to 64.Capture.cancel(all three branches) andshutdownsettle the session's host read so a cancelled browser session sends no further accessibility requests. Proof: the newTranscriptTargetTestsdriveInsertion.recordTargetintoCaptureand read the emittedtranscriptline; on the old code the override row failed with(reported["host"] as? String → nil) == "mail.google.com", the cancel and shutdown rows with.pending == .read(nil), and the flippeddropsAnInnerWebAreaWhenTheBoundStopsTheWalkwith(found.node → index 1) == nil. After the fixswift test --filter 'TranscriptTarget|WebArea|HostRead|PageHost|PageNode|Protocol|CaptureStop|CaptureIdle'passes 36 tests in 7 suites andswift buildis clean. Livedictate --appandtarget-smoke.mjsare still blocked by the user's own Voice.app holding the hotkey, so the override path is proven at the helper level, not through the hub.Hub after the dictations (no UI change in this PR):