Skip to content

fix: sftp: saving an edit asks when the file changed after it was opened - #2049

Open
pwu2775-dev wants to merge 1 commit into
lollipopkit:mainfrom
pwu2775-dev:fix/sftp-editor-stale-check
Open

pwu2775-dev wants to merge 1 commit into
lollipopkit:mainfrom
pwu2775-dev:fix/sftp-editor-stale-check

Conversation

@pwu2775-dev

Copy link
Copy Markdown
Contributor

What this changes

The editor path through the monitor's agent backend has, since it was written, compared the file the server now describes against the one the edit opened and asked before replacing it — its own comment says "Before the bytes: a change in between then reads as a change at save, never as one silently overwritten". The SFTP path, which is the default one, had none: _edit fetched a copy, the editor held it for however long the user worked, and _saveBack queued the whole local file straight over the remote — so a change made in another terminal, by a deploy, or by a second device in those minutes was replaced without it ever being said.

The mtime the listing gave _edit now travels to the save-back, which stats the remote once before writing and asks whether to overwrite when the two disagree — the same fileChangedOverwrite dialog the monitor path shows (its string reused, no new l10n). Asked, not refused: the user may have seen the change and want their version anyway. A stat that cannot be had writes as before rather than blocking an edit it knows nothing about, and the sudo route runs through the same check.

How it was tested

flutter analyze lib/view/page/storage/sftp.dart clean. sftp_file_backend_test (4) and sftp_replace_test pass. The behavioral change is the stat-and-ask in _saveBack, wired from the mtime the listing already carries (FileEntry.modified) — the same pattern server_file.dart's writeIfUnchanged flow uses on the monitor side.

Windows 11, Flutter 3.50.0. No model / ARB file changed, no crates/ change, no formatter run over untouched code.

The editor path through the monitor's agent backend has, since it was
written, compared the file the server now describes against the one the
edit opened and asked before replacing it — "Before the bytes: a change
in between then reads as a change at save, never as one silently
overwritten". The SFTP path, which is the default one, had none: _edit
fetched a copy, the editor held it for however long the user worked,
and _saveBack queued the whole local file straight over the remote — so
a change made in another terminal, by a deploy, or by a second device
in those minutes was replaced without it ever being said.

The mtime the listing gave _edit now travels to the save-back, which
stats the remote once before writing and asks whether to overwrite when
the two disagree (the same fileChangedOverwrite dialog the monitor path
shows; reusing its string, no new l10n). Asked, not refused — the user
may have seen the change and want their version anyway. A stat that
cannot be had writes as before rather than blocking an edit it knows
nothing about, and the sudo route runs through the same check.
@pwu2775-dev

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

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.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 439f502c-3880-4a96-aa09-34c0da96e5cb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

This branch has not been deployed

No deployments
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