Skip to content

Migrate editor to use remote backed buffer#10520

Open
kevinyang372 wants to merge 7 commits intomasterfrom
kevin/migrate-editor-to-use-remote-buffer
Open

Migrate editor to use remote backed buffer#10520
kevinyang372 wants to merge 7 commits intomasterfrom
kevin/migrate-editor-to-use-remote-buffer

Conversation

@kevinyang372
Copy link
Copy Markdown
Member

@kevinyang372 kevinyang372 commented May 8, 2026

Description

Wire editor to use remote backed buffer. A few noteable things:

  1. LocalCodeEditor (I will change its name in a follow-up) now takes a FileLocation, which could be a local / remote file
  2. Existing LocalCodeEditor concepts like conflict resolution banner is now hooked up with the remote logic

Also fixed a bug where server detected conflicts aren't being properly forwarded to the client

This also removes the remote file tree gating on not opening files

Testing

Tested locally

@cla-bot cla-bot Bot added the cla-signed label May 8, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 8, 2026

@kevinyang372

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR wires the code editor and file tree to open and save remote-backed buffers, adds conflict notifications, and extends buffer tracking for server-local buffers.

Concerns

  • Remote OpenBuffer responses can still replace the editable buffer unconditionally, which can drop user edits made before the initial load completes.
  • Local file-tree CodeSource state no longer persists its file path because the only location field is skipped by serde.
  • Remote save failure handling can clear the dirty state even when the save failed.
  • Discarding a remote conflict by closing and reopening the buffer does not guarantee a disk reload when another connection still has that server buffer open.

Found: 1 critical, 3 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread app/src/code/editor_management.rs Outdated
Comment thread app/src/code/global_buffer_model.rs
Comment thread app/src/code/global_buffer_model.rs
Comment thread app/src/code/global_buffer_model.rs Outdated
// (which contains stale client edits). The subsequent OpenBuffer
// will create a fresh buffer and read from disk.
let path_for_close = path_str.clone();
client.close_buffer(path_for_close);
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.

⚠️ [IMPORTANT] Discarding a remote conflict by sending CloseBuffer does not force a fresh disk read when another connection still has the same server buffer open; the server keeps the stale in-memory buffer and the subsequent OpenBuffer can return it again. Use an explicit reload/accept-server RPC or otherwise force the server to reopen from disk.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a very good call. Updated to have a force_reload flag for opening buffers

@kevinyang372 kevinyang372 requested a review from moirahuang May 8, 2026 22:54
Copy link
Copy Markdown
Contributor

@moirahuang moirahuang left a comment

Choose a reason for hiding this comment

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

  1. the delay is kinda long when overwriting, can we auto dismiss and then bring back the banner if it fails to save
    https://github.com/user-attachments/assets/56e11d37-251f-4329-8c02-0692982b22e6

  2. when we discard, we aren't correctly writing the first time. it only correctly writes the 2nd time
    https://github.com/user-attachments/assets/221b8d00-f826-48da-8e03-ca39d395637e


match item {
FileTreeItem::File { metadata, .. } => {
// Remote file trees don't support opening files in the editor.
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.

very niceeeee

let manager = RemoteServerManager::handle(ctx);
manager.as_ref(ctx).client_for_host(&host_id).cloned()
};
log::debug!(
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.

nit: do we need the log debugs here and below?

return;
};
if let BufferSource::Remote { sync_clock, .. } = &mut state.source {
*sync_clock = Some(SyncClock::from_wire(response.server_version, 0));
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.

why do we save this version as 0 vs. the latest version?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants