Skip to content

IEP-1516: Automatic update to IDE with filewatcher #1210

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: release/v4.0.0
Choose a base branch
from

Conversation

alirana01
Copy link
Collaborator

@alirana01 alirana01 commented Apr 28, 2025

Description

We can update the IDE environment if there is a change to the eim json file. We will update the IDE only when there is one entry in json file. For multiple we will open the ESP-IDF Manager

Fixes # (IEP-1516)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How has this been tested?

Try to make changes to eim_idf.json file the IDE should be able to capture that and show a proper message to user to update their environment for only one entry it will update automatically for multiple ones we will launch ESP-IDF Manager.

Test Configuration:

  • ESP-IDF Version: all
  • OS (Windows,Linux and macOS): all

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Verified on all platforms - Windows,Linux and macOS

@alirana01 alirana01 self-assigned this Apr 28, 2025
Copy link

coderabbitai bot commented Apr 28, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Collaborator Author

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

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

Self Review

Copy link
Collaborator

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

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

from the code perspective LGTM

Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

LGTM. it would be great if we can incorpate the feedback.

@@ -7,6 +7,6 @@ EspIdfManagerReloadBtnToolTip=Reload from disk
IDFToolsHandler_ToolsManagerConsole=Espressif IDF Tools Console
IDFGuideLinkLabel_Text=Select the version of ESP-IDF you want to use. Click the radio button in Active column next to the version you want. For help in choosing the correct version, visit <a>ESP-IDF Version Guide</a>.
EimJsonChangedMsgTitle=ESP-IDF Installation Changed
EimJsonChangedMsgDetail=It looks like the ESP-IDF tools are modified. The Espressif IDE cannot guarantee the consistency. Kindly refresh the installation via ESP-IDF Manager.
EimJsonChangedMsgDetail=It looks like the ESP-IDF tools are modified. The Espressif IDE cannot guarantee the consistency. Do you want to refresh installation?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we maintain a positive tone in this message(especially this -The Espressif IDE cannot guarantee the consistency)?

It seems the ESP-IDF tools have been modified. To maintain consistency, we recommend refreshing your installation. Would you like to proceed with the update?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines +59 to +63
display.syncExec(() -> {
Shell shell = display.getActiveShell();
if (shell == null)
{
shell = new Shell(display);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Display.getDefault().getActiveShell() should work here considering that workbench has been already initilized, do you see any issue here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can also use EclipseUtil.getShell()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kolipakakondal yes since the handler can be called from early startup class it causes NPE because the shell is not available at times

Comment on lines 65 to 68
MessageBox messageBox = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
messageBox.setText(Messages.EimJsonChangedMsgTitle);
messageBox.setMessage(Messages.EimJsonChangedMsgDetail);
response[0] = messageBox.open();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use MessageDialog over MessageBox? MessageDialogs are better, more modern, and JFace-based.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 118 to 137
Display.getDefault().asyncExec(() -> {
IWorkbenchWindow activeww = EclipseHandler.getActiveWorkbenchWindow();
if (activeww != null && activeww.getActivePage() != null)
{
try
{
IDE.openEditor(activeww.getActivePage(), new EimEditorInput(eimJson),
ESPIDFManagerEditor.EDITOR_ID, true);
}
catch (PartInitException e)
{
Logger.log("Failed to open ESP-IDF Manager Editor.");
Logger.log(e);
}
}
else
{
Logger.log("Cannot open ESP-IDF Manager Editor. No active workbench window yet.");
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Avoid nested blocks
If certain criteria doesn't match, verify and return immedialy

if (activeww == null || activeww.getActivePage() == null) {
                Logger.log("Cannot open ESP-IDF Manager Editor. No active workbench window or page.");
                return;
            }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator Author

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

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

Self review after the code review comments resolution

Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

LGTM

@kolipakakondal
Copy link
Collaborator

Hi @AndriiFilippov Please check

@kolipakakondal kolipakakondal added this to the v4.0.0 milestone May 6, 2025
@AndriiFilippov
Copy link
Collaborator

@alirana01 hi!

Tested under:
OS - Windows 11
ESP-IDF: v5.4 / v5.3 / v5.2

The filewatcher been added only if tools\eim_idf.json exists. So, if user haven't used our eim installer before he runs IDE, the filewatcher won't be added without restart.

Reproduce:

delete your tools\eim_idf.json file -> run IDE -> run eim.installer and install ESP-IDF -> the installed version will appears in IDE Installation Manager -> but no filewatcher added. To add filewatcher - restart IDE.

@AndriiFilippov
Copy link
Collaborator

@alirana01 hi!

Tested under:
OS - Windows 11

During testing, I made a mistake by manually editing the eim_idf.json file (extra comma) and received an error in the Installation Manager. Perhaps we should consider providing a more informative error message in this case.

image

org.eclipse.core.runtime.AssertionFailedException: null argument:
	at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:92)
	at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:79)
	at org.eclipse.jface.viewers.StructuredViewer.assertElement

@AndriiFilippov
Copy link
Collaborator

@alirana01

Tested under:
OS - Windows 11

after changes to eim_idf.json the IDE react with pop up imessage:
image
but after any selection the message pop up again.

@AndriiFilippov
Copy link
Collaborator

@alirana01

OS - Windows 11

if I have 2 esp-idf installed (5.3 + 5.4), and for example using 5.4 as active. Then I deleted manually v5.3(inactive) from eim_idf.json -> then the info message ask to "refresh" installation but if I click yes
image

  • no tools re-installation happens

@AndriiFilippov
Copy link
Collaborator

@alirana01

OS - Windows 11

ESP-IDF Manager shell (window) does not update after changes to eim_idf.json file.
Example: have 1 esp-idf in eim_idf.json file -> install one more using eim_installer.exe -> after pop-up asking for "refreshing your installation" the ESP-IDF Manager window does not update values in table, you should close and re-open window to refresh table.

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