Skip to content

Fix Enter Key & Node Creation Operations (17 test failures)#239

Closed
malibio wants to merge 1 commit into
mainfrom
feature/issue-232-dual-persistence-fix
Closed

Fix Enter Key & Node Creation Operations (17 test failures)#239
malibio wants to merge 1 commit into
mainfrom
feature/issue-232-dual-persistence-fix

Conversation

@malibio

@malibio malibio commented Oct 12, 2025

Copy link
Copy Markdown
Collaborator

Closes #232

…ge (Issue #232)

## Problem
HTTP dev server used a single shared NodeService instance, preventing test
isolation. When tests called /api/database/init with unique database paths, the
endpoint created new services but didn't update AppState, causing:
- UNIQUE constraint errors from static node IDs across tests
- Test contamination (nodes from one test appearing in another)
- Inability to run comprehensive integration test suites

## Solution
Implemented RwLock pattern to enable atomic database swapping:

**Backend Changes:**
- AppState now uses Arc<RwLock<Arc<DatabaseService>>> and Arc<RwLock<Arc<NodeService>>>
- init_database() creates new services and swaps them atomically via RwLock
- All endpoints use .read().unwrap().clone() pattern for safe concurrent access
- Updated dev-server.rs to wrap initial services in RwLock

**Frontend Changes:**
- SharedNodeStore: Skip viewer-sourced persistence (temporary dual persistence fix)
- ReactiveNodeService: Fixed containerNodeId='root' for root-level nodes
- node-ordering tests: Added sharedNodeStore.__resetForTesting() for isolation

## Test Results
- ✅ node-ordering: 10/10 passing
- ✅ enter-key-operations: 7/10 passing (3 real bugs remain - Issue #232 continued)
- ⏳ shift-enter-operations: Skipped (HTTP 500 error - separate issue)

**Database isolation verified working:**
- Server logs show "🔄 Database SWAPPED to: <path>" for each test
- NO MORE UNIQUE constraint errors
- Each test gets isolated database with unique path

## Files Modified
- src-tauri/src/bin/dev-server.rs - RwLock initialization
- src-tauri/src/dev_server/mod.rs - AppState with RwLock
- src-tauri/src/dev_server/node_endpoints.rs - RwLock swap logic + access pattern
- src-tauri/src/dev_server/query_endpoints.rs - RwLock access pattern
- src-tauri/src/dev_server/embedding_endpoints.rs - RwLock access pattern
- src/lib/services/reactive-node-service.svelte.ts - containerNodeId fix
- src/lib/services/shared-node-store.ts - viewer-source persistence skip
- src/tests/integration/node-ordering.test.ts - test isolation reset

## Next Steps (Issue #232 continued)
1. Fix 3 remaining enter-key operation bugs (beforeSiblingId logic)
2. Investigate shift-enter HTTP 500 error
3. Run full test suite
4. Create PR

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@malibio

malibio commented Oct 12, 2025

Copy link
Copy Markdown
Collaborator Author

Closing PR - database isolation is fixed but actual enter key bugs still need to be resolved. See issue #232 for comprehensive status and next steps.

@malibio malibio closed this Oct 12, 2025
@malibio
malibio deleted the feature/issue-232-dual-persistence-fix branch October 15, 2025 11:56
mstomar125 added a commit that referenced this pull request Jul 2, 2026
…rrent_person Tauri commands (#239) (#1472)

Refresh the vendored Pro proto from the daemon source-of-truth (adds the
ListInvites / ListRequests / RevokeInvite / GetIdentity RPCs + Invite /
JoinRequest / GetIdentity messages) and add the matching Tauri commands:

- pro_list_invites → Vec<InviteDto{id,code,email,permission,expires_at}>
- pro_list_requests → Vec<RequestDto{id,requested_by,created_at}>
- pro_revoke_invite(invite_id) — cancel a pending invite or join request
- pro_current_person → PersonDto{person_id,email} — the caller's own bound
  PersonNode id (+ email) so the UI can identify its own roster row and gate
  admin controls on the caller's per-collection role. Empty person_id on an
  un-bound device is treated as "role unknown".

Each is a thin pass-through over the daemon gRPC client, mirroring the eight
existing membership commands, and registered in the invoke handler. They resolve
the ProClient or fail in community mode, so the community build is unaffected.

Co-authored-by: Mayank  Tomar <mayanktomar@Michaels-Mac-mini.local>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.

Fix Enter Key & Node Creation Operations (17 test failures)

1 participant