Skip to content

Introduce task container selector#113

Open
vitolkachova wants to merge 2 commits into
mainfrom
support-task-selector
Open

Introduce task container selector#113
vitolkachova wants to merge 2 commits into
mainfrom
support-task-selector

Conversation

@vitolkachova

Copy link
Copy Markdown
Contributor

Add task container selector for commands ssh, scp and log. Proposes to choose from a task runs list if several are executed in parallel.

% upsun --task myagent -p 45rxrkidodaay -e main
Enter a number to choose which run of "myagent" to connect to:
  [0] 45tkoe3kh5w7w (started 2026-06-23T12:23:17.427775+00:00)
  [1] r4urjsfdqjfsa (started 2026-06-23T12:23:16.095779+00:00)

activity ID can be provided to specify exact task run:

upsun log --task myagent -p 45rxrkidodaay -e main --activity 45tkoe3kh5w7w

Copilot AI review requested due to automatic review settings June 23, 2026 12:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds support for targeting running task containers (ephemeral, activity-backed) via a new --task selector, enabling ssh, scp, and log to connect to a specific task run (optionally disambiguated via --activity).

Changes:

  • Introduces Selector::addTaskOption() and task-container resolution in Selector::selectRemoteContainer() based on in-progress/pending environment.task activities.
  • Adds a new RemoteContainer\Task implementation that derives an SSH URL for a task run.
  • Wires the new options into environment:ssh, environment:scp, and environment:logs commands (plus an example in ssh).

Reviewed changes

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

Show a summary per file
File Description
legacy/src/Selector/Selector.php Adds --task/--activity options and implements selection logic for task-run containers.
legacy/src/Model/RemoteContainer/Task.php New remote container type for SSH access to an in-progress task run.
legacy/src/Command/Environment/EnvironmentSshCommand.php Exposes --task/--activity on ssh and adds a usage example.
legacy/src/Command/Environment/EnvironmentScpCommand.php Exposes --task/--activity on scp.
legacy/src/Command/Environment/EnvironmentLogCommand.php Exposes --task/--activity on log.

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

Comment on lines +963 to +979
private function matchTaskActivity(array $running, string $taskName, string $activityId): Activity
{
$matches = array_values(array_filter(
$running,
fn(Activity $activity): bool => $activity->id === $activityId,
));
if (count($matches) === 1) {
return $matches[0];
}
$ids = implode(', ', array_map(fn(Activity $activity): string => $activity->id, $running));
throw new InvalidArgumentException(sprintf(
'No running instance of the task "%s" matches the activity ID "%s". Running activity IDs: %s',
$taskName,
$activityId,
$ids,
));
}
Comment on lines +939 to +941
$choices[$activity->id] = $activity->created_at !== ''
? sprintf('%s (started %s)', $activity->id, $activity->created_at)
: $activity->id;
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