chore: among other things, fixed connection issue

fix: connection issue
conditional norm now able to undo
 and are updated via pings
goals are able to be achieved out of turn

ref: N25B-400
This commit is contained in:
Pim Hutting
2026-01-16 12:57:22 +01:00
parent a98a87f8ce
commit c4e3ab27b2
5 changed files with 126 additions and 59 deletions

View File

@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import styles from './MonitoringPage.module.css';
import { sendUserInterrupt } from './MonitoringPageAPI';
import { sendAPICall } from './MonitoringPageAPI';
// --- GESTURE COMPONENT ---
export const GestureControls: React.FC = () => {
@@ -23,7 +23,7 @@ export const GestureControls: React.FC = () => {
>
{gestures.map(g => <option key={g.value} value={g.value}>{g.label}</option>)}
</select>
<button onClick={() => sendUserInterrupt("gesture", selectedGesture)}>
<button onClick={() => sendAPICall("gesture", selectedGesture)}>
Actuate
</button>
</div>
@@ -47,7 +47,7 @@ export const SpeechPresets: React.FC = () => {
<li key={i}>
<button
className={styles.speechBtn}
onClick={() => sendUserInterrupt("speech", phrase.text)}
onClick={() => sendAPICall("speech", phrase.text)}
>
"{phrase.label}"
</button>
@@ -64,7 +64,7 @@ export const DirectSpeechInput: React.FC = () => {
const handleSend = () => {
if (!text.trim()) return;
sendUserInterrupt("speech", text);
sendAPICall("speech", text);
setText(""); // Clear after sending
};
@@ -92,6 +92,7 @@ type StatusItem = {
description?: string;
label?: string;
norm?: string;
name?: string;
};
interface StatusListProps {
@@ -99,6 +100,7 @@ interface StatusListProps {
items: StatusItem[];
type: 'goal' | 'trigger' | 'norm'| 'cond_norm';
activeIds: Record<string, boolean>;
setActiveIds?: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
currentGoalIndex?: number;
}
@@ -108,6 +110,7 @@ export const StatusList: React.FC<StatusListProps> = ({
items,
type,
activeIds,
setActiveIds,
currentGoalIndex // Destructure this prop
}) => {
return (
@@ -118,19 +121,23 @@ export const StatusList: React.FC<StatusListProps> = ({
if (item.id === undefined) return null;
const isActive = !!activeIds[item.id];
const showIndicator = type !== 'norm';
const canOverride = showIndicator && !isActive || (type === 'cond_norm' && isActive);
const isCurrentGoal = type === 'goal' && idx === currentGoalIndex;
const canOverride = (showIndicator && !isActive) || (type === 'cond_norm' && isActive);
const handleOverrideClick = () => {
if (!canOverride) return;
if (type === 'cond_norm' && isActive){
{/* Unachieve conditional norm */}
sendUserInterrupt("override_unachieve", String(item.id));
sendAPICall("override_unachieve", String(item.id));
}
else {
if(type === 'goal')
if(setActiveIds)
{setActiveIds(prev => ({ ...prev, [String(item.id)]: true }));}
sendUserInterrupt("override", String(item.id));
sendAPICall("override", String(item.id));
}
};
@@ -156,7 +163,7 @@ export const StatusList: React.FC<StatusListProps> = ({
borderRadius: '4px'
}}
>
{item.description || item.label || item.norm}
{item.name || item.description || item.label || item.norm}
{isCurrentGoal && " (Current)"}
</span>
</li>