Skip to content

Staging#91

Merged
Shashank0701-byte merged 2 commits intomainfrom
staging
Mar 26, 2026
Merged

Staging#91
Shashank0701-byte merged 2 commits intomainfrom
staging

Conversation

@Shashank0701-byte
Copy link
Copy Markdown
Owner

@Shashank0701-byte Shashank0701-byte commented Mar 26, 2026

Summary by CodeRabbit

  • New Features
    • Interviews now support live constraint changes introduced during sessions
    • Interview interface displays active constraints with severity levels
    • Results include adaptability analysis showing which constraints were addressed or missed
    • Candidate reasoning evaluations now assess how well they adapt to dynamic constraints

- Real time interview constraint changes
- Interviewer changes the constraints after when 30-50% of the interview is done
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 26, 2026

Deploy Preview for system-craft-staging ready!

Name Link
🔨 Latest commit 3b9b238
🔍 Latest deploy log https://app.netlify.com/projects/system-craft-staging/deploys/69c52a63878a500008e0bb92
😎 Deploy Preview https://deploy-preview-91--system-craft-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
system-craft Ready Ready Preview, Comment Mar 26, 2026 1:03pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

This PR introduces a "Live Constraint Changes" feature that dynamically triggers design constraints during interviews. It adds domain models for constraint metadata, backend logic to generate and persist constraint changes during hint requests, extends the reasoning evaluator to assess candidate adaptation to constraints, and updates UI components to display both constraint information and adaptation analysis.

Changes

Cohort / File(s) Summary
Domain Model & Schema
src/lib/db/models/InterviewSession.ts
Added new exported types (ConstraintChangeType, ConstraintChangeSeverity, ConstraintChangeStatus) and interface (IConstraintChange) with fields for metadata, timing, status, and impact areas. Extended IInterviewSession with optional constraintChanges array and enhanced reasoning structure with adaptationSummary, addressedConstraintChanges, and missedConstraintChanges fields. Added corresponding Mongoose schemas with validation and defaults.
Backend API Routes
app/api/interview/[id]/hint/route.ts
Added constraint change generation and triggering logic with new helpers (generateConstraintChange(), shouldTriggerConstraintChange()) and progress constants. Implemented conditional early-return path when constraints are triggered. Updated AI prompt to include constraint history. Extended response schema to include optional constraintChange field.
Evaluation & Reasoning
src/lib/evaluation/reasoningEvaluator.ts, app/api/interview/[id]/evaluate/route.ts
Updated evaluateReasoning() to accept constraintChanges parameter and incorporate constraint data into AI prompt. Extended output contract with adaptation fields. Updated evaluate route to pass constraint changes to evaluator.
Session Response
app/api/interview/[id]/route.ts
Extended GET endpoint response to include constraintChanges from session data with default empty array.
Hook Integration
src/hooks/useInterviewAI.ts
Added optional onConstraintChange callback to hook signature and props type. Enhanced hint response handling to invoke callback when constraint change is present. Added effect to reset messages on initialMessages change.
Interview Page & Components
app/interview/[id]/page.tsx, components/interview/QuestionPanel.tsx
Extended InterviewSessionData with optional constraintChanges field. Updated page.tsx to pass onConstraintChange callback to hook and constraint changes to QuestionPanel. Extended QuestionPanel to accept and conditionally render constraint changes with severity-based styling.
Results Page
app/interview/[id]/result/page.tsx
Extended InterviewSessionData with constraintChanges. Added conditional rendering of "Live Constraint Changes" section listing constraint metadata and "Adaptability" block showing adaptationSummary and categorized addressed/missed constraint changes.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client / Frontend
    participant HintAPI as Hint API Route
    participant SessionDB as Session DB
    participant Evaluator as Reasoning Evaluator
    participant Hook as useInterviewAI Hook

    Client->>HintAPI: POST /hint (with current progress)
    HintAPI->>HintAPI: shouldTriggerConstraintChange() → true
    HintAPI->>HintAPI: generateConstraintChange()
    HintAPI->>SessionDB: session.constraintChanges.push(newConstraint)
    HintAPI->>SessionDB: await session.save()
    HintAPI->>Client: { constraintChange: {...}, messages: [...] }
    Client->>Hook: Response received
    Hook->>Hook: onConstraintChange(constraintChange)
    Hook->>Client: Update local session.constraintChanges
    Client->>Client: Render updated constraint display

    Note over Client,Evaluator: Later: Interview evaluation
    Client->>Evaluator: evaluateReasoning(question, snapshot, results, constraintChanges)
    Evaluator->>Evaluator: Include constraints in prompt
    Evaluator->>Evaluator: Analyze adaptation response
    Evaluator->>Client: { adaptationSummary, addressedConstraintChanges, missedConstraintChanges }
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • Staging #50: Introduced evaluateReasoning and the evaluation route; this PR extends those by updating the signature to include constraint change handling.
  • Staging #39: Established the interview evaluation code paths and InterviewSession schema; this PR adds constraint-related fields and extends those same areas.
  • feat(interview): implement real-time AI interviewer #59: Implemented AI interviewer and hint route functionality; this PR builds on that by adding constraint change triggering and propagation within the same hint flow.

Poem

🐰 Constraints emerge mid-interview sprint,
As progress climbs and designs get a hint,
The evaluator learns what candidates address,
Adaptation unfolds—no more, no less! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The pull request title 'Staging' is vague and does not convey meaningful information about the changeset, which implements a comprehensive live constraint changes feature. Replace with a descriptive title summarizing the main change, such as 'Add live constraint changes feature to interview sessions' or 'Implement dynamic constraint tracking in interview evaluation'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch staging

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/api/interview/[id]/evaluate/route.ts (1)

82-90: ⚠️ Potential issue | 🟠 Major

Missing constraint adaptation fields in final evaluation document.

The evaluateReasoning function returns adaptationSummary, addressedConstraintChanges, and missedConstraintChanges, but combineEvaluations in src/lib/evaluation/scoringEngine.ts does not include these fields in the reasoning object. This causes the constraint adaptation data to be discarded before persistence, and the result page will always display fallback text ("no adaptation summary was generated") regardless of whether the AI generated adaptation feedback.

Update combineEvaluations to include the missing fields:

Fix
reasoning: {
    score: reasoning.score,
    strengths: reasoning.strengths,
    weaknesses: reasoning.weaknesses,
    suggestions: reasoning.suggestions,
    adaptationSummary: reasoning.adaptationSummary,
    addressedConstraintChanges: reasoning.addressedConstraintChanges,
    missedConstraintChanges: reasoning.missedConstraintChanges
},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/api/interview/`[id]/evaluate/route.ts around lines 82 - 90, The final
evaluation omits constraint-adaptation fields returned by evaluateReasoning, so
update combineEvaluations (in scoringEngine.ts) to include adaptationSummary,
addressedConstraintChanges, and missedConstraintChanges inside the returned
reasoning object (alongside score, strengths, weaknesses, suggestions) so those
values are persisted and shown; locate the combineEvaluations function and add
the three fields (adaptationSummary, addressedConstraintChanges,
missedConstraintChanges) to the reasoning property of the combined evaluation
object.
🧹 Nitpick comments (3)
src/hooks/useInterviewAI.ts (1)

42-46: Potential message state reset on re-fetch.

This useEffect resets messages whenever initialMessages changes and has content. If the parent component re-fetches session data (e.g., after a network reconnection), this could overwrite locally-added messages that haven't been persisted yet.

Consider comparing array contents rather than just length, or removing this effect if initial sync is only needed on mount:

♻️ Option 1: Remove effect if initial sync happens via useState initializer

The initial state is already set via useState<AIMessage[]>(() => initialMessages). If the intent is only to initialize once, this effect may be unnecessary.

-    useEffect(() => {
-        if (initialMessages.length > 0) {
-            setMessages(initialMessages);
-        }
-    }, [initialMessages]);
♻️ Option 2: Track if initial load completed to avoid resetting user messages
+    const hasInitializedRef = useRef(false);
+
     useEffect(() => {
-        if (initialMessages.length > 0) {
+        if (!hasInitializedRef.current && initialMessages.length > 0) {
             setMessages(initialMessages);
+            hasInitializedRef.current = true;
         }
     }, [initialMessages]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/useInterviewAI.ts` around lines 42 - 46, The useEffect that resets
messages when initialMessages changes can overwrite local, unsaved messages;
remove this effect or guard it to run only once on mount: stop using the effect
that references initialMessages and setMessages, and instead rely on the
useState initializer useState<AIMessage[]>(() => initialMessages) for the
initial sync, or add a boolean flag (e.g., hasInitialized) checked/updated by
the effect so useEffect(() => { if (!hasInitialized) {
setMessages(initialMessages); setHasInitialized(true); } }, [initialMessages])
runs only the first time; update references to messages, setMessages, and
initialMessages accordingly.
app/interview/[id]/page.tsx (1)

86-98: Consider memoizing the onConstraintChange callback.

The onConstraintChange callback is defined inline, creating a new function reference on every render. This could trigger unnecessary re-invocations of the useEffect in useInterviewAI that depends on onConstraintChange (via requestHint).

