Skip to content

perf(clipboard): make history writes async#511

Closed
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-clipboard-async-writes
Closed

perf(clipboard): make history writes async#511
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-clipboard-async-writes

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

Summary

  • Replace synchronous full-history clipboard JSON writes with a debounced async queue.
  • Persist via same-format pretty JSON using temp-file + rename atomic replacement.
  • Keep in-memory clipboard history updates immediate, while clear/delete/stop/quit/update restart flush pending writes.
  • Add focused regression coverage for coalesced writes and flush wiring.

Before / After Evidence

  • Baseline before implementation: node --test scripts/test-clipboard-history-persistence.mjs reported [clipboard-baseline] rapidAdditions=100 syncWrites=100 serializeMs=3.23 writeMs=25.38 blockingMs=28.61 finalBytes=17372 sourceSaveCalls=10 historyWriteFileSyncSites=1.
  • After implementation: focused regression reports [clipboard-after] rapidAdditions=100 coalescedWrites=1 serializeMs=0.05 writeMs=0.33 blockingMs=0.38 finalBytes=17372.

Validation

  • node --test scripts/test-clipboard-history-persistence.mjs
  • node --test 'scripts/test-*.mjs'\n- ./node_modules/.bin/tsc -p tsconfig.main.json --noEmit\n- node /opt/homebrew/lib/node_modules/npm/bin/npm-cli.js run build:main\n- Codex LSP diagnostics on src/main: 0 errors\n- node scripts/check-i18n.mjs exited 0; existing Italian locale gaps remain (settings.ai.whisper.vocabulary, settings.extensions.appSearchScope)\n\n## Risks\n- If an async save fails, the queue logs the error and leaves history dirty for a later retry, matching the old non-throwing behavior while avoiding main-process sync I/O.\n- Normal app quit may briefly defer while a pending clipboard write drains; updater restart flushes before quitAndInstall.

@JustYannicc JustYannicc changed the title [codex] Make clipboard history writes async perf(clipboard): make history writes async Jul 3, 2026
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated upstream PR #534 (perf(mac): reduce native polling and async IO stalls), which carries this change together with the related macOS/native/audio/camera async IO performance fixes. Closing this source PR so review can continue on #534.

@JustYannicc JustYannicc closed this Jul 3, 2026
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