Skip to content

feat(cli): link a prefilled GitHub issue from voltage feedback and panics - #130

Draft
thebrandonlucas wants to merge 2 commits into
masterfrom
brandon/dev-2955-add-prepopulated-github-issue-links-to-the-cli
Draft

thebrandonlucas wants to merge 2 commits into
masterfrom
brandon/dev-2955-add-prepopulated-github-issue-links-to-the-cli

Conversation

@thebrandonlucas

Copy link
Copy Markdown
Contributor

Fixes DEV-2955

Problem

When a person or an agent hit a CLI bug, there was no short path to a useful GitHub issue. Reports had to be written by hand, with no build or platform, and could easily carry IDs or keys copied from a failing command.

Behavior

voltage feedback [--title TEXT] [--no-browser] [-- COMMAND...] prints a link to a prefilled new issue, and a link to search existing issues first.

Where it runs Browser Output Report marked
Terminal (stdout and stdin interactive, human output) Opens, unless --no-browser › Search existing issues first: URL and › File the issue: URL (or Opened in your browser: URL) Person
Off a terminal, --no-input, --json, or --output-file Never The report: title, labels, reporter, body, url, search_url, opened Agent ([x] An AI agent wrote this report)
  • The command after -- is reduced to voltage, its subcommand words, and flag names, so -- wallets get WALLET --profile prod --json becomes voltage wallets get --profile --json. No positional or flag value is kept.
  • The body has What happened, Steps to reproduce (with placeholders), Environment (voltage --version output, OS and architecture, command), and Checks: a search-first box and the agent box. A hidden comment asks agents to search first, keep the agent box checked, and give steps a person can run.
  • It needs no configuration or credentials and makes no request.

After a panic, the default panic message is followed by This is a bug in voltage. Report it: URL, with the source file:line and a scrubbed panic message. A dependency's absolute source path keeps only its file name, so the builder's home directory is not included.

Scrubbing and caps. Report text passes through scrub_line (control and bidi characters), and then any word that contains @ or ://, is 32 or more characters, or is 16 or more characters with a digit becomes [REDACTED] (the existing redaction marker). That covers UUIDs, API keys, tokens, invoices, addresses, emails, and URLs. The title is capped at 120 characters, the command at 300, and the panic message at 500. If the encoded URL is still more than 6,000 bytes, the body is trimmed until it fits.

Template. .github/ISSUE_TEMPLATE/bug_report.md gives manually filed reports the same sections and the bug label. Blank issues stay enabled, because the prefilled link uses title/body/labels parameters.

Design notes

  • feedback is a new module (prefilled reports, scrubbing, and the panic hook). cli::outline walks the clap command tree without parsing, so it also works on a line that does not parse. startup::run installs the hook, and execute sends feedback to file_feedback before the configuration is read.
  • Agent marking uses the same test as the rest of the CLI: no interactive terminal, or machine output, almost always means an agent or script. The checkbox is the reliable marker. GitHub applies labels= from a URL only for users with triage access, so the label is best effort.
  • No new dependency (url and webbrowser are already used). output::REDACTED becomes pub(crate) so the scrubber reuses the marker.

Try it

From the repository root, on this branch, with .env in place:

alias voltage="$PWD/scripts/voltage-staging"
voltage --build
voltage login --account me --credential-store file
voltage feedback --no-browser --title Balance-looks-wrong -- wallets get 00000000-0000-4000-8000-000000000000 --account me --json

Expect two › lines: a search link, and a File the issue: link. Open the second link. The form shows the title, the body with your version and platform, Command: voltage wallets get --account --json (no UUID, no me), and an unchecked agent box.

voltage feedback --title Balance-looks-wrong -- wallets get 00000000-0000-4000-8000-000000000000 --json

Expect the browser to open the same form.

voltage feedback --json -- payments send lnbc1example --execute | cat
voltage feedback --no-input

Expect JSON with "reporter": "agent", "opened": false, and a body with [x] An AI agent wrote this report and Command: voltage payments send --execute. No browser opens for either command.

The panic link can't be triggered on a normal build. The unit tests cover it, and I checked it by hand with a temporary panic! that echoed a wallet UUID. The link came out with src/startup.rs:LINE, the UUID as [REDACTED], and exit code 101.

Checks

  • User-visible change: docs/guides/troubleshooting.md (new Report a problem), docs/guides/scripting.md, docs/README.md, README.md, docs/quality.md (module ownership), the regenerated docs/commands.md, and CHANGELOG.md (Unreleased).
  • The verification gate passes: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo machete --with-metadata (in nix develop), cargo test --locked (207 unit, 150 integration), and python3 scripts/check-coverage.py.
  • I reviewed the diff against master with voltage-pr-review. Tests cover the new paths: an empty title, no command, an agent versus a person, --no-browser, --, negative values, attached short-flag values, a line that does not parse, the length cap, and the trimming loop.
  • CRAP report (scripts/crap-report.sh, cargo-llvm-cov 0.8.5, knots 1.16.0): 0 violations. The highest score is 18.10 (api.rs wait_for_payment, baseline). New functions: cli::outline 6, feedback::push_word 6, startup::file_feedback 4.03, and the rest 1 to 4. startup::execute is 16.
  • Checks not run: an automated panic-hook test, because a process-wide hook in the test binary would affect other tests and there is no panic to trigger, so I checked it by hand as described above. The terminal branch of file_feedback: the suite has no pty harness, so I checked it by hand under a pty.

…nics

`voltage feedback` prints a new-issue link with the build, platform, and
the misbehaving command's words and flag names (never values), plus a
link to search existing issues. A person at a terminal gets it opened in
a browser; an agent or script never does, gets the report as JSON for
`gh issue create`, and its report is marked agent-written.

A panic hook prints the same link after the panic message, with the
source line and a message scrubbed of IDs, keys, tokens, invoices,
addresses, emails, and URLs. Every part is capped so the URL stays
under 6,000 bytes. A bug report template gives manual reports the same
sections.
The prefilled link wrapped across about nine terminal lines. When a
browser opens it, the terminal now says so instead of printing it, and
a person's report leaves out the agent instructions, so a --no-browser
link stays near 700 characters. Agent and --json reports are unchanged.
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