Skip to content

Fix behaviors of gui.sidePanelWidth: 1 #4583

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ChrisMcD1
Copy link
Contributor

@ChrisMcD1 ChrisMcD1 commented May 23, 2025

  • PR Description

We have technically allowed sidePanelWidth = 1 in the schema for forever. But it seems it never worked! #4582

yaml:"sidePanelWidth" jsonschema:"maximum=1,minimum=0"

This PR fixes 2 behaviors:

  1. When trying to full screen the main view, we previously we were relying on setting just the sideSectionWeight in order to ensure the main panel was fully focused. This can cause a problem if the user had their gui.sidePanelWidth set to 1. Such a value make the mainPanelWidth = 0 by default. By just setting the sideSectionWeight, you then communicate to the UI that you want both halves of the screen to have 0 width! No good! Crash!
  2. When switching to the main view, we implicitly assumed it was visible. Now, we set it to be full screen if it otherwise would have been not-rendered. That feels like the natural behavior for a full-screen side panel user.

These changes seem like they won't impact users of more standard gui.sidePanelWidth values, so it's just a free win!

Fixes #4582

  • Please check if the PR fulfills these requirements
  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

Chris McDonnell added 2 commits May 22, 2025 20:52
Previously we were relying on setting just the sideSectionWeight in order
to ensure the main panel was fully focused. This can cause a problem if
the user had their `gui.sidePanelWidth` set to 1. Such a value make the
mainPanelWidth = 0 by default. By just setting the sideSectionWeight, you
then communicate to the UI that you want _both_ halves of the screen to have
0 width! No good!

This change seems like it won't impact users of more standard
`gui.sidePanelWidth` values, so it's just a free win!
Any time that we are on the `currentWindow == "main"` it makes sense for
it to be visible, and this will ensure that
@ChrisMcD1 ChrisMcD1 changed the title Set explicit mainSectionWeight when forcing main view to full width Fix behaviors of gui.sidePanelWidth: 1 May 23, 2025
@stefanhaller stefanhaller added the bug Something isn't working label May 23, 2025
@stefanhaller
Copy link
Collaborator

The changes make sense to me. I guess there are some more weirdnesses around focusing the main view in half or full screen mode, but I don't use these modes much, and can't be bothered right now to explore this more. 😄

We have fancy tests for this kind of stuff in window_arrangement_helper_test.go, do you think it's worth adding tests for these new conditions?

Chris McDonnell added 2 commits May 23, 2025 17:24
I was unable to test the full flow that caused the crash from the
initial bug report inside of window_arrangement_helper_test.go, so I
created a full integration test.
@ChrisMcD1
Copy link
Contributor Author

We have fancy tests for this kind of stuff in window_arrangement_helper_test.go, do you think it's worth adding tests for these new conditions?

Sure, just added! Those tests don't end up exercising the crash point that created this PR, so I also made an integration test for that behavior in particular.

I also realized I had inadvertently duplicated the logic of "make the main view full screen", so I added a fixup to simply that logic.

@stefanhaller
Copy link
Collaborator

Looks great. Just one last question about the integration test: I verified that it crashes when I revert the production code changes, but only if I run it with go test pkg/integration/clients/*.go. If I run it with go run cmd/integration_test/main.go cli ui/side_panel_width_1, then it succeeds. Any idea why that might be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[sidePanelWidth]: Runtime error when value is 1.0
2 participants