Skip to content

Conversation

@dawndiy
Copy link

@dawndiy dawndiy commented Oct 28, 2025

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

At the Switch Model dialog, models were grouped by the provider. Each section has a unfocusable name of the provider.
If I go down when at the last item, it will come to the top model, but It will not come to the last model when I go up at the first item. Because there is a provider name ( a list item ) before the first model. The list wrap logic is not adapter this scene.
This PR fix list wrap logic in this scene.

@dawndiy dawndiy requested a review from a team as a code owner October 28, 2025 12:23
@dawndiy dawndiy requested review from kujtimiihoxha and raphamorim and removed request for a team October 28, 2025 12:23
@charmcli
Copy link
Contributor

charmcli commented Oct 28, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@dawndiy
Copy link
Author

dawndiy commented Oct 28, 2025

I have read the Contributor License Agreement (CLA) and hereby sign the CLA.

@blouflab
Copy link

thanks for that - it is great, these little annoying things

@kujtimiihoxha
Copy link
Member

@dawndiy thanks for the PR and the fix, I am wondering if it would be better to jump the viewport to the first un-selectable item instead of the selectable item so that we actually go to the top?

So for example here instead of hiding the Anthropic title we just go to the first item in the list.

@dawndiy
Copy link
Author

dawndiy commented Oct 29, 2025

@kujtimiihoxha thanks your reply. Of cause it would be better to show the un-selectable item (provider name in this case), it will more readable.

Let me describe my use case about this issue:
As you know, OpenRouter has many models and the list is longer than the height of the Viewport. When the model I want is at the end of the list, I need long-press the DOWN KEY to move the cursor to get the end of the list. If I press too long, the cursor will come to the top due to the list's wrapping logic. But because of this issue, I can't press the UP KEY to go back to the end, so I need long-press the DOWN KEY again... This is very annoying.

Following your advice, I believe the following 2 points are our final desired outcomes.

  1. Come to the first selectable item from the end wrap should show the un-selectable item before it in the viewport if there has a un-selectable before it.
  2. The viewport can show the first un-selectable item when the cursor at the first selectable item. And now press the UP KEY can back to the latest selectable item

And I found that I can add these code to the end of the scrollToSelectio function, and it can run as what I want.

	selectedIndex, ok := l.indexMap.Get(l.selectedItem)
	if ok && selectedIndex > 0 {
		prevItem, ok := l.items.Get(selectedIndex - 1)
		if ok {
			if _, ok := any(prevItem).(layout.Focusable); !ok {
				prevRendered, ok := l.renderedItems.Get(prevItem.ID())
				if ok && prevRendered.start < start {
					if l.direction == DirectionForward {
						l.offset = max(0, prevRendered.start)
					} else {
						l.offset = max(0, lipgloss.Height(l.rendered)-(prevRendered.end+1))
					}
				}
			}
		}
	}

It works, but I don't know if this is the correct way to fix this issue and match the 2 points above.
I need read more code about the list implementation to find an appropriate way to fix this, any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants