MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / Update

Method Update

tui/status.go:232–309  ·  view source on GitHub ↗
(msg tea.Msg)

Source from the content-addressed store, hash-verified

230}
231
232func (m statusModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
233 if m.quitting {
234 return m, tea.Quit
235 }
236
237 switch msg := msg.(type) {
238 case tea.KeyMsg:
239 switch msg.String() {
240 case "q", "Q", "esc", "ctrl+c":
241 m.cancelled = true
242 m.quitting = true
243 m.monitoring = false
244 return m, deferQuit()
245 }
246
247 case quitNow:
248 return m, tea.Quit
249
250 case tickMsg:
251 if m.monitoring {
252 return m, fetchInstancesCmd(m.client)
253 }
254
255 case spinner.TickMsg:
256 var cmd tea.Cmd
257 m.spinner, cmd = m.spinner.Update(msg)
258 return m, cmd
259
260 case instancesMsg:
261 if msg.err != nil {
262 if m.monitoring {
263 if delay, ok := m.statusRefreshRetryDelay(msg.err); ok {
264 m.refreshErr = msg.err
265 m.nextRetryAt = time.Now().Add(delay)
266 return m, tickAfter(delay)
267 }
268 }
269 m.err = msg.err
270 m.monitoring = false
271 return m, deferQuit()
272 }
273 m.instances = msg.instances
274 m.lastUpdate = time.Now()
275 m.refreshErr = nil
276 m.nextRetryAt = time.Time{}
277
278 if len(m.instances) == 0 {
279 m.transitionStartedAt = time.Time{}
280 if m.monitoring {
281 if m.emptyStartedAt.IsZero() {
282 m.emptyStartedAt = time.Now()
283 }
284 return m, m.tickCmd()
285 }
286 m.quitting = true
287 return m, deferQuit()
288 }
289

Callers

nothing calls this directly

Calls 6

tickCmdMethod · 0.95
deferQuitFunction · 0.85
fetchInstancesCmdFunction · 0.85
tickAfterFunction · 0.85
hasTransitionalInstanceFunction · 0.85

Tested by

no test coverage detected