Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(file-operations): unify same-folder and cross-folder paste #395

Description

@wmfeht

Split from the grouped rename and copy/paste report (#354, item 5 of 5).

Sibling issues already filed for other slices of that report: copy undo (#390), conflict dialog X (#391), destination selection (#392), rename caret (#394). This issue is the remaining product inconsistency between pasting into the current folder and pasting into a different folder — naming / collision policy — not those completion behaviors.

Strata version

Reproduced on Strata debug build at commit 183d744 with fixture source/report.txt and dest/report.txt.

What happened?

Copy/paste does not behave the same way when the destination is the current folder versus a different folder.

In practice:

  • Pasting a file into the folder it already occupies silently creates name (1).ext (then (2), …) and never asks.
  • Pasting that same file into another folder that already has name.ext raises “File already exists” with Replace / Skip / Cancel, and has no “keep both / unique name” choice.

That makes it hard to predict whether a paste will auto-rename, prompt, replace, or no-op.

Steps to reproduce

Use a writable fixture with source/report.txt and dest/report.txt (same basename, different files).

Same-folder paste (auto-duplicate)

  1. Open source/.
  2. Copy report.txt and paste into source/.
  3. Observe a new report (1).txt with no dialog.

Cross-folder paste (conflict dialog)

  1. Copy source/report.txt.
  2. Open dest/ and paste.
  3. Observe the “File already exists” dialog instead of a generated unique name.
  4. Choose Replace, Skip, and Cancel on separate runs and compare outcomes.

Expected behavior

Same-folder and cross-folder paste share consistent naming and collision policy (auto unique name, prompt, or a prompt that includes “keep both”), and share the same dialog actions when a prompt is required.

Duplicate and clipboard paste into the source’s parent must stay on that shared path so Ctrl+V in the current folder and an explicit duplicate do not diverge again.

Selection / undo / dialog X belong to the sibling issues above; the unified paste path should use those once they exist.

Screenshots or video

Full walkthrough (~91s) — same-folder unique name, conflict dialog Cancel/Skip, Miller context check:

https://cursor.com/artifacts/v/art-86a1f3a7-9cee-47d1-8ac9-a381187a9b2b

Clean side-by-side (~28s) — silent report (1).txt, then conflict dialog → Replace:

https://cursor.com/artifacts/v/art-785334c0-28ba-46e3-b57f-36e626141119

Additional context

Paste enters BrowserState::start_transfer. transfer_has_collision returns false when the source equals the would-be target, so same-folder pastes bypass the dialog and take the path where local_operations allocates name (1).ext via duplicate_target. Only genuine cross-folder collisions reach confirm_replace_conflict, which offers Replace / Skip / Cancel with no generate-unique-name choice.

TransferConflict only has FailIfExists and ReplaceExisting — there is no keep-both / unique-name option for the cross-folder dialog.

Acceptance criteria

  • Same-folder and cross-folder paste use one naming and collision policy, including generated unique names and conflict-resolved names.
  • Duplicate, clipboard paste into the source folder, and clipboard paste into another folder share completion, selection, and undo behavior (via the sibling fixes).
  • The conflict dialog, when shown, offers the same actions regardless of which path produced the collision; Cancel / Escape / X do not modify files.
  • Automated tests cover: same-folder generated names, cross-folder unique-name or replace/skip outcomes under the chosen policy, and mixed multi-item pastes.

Labels suggestion: bug, UX

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2UXbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions