Skip to content

0.17 phase 5 PR D: history lane reservation + path escape#145

Open
StanMarek wants to merge 2 commits into
masterfrom
feat/macos-smart-completions-d
Open

0.17 phase 5 PR D: history lane reservation + path escape#145
StanMarek wants to merge 2 commits into
masterfrom
feat/macos-smart-completions-d

Conversation

@StanMarek
Copy link
Copy Markdown
Owner

Summary

  • Reserve 2 high-confidence history rows (exact/prefix only, excludes flag/redirect contexts).
  • Shell-escape accepted filesystem paths at both accept and chaining call sites; quote-state aware.

Test plan

  • cargo test -p gc-suggest engine_history
  • cargo test -p gc-pty handler
  • cargo test --workspace
  • cargo clippy --all-targets -- -D warnings
  • cargo fmt --check
  • Manual: deferred to end-of-milestone smoke.

References

  • docs/plans/0.17-polish-and-trust/5-macos-smart-completions/plan.md Tasks 11-13

Notes

  • Phase 5 PR D of 4. PR A (feat/static-alias-parser) and PR B (feat/brew-query-aware-cask-split) touch gc-suggest/src/alias.rs and providers/brew.rs; PR C (feat/macos-smart-completions-c) touches engine.rs near ~1863 for params["prev_arg"] injection. PR D touches engine.rs only in rank_with_history (~1625-1700) and handler.rs (accept_suggestion_locked + accept_with_chaining) — no overlap with A/B; trivial overlap with C if it lands first.
  • provider_latency bench was not run on this host — the workspace test suite + clippy + fmt all pass; manual macOS smoke deferred to the end-of-milestone pass per the plan.

StanMarek added 2 commits May 27, 2026 21:40
When a SpecArg context saturates max_results with normal candidates, the
post-rank history fuzzy-fill flow had no room to add anything — its
remaining = max_history_results.min(max_results - results.len()) clamped
to zero. High-confidence (prefix/exact) history rows vanished from the
popup whenever it filled up.

rank_with_history now reserves up to 2 slots for prefix-matching history
BEFORE ranking candidates. The cap is reduced upstream so the popup
never grows past max_results. Flag and redirect contexts skip the lane
entirely (flags don't prefix-match command lines; redirects want
filenames).
Filesystem suggestions (FilePath/Directory kinds) are now escaped before
the byte buffer is sent to the shell. Unquoted context backslashes the
full word-splitting/expansion metacharacter set; single quotes only
need the close-reopen dance for embedded apostrophes; double quotes
escape the four-character set (", \\, $, backtick).

The escape is applied once inside accept_suggestion_locked and the
escaped replacement is returned so the chaining caller writes the SAME
text into the predicted buffer. Without that, the engine's next
context read would see the raw display text while the shell sees the
escaped form — the next completion would resolve the wrong directory.
@StanMarek StanMarek changed the title feat(suggest,handler): history lane reservation + path escape 0.17 phase 5 PR D: history lane reservation + path escape May 27, 2026
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