-
Notifications
You must be signed in to change notification settings - Fork 886
fix: fix duplicated agent logs #17806
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…licated-agent-logs
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.
Nothing jumped out to me with the logic, but obviously the stories a little wrong now. Happy to re-review once those get fixed up
site/src/api/api.ts
Outdated
) => { | ||
const searchParams = new URLSearchParams({ | ||
follow: "true", | ||
after: after.toString(), | ||
after: params?.after ? params?.after.toString() : "", |
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.
Could we make this params?.after.toString() ?? ""
?
jest.spyOn(apiModule, "watchWorkspaceAgentLogs").mockImplementation( | ||
() => | ||
new OneWayWebSocket({ | ||
apiRoute: "", |
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.
Does it make sense to pass in an empty string for the API route? I don't know if we've updated the class since I merged it in originally, but I remember that it was originally made so that you couldn't update the URL after instantiation
A socket like this would always be useless, right?
): readonly WorkspaceAgentLog[] | undefined { | ||
const [logs, setLogs] = useState<WorkspaceAgentLog[]>(); |
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.
What do you think of making the hook so that it always returns an array, and if we don't have logs, we return an empty array?
I feel like that might help clean up some of the render logic long-term, but I also don't know if we need to differentiate between logs not existing because we haven't gotten anything back from the server yet, versus logs not existing because the server explicitly told us that it doesn't have anything
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.
It'd also simplify line 29's state update logic
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.
For now, I don't think it would be a problem. I like the idea 👍
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.
LGTM and tested in my dogfood env, but deferring to @Parkreiner for approval on the TS side.
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'm okay with this, too
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.
LGTM!
Fix #16355