lietzsche;fresnel

updated 2026-11-26·4 min read

Companion Settings & Visual Search

NDJSON named-pipe sync, global hotkey and mouse chord conflict detection, filename template expansion, WinRT toast notifications, and Google Lens / Cloud Vision search.

Building a full Windows 11 settings window inside immediate-mode egui looks weirdly off next to PowerToys, and leaving a .NET 10 WinUI 3 window parked in the tray just to flip a toggle burns RAM for nothing. Having fresnel.exe spawn fresnel-settings.exe (ui/Fresnel.Settings) on demand over two unidirectional NDJSON named pipes (--d2s-pipe and --s2d-pipe) gives you real Fluent controls while letting the daemon stay near working_set_pin_mb = 24 and letting .NET exit completely on close. Config edits flush to %LOCALAPPDATA%\Fresnel\settings.json (CURRENT_SCHEMA_VERSION = 1).

Companion Settings Screens

Bindings and Hook Traps

One WH_KEYBOARD_LL hook alone couldn’t handle every shortcut: elevated windows silently swallow Win+Alt+V under UIPI, and taking a RwLock inside the low-level hook risks Windows silently unhooking you after its ~300 ms timeout. So global shortcuts split between a lock-free WH_KEYBOARD_LL path (PrintScreen / Win+Shift+S), GlobalHotKeyManager (global-hotkey v0.10 for Win+Alt+V), and a 30-second foreground-PID-checked suppression window while recording new bindings in Settings. crates/core/src/bindings.rs also checks for duplicate chords and OS-reserved shortcuts before registering anything.

Storage and Filename Templates

crates/core/src/template.rs expands date and counter tokens into filenames, strips invalid path characters, clamps stems to Windows directory limits, and picks collision-free PNG names without needing the old disk-spooled capture drawer.

Visual Search Post-Bing Retirement

Following Microsoft’s August 11, 2025 retirement of Bing Search APIs, crates/search implements GoogleLensClient alongside an early CloudVisionClient wrapper.

Detached Lens threads gave me plenty of headaches first: cancelling with Esc still let an in-flight upload hijack browser focus later, an early build streamed raw BGRA bytes labeled image/png, and egui::Area::new(Id::unique(...)) regenerated IDs every frame so one flyout click opened the browser three times. Even centroid ray-cast snapping teleported lasso endpoints 70.7 px across the box on near-zero vectors until alpha crossfade snapping replaced it.

  • Google Lens Handoff (GoogleLensClient): Encodes the cropped frame to PNG (AtomicBool-cancellable), POSTs multipart encoded_image data to https://lens.google.com/v3/upload, and opens the Location redirect URL (falling back to https://lens.google.com/search?ep=fresnel).
  • Cloud Vision Stub (CloudVisionClient): Early REST wrapper targeting WEB_DETECTION (1,000 free lookups/month, $3.50 per 1,000 paid); currently returns mock strings when unauthenticated and ["Web Entity 1"] on HTTP 200 without parsing response JSON, and isn’t wired into Settings.
Settings Schema Defaults, Internal Symbols, and Toast Bitmask
  • General (crates/core/src/settings.rs): ThemePreference (System, Dark, Light), launch_at_startup = false, show_tray_icon = true, working_set_pin_mb = 24.
  • Capture: SnipCompletionMode (InstantSnip or ShowControlBar), magnetic_snap_enabled = true (12.0 px), show_crosshair_hud = true, veil_opacity = 0.45, SelectionBorderStyle (AccentColor, MonochromeWhite, Custom).
  • OCR & Redact: preserve_visual_lines = true, indent_spaces = 2, marquee_live_highlight = true; RedactToolDefault (Solid, Blur, Mosaic).
  • Toast Notifications: ToastButtonMask bitmask controls COPY (1 << 0), OPEN_FILE (1 << 1), OPEN_FOLDER (1 << 2), and VISUAL_SEARCH (1 << 3) buttons alongside 364x180 Hero toast previews managed by ToastCacheIndex (5 entries / 16 MB cap).
  • Bindings & Templates (crates/core/src/bindings.rs, template.rs): Validates HotkeyBinding, OverlayMouseBinding, PostSnipBinding, and RedactMouseBinding via detect_hotkey_conflicts and is_os_reserved_hotkey; formats FilenameTemplate via LocalDateTimeParts, sanitize_component, clamp_stem_for_directory, and create_unique_png_file.

Return to Fresnel Overview or inspect Zero-Copy Capture & OCR Pipeline.

Search wiki and portfolio

type to search across all entries.