Skip to content

Commit 1747758

Browse files
Merge pull request #1 from rohitmane-dev/sync-upstream
Sync upstream
2 parents c5ece37 + 52af86e commit 1747758

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+9653
-1250
lines changed

.gemini/AI_TUTOR_CRITICAL_FIXES.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# AI Tutor Critical Fixes - Typing & Video Issues
2+
3+
## Date: 2026-02-17 01:16 IST
4+
5+
## Issues Fixed
6+
7+
### 1. ✅ Typing Rendering Problem (FIXED)
8+
**Problem:** Text rendering was breaking/glitching during speech synthesis
9+
**Root Cause:** Speech was starting immediately with typing, causing React rendering conflicts
10+
11+
**Solution:**
12+
- Added 500ms delay before speech starts
13+
- Allows typing animation to stabilize first
14+
- Prevents rendering interference
15+
16+
**Code:**
17+
```javascript
18+
// Speak non-code stages while typing - with delay to prevent rendering issues
19+
if (stage.type !== 'CODE') {
20+
// Delay speech slightly to let typing animation start smoothly
21+
setTimeout(() => {
22+
speak(stage.content, `stage-${currentStageIndex}`);
23+
}, 500);
24+
}
25+
```
26+
27+
**Result:** Smooth typing animation without visual glitches ✅
28+
29+
---
30+
31+
### 2. ✅ YouTube Video Not Embedding (FIXED)
32+
**Problem:** Videos showing as raw links instead of playable embeds
33+
**Root Cause:** Video player only rendered during typing (SequentialFlow), not for completed messages
34+
35+
**Solution:**
36+
- Added video extraction for completed messages
37+
- Renders ReactPlayer component after message content
38+
- Maintains same styling as typing video display
39+
40+
**Code:**
41+
```javascript
42+
{(() => {
43+
const videoMatch = msg.content.match(/\[\[VIDEO:\s*(https?:\/\/[^\]]+)\]\]/);
44+
if (videoMatch) {
45+
return (
46+
<div className="mt-6 overflow-hidden rounded-2xl border border-border bg-card shadow-xl w-full max-w-full">
47+
<div className="p-3 bg-red-500/5 border-b flex items-center justify-between">
48+
<div className="flex items-center gap-2">
49+
<div className="p-1 bg-red-500 rounded-lg shrink-0">
50+
<Youtube className="w-4 h-4 text-white" />
51+
</div>
52+
<span className="text-[10px] font-bold uppercase tracking-widest text-red-600 truncate">Mastery Tutorial</span>
53+
</div>
54+
</div>
55+
<div className="w-full relative bg-black aspect-video">
56+
<ReactPlayer
57+
url={videoMatch[1]}
58+
width="100%"
59+
height="100%"
60+
style={{ position: 'absolute', top: 0, left: 0 }}
61+
controls={true}
62+
/>
63+
</div>
64+
</div>
65+
);
66+
}
67+
return null;
68+
})()}
69+
```
70+
71+
**Result:** Videos now embed properly in both typing and completed states ✅
72+
73+
---
74+
75+
### 3. ✅ Video Display Timing (IMPROVED)
76+
**Problem:** Video was showing on all stages during typing
77+
**Solution:**
78+
- Video now only shows on the last stage
79+
- Only displays when typing is complete
80+
81+
**Code:**
82+
```javascript
83+
isFinal={i === visibleStages.length - 1 && !isTyping}
84+
```
85+
86+
**Result:** Clean, sequential display without premature video rendering ✅
87+
88+
---
89+
90+
### 4. ✅ Code Block Width (FIXED)
91+
**Problem:** Code blocks constrained by message bubble width (85%)
92+
**Solution:**
93+
- Code blocks now break out of message container
94+
- Use full AI Tutor window width
95+
- Negative margins to expand beyond bubble
96+
97+
**Code:**
98+
```javascript
99+
className="my-6 -mx-4 sm:-mx-6 md:-mx-8 rounded-2xl overflow-hidden border border-border shadow-2xl bg-[#0d1117] w-[calc(100%+2rem)] sm:w-[calc(100%+3rem)] md:w-[calc(100%+4rem)]"
100+
```
101+
102+
**Result:** Code blocks use full window width, text stays in bubble ✅
103+
104+
---
105+
106+
## Current Behavior
107+
108+
### Message Flow:
109+
1. **User asks question** → Message sent
110+
2. **AI starts typing**
111+
- INTRO stage types + speaks (after 500ms delay)
112+
- CONCEPT stage types + speaks (after 500ms delay)
113+
- CODE stage types + shows "Preparing code..." (silent)
114+
- SUMMARY stage types + speaks (after 500ms delay)
115+
3. **Typing completes**
116+
- Video extracts from content
117+
- ReactPlayer renders with controls
118+
- Confidence meter appears
119+
- "Ask Mentor" button appears
120+
121+
### Video Rendering:
122+
- **During typing:** Shows on last stage when typing complete
123+
- **After typing:** Extracted and rendered from message content
124+
- **Format:** Responsive ReactPlayer with 16:9 aspect ratio
125+
- **Never shows:** Raw URLs or `[[VIDEO: URL]]` markers
126+
127+
---
128+
129+
## Testing Results
130+
131+
**Typing Animation:** Smooth, no glitches
132+
**Speech Synthesis:** Plays without breaking rendering
133+
**Video Embedding:** Works in both typing and completed states
134+
**Code Block Width:** Full window width
135+
**Text Content:** Stays within message bubble
136+
**Confidence Score:** Displays correctly
137+
**Escalation Button:** Functional
138+
139+
---
140+
141+
## Files Modified
142+
143+
### `eta-web/src/components/AITutor.jsx`
144+
1. **Line 301-307:** Added 500ms delay to speech synthesis
145+
2. **Line 343:** Fixed video display timing (`isFinal` logic)
146+
3. **Line 39:** Code block width expansion with negative margins
147+
4. **Line 783-815:** Added video extraction and rendering for completed messages
148+
149+
---
150+
151+
## Known Behavior
152+
153+
**Speech Delay:** 500ms pause before speech starts (prevents rendering issues)
154+
**Video Display:** Shows after all content is typed
155+
**Code Blocks:** Expand to full window width
156+
**Message Text:** Stays within 85% bubble constraint
157+
158+
---
159+
160+
**Status:** ✅ ALL CRITICAL ISSUES RESOLVED
161+
**Last Updated:** 2026-02-17 01:16 IST

0 commit comments

Comments
 (0)