Skip to content

bgctl: improve usability feedback and flag guidance (part 1)#578

Open
MaxRink wants to merge 16 commits intomainfrom
fix/issue-544-cli-usability-part1
Open

bgctl: improve usability feedback and flag guidance (part 1)#578
MaxRink wants to merge 16 commits intomainfrom
fix/issue-544-cli-usability-part1

Conversation

@MaxRink
Copy link
Copy Markdown
Collaborator

@MaxRink MaxRink commented Mar 17, 2026

Summary

  • improve unknown output format errors in bgctl session, bgctl debug, and bgctl escalation commands to include supported format choices
  • clarify watch polling interval help text to include Go duration syntax examples (2s, 1m)
  • clarify debug --state flag help text to mention comma-separated filter values
  • add actionable guidance for missing-context errors in bgctl config delete-context (bgctl config get-contexts)
  • add unit tests for the new output-format error helper and for the config missing-context guidance

Scope

This is a focused first slice of #544 (error/help text and guidance improvements). Remaining items (broader command examples, additional short flags, and update progress UX) can be handled in follow-up PRs.

Refs #544

Validation

  • go test ./pkg/bgctl/cmd -run 'TestUnknownOutputFormatError|TestConfigDeleteContextNotFound'
  • make lint
  • make test

Copilot AI review requested due to automatic review settings March 17, 2026 16:55
@MaxRink MaxRink requested a review from a team as a code owner March 17, 2026 16:55
@github-actions github-actions bot added documentation Improvements or additions to documentation pkg tests size/S labels Mar 17, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA ebb95c2.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2026

Manifest Changes vs v0.1.0-beta.27

base

✅ No changes

debug

✅ No changes

crds

✅ No changes

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 65.54622% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.86%. Comparing base (c2b918e) to head (ebb95c2).

Files with missing lines Patch % Lines
pkg/bgctl/cmd/debug.go 36.95% 23 Missing and 6 partials ⚠️
pkg/bgctl/cmd/session.go 11.11% 8 Missing ⚠️
pkg/bgctl/cmd/escalation.go 80.00% 2 Missing ⚠️
pkg/bgctl/cmd/output_format_error.go 88.23% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #578      +/-   ##
==========================================
+ Coverage   68.72%   68.86%   +0.13%     
==========================================
  Files         159      160       +1     
  Lines       33620    33687      +67     
