Skip to content

Conversation

@DropSnorz
Copy link
Owner

Relates to #281

@DropSnorz DropSnorz self-assigned this Oct 27, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

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.

Walkthrough

Adds a utility to capture throwable stack traces as strings, uses it in TaskRunner error reporting, disables delete/uninstall UI buttons when target paths are not writable, and avoids inserting null root items into the plugin tree view during refresh.

Changes

Cohort / File(s) Summary
Stack trace logging
owlplug-client/src/main/java/com/owlplug/core/components/TaskRunner.java, owlplug-client/src/main/java/com/owlplug/core/utils/StringUtils.java, owlplug-client/src/test/java/com/owlplug/core/utils/StringUtilsTest.java
New StringUtils.getStackTraceAsString(Throwable) added; TaskRunner now passes the full stack trace string to taskBarController.setErrorLog(...) instead of ex.toString(). Unit tests added/updated for StringUtils.
File write-permission controls
owlplug-client/src/main/java/com/owlplug/plugin/controllers/DirectoryInfoController.java, owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginInfoController.java
Controllers now create java.io.File from configured paths and disable deleteDirectoryButton / uninstallButton when the target path is not writable (canWrite() check).
Tree view null-safety & docs
owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTreeViewController.java
clearAndFillPluginTree now skips adding directory root items whose item.getValue() is null; minor javadoc/comment grammar fixes.

Sequence Diagram(s)

sequenceDiagram
  participant TaskRunner
  participant TaskBarController
  participant StringUtils
  participant Throwable as Exception

  TaskRunner->>Exception: catches exception
  TaskRunner->>StringUtils: getStackTraceAsString(Exception)
  StringUtils-->>TaskRunner: stack trace string
  TaskRunner->>TaskBarController: setErrorLog(message, Exception.getMessage(), stackTraceString)
  Note right of TaskBarController #DDDDFF: UI receives full stack trace for display
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to TaskRunner changes to ensure exception message vs stack trace are passed in correct order/format to taskBarController.setErrorLog.
  • Verify StringUtils.getStackTraceAsString handles null inputs or unusual Throwables as intended.
  • Confirm canWrite() checks reflect desired UX on different platforms/permission scenarios and that disabling buttons is the correct behavior.
  • Review PluginTreeViewController change to ensure skipping null item.getValue() doesn't hide valid edge cases.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.05% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "Add simple permission checks before plugin uninstall" accurately describes a significant portion of the changeset. The changes include adding file writeability checks that disable uninstall and delete buttons in PluginInfoController and DirectoryInfoController, which directly corresponds to the title's subject matter. While the changeset also includes supporting improvements to error logging (TaskRunner.java and StringUtils.java) and bug fixes to PluginTreeViewController, the permission checks represent the core focus of the PR and the title appropriately highlights this main aspect without being misleading or off-topic.
Description Check ✅ Passed The PR description "Relates to #281" is minimal but provides a meaningful connection to the changeset by referencing the related issue. While lacking detailed explanation of the specific changes made, the check criteria explicitly state that "level of detail is not important" and this is a "very lenient check" that should pass as long as the description is "not completely off-topic." The issue reference demonstrates awareness of the underlying context and requirements, making it appropriately related to the changeset rather than completely unrelated or generic.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@DropSnorz
Copy link
Owner Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
owlplug-client/src/main/java/com/owlplug/plugin/controllers/DirectoryInfoController.java (1)

51-51: Remove unused import.

The Tooltip import is not used anywhere in this file.

-import javafx.scene.control.Tooltip;
owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginInfoController.java (1)

175-176: Permission check aligns with PR objective but could benefit from user feedback.

The implementation is consistent with DirectoryInfoController and provides a useful UI hint. However, it shares the same platform-specific limitations where canWrite() may not accurately reflect actual deletion permissions.

Consider adding a tooltip to explain why the uninstall button is disabled when permissions are insufficient.

 File file = new File(plugin.getPath());
 this.uninstallButton.setDisable(!file.canWrite());
+if (!file.canWrite()) {
+  this.uninstallButton.setTooltip(new Tooltip("Insufficient permissions to uninstall this plugin"));
+}
owlplug-client/src/main/java/com/owlplug/core/utils/StringUtils.java (1)

46-51: Handle null input and consider including exception cause chain.

The method will throw NullPointerException if a null throwable is passed. Additionally, it doesn't include the cause chain from getCause(), which may omit valuable debugging information.

Consider using the standard approach with StringWriter and PrintWriter, or add null checks and cause chain handling.

 public static String getStackTraceAsString(Throwable throwable) {
+  if (throwable == null) {
+    return "";
+  }
-  return throwable.toString() + "\n"
-          + Arrays.stream(throwable.getStackTrace())
-                  .map(StackTraceElement::toString)
-                  .collect(Collectors.joining("\n"));
+  java.io.StringWriter sw = new java.io.StringWriter();
+  throwable.printStackTrace(new java.io.PrintWriter(sw));
+  return sw.toString();
 }

This approach automatically includes the cause chain and handles all edge cases.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 72422ab and 6c4a993.

📒 Files selected for processing (5)
  • owlplug-client/src/main/java/com/owlplug/core/components/TaskRunner.java (2 hunks)
  • owlplug-client/src/main/java/com/owlplug/core/utils/StringUtils.java (2 hunks)
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/DirectoryInfoController.java (3 hunks)
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginInfoController.java (1 hunks)
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTreeViewController.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (4)
owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTreeViewController.java (2)

158-165: Good defensive programming to prevent empty tree items.

The null check ensures that only directory roots containing plugins are added to the tree view, preventing empty nodes from appearing in the UI.


258-258: Grammar correction improves documentation clarity.

owlplug-client/src/main/java/com/owlplug/core/components/TaskRunner.java (1)

127-127: Enhanced error logging improves debugging capability.

The change from ex.toString() to StringUtils.getStackTraceAsString(ex) provides complete stack traces in error logs, making it significantly easier to diagnose issues in production.

owlplug-client/src/main/java/com/owlplug/plugin/controllers/DirectoryInfoController.java (1)

171-172: Permission check is a necessary safeguard, not merely a UX hint.

The canWrite() check prevents DirectoryRemoveTask from executing when the directory is not writable. Unlike PluginRemoveTask which handles IOException gracefully, DirectoryRemoveTask lacks exception handling and will propagate deletion errors uncaught. The permission check is essential to prevent unhandled exceptions.

However, note that canWrite() has platform-specific limitations: on Windows it checks read-only attributes rather than full NTFS permissions, and it doesn't account for parent directory write requirements for deletion. Despite these limitations, the check appropriately prevents most permission-denied scenarios at the UI layer.

Likely an incorrect or invalid review comment.

@DropSnorz DropSnorz moved this to In Progress in OwlPlug 1.31 Oct 30, 2025
@DropSnorz DropSnorz force-pushed the feat/delete-permissions branch from 6c4a993 to dc820c2 Compare October 30, 2025 18:54
@DropSnorz
Copy link
Owner Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Oct 30, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6c4a993 and dc820c2.

📒 Files selected for processing (6)
  • owlplug-client/src/main/java/com/owlplug/core/components/TaskRunner.java (2 hunks)
  • owlplug-client/src/main/java/com/owlplug/core/utils/StringUtils.java (2 hunks)
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/DirectoryInfoController.java (2 hunks)
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginInfoController.java (1 hunks)
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTreeViewController.java (2 hunks)
  • owlplug-client/src/test/java/com/owlplug/core/utils/StringUtilsTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • owlplug-client/src/main/java/com/owlplug/core/components/TaskRunner.java
  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginInfoController.java
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-01-09T18:03:46.895Z
Learnt from: DropSnorz
PR: DropSnorz/OwlPlug#280
File: owlplug-client/src/main/java/com/owlplug/core/controllers/dialogs/DisablePluginDialogController.java:47-49
Timestamp: 2025-01-09T18:03:46.895Z
Learning: In the DisablePluginDialogController, the admin privileges warning is always shown when disabling a plugin, regardless of the actual file permissions, as implementing permission checks is complex and OS-dependent.

Applied to files:

  • owlplug-client/src/main/java/com/owlplug/plugin/controllers/DirectoryInfoController.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (7)
owlplug-client/src/main/java/com/owlplug/plugin/controllers/DirectoryInfoController.java (2)

35-35: LGTM!

The import is necessary for the permission check implementation.


170-171: Good UI safeguard, though platform-dependent.

The canWrite() check provides useful immediate feedback by disabling the delete button when the directory appears non-writable. Note that File.canWrite() behavior is platform-dependent and may not catch all permission scenarios, especially on Windows. Users may still encounter permission errors during the actual deletion if the check yields a false positive. This approach aligns with the project's strategy of using simple permission checks rather than complex OS-dependent verification. Based on learnings.

owlplug-client/src/main/java/com/owlplug/plugin/controllers/PluginTreeViewController.java (2)

159-164: LGTM!

The null check appropriately prevents empty directory roots from appearing in the tree view when no plugins are detected in that directory. This improves the user experience by keeping the tree clean.


258-258: LGTM!

Grammar correction improves the documentation quality.

owlplug-client/src/main/java/com/owlplug/core/utils/StringUtils.java (1)

21-22: LGTM!

The imports are necessary for the stack trace utility implementation.

owlplug-client/src/test/java/com/owlplug/core/utils/StringUtilsTest.java (2)

14-43: LGTM!

The truncate tests provide comprehensive coverage including normal cases and edge cases (null input, negative size, suffix length handling).


47-70: LGTM!

The ellipsis tests thoroughly cover the method's behavior including edge cases.

@DropSnorz DropSnorz force-pushed the feat/delete-permissions branch from dc820c2 to fd7df0e Compare October 30, 2025 19:04
@DropSnorz DropSnorz merged commit 422044a into master Oct 30, 2025
2 of 3 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in OwlPlug 1.31 Oct 30, 2025
daniel-chiuratto-seabra pushed a commit to daniel-chiuratto-seabra/OwlPlug that referenced this pull request Nov 3, 2025
…ning all the updates from the original repository until the commit below:

***********************************************************************
Merge pull request DropSnorz#390 from DropSnorz/feat/delete-permissions

Add simple permission checks before plugin uninstall

422044a Arthur Poiret <[email protected]> on 30/10/2025 at 20:17
committed by GitHub <[email protected]>
***********************************************************************
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants