From 09caac305167d5c83b147ce6991647d9034c5b91 Mon Sep 17 00:00:00 2001 From: akbyrner Date: Fri, 24 Apr 2026 08:37:25 -0500 Subject: [PATCH 1/8] UPDATE login field to direct user to profile creation screen if they don't already have one --- .../migration.sql | 2 + src/App.tsx | 2 + src/components/LogInAuth/CreateProfile.tsx | 92 ++++++++++++++++ src/components/LogInAuth/GoogleAuth.tsx | 20 +--- src/components/LogInAuth/LandingPage.tsx | 100 +++--------------- .../MakeSigil/__tests__/MakeSigil.test.tsx | 5 + .../ui/__tests__/TutorialOverlay.test.tsx | 5 + test-login.cjs | 9 -- 8 files changed, 123 insertions(+), 112 deletions(-) create mode 100644 server/prisma/migrations/20260413050231_add_tutorial_field/migration.sql create mode 100644 src/components/LogInAuth/CreateProfile.tsx create mode 100644 src/components/SigilRoomHome/MakeSigil/__tests__/MakeSigil.test.tsx create mode 100644 src/components/ui/__tests__/TutorialOverlay.test.tsx delete mode 100644 test-login.cjs diff --git a/server/prisma/migrations/20260413050231_add_tutorial_field/migration.sql b/server/prisma/migrations/20260413050231_add_tutorial_field/migration.sql new file mode 100644 index 0000000..248f3f2 --- /dev/null +++ b/server/prisma/migrations/20260413050231_add_tutorial_field/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE `users` ADD COLUMN `hasCompletedTutorial` BOOLEAN NOT NULL DEFAULT false; diff --git a/src/App.tsx b/src/App.tsx index 7cc4a6e..0444bb6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,6 +5,7 @@ import { useUser } from '@/context/UserContext'; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Landing Page & Log in import ProtectedRoute from './components/LogInAuth/ProtectedRoute' import LandingPage from './components/LogInAuth/LandingPage' +import CreateProfile from './components/LogInAuth/CreateProfile' //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ User @@ -67,6 +68,7 @@ console.log('App render - isLoading:', isLoading, 'path:', window.location.pathn {/* Auth flow */} } /> } /> + } /> {/* User */} } /> diff --git a/src/components/LogInAuth/CreateProfile.tsx b/src/components/LogInAuth/CreateProfile.tsx new file mode 100644 index 0000000..a2a891a --- /dev/null +++ b/src/components/LogInAuth/CreateProfile.tsx @@ -0,0 +1,92 @@ +import { useState } from 'react'; +import { useNavigate } from 'react-router-dom'; +import * as SwitchPrimitive from "@radix-ui/react-switch"; +import { useUser } from '@/context/UserContext'; +import MapSearchBox from '@/components/SigilRoomHome/Grimoire/LeftPage/Map/MapSearchBox'; + +export default function CreateProfile() { + const { user, setUser } = useUser(); + const navigate = useNavigate(); + const [username, setUsername] = useState(''); + const [avatar, setAvatar] = useState('0'); + const [homeLocation, setHomeLocation] = useState(''); + const [isDark, setIsDark] = useState(false); + + const handleCreate = async () => { + if (!user) return; + try { + const res = await fetch(`/api/users/${user.id}`, { + method: "PATCH", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + username, + avatar: parseInt(avatar), + theme: isDark ? 1 : 0, + homeLocation + }) + }); + const updated = await res.json(); + setUser(updated); + navigate('/make-sigil/write'); + } catch (err) { + console.error(err); + } + }; + + const handleThemeChange = (checked: boolean) => { + setIsDark(checked); + document.documentElement.classList.toggle("dark", checked); + }; + + return ( +
+
+
+

Create Your Profile:

+ + + + + + + + + +
+
+
+ ); +} diff --git a/src/components/LogInAuth/GoogleAuth.tsx b/src/components/LogInAuth/GoogleAuth.tsx index 926f12d..952520b 100644 --- a/src/components/LogInAuth/GoogleAuth.tsx +++ b/src/components/LogInAuth/GoogleAuth.tsx @@ -9,19 +9,11 @@ declare global { } } -export default function GoogleAuth({ formData, isNewUser = false }: { formData: any, isNewUser?: boolean }) { +export default function GoogleAuth() { const { setUser } = useUser(); const navigate = useNavigate(); const initialized = useRef(false); - const formDataRef = useRef(formData); - const buttonId = isNewUser ? 'google-signin-button-new' : 'google-signin-button'; - - - - - useEffect(() => { - formDataRef.current = formData; - }, [formData]); + const buttonId = 'google-signin-button'; useEffect(() => { console.log('[GoogleAuth] Mounted. Checking for window.google'); @@ -31,7 +23,6 @@ export default function GoogleAuth({ formData, isNewUser = false }: { formData: try { const payload = { credential: response.credential, - ...formDataRef.current }; console.log('[GoogleAuth] Sending login data to backend:', { ...payload, credential: 'HIDDEN' }); @@ -50,15 +41,12 @@ export default function GoogleAuth({ formData, isNewUser = false }: { formData: const data = await res.json(); console.log('[GoogleAuth] Backend response successful:', data.success); - setUser(data.user); setTimeout(() => { if (data.needsProfile) { - navigate('/login'); - } else if (isNewUser) { - navigate('/make-sigil/write'); + navigate('/create-profile'); } else { - navigate('/home'); + navigate('/home'); } }, 300); } catch (error) { diff --git a/src/components/LogInAuth/LandingPage.tsx b/src/components/LogInAuth/LandingPage.tsx index 511061a..9d7c7cd 100644 --- a/src/components/LogInAuth/LandingPage.tsx +++ b/src/components/LogInAuth/LandingPage.tsx @@ -2,9 +2,7 @@ import { useState, useEffect, useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; import SigiLifeLogo from '../../assets/SigilifeLogo.svg'; import GoogleAuth from './GoogleAuth'; -import MapSearchBox from '@/components/SigilRoomHome/Grimoire/LeftPage/Map/MapSearchBox'; import { useUser } from '@/context/UserContext'; -import * as SwitchPrimitive from "@radix-ui/react-switch" import { Carousel, CarouselContent, @@ -14,41 +12,26 @@ import { type CarouselApi, } from "@/components/ui/carousel" - export default function LandingPage() { - const { user, isLoading, setUser } = useUser(); + const { user, isLoading } = useUser(); const navigate = useNavigate(); - const [username, setUsername] = useState(''); - const [avatar, setAvatar] = useState('0'); - const [homeLocation, setHomeLocation] = useState(''); - const [isNewUser, setIsNewUser] = useState(false); - const [isDark, setIsDark] = useState(false) const [carouselApi, setCarouselApi] = useState(); - const handleSlideClick = useCallback(() => { carouselApi?.scrollNext(); }, [carouselApi]); - - const handleThemeChange = (checked: boolean) => { - setIsDark(checked) - document.documentElement.classList.toggle("dark", checked) - if (!user) return - fetch(`/api/users/${user!.id}`, { - method: "PATCH", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ theme: checked ? 1 : 0 }) - }) - .then(res => res.json()) - .then(updated => setUser(updated)) - } - useEffect(() => { if (!isLoading && user) { - navigate('/home'); + const needsProfile = !user.username || user.avatar === null || user.theme === null || !user.homeLocation; + if (needsProfile) { + navigate('/create-profile'); + } else { + navigate('/home'); + } } - }, [user, isLoading]); + }, [user, isLoading, navigate]); + useEffect(() => { if (!carouselApi) return; @@ -59,7 +42,6 @@ export default function LandingPage() { return () => clearInterval(interval) }, [carouselApi]); - const slides = [ <>Mark your intent.
Leave a trace.

Nothing disappears without a ritual., <>SigiLife is a map of hidden intentions:

yours and everyone else's., @@ -81,9 +63,7 @@ export default function LandingPage() { return ( <>
-
- {!isNewUser && ( <> Sigil-Life-Logo
@@ -105,66 +85,12 @@ export default function LandingPage() {
- )} - {isNewUser && ( -
-

Create Your Profile:

- - - - - - - +
+
- )} - - -
- - {!isNewUser && ( - - )}
-
-
- -); + + ); } \ No newline at end of file diff --git a/src/components/SigilRoomHome/MakeSigil/__tests__/MakeSigil.test.tsx b/src/components/SigilRoomHome/MakeSigil/__tests__/MakeSigil.test.tsx new file mode 100644 index 0000000..78e8512 --- /dev/null +++ b/src/components/SigilRoomHome/MakeSigil/__tests__/MakeSigil.test.tsx @@ -0,0 +1,5 @@ +import { render, screen } from '@testing-library/react'; + +it('renders MakeSigil component', () => { + render(); +}); \ No newline at end of file diff --git a/src/components/ui/__tests__/TutorialOverlay.test.tsx b/src/components/ui/__tests__/TutorialOverlay.test.tsx new file mode 100644 index 0000000..7ebcd64 --- /dev/null +++ b/src/components/ui/__tests__/TutorialOverlay.test.tsx @@ -0,0 +1,5 @@ +import { render, screen } from '@testing-library/react'; + +it('renders TutorialOverlay component', () => { + render(); +}); \ No newline at end of file diff --git a/test-login.cjs b/test-login.cjs deleted file mode 100644 index d5e1aec..0000000 --- a/test-login.cjs +++ /dev/null @@ -1,9 +0,0 @@ -const crypto = require('crypto'); -function sign(val, secret) { - return 's:' + val + '.' + crypto - .createHmac('sha256', secret) - .update(val) - .digest('base64') - .replace(/\=+$/, ''); -} -console.log(sign('Lg-TZBWjOCBA6_RsqikQ1VOmGplacZ87', '6133ae4665471824739d603404026ce263db3af3805d0530e44d10ea8eabe5d0')); From 11ae27a9eef61225d14d0ff12c76cc9558bff9de Mon Sep 17 00:00:00 2001 From: akbyrner Date: Mon, 27 Apr 2026 01:19:14 -0500 Subject: [PATCH 2/8] UPDATE buttons to be standardized, AR View to stop juttering when placing sigils, CSS paths to standardize button appearance, Test hooks --- .github/workflows/pipeline.yml | 22 +++-- .../LeftPage/Map/PlaceSigilInWorld.tsx | 84 +++++++++++++------ src/components/SigilRoomHome/HomeRoom.tsx | 4 + src/index.css | 43 ++++++++-- 4 files changed, 112 insertions(+), 41 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 59c2ba2..c5f8953 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -64,6 +64,11 @@ jobs: npx prisma generate --schema=server/prisma/schema.prisma npm run build + - name: Connect to Tailscale + uses: tailscale/github-action@v3 + with: + authkey: ${{ secrets.TAILSCALE_AUTH_KEY }} + - name: Deploy via rsync env: SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }} @@ -86,17 +91,18 @@ jobs: --exclude 'logs/' \ --exclude '*.log' \ ./ $REMOTE_USER@$REMOTE_HOST:~/SigiLife/ - rm deploy_key.pem - + - name: Restart Application - uses: appleboy/ssh-action@v1.0.3 - with: - host: ${{ secrets.REMOTE_HOST }} - username: ${{ secrets.REMOTE_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - script: | + env: + SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + REMOTE_HOST: ${{ secrets.REMOTE_HOST }} + REMOTE_USER: ${{ secrets.REMOTE_USER }} + run: | + ssh -i deploy_key.pem -o StrictHostKeyChecking=no $REMOTE_USER@$REMOTE_HOST << 'EOF' cd ~/SigiLife npm install npx prisma migrate deploy --schema=server/prisma/schema.prisma npx prisma generate --schema=server/prisma/schema.prisma pm2 restart sigilife || pm2 start ecosystem.config.cjs --env production + EOF + rm deploy_key.pem diff --git a/src/components/SigilRoomHome/Grimoire/LeftPage/Map/PlaceSigilInWorld.tsx b/src/components/SigilRoomHome/Grimoire/LeftPage/Map/PlaceSigilInWorld.tsx index ef73926..d100f93 100644 --- a/src/components/SigilRoomHome/Grimoire/LeftPage/Map/PlaceSigilInWorld.tsx +++ b/src/components/SigilRoomHome/Grimoire/LeftPage/Map/PlaceSigilInWorld.tsx @@ -141,12 +141,21 @@ export default function PlaceSigilInWorld() { // debugDiv.style.padding = '10px'; // document.body.appendChild(debugDiv); + let targetPosition = new THREE.Vector3(); + let targetQuaternion = new THREE.Quaternion(); + let lastRefineFrame = 0; + const REFINE_INTERVAL_FRAMES = 60; // Refine anchor every 1s (at 60fps) + const getOrCreateMesh = () => { if (!placedSigilMesh) { const geometry = new THREE.PlaneGeometry(1, 1); placedSigilMesh = new THREE.Mesh(geometry, sigilMaterial); scene.add(placedSigilMesh); setIsPlaced(true); + + // Initialize targets to current position/rotation on first placement + targetPosition.copy(placedSigilMesh.position); + targetQuaternion.copy(placedSigilMesh.quaternion); } return placedSigilMesh; }; @@ -175,15 +184,18 @@ export default function PlaceSigilInWorld() { const mesh = getOrCreateMesh(); if (intersection) { - mesh.position.copy(intersection); + targetPosition.copy(intersection); } else { - mesh.position.copy(planeCenter); // Absolute fallback + targetPosition.copy(planeCenter); // Absolute fallback } // Rotate to face the camera (billboard toward viewer) - mesh.lookAt(camPos); + const lookAtMatrix = new THREE.Matrix4(); + lookAtMatrix.lookAt(targetPosition, camPos, new THREE.Vector3(0, 1, 0)); + targetQuaternion.setFromRotationMatrix(lookAtMatrix); + setStatus("Sigil Placed!"); - console.log(`[AR] Placed via raycast fallback at (${mesh.position.x.toFixed(2)}, ${mesh.position.y.toFixed(2)})`); + console.log(`[AR] Placed via raycast fallback at (${targetPosition.x.toFixed(2)}, ${targetPosition.y.toFixed(2)})`); }; const handleTap = (e: TouchEvent | MouseEvent) => { @@ -211,25 +223,27 @@ export default function PlaceSigilInWorld() { let slamSucceeded = false; try { if (XR8.XrController && XR8.XrController.hitTest) { + // Prioritize DETECTED_SURFACE and ESTIMATED_SURFACE for better stability const hitTestResults = XR8.XrController.hitTest( - tapX, tapY, ['FEATURE_POINT', 'ESTIMATED_SURFACE', 'DETECTED_SURFACE'] + tapX, tapY, ['DETECTED_SURFACE', 'ESTIMATED_SURFACE', 'FEATURE_POINT'] ); - console.log("[AR] hitTest results:", hitTestResults); + if (hitTestResults && hitTestResults.length > 0) { const hit = hitTestResults[0]; - const mesh = getOrCreateMesh(); - mesh.position.set(hit.position.x, hit.position.y, hit.position.z); + getOrCreateMesh(); + + targetPosition.set(hit.position.x, hit.position.y, hit.position.z); if (hit.rotation) { - mesh.quaternion.set( + targetQuaternion.set( hit.rotation.x, hit.rotation.y, hit.rotation.z, hit.rotation.w ); } else { - mesh.rotation.x = -Math.PI / 2; // default: flat on floor + // Default to flat on floor (X-axis rotation) + targetQuaternion.setFromAxisAngle(new THREE.Vector3(1, 0, 0), -Math.PI / 2); } + setStatus("Sigil Anchored!"); slamSucceeded = true; - } else { - console.log("[AR] hitTest returned no results, using fallback."); } } } catch (err: any) { @@ -257,24 +271,46 @@ export default function PlaceSigilInWorld() { } } + const { camera } = XR8.Threejs.xrScene(); + + // Apply Smoothing (Lerp/Slerp) if sigil is placed + if (placedSigilMesh && isPlaced) { + const SMOOTHING_FACTOR = 0.15; // Adjust this: lower = smoother/slower, higher = snappier/jitterier + placedSigilMesh.position.lerp(targetPosition, SMOOTHING_FACTOR); + placedSigilMesh.quaternion.slerp(targetQuaternion, SMOOTHING_FACTOR); + + // Periodic Anchor Refinement: + // This re-runs a hit test at the sigil's screen position to "cling" to the moving points. + if (frameCount % REFINE_INTERVAL_FRAMES === 0 && XR8.XrController && XR8.XrController.hitTest) { + try { + // Project the current 3D position back to screen space (0 to 1) + const vector = targetPosition.clone(); + vector.project(camera); + const screenX = (vector.x + 1) / 2; + const screenY = -(vector.y - 1) / 2; + + // Re-run hit test at that screen coordinate + const results = XR8.XrController.hitTest(screenX, screenY, ['DETECTED_SURFACE', 'ESTIMATED_SURFACE']); + if (results && results.length > 0) { + const hit = results[0]; + // Slowly nudge the target towards the refined surface position + const refineLerp = 0.5; // Weight of the new refinement + targetPosition.x = targetPosition.x * (1 - refineLerp) + hit.position.x * refineLerp; + targetPosition.y = targetPosition.y * (1 - refineLerp) + hit.position.y * refineLerp; + targetPosition.z = targetPosition.z * (1 - refineLerp) + hit.position.z * refineLerp; + } + } catch (err) { + // Silently ignore hit test failures during refinement + } + } + } + // Update the point cloud visualization if data is available if (pointCloudMesh && pointCloudGeom && e.processCpuResult && e.processCpuResult.reality) { const reality = e.processCpuResult.reality; // Support multiple legacy naming conventions const pc = reality.pointCloud || reality.worldPoints; - // const debugDiv = document.getElementById('slam-debug-info'); - // if (debugDiv) { - // const keys = Object.keys(reality).join(', '); - // const type = pc ? (typeof pc[0] === 'number' ? 'Float32Array' : 'ObjectArray') : 'N/A'; - // const length = pc ? pc.length : 0; - // debugDiv.innerHTML = ` - // Reality Keys:
${keys}
- // PC Type: ${type}
- // PC Length: ${length} - // `; - // } - if (pc && pc.length > 0) { const positions = pointCloudGeom.attributes.position.array as Float32Array; diff --git a/src/components/SigilRoomHome/HomeRoom.tsx b/src/components/SigilRoomHome/HomeRoom.tsx index 10c32ac..921ab77 100644 --- a/src/components/SigilRoomHome/HomeRoom.tsx +++ b/src/components/SigilRoomHome/HomeRoom.tsx @@ -40,6 +40,7 @@ export default function HomeRoom() {