Add experiment logs to the monitoring page #48

Merged
0950726 merged 122 commits from feat/experiment-logs into dev 2026-01-28 10:16:00 +00:00
3 changed files with 28 additions and 5 deletions
Showing only changes of commit 39f013c47f - Show all commits

View File

@@ -119,7 +119,7 @@ export const StatusList: React.FC<StatusListProps> = ({ title, items, type }) =>
let isAchieved = item.achieved;
const showIndicator = type !== 'norm';
const canOverride = showIndicator && !isAchieved;
const isCurrentGoal = type === 'goal' && item.isCurrent;
const handleOverrideClick = () => {
if (!canOverride) return;
let contextValue = String(item.id);
@@ -136,7 +136,14 @@ export const StatusList: React.FC<StatusListProps> = ({ title, items, type }) =>
{isAchieved ? "✔️" : "❌"}
</span>
)}
<span className={styles.itemDescription}>
<span
className={styles.itemDescription}
style={{
textDecoration: isCurrentGoal ? 'underline' : 'none',
fontWeight: isCurrentGoal ? 'bold' : 'normal',
color: isCurrentGoal ? '#007bff' : 'inherit'
}}
>
{item.description || item.label || item.norm}
</span>
</li>

View File

@@ -17,6 +17,7 @@ const MonitoringPage: React.FC = () => {
// Can be used to block actions until feedback from CB.
const [loading, setLoading] = React.useState(false);
const [activeIds, setActiveIds] = React.useState<Record<string, boolean>>({});
const [goalIndex, setGoalIndex] = React.useState(0);
const phaseIds = getPhaseIds();
const [phaseIndex, setPhaseIndex] = React.useState(0);
@@ -29,11 +30,25 @@ const MonitoringPage: React.FC = () => {
const newIndex = allIds.indexOf(data.phase_id);
if (newIndex !== -1) {
setPhaseIndex(newIndex);
setGoalIndex(0); //when phase change we reset the index
}
}
else if (data.type === 'trigger_update' || data.type === 'goal_update') {
else if (data.type === 'goal_update') {
// We find which goal in the current phase matches this ID
const currentPhaseGoals = getGoalsInPhase(phaseIds[phaseIndex]);
const gIndex = currentPhaseGoals.findIndex((g: any) => g.id === data.id);
if (gIndex !== -1) {
setGoalIndex(gIndex);
console.log(`Goal index updated to ${gIndex} for goal ID ${data.id}`);
}
setActiveIds((prev) => ({
...prev,
[data.id]: true
}));
}
else if (data.type === 'trigger_update') {
setActiveIds((prev) => ({
...prev,
[data.id]: data.achieved // data.id is de key, achieved is true/false

View File

@@ -31,6 +31,7 @@ export function useExperimentLogger(onUpdate?: (data: any) => void) {
try {
const parsedData = JSON.parse(event.data);
if (onUpdate) {
console.log(event.data);
onUpdate(parsedData);
}
} catch (err) {