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

Method Update

tui/snapshot_list.go:122–170  ·  view source on GitHub ↗
(msg tea.Msg)

Source from the content-addressed store, hash-verified

120}
121
122func (m snapshotListModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
123 if m.quitting {
124 return m, tea.Quit
125 }
126
127 switch msg := msg.(type) {
128 case tea.KeyMsg:
129 switch msg.String() {
130 case "q", "Q", "esc", "ctrl+c":
131 m.cancelled = true
132 m.quitting = true
133 m.monitoring = false
134 return m, deferQuit()
135 }
136
137 case quitNow:
138 return m, tea.Quit
139
140 case tickMsg:
141 if m.monitoring {
142 return m, fetchSnapshotsCmd(m.client)
143 }
144
145 case spinner.TickMsg:
146 var cmd tea.Cmd
147 m.spinner, cmd = m.spinner.Update(msg)
148 return m, cmd
149
150 case snapshotsMsg:
151 if msg.err != nil {
152 m.err = msg.err
153 m.monitoring = false
154 return m, deferQuit()
155 }
156 m.snapshots = msg.snapshots
157 m.lastUpdate = time.Now()
158
159 if delay, ok := nextSnapshotPollDelay(m.snapshots); m.monitoring && ok {
160 return m, snapshotsTickCmd(delay)
161 }
162
163 if !m.monitoring {
164 m.quitting = true
165 return m, deferQuit()
166 }
167 }
168
169 return m, nil
170}
171
172func (m snapshotListModel) View() string {
173 if m.err != nil {

Callers

nothing calls this directly

Calls 4

deferQuitFunction · 0.85
fetchSnapshotsCmdFunction · 0.85
nextSnapshotPollDelayFunction · 0.85
snapshotsTickCmdFunction · 0.85

Tested by

no test coverage detected