Skip to content

Commit d23a452

Browse files
committed
fixed callibration and iphone UI
1 parent b58bfe0 commit d23a452

9 files changed

Lines changed: 2413 additions & 614 deletions

File tree

apps/admin/src/pages/CalibrationRedesign.tsx

Lines changed: 176 additions & 20 deletions
Large diffs are not rendered by default.

apps/backend/src/routes/calibration.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type CalibrationPhase =
3333
interface CalibrationSessionState {
3434
phase: CalibrationPhase;
3535
selectedDoorId: string | null;
36+
selectedDoorName: string | null;
3637
selectedStartCornerIndex: number | null;
3738
currentCornerIndex: number;
3839
totalCorners: number;
@@ -109,6 +110,7 @@ const calibrationLinksByCode = new Map<string, CalibrationLink>();
109110

110111
const broadcast = (event: CalibrationEvent) => {
111112
const payload = `event: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`;
113+
console.log(`[SSE] Broadcasting ${event.type} to ${sseClients.size} clients:`, JSON.stringify(event.payload || {}).slice(0, 200));
112114
for (const res of sseClients) {
113115
try {
114116
res.write(payload);
@@ -181,6 +183,7 @@ router.post('/session/start', (req: Request, res: Response) => {
181183
const defaultState: CalibrationSessionState = {
182184
phase: 'paired',
183185
selectedDoorId: null,
186+
selectedDoorName: null,
184187
selectedStartCornerIndex: null,
185188
currentCornerIndex: 0,
186189
totalCorners: roomData?.corners?.length ?? 0,
@@ -670,14 +673,15 @@ router.patch('/session/:sessionId/state', (req: Request, res: Response) => {
670673
// Select door (can be called from admin or calibrator)
671674
router.post('/session/:sessionId/select-door', (req: Request, res: Response) => {
672675
const { sessionId } = req.params;
673-
const { doorId, doorPosition, source } = req.body ?? {};
676+
const { doorId, doorName, doorPosition, source } = req.body ?? {};
674677

675678
const session = sessions.get(sessionId);
676679
if (!session) {
677680
return res.status(404).json({ success: false, error: 'Session not found' });
678681
}
679682

680683
session.state.selectedDoorId = doorId;
684+
session.state.selectedDoorName = doorName || null;
681685
session.state.doorPosition = doorPosition || null;
682686
session.state.phase = 'door-selected';
683687

@@ -686,13 +690,13 @@ router.post('/session/:sessionId/select-door', (req: Request, res: Response) =>
686690
id: randomUUID(),
687691
timestamp: Date.now(),
688692
type: 'milestone',
689-
data: { milestone: `Door selected (from ${source})`, phase: 'door-selected' }
693+
data: { milestone: `Door ${doorName || doorId} selected (from ${source})`, phase: 'door-selected' }
690694
});
691695

692696
const event: CalibrationEvent = {
693697
type: 'door-selected',
694698
sessionId,
695-
payload: { doorId, doorPosition, source, state: session.state },
699+
payload: { doorId, doorName, doorPosition, source, state: session.state },
696700
timestamp: Date.now(),
697701
};
698702
broadcast(event);
@@ -738,8 +742,11 @@ router.post('/session/:sessionId/milestone', (req: Request, res: Response) => {
738742
const { sessionId } = req.params;
739743
const { type, cornerIndex, message } = req.body ?? {};
740744

745+
console.log(`[Milestone] Received milestone request: sessionId=${sessionId}, type=${type}, cornerIndex=${cornerIndex}`);
746+
741747
const session = sessions.get(sessionId);
742748
if (!session) {
749+
console.log(`[Milestone] Session not found: ${sessionId}`);
743750
return res.status(404).json({ success: false, error: 'Session not found' });
744751
}
745752

apps/calibrator/app/_layout.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { Stack } from 'expo-router';
2+
import { SafeAreaProvider } from 'react-native-safe-area-context';
23

34
export default function RootLayout() {
45
return (
5-
<Stack>
6-
<Stack.Screen name="index" options={{ headerShown: false }} />
7-
</Stack>
6+
<SafeAreaProvider>
7+
<Stack>
8+
<Stack.Screen name="index" options={{ headerShown: false }} />
9+
</Stack>
10+
</SafeAreaProvider>
811
);
912
}

0 commit comments

Comments
 (0)