Skip to content

feat(overleaf): add manual bidirectional sync - #121

Closed
YishayPo wants to merge 7 commits into
ScientFactory:mainfrom
YishayPo:agent/overleaf-manual-sync
Closed

YishayPo wants to merge 7 commits into
ScientFactory:mainfrom
YishayPo:agent/overleaf-manual-sync

Conversation

@YishayPo

@YishayPo YishayPo commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • Adds manual bidirectional Overleaf synchronization through a private Git mirror under the server state directory.
  • Supports workspace-root or subdirectory mappings, saved host-scoped accounts, connection preflight, safe initial reconciliation, push-before-project sync, outbound deletion/revert review, whole-file conflict resolution, local reconciliation, repair, and disconnect.
  • Adds an isolated direct Git executor with clean environment construction, operation-scoped askpass credentials, bounded output/timeouts, and process-tree cleanup.
  • Discovers the project's advertised main or legacy master branch instead of assuming one fixed branch.
  • Adds typed HTTP/client contracts, Project Settings and LaTeX toolbar surfaces, user/internal documentation, focused tests, and a guarded five-mount upstream seam manifest.
  • Adds a streamlined project-level onboarding entry beside Sources/Zotero: connect an account once, open the signed-in Overleaf project list, explicitly paste the chosen project link, choose a project folder or workspace root, and connect with automatic Safe Combine when no review is required.
  • Keeps account host, commit policy, and replacement modes under Advanced while showing account/project failures persistently inside the relevant dialog.

Why

Using the workspace repository would couple Overleaf synchronization to inherited checkpoint Git indexes, while a nested repository would make checkpoint capture treat the paper as a gitlink. A private mirror keeps Git state app-owned, preserves checkpoint coverage of ordinary workspace files, and minimizes inherited T3 mount conflicts.

Synchronization is manual-only and pushes before workspace projection so remote races do not mutate local files and confirmed pushes can recover projection offline.

Overleaf does not expose a supported account project-list API. The onboarding therefore opens the normal signed-in Overleaf dashboard and reads the clipboard only after an explicit Paste action; it does not scrape private endpoints or introduce another browser login.

Impact

  • No automatic polling, save/open hooks, or background Overleaf network activity.
  • No .git directory is placed in the workspace.
  • Git author and committer metadata comes only from the configured human Overleaf identity.
  • Deletions and historical reverts require candidate-bound confirmation; conflicts remain in the mirror until resolved.
  • Tokens remain write-only through the API and use the existing private-file secret store.
  • Routine warning-free setup is a single Connect action after the project and destination are chosen.

Validation

  • Focused Overleaf onboarding/validation tests: 6 passed.
  • Web typecheck and scoped lint/format passed.
  • Production web build passed (7,209 modules).
  • Overleaf seam verifier passed: 5/8 inherited mounts and 2 declared cross-Scient mounts.
  • git diff --check passed.
  • GitHub CI is green across Check, Documentation, provenance, Web, Workspace, all Server shards, mobile static analysis, and release smoke.
  • Windows x64 NSIS packaging completed and validated an 89-file payload with 38 sidecar natives.
  • A real authenticated read-only Cloud Git Bridge probe succeeded and confirmed an advertised main branch.

Draft acceptance gates

  • Run the disposable Cloud and Server Pro Git Bridge commit/tree-identity spike with real disposable projects.
  • Exercise packaged Desktop askpass/process-tree behavior through a full connect and Sync against a disposable project.
  • Capture required before/after UI evidence after explicit approval for browser/computer interaction.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XXL labels Aug 17, 2026
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. and removed vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Aug 21, 2026
yaacovcorcos added a commit to nattikahana/scient-desktop that referenced this pull request Oct 9, 2026
Runs the system Git for the Overleaf connection with an environment built
from scratch, a fixed neutral commit identity, standard input, an output
limit, a time limit, and a process-group kill on interruption. The token
reaches Git only through a per-command askpass file.

Git 2.39 is the minimum: merge-tree reports conflicts as structured
records from that version. A missing or older Git is reported when the
feature is used; it never fails server startup.

The environment and askpass helpers are carried over from PR ScientFactory#121.

Co-authored-by: Yishay Polatov <polyishay@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
yaacovcorcos added a commit to nattikahana/scient-desktop that referenced this pull request Oct 9, 2026
The private repository behind a connection is bare. Trees are built
from captured bytes through a private index, merged with an explicit
base using `git merge-tree`, compared with rename detection, and
published without force. Nothing is ever checked out.

- Conflicts are returned as Git's structured records, so one conflict
  can span several paths. A failed merge without a record is refused.
- Every tree is validated before Git sees it and re-read after it is
  written: Git's index plumbing can drop an entry silently when a path
  is both a file and a folder.
- Trees containing links, submodules, reserved or unsafe paths are
  rejected, whichever side they come from.
- A publish has three outcomes. Only an explicit out-of-date rejection
  is definite; a timeout or a broken connection is "unknown".

The path rules and branch discovery are carried over from PR ScientFactory#121.

Co-authored-by: Yishay Polatov <polyishay@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@yaacovcorcos

Copy link
Copy Markdown
Contributor

Closing at the owner's request. Thank you for this original implementation. Overleaf sync is being rebuilt in planned steps on its work: the engine and applier (#486), the macOS helper and probe (#495) and coordinator step 1 (#536) have merged, and step 2 is #556. The plans are in #535.

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

Labels

size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants