Skip to content

feat: improve environment-aware autocomplete across commands#672

Open
rbjornstad wants to merge 25 commits intomainfrom
feat/autocomplete-env-subcommands
Open

feat: improve environment-aware autocomplete across commands#672
rbjornstad wants to merge 25 commits intomainfrom
feat/autocomplete-env-subcommands

Conversation

@rbjornstad
Copy link
Contributor

Summary

  • improve environment autocomplete so subcommands suggest only relevant environments with resources
  • align app and job subcommand name/environment completion behavior with CLI argument fallbacks
  • add issues list shorthand -e for environment filtering
  • improve secrets UX with environment-aware completion, clearer ambiguous-environment guidance, and deterministic activity ordering
  • apply fix/fmt cleanups to autocomplete helper parsing

Areas covered

  • app
  • job
  • kafka
  • opensearch
  • valkey
  • issues
  • secret

Verification

  • mise run build
  • go test ./internal/app/...
  • go test ./internal/job/...
  • go test ./internal/secret/...
  • manual __complete checks for updated commands

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

📝 Changelog preview

Below is a preview of the Changelog that will be added to the next release. Only commit messages that follow the Conventional Commits specification will be included in the Changelog.

v5.17.0 - 2026-03-18

Full Changelog: v5.16.3...v5.17.0

🚀 Features

  • (app) Improve environment-aware autocomplete (f8ca033)
  • (job) Improve environment-aware autocomplete (7329849)
  • (kafka) Filter environment autocomplete by topics (41eba83)
  • (opensearch) Filter environment autocomplete by instances (d328200)
  • (valkey) Filter environment autocomplete by instances (86c1ecb)
  • (secret) Improve environment-aware UX and activity ordering (ec5d29a)

🐛 Bug Fixes

  • (issues) Add -e shorthand for environment filter (e5fe2f0)
  • Address copilot review feedback on autocomplete parsing (b2ff21c)
  • Address remaining Copilot feedback (e2cb983)
  • Apply go fix for reflect.Pointer on go1.26 (a61d3a9)
  • Remove duplicate genqlient operation blocks (7867517)
  • Reorder import statements for consistency (744d3e1)
  • Address latest Copilot feedback (3ac9a14)
  • Remove unused secret environment resolver (875d284)
  • Tighten autocomplete subcommand path detection (4e2caa3)
  • Handle flags in autocomplete argv parsing (58d6ad4)
  • Finalize strict env requirement for secrets get (73f9137)
  • Use CLI team fallback in secret get env completion (9110d77)
  • Improve env completion fallbacks and guidance text (09cbc2b)

⚙️ Miscellaneous Changes

  • Apply fix/fmt cleanups for autocomplete helpers (cd2a210)
  • Deduplicate team flag parsing in autocomplete (6d462d7)
  • Harden autocomplete team and command parsing (3e3bc8f)
  • Improve autocomplete fallback and arg parsing (12206d9)
  • Standardize formatting in TestPositionalArgAfterSubcommand (60f555e)
  • Remove duplicate env and team helper logic (f143ec9)

Copy link
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 updates CLI auto-completion to be more context-aware by suggesting environments that actually contain the relevant resources (apps, jobs, secrets, Kafka topics, Valkey/OpenSearch instances), and improves some UX around ordering and guidance messages.

Changes:

  • Add “team-scoped environment” helpers (apps/jobs/secrets/kafka) and wire them into flag autocompletion.
  • Improve autocompletion behavior for several commands by deriving team/environment from CLI args when naistrix doesn’t expose them during completion.
  • Tweak UX: secret activity is now sorted by timestamp descending; secret multi-environment error includes an example; issues --environment gets -e shorthand.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
internal/valkey/command/flag/flag.go Expand environment completion to cover more subcommands and list filtering; remove slices dependency.
internal/opensearch/command/flag/flag.go Expand environment completion to cover more subcommands and list/get behavior; remove slices dependency.
internal/secret/secret.go Add helper to return unique environments containing any secrets for a team.
internal/secret/command/get.go Change secret-name autocompletion behavior for get.
internal/secret/command/flag/flag.go Use team-scoped secret environments for env completion; add team parsing from CLI args.
internal/secret/command/environment.go Improve multi-environment error message with a concrete example invocation.
internal/secret/command/environment_test.go Update test to match the new error message.
internal/secret/activity.go Sort secret activity entries by CreatedAt descending.
internal/secret/activity_test.go Add test coverage for the new activity sorting.
internal/kafka/kafka.go Add helper to list unique environments where team has Kafka topics.
internal/kafka/command/flag/flag.go Use Kafka team environment helper for environment autocompletion; add team parsing from CLI args.
internal/job/list.go Add helpers to list environments with any jobs / environments for a specific job.
internal/job/command/trigger.go Improve job-name completion by accepting --environment/-e parsed from CLI args during completion.
internal/job/command/log.go Same as trigger: improve environment handling for job-name completion.
internal/job/command/issues.go Improve environment handling for job-name completion (supports parsing env flags from CLI args).
internal/job/command/flag/flag.go Make environment completion team/job aware; add CLI parsing fallbacks.
internal/issues/command/flag/flag.go Add -e shorthand for issues --environment flag.
internal/app/command/restart.go Add application-name autocompletion for app restart.
internal/app/command/issues.go Improve app-name completion by parsing environments from CLI args.
internal/app/command/flag/flag.go Make environment completion team/app aware; add CLI parsing fallbacks.
internal/app/api.go Add helper to list environments where a team has applications.
internal/naisapi/gql/generated.go Generated GraphQL types/query for team application environments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

