MCPcopy Create free account
hub / github.com/SamNet-dev/snix / Update

Method Update

tui/run.go:59–107  ·  view source on GitHub ↗
(msg tea.Msg)

Source from the content-addressed store, hash-verified

57func (m runModel) Init() tea.Cmd { return nil }
58
59func (m runModel) Update(msg tea.Msg) (runModel, tea.Cmd) {
60 switch msg := msg.(type) {
61 case tea.WindowSizeMsg:
62 m.vp.Width = msg.Width - 4
63 m.vp.Height = msg.Height - 12
64
65 case tea.KeyMsg:
66 switch msg.String() {
67 case "s":
68 if !m.isRunning() {
69 return m, m.start()
70 }
71 case "x":
72 if m.isRunning() {
73 return m, m.stop()
74 }
75 case "r":
76 cmds := []tea.Cmd{}
77 if m.isRunning() {
78 cmds = append(cmds, m.stop())
79 }
80 cmds = append(cmds, m.start())
81 return m, tea.Sequence(cmds...)
82 case "c":
83 m.logs = nil
84 m.vp.SetContent("")
85 }
86
87 case runLogMsg:
88 m.appendLog(string(msg))
89 if ch := m.stChan(); ch != nil {
90 return m, pumpCmd(ch)
91 }
92 case runExitMsg:
93 m.st.mu.Lock()
94 m.st.running = false
95 m.st.msgCh = nil
96 m.st.mu.Unlock()
97 line := "[engine exited cleanly]"
98 if msg.err != nil {
99 line = fmt.Sprintf("[engine exited: %v]", msg.err)
100 }
101 m.appendLog(errStyle.Render(line))
102 }
103
104 var cmd tea.Cmd
105 m.vp, cmd = m.vp.Update(msg)
106 return m, cmd
107}
108
109func (m *runModel) appendLog(line string) {
110 m.logs = append(m.logs, line)

Callers

nothing calls this directly

Calls 7

isRunningMethod · 0.95
startMethod · 0.95
stopMethod · 0.95
appendLogMethod · 0.95
stChanMethod · 0.95
pumpCmdFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected