Class OptimisticDraftHandler

java.lang.Object
com.vaadin.copilot.CopilotCommand
com.vaadin.copilot.OptimisticDraftHandler

public class OptimisticDraftHandler extends CopilotCommand
Commits browser-owned optimistic operations as one atomic source rewrite.

Operations are first applied to in-memory source models. Sources are saved only after every operation succeeds, allowing optimistic editors to provide an all-or-nothing submit action. New optimistic editors can add operation handlers here without becoming part of a source-editor command handler.

  • Field Details

  • Constructor Details

    • OptimisticDraftHandler

      public OptimisticDraftHandler(JavaRewriteHandler javaRewriteHandler)
      Creates the optimistic draft command handler.
      Parameters:
      javaRewriteHandler - the Java source rewrite operations used by the component editor
  • Method Details

    • handleMessage

      public boolean handleMessage(String command, tools.jackson.databind.JsonNode data, com.vaadin.base.devserver.DevToolsInterface devToolsInterface)
      Description copied from class: CopilotCommand
      Called whenever there is a message from the browser. Implementations should check if the command is for them, handle it and return true if the command was handled.
      Specified by:
      handleMessage in class CopilotCommand
      Parameters:
      command - the command to handle
      data - the data for the command
      devToolsInterface - the devtools interface for the connection
      Returns:
      true if the command was handled, false otherwise
    • findPreviewComponent

      public static ComponentInfo findPreviewComponent(String draftId, String optimisticComponentId, Path projectRoot) throws IOException
      Resolves an optimistic component exclusively from its persisted preview source. No browser DOM or operation-local metadata is retained server side between requests.
      Throws:
      IOException