feat: Make galaxy viewable without login requirement

Implemented public galaxy viewing feature that allows unauthenticated
users to view public thought galaxies via the ?user={did} parameter,
while maintaining privacy controls for node-level visibility.

Changes:
- Updated /api/galaxy/route.ts to support public access:
  * Accept ?user={did} query parameter for viewing specific user's galaxy
  * Show all nodes (including private) for authenticated user viewing own galaxy
  * Filter to only public nodes when viewing someone else's galaxy
  * Return empty state with helpful message when not authenticated
  * Filter links to only show connections between visible nodes

- Added is_public field to database schema:
  * Updated db/schema.surql with DEFAULT true (public by default)
  * Created migration script scripts/add-is-public-field.ts
  * Aligns with ATproto's public-by-default philosophy

- Enhanced ThoughtGalaxy component:
  * Support viewing galaxies via ?user={did} parameter
  * Display user info banner when viewing public galaxy
  * Show appropriate empty state messages based on context
  * Refetch data when user parameter changes

- Created comprehensive Magnitude tests:
  * Test public galaxy viewing without authentication
  * Verify private nodes are hidden from public view
  * Test own galaxy access requires authentication
  * Validate invalid user DID handling
  * Test user info display and navigation between galaxies

- Documented implementation plan in plans/10-public-galaxy-viewing.md

This implements the "public by default" model while allowing future
node-level privacy controls. All canonical data remains on the user's
ATproto PDS, with SurrealDB serving as a high-performance cache.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-10 00:36:16 +00:00
parent aa60098690
commit d656b06113
6 changed files with 592 additions and 21 deletions

View File

@@ -0,0 +1,44 @@
import Surreal from 'surrealdb';
/**
* Migration: Add is_public field to node table
*
* This script adds the is_public field to all existing nodes,
* defaulting them to public (true) to align with the public-by-default
* philosophy of ATproto.
*/
async function migrate() {
const db = new Surreal();
try {
await db.connect('ws://localhost:8000/rpc');
await db.signin({ username: 'root', password: 'root' });
await db.use({ namespace: 'ponderants', database: 'main' });
console.log('Adding is_public field definition to node table...');
// Define the field (should already be in schema.surql, but ensuring it's applied)
await db.query(`
DEFINE FIELD is_public ON TABLE node TYPE bool DEFAULT true;
`);
console.log('✓ Field definition added');
console.log('Setting existing nodes to public...');
// Set all existing nodes where is_public is NONE to true (public by default)
const result = await db.query(`
UPDATE node SET is_public = true WHERE is_public = NONE;
`);
console.log('Result:', result);
console.log('✓ Migration complete: All existing nodes are now public by default');
} catch (error) {
console.error('Migration failed:', error);
process.exit(1);
} finally {
await db.close();
}
}
migrate();