==========================================
+ Hits        23107    23197      +90     
+ Misses       8985     8952      -33     
- Partials     1528     1538      +10     
Flag Coverage Δ
cli 62.84% <57.73%> (+1.24%) ⬆️
controller 71.21% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/bgctl/client/debug.go 73.52% <100.00%> (+3.68%) ⬆️
pkg/bgctl/cmd/config.go 75.83% <100.00%> (ø)
pkg/bgctl/cmd/root.go 86.08% <100.00%> (ø)
pkg/bgctl/output/output.go 90.00% <100.00%> (ø)
pkg/breakglass/debug/debug_session_api.go 68.66% <100.00%> (+1.49%) ⬆️
pkg/bgctl/cmd/escalation.go 71.25% <80.00%> (+9.60%) ⬆️
pkg/bgctl/cmd/output_format_error.go 88.23% <88.23%> (ø)
pkg/bgctl/cmd/session.go 42.98% <11.11%> (ø)
pkg/bgctl/cmd/debug.go 64.13% <36.95%> (+3.49%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves bgctl CLI usability by making output-format errors and flag help text more actionable, and adds tests + changelog entry to cover the new behavior.

Changes:

  • Add unknownOutputFormatError helper and use it in session, debug, and escalation list-style commands to include supported -o/--output choices in errors.
  • Clarify watch --interval help text with Go duration examples, and clarify debug --state help text as comma-separated.
  • Improve config delete-context missing-context error with an actionable get-contexts hint, and add/extend unit tests + changelog entry.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/bgctl/cmd/session.go Improves watch interval help text; upgrades list command unknown-format error to include supported choices.
pkg/bgctl/cmd/escalation.go Upgrades unknown-format errors in escalation list commands to include supported choices.
pkg/bgctl/cmd/debug.go Upgrades unknown-format errors; improves --interval and --state flag guidance.
pkg/bgctl/cmd/output_format_error.go Adds helper for consistent unknown output format errors with supported choices.
pkg/bgctl/cmd/output_format_error_test.go Adds unit tests for the new helper.
pkg/bgctl/cmd/config.go Adds actionable guidance to missing-context error in delete-context.
pkg/bgctl/cmd/config_commands_test.go Extends unit test to assert the new guidance is present.
CHANGELOG.md Documents the CLI usability improvements under Unreleased.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves bgctl CLI usability by making output-format errors more actionable, clarifying flag help text, and adding guidance for common config mistakes across the CLI command suite.

Changes:

  • Added a shared helper to produce output-format errors that list supported choices, and wired it into session, debug, and escalation commands (including object-returning subcommands).
  • Clarified flag help text for polling intervals (Go duration examples) and debug --state filtering (comma-separated).
  • Improved config delete-context missing-context error guidance and added unit tests + changelog entry.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/bgctl/cmd/session.go Improves --interval help and uses the new output-format error helper / runtime object writer paths.
pkg/bgctl/cmd/debug.go Improves unknown output-format errors, clarifies --interval and --state help, and validates output formats for object-returning commands.
pkg/bgctl/cmd/escalation.go Improves unknown output-format errors and validates output formats for get.
pkg/bgctl/cmd/root.go Updates global --output/-o help text to include wide and note command-dependent support.
pkg/bgctl/cmd/output_format_error.go Introduces helper(s) for validating output formats and producing actionable format errors.
pkg/bgctl/cmd/output_format_error_test.go Adds unit tests for the new output-format validation/error helper.
pkg/bgctl/cmd/config.go Adds actionable guidance when deleting a non-existent context.
pkg/bgctl/cmd/config_commands_test.go Extends test coverage to assert the new missing-context guidance.
CHANGELOG.md Documents the CLI usability improvements under Unreleased changes.

You can also share your feedback on Copilot code review. Take the survey.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2026

📸 UI Screenshots

Captured 22 screenshots (11 light, 11 dark mode)

📥 Download

Pages Captured

Page Light Dark
Home
Session Browser
Pending Approvals
My Requests
Session Review
Debug Sessions
Create Debug Session
404 Not Found
Mobile Views
Tablet Views

Screenshots are generated automatically on each PR that modifies frontend code.

MaxRink added a commit that referenced this pull request Apr 4, 2026
A known format like `table` that is simply not supported by a command
is misleading when called "unknown". Rename the error prefix from
"unknown output format" to "unsupported output format" so users get
accurate feedback.

Addresses Copilot review comment on PR #578.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Copilot AI review requested due to automatic review settings April 4, 2026 19:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves bgctl CLI usability by making output-format errors more actionable, clarifying flag help text, and adding guidance for common config mistakes, with accompanying unit tests. It also includes a small Playwright auth helper adjustment and documents the user-facing changes in the changelog.

Changes:

  • Add a shared unknownOutputFormatError/writeRuntimeObject helper and apply it across session, debug, and escalation commands for clearer -o/--output failures.
  • Improve CLI help/error guidance (watch --interval duration examples, root --output help text, config delete-context missing-context suggestion).
  • Add unit tests for the new output-format helper and the improved delete-context error; update changelog entry.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/bgctl/cmd/session.go Clarifies watch interval help and routes output-format errors/object output through the new helper.
pkg/bgctl/cmd/root.go Updates global --output help to mention wide and command-dependent support.
pkg/bgctl/cmd/output_format_error.go Introduces helper functions for consistent output-format validation and error messaging.
pkg/bgctl/cmd/output_format_error_test.go Adds unit tests covering helper error messages and validation behavior.
pkg/bgctl/cmd/escalation.go Uses the shared helper for unknown-format errors and validated object output.
pkg/bgctl/cmd/debug.go Uses the shared helper for unknown-format errors, updates interval/state flag help, and validates object output.
pkg/bgctl/cmd/config.go Improves missing-context error with actionable next command.
pkg/bgctl/cmd/config_commands_test.go Extends test to assert the new missing-context guidance is present.
frontend/tests/e2e/helpers/auth.ts Adjusts Playwright login flow to handle fast SSO return paths and adds authenticated-state polling.
CHANGELOG.md Documents the CLI usability improvements under Unreleased.

MaxRink added a commit that referenced this pull request Apr 4, 2026
A known format like `table` that is simply not supported by a command
is misleading when called "unknown". Rename the error prefix from
"unknown output format" to "unsupported output format" so users get
accurate feedback.

Addresses Copilot review comment on PR #578.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@MaxRink MaxRink force-pushed the fix/issue-544-cli-usability-part1 branch from 5430d63 to 744fd0f Compare April 4, 2026 21:36
Copilot AI review requested due to automatic review settings April 5, 2026 09:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings April 6, 2026 10:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

pkg/bgctl/cmd/debug.go:112

  • The PR/CHANGELOG says the debug --state flag help now documents comma-separated filters, but both debug session list and debug session watch still show "Filter by state". Either update the flag help text to mention comma-separated values (and ideally give an example), or remove that claim from the CHANGELOG/PR scope.
		},
	}
	cmd.Flags().StringVar(&cluster, "cluster", "", "Filter by cluster")
	cmd.Flags().StringVar(&state, "state", "", "Filter by state")
	cmd.Flags().StringVar(&user, "user", "", "Filter by requesting user")
	cmd.Flags().BoolVar(&mine, "mine", false, "Only sessions requested by current user")