@rbjornstad
Copy link
Contributor Author

Addressed Copilot review comments in 3b7d638:\n- fixed type handling in app restart autocomplete ()\n- hardened in app/job/kafka/secret to stop at and ignore invalid flag values\n\nBuild/tests run locally:\n- go test ./internal/app/... ./internal/job/... ./internal/secret/...\n- mise run build

Copy link
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 CLI auto-completion and UX by making environment/name completion more resource-aware (scoped to the team’s actual apps/jobs/topics/secrets/instances), adds supporting GraphQL-backed helpers to fetch “team environments”, and tightens a few error messages and ordering behaviors.

Changes:

  • Add “team environments” helpers (apps, jobs, Kafka topics, secrets) and use them to narrow environment auto-completion.
  • Improve auto-completion behavior for app/job/secret commands by reading team/environment from flags and CLI args (where naistrix completion context is incomplete).
  • Improve UX details: clearer secret multi-environment error message; ensure secret activity is sorted newest-first; add -e shorthand for issues environment filter.

Reviewed changes

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

Show a summary per file
File Description
internal/valkey/command/flag/flag.go Narrows environment completion to environments that actually contain Valkey instances when team context is available.
internal/secret/secret.go Adds helper to list unique environments where a team has secrets.
internal/secret/command/get.go Adjusts secret-name completion behavior for get.
internal/secret/command/flag/flag.go Updates secret env auto-completion to prefer team-specific environments; adds CLI arg parsing for --team.
internal/secret/command/environment.go Improves error message when a secret exists in multiple environments.
internal/secret/command/environment_test.go Updates test expectation for the improved error message.
internal/secret/activity.go Sorts secret activity entries newest-first.
internal/secret/activity_test.go Adds test coverage for activity sorting behavior.
internal/opensearch/command/flag/flag.go Narrows environment completion to environments that actually contain OpenSearch instances when team context is available.
internal/naisapi/gql/generated.go Regenerates GraphQL client code for new app team-environment query.
internal/kafka/kafka.go Adds helper to list unique environments where a team has Kafka topics.
internal/kafka/command/flag/flag.go Uses Kafka “team topic environments” to improve environment auto-completion.
internal/job/list.go Adds helpers to list team job environments and job-specific environments.
internal/job/command/trigger.go Improves job-name completion by resolving environment from CLI flags when not present in naistrix args.
internal/job/command/log.go Same as trigger: improves job-name completion environment resolution.
internal/job/command/issues.go Improves job-name completion by resolving environments from CLI flags when not present in flags.
internal/job/command/flag/flag.go Uses team/job-specific environment helpers to narrow environment completion (but currently has a compilation issue).
internal/issues/command/flag/flag.go Adds -e shorthand for environment filter.
internal/app/command/restart.go Adds app-name auto-completion for restart, resolving environment from flags/CLI.
internal/app/command/issues.go Improves app-name completion by resolving environments from CLI flags when not present in flags.
internal/app/command/flag/flag.go Uses team/app-specific environment helpers to narrow environment completion (but currently has a compilation issue).
internal/app/api.go Adds helper to list unique environments where a team has applications, backed by GraphQL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

@rbjornstad
Copy link
Contributor Author

rbjornstad commented Mar 17, 2026

Follow-up on the reflect discussion:

  • ran go fix ./... on this branch (go 1.26.1 per go.mod)
  • go fix rewrote reflect kind checks to reflect.Pointer
  • verified with mise run build\n\nSo for this repo/toolchain, reflect.Pointer is the go-fix canonical form and compiles as expected.

Copy link
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 CLI auto-completion and environment scoping across multiple resource domains (apps, jobs, secrets, Kafka topics, OpenSearch, Valkey) by preferring “team-relevant” environments and tightening completion behavior for certain commands.

Changes:

  • Add team-scoped “environment discovery” helpers (apps/jobs/secrets/Kafka) and use them in flag auto-completion.
  • Improve UX in a few places (more actionable secret environment error, stable sorting of secret activity).
  • Extend/adjust command auto-completion to better respect provided --team / --environment values.

Reviewed changes

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

Show a summary per file
File Description
internal/valkey/command/flag/flag.go Improve environment auto-complete to prefer envs that actually have Valkey instances for relevant subcommands/listing.
internal/opensearch/command/flag/flag.go Same as Valkey: prefer envs with OpenSearch instances during completion.
internal/secret/secret.go Add TeamSecretEnvironments helper to return unique sorted envs where the team has secrets.
internal/secret/command/flag/flag.go Use team-scoped secret environments for environment auto-completion; add CLI arg parsing for --team.
internal/secret/command/get.go Adjust secret name completion behavior for get to require environment.
internal/secret/command/environment.go Improve error message when a secret exists in multiple environments (adds example command).
internal/secret/command/environment_test.go Update expected error string for the improved message.
internal/secret/activity.go Sort secret activity entries by CreatedAt descending.
internal/secret/activity_test.go Add coverage asserting descending sort order.
internal/kafka/kafka.go Add TeamTopicEnvironments helper for env discovery based on team Kafka topics.
internal/kafka/command/flag/flag.go Use team-scoped topic environments for environment auto-completion.
internal/job/list.go Add TeamJobEnvironments/JobEnvironments helpers for env discovery based on jobs.
internal/job/command/flag/flag.go Use team-scoped job environments for environment auto-completion (including trigger edge-case parsing).
internal/job/command/trigger.go Improve job-name auto-complete by reading env from flags or CLI args.
internal/job/command/log.go Same improvement for log command job-name completion.
internal/job/command/issues.go Improve job-name completion by reading envs from flags or CLI args.
internal/app/api.go Add TeamApplicationEnvironments GraphQL-backed helper to list envs where team has apps.
internal/app/command/flag/flag.go Use team-scoped application environments for environment auto-completion (including restart edge-case parsing).
internal/app/command/restart.go Add app-name auto-completion for restart command, scoped by team + single env.
internal/app/command/issues.go Improve app-name auto-completion by reading environments from flags or CLI args.
internal/issues/command/flag/flag.go Add -e shorthand for issues environment filter flag.
internal/naisapi/gql/generated.go Regenerated GraphQL client to include TeamApplicationEnvironments operation/types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copy link
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 pull request improves CLI auto-completion by making environment/name suggestions more context-aware (team-specific and resource-specific), and tweaks a few related UX/details (sorting and error messaging).

Changes:

  • Add team-scoped environment discovery helpers for apps, jobs, Kafka topics, and secrets, and use them in flag auto-completion.
  • Improve/expand auto-completion behavior for several commands by reading relevant CLI flags/args (e.g. --team, --environment) when naistrix doesn’t provide enough context.
  • Update secret activity ordering and refine an error message when a secret exists in multiple environments.

Reviewed changes

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

Show a summary per file
File Description
internal/valkey/command/flag/flag.go Adjust environment completion logic for instance-scoped operations and list filtering.
internal/opensearch/command/flag/flag.go Same as Valkey: instance-scoped environment completions and list filtering.
internal/secret/secret.go Add helper to derive unique/sorted environments where a team has secrets.
internal/secret/command/flag/flag.go Use team-derived secret environments for env auto-completion; add CLI --team parsing.
internal/secret/command/get.go Change secret-name autocomplete behavior for secrets get.
internal/secret/command/environment.go Improve multi-environment error message with a concrete example command.
internal/secret/command/environment_test.go Update test expectation for the new error message.
internal/secret/activity.go Sort activity entries by CreatedAt descending.
internal/secret/activity_test.go Add coverage ensuring activity sorting is descending by time.
internal/kafka/kafka.go Add helper to derive unique/sorted environments where a team has Kafka topics.
internal/kafka/command/flag/flag.go Use team-derived Kafka topic environments for env auto-completion; add CLI --team parsing.
internal/job/list.go Add helpers to derive job environments per team / per job name.
internal/job/command/flag/flag.go Make job environment completion team- and job-name-aware; add CLI arg parsing helpers.
internal/job/command/trigger.go Improve job-name autocomplete by reading --environment values from CLI args.
internal/job/command/log.go Same as trigger: use CLI --environment values for job-name autocomplete.
internal/job/command/issues.go Same pattern: use CLI --environment values for job-name autocomplete.
internal/app/api.go Add helper to derive unique/sorted environments where a team has applications (new GraphQL query).
internal/naisapi/gql/generated.go Genqlient output updated for new TeamApplicationEnvironments query/types.
internal/app/command/flag/flag.go Make app environment completion team- and app-name-aware; add CLI arg parsing helpers.
internal/app/command/restart.go Add app-name autocomplete for app restart, using --environment from CLI args when needed.
internal/app/command/issues.go Use CLI --environment values for app-name autocomplete in app issues.
internal/issues/command/flag/flag.go Add -e shorthand for issues environment filter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

@rbjornstad rbjornstad force-pushed the feat/autocomplete-env-subcommands branch from bd7c05b to 7867517 Compare March 17, 2026 15:26
Copy link
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 enhances CLI auto-completion across several resource areas (apps, jobs, secrets, Kafka, Valkey, OpenSearch) by narrowing environment suggestions to the team’s actual environments, introducing new cliflags helpers for parsing os.Args, and adding supporting GraphQL queries/helpers. It also improves determinism in secret activity output by sorting by creation time.

Changes:

  • Add cliflags.FirstFlagValue and cliflags.HasSubCommandPath (with tests) and use them to improve context-aware completion logic.
  • Introduce team-scoped “environment discovery” helpers for apps/jobs/secrets/Kafka to drive more relevant environment auto-completion.
  • Adjust secret get behavior to require an explicit environment and update secret activity ordering + tests.

Reviewed changes

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

Show a summary per file
File Description
internal/valkey/command/flag/flag.go Improves environment auto-completion for Valkey commands using subcommand-path detection and team-scoped env fetching.
internal/opensearch/command/flag/flag.go Improves environment auto-completion for OpenSearch credentials and list/get flows, using subcommand-path detection.
internal/secret/secret.go Adds team-level secret environment discovery via a new GraphQL query and sorting.
internal/secret/command/get.go Makes secrets get require an explicit environment and adjusts name completion behavior.
internal/secret/command/flag/flag.go Adds team-aware environment auto-completion for secrets (including CLI arg team extraction).
internal/secret/command/environment.go Refines selection error messaging for multi-environment secrets; removes resolver helper.
internal/secret/command/environment_test.go Updates expected error text for multi-environment selection.
internal/secret/activity.go Sorts secret activity entries by CreatedAt descending.
internal/secret/activity_test.go Adds coverage to verify descending time sort for secret activity.
internal/kafka/kafka.go Adds team-level Kafka topic environment discovery to support smarter completion.
internal/kafka/command/flag/flag.go Uses team-scoped Kafka environments for auto-completion when team is known.
internal/job/list.go Adds team/job-level job environment discovery helpers to support completion.
internal/job/command/trigger.go Improves job name completion by deriving a single environment from parsed flags or CLI args.
internal/job/command/log.go Same as trigger: improves job name completion environment derivation.
internal/job/command/issues.go Uses CLI arg-derived environments when not present in parsed flags for job name completion.
internal/job/command/flag/flag.go Adds team/job-aware environment auto-completion and CLI arg parsing for trigger-related cases.
internal/issues/command/flag/flag.go Adds -e short flag for issues environment filter.
internal/cliflags/flags.go Adds FirstFlagValue and HasSubCommandPath utilities for CLI arg inspection.
internal/cliflags/flags_test.go Adds tests for FirstFlagValue and HasSubCommandPath.
internal/app/command/restart.go Adds application-name auto-completion for restart, requiring team + exactly one environment.
internal/app/command/issues.go Improves application-name completion by reading environment values from CLI args when needed.
internal/app/command/flag/flag.go Adds team/app-aware environment auto-completion and CLI arg parsing for restart-related cases.
internal/app/api.go Adds team-level application environment discovery via new GraphQL query and sorting.
internal/naisapi/gql/generated.go Updates generated GraphQL bindings for the new environment discovery queries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copy link
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 enhances CLI auto-completion by making environment suggestions context-aware (based on the selected team and existing resources), adds shared helpers for parsing CLI args, and introduces a few supporting API/query helpers (plus a small secret activity ordering tweak).

Changes:

  • Add cliflags helpers to extract flag values and detect subcommand paths, and use them to improve environment auto-completion in multiple commands.
  • Add “team-scoped environments” helpers for secrets/apps/jobs/kafka to suggest only environments where resources exist.
  • Update secret activity output to be sorted by creation time (descending), with corresponding tests.

Reviewed changes

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

Show a summary per file
File Description
internal/valkey/command/flag/flag.go Uses cliflags.HasSubCommandPath and improves environment completion for list/credentials flows.
internal/secret/secret.go Adds TeamSecretEnvironments backed by a new GraphQL query to support smarter environment completion.
internal/secret/command/get.go Changes validation and autocomplete behavior for secrets get, now always requiring an environment.
internal/secret/command/flag/flag.go Improves secret environment auto-completion (team-aware; suggests envs with secrets).
internal/secret/command/environment.go Updates multi-environment error message and removes unused resolver logic (now only selection helper remains).
internal/secret/command/environment_test.go Updates expected error message for multi-environment secrets.
internal/secret/activity.go Sorts returned activity entries by CreatedAt descending.
internal/secret/activity_test.go Adds coverage to ensure activity is sorted by creation time descending.
internal/opensearch/command/flag/flag.go Uses cliflags.HasSubCommandPath and improves environment completion for list/get flows.
internal/naisapi/gql/generated.go Adds generated types/operations for the new secret/app environment queries.
internal/kafka/kafka.go Adds TeamTopicEnvironments to return unique environments where the team has Kafka topics.
internal/kafka/command/flag/flag.go Makes Kafka environment completion team-aware (envs where topics exist), with fallback to all envs.
internal/job/list.go Adds helpers to list unique job environments per team and per job name.
internal/job/command/trigger.go Improves job name completion by resolving the effective --environment from CLI args when needed.
internal/job/command/log.go Same as trigger: improves job name completion when environment is provided via CLI args.
internal/job/command/issues.go Uses CLI-parsed environment flags when completing job names.
internal/job/command/flag/flag.go Makes job environment completion team-aware and optionally job-name-aware; adds CLI arg parsing for trigger completion.
internal/issues/command/flag/flag.go Adds -e shorthand for the issues --environment flag.
internal/cliflags/flags.go Adds FirstFlagValue and HasSubCommandPath utilities for parsing os.Args.
internal/cliflags/flags_test.go Adds tests for FirstFlagValue and HasSubCommandPath.
internal/app/command/restart.go Adds app name auto-completion for restart, requiring team + exactly one environment.
internal/app/command/issues.go Uses CLI-parsed environment flags when completing application names.
internal/app/command/flag/flag.go Makes app environment completion team-aware and optionally app-name-aware; adds CLI arg parsing for restart completion.
internal/app/api.go Adds TeamApplicationEnvironments query helper used for smarter environment completion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copy link
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 CLI auto-completion and environment selection across multiple resource commands by introducing shared CLI-args helpers and adding team-scoped environment lookups (apps, jobs, secrets, Kafka topics, Valkey/OpenSearch instances), while also tightening secret get to require an explicit environment.

