Skip to content

feat(consent): Name the process Windows Privacy will list - #536

Merged
omesser merged 4 commits into
mainfrom
cursor/windows-process-privacy-name-33f8
Sep 8, 2026
Merged

omesser merged 4 commits into
mainfrom
cursor/windows-process-privacy-name-33f8

Conversation

@omesser

@omesser omesser commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Why

Windows Privacy UI (screen capture, UI Automation) lists the process requesting permission, but the Settings window showed Linux prose and process_listed_as() hardcoded "ai-buddy" on Windows. A cargo run from Cursor/Terminal shows the IDE or shell, not the app name, so the hint has to name what Privacy will actually list.

Issue #238 requests Windows-specific process naming and hint copy to match the macOS approach (sibling of #148 / PR #229). #197 shipped the native Settings window; this is copy only.

What changed

  • Process detection: consent::windows::process_list_name() detects packaged builds (not under target\debug or target\release) vs dev builds, walks the parent process chain via CreateToolhelp32Snapshot / Process32FirstW / Process32NextW to find the launching IDE/terminal for cargo run.
  • Windows hint copy: Added listed_under_hint(name) and pane_intro(listed_as) for Windows that do not mention macOS, Privacy & Security, TCC, Accessibility, or Screen Recording.
  • Form wiring: form::privacy_sections() now routes Windows to consent::pane_intro(&process_listed_as()) instead of linux_pane_intro(). Linux still gets linux_pane_intro().
  • Tests: Separated Linux and Windows test assertions in form.rs. Added Windows-specific tests in consent.rs for hint copy (no macOS vocabulary) and confirmed process_listed_as() is non-empty.
  • Kept Null: live() stays Null on Windows. No real grant probe or prompt APIs.

Did not implement:

How to verify

Tests (on this Linux cloud agent):

  • ✅ cargo test -p ai-buddy-core --lib passes (454 tests).
  • Windows-specific code gated by #[cfg(target_os = "windows")] will be tested by Windows CI.
  • Form tests confirm Windows prose contains the process name and does not contain "macOS" or "Privacy & Security".
  • Consent tests confirm Windows listed_under_hint and pane_intro avoid macOS vocabulary.

CI:

  • Ubuntu + macOS checks should pass (no changes to macOS or Linux behavior).
  • Windows job (cargo test + cargo clippy) will compile and test the Windows code path. The windows label ensures CI runs Windows tests despite path filter.

Manual (next gate):

  • On a Windows machine with cargo run from Cursor/Terminal/PowerShell: Settings → Privacy should print the IDE/shell name, not "ai-buddy".
  • Packaged NSIS build: Settings → Privacy should print "ai-buddy".

Closes #238

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

Open in Web Open in Cursor 