@MaxRink MaxRink force-pushed the fix/issue-544-cli-usability-part1 branch from d642d32 to cab6f4c Compare April 6, 2026 12:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.

MaxRink added a commit that referenced this pull request Apr 7, 2026
- Rename unknownOutputFormatError -> unsupportedOutputFormatError to match
  the error message wording; update all callers and test function names
- Fix loop variable shadow in DebugSessionService.List: rename s -> state
- Update --state help text to accurately describe multi-value support via
  comma-separated values (client sends repeated state= query params)
- Refactor isKeycloakUrl() to use URL parsing instead of string matching,
  properly excluding /auth/callback and /auth/silent-renew app routes
- Consolidate Keycloak detection in clickLoginButton and loginViaKeycloak
  to use isKeycloakUrl() exclusively, removing redundant includes() checks
- Update CHANGELOG to match actual --state multi-value behavior
MaxRink added a commit that referenced this pull request Apr 7, 2026
- Rename loop variable 'state' to 'stateVal' in client/debug.go to
  avoid shadowing the method receiver 's *DebugSessionService'
- Update debug_test.go state filter test to use TitleCase values
  ('Active', 'Pending') matching actual DebugSessionState enum
- Add case-insensitive state comparison (strings.EqualFold) in
  handleListDebugSessions so both 'Active' and 'active' match
- Update server-side comment examples to use TitleCase state values
- Add frontend/test-results-a11y/ and frontend/playwright-report-a11y/
  to .gitignore and untrack committed Playwright artifacts