♻️ Proposed fix using useCallback
+    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]
+            };
+        });
+    }, []);

     // AI Interviewer hook
     const ai = useInterviewAI({
         sessionId: id,
         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
     });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/interview/`[id]/page.tsx around lines 86 - 98, The inline
onConstraintChange callback recreates a new function each render and can cause
downstream effects (like useInterviewAI/useEffect that depends on requestHint)
to re-run; wrap this handler in React.useCallback to memoize it (e.g., memoize
the function that calls setSession and checks/updates constraintChanges) and
include only necessary stable dependencies (setSession is stable so the deps can
be [] or [setSession] depending on your hooks setup). Ensure you replace the
inline definition passed to the component with the memoized callback name so its
identity remains stable across renders and update any dependent effects if
required.
src/lib/db/models/InterviewSession.ts (1)

124-146: Consider adding validation bounds for introducedAtMinute.

The schema is well-structured with proper enum validation. One minor improvement: introducedAtMinute could benefit from a minimum bound to prevent invalid negative values.

🛡️ Optional: Add min validation
-        introducedAtMinute: { type: Number, required: true },
+        introducedAtMinute: { type: Number, required: true, min: 0 },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/db/models/InterviewSession.ts` around lines 124 - 146, The
introducedAtMinute field in ConstraintChangeSchema allows invalid negative (and
out-of-range) values; update the introducedAtMinute definition in
ConstraintChangeSchema to include numeric validation bounds (e.g., add min: 0
and max: 59) so minutes are constrained to valid minute values, and ensure
required: true remains set; adjust any related type/interface if present to
reflect these bounds.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@app/api/interview/`[id]/evaluate/route.ts:
- Around line 82-90: The final evaluation omits constraint-adaptation fields
returned by evaluateReasoning, so update combineEvaluations (in
scoringEngine.ts) to include adaptationSummary, addressedConstraintChanges, and
missedConstraintChanges inside the returned reasoning object (alongside score,
strengths, weaknesses, suggestions) so those values are persisted and shown;
locate the combineEvaluations function and add the three fields
(adaptationSummary, addressedConstraintChanges, missedConstraintChanges) to the
reasoning property of the combined evaluation object.

---

Nitpick comments:
In `@app/interview/`[id]/page.tsx:
- Around line 86-98: The inline onConstraintChange callback recreates a new
function each render and can cause downstream effects (like
useInterviewAI/useEffect that depends on requestHint) to re-run; wrap this
handler in React.useCallback to memoize it (e.g., memoize the function that
calls setSession and checks/updates constraintChanges) and include only
necessary stable dependencies (setSession is stable so the deps can be [] or
[setSession] depending on your hooks setup). Ensure you replace the inline
definition passed to the component with the memoized callback name so its
identity remains stable across renders and update any dependent effects if
required.

In `@src/hooks/useInterviewAI.ts`:
- Around line 42-46: The useEffect that resets messages when initialMessages
changes can overwrite local, unsaved messages; remove this effect or guard it to
run only once on mount: stop using the effect that references initialMessages
and setMessages, and instead rely on the useState initializer
useState<AIMessage[]>(() => initialMessages) for the initial sync, or add a
boolean flag (e.g., hasInitialized) checked/updated by the effect so
useEffect(() => { if (!hasInitialized) { setMessages(initialMessages);
setHasInitialized(true); } }, [initialMessages]) runs only the first time;
update references to messages, setMessages, and initialMessages accordingly.

In `@src/lib/db/models/InterviewSession.ts`:
- Around line 124-146: The introducedAtMinute field in ConstraintChangeSchema
allows invalid negative (and out-of-range) values; update the introducedAtMinute
definition in ConstraintChangeSchema to include numeric validation bounds (e.g.,
add min: 0 and max: 59) so minutes are constrained to valid minute values, and
ensure required: true remains set; adjust any related type/interface if present
to reflect these bounds.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: beccf8c2-df86-4337-bce3-6b2d0349b2b1

📥 Commits

Reviewing files that changed from the base of the PR and between 820f7bc and 3b9b238.

📒 Files selected for processing (9)
  • app/api/interview/[id]/evaluate/route.ts
  • app/api/interview/[id]/hint/route.ts
  • app/api/interview/[id]/route.ts
  • app/interview/[id]/page.tsx
  • app/interview/[id]/result/page.tsx
  • components/interview/QuestionPanel.tsx
  • src/hooks/useInterviewAI.ts
  • src/lib/db/models/InterviewSession.ts
  • src/lib/evaluation/reasoningEvaluator.ts

@Shashank0701-byte Shashank0701-byte merged commit 7a5cbbf into main Mar 26, 2026
9 checks passed
This was referenced Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant