Repository navigation
feat: AI Chat node type with schema, behavior, plugin, and viewer - #1028
Conversation
Code Review: PR #1028 — AI Chat Node TypeOverall AssessmentThis PR delivers the foundational scaffolding for the Verdict: Request Changes — one critical bug blocks merge; two schema gaps should be fixed in-band. Critical Issues1. [Critical/Blocker] `sharedNodeStore.updateNode` called with wrong signatureFile: `ai-chat-node-viewer.svelte`, `flushToStore()` function The viewer calls: But `sharedNodeStore.updateNode` signature is: This passes `node.version` (a number) as the `changes` parameter and the actual properties object as `source`. The call will either silently produce incorrect state or throw at runtime. It also returns `void`, not `Promise`. Fix: Follow the established pattern from `reactive-node-service.svelte.ts`: Note: this is synchronous (returns `void`) — the store handles persistence asynchronously internally. Remove the `await` and adjust `flushToStore` to not be `async` (or keep async for future-proofing but remove the await). Suggested Improvements2. [Improvement] Schema missing `args` and `status` item_fields for messagesFile: `packages/core/src/models/core_schemas.rs` The viewer reads and writes `args` and `status` properties on tool_call messages (in `loadMessagesFromNode` and `archiveMessages`), and the issue spec explicitly includes both in its example schema JSON. However, the schema `item_fields` for messages only defines 7 fields: `role`, `content`, `timestamp`, `referenced_nodes`, `tool`, `result_summary`, `duration_ms`. Add:
This ensures schema-driven validation will not reject persisted tool_call messages. 3. [Improvement] `onDestroy` flush is fire-and-forget with async functionFile: `ai-chat-node-viewer.svelte`, `onDestroy` ```ts Since `flushToStore` is currently async (and should become sync after fixing issue #1 above), this is a concern. If the underlying sharedNodeStore call is synchronous (it is — it queues and returns), this becomes a non-issue after the fix. Just ensure the flush path is synchronous end-to-end so the onDestroy callback reliably persists before teardown. 4. [Improvement] `chatStore.sendMessage` coupling creates dual source of truthFile: `ai-chat-node-viewer.svelte`, `handleSend()` The viewer maintains its own `inMemoryMessages` state, but also delegates to `chatStore.sendMessage()` for streaming, then copies the response back: This creates a fragile coupling: `chatStore` manages its own message list (for the panel-based chat UI), and the viewer tries to pluck the last message from it. If `chatStore` adds multiple messages (tool calls + assistant response), only the last is captured. If another component sends a message concurrently, the wrong message could be captured. This is acceptable for the mock streaming phase but should be noted as technical debt. When #1008 (Tauri commands) lands, the viewer should either:
5. [Improvement] `archiveMessages` truncates `result_summary` to 200 chars silentlyFile: `ai-chat-node-viewer.svelte`, `archiveMessages()` ```ts If `te.result` is a string, it is passed through without truncation. If it is an object, it is truncated at 200 chars. This inconsistency could lead to unexpectedly large string results being persisted verbatim while smaller objects get truncated. Consider applying a consistent max length regardless of type. 6. [Improvement] Viewer priority is 10, all others are 1File: `core-plugins.ts`, `aiChatNodePlugin.viewer.priority` ```ts All other viewer priorities in `core-plugins.ts` are `1`. Unless there is a specific reason this viewer needs higher priority (e.g., to override another viewer for the same node type), this should be `1` for consistency. Nitpicks7. Nit: Unused `paneId` propFile: `ai-chat-node-viewer.svelte` `paneId` is declared in the props destructuring but never used in the component body. Consider removing it or adding a TODO if it will be needed for multi-pane routing. 8. Nit: Auto-scroll `$effect` always firesFile: `ai-chat-node-viewer.svelte` ```ts The condition `>= 0` is always true (arrays have non-negative length). The intent is dependency tracking on `inMemoryMessages.length`, but the condition reads as dead code. Simplify to: 9. Nit: Message ID generation could collide under high throughputFile: `ai-chat-node-viewer.svelte`, `handleSend()` ```ts This is the same pattern used in `chatStore` and is fine for a single-user desktop app. No change needed — just noting for future multi-device sync consideration. Scope Gaps (Not blocking, but documenting for tracking)The following acceptance criteria from #1017 are not addressed in this PR. If intentionally deferred, consider updating the issue to reflect partial completion:
These are significant features. If this PR is intended as a foundation-only PR, the issue should be updated or child issues created for the remaining criteria. What Works Well
Reviewed by Principal Engineer AI Reviewer |
malibio
left a comment
There was a problem hiding this comment.
Requesting changes due to critical bug: sharedNodeStore.updateNode() is called with the wrong argument signature in the viewer's flushToStore() function — node.version is passed as the changes parameter. See the detailed review comment for the full list of findings.
Re-Review: PR #1028 -- AI Chat Node TypeReviewer: Principal Engineer AI Reviewer Verdict: None of the previous findings have been addressedThe PR has not been updated since the initial review. The branch still contains a single commit ( Status of Previously Identified Issues1. [Critical/Blocker]
|
| Finding | Severity | Status |
|---|---|---|
flushToStore() wrong updateNode signature |
Critical/Blocker | Not addressed |
Missing args/status schema item_fields |
Improvement | Not addressed |
| Viewer priority 10 vs 1 | Improvement | Not addressed |
Unused paneId type declaration |
Nit | Not addressed |
| Always-true scroll condition | Nit | Not addressed |
Decision: The PR cannot be approved. The critical updateNode API misuse in flushToStore() will cause runtime failures. The schema gap (args/status) means persisted tool_call messages will have undeclared fields. Both must be fixed before merge.
To unblock: push fix commits addressing at minimum items 1 and 2, then request re-review.
Re-reviewed by Principal Engineer AI Reviewer
- Fixed critical: updateNode call signature (was passing version as changes) - Added args and status item_fields to ai-chat message schema - Changed viewer priority from 10 to 1 for consistency - Removed unused paneId prop Addresses reviewer recommendations from PR #1028 review. Co-Authored-By: Claude <[email protected]>
Re-Review: Fixes ConfirmedAll review findings have been addressed in commit 5a66502:
PR is ready to merge. |
…oses #1017) Implements ai-chat as a first-class knowledge graph node with messages stored as nested properties per ADR-028. Backend (Rust): - AiChatNodeBehavior: validates provider enum, status, messages array; get_embeddable_content extracts user+assistant text skipping tool_call; get_parent_contribution returns None - Core schema in core_schemas.rs with 7 top-level fields and 7 message item_fields (role, content, timestamp, referenced_nodes, tool, result_summary, duration_ms) - Registered in NodeBehaviorRegistry and exported from lib.rs - 13 behavior tests covering validation, embedding, capabilities Frontend (Svelte): - AiChatNodeViewer with write buffering (7s debounce), immediate flush on destroy, tool result archival (result nulled at write time), soft 500-message cap nudge, archived conversation read-only mode - aiChatNodePlugin registered with /ai-chat slash command, lazy-loaded viewer, and BaseNodeReference - Updated 3 test files for new plugin count (12->13 plugins, commands, references; 4->5 viewers) Also fixed pre-existing Cargo.toml merge conflict in src-tauri. Co-Authored-By: Claude <[email protected]>
- Fixed critical: updateNode call signature (was passing version as changes) - Added args and status item_fields to ai-chat message schema - Changed viewer priority from 10 to 1 for consistency - Removed unused paneId prop Addresses reviewer recommendations from PR #1028 review. Co-Authored-By: Claude <[email protected]>
5a66502 to
1eb0e5f
Compare
) * feat: AI Chat node type with schema, behavior, plugin, and viewer (closes #1017) Implements ai-chat as a first-class knowledge graph node with messages stored as nested properties per ADR-028. Backend (Rust): - AiChatNodeBehavior: validates provider enum, status, messages array; get_embeddable_content extracts user+assistant text skipping tool_call; get_parent_contribution returns None - Core schema in core_schemas.rs with 7 top-level fields and 7 message item_fields (role, content, timestamp, referenced_nodes, tool, result_summary, duration_ms) - Registered in NodeBehaviorRegistry and exported from lib.rs - 13 behavior tests covering validation, embedding, capabilities Frontend (Svelte): - AiChatNodeViewer with write buffering (7s debounce), immediate flush on destroy, tool result archival (result nulled at write time), soft 500-message cap nudge, archived conversation read-only mode - aiChatNodePlugin registered with /ai-chat slash command, lazy-loaded viewer, and BaseNodeReference - Updated 3 test files for new plugin count (12->13 plugins, commands, references; 4->5 viewers) Also fixed pre-existing Cargo.toml merge conflict in src-tauri. Co-Authored-By: Claude <[email protected]> * address review: fix flushToStore API, add schema fields, clean up viewer - Fixed critical: updateNode call signature (was passing version as changes) - Added args and status item_fields to ai-chat message schema - Changed viewer priority from 10 to 1 for consistency - Removed unused paneId prop Addresses reviewer recommendations from PR #1028 review. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]>
Summary
ai-chatas a first-class knowledge graph node type (closes AI Chat node type: schema, behavior, plugin, and viewer #1017)AiChatNodeBehaviorwith provider/status validation, embedding extraction (user+assistant text, skipping tool_call), and no parent contributioncore_schemas.rswith 7 top-level fields (provider,model,status,last_active,context_tokens,created_nodes,messages[]) and 7 nested message item_fieldsAiChatNodeViewer.sveltewith write buffering (7s debounce), immediate flush on close/navigate, tool result archival at write time, soft 500-message cap nudge, and archived conversation read-only modeaiChatNodePluginregistered incore-plugins.tswith/ai-chatslash command and lazy-loaded viewerTest plan
cargo fmtcleanbun run quality:fixclean for new files (pre-existing errors in ChatPanel/ToolCallDisplay/ModelManager untouched)Generated with Claude Code