Skip to content

Conversation

@OceanOak
Copy link
Collaborator

@OceanOak OceanOak commented Nov 18, 2025

This PR adds a background sync service that automatically synchronises package ops between Darklang instances. The sync service auto-starts when you launch either the CLI or the VS Code extension.

  • It syncs all branches, not just the current one
  • Batches Ops by (branchID, instanceID) to track origin and prevent duplicates
  • Adds a CLI config system for sync settings

Test:

  • Start CLI or open VS Code extension, verify sync service auto-starts (check sync-service.log)
  • Push check : make changes in local instance, verify they appear on instance2 (check if http://dark-packages.dlio.localhost:11003/stats matches http://dark-packages.dlio.localhost:11001/stats)
  • Pull check: make changes on instance2 (run DARK_CONFIG_DB_NAME=data-instance2.db ./scripts/run-cli val Stachu.Test.syncTestValue "\"Created in instance2\"", verify they appear on local instance (by checking logs or stats)
  • Stop CLI or close VS Code, verify sync service stops gracefully

@OceanOak OceanOak force-pushed the remove-manual-sync branch 7 times, most recently from 07ecd6d to 95e44a3 Compare November 24, 2025 17:11
@OceanOak OceanOak changed the title WIP: Remove manual sync Implement background service to auto-sync package operations between instances Nov 24, 2025
@OceanOak OceanOak marked this pull request as ready for review November 25, 2025 09:35
Copy link
Member

@StachuDotNet StachuDotNet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, this is great. Just one notable gripe: as of this PR, the extension is the thing that's managing the sync service - and the sync service has bled a bit into the language server itself.

Rather,

  • (long-term) the sync service should be managed by some broader 'dev server' that happens to serve the language server, mcp server(s), and sync. So as part of a CLI install, someone should be able to type dark dev-server start
  • for now, let's just have a tiny separate CLI app that just does sync - takes a 'start' or 'stop' command/arg. Then, we can remove the LSP way of doing things, and have the extension call upon the separate CLI app rather than do things via a LSP-centric handshake
  • I'm not sure what to do about the config file -- if syncing is 'separate' where would those things live? I'm open to any options, incl. push-back against it being a 'separate app' but would be happy to think through other options.
  • the 'main' CLI can call upon the 'separate' syncing CLI app, or something?
  • certainly, the main CLI app shouldn't have a sync-service-loop thing exposed in the commands (in core.dark)

We're in a sort of in-between awkward stage, and will end up iterating here a few times over the next weeks and beyond, so any progress in these directions is fine / good enough.

Tangentially - do we still need vscode-extension/client/src/commands/instanceCommands.ts? (Seems empty)

@OceanOak OceanOak marked this pull request as draft December 1, 2025 20:02
@OceanOak OceanOak force-pushed the remove-manual-sync branch 2 times, most recently from 4cad828 to 9090a1f Compare December 3, 2025 10:49
@OceanOak OceanOak force-pushed the remove-manual-sync branch 3 times, most recently from 7d9375e to b497ea0 Compare December 3, 2025 14:26
@OceanOak OceanOak marked this pull request as ready for review December 3, 2025 18:13
@OceanOak OceanOak requested a review from StachuDotNet December 3, 2025 18:14
@StachuDotNet StachuDotNet merged commit 9fbfc3a into darklang:main Dec 4, 2025
9 checks passed
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