Skip to content

feat: add copy/paste layer support - #2992

Merged
ert78gb merged 4 commits into
masterfrom
feat-copy-paste-layer
Jul 11, 2026
Merged

feat: add copy/paste layer support#2992
ert78gb merged 4 commits into
masterfrom
feat-copy-paste-layer

Conversation

@ert78gb

@ert78gb ert78gb commented Jul 10, 2026

Copy link
Copy Markdown
Member

Implements copy/paste of layers, as requested in #2692.

  • Adds Copy and Paste buttons to the layer header (to the right of the layer button group, left of the help ? icon). The Paste button appears once a layer has been copied.
  • Copy stores the current layer in an in-memory "virtual clipboard" (NgRx store), so it can be pasted onto any layer — including in another keymap or on another device.
  • Paste overwrites the currently selected layer with the copied layer.

Cross-context safety

Paste is guarded so it can never produce an invalid configuration:

  • Macros are re-linked by name (macro names are unique). If the target config has no macro with that name, the key becomes a NoneAction (color preserved).
  • Switch-keymap references are kept only if the referenced keymap abbreviation still exists; otherwise the key becomes a NoneAction (color preserved). This avoids serializing a -1 keymap index.
  • Switch-layer switch layer actions only copy to base layer and overwrite the corresponding key on the destination layer. Same behaviour as UI.
  • Structural merge: modules are matched by id, so a layer copied from a different keyboard/layout (e.g. UHK60 ↔ UHK80, ANSI ↔ ISO) can never desync the target's module structure. Modules without a compatible counterpart keep their existing content.

SwitchLayerAction, keystroke secondary roles, and ConnectionsAction host-connection references are left untouched — they serialize to fixed/valid values and at worst become semantically "dead" keys until the relevant layer/connection exists (no corruption).

Notes

  • Partial pastes (some incompatible modules skipped) are intentionally silent.
  • No undo for paste yet; a general undo/redo is planned separately and would cover this for free.
  • Also fixing the default them handling of the web build

Test plan

  • Copy a layer, verify the Paste button appears.
  • Paste onto a different layer in the same keymap; verify key actions, colors, and macro/switch-keymap keys are correct.
  • Paste into a different keymap; verify macro keys re-link by name and switch-keymap keys survive/clear correctly.
  • Copy on one device, paste on another (different layout); verify no structural corruption and config saves/loads cleanly.
  • Verify buttons don't appear on the add-keymap preview screen.

mondalaci and others added 2 commits July 9, 2026 15:38
Adds copy and paste buttons to the layer header so a layer can be copied
to a virtual clipboard and pasted onto any layer, overwriting it (closes #2692).

Paste is safe across keymaps and devices:
- macro references are re-linked by name, falling back to a none action
- dangling switch-keymap references fall back to a none action
- modules are merged by id and key count so a layer copied from a different
  keyboard or layout can never desync the target's structure

Co-authored-by: Cursor <cursoragent@cursor.com>
@ert78gb
ert78gb requested a review from mondalaci July 10, 2026 18:41
@ert78gb
ert78gb marked this pull request as ready for review July 10, 2026 18:42
@ert78gb ert78gb mentioned this pull request Jul 10, 2026
5 tasks
@ert78gb
ert78gb merged commit bea7175 into master Jul 11, 2026
6 checks passed
@ert78gb
ert78gb deleted the feat-copy-paste-layer branch July 11, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants