super-productivity/electron
johannesjo 00e71b407f refactor(electron): simplify sync folder ownership + stop renderer writes
Post-review of Phase 2 (#8228). The reviewer flagged one real bug and
several pieces of premature scaffolding.

Real bug — finding #1: the sync form was still writing the sync folder
path back into the renderer credential store. Phase 2 made the IPCs
take a relative path and main own the canonical root, but the Formly
button at sync-form.const.ts:200 had `key: 'syncFolderPath'`, which
caused FormlyBtn.onClick to setValue(picker-return-string) on the
form model. That flowed into privateCfg.syncFolderPath on save. The
"renderer no longer holds the authoritative copy" claim was true in
the IPC contract but untrue at runtime. A compromised renderer could
keep mutating its own privateCfg.syncFolderPath; nothing on master
reads it after Phase 2, but any future code path that does would
re-open the hole. Fix:
- drop `syncFolderPath` from PROVIDER_FIELD_DEFAULTS[LocalFile] so it
  is not in the LocalFile credential-store defaults at all
- drop `key: 'syncFolderPath'` from the LocalFile picker button so the
  picker's return value is not bound to the form model

KISS simplifications (a/b/d from review):
- delete electron/sync-folder-store.ts and its test; inline the
  load/cache/persist helpers at the top of local-file-sync.ts as
  ~25 LOC. The dedicated module was carrying an init/get/set ceremony
  and a Promise singleton for a single string that is read at most a
  few times per second in the worst case. simple-store is the durable
  layer either way.
- drop the `_resolveOrThrow` typeof precheck; resolveSyncPath already
  type-checks `relativePath` and throws the same opaque error
- inline `resolveSyncPath(...).absolutePath` into each handler; the
  helper was the third layer doing the same thing

Other findings addressed:
- finding #2 (PICK_DIRECTORY silently undefined on persist failure):
  PICK_DIRECTORY now returns a safe Error via createSafeIpcError when
  realpath/persist fails, distinct from `undefined` for user-cancel.
  New tests cover both branches plus the "cache must not be poisoned
  with a non-existent path" invariant.
- finding #4 (set-without-canonicalize): the inlined
  setSyncFolderPath now `realpathSync.native`s the picked path before
  persisting, so a relative or symlinked picker result is rejected
  early and the on-disk form matches what resolveSyncPath compares
  against on read.
- finding #5 (fire-and-forget init that was also being awaited per
  handler): dropped the fire-and-forget; handlers just `await
  getSyncFolderPath()`, which lazy-loads from disk on first call and
  caches.

