TUI: ignore surrounding whitespace when searching secret names

Open Beginner friendly
#796 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust, wasm
Domain
cli

Research direction

The filter lives in TuiApp::apply_filter() in crates/cli/src/tui/app.rs, where the empty check uses the trimmed query but matching uses the raw search_query. Read the existing filtering test near the in-memory fixtures in that file and add cases for leading/trailing, mixed-case, whitespace-only and internal-space queries. Done when cargo test -p sotto-cli --lib tui passes and the matched names are asserted, with search_query itself left unchanged.

Written by the indexing model from the issue text.

Description

enhancement good first issue help wanted

The problem

The web vault trims surrounding whitespace before searching secret names. The terminal dashboard does not: TuiApp::apply_filter() trims the query only to detect an empty search, then uses the untrimmed query for non-empty matching.

This means data and data have different matching semantics in the dashboard, while both are equivalent in the web vault. Make surrounding whitespace insignificant for TUI search too, so an accidentally typed leading or trailing space does not hide otherwise matching names.

This is a small usability enhancement, not a change to stored secret names.

Acceptance criteria

  • Use the trimmed query for case-insensitive TUI substring matching. Queries such as data, data, data and DATA return the same matching names.
  • Preserve the user's editable search_query text; normalise only the value used for matching so typing and Backspace remain predictable.
  • Preserve spaces inside a query rather than removing all whitespace. For example, DA TA must not become DATA.
  • Empty and whitespace-only searches continue to show the full list. Existing no-match handling, selection bounds and reveal/cache reset behaviour remain intact.
  • Extend the existing filtering tests with leading/trailing whitespace, mixed case, whitespace-only and internal-space cases. Assert matching names rather than only result counts.
  • Run cargo test -p sotto-cli --lib tui and cargo fmt --all --check.

Keep the scope to query normalisation and regression tests. Do not trim or rename stored secrets, change the web implementation, add fuzzy matching or change keyboard/mouse navigation.

Starting points

Evidence and scope

Source inspected on clean main e8ef823cedae31a1b4e435752bcb5e7485ecc69a. The TUI uses self.search_query.trim().is_empty() for the empty branch but self.search_query.to_lowercase() for matching. The web uses secretQuery.trim().toLocaleLowerCase(). Existing TUI filtering tests cover ordinary matching and no results, but not surrounding whitespace.

This is a source-verified behavioural difference and a proposed consistency improvement. The Rust binary was not built or run for this report, and no hands-on terminal reproduction is claimed.

Checked open and closed issues and open PRs. #793 covers mouse selection of filtered results, while this issue only changes how the search query is normalised. It is unrelated to #465 / PR #469, which concerns preserving secret identity while editing.

Suitable for a first contribution: a bounded Rust change with existing deterministic in-memory test fixtures. Follow CONTRIBUTING.md, use British English, and sign off commits with git commit -s.

Dominant language
Rust
Stars
31
Forks
42
Avg merge
3d 21m
Merged PRs (30d)
147

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsotto/sotto

All issues in getsotto/sotto

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.