Skip to content

Never replay dictations into fields whose security is unknown - #358

Merged
alexkroman merged 5 commits into
mainfrom
claude/wizardly-cori-xwadtb
Nov 25, 2026
Merged

alexkroman merged 5 commits into
mainfrom
claude/wizardly-cori-xwadtb

Conversation

@alexkroman

@alexkroman alexkroman commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What & why

Fixes #335. A dictation was kept out of recentDictations (and so out of later stt_prompt lines) only when the press-time read positively flagged a password field. Two common cases left security unknown and failed open:

  1. Accessibility reached no focused element (untrusted, or an Electron app answering the focus query with nothing): FocusCapture returned .empty, whose isSecure is false.
  2. The read was still in flight at release: capturedContext was nil, which read as "not secure".

The verdict is now three-way (PressContext.TargetSecurity):

Target Recent list / saved history Replayed in stt_prompt
.ordinary (read landed, normal field) yes yes
.secure (known password field) no no (unchanged)
.unknown (read not landed, or no focused element) yes no

Unknown dictations stay in Recent and saved history (which stay on the device) but are never sent, so Electron-app dictations don't vanish from history.

Changes:

  • FocusedFieldContext.unreachable (new securityUnknown flag, carried as TranscriptionContext.targetSecurityUnknown), returned by FocusCapture.captureFieldContext when no focused element can be read. .empty keeps meaning "a readable, empty, ordinary field".
  • PressContext tracks whether the read has landed (settled) and exposes targetSecurity.
  • RecentDictations.Entry.replayable; spokenOldestFirst (what is sent) skips unreplayable entries.
  • The developer-mode log withholds an unknown target's transcript too (DictationLog.unverifiedTranscript), closing the case where an in-flight read left it in plain text.
  • README privacy note updated.

How it was tested

  • New: hungReadIsNotReplayed (read never lands → listed in Recent, not sent, withheld from the log), unreachableFieldIsNotReplayed, and RecentDictationsTests.unreplayableEntriesStayLocal.

  • timedOutReadStillSendsPressKnownContext now lets each read land before release so its history is still replayable.

  • scripts/check.sh --portable passes locally (Linux sandbox); Swift build/tests run on CI.

  • Concurrency reviewed (swift6-concurrency-reviewer): no stale-pressContext race, tests deterministic, no Sendable issues.

  • scripts/check.sh passes (or CI will, if I'm not on a Mac)

  • I read AGENTS.md and this doesn't reintroduce anything deliberately removed

  • Docs updated if behavior changed

🤖 Generated with Claude Code

https://claude.ai/code/session_01DS5B1W14FsLoKZzXYpRu2z

A dictation is kept out of Recent (and so out of later stt_prompt lines)
only when the press-time read flagged a password field. Two cases left
security unknown and fell through to "record it":

- No focused element reachable (untrusted, or an Electron app answering
  the focus query with nothing): FocusCapture returned `.empty`, whose
  isSecure is false. It now returns `.unreachable`, flagged secure.
- The read still in flight at release: capturedContext is nil, which read
  as "not secure". PressContext now tracks whether the read has landed,
  and the remember decision reads `mayRemember`, which requires it to
  have landed and not be secure.

Delivery is unchanged; only remembering is withheld. Tests cover the hung
read and the unreachable field, and the press-known test now lets each
read land before release so its history is still seeded.

Fixes #335

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1W14FsLoKZzXYpRu2z
@alexkroman
alexkroman enabled auto-merge November 24, 2026 22:49
The previous commit dropped a dictation from the ring whenever the
press couldn't tell whether the target was a password field. The ring
also feeds the Recent list and saved history, so every dictation into
an app Accessibility can't see (many Electron apps), while untrusted,
or released before the read landed silently vanished from history too
-- and the UI-test build, which runs untrusted, would land nothing in
Recent.

Split the verdict three ways (`PressContext.TargetSecurity`):
- ordinary: remembered and replayed, as before;
- secure (a known password field): not remembered, as before;
- unknown (read not landed, or no focused element reached): remembered
  with `replayable: false`, so it stays in Recent and saved history but
  `spokenOldestFirst` never sends it in `stt_prompt`.

`.unreachable` now sets a separate `securityUnknown` flag (carried as
`TranscriptionContext.targetSecurityUnknown`) instead of `isSecure`. The
developer-mode log withholds an unknown target's transcript too, closing
the case where a read still in flight left it written in plain text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1W14FsLoKZzXYpRu2z
@alexkroman alexkroman changed the title Treat unreachable fields as secure to prevent history leaks Never replay dictations into fields whose security is unknown Nov 24, 2026
CI's swiftlint (--strict) failed on file_length: the two new tests took
DictationSessionContextTests.swift to 452 lines, past the 400 default.
They now live in DictationSessionUnknownSecurityTests.swift, which is
also where they belong topically; no test logic changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1W14FsLoKZzXYpRu2z
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
…-behinds (#378) and unknown-security fields (#358)

Both PRs reword the same sentence; carrying the identical combined
paragraph in each lets them merge in either order without a conflict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexkroman
alexkroman removed this pull request from the merge queue due to a manual request Nov 25, 2026
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

CI note on 33fa200: gate is red only because ios-build reached its 30-minute timeout-minutes while Periphery was running. It didn't fail on anything. On the previous commit (2629ae4), whose iOS code is identical (this push only moved two engine tests to a new file), the same job passed in 21 minutes. check (macOS tests, swiftlint, periphery) and both ios-sanitizers jobs passed. The merge-queue run will build iOS again on the merge group. I haven't re-run the PR job separately.


Generated by Claude Code

alexkroman pushed a commit that referenced this pull request Nov 25, 2026
…-behinds (#378) and unknown-security fields (#358)

Both PRs reword the same sentence; carrying the identical combined
paragraph in each lets them merge in either order without a conflict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to invalid changes in the merge commit Nov 25, 2026
@alexkroman
alexkroman enabled auto-merge November 25, 2026 01:10
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 0c516a2 Nov 25, 2026
13 checks passed
@alexkroman
alexkroman deleted the claude/wizardly-cori-xwadtb branch November 25, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Password dictations can enter Recent / stt_prompt when focus security is unknown

3 participants