Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions app/interview/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ export default function InterviewCanvasPage({ params }: PageProps) {
const canvasStateRef = useRef<CanvasStateRef | null>(null);
const saveAbortControllerRef = useRef<AbortController | null>(null);

const handleConstraintChange = useCallback((change: IConstraintChange) => {
setSession(prev => {
if (!prev) return prev;
const existing = prev.constraintChanges || [];
if (existing.some(item => item.id === change.id)) {
return prev;
}
return {
...prev,
constraintChanges: [...existing, change]
};
});
}, []);

// Interview timer
const timer = useInterviewTimer({
timeLimit: session?.timeLimit || 45,
Expand All @@ -83,19 +97,7 @@ export default function InterviewCanvasPage({ params }: PageProps) {
stateRef: canvasStateRef,
timeRemaining: timer.minutes,
initialMessages: session?.aiMessages || [],
onConstraintChange: (change) => {
setSession(prev => {
if (!prev) return prev;
const existing = prev.constraintChanges || [];
if (existing.some(item => item.id === change.id)) {
return prev;
}
return {
...prev,
constraintChanges: [...existing, change]
};
});
}
onConstraintChange: handleConstraintChange
});

// Fetch session data
Expand Down
9 changes: 6 additions & 3 deletions src/hooks/useInterviewAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ export function useInterviewAI({
}: UseInterviewAIProps) {
const [messages, setMessages] = useState<AIMessage[]>(() => initialMessages);
const [isThinking, setIsThinking] = useState(false);
const hasInitializedMessagesRef = useRef(false);

useEffect(() => {
if (initialMessages.length > 0) {
setMessages(initialMessages);
}
if (hasInitializedMessagesRef.current) return;
if (initialMessages.length === 0) return;

setMessages(initialMessages);
hasInitializedMessagesRef.current = true;
}, [initialMessages]);

const isThinkingRef = useRef(isThinking);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/db/models/InterviewSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const ConstraintChangeSchema = new Schema(
description: { type: String, required: true },
severity: { type: String, enum: ['moderate', 'high'], required: true },
introducedAt: { type: Date, required: true },
introducedAtMinute: { type: Number, required: true },
introducedAtMinute: { type: Number, required: true, min: 0 },
status: {
type: String,
enum: ['active', 'acknowledged', 'addressed'],
Expand Down
5 changes: 4 additions & 1 deletion src/lib/evaluation/scoringEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export function combineEvaluations(
score: reasoning.score,
strengths: reasoning.strengths,
weaknesses: reasoning.weaknesses,
suggestions: reasoning.suggestions
suggestions: reasoning.suggestions,
adaptationSummary: reasoning.adaptationSummary,
addressedConstraintChanges: reasoning.addressedConstraintChanges,
missedConstraintChanges: reasoning.missedConstraintChanges
},
finalScore,
weights: WEIGHTS
Expand Down
Loading