Repository navigation
Protect ai-chat nodes from Backspace deletion/merge (closes #1697) - #1731
Conversation
Backspace at the start of an ai-chat node deleted or merged it away like a plain text node, silently discarding the conversation stored in properties.messages (separate from .content). Adds a deletableViaBackspace plugin flag (default true, mirroring acceptsContentMerge). base-node-viewer's handleDeleteNode and handleCombineWithPrevious now check it against the current/event node's own type and no-op when false. ai-chat sets deletableViaBackspace: false, and acceptsContentMerge: false so a node below it can't merge into its .content. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
APPROVE Independent adversarial review returned CONFIRMED-GOOD across all 6 scrutiny points: the two guarded handlers are the only Backspace-at-start delete/merge paths ( |
Summary
Fixes a data-loss bug: pressing Backspace at the start of an ai-chat node deleted or merged it away exactly like a plain text node, silently discarding the entire conversation. An ai-chat's messages live in
properties.messages(ADR-028), separate from.content, socombineNodes()— which only concatenates.contentstrings and deletes the current node — destroyed the whole conversation with no protection or confirmation.The existing
acceptsContentMergeflag only guards the previous (target) node from receiving a merge; nothing guarded a node from being deleted/merged away as the current node.Change
Adds a new plugin flag
deletableViaBackspace, mirroringacceptsContentMergeexactly:types.ts— optionaldeletableViaBackspace?: booleanonPluginDefinition, defaulttrue(existing types unaffected).plugin-registry.ts—deletableViaBackspace(nodeType)returningtruefor unknown/disabled/unspecified,falseonly when a registered+enabled plugin opts out.core-plugins.ts—deletableViaBackspace: falseon the ai-chat plugin. Also setsacceptsContentMerge: false(like code-block/quote-block) so a node below an ai-chat can't Backspace-merge its text into ai-chat's.contentand consume itself — the symmetric guard surfaced in review.base-node-viewer.svelte— bothhandleCombineWithPreviousandhandleDeleteNodenow check the flag against the current/event node's own type (nodeManager.nodes.get(eventNodeId).nodeType) right after the existence check, and no-op when it'sfalse. (Previously the only type check was against the previous node.)Acceptance criteria
acceptsContentMerge(JSDoc in-code + nodespace-docs PR Phase 1.1: Enhanced ContentProcessor with Dual-Representation #70)bun run testpassesVerification
acceptsContentMergeregistry block:plugin-registry.test.ts(+5 — false/true/default/unknown/disabled) andcore-plugins.test.ts(+1 asserting the real ai-chat plugin sets the flag). All green.svelte-check: 0 errors / 1769 files.nodespace-docsPR Phase 1.1: Enhanced ContentProcessor with Dual-Representation #70 adds the flag tocreating-node-types.mdalongsideacceptsContentMerge.MergeNodesCommand→deleteNode/combineWithPrevious, no Cmd+Backspace or select-all bypass);nodeTypeis the correct field on theMap<string, Node>; default-true preserves all other types; and ai-chat reaches these handlers via node-row's fallbackBaseNodebranch (it has a viewer but no inline node component). The companionacceptsContentMerge: falsewas added per the review's secondary finding.Closes #1697.