diff --git a/internal/ui/dialog/commands.go b/internal/ui/dialog/commands.go index 9039a2457d3c86ba21886deac4137970f861fd59..66d924a28a64a7ad9dff3081878290b3f74cc230 100644 --- a/internal/ui/dialog/commands.go +++ b/internal/ui/dialog/commands.go @@ -28,7 +28,10 @@ type CommandType uint // String returns the string representation of the CommandType. func (c CommandType) String() string { return []string{"System", "User", "MCP"}[c] } -const sidebarCompactModeBreakpoint = 120 +const ( + sidebarCompactModeBreakpoint = 120 + defaultCommandsDialogMaxWidth = 70 +) const ( SystemCommands CommandType = iota @@ -238,7 +241,7 @@ func commandsRadioView(sty *styles.Styles, selected CommandType, hasUserCmds boo // Draw implements [Dialog]. func (c *Commands) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor { t := c.com.Styles - width := max(0, min(defaultDialogMaxWidth, area.Dx())) + width := max(0, min(defaultCommandsDialogMaxWidth, area.Dx())) height := max(0, min(defaultDialogHeight, area.Dy())) if area.Dx() != c.windowWidth && c.selected == SystemCommands { c.windowWidth = area.Dx() @@ -254,7 +257,9 @@ func (c *Commands) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor { t.Dialog.View.GetVerticalFrameSize() c.input.SetWidth(innerWidth - t.Dialog.InputPrompt.GetHorizontalFrameSize() - 1) // (1) cursor padding - c.list.SetSize(innerWidth, height-heightOffset) + + listHeight := min(height-heightOffset, c.list.Len()) + c.list.SetSize(innerWidth, listHeight) c.help.SetWidth(innerWidth) rc := NewRenderContext(t, width) diff --git a/internal/ui/dialog/models.go b/internal/ui/dialog/models.go index 77aeab22380f89455f83760428fac128fd4fc28b..31c0f0a886b72d409696f1a3a6c4305488ed9539 100644 --- a/internal/ui/dialog/models.go +++ b/internal/ui/dialog/models.go @@ -69,6 +69,8 @@ const ( // ModelsID is the identifier for the model selection dialog. const ModelsID = "models" +const defaultModelsDialogMaxWidth = 70 + // Models represents a model selection dialog. type Models struct { com *common.Common @@ -240,7 +242,7 @@ func (m *Models) modelTypeRadioView() string { // Draw implements [Dialog]. func (m *Models) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor { t := m.com.Styles - width := max(0, min(defaultDialogMaxWidth, area.Dx())) + width := max(0, min(defaultModelsDialogMaxWidth, area.Dx())) height := max(0, min(defaultDialogHeight, area.Dy())) innerWidth := width - t.Dialog.View.GetHorizontalFrameSize() heightOffset := t.Dialog.Title.GetVerticalFrameSize() + titleContentHeight + @@ -442,6 +444,7 @@ func (m *Models) setProviderItems() error { // Set model groups in the list. m.list.SetGroups(groups...) m.list.SetSelectedItem(selectedItemID) + m.list.ScrollToSelected() // Update placeholder based on model type m.input.Placeholder = m.modelType.Placeholder()