Skip to content

view: apply edits to the latest source instead of whole-file snapshots #2067

Closed

Description

@shunichironomura

Warning

This content was written by an AI agent and must be verified by a human developer. After human verification, this alert may be removed.

Found in the review of #2057, which adds the experimental view. It does not block that PR; #2059 fixed the findings that did. Paths refer to #2059's head.

Problem

An edit from the sheet is the whole text of the file, built from host.source() when the edit is committed (web/view/src/main.ts). The host sets that text when the edit's turn comes (GitHubHost.edit in web/view/src/githubHost.ts).

If edits B and C are both committed while an evaluation runs, C is built from the text before B, so C erases B, after B was reported as applied.

This cannot happen today. Once the engine is loaded, evaluateView only awaits resolved promises and calls Wasm synchronously, so no input event runs between an edit's start and end. It will happen as soon as evaluation is really asynchronous, for example in a worker.

Related: #2059's ModelCache marks the models an edit did not re-project as stale, and re-projects them before use. Models are not tied to a source revision, so a late result cannot be recognised in general.

Proposed fix

  • Represent an edit as a range and its replacement (or a function of the latest source), and let the host apply it to its latest source on the edit's turn.
  • Give sources a revision, and record the revision each model was projected from.
  • Do this before moving evaluation into a worker.

Activity

  1. added a commit that references this issue on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorwebviewThe experimental view (web/view, graphcal view, graphcal/viewModel)

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions