bgctl: improve usability feedback and flag guidance (part 1)#578
bgctl: improve usability feedback and flag guidance (part 1)#578
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure 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 FilesNone |
Manifest Changes vs v0.1.0-beta.27base✅ No changes debug✅ No changes crds✅ No changes |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
unknownOutputFormatErrorhelper and use it insession,debug, andescalationlist-style commands to include supported-o/--outputchoices in errors. - Clarify
watch --intervalhelp text with Go duration examples, and clarify debug--statehelp text as comma-separated. - Improve
config delete-contextmissing-context error with an actionableget-contextshint, 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.
There was a problem hiding this comment.
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, andescalationcommands (including object-returning subcommands). - Clarified flag help text for polling intervals (Go duration examples) and debug
--statefiltering (comma-separated). - Improved
config delete-contextmissing-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.
📸 UI ScreenshotsCaptured 22 screenshots (11 light, 11 dark mode) 📥 Download
Pages Captured
Screenshots are generated automatically on each PR that modifies frontend code. |
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>
There was a problem hiding this comment.
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/writeRuntimeObjecthelper and apply it acrosssession,debug, andescalationcommands for clearer-o/--outputfailures. - Improve CLI help/error guidance (watch
--intervalduration examples, root--outputhelp text,config delete-contextmissing-context suggestion). - Add unit tests for the new output-format helper and the improved
delete-contexterror; 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. |
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>
5430d63 to
744fd0f
Compare
There was a problem hiding this comment.
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
--stateflag help now documents comma-separated filters, but bothdebug session listanddebug session watchstill 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")
d642d32 to
cab6f4c
Compare
- 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
- 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)
- 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
6687fc4 to
9d9c9bc
Compare
- 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.
98a3808 to
f1b9965
Compare
- 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
Summary
bgctl session,bgctl debug, andbgctl escalationcommands to include supported format choices2s,1m)--stateflag help text to mention comma-separated filter valuesbgctl config delete-context(bgctl config get-contexts)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