Skip to content

Fix mention sync in HTTP dev mode #341

Closed

Description

@malibio

Problem

The mention sync system is not creating mention relationships in the database when using bun run dev (HTTP dev server mode). Users can create @mentions in content, but the bidirectional links are not being stored.

Investigation Findings

What Works

  • ✅ Backend: POST /api/nodes/mention endpoint exists in HTTP dev server
  • ✅ Backend: Node CRUD operations work (POST/PATCH /api/nodes)
  • ✅ Backend: BacklinksPanel queries work (GET /api/nodes/{id}/mentioning-containers)
  • ✅ Frontend: MentionSyncService exists and has correct logic
  • ✅ Frontend: SharedNodeStore calls mentionSyncService.syncMentions() on line 542
  • ✅ Frontend: HttpBackendAdapter.createNodeMention() method exists and calls correct endpoint

What's Broken

  • ❌ NO POST /api/nodes/mention network requests are being made
  • ❌ No mention records in node_mentions database table
  • ❌ BacklinksPanel shows 0 mentions even after creating [@Node](nodespace://id) links

Evidence from Logs

Backend HTTP server logs show content updates:

📝 UPDATE request for node: 5066ebc3-... with content: "[@Some New Node](nodespace://e937a199-...)"
✅ Updated node: 5066ebc3-...

Network requests show NO mention creation:

✅ PATCH http://localhost:3001/api/nodes/5066ebc3-... [200]  <-- Content saved
❌ POST http://localhost:3001/api/nodes/mention            <-- Never called!

Console shows NO mention sync errors:

  • No [SharedNodeStore] Failed to sync mentions errors
  • No network failures for mention endpoints
  • Silent failure - sync code not executing

Root Cause Hypothesis

SharedNodeStore.setNode() may not be called during PATCH updates in HTTP dev mode. The updates might be:

  1. Going directly to HTTP adapter bypassing SharedNodeStore
  2. Using a code path that doesn't trigger the mention sync logic (line 540-545)
  3. Content comparison oldNode?.content !== node.content failing to detect changes

Expected Behavior

When user creates content like:

[@Some New Node](nodespace://e937a199-3d59-470b-b947-40a67228fc41)

Should see:

  1. Network request: POST /api/nodes/mention with {mentioningNodeId, mentionedNodeId}
  2. Database record in node_mentions table
  3. BacklinksPanel on mentioned node shows the mentioning container

Reproduction Steps

  1. Run bun run dev (frontend only)
  2. Run cargo run --bin dev-server (HTTP backend on port 3001)
  3. Navigate to a date page
  4. Create a node
  5. Type @ to trigger autocomplete
  6. Select a node to create mention link
  7. Check network tab - no POST to /api/nodes/mention
  8. Check database: sqlite3 ~/.nodespace/database/nodespace-dev.db "SELECT * FROM node_mentions;"
  9. Result: Empty table

Next Steps

  1. Add debug logging to SharedNodeStore.setNode() to verify it's being called during PATCH
  2. Add logging to MentionSyncService.syncMentions() to see if it's extracting mentions
  3. Verify content comparison logic detects mention additions
  4. Check if HTTP adapter updates flow through SharedNodeStore or bypass it

Related

Metadata

Metadata

Assignees

Labels

backendbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions