Skip to content

fix: patch-hub crashes when loading patches after b4 fails #142

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 2 commits into
base: unstable
Choose a base branch
from

Conversation

ArthurPilone
Copy link

Seeking to fix #69, this first commit introduces a check to the function init_details_actions. We hoped to stop the crash described in #69 by throwing an Err and catching it in the handle_latest_patchsets fucntion before showing a popup to the user. For some still unkown reason, the TUI freezes and 'melts' after the popup is shown.

Co-developed-by: Bruno Stephan [email protected]
Co-developed-by: Andre de Lima [email protected]

Seeking to fix kworkflow#69, this commit introduces a check to the function
init_details_actions. We hoped to stop the crash described in kworkflow#69
by throwing an Err and catching it in the handle_latest_patchsets
fucntion before showing a popup to the user. For some still unkown
reason, the TUI freezes and 'melts' after the popup is shown.

Co-developed-by: Bruno Stephan <[email protected]>
Signed-off-by: Bruno Stephan <[email protected]>
Co-developed-by: Andre de Lima <[email protected]>
Signed-off-by: Andre de Lima <[email protected]>
Signed-off-by: Arthur Pilone <[email protected]>
@ArthurPilone
Copy link
Author

@davidbtadokoro and @lorenzoberts we'd really appreciate it if you could check out this bug our partial "fix" introduces. It seems to have something to do with the rendering or with the thread management. Try to reproduce the original bug from #69 with the patch accel-config/[Install test programs in /usr/lib].

Do you guys have any info or what exactly we should look after in order to fix this?

This commit fixes the previous one. The terminal
was unresponsive because the macro received an Err.

We created a new enum to test whether the init_details_action
function found a patch in the expected path. This enum is
used to test whether the file exists in the
handle_latest_patchsets function still using an Ok().

Fixes: kworkflow#69

Co-developed-by: Bruno Stephan <[email protected]>
Signed-off-by: Bruno Stephan <[email protected]>
Co-developed-by: Andre de Lima <[email protected]>
Signed-off-by: Andre de Lima <[email protected]>
Signed-off-by: Arthur Pilone <[email protected]>
@ArthurPilone
Copy link
Author

Fixed.

@ArthurPilone ArthurPilone marked this pull request as ready for review May 14, 2025 19:44
@davidbtadokoro davidbtadokoro force-pushed the unstable branch 2 times, most recently from 167d77b to deba389 Compare May 16, 2025 18:55
Copy link
Collaborator

@auyer auyer left a comment

Choose a reason for hiding this comment

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

I have a few minor fixes before finishing the review.

@@ -3,7 +3,7 @@ use crate::{
ui::popup::{info_popup::InfoPopUp, PopUp},
};
use ansi_to_tui::IntoText;
use color_eyre::eyre::bail;
use color_eyre::eyre::{bail};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unecessary braces. They should be used when importing different parts in the same package.

Suggested change
use color_eyre::eyre::{bail};
use color_eyre::eyre::bail;

Comment on lines +70 to +71
Ok(())
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

fix formatting

Suggested change
Ok(())
}
Ok(())
}

Comment on lines +65 to +67
app.popup = Some(InfoPopUp::generate_info_popup("Error","The selected patchset couldn't be retrieved.\nPlease choose another patchset."));
app.set_current_screen(CurrentScreen::LatestPatchsets);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

fix formatting

Suggested change
app.popup = Some(InfoPopUp::generate_info_popup("Error","The selected patchset couldn't be retrieved.\nPlease choose another patchset."));
app.set_current_screen(CurrentScreen::LatestPatchsets);
}
app.popup = Some(InfoPopUp::generate_info_popup("Error","The selected patchset couldn't be retrieved.\nPlease choose another patchset."));
app.set_current_screen(CurrentScreen::LatestPatchsets);
}

Copy link
Collaborator

@auyer auyer left a comment

Choose a reason for hiding this comment

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

This is good overall. But I would like to ask for a few improvements.
I'm open to help and discuss this. Thanks!

Comment on lines +37 to +40
pub enum PatchFound {
Found,
NotFound
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this naming is a bit unidiomatic.
If you look at the usage, PatchFound::Found and PatchFound::NotFound is a bit "funny".

I would like to propose a change that goes a bit beyond just changing the name.
My suggestion is to name it B4Result, and the lore_session::download_patchset function should return it.
Doing this, the "file exists" check (see image) could also be moved inside the download_patchset function too, and the enum can carry the Path for us.
image

Suggested change
pub enum PatchFound {
Found,
NotFound
}
pub enum B4Result {
PatchFound(PathBuf),
PatchNotFound,
}

Copy link
Collaborator

@davidbtadokoro davidbtadokoro left a comment

Choose a reason for hiding this comment

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

Hi guys! I'm just dropping in to add a few comments to compliment @auyer's review (thank you so much, BTW, Rafa). Nevertheless, I can't thank you guys enough for tackling this annoying and ghostly bug! Also, feel free to ping me in case of any doubt!

Number of Commits

Because a PR is still unmerged code, we have the opportunity to refine it and make it the most atomic (along with all the other good git practices stuff).

In this sense, I feel like the first commit goes in one direction (tries to fix the bug using Result), while the second goes in another direction (the "correct" one that works). So, you should make this PR a single commit by dropping the first and leaving just the second (it may need some adjustments).

If you don't know exactly how to do this, I recommend taking a look at this excellent section of the Git book about how you can manipulate a branch and "rewrite" history. Beyond this PR and even patch-hub, having this know-how is invaluable!

After rewriting the history locally, you need to force-push to the same remote branch, and GitHub will automatically update the PR.

Formatting and Linting

We have a formatter and a linter implemented in the project. To fix the problems pointed out by @auyer, you can use

cargo fmt --all

and

cargo lint --fix

for formatting and linting, respectively (I recommend running in this order). With the --fix option, the linter will try to detect and also fix rule violations, but it can "fail" to automatically solve one or another problem.

Optionally, you can use the pre-commit hook we have implemented to run both formatter and linter before every and each commit. For now, just locally and explicitly running both will suffice, IMO.

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.

3 participants