mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
gordon
This commit is contained in:
@@ -10,6 +10,7 @@ const SessionContext = createContext({
|
||||
adminLogs: [],
|
||||
llmCommentaryState: null,
|
||||
llmCommentaryStatus: null,
|
||||
visionHumanState: null,
|
||||
identifySession: async () => {},
|
||||
login: async () => {},
|
||||
setRole: async () => {},
|
||||
@@ -35,6 +36,11 @@ const SessionContext = createContext({
|
||||
setAudioLevels: async () => {},
|
||||
setPrivateSafety: async () => {},
|
||||
llmControl: async () => {},
|
||||
getVisionHumanState: async () => {},
|
||||
updateVisionHumanConfig: async () => {},
|
||||
testVisionHumanTts: async () => {},
|
||||
testVisionHumanDiscord: async () => {},
|
||||
clearVisionHumanState: async () => {},
|
||||
});
|
||||
|
||||
function useAckEmitter(socket) {
|
||||
@@ -61,6 +67,7 @@ export function SessionProvider({ children }) {
|
||||
const [adminLogs, setAdminLogs] = useState([]);
|
||||
const [llmCommentaryState, setLlmCommentaryState] = useState(null);
|
||||
const [llmCommentaryStatus, setLlmCommentaryStatus] = useState(null);
|
||||
const [visionHumanState, setVisionHumanState] = useState(null);
|
||||
const [alerts, setAlerts] = useState([]);
|
||||
const [connected, setConnected] = useState(socket.connected);
|
||||
|
||||
@@ -78,6 +85,9 @@ export function SessionProvider({ children }) {
|
||||
useEffect(() => {
|
||||
function handleSession(payload) {
|
||||
setSession(payload);
|
||||
if (payload?.visionHumanDetection) {
|
||||
setVisionHumanState(payload.visionHumanDetection);
|
||||
}
|
||||
}
|
||||
function handleLogInit(entries = []) {
|
||||
setLogs(entries);
|
||||
@@ -104,6 +114,10 @@ export function SessionProvider({ children }) {
|
||||
socket.on('adminlog:init', handleAdminLogInit);
|
||||
socket.on('adminlog:entry', handleAdminLogEntry);
|
||||
socket.on('llm:state', handleLlmState);
|
||||
socket.on('vision:human:state', (payload = null) => {
|
||||
const state = payload && typeof payload === 'object' ? payload : null;
|
||||
setVisionHumanState(state);
|
||||
});
|
||||
socket.on('alert:new', (payload = {}) => {
|
||||
setAlerts((prev) => [
|
||||
...prev.slice(-49),
|
||||
@@ -120,6 +134,7 @@ export function SessionProvider({ children }) {
|
||||
socket.off('adminlog:init', handleAdminLogInit);
|
||||
socket.off('adminlog:entry', handleAdminLogEntry);
|
||||
socket.off('llm:state', handleLlmState);
|
||||
socket.off('vision:human:state');
|
||||
socket.off('alert:new');
|
||||
};
|
||||
}, [socket]);
|
||||
@@ -162,6 +177,12 @@ export function SessionProvider({ children }) {
|
||||
emitWithAck('session:privateSafety:set', { roverId, safety }),
|
||||
llmControl: (action, controls = {}) =>
|
||||
emitWithAck('llm:control', { controls: { action, ...controls } }),
|
||||
getVisionHumanState: () => emitWithAck('vision:human:getState'),
|
||||
updateVisionHumanConfig: (nextConfig = {}) =>
|
||||
emitWithAck('vision:human:updateConfig', { config: nextConfig }),
|
||||
testVisionHumanTts: () => emitWithAck('vision:human:testTts'),
|
||||
testVisionHumanDiscord: () => emitWithAck('vision:human:testDiscord'),
|
||||
clearVisionHumanState: () => emitWithAck('vision:human:clear'),
|
||||
pushAlert: (alert) =>
|
||||
setAlerts((prev) => [
|
||||
...prev.slice(-49),
|
||||
@@ -179,10 +200,21 @@ export function SessionProvider({ children }) {
|
||||
adminLogs,
|
||||
llmCommentaryState,
|
||||
llmCommentaryStatus,
|
||||
visionHumanState,
|
||||
alerts,
|
||||
...actions,
|
||||
}),
|
||||
[actions, adminLogs, alerts, connected, llmCommentaryState, llmCommentaryStatus, logs, session],
|
||||
[
|
||||
actions,
|
||||
adminLogs,
|
||||
alerts,
|
||||
connected,
|
||||
llmCommentaryState,
|
||||
llmCommentaryStatus,
|
||||
logs,
|
||||
session,
|
||||
visionHumanState,
|
||||
],
|
||||
);
|
||||
|
||||
return <SessionContext.Provider value={value}>{children}</SessionContext.Provider>;
|
||||
|
||||
Reference in New Issue
Block a user