Changes:

  • Add cliflags.FirstFlagValue and cliflags.HasSubCommandPath (plus tests) and use them to make completions more context-aware.
  • Add team-scoped “environments with resources” queries/helpers for apps, jobs, secrets, and Kafka topics; wire them into environment auto-completion.
  • Adjust secret get behavior to require --environment/-e, and sort secret activity output by CreatedAt descending.

Reviewed changes

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

Show a summary per file
File Description
internal/valkey/command/flag/flag.go Improves environment auto-completion by detecting relevant subcommand paths and returning only environments with Valkey instances when appropriate.
internal/opensearch/command/flag/flag.go Similar environment completion improvements for OpenSearch, including better behavior for get and list completion contexts.
internal/secret/secret.go Adds TeamSecretEnvironments and a dedicated GraphQL query to list environments that contain secrets for a team.
internal/secret/command/flag/flag.go Updates environment auto-completion to prefer team-scoped “environments with secrets” suggestions.
internal/secret/command/get.go Makes --environment/-e required for secret get and updates completion behavior accordingly.
internal/secret/command/environment.go Removes the prior “select environment” resolution logic; keeps single-environment flag validation utilities.
internal/secret/command/environment_test.go Removes tests tied to the deleted environment-selection logic.
internal/secret/activity.go Ensures secret activity entries are sorted by newest first.
internal/secret/activity_test.go Adds coverage for the new activity sorting behavior.
internal/kafka/kafka.go Adds TeamTopicEnvironments helper to list unique environments where a team has Kafka topics.
internal/kafka/command/flag/flag.go Uses team-scoped Kafka topic environments to improve environment auto-completion.
internal/job/list.go Adds helpers to list environments with jobs (team-wide and per job name).
internal/job/command/trigger.go Improves job name completion by resolving environment from CLI args when not present on flags.
internal/job/command/log.go Same job name completion improvement for job log.
internal/job/command/issues.go Updates job name completion to support pulling environments from CLI args when not set on flags.
internal/job/command/flag/flag.go Reworks environment auto-completion to prefer team/job-scoped environments; adds CLI-args parsing for trigger completion context.
internal/app/api.go Adds TeamApplicationEnvironments query helper for team-scoped environment completion.
internal/app/command/flag/flag.go Reworks app environment auto-completion to prefer team/app-scoped environments; adds CLI-args parsing for restart completion context.
internal/app/command/restart.go Adds positional app-name auto-completion based on team + exactly one environment.
internal/app/command/issues.go Updates app name completion to support pulling environments from CLI args when not set on flags.
internal/issues/command/flag/flag.go Adds -e short flag for environment filtering.
internal/cliflags/flags.go Adds new CLI-args helpers (FirstFlagValue, HasSubCommandPath) used by the updated completion logic.
internal/cliflags/flags_test.go Adds tests for the new cliflags helpers.
internal/naisapi/gql/generated.go Regenerates GraphQL types/operations for the newly introduced queries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copy link
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 CLI auto-completion by making environment/name suggestions context-aware (team/resource-specific) across multiple commands, backed by new helper functions for parsing CLI args and new GraphQL queries for “team has resources in these environments”.

Changes:

  • Add internal/cliflags helpers to extract flag values from os.Args and detect subcommand paths during shell completion.
  • Make environment auto-completion prefer “environments where the team has X” for apps, jobs, secrets, Kafka topics, Valkey and OpenSearch.
  • Tighten secret get behavior by requiring --environment/-e, and improve secret activity ordering by sorting newest-first.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
internal/cliflags/flags.go Adds arg-parsing helpers used to improve completion context detection.
internal/cliflags/flags_test.go Adds unit tests for the new cliflags helpers.
internal/app/api.go Adds GraphQL-backed TeamApplicationEnvironments helper.
internal/app/command/flag/flag.go Environment completion now prefers team app environments; adds CLI-arg parsing helpers for completion edge cases.
internal/app/command/restart.go Adds app-name completion requiring a single environment.
internal/app/command/issues.go Uses CLI arg parsing to support environment filtering during completion.
internal/job/list.go Adds TeamJobEnvironments / JobEnvironments helpers for completion.
internal/job/command/flag/flag.go Environment completion now prefers team/job-specific environments; adds CLI-arg parsing helpers.
internal/job/command/trigger.go Improves job-name completion when environment is provided via CLI args.
internal/job/command/log.go Improves job-name completion when environment is provided via CLI args.
internal/job/command/issues.go Improves job-name completion when environment is provided via CLI args.
internal/secret/secret.go Adds TeamSecretEnvironments and GraphQL query to power environment completion.
internal/secret/command/flag/flag.go Improves secret environment completion using team secret environments.
internal/secret/command/get.go Makes --environment/-e required and aligns validation + name completion accordingly.
internal/secret/command/environment.go Removes multi-environment resolution logic; keeps environment-flag counting helpers.
internal/secret/command/environment_test.go Removes tests for deleted environment resolution logic.
internal/secret/activity.go Sorts activity entries by CreatedAt descending.
internal/secret/activity_test.go Adds coverage for the new activity sort order.
internal/kafka/kafka.go Adds TeamTopicEnvironments helper for completion.
internal/kafka/command/flag/flag.go Environment completion now prefers team Kafka-topic environments.
internal/valkey/command/flag/flag.go Uses cliflags-based subcommand path detection for more precise env completion.
internal/opensearch/command/flag/flag.go Uses cliflags-based subcommand path detection; improves env completion for list/get flows.
internal/issues/command/flag/flag.go Adds -e shorthand for issues environment filter.
internal/naisapi/gql/generated.go Regenerates GraphQL client/types for newly added queries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copy link
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 enhances CLI auto-completion and environment filtering across multiple resource commands (apps, jobs, secrets, Kafka, OpenSearch, Valkey) by adding more context-aware environment lookups and introducing shared CLI-arg parsing helpers.

Changes:

  • Added internal/cliflags helpers to reliably parse flag values and detect subcommand paths from os.Args, with accompanying tests.
  • Improved environment auto-completion to prefer “environments where the team actually has resources” (apps/jobs/secrets/topics/instances) before falling back to all environments.
  • Adjusted secret behavior: secret get now requires --environment/-e, and secret activity output is sorted by newest-first.

Reviewed changes

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

Show a summary per file
File Description
internal/valkey/command/flag/flag.go Uses cliflags helpers to better detect when to suggest only environments with Valkey instances; improves list env completion.
internal/opensearch/command/flag/flag.go Same as Valkey: more accurate “instance environments” completion and improved list/get env completion behavior.
internal/secret/secret.go Adds GraphQL-backed TeamSecretEnvironments to list environments where a team has secrets (unique + sorted).
internal/secret/command/get.go Makes --environment/-e required for secret get; updates validation and autocomplete accordingly.
internal/secret/command/flag/flag.go Improves environment autocomplete by suggesting only environments where the team has secrets when possible.
internal/secret/command/environment.go Removes now-unneeded environment-resolution helpers after making env mandatory for secret get.
internal/secret/command/environment_test.go Deletes tests for the removed environment-selection helper.
internal/secret/activity.go Sorts built secret activity entries by CreatedAt descending.
internal/secret/activity_test.go Adds coverage asserting activity sorting order (newest first).
internal/kafka/kafka.go Adds TeamTopicEnvironments helper to derive environments where the team has Kafka topics.
internal/kafka/command/flag/flag.go Uses TeamTopicEnvironments (when team is known) to narrow environment autocomplete.
internal/job/list.go Adds TeamJobEnvironments and JobEnvironments helpers for environment discovery from jobs.
internal/job/command/flag/flag.go Makes job environment autocomplete context-aware (team/job-name/trigger completion), using cliflags.
internal/job/command/trigger.go Improves job-name autocomplete by handling environment values coming from CLI args during completion.
internal/job/command/log.go Same as trigger: better environment handling for job-name autocomplete.
internal/job/command/issues.go Same as trigger/log: supports CLI-provided environment values for job-name autocomplete.
internal/issues/command/flag/flag.go Adds -e shorthand for issues environment flag.
internal/cliflags/flags.go Adds FirstFlagValue, HasSubCommandPath*, and PositionalArgAfterSubcommand utilities.
internal/cliflags/flags_test.go Adds tests for new cliflags helpers.
internal/app/command/restart.go Adds autocomplete for app names in app restart, requiring exactly one environment.
internal/app/command/issues.go Lets app-name autocomplete use environments parsed from CLI args when needed.
internal/app/command/flag/flag.go Makes app environment autocomplete team- and app-name-aware; adds CLI-arg based fallback for restart completion.
internal/app/api.go Adds TeamApplicationEnvironments GraphQL query and helper (unique + sorted).
internal/naisapi/gql/generated.go Regenerates GraphQL client/types for the newly added queries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copy link
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 pull request improves CLI auto-completion and environment scoping across several resource commands (apps, jobs, secrets, Kafka topics, Valkey, OpenSearch) by introducing shared CLI-args parsing helpers and adding team-scoped “available environments” lookups.

Changes:

  • Add internal/cliflags utilities for extracting flag values and detecting subcommand paths/positionals, with accompanying tests.
  • Update multiple command flag auto-completers to prefer team-scoped environment suggestions (where possible) instead of always listing all environments.
  • Simplify secret get by requiring --environment/-e, add team-wide secret environment lookup, and ensure secret activity is sorted newest-first.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/valkey/command/flag/flag.go Uses cliflags helpers and improves environment auto-completion for Valkey instance-related flows.
internal/opensearch/command/flag/flag.go Uses cliflags helpers and improves environment auto-completion for OpenSearch instance-related flows.
internal/secret/secret.go Adds team-wide secret environment query + helper returning unique, sorted envs.
internal/secret/command/get.go Makes --environment/-e required for secret get and aligns auto-completion accordingly.
internal/secret/command/flag/flag.go Environment auto-completion now prefers environments where the team actually has secrets.
internal/secret/command/environment.go Removes secret environment selection logic; retains single-flag validation helpers.
internal/secret/command/environment_test.go Removes tests tied to removed secret environment selection logic.
internal/secret/activity.go Sorts secret activity entries by creation time descending.
internal/secret/activity_test.go Adds test coverage for newest-first activity sorting.
internal/opensearch/command/flag/flag.go Adds environment narrowing for get and list environment completion using credential environments.
internal/naisapi/gql/generated.go Updates generated GraphQL types/operations to support new queries.
internal/kafka/kafka.go Adds TeamTopicEnvironments to drive team-scoped environment completion.
internal/kafka/command/flag/flag.go Kafka environment completion now prefers team topic environments when team is known.
internal/job/list.go Adds TeamJobEnvironments and JobEnvironments to support job-scoped env completion.
internal/job/command/trigger.go Uses CLI arg inspection to enable better job-name completion when env is supplied via args.
internal/job/command/log.go Uses CLI arg inspection to enable better job-name completion when env is supplied via args.
internal/job/command/issues.go Improves job-name completion when environments are supplied via repeated flags.
internal/job/command/flag/flag.go Job environment completion now prefers team/job-specific environments; adds trigger-path positional handling.
internal/issues/command/flag/flag.go Adds -e shorthand for issues environment flag.
internal/cliflags/flags.go Introduces FirstFlagValue, subcommand-path detection, and positional extraction helpers.
internal/cliflags/flags_test.go Adds tests for new cliflags helpers.
internal/app/command/restart.go Adds app-name auto-completion for restart, using team + single environment.
internal/app/command/issues.go Improves app-name completion when environments are supplied via repeated flags.
internal/app/command/flag/flag.go App environment completion now prefers team/app-specific environments; adds restart-path positional handling.
internal/app/api.go Adds TeamApplicationEnvironments query to drive team-scoped environment completion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copy link
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 CLI auto-completion by making environment suggestions context-aware (team/resource specific) and by adding shared helpers for parsing command/flag context from os.Args. It also tightens secret get semantics to require --environment/-e, and adds a few new GraphQL-backed helpers/queries to support the new completions.

Changes:

  • Add internal/cliflags helpers to extract flag values and detect subcommand paths/positionals during shell completion.
  • Update multiple command flag autocompleters (app/job/secret/kafka/opensearch/valkey) to suggest only environments that actually contain relevant resources for the selected team.
  • Require --environment/-e for secret get, remove the old “resolve environment” selection logic, and ensure secret activity output is sorted newest-first.

Reviewed changes

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

Show a summary per file
File Description
internal/cliflags/flags.go Adds helpers for extracting flag values, detecting subcommand paths, and finding positionals for completion logic.
internal/cliflags/flags_test.go Adds unit tests for the new cliflags helpers.
internal/valkey/command/flag/flag.go Uses subcommand-path detection for instance env completion; narrows list env completion to team instances.
internal/opensearch/command/flag/flag.go Same as Valkey: improved subcommand detection and env completion narrowing.
internal/secret/secret.go Adds GraphQL-backed TeamSecretEnvironments to list envs where a team has secrets.
internal/secret/command/flag/flag.go Uses team-specific secret env lists for env autocompletion (incl. list/get env flows).
internal/secret/command/get.go Makes --environment/-e required; simplifies execution path accordingly; updates name completion requirement.
internal/secret/command/environment.go Removes obsolete environment resolution/selection helpers (now that env is required).
internal/secret/command/environment_test.go Removes tests tied to the deleted selection helper.
internal/secret/activity.go Sorts built activity entries by CreatedAt descending.
internal/secret/activity_test.go Adds coverage to validate the new activity sorting.
internal/kafka/kafka.go Adds TeamTopicEnvironments helper (env list derived from team topics) for completion.
internal/kafka/command/flag/flag.go Uses TeamTopicEnvironments to suggest environments for a team when completing --environment.
internal/job/list.go Adds helpers to derive team/job environments via GraphQL for better completion.
internal/job/command/flag/flag.go Updates environment completion to be team-aware and (when possible) job-name-aware.
internal/job/command/trigger.go Improves job name completion by reliably deriving a single environment from CLI args during completion.
internal/job/command/log.go Same as trigger: robustly derive a single environment for name completion.
internal/job/command/issues.go Uses CLI-derived environments when sticky flags don’t expose env values during completion.
internal/app/api.go Adds TeamApplicationEnvironments helper to list envs where a team has applications.
internal/app/command/flag/flag.go Makes app env completion team-aware and (when possible) app-name-aware (restart completion support).
internal/app/command/restart.go Adds app-name auto-completion for restart, requiring exactly one environment.
internal/app/command/issues.go Uses CLI-derived environments when needed for app-name completion.
internal/issues/command/flag/flag.go Adds -e shorthand to the issues list environment flag.
internal/naisapi/gql/generated.go Updates generated GraphQL bindings for new queries used by completion helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copy link
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 CLI auto-completion by making it more context-aware (team/resource scoped), adds reusable CLI-args parsing helpers, and adjusts secret/env behavior (notably making secrets get require --environment).

Changes:

  • Add internal/cliflags helpers to parse flag values and detect subcommand paths from os.Args, then use them to make completions more accurate.
  • Improve environment auto-completion for app/job/secret/kafka/opensearch/valkey by suggesting only environments that actually contain relevant resources for the selected team.
  • Make nais secrets get require --environment/-e and remove the previous “auto-resolve environment” behavior (and its tests); also sort secret activity newest-first.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
internal/valkey/command/flag/flag.go Uses cliflags.HasSubCommandPathWithValueFlags and adds team-scoped env completion for list/credentials flows.
internal/opensearch/command/flag/flag.go Same as Valkey: subcommand-path detection + env completion improvements.
internal/secret/secret.go Adds TeamSecretEnvironments and a dedicated GraphQL query for env suggestions.
internal/secret/command/get.go Requires --environment/-e for secrets get and simplifies execution path.
internal/secret/command/flag/flag.go Adds team-aware env completion for secrets (including new team/env inference from CLI args).
internal/secret/command/environment.go Removes environment-selection logic, keeps single-flag validation helpers.
internal/secret/command/environment_test.go Removes tests tied to the removed environment-selection logic.
internal/secret/activity.go Sorts secret activity entries by CreatedAt (descending).
internal/secret/activity_test.go Adds coverage asserting activity sorting behavior.
internal/kafka/kafka.go Adds TeamTopicEnvironments to enable team-scoped env suggestions.
internal/kafka/command/flag/flag.go Uses TeamTopicEnvironments to improve env completion when team is known.
internal/job/list.go Adds TeamJobEnvironments / JobEnvironments helpers for env suggestions.
internal/job/command/trigger.go Improves job-name completion by pulling env values from CLI args when needed.
internal/job/command/log.go Same improvement as trigger for job-name completion.
internal/job/command/issues.go Passes env list derived from CLI args to job-name completion.
internal/job/command/flag/flag.go Adds team/job-aware env completion (including reading positional args from CLI args for job trigger).
internal/issues/command/flag/flag.go Adds -e shorthand for issue environment filter.
internal/cliflags/flags.go Adds FirstFlagValue, HasSubCommandPath*, and PositionalArgAfterSubcommand.
internal/cliflags/flags_test.go Adds unit tests for the new cliflags helpers.
internal/app/command/restart.go Adds app-name completion for app restart, requiring team + exactly one environment.
internal/app/command/issues.go Improves app-name completion by reading env values from CLI args when needed.
internal/app/command/flag/flag.go Adds team/app-aware env completion (and restart subcommand detection).
internal/app/api.go Adds TeamApplicationEnvironments GraphQL query to support env suggestions.
internal/naisapi/gql/generated.go Regenerates GraphQL types/ops for new queries.
Comments suppressed due to low confidence (2)

internal/valkey/command/flag/flag.go:103

  • Same issue as above: when valkeyCredentialEnvironments returns an empty list (no instances for team), completion will produce no candidates. Add a len(envs) > 0 guard (and fall back to autoCompleteEnvironments(ctx) or a "no environments" message) to avoid silent empty completions.
	if team != "" && isInstanceEnvironmentCompletionFromCLIArgs() {
		envs, err := valkeyCredentialEnvironments(ctx, team)
		if err == nil {
			return envs, "Available environments with Valkey instances"
		}
	}

internal/opensearch/command/flag/flag.go:38

  • If opensearchCredentialEnvironments returns an empty slice (team has no instances), completion returns no candidates. Consider guarding on len(envs) > 0 and falling back to autoCompleteEnvironments(ctx) (or a specific message) to avoid silent empty suggestions.
	if team != "" && isInstanceEnvironmentCompletionFromCLIArgs() {
		envs, err := opensearchCredentialEnvironments(ctx, team)
		if err == nil {
			return envs, "Available environments with OpenSearch instances"
		}
	}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

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.

2 participants