- Notifications
You must be signed in to change notification settings - Fork1k
feat(cli): add exp task logs#19915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
d0e4d4c
tocc041e5
CompareThere isn't a supporting API for this yet. This is a skeletonimplementation prepared in advance for the API being available.
cc041e5
to9ae4d44
Comparecli/exp_task_logs.go Outdated
enc:=json.NewEncoder(inv.Stdout) | ||
for_,log:=rangelogs.Logs { | ||
iferr:=enc.Encode(log);err!=nil { | ||
returnxerrors.Errorf("encode task log: %w",err) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Q: Do we want this? This will spit out a json object per log line, each separated by a newline. This is easily consumed by jq and other tools. I'm happy to change this if desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yep, this is fine!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think it's very usable! This way I can get just the last two entries, my input and the agents output.
❯ ./coder exp tasks logs task-foo-bar-15e4 | tail -n2 | jq -r '.type, .content'inputrun echo "are we there yet?"output● coder - coder_report_task (MCP)(summary: "Running echo command with quoted string as requested", link: "https://coder.com", state: "working") ⎿ { "message": "Thanks for reporting!" }● Bash(echo "are we there yet?") ⎿ are we there yet?● are we there yet?
Children: []*serpent.Command{ | ||
r.taskList(), | ||
r.taskCreate(), | ||
r.taskStatus(), | ||
r.taskDelete(), | ||
r.taskList(), | ||
r.taskLogs(), | ||
r.taskSend(), | ||
r.taskStatus(), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
drive-by: sort
cli/exp_task_logs.go Outdated
enc:=json.NewEncoder(inv.Stdout) | ||
for_,log:=rangelogs.Logs { | ||
iferr:=enc.Encode(log);err!=nil { | ||
returnxerrors.Errorf("encode task log: %w",err) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yep, this is fine!
ifid,err:=uuid.Parse(task);err==nil { | ||
taskID=id | ||
}else { | ||
ws,err:=namedWorkspace(ctx,client,task) | ||
iferr!=nil { | ||
returnxerrors.Errorf("resolve task %q: %w",task,err) | ||
} | ||
taskID=ws.ID | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
suggestion: at this point, we can probably use some kind of helpertaskByNameOrID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Possibly. I'm curious about what it would look like though because I don't want to make an unnecessary API call.
cli/exp_task_logs.go Outdated
returnxerrors.Errorf("get task logs: %w",err) | ||
} | ||
enc:=json.NewEncoder(inv.Stdout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
suggestion: we could possibly use a cli.OutputFormatter and emit the logs either as text or JSON
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I've never used that before, I'll take a look at.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Addressed in:refactor: use cliu.OutputFormatter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
🚢
Note: with thecli.OutputFormatter
the JSON output will be an array now.
b7e0b2a
intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Closescoder/internal#894