Skip to content

[rpc] Destructive actions in collections always act on the original source.  #848

Open

Description

@dantleech

When executing multiple actions with a Collection respponse, the original source is always used, instead of the modified version from the previous action.

This is hard to solve without serious refactoring.

Because Phpactor is stateless, the client would need to provide up-to-date source code for the callback's source parameter.

  • We could refer to files by reference (e.g. URI) instead of only providing the source code.
  • The actual files (i.e. the ones we are working with) can be transferred as a generic field on the request / response objects.
  • The Client can then ensure that the files are up-to-date, and we need not supply the source code in callbacks, only the file references.

This could mean refactoring all handlers to supply a reference, and the client will need to ensure that:

  • It sends the reference instead of the current source field.
  • That on initial requests it provides the subject-file in the additional workspace field.

Activity

  1. camilledejoye commented on Mar 8, 2020

    @camilledejoye
    Contributor

    I'm not really sure about the reference thingy.
    The advantage of providing the source code directly is that phpactor is able to work on a code not saved yet.
    Even better it can work on a code in a buffer not linked to a file!
    Providing a reference will also imply to read the file from the disk, which could have an impact of the performances.

    Does the actions returned in the collection already contained the source key ?
    If yes, that might be the issue.
    We could provide the client with a collection of action to trigger but require from the client to provide the source code before each action. So it will always be updated.

  2. dantleech commented on Mar 8, 2020

    @dantleech
    CollaboratorAuthor

    Providing a reference will also imply to read the file from the disk, which could have an impact of the performances.

    The idea would be, I guess, to provide the source code in the initial request with a uniq ID (doesn't have to be a URI) - possibly a collection of files (so we'd call this the "workspace") which can then be used to reference it or similar.

    The language server protocol syncs files and deals with references (CoC (a languaage server client) will send f.e. untitled:10 if the buffer is empty and send all changes to that buffer to Phpactor with that reference).

  3. camilledejoye commented on Mar 9, 2020

    @camilledejoye
    Contributor

    So we will have to send phpactor the source code of our files when we edit them ?
    I'm not sure I'm following.
    Would it not be simpler and faster to just change the action we send to the client, instead of including the source code in it we add a path or something like that for the file the action need the source. Then the client just has to add the key source with the source code to the action before sending it back the RPC server ?

    Feel free to ignore if I haven't understood properly the issue :)

  4. dantleech commented on Mar 9, 2020

    @dantleech
    CollaboratorAuthor

    Would it not be simpler and faster to just change the action we send to the client

    Potentially, we just need to solve the problem of getting the latest source code when performing multiple actions on the same file over multiple requests.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions