Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove presence of leftover data from previous page in TUI (#592) #725

Merged
merged 4 commits into from
Jul 10, 2024

Conversation

abhishek818
Copy link
Contributor

@abhishek818 abhishek818 commented Jul 3, 2024

fix: remove presence of leftover data from previous page in TUI (#592)
fix: filter input gets duplicated in full screen tui (#668)

  1. consider height of other ui components ('title' header in this case) while setting window height for workspaces list.
  2. set a max height for workspace selection view.
  • This change requires a documentation update
  • I have made corresponding changes to the documentation

This PR addresses issue #592 and #668

closes #592
closes #668

/claim #592

@abhishek818 abhishek818 requested a review from a team as a code owner July 3, 2024 19:48
@abhishek818
Copy link
Contributor Author

@idagelic @Tpuljak Up for review.

@abhishek818 abhishek818 force-pushed the tui_last_page_fix branch 2 times, most recently from acd41d5 to 99204b9 Compare July 3, 2024 19:56
@abhishek818 abhishek818 changed the title TUI - fix presence of leftover data from previous page (#592) fix - remove presence of leftover data from previous page in TUI (#592) Jul 3, 2024
…onaio#592)

consider height of other ui components ('title' header
in this case) while setting window height for workspaces list.

Signed-off-by: Abhishek Kumar Gupta <abhishekguptaatweb17@gmail.com>
@abhishek818 abhishek818 changed the title fix - remove presence of leftover data from previous page in TUI (#592) fix: remove presence of leftover data from previous page in TUI (#592) Jul 3, 2024
@abhishek818
Copy link
Contributor Author

abhishek818 commented Jul 3, 2024

i demand additional tip for the level of stupid ways i tried to solve this.. :p 😅

@abhishek818
Copy link
Contributor Author

abhishek818 commented Jul 3, 2024

PS: subtracting height by 4 is more safer (due to title header + 'current profile' line tag at end of tui), just check it out once on your screens, using 3 just worked for me.

Also one of other tried ways:

// fails
case tea.WindowSizeMsg:
      h, v := views.DocStyle.GetFrameSize()
      itemHeight := lipgloss.NewStyle().GetVerticalFrameSize() + 4
      availableHeight := msg.Height - v
      
      itemsPerPage := availableHeight / itemHeight
      remainingItems := len(m.list.Items()) % itemsPerPage
      
      if remainingItems > 0 {
	      m.list.SetSize(msg.Width-h, remainingItems*itemHeight+v)
      }

Copy link
Member

@idagelic idagelic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @abhishek818, thanks for the PR

As you can see on this closed PR, there was a similar attempt with changing the height of the view which resulted in big empty bars on the top and bottom of the view. We were hoping for a solution that doesn't make this compromise and fixes the underlying issue instead which is why we kept the issue open. Please let me know if you find a solution that gets rid of the residue without sacrificing the space

Here are the screenshot from your branch and main

Screenshot 2024-07-04 at 10 09 41 Screenshot 2024-07-04 at 10 08 57

@abhishek818
Copy link
Contributor Author

@idagelic hey I have pushed 1 more commit related to this issue.

My fixes results in listing of 11 repo results instead of 12. I have found several other repos like this where they are hardcoding a value to be sub/add to the height/widths. Overall, all these ui issues are related to allotment of appropriate heights/widths for respective ui components. I find this is the only way to fix this.

Refer some discussions on bubbletea repos: here1 and here2

Also, I think the tradeoff of some empty space for these fixes is a better deal.
Anyways upto you.. 😅 just trying to convince you.

BEFORE:
daytona_tui_BEFORE_fix_2024-07-24

AFTER:
daytona_tui_AFTER_fix_2024-07-24

daytona_tui_AFTER_fix_2_2024-07-24

@abhishek818
Copy link
Contributor Author

abhishek818 commented Jul 4, 2024

PS: had tried fixing empty spaces at header and footer by changing padding etc. Nothing works once height is manipulated for workspaces list in the view file..
CC: @idagelic

set a max height for workspace selection view.

Signed-off-by: Abhishek Kumar Gupta <abhishekguptaatweb17@gmail.com>
@abhishek818
Copy link
Contributor Author

abhishek818 commented Jul 8, 2024

@idagelic you got time to review ?
your views on above comments #725 (comment) ?

@idagelic
Copy link
Member

idagelic commented Jul 9, 2024

@abhishek818 The difference is less obvious on full screen terminal windows, but when there would only be 3 elements in the list page, that number is now reduced to 2 for example. Also, you unintentionally "lost" the "Active profile" footer under the view.
I agree that the last page residue is still an issue and I would love to have it resolved - I'll request an opinion from another maintainer.

@idagelic idagelic requested a review from Tpuljak July 9, 2024 08:21
@Tpuljak
Copy link
Member

Tpuljak commented Jul 9, 2024

@abhishek818 The difference is less obvious on full screen terminal windows, but when there would only be 3 elements in the list page, that number is now reduced to 2 for example. Also, you unintentionally "lost" the "Active profile" footer under the view.

Screenshot 2024-07-09 at 10 36 44
I believe too much space was lost here. It would've been fine if maybe only one row was lost. Is that a possibility @abhishek818?

Also, losing the active profile footer label is not an option. It needs to be shown in all the places as before.

Signed-off-by: Abhishek Kumar Gupta <abhishekguptaatweb17@gmail.com>
@abhishek818
Copy link
Contributor Author

Also, you unintentionally "lost" the "Active profile" footer under the view.

fixed, brought it back.

I believe too much space was lost here. It would've been fine if maybe only one row was lost. Is that a possibility @abhishek818?

yeah, unfortunately cant resolve the empty height issue. This is weird, have tried resizing to terminal's height everywhere but once list's size is fixed here nothing can be done.

Ultimately, this fix solves both the last page residue and filter input getting duplicated issues. Upto you guys.
@Tpuljak @idagelic

@Tpuljak
Copy link
Member

Tpuljak commented Jul 9, 2024

	if m.list.FilterState() == list.Filtering {
		return views.DocStyle.MaxWidth(terminalWidth - 4).Height(terminalHeight - 4).Render(m.list.View() + m.footer)
	}

	return views.DocStyle.MaxWidth(terminalWidth - 4).Height(terminalHeight - 2).Render(m.list.View() + m.footer)

I believe this solution works best. It minimizes space lost at the top (it remains at 2 empty rows which is what we want) and doesn't cause "ghosted items" when filtering.

Signed-off-by: Abhishek Kumar Gupta <abhishekguptaatweb17@gmail.com>
@abhishek818
Copy link
Contributor Author

abhishek818 commented Jul 10, 2024

	if m.list.FilterState() == list.Filtering {
		return views.DocStyle.MaxWidth(terminalWidth - 4).Height(terminalHeight - 4).Render(m.list.View() + m.footer)
	}

	return views.DocStyle.MaxWidth(terminalWidth - 4).Height(terminalHeight - 2).Render(m.list.View() + m.footer)

I believe this solution works best. It minimizes space lost at the top (it remains at 2 empty rows which is what we want) and doesn't cause "ghosted items" when filtering.

yes, works best, thanks. (now only leaves out a single trace only when the list size is 2 items but thats okay..)

Only 2 small issues with filter mode left :

  1. type something in input, then erase it to type some other query, filter input gets duplicated.
  2. leaves traces of search results while typing the search query and after the final results.

Just replacing with 'MaxHeight' below resolves it.

if m.list.FilterState() == list.Filtering {
		return views.DocStyle.MaxWidth(terminalWidth - 4).Height(terminalHeight - 4).Render(m.list.View() + m.footer)
	}

@Tpuljak

Copy link
Member

@Tpuljak Tpuljak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work great now. Thanks!

Copy link
Member

@idagelic idagelic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well now.
I see that you put this PR closes #668 as well - yes, it fixes the filter issue which is great. Have you had any success reproducing and fixing the problem when the cursor sometimes moves to the bottom of the screen making it impossible to select items?

@idagelic idagelic merged commit edfa52c into daytonaio:main Jul 10, 2024
12 checks passed
@abhishek818
Copy link
Contributor Author

This works well now. I see that you put this PR closes #668 as well - yes, it fixes the filter issue which is great. Have you had any success reproducing and fixing the problem when the cursor sometimes moves to the bottom of the screen making it impossible to select items?

Perhaps pressing any key or '/' during the loading time (i.e. when it is about to render the next view) is the way to reproduce this. Not sure about it and not sure if this can even be resolved..

Will checkout this issue some other day.

@abhishek818
Copy link
Contributor Author

bounty not credited yet, Is it delayed on algora's side? @Tpuljak

@Tpuljak
Copy link
Member

Tpuljak commented Jul 10, 2024

@abhishek818 my bad on that one. I configured auto-payouts shortly after abut this one didn't go through so I processed it manually now.

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

Successfully merging this pull request may close these issues.

TUI breaking under pressure TUI Pagination breaks on last page
3 participants