Skip to content

Commit bbdf0cc

Browse files
committed
fix: correct agent selection logic and handle nil timestamps
Change-Id: I12e96df671e52eb9e2ae85127ac1aa40f5671e52 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent d7b1253 commit bbdf0cc

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cli/cliui/agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func Agent(ctx context.Context, writer io.Writer, agentID uuid.UUID, opts AgentO
127127
}
128128
}
129129
}
130-
sw.Complete(stage, agent.FirstConnectedAt.Sub(agent.CreatedAt))
130+
sw.Complete(stage, safeDuration(sw, agent.FirstConnectedAt, &agent.CreatedAt))
131131

132132
case codersdk.WorkspaceAgentConnected:
133133
if !showStartupLogs && agent.LifecycleState == codersdk.WorkspaceAgentLifecycleReady {

cli/ssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ func getWorkspaceAgent(workspace codersdk.Workspace, agentName string) (workspac
943943
slices.Sort(availableNames)
944944
if agentName != "" {
945945
for i, agent := range agents {
946-
if agent.Name != agentName || agent.ID.String() == agentName {
946+
if agent.Name != agentName && agent.ID.String() != agentName {
947947
continue
948948
}
949949
otherAgents := slices.Delete(agents, i, i+1)

0 commit comments

Comments
 (0)