@@ -143,12 +143,7 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
143143 return a , nil
144144 case output.MessageEvent :
145145 msgCopy := msg
146- line := styledLine {text : components .RenderMessage (msg ), message : & msgCopy }
147- if a .spinner .PendingStop () {
148- a .bufferedLines = appendLine (a .bufferedLines , line )
149- } else {
150- a .lines = appendLine (a .lines , line )
151- }
146+ a .addLine (styledLine {text : components .RenderMessage (msg ), message : & msgCopy })
152147 return a , nil
153148 case output.AuthEvent :
154149 if msg .Preamble != "" {
@@ -166,12 +161,7 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
166161 return a , nil
167162 case output.LogLineEvent :
168163 prefix := styles .Secondary .Render (msg .Source + " | " )
169- line := styledLine {text : prefix + renderLogLine (msg .Line , msg .Level )}
170- if a .spinner .PendingStop () {
171- a .bufferedLines = appendLine (a .bufferedLines , line )
172- } else {
173- a .lines = appendLine (a .lines , line )
174- }
164+ a .addLine (styledLine {text : prefix + renderLogLine (msg .Line , msg .Level )})
175165 return a , nil
176166 case output.ContainerStatusEvent :
177167 if msg .Phase == "pulling" {
@@ -185,7 +175,7 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
185175 if msg .Phase == "ready" {
186176 line = strings .Replace (line , output .SuccessMarker (), styles .Success .Render (output .SuccessMarker ()), 1 )
187177 }
188- a .lines = appendLine ( a . lines , styledLine {text : line })
178+ a .addLine ( styledLine {text : line })
189179 }
190180 return a , nil
191181 case output.ProgressEvent :
@@ -216,21 +206,11 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
216206 case output.TableEvent :
217207 if line , ok := output .FormatEventLine (msg ); ok {
218208 parts := strings .Split (line , "\n " )
219- var lines []styledLine
220209 if len (parts ) > 0 {
221- lines = append ( lines , styledLine {text : parts [0 ], secondary : true })
210+ a . addLine ( styledLine {text : parts [0 ], secondary : true })
222211 }
223212 for _ , part := range parts [1 :] {
224- lines = append (lines , styledLine {text : part })
225- }
226- if a .spinner .PendingStop () {
227- for _ , l := range lines {
228- a .bufferedLines = appendLine (a .bufferedLines , l )
229- }
230- } else {
231- for _ , l := range lines {
232- a .lines = appendLine (a .lines , l )
233- }
213+ a .addLine (styledLine {text : part })
234214 }
235215 }
236216 case output.ResourceSummaryEvent :
@@ -239,27 +219,23 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
239219 if msg .Resources > 0 && msg .Services > 0 {
240220 style = styles .Highlight
241221 }
242- line := styledLine {text : style .Render (text )}
243222 blank := styledLine {text : "" }
244- if a .spinner .PendingStop () {
245- a .bufferedLines = appendLine (a .bufferedLines , blank )
246- a .bufferedLines = appendLine (a .bufferedLines , line )
247- a .bufferedLines = appendLine (a .bufferedLines , blank )
248- } else {
249- a .lines = appendLine (a .lines , blank )
250- a .lines = appendLine (a .lines , line )
251- a .lines = appendLine (a .lines , blank )
223+ a .addLine (blank )
224+ a .addLine (styledLine {text : style .Render (text )})
225+ a .addLine (blank )
226+ return a , nil
227+ case output.InstanceInfoEvent :
228+ if line , ok := output .FormatEventLine (msg ); ok {
229+ line = strings .Replace (line , output .SuccessMarker (), styles .Success .Render (output .SuccessMarker ()), 1 )
230+ for _ , part := range strings .Split (line , "\n " ) {
231+ a .addLine (styledLine {text : part })
232+ }
252233 }
253234 return a , nil
254235 default :
255236 if line , ok := output .FormatEventLine (msg ); ok {
256237 for _ , part := range strings .Split (line , "\n " ) {
257- l := styledLine {text : part }
258- if a .spinner .PendingStop () {
259- a .bufferedLines = appendLine (a .bufferedLines , l )
260- } else {
261- a .lines = appendLine (a .lines , l )
262- }
238+ a .addLine (styledLine {text : part })
263239 }
264240 }
265241 }
@@ -288,6 +264,14 @@ func appendLine(lines []styledLine, line styledLine) []styledLine {
288264 return lines
289265}
290266
267+ func (a * App ) addLine (line styledLine ) {
268+ if a .spinner .PendingStop () {
269+ a .bufferedLines = appendLine (a .bufferedLines , line )
270+ } else {
271+ a .lines = appendLine (a .lines , line )
272+ }
273+ }
274+
291275func (a * App ) flushBufferedLines () {
292276 for _ , line := range a .bufferedLines {
293277 a .lines = appendLine (a .lines , line )
0 commit comments