Skip to content

Match display refs whose project prefix carries digits - #13

Merged
raine merged 3 commits into
raine:mainfrom
seungjuchoi:fix-numeric-project-prefix-ref-search
Aug 19, 2026
Merged

Match display refs whose project prefix carries digits#13
raine merged 3 commits into
raine:mainfrom
seungjuchoi:fix-numeric-project-prefix-ref-search

Conversation

@seungjuchoi

Copy link
Copy Markdown
Contributor

Problem

In the TUI, pressing enter on a search result lands on the empty "no search results" view for every task that lives in a project whose prefix contains a digit.

Repro (hit this on my own data with v0.1.28):

  1. Create a project whose key starts with digits, e.g. 00-main. prefix_base derives the prefix from the first character of each key word, so the project gets prefix 0M and its tasks display as 0M-XYMT.
  2. Open the TUI, press /, and type something that matches such a task. The preview lists it fine.
  3. Press enter. The list switches to the search view with no results, even though the row was right there a keystroke earlier.

Same thing from the CLI:

$ aven search fin
0M-XYMT  FinceptTerminal ...      # found

$ aven search 0M-XYMT
                                  # nothing

Alphabetic prefixes (AVN-RHGF) are unaffected, which is why this went unnoticed.

Root cause

Accepting a search result re-runs the search against the result's display ref (App::accept_search_resultaccept_search_input(result.display_ref)), so the ref lane has to be able to parse PREFIX-SUFFIX back.

parse_ref_query only treated a leading group as a project prefix when it was entirely alphabetic:

if groups.len() >= 2 && groups[0].chars().all(|c| c.is_ascii_alphabetic()) {

But prefix_base takes the first character of each dash-separated key word, so digits are perfectly ordinary in a prefix (00-main0M, 01-loop0L, 03-lge0L2). For those refs the branch was skipped and the query fell through to the suffix-only branch, where 0M-XYMT collapses into 0MXYMT — which never prefix-matches the task id XYMTB8W8T3NRZDXY. No ref evidence, no results, empty view.

refs.rs::split_ref (used by show, edit, …) has always split on the first - without an alphabetic requirement, so aven show 0M-XYMT works and only search disagreed.

Fix

Treat any leading group of at most four characters as a prefix candidate. unique_project_prefix mints at most a three-character base plus a collision counter, so four is the real ceiling, and the length bound keeps ordinary hyphenated prose (release-cleanup) out of the ref lane the way the alphabetic check used to.

The prefix stays a hard filter against the project prefix in score_ref_lane, so /WRONG-7KQ9 still returns nothing.

Test

  • task_search_parser_identifies_ref_shapes_for_numeric_project_prefixes covers 0M-XYMT, /0L2-7OKI, and that release-cleanup still parses as suffix-only.
  • task_search_resolves_display_refs_for_numeric_project_prefixes seeds a 0M-prefixed project and walks the actual TUI round trip: preview a task, then re-search its display_ref and assert the task comes back with matched_field = Ref.

cargo test, cargo clippy --all-targets, and cargo fmt --check pass. The 8 failures I see in cli_sync / cli_workspaces / cli_daemon_sync / cli_inference_errors are pre-existing on main — the exec_sql helper shells out to my system sqlite3, which has no fts5 module.

I also re-ran every display ref in my own workspace (186 of them) through aven search and they all resolve now. The only refs that still don't are recurrence series refs (RCR-…), which are a separate matter — happy to send that as its own PR.

@raine
raine force-pushed the fix-numeric-project-prefix-ref-search branch 2 times, most recently from 1bc7215 to a789f00 Compare August 18, 2026 10:15
Search's ref lane only treated a leading token as a project prefix when it
was entirely alphabetic, but prefix_base builds prefixes from the first
character of each key word, so a key like 00-main yields 0M and 03-lge
yields 0L2. Those display refs fell through to the suffix-only branch,
where 0M-XYMT collapses to 0MXYMT and never matches the task id XYMT...,
so searching them returned nothing.

That surfaced in the TUI: accepting a search result re-runs the search
against the result's display ref, so pressing enter on any task in a
digit-prefixed project landed on the empty "no search results" view.

Treat any leading group of at most four characters as a prefix candidate
(unique_project_prefix mints at most a three-character base plus a
collision counter), which keeps ordinary hyphenated prose out of the ref
lane. Cover the parser shapes and the preview-then-accept round trip.
@seungjuchoi
seungjuchoi force-pushed the fix-numeric-project-prefix-ref-search branch from a789f00 to d857c48 Compare August 18, 2026 21:42
raine added 2 commits August 19, 2026 06:43
The numeric-prefix parser used a four-character ceiling that excluded valid
custom prefixes and changed how longer alphabetic prefixes were parsed. Those
refs could not resolve after selecting their tasks from TUI search.

Use the explicit project-prefix length limit for numeric groups and preserve
alphabetic prefix parsing regardless of length. Share the limit with project
validation and cover longer numeric and alphabetic refs in parser tests.
The shared prefix limit applies to explicitly assigned prefixes, while the
search parser intentionally preserves alphabetic prefix candidates of any
length. The previous constant name and parser comment obscured that distinction.

Name the explicit-prefix limit precisely and separate numeric and alphabetic
parser coverage so failures identify the affected behavior directly.
@raine
raine merged commit fba0346 into raine:main Aug 19, 2026
2 checks passed
@raine

raine commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Thanks!

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.

2 participants