on main help sign in
chore: change the dialog sizes a bit
1b61cd2Kujtim Hoxha
internal/ui/dialog/commands.go+8−3
@@ -28,7 +28,10 @@ type CommandType uint
28// String returns the string representation of the CommandType.
28// String returns the string representation of the CommandType.
29func (c CommandType) String() string { return []string{"System", "User", "MCP"}[c] }
29func (c CommandType) String() string { return []string{"System", "User", "MCP"}[c] }
30
30
31+const (
31−const sidebarCompactModeBreakpoint = 120
32+ sidebarCompactModeBreakpoint = 120
33+ defaultCommandsDialogMaxWidth = 70
34+)
32
35
33const (
36const (
34 SystemCommands CommandType = iota
37 SystemCommands CommandType = iota
@@ -238,7 +241,7 @@ func commandsRadioView(sty *styles.Styles, selected CommandType, hasUserCmds boo
238// Draw implements [Dialog].
241// Draw implements [Dialog].
239func (c *Commands) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
242func (c *Commands) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
240 t := c.com.Styles
243 t := c.com.Styles
241− width := max(0, min(defaultDialogMaxWidth, area.Dx()))
244+ width := max(0, min(defaultCommandsDialogMaxWidth, area.Dx()))
242 height := max(0, min(defaultDialogHeight, area.Dy()))
245 height := max(0, min(defaultDialogHeight, area.Dy()))
243 if area.Dx() != c.windowWidth && c.selected == SystemCommands {
246 if area.Dx() != c.windowWidth && c.selected == SystemCommands {
244 c.windowWidth = area.Dx()
247 c.windowWidth = area.Dx()
@@ -254,7 +257,9 @@ func (c *Commands) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
254 t.Dialog.View.GetVerticalFrameSize()
257 t.Dialog.View.GetVerticalFrameSize()
255
258
256 c.input.SetWidth(innerWidth - t.Dialog.InputPrompt.GetHorizontalFrameSize() - 1) // (1) cursor padding
259 c.input.SetWidth(innerWidth - t.Dialog.InputPrompt.GetHorizontalFrameSize() - 1) // (1) cursor padding
260+
257− c.list.SetSize(innerWidth, height-heightOffset)
261+ listHeight := min(height-heightOffset, c.list.Len())
262+ c.list.SetSize(innerWidth, listHeight)
258 c.help.SetWidth(innerWidth)
263 c.help.SetWidth(innerWidth)
259
264
260 rc := NewRenderContext(t, width)
265 rc := NewRenderContext(t, width)
internal/ui/dialog/models.go+4−1
@@ -69,6 +69,8 @@ const (
69// ModelsID is the identifier for the model selection dialog.
69// ModelsID is the identifier for the model selection dialog.
70const ModelsID = "models"
70const ModelsID = "models"
71
71
72+const defaultModelsDialogMaxWidth = 70
73+
72// Models represents a model selection dialog.
74// Models represents a model selection dialog.
73type Models struct {
75type Models struct {
74 com *common.Common
76 com *common.Common
@@ -240,7 +242,7 @@ func (m *Models) modelTypeRadioView() string {
240// Draw implements [Dialog].
242// Draw implements [Dialog].
241func (m *Models) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
243func (m *Models) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
242 t := m.com.Styles
244 t := m.com.Styles
243− width := max(0, min(defaultDialogMaxWidth, area.Dx()))
245+ width := max(0, min(defaultModelsDialogMaxWidth, area.Dx()))
244 height := max(0, min(defaultDialogHeight, area.Dy()))
246 height := max(0, min(defaultDialogHeight, area.Dy()))
245 innerWidth := width - t.Dialog.View.GetHorizontalFrameSize()
247 innerWidth := width - t.Dialog.View.GetHorizontalFrameSize()
246 heightOffset := t.Dialog.Title.GetVerticalFrameSize() + titleContentHeight +
248 heightOffset := t.Dialog.Title.GetVerticalFrameSize() + titleContentHeight +
@@ -442,6 +444,7 @@ func (m *Models) setProviderItems() error {
442 // Set model groups in the list.
444 // Set model groups in the list.
443 m.list.SetGroups(groups...)
445 m.list.SetGroups(groups...)
444 m.list.SetSelectedItem(selectedItemID)
446 m.list.SetSelectedItem(selectedItemID)
447+ m.list.ScrollToSelected()
445
448
446 // Update placeholder based on model type
449 // Update placeholder based on model type
447 m.input.Placeholder = m.modelType.Placeholder()
450 m.input.Placeholder = m.modelType.Placeholder()