Skip to content

Add on-device Ask search mode - #11

Merged
nklmilojevic merged 2 commits into
mainfrom
feature/ask-search
Sep 19, 2026
Merged

nklmilojevic merged 2 commits into
mainfrom
feature/ask-search

Conversation

@nklmilojevic

@nklmilojevic nklmilojevic commented Sep 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Adds an Ask search mode: a natural-language request is turned into literal filters by the on-device Apple Intelligence model (FoundationModels), and Lodge applies those filters locally to clipboard text, OCR text, website, source app, and last copy date. Only the request reaches the model — clipboard contents never leave the Mac.
  • Ask defers to Return: typing shows "Press Return to search", the first Return builds the plan, a second Return accepts the selected item. Later query edits invalidate a completed plan, and in-flight responses are discarded once the query changes.
  • When the model is unavailable (pre-macOS 26, Apple Intelligence off, device ineligible, model not ready) or planning fails, Lodge falls back to exact search and shows why. Every other search mode still works on macOS 14+.
  • Plans are validated before use: domains must be plausible hostnames, dates must be real yyyy-MM-dd values, and app/date filters are dropped unless the phrase actually appears in the request, so the model cannot invent filters.
  • Link matching detects HTTP(S) URLs inside copied text; github.com also matches its subdomains but not lookalikes such as notgithub.com or github.com.example.org.
  • Adds a search-mode menu beside the search field with a live status line, plus availability hints in Settings → General.
  • Drive-by fixes: the search field placeholder now updates when the mode changes, and the detail panel copy date uses a single DateFormatter instead of three stacked Text views.

Test plan

  • xcodebuild test -scheme Lodge — new coverage in HistoryTests (Return gating, exact-search fallback, stale response discarded) and SearchTests (combined app/type/date/text filters, link and domain matching, filter-evidence rules, relative date ranges across a DST boundary, invalid domain/date rejection)
  • On macOS 26 with Apple Intelligence on: pick Ask, run "links from Safari yesterday" and "GitHub links", confirm results and that a second Return pastes the selection
  • On macOS 14/15 or with Apple Intelligence off: confirm Ask shows the availability message and returns exact-search results
  • Switch modes with text in the field and confirm the placeholder updates

Adds an "Ask" search mode that turns a natural-language request into
literal filters using the on-device Apple Intelligence model, then applies
those filters locally to clipboard text, OCR text, website, source app,
and last copy date.

- AskSearch builds a plan from the request; filtering never leaves the Mac
- Ask waits for Return before planning; a second Return accepts the selection
- Falls back to exact search with a status message when the model is
  unavailable or fails
- Search mode menu next to the search field, with availability hints in
  General settings
- Fix the search field placeholder not updating on mode change
- Format the detail panel copy date with a single DateFormatter
@greptile-apps

greptile-apps Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge with no outstanding actionable findings.

Summary

Adds an on-device Ask search mode that converts natural-language requests into locally applied clipboard filters.

  • Adds model-generated and validated filters for text, source applications, content types, dates, and domains.
  • Defers Ask execution until Return and falls back to exact search when planning is unavailable or fails.
  • Extends link matching to inspect destinations embedded in HTML and RTF clipboard content.
  • Adds search-mode controls, availability messaging, tests, and documentation.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Q[User enters Ask query] --> R[Press Return]
  R --> M[On-device language model]
  M --> V[Validate generated filters]
  V --> S[Search local clipboard history]
  S --> T[Text and OCR]
  S --> A[Source application]
  S --> D[Date range]
  S --> L[Plain-text and rich-content links]
  T --> O[Filtered results]
  A --> O
  D --> O
  L --> O
  M -->|Unavailable or failure| E[Exact-search fallback]
  E --> O
Loading

Reviews (2) · Last reviewed commit: "Match hyperlink destinations in Ask link..."

Comment thread Lodge/AskSearch.swift Outdated
Link and domain filters only inspected the flattened plain text, so an
anchor copied as rich content matched nothing: plainText keeps the visible
text and drops the href. Read destinations from the stored HTML and RTF
content as well, and only load that content when the plan needs links.
@nklmilojevic
nklmilojevic merged commit d3e0fba into main Sep 19, 2026
2 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.

1 participant