mirror of
https://github.com/ruvnet/RuView
synced 2026-07-22 17:23:19 +00:00
5bd0d59aa6
P1 fixes (this sprint): - P1-6: Extract sensing-server modules (cli, types, csi, pose) from main.rs - P1-7: DDA ray march for tomography — O(max(n)) replaces O(n^3) voxel scan - P1-8: Batch neural inference — Tensor::stack/split for single GPU call - P1-10: Eliminate 112KB/frame alloc — islice replaces deque→list copy P2 fixes (this quarter): - P2-11: Python unit tests for 8 modules (rate_limit, auth, error_handler, pose_service, stream_service, hardware_service, health_check, metrics) - P2-13: MAT simulated data safety guard — blocking overlay + pulsing banner - P2-14: Wire token blacklist into auth verification + logout endpoint - P2-15: Frame budget benchmark — confirms pipeline well under 50ms budget Addresses 8 of 10 remaining issues from QE analysis (ADR-080). Co-Authored-By: claude-flow <ruv@ruv.net>
91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
import { create } from 'zustand';
|
|
import type { Alert, DisasterEvent, ScanZone, Survivor } from '@/types/mat';
|
|
|
|
export interface MatState {
|
|
events: DisasterEvent[];
|
|
zones: ScanZone[];
|
|
survivors: Survivor[];
|
|
alerts: Alert[];
|
|
selectedEventId: string | null;
|
|
/** Whether data comes from real sensors or simulation. */
|
|
dataSource: 'real' | 'simulated';
|
|
/** Whether the user has dismissed the simulation warning overlay. */
|
|
simulationAcknowledged: boolean;
|
|
upsertEvent: (event: DisasterEvent) => void;
|
|
addZone: (zone: ScanZone) => void;
|
|
upsertSurvivor: (survivor: Survivor) => void;
|
|
addAlert: (alert: Alert) => void;
|
|
setSelectedEvent: (id: string | null) => void;
|
|
setDataSource: (source: 'real' | 'simulated') => void;
|
|
acknowledgeSimulation: () => void;
|
|
}
|
|
|
|
export const useMatStore = create<MatState>((set) => ({
|
|
events: [],
|
|
zones: [],
|
|
survivors: [],
|
|
alerts: [],
|
|
selectedEventId: null,
|
|
dataSource: 'simulated',
|
|
simulationAcknowledged: false,
|
|
|
|
upsertEvent: (event) => {
|
|
set((state) => {
|
|
const index = state.events.findIndex((item) => item.event_id === event.event_id);
|
|
if (index === -1) {
|
|
return { events: [...state.events, event] };
|
|
}
|
|
const events = [...state.events];
|
|
events[index] = event;
|
|
return { events };
|
|
});
|
|
},
|
|
|
|
addZone: (zone) => {
|
|
set((state) => {
|
|
const index = state.zones.findIndex((item) => item.id === zone.id);
|
|
if (index === -1) {
|
|
return { zones: [...state.zones, zone] };
|
|
}
|
|
const zones = [...state.zones];
|
|
zones[index] = zone;
|
|
return { zones };
|
|
});
|
|
},
|
|
|
|
upsertSurvivor: (survivor) => {
|
|
set((state) => {
|
|
const index = state.survivors.findIndex((item) => item.id === survivor.id);
|
|
if (index === -1) {
|
|
return { survivors: [...state.survivors, survivor] };
|
|
}
|
|
const survivors = [...state.survivors];
|
|
survivors[index] = survivor;
|
|
return { survivors };
|
|
});
|
|
},
|
|
|
|
addAlert: (alert) => {
|
|
set((state) => {
|
|
if (state.alerts.some((item) => item.id === alert.id)) {
|
|
return {
|
|
alerts: state.alerts.map((item) => (item.id === alert.id ? alert : item)),
|
|
};
|
|
}
|
|
return { alerts: [...state.alerts, alert] };
|
|
});
|
|
},
|
|
|
|
setSelectedEvent: (id) => {
|
|
set({ selectedEventId: id });
|
|
},
|
|
|
|
setDataSource: (source) => {
|
|
set({ dataSource: source });
|
|
},
|
|
|
|
acknowledgeSimulation: () => {
|
|
set({ simulationAcknowledged: true });
|
|
},
|
|
}));
|