logancyang_obsidian-copilot/src
Logan Yang 728ccb25d4
fix: restore expanded search limits for time-range and tag queries (#2295)
* fix: restore expanded search limits for time-range and tag queries

PR #2273 removed the agent-facing returnAll parameter but also
removed the implicit expanded limits that time-range and tag-focused
queries relied on. This restores the behavior: when a search has a
timeRange or tag terms, automatically use RETURN_ALL_LIMIT (100)
instead of the default maxSourceChunks, and pass returnAll to the
underlying retrievers. The agent still cannot explicitly request
returnAll via the tool schema.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: two-tier search result formatting to reduce context bloat for expanded queries

When search results exceed maxSourceChunks, split into two tiers:
- Tier 1 (first maxSourceChunks docs): full content XML as before
- Tier 2 (overflow docs): metadata-only with title, path, mtime, 150-char snippet

Achieves ~85% context reduction for expanded-limit queries while preserving
discoverability. Adds formatMetadataOnlyDocuments() as a pure, testable utility.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: two-tier search formatting for time-range and tag queries

- Add isFilterOnlyResults() and isTimeDominantResults() helpers in searchResultUtils
- Update formatMetadataOnlyDocuments() with configurable snippetLength (default 300)
- Update prepareLocalSearchResult() with three-case logic:
  - Time-dominant: sort by mtime desc, top maxSourceChunks get full content, rest metadata-only
  - Tag-only: all docs get metadata-only (no ranking available)
  - Ranked: existing behavior unchanged
- Extract FILTER_SOURCES to module-level constant to avoid per-call Set allocation
- Add tests for isFilterOnlyResults, isTimeDominantResults, and custom snippetLength

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: update readNote instruction in metadata-only search results

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address Codex P1/P2 review findings for two-tier search

P1: Remove title-match from FILTER_SOURCES so explicit note references
([[Note Name]]) get full content in tier 1, not metadata-only. This
restores prior behavior where title-match queries provided full content
without requiring an extra readNote tool call.

P2: Fall back to parsing tags directly from the query string when
salientTerms has no tag terms. Mirrors the regex logic in FilterRetriever
so needsExpandedLimits is true even when salientTerms is incomplete.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* revert: remove unrelated Prettier formatting changes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: preserve no-results marker and sanitize metadata snippets

- Guard the metadata-only path with tier2Docs.length > 0 so empty-result
  searches fall through to formatSearchResultsForLLM and return the
  expected "No relevant documents found." marker instead of an empty string.
- Apply sanitizeContentForCitations to doc.content in
  formatMetadataOnlyDocuments before slicing the snippet, preventing
  leaked citation markers (e.g. [^12], [3]) from note content into the
  tier-2 metadata prompt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: decouple timeDominant detection from filterOnly

Time-range queries via FilterRetriever often produce a mix of
"time-filtered" and "title-match" (daily notes from getTitleMatches)
docs. Since "title-match" is not in FILTER_SOURCES, isFilterOnlyResults
returns false for these result sets, making the old `timeDominant =
filterOnly && isTimeDominantResults(...)` always false — skipping the
mtime-based recency sort for time-range queries.

Fix by evaluating isTimeDominantResults independently: if any doc has
source "time-filtered", use mtime sort regardless of whether all docs
are filter-only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: populate tagTerms from query when salientTerms misses hashtags

When salientTerms is incomplete (e.g. query="#python" with empty
salientTerms), tagTerms was always an empty array, so SelfHostRetriever
received no server-side tag filters despite expanding to RETURN_ALL_LIMIT.

Extract hashtags from the raw query using the same regex as FilterRetriever
as a fallback, and assign the result directly to tagTerms so all retriever
paths (including SelfHostRetriever) get proper tag constraints.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 20:45:22 -07:00
..
cache Clean up dead code and update readme for privacy disclosure (#2071) 2025-12-15 20:50:46 -08:00
commands fix: Quick Ask/Command panel positioning overhaul (#2278) 2026-03-13 21:50:01 -07:00
components fix: agent loop improvements, clickable citations, and UI fixes (#2287) 2026-03-14 16:17:37 -07:00
context Audit context envelope, tag alignment, artifact dedup, and logging (#2164) 2026-02-07 21:18:25 -08:00
contexts feat: New Setting UI. (#955) 2025-01-13 22:32:20 -08:00
core chore: rename docs to designdocs and nest todo folder (#2252) 2026-03-03 16:26:03 -08:00
editor fix: Quick Ask/Command panel positioning overhaul (#2278) 2026-03-13 21:50:01 -07:00
hooks feat: drag relevant notes and sources into editor to insert wikilinks (#2288) 2026-03-13 11:56:55 -07:00
imageProcessing Improve custom command (#1942) 2025-10-20 17:52:50 -07:00
integration_tests Implement modular context compaction architecture (#2159) 2026-02-06 21:52:33 -08:00
lib Add tw prefix to tailwind (#1497) 2025-05-31 22:30:54 -07:00
LLMProviders fix: restore expanded search limits for time-range and tag queries (#2295) 2026-03-14 20:45:22 -07:00
memory Add CRUD to Saved Memory (#1929) 2025-10-22 23:33:35 -07:00
mentions feat: add Firecrawl and Supadata self-host support for web search and YouTube (#2196) 2026-02-19 20:44:39 -08:00
miyo Add license auth header to Miyo requests (#2260) 2026-03-05 07:37:51 +09:00
search feat: add custom Miyo server URL setting for remote deployments (#2229) 2026-03-03 11:29:43 +09:00
services fix: support both classic and modern YouTube transcript panel DOM structures (#2286) 2026-03-12 20:59:56 -07:00
settings feat(openrouter): enable prompt caching via cache_control (#2279) 2026-03-14 17:18:01 -07:00
state feat: implement auto-compact context with map-reduce summarization (#2106) 2026-01-13 22:15:24 -08:00
styles fix: agent loop improvements, clickable citations, and UI fixes (#2287) 2026-03-14 16:17:37 -07:00
system-prompts fix(ui): improve system prompt template syntax hints (#2235) (#2245) 2026-03-02 21:58:29 -08:00
tests feat: Add project new context loading ui. (#1695) 2025-08-08 09:59:00 -07:00
tools fix: restore expanded search limits for time-range and tag queries (#2295) 2026-03-14 20:45:22 -07:00
types Address quick ask (#2146) 2026-02-03 20:04:10 -08:00
utils feat: unify Azure OpenAI and Azure Foundry into single Azure provider (#2291) 2026-03-14 16:41:14 -07:00
aiParams.ts fix: command UI improvements, LaTeX rendering, and Ollama numCtx config (#2276) 2026-03-10 23:29:17 -07:00
chainFactory.ts feat: Improve error handling architecture across chain runners. (#1931) 2025-10-23 17:00:23 -07:00
chainUtils.ts fix: defense-in-depth overrides to prevent tiktoken CDN timeout in Plus mode (#2283) 2026-03-13 21:48:13 -07:00
chatUtils.toolMarkers.test.ts Implement modular context compaction architecture (#2159) 2026-02-06 21:52:33 -08:00
chatUtils.ts Implement modular context compaction architecture (#2159) 2026-02-06 21:52:33 -08:00
composerUtils.ts Squash preview (#1502) 2025-05-30 20:06:25 -07:00
constants.ts feat: add Gemini Embedding 2 preview model support (#2299) 2026-03-14 20:33:40 -07:00
context.ts Listen to active note changes (#1015) 2025-01-06 23:23:56 -08:00
contextProcessor.dataview.test.ts Support dataview result in active note (#1918) 2025-10-12 19:05:55 -07:00
contextProcessor.embeds.test.ts Support embedded note (#1995) 2025-10-31 13:45:11 -07:00
contextProcessor.selectedText.test.ts Address quick ask (#2146) 2026-02-03 20:04:10 -08:00
contextProcessor.ts Audit context envelope, tag alignment, artifact dedup, and logging (#2164) 2026-02-07 21:18:25 -08:00
encryptionService.test.ts fix: replacing Node's Buffer with npm's buffer package. (#1306) 2025-03-02 19:04:05 -08:00
encryptionService.ts feat: add GitHub Copilot integration with improved robustness (#2110) 2026-01-14 15:01:47 -08:00
error.ts feat: add confirmation dialog before clearing Miyo index (#2211) 2026-03-03 11:11:13 +09:00
errorFormat.ts Implement log file (#1804) 2025-09-10 22:34:57 -07:00
langchainStream.test.ts Improve new user onboarding by removing notice on missing api key (#2063) 2025-12-11 13:44:21 -08:00
langchainStream.ts feat: Improve error handling architecture across chain runners. (#1931) 2025-10-23 17:00:23 -07:00
logFileManager.ts Update log file (#2014) 2025-11-08 23:02:55 -08:00
logger.ts feat: add search explanation table in log (#1805) 2025-09-11 01:05:34 -07:00
main.ts fix(tools): replace cachedRead with vault.read in agent/tool paths (#2274) 2026-03-10 14:53:54 -07:00
noteUtils.ts Throttle number of links returned (#998) 2025-01-02 18:18:56 -08:00
plusUtils.ts Rename enableMiyoSearch to enableMiyo and scope Miyo to Plus/agent chains (#2201) 2026-02-21 21:27:54 -08:00
rateLimiter.ts Add configurable batch size, update rps (#1240) 2025-02-11 22:20:30 -08:00
types.ts Add Editor "Quick Ask" Floating Panel + Persistent Selection Highlights (#2139) 2026-02-03 17:37:33 -08:00
utils.cleanMessageForCopy.test.ts Fix insert/replace at cursor including agent reasoning blocks (#2174) 2026-02-10 19:54:52 -08:00
utils.test.ts feat: Add comprehensive system prompt management system. (#1969) 2026-01-13 21:38:17 -08:00
utils.ts fix(tools): replace cachedRead with vault.read in agent/tool paths (#2274) 2026-03-10 14:53:54 -07:00