MaxRink added a commit that referenced this pull request Apr 7, 2026
- Tighten waitForURL regex in auth.ts to not match app-owned routes
  (/auth/callback, /auth/silent-renew): replace loose /auth[/?#] with
  /auth(?:[?#]|$) so only pathname exactly equal to /auth qualifies
- Fix --state flag help text in debug session list and watch to correctly
  advertise comma-separated multi-value support (matching actual behavior
  where strings.Split sends repeated state= query params)
- Update CHANGELOG entry to accurately describe multi-state filtering
  behavior (not single-value as previously stated)
Copilot AI review requested due to automatic review settings April 7, 2026 16:50
MaxRink added a commit that referenced this pull request Apr 7, 2026
- Propagate WriteObject error in debug session watch loop
- Update --show-full flag description to mention output format
- Remove duplicate test case in TestDebugSessionWatchCommand_ShowFullRespectsOutputFormat
- Remove stray handleJoinDebugSession comment from debug_session_api.go
- Use %q (not %s) in unsupportedOutputFormatError for proper quoting;
  update test expectations accordingly
@MaxRink MaxRink force-pushed the fix/issue-544-cli-usability-part1 branch from 6687fc4 to 9d9c9bc Compare April 7, 2026 16:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated no new comments.

MaxRink added 15 commits April 8, 2026 12:24
- Add output format validation across object commands (get/list/describe)
- Use 'unsupported' instead of 'unknown' in format error messages
- Harden keycloak auth login flow in E2E tests
- Add SPDX license headers to new files
…ported' not 'unknown')

Address Copilot review comment: the error helper already produces 'unsupported
output format' for both known-but-unsupported and truly unknown formats; update
CHANGELOG and clarify client sends repeated state= query params.
- Rename unknownOutputFormatError -> unsupportedOutputFormatError to match
  the error message wording; update all callers and test function names
- Fix loop variable shadow in DebugSessionService.List: rename s -> state
- Update --state help text to accurately describe multi-value support via
  comma-separated values (client sends repeated state= query params)
- Refactor isKeycloakUrl() to use URL parsing instead of string matching,
  properly excluding /auth/callback and /auth/silent-renew app routes
- Consolidate Keycloak detection in clickLoginButton and loginViaKeycloak
  to use isKeycloakUrl() exclusively, removing redundant includes() checks
- Update CHANGELOG to match actual --state multi-value behavior
Remove the misleading "comma-separated" claim from the --state flag help
in debug session list and watch commands; the API treats the value as a
single filter, not a comma-separated list. Update the CHANGELOG entry to
reflect the corrected behavior.
- Rename loop variable 'state' to 'stateVal' in client/debug.go to
  avoid shadowing the method receiver 's *DebugSessionService'
- Update debug_test.go state filter test to use TitleCase values
  ('Active', 'Pending') matching actual DebugSessionState enum
- Add case-insensitive state comparison (strings.EqualFold) in
  handleListDebugSessions so both 'Active' and 'active' match
- Update server-side comment examples to use TitleCase state values
- Add frontend/test-results-a11y/ and frontend/playwright-report-a11y/
  to .gitignore and untrack committed Playwright artifacts
- Tighten waitForURL regex in auth.ts to not match app-owned routes
  (/auth/callback, /auth/silent-renew): replace loose /auth[/?#] with
  /auth(?:[?#]|$) so only pathname exactly equal to /auth qualifies
- Fix --state flag help text in debug session list and watch to correctly
  advertise comma-separated multi-value support (matching actual behavior
  where strings.Split sends repeated state= query params)
- Update CHANGELOG entry to accurately describe multi-state filtering
  behavior (not single-value as previously stated)
MAJOR: add validateOutputFormat PreRunE to debug session watch command
so invalid -o values are rejected before the watch loop starts.

MINOR: use %q instead of %s in unknown-output-format error messages for
clearer quoting. Add validateDebugSessionState to client List to reject
unknown state values before sending API requests. Document --state,
--user, --show-full, --interval flags for debug session watch in
docs/cli.md. Add TestDebugSessionsList_StateFilter and
TestDebugSessionsList_InvalidStateFilter to client/debug_test.go.
- Make validateDebugSessionState case-insensitive: normalize input with
  strings.ToLower before map lookup; canonical title-cased value sent to API
- Add test for lowercase state filter input (active -> Active on wire)
- escalation get: default to yaml output when table/wide is the resolved
  format, since this command has no table renderer
- output.go: add SPDX-FileCopyrightText/SPDX-License-Identifier headers
  for REUSE compliance (CI enforces this on all Go files)
- escalation_test.go: add 5 tests covering escalation get command output
  formats (JSON, YAML, table→YAML coercion, wide→YAML coercion, unknown
  format error) to verify the table/wide coercion logic from fix #3
…ormat in show-full

- handleListDebugSessions now returns HTTP 400 for unrecognized ?state= values
  instead of silently ignoring them; validation is case-insensitive
- debug watch --show-full now respects -o/--output flag instead of hard-coding JSON
- Added unit tests for both fixes
- Propagate WriteObject error in debug session watch loop
- Update --show-full flag description to mention output format
- Remove duplicate test case in TestDebugSessionWatchCommand_ShowFullRespectsOutputFormat
- Remove stray handleJoinDebugSession comment from debug_session_api.go
- Use %q (not %s) in unsupportedOutputFormatError for proper quoting;
  update test expectations accordingly
… formats

Replace the ad-hoc table/wide coercion in 'escalation get' with an explicit
switch that passes unknown formats to unsupportedOutputFormatError (listing
table, wide, json, yaml as supported choices) so invalid -o values produce a
helpful actionable error message consistent with other commands.

Update the test assertion from 'unknown output format' to 'unsupported output
format' to match the new wording.

Addresses Copilot review thread PRRT_kwDOMRanZc55JzVi.
PR578-REL-01: The server-side validDebugSessionStates and the
client-side canonicalDebugSessionStates look like accidental
duplication. Add a comment explaining that they cannot be unified
(different packages, circular import would result) and that both
derive from the same v1alpha1 constants so they stay in sync.
Copilot AI review requested due to automatic review settings April 8, 2026 10:25
@MaxRink MaxRink force-pushed the fix/issue-544-cli-usability-part1 branch from 98a3808 to f1b9965 Compare April 8, 2026 10:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.

- Validate --show-full requires -o json or -o yaml; reject table/wide early in PreRunE
- Update docs/cli.md watch example to include -o json when using --show-full
- Add multi-state filter tests: repeated params, comma-separated, case-insensitive, invalid state 400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants