Skip to content

Auto-select a sole discovered target#10

Merged
V3RON merged 2 commits intomasterfrom
feat/auto-select-single-target
May 6, 2026
Merged

Auto-select a sole discovered target#10
V3RON merged 2 commits intomasterfrom
feat/auto-select-single-target

Conversation

@V3RON
Copy link
Copy Markdown
Contributor

@V3RON V3RON commented May 6, 2026

Target-required commands now auto-select the only discoverable target instead of failing with a manual selection error. Users only need to run target list and target select when more than one target is available.

Summary

  • add a CLI helper that checks daemon status and auto-selects a target when default discovery finds exactly one result
  • route target-required commands through that helper while leaving explicit target-management and stored-artifact commands unchanged
  • add CLI tests for single-target auto-selection, selected-target passthrough, and the multi-target guidance message

Closes #9.

Backward-Compatibility

  • Existing commands, flags, daemon IPC, and persisted selected-target behavior remain compatible.
  • target list, target select, target clear, start, stop, and status are unchanged.
  • The only default-behavior change is that target-required commands now auto-select when discovery returns exactly one target; when multiple targets are available, they still stop and require explicit selection.

Risks

  • Commands that previously surfaced No target selected may now surface discovery or auto-selection errors first when no target has been chosen yet.
  • The helper depends on the same default discovery URLs as target list, so environments with transient extra targets may now hit the multi-target guidance path more often.
  • If a command was missed and still uses plain ensureDaemon(), its behavior would remain inconsistent with the rest of the target-required commands.

Manual testing

  • Setup: run a single debuggable app or runtime so only one target is available on the default discovery URLs.
  • Run agent-cdp target clear to remove any previous selection.
  • Run a target-required command such as agent-cdp console list.
  • Verify the command succeeds without an explicit target select step and that agent-cdp status shows the selected target.
  • Start a second debuggable target on a default discovery URL.
  • Run agent-cdp target clear, then rerun agent-cdp console list.
  • Verify the command stops with Multiple targets available. Run 'agent-cdp target list' and 'agent-cdp target select <id>'.

@V3RON V3RON merged commit 1292566 into master May 6, 2026
4 checks passed
@V3RON V3RON deleted the feat/auto-select-single-target branch May 6, 2026 10:53
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.

Auto-select target when exactly one target is discoverable

1 participant