Skip to content

feat: add drag-and-drop foundation and fix build errors#7

Open
brosell wants to merge 2 commits intomainfrom
feat/drag-and-drop
Open

feat: add drag-and-drop foundation and fix build errors#7
brosell wants to merge 2 commits intomainfrom
feat/drag-and-drop

Conversation

@brosell
Copy link
Owner

@brosell brosell commented Jul 25, 2025

Summary

• Add foundational drag-and-drop functionality to ChatMap mindmap using svelte-dnd-action
• Fix critical build errors by updating markmap dependencies to latest versions
• Add AGENTS.md development guidelines for coding agents

Test plan

  • Verify build succeeds without errors (npm run build)
  • Test drag-and-drop visual feedback in mindmap view
  • Confirm no runtime errors in browser console
  • Note: drag-and-drop changes are not yet persisted (logged to console only)

🤖 Generated with opencode

Summary by CodeRabbit


New Feature:

  • Added drag-and-drop functionality to the ChatMap mindmap, enhancing user interaction and customization.

Bug Fix:

  • Updated dependencies to resolve critical build errors.
  • Fixed an import issue in template-strings.ts service due to changes in markmap-lib.

Documentation:

  • Introduced a new document Agent Guidelines providing development commands, style guidelines, and rules.

Refactor:

  • Enhanced contextual-stores.ts with a new method reorderChatPoints for reordering chat points based on user input.

These updates aim to improve user experience and application stability while providing clear guidelines for future development.

brosell and others added 2 commits July 24, 2025 20:58
…ng unused import

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>
@github-actions
Copy link

github-actions bot commented Jul 25, 2025

Image description CodeRabbit

Walkthrough

This update introduces development guidelines, adds drag-and-drop functionality to the ChatMap component, and updates dependencies to fix build errors. It also addresses an import issue in template-strings.ts and adds a method to reorder chat points in contextual-stores.ts.

Changes

Files Summary
AGENTS.md, src/components/ChatMap.svelte Introduced a document Agent Guidelines for development commands, style guidelines, and rules. Added drag-and-drop functionality to the ChatMap mindmap using svelte-dnd-action. Updated dependencies to resolve critical build errors.
src/services/template-strings.ts, src/stores/contextual-stores.ts Fixed an import issue in template-strings.ts where template was not exported in the latest version of markmap-lib. Added a new method reorderChatPoints in contextual-stores.ts to reorder chat points based on provided IDs.

🐰 "In the land of code, changes are afoot,
Drag-and-drop, reordering, giving the app a new look.
With guidelines set, and dependencies met,
We hop forward, our goals firmly set!" 🎉


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 97b210c and ed17ee9 commits.
Files selected (4)
  • AGENTS.md (1)
  • src/components/ChatMap.svelte (3)
  • src/services/template-strings.ts (1)
  • src/stores/contextual-stores.ts (1)
Files ignored due to filter (1)
  • package.json
Files skipped from review due to trivial changes (2)
  • AGENTS.md
  • src/services/template-strings.ts
Review comments generated (5)
  • Review: 2
  • LGTM: 3

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines +197 to +201
reorderChatPoints(newOrderIds: string[]): void {
const points = this.chatPoints.getValue();
const reordered = newOrderIds.map(id => points.find(cp => cp.id === id)).filter(Boolean) as ChatPoint[];
this.chatPoints.next(reordered);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

The reorderChatPoints function could potentially have performance issues if the number of chat points is large. The current implementation has a time complexity of O(n^2) because for each id in newOrderIds, it performs a find operation on points which is an O(n) operation. This can be optimized to O(n) by creating a map of ids to chat points before reordering.

-    const reordered = newOrderIds.map(id => points.find(cp => cp.id === id)).filter(Boolean) as ChatPoint[];
+    const pointsMap = new Map(points.map(cp => [cp.id, cp]));
+    const reordered = newOrderIds.map(id => pointsMap.get(id)).filter(Boolean) as ChatPoint[];

Comment on lines +80 to +87
let linkSVG: any;

// drag-and-drop items
let dndItems: Array<{ id: string; item: any }> = [];
const unsubscribeTree = treeDisplay.subscribe(items => { dndItems = items.map(item => ({ id: item.id, item })); });
function handleDndFinalize(e: CustomEvent) {
console.log('Reordered items:', e.detail.items);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

The unsubscribeTree subscription is not being cleaned up. This could lead to memory leaks if the component is destroyed and recreated multiple times. Consider unsubscribing in an onDestroy lifecycle hook.

+ import { onDestroy } from 'svelte';
  
  let mindmap: SVGSVGElement;
  let linkSVG: any;

  // drag-and-drop items
  let dndItems: Array<{ id: string; item: any }> = [];
- const unsubscribeTree = treeDisplay.subscribe(items => { dndItems = items.map(item => ({ id: item.id, item })); });
+ const unsubscribeTree = treeDisplay.subscribe(items => { dndItems = items.map(item => ({ id: item.id, item })); });
+ onDestroy(unsubscribeTree);
  function handleDndFinalize(e: CustomEvent) {
    console.log('Reordered items:', e.detail.items);
  }

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