fix(dialogs): prevent panic due to negative index
commit44e1ca7c4a0c7d008b79a34521360a1d11d16883
authorAndrey Nering <andreynering@users.noreply.github.com>
dateTue 20 Jan 2026, 16:44 (9 months ago)
parent1073723
internal/ui/dialog/api_key_input.go+1−1
@@ -71,7 +71,7 @@ func NewAPIKeyInput(com *common.Common, provider catwalk.Provider, model config.
7171 m.input.Placeholder = "Enter you API key..."
7272 m.input.SetStyles(com.Styles.TextInput)
7373 m.input.Focus()
74− m.input.SetWidth(innerWidth - t.Dialog.InputPrompt.GetHorizontalFrameSize() - 1) // (1) cursor padding
74+ m.input.SetWidth(max(0, innerWidth-t.Dialog.InputPrompt.GetHorizontalFrameSize()-1)) // (1) cursor padding
7575
7676 m.spinner = spinner.New(
7777 spinner.WithSpinner(spinner.Dot),
internal/ui/dialog/commands.go+1−1
@@ -256,7 +256,7 @@ func (c *Commands) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
256256 t.Dialog.HelpView.GetVerticalFrameSize() +
257257 t.Dialog.View.GetVerticalFrameSize()
258258
259− c.input.SetWidth(innerWidth - t.Dialog.InputPrompt.GetHorizontalFrameSize() - 1) // (1) cursor padding
259+ c.input.SetWidth(max(0, innerWidth-t.Dialog.InputPrompt.GetHorizontalFrameSize()-1)) // (1) cursor padding
260260
261261 c.list.SetSize(innerWidth, height-heightOffset)
262262 c.help.SetWidth(innerWidth)
internal/ui/dialog/models.go+1−1
@@ -251,7 +251,7 @@ func (m *Models) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
251251 t.Dialog.InputPrompt.GetVerticalFrameSize() + inputContentHeight +
252252 t.Dialog.HelpView.GetVerticalFrameSize() +
253253 t.Dialog.View.GetVerticalFrameSize()
254− m.input.SetWidth(innerWidth - t.Dialog.InputPrompt.GetHorizontalFrameSize() - 1) // (1) cursor padding
254+ m.input.SetWidth(max(0, innerWidth-t.Dialog.InputPrompt.GetHorizontalFrameSize()-1)) // (1) cursor padding
255255 m.list.SetSize(innerWidth, height-heightOffset)
256256 m.help.SetWidth(innerWidth)
257257
internal/ui/dialog/sessions.go+1−1
@@ -148,7 +148,7 @@ func (s *Session) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
148148 t.Dialog.InputPrompt.GetVerticalFrameSize() + inputContentHeight +
149149 t.Dialog.HelpView.GetVerticalFrameSize() +
150150 t.Dialog.View.GetVerticalFrameSize()
151− s.input.SetWidth(innerWidth - t.Dialog.InputPrompt.GetHorizontalFrameSize() - 1) // (1) cursor padding
151+ s.input.SetWidth(max(0, innerWidth-t.Dialog.InputPrompt.GetHorizontalFrameSize()-1)) // (1) cursor padding
152152 s.list.SetSize(innerWidth, height-heightOffset)
153153 s.help.SetWidth(innerWidth)
154154