diff --git a/pkg/cmd/agent-task/view/view.go b/pkg/cmd/agent-task/view/view.go index 787157ffe..4f9d6dc3a 100644 --- a/pkg/cmd/agent-task/view/view.go +++ b/pkg/cmd/agent-task/view/view.go @@ -80,6 +80,8 @@ func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Comman opts.SelectorArg = args[0] if shared.IsSessionID(opts.SelectorArg) { opts.SessionID = opts.SelectorArg + } else if sessionID, err := shared.ParsePullRequestAgentSessionURL(opts.SelectorArg); err == nil { + opts.SessionID = sessionID } } diff --git a/pkg/cmd/agent-task/view/view_test.go b/pkg/cmd/agent-task/view/view_test.go index a4636c369..bdff45793 100644 --- a/pkg/cmd/agent-task/view/view_test.go +++ b/pkg/cmd/agent-task/view/view_test.go @@ -46,6 +46,15 @@ func TestNewCmdList(t *testing.T) { SessionID: "00000000-0000-0000-0000-000000000000", }, }, + { + name: "PR agent-session URL arg tty", + tty: true, + args: "https://github.com/OWNER/REPO/pull/101/agent-sessions/00000000-0000-0000-0000-000000000000", + wantOpts: ViewOptions{ + SelectorArg: "https://github.com/OWNER/REPO/pull/101/agent-sessions/00000000-0000-0000-0000-000000000000", + SessionID: "00000000-0000-0000-0000-000000000000", + }, + }, { name: "non-session ID arg tty", tty: true,