Skip to content

Filter blank lines in apt generator callbacks - #378

Open
vikvang wants to merge 2 commits into
mainfrom
vikvang/apt-installed-versions
Open

Filter blank lines in apt generator callbacks#378
vikvang wants to merge 2 commits into
mainfrom
vikvang/apt-installed-versions

Conversation

@vikvang

@vikvang vikvang commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

list_all_packages and list_all_deb_files_in_cwd push a suggestion for every line of generator output without filtering empty lines, unlike list_available_packages which guards with is_empty(). A trailing newline in dpkg-query/find output therefore produces a blank completion entry.

This adds the same guard to both callbacks.

Fixes #380

Co-Authored-By: Warp agent@warp.dev

@cla-bot cla-bot Bot added the cla-signed label Sep 2, 2026
@warp-factories

warp-factories Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Reviewed at c83d9c81changes requested. The branch was repurposed since the previous pass, so that earlier review no longer applies to any code on it.

Blocking items, both with concrete fixes in the review:

  • lint is red. cargo fmt --check rejects the blank line at end of apt.rs, which is the entire content of the Trigger review loop commit. Dropping that commit turns CI green.
  • The premise needs confirming. str::lines() treats a final line ending as optional, so the ordinary trailing newline from dpkg-query produces no empty segment and cannot cause the blank entry list_all_packages suggests blank entries when dpkg-query output has trailing newline #380 describes. The guards only filter a genuine interior blank line or a doubled trailing newline.

Also missing: a regression test, and a completion-dropdown screenshot for the modified callbacks.

CI/test now passes, including all_command_specs_have_no_newlines. No maintainer review has been requested — that happens once the factory review reaches an accepting verdict. Push a fix and I'll take another pass.

Responding as Warp for OSS: Open session · View run

@warp-factories warp-factories Bot added the factory:warp-for-oss Owned by the Warp for OSS factory label Sep 2, 2026

@warp-factories warp-factories Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-query output — 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

Comment on lines +17 to +18
const LIST_INSTALLED_VERSIONS_COMMAND: &str = "dpkg-query --show
--showformat '${Package} ${Version}\n'";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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'"#;

Comment on lines +59 to +61
let parts: Vec<&str> = line.split(' ').collect();
let package = parts[0];
let version = parts[1];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vikvang
vikvang removed the request for review from captainsafia September 2, 2026 22:01
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>
@vikvang
vikvang force-pushed the vikvang/apt-installed-versions branch from 0cbea1c to d42da80 Compare September 2, 2026 22:01
@vikvang vikvang changed the title Add installed-versions generator for apt-get Filter blank lines in apt generator callbacks Sep 2, 2026
Co-Authored-By: Warp <agent@warp.dev>

@warp-factories warp-factories Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

importantstr::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.

),
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed factory:warp-for-oss Owned by the Warp for OSS factory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

list_all_packages suggests blank entries when dpkg-query output has trailing newline

1 participant