From 07454e0fb5528d299d7077fff680a8216c6f4c17 Mon Sep 17 00:00:00 2001 From: Toma Puljak Date: Tue, 26 Mar 2024 14:20:10 +0100 Subject: [PATCH] fix: minor fix for workspace creation logging (#291) Signed-off-by: Toma Puljak --- pkg/cmd/workspace/create.go | 10 +++++++--- pkg/views/workspace/status/view.go | 3 +-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/workspace/create.go b/pkg/cmd/workspace/create.go index 00e9a592df..8276096b0e 100644 --- a/pkg/cmd/workspace/create.go +++ b/pkg/cmd/workspace/create.go @@ -9,6 +9,7 @@ import ( "fmt" "net/url" "os" + "strings" "time" tea "github.com/charmbracelet/bubbletea" @@ -132,14 +133,14 @@ var CreateCmd = &cobra.Command{ cleanUpTerminal(statusProgram, apiclient.HandleErrorResponse(res, err)) } - started = true - dialStartTime := time.Now() dialTimeout := 3 * time.Minute statusProgram.Send(status.ResultMsg{Line: "Establishing connection with the workspace"}) waitForDial(tsConn, *createdWorkspace.Id, *createdWorkspace.Projects[0].Name, dialStartTime, dialTimeout, statusProgram) + started = true + cleanUpTerminal(statusProgram, nil) wsInfo, res, err := apiClient.WorkspaceAPI.GetWorkspace(ctx, workspaceName).Execute() @@ -321,7 +322,10 @@ func scanWorkspaceLogs(activeProfile config.Profile, workspaceName string, statu return } - statusProgram.Send(status.ResultMsg{Line: string(msg)}) + messages := strings.Split(string(msg), "\r") + for _, msg := range messages { + statusProgram.Send(status.ResultMsg{Line: msg}) + } if *started { statusProgram.Send(status.ResultMsg{Line: "END_SIGNAL"}) break diff --git a/pkg/views/workspace/status/view.go b/pkg/views/workspace/status/view.go index 3829f0e27b..91ec5a2061 100644 --- a/pkg/views/workspace/status/view.go +++ b/pkg/views/workspace/status/view.go @@ -4,7 +4,6 @@ package status import ( - "fmt" "strings" "github.com/charmbracelet/bubbles/spinner" @@ -31,7 +30,7 @@ func (r ResultMsg) String() string { if r.Dots { return dotStyle.Render(strings.Repeat(".", 30)) } - return fmt.Sprintf(r.Line) + return r.Line } type model struct {