Skip to content

fix(site): Handle carriage on logs output #7172

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

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/src/components/Logs/Logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const LogLine: FC<{
lineNumbers: Boolean(number),
})
const output = useMemo(() => {
return convert.toHtml(line.output)
return convert.toHtml(line.output.split(/\r/g).pop() as string)
}, [line.output])

return (
Expand Down
38 changes: 14 additions & 24 deletions site/src/components/Resources/AgentRow.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ import { AgentRow, AgentRowProps } from "./AgentRow"
export default {
title: "components/AgentRow",
component: AgentRow,
args: {
storybookStartupLogs: [
"\x1b[91mCloning Git repository...",
"\x1b[2;37;41mStarting Docker Daemon...",
"\x1b[1;95mAdding some 🧙magic🧙...",
"Starting VS Code...",
"\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r100 1475 0 1475 0 0 4231 0 --:--:-- --:--:-- --:--:-- 4238",
].map((line, index) => ({
id: index,
level: "info",
output: line,
time: "",
})),
},
}

const Template: Story<AgentRowProps> = (args) => <AgentRow {...args} />
Expand Down Expand Up @@ -107,18 +121,6 @@ export const Starting = Template.bind({})
Starting.args = {
...Example.args,
agent: MockWorkspaceAgentStarting,

storybookStartupLogs: [
"\x1b[91mCloning Git repository...",
"\x1b[2;37;41mStarting Docker Daemon...",
"\x1b[1;95mAdding some 🧙magic🧙...",
"Starting VS Code...",
].map((line, index) => ({
id: index,
level: "info",
output: line,
time: "",
})),
}

export const Started = Template.bind({})
Expand All @@ -128,18 +130,6 @@ Started.args = {
...MockWorkspaceAgentReady,
startup_logs_length: 1,
},

storybookStartupLogs: [
"Cloning Git repository...",
"Starting Docker Daemon...",
"Adding some 🧙magic🧙...",
"Starting VS Code...",
].map((line, index) => ({
id: index,
level: "info",
output: line,
time: "",
})),
}

export const StartedNoMetadata = Template.bind({})
Expand Down