Skip to content

Add suggestChanges: turn pushed edits into tracked changes - #66

Merged
aloth merged 2 commits into
aloth:mainfrom
fredericosantos:feat/suggest-changes
Nov 16, 2026
Merged

aloth merged 2 commits into
aloth:mainfrom
fredericosantos:feat/suggest-changes

Conversation

@fredericosantos

Copy link
Copy Markdown
Contributor

This is for edits that reach Overleaf as plain text, through git push, olcli push or a sync, from someone who would have liked them to be suggestions. Today the only way to get a tracked change is typing in the editor in Reviewing mode.

Change

suggestChanges(projectId, path, edits) takes edits as old text, new text and some text around them. For each one it finds the new text in the doc (the match nearest to a position hint), undoes the edit without tracking, and redoes it as a tracked change by setting meta.tc on the update, as the editor does in Reviewing mode. The text ends up exactly as it was, so a git clone that pushed the edit has nothing new to pull. An edit whose new text isn't on Overleaf yet comes back as not-pushed and is left alone; one that matches neither text comes back as not-found.

It's sharejs-text-ot only. history-ot docs are refused with an error.

Tests

npm test goes from 240 to 242. The tests stub the socket (no network): a pushed edit sends the untracked undo and then the tracked redo, with a 18-hex-digit tc and consecutive versions; an unpushed edit and a missing one send nothing; history-ot is refused and the socket is closed. Lint is unchanged. CHANGELOG entry included.

Live, on a scratch project: replacements, pure inserts and pure deletes (including non-ASCII text) show up in the editor as suggestions with my name, grouped as "Changed" like ones typed in the browser, and git pull afterwards is a fast-forward with no content change.

What I haven't verified

  • The meta.tc format (18 hex digits, ids are the seed plus a counter) is what I observed in the editor's updates; I haven't found it documented anywhere.
  • For a moment between the two updates a collaborator sees the old text. I haven't tried to make the two steps atomic.
  • history-ot docs. I don't know how tracking is requested there.

CONTRIBUTING says to discuss bigger changes first, and this is a new feature. Happy to open an issue and move the discussion there if you'd rather.

Undo each edit without tracking, redo it with meta.tc. The text is
unchanged, so a clone that pushed it has nothing to pull.
@aloth

aloth commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Thanks, this is an interesting one. Turning pushed edits into suggestions would help anyone who writes locally and reviews with co-authors on Overleaf.

Since it writes to documents others are editing and relies on an undocumented format, I'd like to discuss the design in an issue first. Could you open one? Points to settle there:

  1. The meta.tc format (18 hex digits, seed plus counter): what we know and how we notice if Overleaf changes it.
  2. The short window between the untracked undo and the tracked redo, when collaborators see the old text. Acceptable, or can both updates go out together?
  3. history-ot docs: keep refusing, or find out how the editor requests tracking there.
  4. Whether to mark it experimental at first, and whether it should get a CLI command or MCP tool later.

I'll also run some tests of my own over the next few days, with a second account watching the document. I'll leave this PR open until then.

@fredericosantos

fredericosantos commented Nov 16, 2026 via email

Copy link
Copy Markdown
Contributor Author

@aloth

aloth commented Nov 16, 2026

Copy link
Copy Markdown
Owner

No need to apologize, your PRs were small, tested and easy to review. I'm really glad you sent this one, and I'm looking into it more closely now. I'll post what I find here.

If you're short on time, there's no need to open a separate issue. We can keep the discussion in this PR.

Good luck with the VS Code extension, happy to hear how it goes.

@aloth

aloth commented Nov 16, 2026

Copy link
Copy Markdown
Owner

I've tested this against overleaf.com with two accounts on a sharejs-text-ot project: one ran suggestChanges, the other had the doc open in the browser. In the collaborator's review panel each replacement shows up as a single "Changed: X to Y" entry with the author's name, like a suggestion typed in the editor, and accepting and rejecting it in the browser works. Overleaf's source confirms the meta.tc format.

A few things came up:

  1. Running the same edit twice tracks it twice (the delete becomes "gammagamma").
  2. A pure delete with empty before and after never returns, because the search needle is empty.
  3. Collaborators see the old text for about 230 ms between undo and redo. Text typed in that window is kept and the suggestion stays intact.
  4. With review-only access the call fails safely, but with an unclear error.
  5. Overleaf's seed starts with a timestamp; the PR uses fully random hex.

I'll merge this and take care of these in a follow-up, so there's nothing more you need to do here. It will ship in 0.18.0. Thanks again for the idea and the careful PR.

@aloth
aloth merged commit 15f9004 into aloth:main Nov 16, 2026
2 checks passed
aloth added a commit that referenced this pull request Nov 16, 2026
Set version 0.18.0 in package.json, package-lock.json, CITATION.cff and server.json, and fold the Unreleased CHANGELOG entries of #66, #70 and #71 and the CONTRIBUTING.md change into the 0.18.0 section dated 2026-11-16.
@aloth

aloth commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Shipped in 0.18.0, together with the follow-up fixes from #70.

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.

2 participants