summaryrefslogtreecommitdiff
path: root/makima/frontend/src/contexts/SupervisorQuestionsContext.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'makima/frontend/src/contexts/SupervisorQuestionsContext.tsx')
-rw-r--r--makima/frontend/src/contexts/SupervisorQuestionsContext.tsx20
1 files changed, 20 insertions, 0 deletions
diff --git a/makima/frontend/src/contexts/SupervisorQuestionsContext.tsx b/makima/frontend/src/contexts/SupervisorQuestionsContext.tsx
index aa1bb12..712c755 100644
--- a/makima/frontend/src/contexts/SupervisorQuestionsContext.tsx
+++ b/makima/frontend/src/contexts/SupervisorQuestionsContext.tsx
@@ -4,10 +4,14 @@ import { useAuth } from "./AuthContext";
interface SupervisorQuestionsContextValue {
pendingQuestions: PendingQuestion[];
+ /** Questions that are pending but not dismissed from notifications */
+ notificationQuestions: PendingQuestion[];
loading: boolean;
error: string | null;
refreshQuestions: () => Promise<void>;
submitAnswer: (questionId: string, response: string) => Promise<boolean>;
+ /** Dismiss a question from the notification (but keep it pending in task output) */
+ dismissNotification: (questionId: string) => void;
}
const SupervisorQuestionsContext = createContext<SupervisorQuestionsContextValue | null>(null);
@@ -15,9 +19,17 @@ const SupervisorQuestionsContext = createContext<SupervisorQuestionsContextValue
export function SupervisorQuestionsProvider({ children }: { children: ReactNode }) {
const { isAuthenticated } = useAuth();
const [pendingQuestions, setPendingQuestions] = useState<PendingQuestion[]>([]);
+ const [dismissedIds, setDismissedIds] = useState<Set<string>>(new Set());
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
+ // Questions that should show in notifications (not dismissed)
+ const notificationQuestions = pendingQuestions.filter(q => !dismissedIds.has(q.questionId));
+
+ const dismissNotification = useCallback((questionId: string) => {
+ setDismissedIds(prev => new Set(prev).add(questionId));
+ }, []);
+
const refreshQuestions = useCallback(async () => {
if (!isAuthenticated) return;
@@ -44,6 +56,12 @@ export function SupervisorQuestionsProvider({ children }: { children: ReactNode
if (result.success) {
// Remove the question from local state
setPendingQuestions(prev => prev.filter(q => q.questionId !== questionId));
+ // Also clean up dismissed state
+ setDismissedIds(prev => {
+ const next = new Set(prev);
+ next.delete(questionId);
+ return next;
+ });
}
return result.success;
} catch (err) {
@@ -74,10 +92,12 @@ export function SupervisorQuestionsProvider({ children }: { children: ReactNode
<SupervisorQuestionsContext.Provider
value={{
pendingQuestions,
+ notificationQuestions,
loading,
error,
refreshQuestions,
submitAnswer,
+ dismissNotification,
}}
>
{children}