feat: Implement node deletion with shared modal and fix SurrealDB RecordId handling

Implements complete node deletion functionality for both galaxy view and debug panel:

**Core Changes:**
- Created shared DeleteNodeModal component used by both ThoughtGalaxy and UserMenu
- Modal provides consistent UX with proper confirmation messaging
- Deletion follows write-through cache pattern: ATproto first, then SurrealDB

**SurrealDB RecordId Fixes:**
- Fixed SELECT query to use type::thing($table, $recordId) for UUID-based RecordIds
- Fixed DELETE query to use type::thing() instead of db.delete() to handle dashes in UUIDs
- Without type::thing(), SurrealDB interprets dashes as subtraction operators

**Testing & Documentation:**
- Added comprehensive Magnitude tests for delete functionality (galaxy view and debug panel)
- Updated CLAUDE.md with complete testing workflow documentation
- Added pre-commit checklist requiring database verification and test execution
- Documented PlaywrightMCP manual testing process before Magnitude test writing

**Database Setup:**
- Configured docker-compose.yml to use environment variables for credentials
- Updated namespace/database to match .env configuration (ponderants/main)

**File Changes:**
- app/api/nodes/[id]/route.ts: Fixed RecordId query patterns (SELECT and DELETE)
- components/DeleteNodeModal.tsx: New shared modal component
- components/ThoughtGalaxy.tsx: Uses shared DeleteNodeModal
- components/UserMenu.tsx: Replaced browser confirm() with shared DeleteNodeModal
- tests/magnitude/03-delete-node.mag.ts: Added debug panel delete test
- AGENTS.md: Added testing workflow and pre-commit checklist documentation
- docker-compose.yml: Environment variable configuration

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-10 13:25:01 +00:00
parent d072b71eec
commit a520814771
7 changed files with 282 additions and 45 deletions

100
AGENTS.md
View File

@@ -17,6 +17,106 @@ EOF
These credentials should be used for all automated testing (Magnitude, Playwright) and manual testing when needed. Do not attempt to authenticate without using these credentials.
**Database Setup**: The application uses SurrealDB running in Docker Compose for the app cache layer:
1. Start the database services:
```bash
docker compose up -d
```
2. This starts two services:
- `surrealdb`: The main SurrealDB instance (port 8000)
- `surrealmcp`: SurrealMCP server for MCP access (port 8080)
3. Start the Next.js development server:
```bash
pnpm dev
```
4. To stop the services:
```bash
docker compose down
```
5. Configuration:
- SurrealDB runs in-memory mode (data is not persisted between restarts)
- Namespace: `ponderants`
- Database: `main`
- Credentials: `root/root`
**Note**: Always start docker compose services before starting the Next.js dev server to ensure the database is available.
**Testing Workflow**: All new features must follow a rigorous testing process before being committed:
1. **Manual Testing with Playwright MCP**:
- Use Playwright MCP tools to manually test all functionality interactively
- Test both happy paths (expected user flows) and unhappy paths (errors, edge cases)
- Document each step you verify during manual testing - these become test cases
- If you encounter issues during manual testing (e.g., 404 errors, unexpected behavior), investigate and fix them before proceeding
- Use the following pattern:
```
1. Navigate to the feature
2. Perform user actions (clicks, typing, etc.)
3. Verify expected outcomes
4. Test error scenarios
5. Verify cleanup/state updates
```
2. **Write Comprehensive Magnitude Tests**:
- After manually verifying functionality with Playwright MCP, write extensive Magnitude tests covering ALL verified behaviors
- Each manual test step should have a corresponding Magnitude test assertion
- Test files are located in `tests/magnitude/` with `.mag.ts` extension
- Use the test credentials from .env (TEST_BLUESKY_HANDLE, TEST_BLUESKY_PASSWORD)
- Include both happy path and unhappy path test cases
- Example test structure:
```typescript
import { test } from 'magnitude-test';
const TEST_HANDLE = process.env.TEST_BLUESKY_HANDLE;
const TEST_PASSWORD = process.env.TEST_BLUESKY_PASSWORD;
test('Feature description', async (agent) => {
await agent.act('Navigate to /page');
await agent.act('Perform user action');
await agent.check('Verify expected outcome');
});
```
3. **Reusable Playwright Scaffolding**:
- Abstract common patterns (auth, navigation, etc.) into helper files in `tests/playwright/helpers/`
- These helpers should be usable both during manual Playwright MCP testing AND by Magnitude tests
- Examples: `tests/playwright/helpers/chat.ts`, `tests/playwright/helpers/galaxy.ts`, `tests/playwright/helpers/node.ts`
- For auth setup, use Playwright's global setup pattern (see https://playwright.dev/docs/test-global-setup-teardown)
- Current auth setup: `tests/playwright/auth.setup.ts`
4. **Generating Playwright Code**:
- Use https://playwright.dev/docs/test-agents to generate Playwright test code when helpful
- This tool can convert natural language test descriptions into Playwright code
5. **Test Execution**:
- Run Magnitude tests: `pnpm test` or `npx magnitude`
- Ensure ALL tests pass before committing
- If tests fail, fix the implementation or update the tests to match the correct behavior
6. **Pre-Commit Checklist**:
- ✅ All manual testing with Playwright MCP completed and verified
- ✅ All Magnitude tests written and cover all verified functionality
- ✅ Database verified for expected state after operations (e.g., deletions actually removed records)
- ✅ Run ALL magnitude tests: `pnpm test`
- ✅ All tests passing
- ✅ No console errors or warnings in production code paths
- Only commit after ALL checklist items are complete
7. **Documentation**:
- Document test coverage in `tests/README.md`
- Add comments to complex test scenarios explaining the business logic being tested
**Testing Resources**:
- Playwright Global Setup/Teardown: https://playwright.dev/docs/test-global-setup-teardown
- Playwright Test Agents: https://playwright.dev/docs/test-agents
- Magnitude.run Documentation: https://magnitude.run/docs
- Project Test README: `tests/README.md`
You are an expert-level, full-stack AI coding agent. Your task is to implement
the "Ponderants" application. Product Vision: Ponderants is an AI-powered
thought partner that interviews a user to capture, structure, and visualize