All 52 electron security tests still pass; lint clean; tsc clean.
2026-06-09 23:15:53 +02:00
..
assets/icons fix: wrong icon for kde title bar 2025-07-22 20:42:28 +02:00
ipc-handlers fix(electron): validate URL scheme before shell.openExternal/openPath (GHSA-hr87-735w-hfq3) (#8210) 2026-06-09 17:29:18 +02:00
scripts refactor(electron): bundle preload script with esbuild to support sandbox mode 2026-03-22 19:38:21 +01:00
shared-with-frontend feat(electron): own sync folder main-side and take only relative paths 2026-06-09 22:40:50 +02:00
task-widget Feat/task widget global shortcut (#7099) 2026-06-09 16:11:16 +02:00
wayland-idle-helper Add ext-idle-notify backend for Wayland idle detection (#7337) 2026-04-24 16:50:24 +02:00
app-control.test.cjs fix(electron): respect tray title settings #7823 (#8097) 2026-06-08 12:07:09 +02:00
backup.ts fix(electron): restrict loadBackupData IPC to the backup directory (#8206) 2026-06-09 15:29:06 +02:00
clear-stale-idb-locks.ts Feat/to me it looks like there are lots of 60dd04 (#7280) 2026-04-20 12:04:38 +02:00
clipboard-image-handler.test.cjs fix(security): restrict renderer-supplied filesystem IPC paths (#8223) 2026-06-09 18:16:22 +02:00
clipboard-image-handler.ts fix(security): restrict renderer-supplied filesystem IPC paths (#8223) 2026-06-09 18:16:22 +02:00
common.const.ts chore: update electron to v41.x (#7097) 2026-04-17 18:12:43 +02:00
CONFIG.ts Increase ping interval and idle time in order to not waste CPU cycles. (#6227) 2026-01-28 15:37:50 +01:00
debug.ts refactor: rename overlay-indicator to task-widget 2026-03-30 22:00:47 +02:00
electronAPI.d.ts feat(electron): own sync folder main-side and take only relative paths 2026-06-09 22:40:50 +02:00
error-handler-with-frontend-inform.ts fix(error-handling): prevent [object Object] from appearing in error messages 2026-01-02 15:40:14 +01:00
file-path-guard.test.cjs fix(security): restrict renderer-supplied filesystem IPC paths (#8223) 2026-06-09 18:16:22 +02:00
file-path-guard.ts fix(security): restrict renderer-supplied filesystem IPC paths (#8223) 2026-06-09 18:16:22 +02:00
full-screen-blocker.ts fix(security): harden XSS sinks and add Origin check (#7413) 2026-05-06 21:37:06 +02:00
gpu-startup-guard.ts fix(electron): add GPU startup guard for confined Linux packages 2026-04-20 18:35:31 +02:00
idle-time-handler.ts fix(electron): retry Wayland idle helper startup (#7527) 2026-05-10 22:35:33 +02:00
indicator.test.cjs fix(electron): respect tray title settings #7823 (#8097) 2026-06-08 12:07:09 +02:00
indicator.ts fix(electron): respect tray title settings #7823 (#8097) 2026-06-08 12:07:09 +02:00
ipc-handler-wrapper.test.cjs fix(security): restrict renderer-supplied filesystem IPC paths (#8223) 2026-06-09 18:16:22 +02:00
ipc-handler-wrapper.ts fix(security): restrict renderer-supplied filesystem IPC paths (#8223) 2026-06-09 18:16:22 +02:00
ipc-handler.ts feat(electron): add Local REST API for desktop automation (#6981) 2026-03-28 13:35:04 +01:00
jira.ts fix(jira): honor no_proxy for electron requests #6324 (#8177) 2026-06-09 15:00:43 +02:00
local-file-sync.test.cjs refactor(electron): simplify sync folder ownership + stop renderer writes 2026-06-09 23:15:53 +02:00
local-file-sync.ts refactor(electron): simplify sync folder ownership + stop renderer writes 2026-06-09 23:15:53 +02:00
local-rest-api.ts fix(security): harden XSS sinks and add Origin check (#7413) 2026-05-06 21:37:06 +02:00
lockscreen.ts fix(electron): restore macOS lock screen by correcting osascript quoting 2026-04-16 19:47:52 +02:00
main-window.ts fix(electron): compare host exactly before in-window navigation 2026-06-09 19:32:09 +02:00
main.ts fix(electron): improve protocol URL handling and register URL scheme on Linux 2026-03-05 16:45:05 +01:00
plugin-node-executor.test.cjs fix(plugins): harden nodeExecution grants (#8205) 2026-06-09 18:16:41 +02:00
plugin-node-executor.ts fix(plugins): harden nodeExecution grants (#8205) 2026-06-09 18:16:41 +02:00
plugin-oauth.ts Improve OAuth error handling and reporting (#7445) 2026-05-01 18:45:11 +02:00
preload.ts feat(electron): own sync folder main-side and take only relative paths 2026-06-09 22:40:50 +02:00
protocol-handler.ts feat(sync): add OneDrive sync provider with PKCE auth (#7523) 2026-05-26 15:31:06 +02:00
proxy-agent.test.cjs fix(jira): honor no_proxy for electron requests #6324 (#8177) 2026-06-09 15:00:43 +02:00
proxy-agent.ts fix(jira): honor no_proxy for electron requests #6324 (#8177) 2026-06-09 15:00:43 +02:00
shared-state.ts fix: refactor tray handling to use shared state for task and countdown visibility 2025-11-28 18:53:00 +01:00
simple-store.test.cjs fix(electron): harden simple store writes (#7297) 2026-04-21 15:03:30 +02:00
simple-store.ts fix(electron): harden simple store writes (#7297) 2026-04-21 15:03:30 +02:00
start-app.ts fix(macOS): gracefully quit app (#7733) 2026-05-27 17:13:43 +02:00
sync-path-resolver.test.cjs feat(electron): add sync-path-resolver for renderer-supplied paths 2026-06-09 22:23:47 +02:00
sync-path-resolver.ts feat(electron): add sync-path-resolver for renderer-supplied paths 2026-06-09 22:23:47 +02:00
task-widget.test.cjs Feat/task widget global shortcut (#7099) 2026-06-09 16:11:16 +02:00
tsconfig.electron.json feat(sync): add OneDrive sync provider with PKCE auth (#7523) 2026-05-26 15:31:06 +02:00
various-shared.ts Feat/task widget global shortcut (#7099) 2026-06-09 16:11:16 +02:00