Skip to content

PowerRename: continue batch rename on per-item IFileOperation failures and surface partial-failure state#47060

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-powerrename-html-file-error
Draft

PowerRename: continue batch rename on per-item IFileOperation failures and surface partial-failure state#47060
Copilot wants to merge 3 commits intomainfrom
copilot/fix-powerrename-html-file-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Summary of the Pull Request

PowerRename currently reports success while silently stopping the batch when it hits an html rename that triggers shell-level conflict behavior (for example, connected folder scenarios). This change isolates rename execution per item so one failure does not terminate the batch, and surfaces partial failures in UI state instead of closing as if fully successful.

PR Checklist

  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

  • Rename execution semantics

    • Switched from a single aggregated IFileOperation rename batch to per-item operations in PowerRenameManager.
    • A failing item is marked and reported; remaining items continue processing.
  • Partial-failure propagation

    • Added file-op error signaling (SRM_FILEOP_ITEM_ERROR) and completion state propagation to manager/UI flow.
    • If any item fails, OnRenameCompleted is raised with non-close behavior to prevent false “all good” UX.
  • UI error surfacing

    • Implemented MainWindow::OnError handling to retain error state across completion.
    • Added localized error text: ErrorMessage_RenameFailed ("This item couldn't be renamed.").
    • Mapped ItemNameAlreadyExists to error visual state and message rendering path.
  • Focused regression coverage

    • Added VerifyRenameContinuesWhenOneItemFails in PowerRename manager tests:
      • locks one target file to force runtime rename failure,
      • verifies unaffected files are still renamed,
      • verifies partial-failure completion behavior is emitted.
// Per-item operation: failure is isolated, loop continues.
HRESULT renameHr = spFileOp->RenameItem(spShellItem, newName, nullptr);
if (SUCCEEDED(renameHr))
{
    renameHr = spFileOp->PerformOperations();
}
if (FAILED(renameHr))
{
    markItemError(spItem);
    continue;
}

Validation Steps Performed

Added a targeted regression unit test that exercises mixed success/failure rename batches (VerifyRenameContinuesWhenOneItemFails) to validate failure isolation and partial-failure signaling behavior.

Copilot AI changed the title [WIP] Fix PowerRename exiting on html file with connected folder PowerRename: continue batch rename on per-item IFileOperation failures and surface partial-failure state Apr 17, 2026
Copilot AI requested a review from moooyo April 17, 2026 09:22
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.

PowerRename exits when it reaches an html file with connected folder

2 participants