Skip to content

Conversation

@disconcision
Copy link
Member

@disconcision disconcision commented Sep 16, 2025

This can be used to sync hazel state between two clients who insert a Hazel tool in patchwork.

Currently this should do a good job retaining your caret position in a hazel document while another performs actions at a distance from your caret. Closer actions are also handled up to the limitations listed below.

Instructions to try this out:

  1. Get <patchwork_url> and <hazel_tool_id> from @disconcision
  2. Go to <patchwork_url>.
  3. Go to 'My tools', and add a new tool with id automerge:<hazel_tool_id>
  4. Create a new HazelDoc. This should appear as a hazel scratchpad, possibly in Dark Mode, depending on system settings, without the usual surrounding top/bottom/sidebars. There's also a sidebar which shows a depiction of the json-serialized hazel AST.
  5. Duplicate the tab and put both tabs in windows side-by-side, or send the URL to someone else.
  6. This hazel instance is loaded from the patchwork branch on the hazle dev server. If you want to develop locally, replace the URL in the sidebar with the relevant local path e.g. http://localhost:8000.

Other features:

  • Zen mode (Cmd-k)

TODO:

  • Figure out a nice way to display other players' caret positions.

Current limitations/bugs include but are not limited to:

  • Projectors/livelits are not supported; their placements will not be synced, and their interactions will not update the other player's syntax.
  • The entire syntax state is currently de/serialized and sent, in a flattened tree representation. This could instead be diff-based, and those diffs could be calculated performantly per action (cost: moderate engineering effort)
  • Caret position will be disrupted under certain circumstances when one of the carets becomes the end of the focal segment due to actions of another
  • If the subterm containing the caret is deleted, the caret will be placed on an ancestor, but this is currently quite imprecise.

@codecov
Copy link

codecov bot commented Sep 16, 2025

Codecov Report

❌ Patch coverage is 0% with 227 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.97%. Comparing base (1af78a0) to head (f711d23).

Files with missing lines Patch % Lines
src/haz3lcore/Iframe.re 0.00% 125 Missing ⚠️
src/haz3lcore/zipper/action/SyncReplace.re 0.00% 63 Missing ⚠️
src/haz3lcore/zipper/AutoSeg.re 0.00% 25 Missing ⚠️
src/haz3lcore/zipper/action/Action.re 0.00% 5 Missing ⚠️
src/web/Settings.re 0.00% 3 Missing ⚠️
src/haz3lcore/zipper/action/Perform.re 0.00% 2 Missing ⚠️
src/web/app/editors/code/CodeEditable.re 0.00% 2 Missing ⚠️
src/haz3lcore/Editor.re 0.00% 1 Missing ⚠️
src/web/app/editors/code/CodeSelectable.re 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1959      +/-   ##
==========================================
- Coverage   51.66%   50.97%   -0.69%     
==========================================
  Files         209      212       +3     
  Lines       21677    21903     +226     
==========================================
- Hits        11200    11166      -34     
- Misses      10477    10737     +260     
Files with missing lines Coverage Δ
src/haz3lcore/Editor.re 4.16% <0.00%> (-0.09%) ⬇️
src/web/app/editors/code/CodeSelectable.re 0.00% <0.00%> (ø)
src/haz3lcore/zipper/action/Perform.re 29.03% <0.00%> (-0.97%) ⬇️
src/web/app/editors/code/CodeEditable.re 0.00% <0.00%> (ø)
src/web/Settings.re 0.00% <0.00%> (ø)
src/haz3lcore/zipper/action/Action.re 0.00% <0.00%> (ø)
src/haz3lcore/zipper/AutoSeg.re 0.00% <0.00%> (ø)
src/haz3lcore/zipper/action/SyncReplace.re 0.00% <0.00%> (ø)
src/haz3lcore/Iframe.re 0.00% <0.00%> (ø)

... and 15 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants