Skip to content

fix: Fix setting status of delete button in multiple files widget - #1443

Open
Czaki wants to merge 4 commits into
developfrom
fix/partseg-10d
Open

fix: Fix setting status of delete button in multiple files widget#1443
Czaki wants to merge 4 commits into
developfrom
fix/partseg-10d

Conversation

@Czaki

@Czaki Czaki commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

fix PARTSEG-10D

Summary by Sourcery

Adjust delete button behavior in the multiple files selection widget to correctly reflect the current selection and handle edge cases.

Bug Fixes:

  • Enable the delete button only when a file is actually selected in the multiple files widget.
  • Prevent errors when attempting to delete with no selected item in the list.
  • Reset the delete button to disabled when the file list is cleared.

Summary by CodeRabbit

  • Bug Fixes
    • Updated multiple-file deletion to remove all selected files at once.
    • Improved delete control state based on whether files are selected.
    • Prevented deletion when no files remain or the selection is cleared.

@sourcery-ai

sourcery-ai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the delete button enable/disable logic in the multiple files selection widget to depend on the current selection and safely handle deletion and reset states.

State diagram for delete button enable/disable logic in multiple files widget

stateDiagram-v2
    [*] --> Disabled

    Disabled --> Enabled: file_chosen
    note right of Enabled
      condition: selected_files.currentRow() != -1
    end note

    Enabled --> Disabled: delete_element
    note right of Disabled
      condition: selected_files.count() == 0
    end note

    Enabled --> Disabled: clean
    Disabled --> Disabled: clean

    Enabled --> Enabled: file_chosen
    note right of Enabled
      condition: selected_files.currentRow() != -1
    end note

    Disabled --> Disabled: file_chosen
    note right of Disabled
      condition: selected_files.currentRow() == -1
    end note
Loading

File-Level Changes

Change Details Files
Make the delete button enabled only when a file is selected and properly reset/guard it during deletions and cleanup.
  • Change file selection handler to enable the delete button only when there is a current selection index (not -1).
  • Guard delete logic by early-returning if no item is selected before accessing its properties or removing it from internal state.
  • Disable the delete button when the file list is fully cleared via the clean method to keep UI state consistent.
package/PartSeg/common_gui/select_multiple_files.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Czaki, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 18524077-76b5-40da-b19c-237e458f899a

📥 Commits

Reviewing files that changed from the base of the PR and between f1164e5 and 2dabfce.

📒 Files selected for processing (1)
  • package/PartSeg/common_gui/select_multiple_files.py
📝 Walkthrough

Walkthrough

The file selection widget now deletes all selected files and updates the delete-button state when files are selected or cleared. Codecov GitHub Checks annotations are enabled.

Changes

File selection controls

Layer / File(s) Summary
Deletion control state and safeguards
package/PartSeg/common_gui/select_multiple_files.py
file_chosen enables deletion when files are selected. delete_element removes all selected files. The delete button is disabled when no files remain or after clean clears the list.

Codecov checks

Layer / File(s) Summary
GitHub Checks annotation configuration
codecov.yml
Codecov annotations are enabled in GitHub Checks.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change to delete button behavior in the multiple files widget.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/partseg-10d

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.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider centralizing the delete button enable/disable logic into a small helper (e.g. _update_delete_button_state()) and calling it from file_chosen, delete_element, and clean to keep the behavior consistent and easier to maintain.
  • For clarity and consistency with setEnabled(...) usage elsewhere, you may want to replace self.delete_button.setDisabled(True) in clean with self.delete_button.setEnabled(False).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider centralizing the delete button enable/disable logic into a small helper (e.g. `_update_delete_button_state()`) and calling it from `file_chosen`, `delete_element`, and `clean` to keep the behavior consistent and easier to maintain.
- For clarity and consistency with `setEnabled(...)` usage elsewhere, you may want to replace `self.delete_button.setDisabled(True)` in `clean` with `self.delete_button.setEnabled(False)`.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package/PartSeg/common_gui/select_multiple_files.py`:
- Around line 231-236: Update delete_button enablement and delete_element to
require an actually selected item rather than relying on currentRow(). Use
selectedItems(), currentItem() with isSelected(), or equivalent selection
validation before enabling deletion and calling takeItem, while preserving the
existing no-item early return.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c2685fc-8a5d-4b86-99c1-527fa0712ff8

📥 Commits

Reviewing files that changed from the base of the PR and between 800ff7f and 3242085.

📒 Files selected for processing (1)
  • package/PartSeg/common_gui/select_multiple_files.py

Comment thread package/PartSeg/common_gui/select_multiple_files.py Outdated
@Czaki Czaki added this to the 0.17.1 milestone Aug 3, 2026
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.56%. Comparing base (800ff7f) to head (2dabfce).

Files with missing lines Patch % Lines
...ackage/PartSeg/common_gui/select_multiple_files.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1443   +/-   ##
========================================
  Coverage    92.56%   92.56%           
========================================
  Files          211      211           
  Lines        33224    33226    +2     
========================================
+ Hits         30755    30757    +2     
  Misses        2469     2469           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package/PartSeg/common_gui/select_multiple_files.py`:
- Around line 233-239: Update delete_element to remove each deleted FileListItem
from selected_files using takeItem with the item’s current row before or
alongside removing its path from files_to_proceed. Set delete_button enabled
state from the remaining widget selection/count after deletion, and extend
test_delete_element to assert the widget count is updated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0bcc6364-173e-47cd-b2f0-97f8683b504e

📥 Commits

Reviewing files that changed from the base of the PR and between 3242085 and f1164e5.

📒 Files selected for processing (2)
  • codecov.yml
  • package/PartSeg/common_gui/select_multiple_files.py

Comment thread package/PartSeg/common_gui/select_multiple_files.py
@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

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.

1 participant