Skip to content

Rank daily-note commands (today first) above other link completions - #5

Open
Feel-ix-343 wants to merge 2 commits into
mainfrom
devin/1787072130-daily-note-completions-first
Open

Rank daily-note commands (today first) above other link completions#5
Feel-ix-343 wants to merge 2 commits into
mainfrom
devin/1787072130-daily-note-completions-first

Conversation

@Feel-ix-343

Copy link
Copy Markdown

Summary

Typing [today](today or [[today buried the today: <date> daily-note command under every heading whose text happens to contain the word "today" — and in a vault with >20 such headings the daily note was dropped entirely, because run_completer does .take(20) over the matcher's output.

Two causes: sort_text was the raw fuzzy score as a decimal string, so all equally-scoring items (headings and the daily note all scored 140 in a repro vault) got an identical sortText and the client ordered them arbitrarily; and the matcher's output order — which the .take(20) truncation consumes — carried no notion of "this item matters more".

Fix: an explicit priority tier, exposed as a defaulted Matchable::priority() so non-link completables are unaffected:

enum CompletionPriority { Top, Elevated, Normal }   // today | other relative daily notes | everything else

// fuzzy_match_completions
sort by (priority, score desc)
sort_text = format!("{}{:010}", priority as u8, u32::MAX - score)

Zero-padding + inverting the score makes plain lexicographic sortText ordering equal the intended ordering (previously "2" sorted ahead of the better-scoring "21"), and sorting the returned Vec means the .take(20) cut now keeps the daily-note commands instead of cutting them.

MDDailyNote now stores the relative name ("today", "next Monday", …) computed in from_date/from_referenceable instead of re-parsing ref_name against the configured date format, so priority() works without completer context; relative_name() became an infallible &str accessor.

Verified by driving the server over stdio against a vault with 24 headings containing "today": for both [today](today and [[today, today: 2026-08-18 is now item #1 with the smallest sortText (04294967155 vs 24294967155 for the headings), where it previously came back 16th. New matcher unit tests cover tier-beats-score and the sortText lexicographic ordering.

Link to Devin session: https://app.devin.ai/sessions/c57ddce975af4dd5ae7861a1f2205307
Requested by: @Feel-ix-343

devin-ai-integration Bot and others added 2 commits August 18, 2026 16:59
Co-Authored-By: Felix Zeller <felixazeller@gmail.com>
Co-Authored-By: Felix Zeller <felixazeller@gmail.com>
@Feel-ix-343 Feel-ix-343 self-assigned this Aug 18, 2026
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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