Skip to content
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

feat(site): show previous agent scripts logs #12233

Merged
merged 12 commits into from
Feb 21, 2024
Merged

Conversation

BrunoQuaresma
Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma commented Feb 20, 2024

PS: If the workspace has multiple agents, they will be displayed as tabs like coder_agent.a, coder_agent.b, and so on.

Close #7409

Demo:

Screen.Recording.2024-02-20.at.15.09.45.mov

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file was extracted from the AgentRow component to be reused

@BrunoQuaresma BrunoQuaresma requested review from a team and Parkreiner and removed request for a team February 20, 2024 18:13
@BrunoQuaresma BrunoQuaresma changed the title Bq/show agent logs feat(site): show previous agent logs Feb 20, 2024
@BrunoQuaresma BrunoQuaresma changed the title feat(site): show previous agent logs feat(site): show previous agent scripts logs Feb 20, 2024
Copy link
Contributor

@Parkreiner Parkreiner left a comment

Choose a reason for hiding this comment

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

Looks really good! Just had a couple of questions/suggestions

Copy link
Contributor

Choose a reason for hiding this comment

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

Big fan of the file changes – looks really clean now.
Once this PR is out, would you be okay with me adding some accessibility code? Mainly want to add some stuff from the APG example for tabs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

100% I'm not attached to my code at all 😆

site/src/components/Tabs/Tabs.tsx Outdated Show resolved Hide resolved
color: theme.palette.text.primary,
position: "relative",

"&:before": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this for the accent underline? I'm wondering if it might be more direct to add a bottom border to all the tabs.
As in, give all the tabs the same border thickness and line style, but not the same color. If the tab's active, it could use the primary accent color, and if not, it could use the same color as the background, and blend them together

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. In the way you suggested it does not vertically align the content correctly since it is off by 1px at the bottom so you also would need to add a border to the top which starts to make the CSS more "complicated" IMO. I just think the before is easier to understand and implement.

Comment on lines +30 to +36
const logSourceByID = useMemo(() => {
const sourcesById: { [id: string]: WorkspaceAgentLogSource } = {};
for (const source of sources) {
sourcesById[source.id] = source;
}
return sourcesById;
}, [sources]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this file's using React Window for list virtualization, but do we know how big the dataset is expected to get? I'm wondering if the useMemo call here is actually doing all that much

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do we know how big the dataset is expected to get?

It can be a lot. It depends on the user's use case. It can have 3+ scripts, and each script can have more than +200 log lines for example.

I'm wondering if the useMemo call here is actually doing all that much

Didn't understand

site/src/modules/resources/AgentLogs.tsx Outdated Show resolved Hide resolved
@@ -128,6 +143,23 @@ export const WorkspaceBuildPageView: FC<WorkspaceBuildPageViewProps> = ({
</Sidebar>

<div css={{ height: "100%", overflowY: "auto", width: "100%" }}>
<Tabs active={tab.value}>
<TabsList>
<TabLink to={`?${LOGS_TAB_KEY}=build`} value="build">
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if there's a better way to expose the props for this component. Something like this:

<Tabs active={tab.value} searchParamsKey="logs">
  <TabsList>
     <TabLink value="build" />
  </TabsList>
</Tabs>

If searchParamsKey is defined, then Tabs would treat all TabLinks as relative, and pass down information to them to let them know to format their links differently. And the to value for each link wouldn't be necessary, because you'd be able to piece together the full param from the container's key and the link's value

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would not like to make Tabs attached to search parameters for now.

const agents = build.resources
.filter((r) => r.agents)
.flatMap((r) => r.agents) as WorkspaceAgent[];
const selectedAgent = agents.find((a) => a.id === tab.value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be inlined inside the JSX, since it's only used in one spot?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeap, I just find it easier to read. Wdyt?

@BrunoQuaresma BrunoQuaresma merged commit b4fb754 into main Feb 21, 2024
24 checks passed
@BrunoQuaresma BrunoQuaresma deleted the bq/show-agent-logs branch February 21, 2024 14:42
@github-actions github-actions bot locked and limited conversation to collaborators Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show historical startup logs in build logs page
2 participants