Implements Windows-specific process detection for Settings Privacy pane (#238):
- Detects packaged vs cargo run via target/debug or target/release paths
- Walks parent process chain to find launching IDE/terminal for dev builds
- Adds Windows-specific hint copy without macOS/TCC vocabulary
- Fixes form.rs to route Windows to Windows intro, not Linux intro
- Updates tests to distinguish Windows and Linux prose separately

Co-authored-by: Oded Messer <odedmesser@gmail.com>
@omesser omesser added the windows Run the Windows compile job on this pull request label Sep 8, 2026 — with Cursor
cursoragent and others added 2 commits September 8, 2026 03:10
Fixes type error comparing HANDLE to integer. Use INVALID_HANDLE_VALUE
constant instead of raw 0 or -1 cast.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
- Remove unused HANDLE import from Windows module
- Use next_back() instead of last() for DoubleEndedIterator per clippy

Co-authored-by: Oded Messer <odedmesser@gmail.com>
@omesser
omesser marked this pull request as ready for review September 8, 2026 03:17
@omesser

omesser commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

Architect review — request changes @ d7af3fee

Direction is right for #238: Windows-specific copy (no macOS/TCC), Null probe unchanged, form routes by OS. CI green. Win e2e left for Oded — fine.

Must-fix: parent walk stops too early

macOS does not take the immediate parent. tcc_list_name uses responsible-pid + bundled ancestor walk (zsh → Cursor Helper → Cursor), skipping Helpers.

This PR’s parent_chain_name returns the first parent with a non-empty exe name. For a typical cargo run that is cargo, not Cursor / WindowsTerminal / powershell — which fails Acceptance (“A cargo run from an IDE or terminal prints the name Privacy will list, not ai-buddy”) in spirit: the user still cannot find the Privacy row under the name they know.

Please walk the chain and skip toolchain / launcher noise until you hit a plausible Privacy list name, e.g. skip (case-insensitive): cargo, rustc, rustup, cargo-watch, maybe conhost — then take the next named parent (IDE or terminal). Document the skip list next to the walk (macOS comments are the model). Prefer matching whatever Privacy actually lists when Oded smokes; until then, mirror the macOS “name the human-facing launcher” intent.

Also: creating a fresh ToolHelp snapshot every hop (up to 24) is fine for settings-open; one snapshot + parent map would be cleaner — soft.

Soft (non-blocking once must-fix lands)

  • packaged() via exe path containing \target\debug / \target\release is a brittle heuristic (false positives/negatives). Acceptable v1 with a comment; .app-style packaging on Windows (MSIX / install dir) may need a later check.
  • Pane copy “permissions are requested through Settings when needed” is aspirational while live() is still Null — OK if framed as future; don’t imply a grant button works today.
  • Unit tests pin “no macOS vocabulary” well; they do not pin that cargo run yields Cursor/Terminal (hard without a fake parent chain). A small injectable walk / skip-list unit would lock the must-fix.

Until the walk skips cargo (etc.) to the IDE/terminal: request changes.

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

Must-fix from Architect review: parent_chain_name was returning the first
named parent (cargo for cargo run), not the IDE/terminal Privacy will list.

Now mirrors macOS bundled_ancestor_name logic:
- Walk parents, skip toolchain (cargo, rustc, rustup, rust-analyzer, rls)
- Return first IDE/terminal (Cursor, Code, WindowsTerminal, powershell, etc.)
- Document packaged() path heuristic (target/debug|release vs installed)
- Soften Settings wording (Null probe: no grants claimed yet)
- Add unit test for toolchain classification (pure string, no live Privacy)

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

omesser commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

Architect must-fix addressed @ 9787e9c:

Must-fix: Skip toolchain in Windows parent walk

✅ parent_chain_name now mirrors macOS bundled_ancestor_name logic:

  • Walks parents up to 24 levels
  • Skips toolchain processes via is_toolchain(): cargo, rustc, rustup, rust-analyzer, rls
  • Returns first IDE/terminal: Cursor, Code, WindowsTerminal, powershell, pwsh, cmd, etc.
  • For cargo run from Cursor, will now return "Cursor" instead of "cargo"

Soft improvements (same pass)

✅ Packaged detection — added comment documenting the heuristic: NSIS installs live in Program Files/AppData (no target\debug|release), dev builds always under Cargo target directory

✅ Settings wording — softened pane_intro to not overclaim grants while live() is still Null:

"These permissions are not required yet. When needed later, Windows will prompt."

✅ Unit test — added windows_toolchain_classification test for the skip list (pure string classification, no live Privacy). Tests cargo/rustc/rustup are skipped; Cursor/Code/WindowsTerminal are not.

CI status

All checks green:

  • ✅ Ubuntu tests + clippy
  • ✅ macOS tests + clippy
  • ✅ Windows tests + clippy

Ready for re-review. Windows desktop e2e/smoke on DESKTOP-UQIE144 remains the next human gate (not run).

— Cursor agent, on @omesser's behalf.

@omesser

omesser commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

Architect re-gate — approve @ 9787e9c

Must-fix closed: parent walk skips toolchain (cargo / rustc / rustup / rust-analyzer / rls, case-insensitive) then takes the next named parent — mirrors the macOS ancestor intent. is_toolchain unit coverage is good. Soft nits addressed (packaged() comment, Null-aware pane copy). CI green. MERGEABLE.

Soft residual (non-blocking): chain may still land on pwsh / WindowsTerminal before Cursor when those sit between cargo and the IDE — issue #238 explicitly allows those names. Win desktop e2e still your smoke when you want it.

Approve. You merge when ready.

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

@omesser
omesser merged commit d1f6236 into main Sep 8, 2026
5 checks passed
cursor Bot pushed a commit that referenced this pull request Sep 8, 2026
Windows settings_window.rs now renders section.heading and section.comment
for each FormSection, matching X11 behavior. Before this fix, only rows were
drawn — heading and comment were ignored.

- Add STATIC label for section heading (LABEL_HEIGHT + HINT_GAP spacing)
- Add STATIC label for section comment when present (LABEL_HEIGHT * 2 height
  to accommodate wrapping)
- Maintain existing SECTION_GAP above each section
- Use unique control IDs (section_heading_<tab>_<section> and
  section_comment_<tab>_<section>) to avoid collisions

After #536, Privacy pane's process-name hint from consent::pane_intro lives
in FormSection.comment, so this fix makes it visible on Windows.

Fixes #552

Co-authored-by: Oded Messer <odedmesser@gmail.com>
cursor Bot pushed a commit that referenced this pull request Sep 8, 2026
…efresh

After rebase on main (which includes #536), Windows Privacy pane now has the
correct pane_intro. The remaining issue is that section heading and comment
STATIC controls were blanked on every refresh.

Root cause: should_update_label_text() returned true for section_heading_*
and section_comment_* IDs. When draw() called set_window_text() on these
labels, it had no match case for them and fell through to String::new(),
blanking the text set at build_ui time.

Fix: Add exclusion patterns for section_heading_* and section_comment_* in
should_update_label_text(), treating them like help hints and field labels
(static text that should never be overwritten from view data).

Test: Added regression test cases to should_update_label_text_preserves_help_hints
verifying both patterns return false.

After this fix:
- Section headings stay populated after refresh
- Section comments (including Privacy pane's process-name hint) stay visible
- Windows Privacy comment shows Windows-specific hint from #536 (no macOS/TCC copy)

Co-authored-by: Oded Messer <odedmesser@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

windows Run the Windows compile job on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Name the process Windows Privacy will list when a grant is requested

2 participants