Filter blank lines in apt generator callbacks - #378
Conversation
|
Reviewed at Blocking items, both with concrete fixes in the review:
Also missing: a regression test, and a completion-dropdown screenshot for the modified callbacks.
Responding as Warp for OSS: Open session · View run |
There was a problem hiding this comment.
Overview
Adds and registers a list_installed_versions generator for apt-get, surfacing installed package versions as completion descriptions. Requesting changes: the command literal breaks CI, the parser panics on blank output lines, and no spec references the generator, so it can never fire.
Concerns
- No visual proof. The description embeds no screenshot of a Warp completions dropdown showing real entries from the modified generator, so the user-facing result cannot be verified. Add a Markdown-embedded screenshot of the dropdown next to the cursor.
- No regression test for the new parser. Representative
dpkg-queryoutput — including the empty and malformed lines that currently panic — is never exercised, so the package-to-version mapping can regress silently. Add a focused test asserting the valid names and descriptions while malformed lines are skipped.
Verdict
Checks: build unexamined (no local cargo), tests unexamined locally — CI's suite is red at 175 passed / 1 failed (tests::all_command_specs_have_no_newlines), CI red (1 failing, 7 passing), visual proof missing
Found: 0 critical, 5 important, 0 suggestions, 0 nits
Three of the five are inline below; the fix for the command literal also turns CI green.
Responding as Warp for OSS: Open session · View run
| const LIST_INSTALLED_VERSIONS_COMMAND: &str = "dpkg-query --show | ||
| --showformat '${Package} ${Version}\n'"; |
There was a problem hiding this comment.
important — The physical newline ends the dpkg-query command here, and because this is a plain Rust string the \n becomes a literal newline byte instead of the format escape dpkg-query expects. CI fails tests::all_command_specs_have_no_newlines as a result, since generator commands must stay on one line for TMUX control mode. Collapse it to a single-line raw string, matching LIST_ALL_PACKAGES_COMMAND above:
| const LIST_INSTALLED_VERSIONS_COMMAND: &str = "dpkg-query --show | |
| --showformat '${Package} ${Version}\n'"; | |
| const LIST_INSTALLED_VERSIONS_COMMAND: &str = r#"dpkg-query --show --showformat '${Package} ${Version}\n'"#; |
| let parts: Vec<&str> = line.split(' ').collect(); | ||
| let package = parts[0]; | ||
| let version = parts[1]; |
There was a problem hiding this comment.
important — A blank or malformed output line leaves parts with fewer than two elements, so this index panics and takes down completion generation. list_available_packages above already guards against empty lines, so this is a known condition for this command's output. Skip lines that do not yield both fields:
| let parts: Vec<&str> = line.split(' ').collect(); | |
| let package = parts[0]; | |
| let version = parts[1]; | |
| let mut parts = line.split_whitespace(); | |
| let (package, version) = match (parts.next(), parts.next()) { | |
| (Some(p), Some(v)) => (p, v), | |
| _ => continue, | |
| }; |
| pub fn apt_get_generators() -> CommandSignatureGenerators { | ||
| CommandSignatureGenerators::new("apt-get") | ||
| .add_generator( | ||
| LIST_INSTALLED_VERSIONS_NAME, |
There was a problem hiding this comment.
important — No JSON spec references list_installed_versions; the only occurrences are the definition and this registration. The generator is therefore dead code and can never produce a completion. Reference it as a generatorName on the appropriate apt-get argument, then capture the dropdown to confirm it fires.
list_all_packages and list_all_deb_files_in_cwd pushed a suggestion for every output line, so a trailing newline produced an empty completion entry. Guard both the way list_available_packages already does. Fixes #380 Co-Authored-By: Warp <agent@warp.dev>
0cbea1c to
d42da80
Compare
Co-Authored-By: Warp <agent@warp.dev>
There was a problem hiding this comment.
Overview
Adds empty-line guards to list_all_packages and list_all_deb_files_in_cwd, mirroring the one list_available_packages already had. Requesting changes: lint is red on a stray EOF blank line, and the trailing-newline reproduction described in #380 cannot occur given str::lines() semantics, so the premise of the fix needs confirming.
Concerns
- No regression test for a bug fix. A test built from output ending in a single newline would pass both before and after this change, since
str::lines()drops the terminal empty segment — so add a test whose input contains a genuine blank line, or narrow #380 and this change to the case that actually reproduces. - No visual proof. The description embeds no completion-dropdown screenshot showing real entries from the modified callbacks, so the user-facing result cannot be verified. Add a Markdown-embedded screenshot of the dropdown next to the cursor.
Verdict
Checks: build unexamined (no local cargo), tests pass on CI — including all_command_specs_have_no_newlines, which the previous revision failed — CI red (lint fails cargo fmt --check; Analyze (rust) still pending), visual proof missing
Found: 0 critical, 4 important, 0 suggestions, 0 nits
Two of the four are inline below. The lint failure has a one-line fix and is the only thing between this branch and green CI.
Responding as Warp for OSS: Open session · View run
| package_name.to_string(), | ||
| "package", | ||
| )); | ||
| if !package_name.is_empty() { |
There was a problem hiding this comment.
important — str::lines() treats the final line ending as optional, so the ordinary trailing newline from dpkg-query yields no empty segment and cannot produce the blank suggestion #380 describes. This guard therefore only filters a genuine interior blank line or a doubled trailing newline, meaning the reported reproduction is not the one being fixed here. Confirm the input that actually reproduces and pin it with a test, or narrow #380 and this change to that case.
| ), | ||
| ) | ||
| } | ||
|
|
There was a problem hiding this comment.
important — This EOF blank line is the sole cause of the failing lint job: cargo fmt -p warp-command-signatures -p warp-completion-metadata --check reports exactly this line at apt.rs:103. It is also the entire content of the Trigger review loop commit, which makes no functional change. Drop that commit to remove the line and turn CI green.
list_all_packagesandlist_all_deb_files_in_cwdpush a suggestion for every line of generator output without filtering empty lines, unlikelist_available_packageswhich guards withis_empty(). A trailing newline indpkg-query/findoutput therefore produces a blank completion entry.This adds the same guard to both callbacks.
Fixes #380
Co-Authored-By: Warp agent@warp.dev