summaryrefslogtreecommitdiff
path: root/makima/frontend/src/components/SupervisorQuestionNotification.tsx
blob: 9c561885b35dbaac757bdcca96d29ea7cea1c5b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { useNavigate } from "react-router";
import { useSupervisorQuestions } from "../contexts/SupervisorQuestionsContext";
import { useUserSettings } from "../hooks/useUserSettings";
import type { PendingQuestion } from "../lib/api";

export function SupervisorQuestionNotification() {
  const navigate = useNavigate();
  const { notificationQuestions, dismissNotification } = useSupervisorQuestions();
  const { settings } = useUserSettings();
  const documentMode = settings?.documentModeEnabled ?? false;

  // Filter out contract_complete questions - they are displayed on the task page instead
  const filteredQuestions = notificationQuestions.filter(
    (q) => q.questionType !== "contract_complete"
  );

  if (filteredQuestions.length === 0) {
    return null;
  }

  const handleGoToTask = (q: PendingQuestion) => {
    dismissNotification(q.questionId);
    // In document mode, route directly to the directive folder page with
    // the task selected — that's the canonical surface where the question
    // is answered (same comment/interrupt UI as the task stream). Fall
    // back to /exec for non-doc-mode users or for tasks not tied to a
    // directive.
    if (documentMode && q.directiveId) {
      navigate(`/directives/${q.directiveId}?task=${q.taskId}`);
    } else {
      navigate(`/exec/${q.taskId}`);
    }
  };

  return (
    <div className="fixed bottom-4 right-4 z-50 max-w-md space-y-2">
      {filteredQuestions.map((question) => (
        <div
          key={question.questionId}
          className="bg-[#0d1b2d] border border-amber-500/50 rounded-lg shadow-lg overflow-hidden"
        >
          {/* Header */}
          <div className="flex items-center justify-between px-4 py-3 bg-amber-900/30">
            <div className="flex items-center gap-2">
              <span className="text-amber-400 text-lg">?</span>
              <span className="font-mono text-sm text-amber-300 uppercase">
                Task needs input
              </span>
            </div>
            <button
              onClick={() => handleGoToTask(question)}
              className="px-3 py-1 font-mono text-xs text-amber-400 border border-amber-500/30 hover:border-amber-400/50 hover:bg-amber-900/20 transition-colors uppercase"
            >
              View Task
            </button>
          </div>

          {/* Question preview */}
          <div className="px-4 py-3">
            {question.context && (
              <div className="text-xs text-[#8b949e] font-mono mb-1 uppercase">
                {question.context}
              </div>
            )}
            <p className="text-sm text-[#dbe7ff] font-mono line-clamp-2">
              {question.question}
            </p>
          </div>
        </div>
      ))}
    </div>
  );
}