Skip to content

[feat] Restore unmodified files exactly on cleanup #1738

Open
@Kitenite

Description

@Kitenite

Problem

Currently, we are transforming every jsx/tsx files with data-oid. While this helps with modifying the code exactly, it creates large commits that include irrelevant files.

Proposed solution

We should only track files that have been changed after the project is transformed. One way to do this is to create cache files and restore all the files that remain unchanged between the transform and cleaup. The algorithm should roughly be:

Start project

  1. Create a .onlook folder if it doesn't already exist
  2. Create cache files for each tsx/jsx files before they are transformed
  3. Transform file with oid
  4. Store a hash of each file's content
  5. Edit project as usual

Clean up

  1. Hash file content
  2. Check if hash is the same (file unchanged since transform)
    a. If hash is the same, restore cached file
    b. Else, clean up as usual

Some optimizations:
In the cache folder root, store map of path to hash, something like this:

{
  "actual/file/path.tsx": {
    "hash": "sha123",
    "cache_path": "123.tsx"
  },
  ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions