MCPcopy
hub / github.com/hatchet-dev/hatchet / Update

Method Update

cmd/hatchet-cli/cli/tui/help.go:35–106  ·  view source on GitHub ↗

Update handles messages and updates the view state

(msg tea.Msg)

Source from the content-addressed store, hash-verified

33
34// Update handles messages and updates the view state
35func (v *HelpView) Update(msg tea.Msg) (View, tea.Cmd) {
36 var cmd tea.Cmd
37
38 switch msg := msg.(type) {
39 case tea.WindowSizeMsg:
40 v.SetSize(msg.Width, msg.Height)
41
42 // Initialize viewport with proper dimensions
43 if !v.ready {
44 // Height: total height - header (3) - footer (3) - spacing (4)
45 viewportHeight := msg.Height - 10
46 if viewportHeight < 10 {
47 viewportHeight = 10
48 }
49
50 v.viewport = viewport.New(msg.Width-4, viewportHeight)
51 v.viewport.YPosition = 0 // Start at top
52 v.viewport.SetContent(v.buildHelpContent())
53 v.ready = true
54 } else {
55 // Update existing viewport size
56 viewportHeight := msg.Height - 10
57 if viewportHeight < 10 {
58 viewportHeight = 10
59 }
60 v.viewport.Width = msg.Width - 4
61 v.viewport.Height = viewportHeight
62 v.viewport.SetContent(v.buildHelpContent())
63 }
64
65 return v, nil
66
67 case tea.KeyMsg:
68 switch msg.String() {
69 case "h", "esc":
70 // Close help view
71 return v, NewNavigateBackMsg()
72 case "down", "j":
73 // Scroll down
74 v.viewport, cmd = v.viewport.Update(msg)
75 return v, cmd
76 case "up", "k":
77 // Scroll up
78 v.viewport, cmd = v.viewport.Update(msg)
79 return v, cmd
80 case "pgdown", "space":
81 // Page down
82 v.viewport, cmd = v.viewport.Update(msg)
83 return v, cmd
84 case "pgup":
85 // Page up
86 v.viewport, cmd = v.viewport.Update(msg)
87 return v, cmd
88 case "home", "g":
89 // Go to top
90 v.viewport.GotoTop()
91 return v, nil
92 case "end", "G":

Callers

nothing calls this directly

Calls 7

SetSizeMethod · 0.95
buildHelpContentMethod · 0.95
NewNavigateBackMsgFunction · 0.85
NewMethod · 0.80
SetContentMethod · 0.80
UpdateMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected