Repository navigation
Description
Overview
Pressing Backspace at the start of an ai-chat node (empty or non-empty) deletes or merges it away exactly like a plain text node, silently discarding the entire conversation (stored in properties.messages, separate from .content) with no protection or confirmation.
Problem Statement
Backspace-at-start handling lives in packages/desktop-app/src/lib/design/components/base-node-viewer.svelte:
handleDeleteNode(lines 862-900) — deletes the current node when emptyhandleCombineWithPrevious(lines 810-860) — merges the current node's content into the previous node
Both ultimately call nodeManager.combineNodes() (packages/desktop-app/src/lib/services/reactive-node-service.svelte.ts:566), which concatenates .content strings and deletes the current node. Neither function has any awareness of the current/event node's own type — the only existing type check is against the previous node, via pluginRegistry.acceptsContentMerge(previousNode.nodeType) (checked at lines 838 and 888), which guards structured node types (code-block, quote-block, horizontal-line, table — set in packages/desktop-app/src/lib/plugins/core-plugins.ts lines 329/372/451/491) from accepting a Backspace-merge from the node above. This is the documented mechanism per creating-node-types.md: "acceptsContentMerge — set to false for structured nodes... that must not accept a Backspace-merge from the node above." No equivalent flag exists for protecting a node from being deleted/merged away as the current node.
Ai-chat has no acceptsContentMerge entry (defaults to true per plugin-registry.ts:513) and no other guard, so it is deleted the same way a text node is — losing the full conversation.
No prior ADR or architecture doc documents a "protect this node type from self-deletion via Backspace" policy; creating-node-types.md and keyboard-and-navigation.md only document the existing merge-into-previous protection. This is new ground, not a reversal of any existing decision.
Proposed Solution
Add a new plugin-level flag, deletableViaBackspace, mirroring the existing acceptsContentMerge pattern:
- Default
true(matchesacceptsContentMerge's default-true convention, so existing node types are unaffected without an explicit opt-out) - Set
falseon the ai-chat plugin definition (packages/desktop-app/src/lib/plugins/core-plugins.ts, ai-chat plugin, ~lines 612-636) handleDeleteNodeandhandleCombineWithPrevious(base-node-viewer.svelte) must check this flag against the current/event node's own type (not just the previous node's type, which is all that's checked today) before proceeding with deletion or combination, and no-op (or otherwise safely decline) when the flag isfalse
Acceptance Criteria
- Pressing Backspace at the start of an empty ai-chat node does not delete it
- Pressing Backspace at the start of a non-empty ai-chat node does not merge/delete it
- Other node types' existing Backspace-delete/merge behavior is unaffected (regression check via existing tests)
- New
deletableViaBackspaceplugin flag is documented consistently with the existingacceptsContentMergeflag (mirror its usage pattern) - Tests pass (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
Reference Files
- base-node-viewer.svelte:
packages/desktop-app/src/lib/design/components/base-node-viewer.svelte—handleDeleteNode(862-900),handleCombineWithPrevious(810-860), existingacceptsContentMergechecks (838, 888) - reactive-node-service.svelte.ts:
packages/desktop-app/src/lib/services/reactive-node-service.svelte.ts:566—combineNodes(), the eventual deletion/merge call - core-plugins.ts:
packages/desktop-app/src/lib/plugins/core-plugins.ts— ai-chat plugin definition (~lines 612-636) to add the new flag to; existingacceptsContentMerge: falseexamples at lines 329, 372, 451, 491 (code-block, quote-block, horizontal-line, table) as the pattern to follow - plugin-registry.ts:
packages/desktop-app/src/lib/plugins/plugin-registry.ts:513— default-truefallback pattern foracceptsContentMerge, to mirror fordeletableViaBackspace
Testing Requirements
Add coverage in base-node-viewer tests (or equivalent) asserting that Backspace on an ai-chat node (both empty and non-empty) is a no-op with respect to node deletion/merging, alongside existing coverage for acceptsContentMerge-protected types.
Related Issues
- Optimistic updateNode merge doesn't flatten properties.* into top-level fields, causing ai-chat UI to lag behind RPC round-trip #1695 (unrelated — different ai-chat bug, optimistic-update reactivity)
- Exclude ai-chat nodes from embedding/vectorization #1696 (unrelated — ai-chat embedding exclusion)
Activity
mstomar125 commentedon Jul 24, 2026
✅ Completed — merged in PR #1731
Backspace at the start of an ai-chat node can no longer delete or merge the node away, so the conversation in
properties.messagesis safe.Fix: a new plugin flag
deletableViaBackspace(defaulttrue, mirroringacceptsContentMerge):types.ts— optional field onPluginDefinitionplugin-registry.ts—deletableViaBackspace(nodeType)(true for unknown/disabled/unspecified)base-node-viewer.svelte— bothhandleDeleteNodeandhandleCombineWithPreviousnow check the flag against the current/event node's own type and no-op whenfalse(previously only the previous node's type was checked)core-plugins.ts— ai-chat setsdeletableViaBackspace: false, plusacceptsContentMerge: falseso a node below it can't Backspace-merge its text into ai-chat's.contentand consume itself (the symmetric guard, like code-block/quote-block)Acceptance criteria — all met
acceptsContentMerge— in-code JSDoc + nodespace-docs PR Phase 1.1: Enhanced ContentProcessor with Dual-Representation #70 (creating-node-types.md)bun run testpassesVerification
acceptsContentMergeblock:plugin-registry.test.ts(+5: false/true/default/unknown/disabled) andcore-plugins.test.ts(+1 asserting the real ai-chat plugin). All green.svelte-check: 0 errors / 1769 files.nodeTypefield, safe no-op (preventDefault already fired), and that ai-chat reaches these handlers via node-row's fallbackBaseNodebranch.