Skip to content

feat(windows): Add WindowTitles consent and implementation - #915

Merged
omesser merged 16 commits into
mainfrom
cursor/windows-window-titles-7ad4
Sep 23, 2026
Merged

omesser merged 16 commits into
mainfrom
cursor/windows-window-titles-7ad4

Conversation

@omesser

@omesser omesser commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

What

Add Windows WindowTitles consent + GetWindowTextW consumer so other apps’ titles can appear in sensing when wanted ∧ granted. Settings row is “Window Titles” (no Capture copy). Probe always grants (no system dialog); usable still follows the Settings checkbox.

Why

Platform equivalency with Linux #904 / #886 and macOS Screen Recording → titles. Windows had been hard-coding title: None.

How to test

  • Windows consent: always granted; usable follows wanted; catalog row + form expects Accessibility + WindowTitles
  • Core suite green where platform-independent
  • Startup applies use_window_titles wanted; MCP list_window_titles gated by usable
  • Apply true/false persists; Settings webview checkbox binds via row_values / form row ids (consent_window_titles)

Manual (DESKTOP, needs your green light before any drive): enable Window Titles → titles in list_windows; disable → None; restart with wanted true → checkbox On.

Closes #912

— Cursor agent (Coder), on @omesser's behalf.

@omesser
omesser marked this pull request as ready for review September 22, 2026 20:24
@cursor
cursor Bot force-pushed the cursor/windows-window-titles-7ad4 branch 3 times, most recently from 37fd0b4 to 5a6e0d2 Compare September 22, 2026 22:26
@omesser

omesser commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

CHANGES_REQUESTED @ 9496fab8 — Standards+Spec vs #912. Tip has real Windows titles work, but it is not mergeable as-is against current main.

Spec (#912)

Mostly met on the tip’s intent:

  • Windows WindowTitles in catalog; Settings row titled “Window Titles” (not Capture).
  • WindowsProbe always grants titles; usable follows wanted.
  • GetWindowTextW via can_read_titles; title: None when not usable.
  • MCP list_window_titles gated; startup + Apply set_wanted / enable_consent ungated for Windows.
  • No pixel Capture.

Hard (must fix before CLEAR)

  1. Rebase onto current main. mergeable_state: dirty. Main has fix(settings): Wire the four dead buttons and key snapshot values by row id #920 (Settings row_values), refactor(overlay): Null the bubble fields at emit and delete forOverlay #922 (overlay emit), and possibly refactor(platform): Keep one due, not a copy per cfg arm #923 (due). platform.rs / settings.rs / consent.rs will conflict.

  2. Delete consent_checkboxes + #[serde(flatten)] after rebase. On main, settings_snapshot sends view: view.row_values(), not the SettingsView struct:

    // main.rs
    view: view.row_values(),

    and row_values already maps consent as:

    self.consent.iter().map(|row| (row.row_id(), RowValue::Bool(row.granted)))

    ConsentRow::row_id() derives consent_{title} → for title "Window Titles" that is consent_window_titles, matching CONSENT_WINDOW_TITLES_ID. The flattened HashMap never reaches settings.js after fix(settings): Wire the four dead buttons and key snapshot values by row id #920; keeping it is a second binding path and a merge landmine. Keep the form checkbox + catalog + BoolField::UseWindowTitles ungating; rely on row_values + fixture pin.

  3. Re-prove Windows CI after the rebase (especially settings/form fixture vs row_values key set).

Soft (non-blocking once hard is done)

  • windows_mcp_window_titles_require_consent: !with_wanted.is_empty() || cfg!(not(windows)) — the cfg!(not(windows)) arm is dead inside a windows-only test; empty EnumWindows in CI is a flake risk. Prefer “empty when unwanted” only, or accept empty when wanted in headless.
  • WindowsProbe::Accessibility always false while the catalog still lists Accessibility (taskbar) — pre-existing / deferred, but the costs copy should not imply it works yet if it never grants.
  • Comment trim on the tip if anything restates the code after rebase.

Do not merge without Oded’s yes. Rebase + drop consent_checkboxes, then ping for re-gate.

— Cursor agent (Architect), on @omesser's behalf.

cursoragent and others added 16 commits September 23, 2026 00:05
- Add WindowTitles capability to Windows consent system
- Implement WindowsProbe that always grants WindowTitles (no system permission needed)
- Update WindowsWindowSource to accept can_read_titles closure
- Implement read_window_title() using GetWindowTextW Win32 API
- Add unit tests for Windows WindowTitles consent behavior
- Update Settings form test to expect 2 consent rows on Windows

Windows users can now enable WindowTitles in Settings to get other applications'
window titles in sensing/list_windows/describe_screen, matching the Linux/macOS
equivalency goal. Without the grant, titles stay None (honest behavior).

Closes #912

Co-authored-by: Oded Messer <odedmesser@gmail.com>
- Remove test doc comments that restate test names
- Remove inline comments that restate code
- Simplify function doc to focus on return behavior

Addresses Standards review feedback.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
Co-authored-by: Oded Messer <odedmesser@gmail.com>
Co-authored-by: Oded Messer <odedmesser@gmail.com>
Co-authored-by: Oded Messer <odedmesser@gmail.com>
Co-authored-by: Oded Messer <odedmesser@gmail.com>
Windows has Accessibility + WindowTitles (2 rows), not 1.
Catalog assertions now check platform-specific terminology:
- macOS: Dock, Accessibility, Screen Recording
- Windows: taskbar, Automation, No system permission required

Fixes catalog test failures and cfg-gated dead_code on Windows builds.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
Windows needs a second consent row for WindowTitles alongside Accessibility.
Adds CONSENT_WINDOW_TITLES_ID constant and the checkbox in privacy_sections.
Fixes settings view test to expect both Accessibility and Window Titles.

Fixes 3 failing tests:
- settings::form::tests::the_consent_rows_are_in_catalog_order
- settings::form::tests::the_consent_section_has_a_checkbox_per_grant_this_platform_offers
- settings::tests::the_settings_view_is_what_the_window_shows

Co-authored-by: Oded Messer <odedmesser@gmail.com>
UseWindowTitles is now available on all three platforms (macOS, Linux, Windows).
The Windows consent form needs this variant to wire the WindowTitles checkbox.

Fixes clippy error: variant not found in BoolField enum on Windows.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
The set_bool match at line 1358 needs to handle UseWindowTitles on Windows.
Removes the #[cfg(not(target_os = "windows"))] guard that was preventing
the match arm from compiling on Windows.

Fixes E0004: non-exhaustive patterns error on Windows builds.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
…ow_titles

Bug 1 (startup): Windows was excluded from set_wanted(WindowTitles) in main.rs
and settings.rs Apply path. With use_window_titles: true in settings.json, the
Privacy checkbox still showed Off after restart. Removed cfg(not(windows)) guards
so Windows now applies wanted state at startup and on Apply.

Bug 2 (MCP leak): list_window_titles() on Windows called visible_window_titles()
directly with no usable(WindowTitles) gate, leaking titles even when consent was
not wanted. macOS and Linux both gate first. Added the gate to Windows path so
resources/read ai-buddy://windows now respects consent.

Test: Added windows_mcp_window_titles_require_consent to verify wanted=false
returns empty, matching macOS/Linux test coverage.

Found via live DESKTOP verification of a799fd6.

_— Cursor agent (Coder), on [@omesser](https://github.com/omesser)'s behalf._

Co-authored-by: Oded Messer <odedmesser@gmail.com>
Bug A (Uncheck + Apply not persisting false): Windows was excluded from prompt_wt
definition and enable_consent call via cfg(not(windows)) guards in settings.rs Apply.
When unchecking Window Titles and clicking Apply, settings.json stayed true and
titles kept flowing. Removed both guards so Windows now:
- Defines prompt_wt when patch.use_window_titles == Some(true)
- Calls enable_consent(WindowTitles) which triggers set_wanted
- Properly handles false patches via apply_and_seed

Bug B (Checkbox not reflecting persisted true on restart): Same root cause. Without
enable_consent running, the wanted state wasn't synchronized. Now startup set_wanted
(fixed in 4190b60) + Apply enable_consent work together.

Test: Added Windows-specific use_window_titles patch test verifying both true and
false toggle behavior, matching existing Linux test coverage.

Found via live DESKTOP verification of 4190b60.

_— Cursor agent (Coder), on [@omesser](https://github.com/omesser)'s behalf._

Co-authored-by: Oded Messer <odedmesser@gmail.com>
…ding

Bug: Windows checkbox always showed Off after restart even with use_window_titles: true
in settings.json. The webview's settings.js reads values[row.id] (e.g. values["consent_window_titles"])
but SettingsView only serialized a nested consent: Vec<ConsentRow> array with no top-level keys
matching form row IDs. This is the same class of #875 mismatch where the page indexes by form row id
but the view serializes nested/field names.

SetBool UI toggle -> Outcome::Apply -> Response::Nothing -> no refresh, so DOM keeps clicked state
until next snapshot (Apply Reset, tab redraw, restart). Then checkbox always paints Off because
Boolean(values[row.id]) is Boolean(undefined) = false.

Fix: Added consent_checkboxes: HashMap<String, bool> to SettingsView, keyed by form row IDs:
- Windows: consent_window_titles, consent_accessibility
- macOS: consent_screen_recording, consent_accessibility, consent_input_monitoring
- Linux: consent_screen_cast

Follows the existing development_switches HashMap pattern. The map is built by consent_checkboxes()
which reads settings.use_* fields and keys them by form::CONSENT_*_ID constants.

Tests:
1. consent_checkboxes_map_keyed_by_form_row_id verifies true/false values for all platforms
2. Extended unchecking_consent test to verify map matches settings state
3. Covers Windows, macOS, Linux consent capabilities

Found via live DESKTOP verification of ed0e8fd where OFF→ON→restart left checkbox Off.

_— Cursor agent (Coder), on [@omesser](https://github.com/omesser)'s behalf._

Co-authored-by: Oded Messer <odedmesser@gmail.com>
…tion

Bug in 2e4524c: consent_checkboxes was nested, so webview still saw
values["consent_window_titles"] = undefined. The HashMap existed in Rust
but serialized as json.consent_checkboxes.consent_window_titles, not as a
top-level json.consent_window_titles key.

Fix: Added #[serde(flatten)] to consent_checkboxes field in SettingsView.
Now the HashMap's keys merge into the parent struct's JSON at the top level,
so settings.js can read values[row.id] directly as it expects.

Test: consent_checkboxes_serialize_as_toplevel_json_keys verifies:
- Serialized JSON has "consent_window_titles": true at top level (not nested)
- json.get("consent_checkboxes") returns None (proves flatten worked)
- All platforms (Windows, macOS, Linux) have their consent form row ids
  as top-level keys when settings.use_* fields are true/false

This is the correct fix for the OFF→ON→restart→checkbox Off bug found on
DESKTOP-UQIE144. Ready for Coder re-verification.

_— Cursor agent (Coder), on [@omesser](https://github.com/omesser)'s behalf._

Co-authored-by: Oded Messer <odedmesser@gmail.com>
Clippy error: field_reassign_with_default in consent_checkboxes_serialize_as_toplevel_json_keys test.
Initialize Settings with use_window_titles: true inline instead of reassigning after default().

Co-authored-by: Oded Messer <odedmesser@gmail.com>
After #920, settings_snapshot sends view.row_values(), not the
SettingsView struct. row_values() already maps consent as
(row.row_id(), RowValue::Bool(row.granted)). ConsentRow::row_id() for
title "Window Titles" → consent_window_titles matching
CONSENT_WINDOW_TITLES_ID.

The flattened HashMap never reaches settings.js after #920; keeping it
is a second binding path and merge landmine. The form checkbox, catalog,
and BoolField::UseWindowTitles ungating remain; rely on row_values() +
fixture pin.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
@cursor
cursor Bot force-pushed the cursor/windows-window-titles-7ad4 branch from 9496fab to a739f13 Compare September 23, 2026 00:09
@omesser

omesser commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

CLEARED @ a739f13205257fa3d6dff7cc6ef7c2cf1e94043f — Standards+Spec vs #912. Prior CHANGES_REQUESTED @ 9496fab8 hard items are done; tip is mergeable.

Spec (#912)

Met on tip:

  • Windows WindowTitles catalog + Settings row titled Window Titles (not Capture).
  • WindowsProbe always grants titles; usable follows wanted; honest title: None / empty MCP when not usable.
  • GetWindowTextW via can_read_titles; shared title: Option<String> no longer hard-coded None.
  • Startup + Apply set_wanted / enable_consent ungated for Windows; MCP list_window_titles gated.
  • No pixel Capture / OCR / Ambient tiers.

Hard checklist

  1. Rebase onto current main — pass. Compare 94e128a…a739f132: behind_by: 0, merge_base = main tip; mergeable_state: clean (was dirty @ prior gate).
  2. No consent_checkboxes / serde(flatten) — pass. Tip + compare patch grep clean; settings_snapshot sends view: view.row_values(); consent binds via ConsentRow::row_id() ("Window Titles" → consent_window_titles) + form CONSENT_WINDOW_TITLES_ID; tests assert row_values keys.
  3. Windows CI green — pass. check run windows conclusion success (macos/ubuntu also success).

Soft (non-blocking)

  • windows_mcp_window_titles_require_consent: cfg!(not(windows)) dead arm inside windows-only test; empty EnumWindows in CI still a flake risk — prefer “empty when unwanted” only.
  • WindowsProbe::Accessibility always false while catalog still lists Accessibility (taskbar) — deferred / pre-existing smell.
  • PR How-to-test still says webview binds via consent_checkboxes map — stale vs tip; optional body scrub.

Do not merge without Oded’s yes.

— Cursor agent (Architect), on @omesser's behalf.

@omesser

omesser commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

Architect hard items addressed @ a739f132

  1. Rebased onto current main — behind_by: 0, mergeable_state: CLEAN.
  2. Dropped consent_checkboxes + #[serde(flatten)]; tip relies on row_values() → consent_window_titles (form row id).
  3. Windows CI re-proved green (ubuntu / macos / windows / build all pass on this tip).

Soft items left as non-blocking. PR How-to-test updated to name row_values() instead of the removed map.

Please re-gate / CLEAR when ready.

— Cursor agent (Coder), on @omesser's behalf.

@omesser

omesser commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

CLEARED @ a739f132 — Standards+Spec vs #912. Prior hard items addressed.

Spec

Met:

  • Windows WindowTitles catalog + Settings “Window Titles” (not Capture).
  • WindowsProbe always grants; usable follows wanted.
  • GetWindowTextW via can_read_titles; title: None when not usable.
  • MCP list_window_titles gated; startup + Apply set_wanted / enable_consent on Windows.
  • No pixel Capture.

Hard (was CHANGES_REQUESTED)

  1. Rebased onto current main — mergeable_state: clean.
  2. consent_checkboxes + flatten deleted. Binding is row_values() + ConsentRow::row_id() ("Window Titles" → consent_window_titles). Tests assert via view.row_values().
  3. CI green (ubuntu / macos / windows / build).

Soft (non-blocking)

  • PR body How to test still says “via consent_checkboxes map” — refresh to row_values / form row ids when convenient.
  • windows_mcp_window_titles_require_consent: cfg!(not(windows)) arm still dead; empty-when-wanted is a mild flake risk (CI passed).
  • WindowsProbe::Accessibility always false while catalog lists Accessibility — deferred honesty, not this Spec.

Do not merge without Oded’s explicit yes.

— Cursor agent (Architect), on @omesser's behalf.

@omesser
omesser merged commit dac3c1a into main Sep 23, 2026
5 checks passed
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.

feat(windows): Window titles behind consent for platform equivalency with Linux #904

2 participants