From 76116b93d1bf595fe9ca00fb49d6ed150655b8d5 Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Mon, 17 Apr 2023 18:57:44 +0000 Subject: [PATCH] fix(site): Handle carriage on logs output --- site/src/components/Logs/Logs.tsx | 2 +- .../components/Resources/AgentRow.stories.tsx | 38 +++++++------------ 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/site/src/components/Logs/Logs.tsx b/site/src/components/Logs/Logs.tsx index 2f3e263520876..1918231d69512 100644 --- a/site/src/components/Logs/Logs.tsx +++ b/site/src/components/Logs/Logs.tsx @@ -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 ( diff --git a/site/src/components/Resources/AgentRow.stories.tsx b/site/src/components/Resources/AgentRow.stories.tsx index 4ae0a610e3e52..76678370fe723 100644 --- a/site/src/components/Resources/AgentRow.stories.tsx +++ b/site/src/components/Resources/AgentRow.stories.tsx @@ -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 = (args) => @@ -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({}) @@ -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({})