Skip to content

Commit 45d5269

Browse files
adewaleclaude
andcommitted
fix: Remove duplicate routing, fix example patterns
Fixes 4 bug patterns: 1. Write-without-read: main.tsx stored patterns in sessionStorage but nothing read them. Fixed by removing the broken Router. 2. Dead code: main.tsx Router duplicated App.tsx's landing page logic. Removed - App.tsx handles all routing internally. 3. Full page reload: main.tsx used window.location.href which caused unnecessary reloads. App.tsx uses React state transitions. 4. Invalid sample ID: LANDING_SAMPLES used 'perc' which doesn't exist. Changed to 'clap' (a valid sample ID). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2887f7e commit 45d5269

File tree

2 files changed

+9
-56
lines changed

2 files changed

+9
-56
lines changed

app/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,8 @@ function hasSessionInUrl(): boolean {
543543
}
544544

545545
// Default drum samples for landing page example patterns
546-
const LANDING_SAMPLES = ['kick', 'snare', 'hihat', 'perc'];
546+
// Must match valid sample IDs from sample-constants.ts
547+
const LANDING_SAMPLES = ['kick', 'snare', 'hihat', 'clap'];
547548

548549
function App() {
549550
const [showLanding, setShowLanding] = useState(() => !hasSessionInUrl());

app/src/main.tsx

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { StrictMode, useState, useEffect, useCallback } from 'react'
1+
import { StrictMode } from 'react'
22
import { createRoot } from 'react-dom/client'
33
import './index.css'
44
import App from './App.tsx'
5-
import { LandingPage } from './components/LandingPage'
65

76
// Initialize unified debugging infrastructure
87
// The debug coordinator handles URL flags (?debug=1, ?trace=1, etc.)
@@ -16,62 +15,15 @@ if (import.meta.env.DEV) {
1615
}
1716

1817
/**
19-
* Root Router Component
18+
* App handles all routing internally:
19+
* - "/" shows LandingPage (showLanding = true)
20+
* - "/s/{id}" shows session UI (showLanding = false)
2021
*
21-
* Handles routing between LandingPage and App:
22-
* - "/" shows LandingPage
23-
* - "/s/{uuid}" shows App with session
24-
*
25-
* @see /specs/LANDING-PAGE.md for routing specification
22+
* This avoids the full page reload that window.location.href causes.
23+
* App.tsx uses React state transitions for instant navigation.
2624
*/
27-
function Router() {
28-
const [showApp, setShowApp] = useState(false);
29-
30-
useEffect(() => {
31-
const path = window.location.pathname;
32-
33-
// Check for session URL pattern: /s/{uuid}
34-
// UUIDs are 36 characters: 8-4-4-4-12 hex digits
35-
const sessionMatch = path.match(/^\/s\/([a-f0-9-]{36})$/i);
36-
if (sessionMatch) {
37-
setShowApp(true);
38-
return;
39-
}
40-
41-
// Any other path with /s/ prefix should show the app
42-
// (handles partial UUIDs, session not found, etc.)
43-
if (path.startsWith('/s/')) {
44-
setShowApp(true);
45-
return;
46-
}
47-
48-
// Root path or unknown paths show landing page
49-
// Landing page is the default
50-
}, []);
51-
52-
// Start a new session from landing page
53-
const handleStartSession = useCallback(() => {
54-
// Navigate to create a new session
55-
// The App component will handle creating a new session on mount
56-
window.location.href = '/s/new';
57-
}, []);
58-
59-
// Select an example pattern - navigate to app with pattern in URL state
60-
const handleSelectExample = useCallback((pattern: number[][], bpm: number) => {
61-
// Store example in sessionStorage for App to pick up
62-
sessionStorage.setItem('pendingExample', JSON.stringify({ pattern, bpm }));
63-
window.location.href = '/s/new';
64-
}, []);
65-
66-
if (showApp) {
67-
return <App />;
68-
}
69-
70-
return <LandingPage onStartSession={handleStartSession} onSelectExample={handleSelectExample} />;
71-
}
72-
7325
createRoot(document.getElementById('root')!).render(
7426
<StrictMode>
75-
<Router />
27+
<App />
7628
</StrictMode>,
7729
)

0 commit comments

Comments
 (0)