Skip to content

feat: sync layouts, drawings, accounts and the CID across computers - #61

Merged
cyenite merged 2 commits into
mainfrom
feat/content-sync
Nov 6, 2026
Merged

cyenite merged 2 commits into
mainfrom
feat/content-sync

Conversation

@cyenite

@cyenite cyenite commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Phases 3 and 4 of Sync Across Computers. Version 1.0.0 shipped the encrypted connection but synced nothing; this makes your content, saved accounts and (by choice) passwords and the CID follow you between computers.

Phase 3: content (df332f1)

  • Every renderer store syncs: layouts and their charts, chart, layout and symbol drawings (drawing order kept), chart profiles and templates, drawing templates and looks, imported themes, watchlists, favourite indicators, timeframes and drawing tools, custom colours, price alerts, Pine scripts, and the theme, replay, Trade Assistant, Risk Ticket and risk settings.
  • Panels, docks, which layout/chart/watchlist is in front, and one-click consent stay per computer.
  • Renderer adapters (src/lib/sync-sources.ts, src/lib/sync-model.ts) are served over IPC to main-side proxies (electron/sync-renderer.ts). The renderer never receives keys, tokens or secret records.
  • A computer joining existing synced content chooses Merge or Use synced data.

Phase 4: accounts, secrets, CID, login handoff (7b9a788)

  • Saved account profiles always sync. Passwords, API keys and webhook secrets sync only on computers that opt in and have a system keychain; the most recently saved password wins.
  • Use one CID on all my computers syncs the CID, asking which to keep when they differ; a change applies from the next login.
  • Webhook sources and notification targets sync; whether each source is on, and the listener, stay per computer.
  • Computers list the accounts they hold in the encrypted manifest. An MT5 login to an account open elsewhere asks Move it here / Log in anyway / Cancel; Move has the other computer log out first.

Security review of Phases 1-3

An independent read-only review ran before secrets were wired in. It found no path for keys or secrets to reach the renderer, and seven data-loss or wedging issues, all fixed in 7b9a788:

  • merged values are validated before apply (a merge past a limit no longer fails every sync);
  • a record skipped as unreadable is never overwritten by local data;
  • __proto__ refused as ids and keys;
  • malformed renderer replies and non-JSON snapshots are rejected;
  • the join question survives a restart, and a first merge keeps the synced settings;
  • closing the window on macOS no longer stops sync;
  • a loading window shows as waiting rather than Synced.

Deliberate departures from the design

  • Presence lasts 30 minutes (renewed at 15), not 5: each renewal is a commit carrying a full manifest, and 5 minutes would add tens of MB of history a day per computer. Logout and quit clear it at once.
  • Only the account in use moves on handoff; copier and signal sessions wait for Phase 5 leases.

Testing

  • npm run check passes: typecheck, 842 tests, production build.
  • New tests cover two engines converging over the real workspace model, passwords only reaching opted-in computers, CID adoption, the join question across a restart, presence and move requests, and each review fix.
  • Not run in the live app: launching it signs in to saved broker accounts.

Phase 3 of sync: every renderer store now syncs through the encrypted
engine. Layouts and their charts, chart, layout and symbol drawings,
profiles, chart and drawing templates, drawing looks, imported themes,
watchlists, favourite indicators, timeframes and drawing tools, custom
colours, price alerts, Pine scripts, and the theme, replay, Trade
Assistant, Risk Ticket and risk settings. Panels, docks, the layout,
chart and watchlist in front, and one-click consent stay per computer.

- Renderer adapters (src/lib/sync-sources.ts) over a pure workspace
  model (src/lib/sync-model.ts), served over IPC to main-side proxies
  (electron/sync-renderer.ts). Validation runs in the renderer; source
  validation may be async and gets the record id.
- New kinds layoutCharts and layoutDrawings; ordered maps carry an
  order item so drawing z-order and watchlist order survive merges.
- A computer joining existing synced content chooses Merge or Use
  synced data instead of pushing its default layout everywhere.
- Closing the window pushes unsynced edits first, while the stores
  can still be read.
…computers

Phase 4 of sync, after a security review of Phases 1-3.

Accounts and secrets:
- Saved account profiles always sync. Passwords, API keys and webhook
  secrets sync only on computers that opt in and have a system keychain;
  the most recently saved password wins (secretSavedAt), and a secret
  that no longer decrypts is skipped, never read as deleted.
- "Use one CID on all my computers" syncs the CID; turning it on asks
  which CID to keep when the synced one differs.
- Webhook sources and notification targets sync; whether each source is
  switched on and the listener settings stay per computer.

Presence and login handoff:
- Computers list the accounts they hold in the encrypted manifest
  (30-minute presence, renewed at 15, cleared on logout and quit).
- An MT5 login to an account open elsewhere asks Move it here / Log in
  anyway / Cancel. Move writes a request the other computer honours
  only if its session predates it, so an asleep computer logs out on
  waking but a later deliberate login is never ended.

Review fixes:
- Merged values are validated before apply; a failing merge keeps the
  remote value instead of failing every sync.
- The unchanged-head shortcut re-pulls while any record lacks a base, so
  a skipped record is never overwritten by local data.
- __proto__ refused as ids and keys; own-property lookups in merges.
- Malformed renderer replies reject; snapshots must be plain JSON;
  secret kinds can never be served by the renderer.
- The join question survives a restart, and a first merge prefers the
  synced value so a fresh install's defaults never replace settings.
- Closing the window on macOS no longer stops sync; a loading window
  shows as waiting instead of Synced.
@cyenite
cyenite merged commit 3bc6dec into main Nov 6, 2026
4 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.

1 participant