Skip to content

Open the sketchbook sidebar at the right location #912

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

Closed
wants to merge 5 commits into from

Conversation

AlbyIanna
Copy link
Contributor

@AlbyIanna AlbyIanna commented Mar 15, 2022

Motivation

When opening a sketch, the sidebar doesn't behave as expected.

As stated in #442, this is the expected behaviour:

Whenever a sketch is opened (by double-clicking it on the sidebar or opening it from the 3 dots menu or when the Arduino IDE is launched from scratch) the sidebar will automatically open at the location of the current sketch; e.g.: if I open a remote sketch, the sidebar will show with the remote sketchbook open.
Note that if I close the editor with another widget open (the Library Manager, for example), when I re-open the IDE I still want the sidebar to show the sketchbook at the sketch location.

fixes #442

Change description

Check which sketchbook widget to show (remote or local) whenever the top-level sketchbook widget (which contains both) is opened.
https://github.com/arduino/arduino-ide/compare/active-sketchbook?expand=1#diff-34e4625218827959b97fd2f2905e68bc3c513e02fd972a65a283176d9245136aR42-R78

Also, fix a bug that occurs sometimes when opening the remote sketchbook and causes the widget to render completely empty:
https://github.com/arduino/arduino-ide/compare/active-sketchbook?expand=1#diff-70a70e54dd8a31cca611f181690c62f53f19385750d6383a5d336d6aaad82257R62-R72

Refine setLayoutData in application-shell.ts so that the initial layout of the left sidebar will always be set with the sketchbook container widget open.

Reviewer checklist

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

@AlbyIanna AlbyIanna requested review from fstasi and msujew March 15, 2022 11:38
@AlbyIanna AlbyIanna marked this pull request as ready for review March 16, 2022 13:56
@AlbyIanna AlbyIanna requested review from per1234 and ubidefeo March 16, 2022 14:14
Copy link
Contributor

@msujew msujew left a comment

Choose a reason for hiding this comment

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

I believe that's a good approach for the issue at hand. I have a minor improvement/question to make it a bit leaner.

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Mar 18, 2022
Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

Issues

I tried it on Windows and Linux and encountered a few different problems:

Remote sketchbook widget is never opened on Windows

To reproduce

  1. Open a sketch from the "Remote Sketchbook".

🐛 The "Sketchbook" view is opened in the Left Panel of the IDE window for the opened sketch, but it has the "Local Sketchbook" widget open.

Expected behavior

The "Remote Sketchbook" widget is open in the "Sketchbook" view of the IDE window for the opened sketch, with the sketch selected.

Additional context

The problem only occurs on Windows.

It doesn't work the first time the sketch is opened

  1. Select File > Quit from the Arduino IDE menus if it is running.
  2. Delete the "User data" folder:
    • Windows:
      • C:\Users\<user name>\AppData\Roaming\arduino-ide\
        
    • Linux:
      • ~/.config/arduino-ide/
        
    • macOS:
      • ~/Library/Application Support/arduino-ide/
        
  3. Start the Arduino IDE.
  4. Open a sketch.
    🐛 The "Sketchbook" view is not opened in the Left Panel of the IDE window for the opened sketch.
  5. Close the sketch window.
  6. Open the same sketch again.
    🙂 The "Sketchbook" view is opened in the Left Panel of the IDE window for the opened sketch, with the sketch selected.

Expected behavior

The "Sketchbook" view behavior is always the same regardless of whether it is the first time opening the sketch.

Additional context

After that first open, it does work as expected with local sketches. If I delete the "User data" folder then the problem repeats.

Both the local and remote sketchbooks have the behavior described above for me on Linux. On Windows, remote sketchbook is not working for me even on subsequent opens of the sketch, as I described previously.

Subfolder containing Sketches in subfolders are not selected

  1. Create a sketch in a subfolder of your sketchbook
    C:/Users/per/Documents/Arduino/
    ├── FooSketch/
    │   └── FooSketch.ino
    └── SomeSubfolder/
        └── BarSketch/
            └── BarSketch.ino
    
  2. Open the sketch from the subfolder of the sketchbook.

🐛 The "Sketchbook" view is opened in the Left Panel of the IDE window for the opened sketch, but the sketch is not selected:

image

Expected behavior

The newly opened sketch is selected in the "Sketchbook" view even if it is in a subfolder:

image

Enhancements

I suggest only enabling this behavior when the user opened the sketch via the "Sketchbook" view.

Opening the "Sketchbook" view in the new window after it is opened via the "Sketchbook" view is a very nice UX because it provides continuity of the UI by giving the new window the same UI state as the old one.

But if I didn't use the "Sketchbook" view to open the sketch then it is doing just the opposite. With the current behavior provided by this PR, the user who is not interested in using the "Sketchbook" view must constantly fight with the IDE in order to keep the unwanted view from occupying precious screen real estate.

…tchbook

# Conflicts:
#	arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts
#	arduino-ide-extension/src/browser/theia/core/application-shell.ts
#	arduino-ide-extension/src/browser/theia/core/shell-layout-restorer.ts
#	arduino-ide-extension/src/browser/utils/constants.ts
#	arduino-ide-extension/src/browser/widgets/cloud-sketchbook/cloud-sketchbook-composite-widget.tsx
#	arduino-ide-extension/src/browser/widgets/cloud-sketchbook/cloud-sketchbook-widget.ts
@AlbyIanna AlbyIanna requested a review from kittaakos June 17, 2022 11:04
@AlbyIanna AlbyIanna mentioned this pull request Jun 23, 2022
4 tasks
@AlbyIanna
Copy link
Contributor Author

Closing in favor of #1102

@AlbyIanna AlbyIanna closed this Jun 23, 2022
@per1234 per1234 added the conclusion: duplicate Has already been submitted label Jun 23, 2022
@per1234 per1234 deleted the active-sketchbook branch December 4, 2022 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: duplicate Has already been submitted topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sketchbook sidebar: opening a sketch will not show the last state of the sidebar in the new window
3 participants