Skip to content

Commit b17212e

Browse files
[mirotalk] - feat: add typing indicator animation for ChatGPT chat
1 parent 093fe4c commit b17212e

8 files changed

Lines changed: 103 additions & 12 deletions

File tree

.env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ====================================================
2-
# MiroTalk P2P v.1.8.05 - Environment Configuration
2+
# MiroTalk P2P v.1.8.06 - Environment Configuration
33
# ====================================================
44

55
# App environment

app/src/config.template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* ==============================================
5-
* MiroTalk P2P v.1.8.05 - Configuration File
5+
* MiroTalk P2P v.1.8.06 - Configuration File
66
* ==============================================
77
*
88
* This file is the central configuration source.

app/src/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dependencies: {
4545
* @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon
4646
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661
4747
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
48-
* @version 1.8.05
48+
* @version 1.8.06
4949
*
5050
*/
5151

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mirotalk",
3-
"version": "1.8.05",
3+
"version": "1.8.06",
44
"description": "A free WebRTC browser-based video call",
55
"main": "server.js",
66
"scripts": {

public/css/client.css

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,6 +4250,61 @@ body {
42504250
color: #d4a017 !important;
42514251
}
42524252

4253+
/* AI Typing Indicator */
4254+
.ai-typing-indicator {
4255+
display: flex;
4256+
align-items: center;
4257+
gap: 8px;
4258+
padding: 12px 16px;
4259+
margin: 8px 0;
4260+
float: left;
4261+
clear: both;
4262+
}
4263+
4264+
.ai-typing-indicator .typing-dots {
4265+
display: flex;
4266+
align-items: center;
4267+
gap: 4px;
4268+
background: rgba(255, 255, 255, 0.06);
4269+
border: 1px solid rgba(255, 255, 255, 0.06);
4270+
border-radius: 16px;
4271+
padding: 12px 18px;
4272+
backdrop-filter: blur(8px);
4273+
}
4274+
4275+
.ai-typing-indicator .typing-dots span {
4276+
width: 8px;
4277+
height: 8px;
4278+
border-radius: 50%;
4279+
background: rgba(255, 255, 255, 0.5);
4280+
animation: typingBounce 1.4s infinite ease-in-out both;
4281+
}
4282+
4283+
.ai-typing-indicator .typing-dots span:nth-child(1) {
4284+
animation-delay: -0.32s;
4285+
}
4286+
4287+
.ai-typing-indicator .typing-dots span:nth-child(2) {
4288+
animation-delay: -0.16s;
4289+
}
4290+
4291+
.ai-typing-indicator .typing-dots span:nth-child(3) {
4292+
animation-delay: 0s;
4293+
}
4294+
4295+
@keyframes typingBounce {
4296+
0%,
4297+
80%,
4298+
100% {
4299+
transform: scale(0.6);
4300+
opacity: 0.4;
4301+
}
4302+
40% {
4303+
transform: scale(1);
4304+
opacity: 1;
4305+
}
4306+
}
4307+
42534308
/*
42544309
z-index
42554310
6 theme custom picker

public/js/brand.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ let brand = {
109109
},
110110
about: {
111111
imageUrl: '../images/mirotalk-logo.gif',
112-
title: 'WebRTC P2P v1.8.05',
112+
title: 'WebRTC P2P v1.8.06',
113113
html: `
114114
<button
115115
id="support-button"

public/js/client.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon
1616
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661
1717
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
18-
* @version 1.8.05
18+
* @version 1.8.06
1919
*
2020
*/
2121

@@ -11558,13 +11558,47 @@ function emitMsg(from, fromAvatar, to, msg, privateMsg, id) {
1155811558
sendToDataChannel(chatMessage);
1155911559
}
1156011560

11561+
/**
11562+
* Show AI typing indicator animation in the chat
11563+
* @param {string} aiName
11564+
*/
11565+
function showAITypingIndicator(aiName) {
11566+
const existing = getId(`ai-typing-${aiName}`);
11567+
if (existing) return;
11568+
const typingHTML = `
11569+
<div id="ai-typing-${aiName}" class="msg left-msg">
11570+
<div class="ai-typing-indicator">
11571+
<div class="typing-dots">
11572+
<span></span>
11573+
<span></span>
11574+
<span></span>
11575+
</div>
11576+
</div>
11577+
</div>
11578+
`;
11579+
msgerChat.insertAdjacentHTML('beforeend', typingHTML);
11580+
msgerChat.scrollTop = msgerChat.scrollHeight;
11581+
}
11582+
11583+
/**
11584+
* Hide AI typing indicator animation from the chat
11585+
* @param {string} aiName
11586+
*/
11587+
function hideAITypingIndicator(aiName) {
11588+
const indicator = getId(`ai-typing-${aiName}`);
11589+
if (indicator) indicator.remove();
11590+
}
11591+
1156111592
/**
1156211593
* Read ChatGPT incoming message
1156311594
* https://platform.openai.com/docs/introduction
1156411595
* @param {string} msg
1156511596
*/
1156611597
async function getChatGPTmessage(msg) {
1156711598
console.log('Send ChatGPT message:', msg);
11599+
11600+
showAITypingIndicator('ChatGPT');
11601+
1156811602
signalingSocket
1156911603
.request('data', {
1157011604
room_id: roomId,
@@ -11579,6 +11613,7 @@ async function getChatGPTmessage(msg) {
1157911613
})
1158011614
.then(
1158111615
function (completion) {
11616+
hideAITypingIndicator('ChatGPT');
1158211617
if (!completion) return;
1158311618
const { message, context } = completion;
1158411619
chatGPTcontext = context ? context : [];
@@ -11590,6 +11625,7 @@ async function getChatGPTmessage(msg) {
1159011625
}.bind(this)
1159111626
)
1159211627
.catch((err) => {
11628+
hideAITypingIndicator('ChatGPT');
1159311629
console.log('ChatGPT error:', err);
1159411630
});
1159511631
}
@@ -14966,7 +15002,7 @@ function showAbout() {
1496615002
Swal.fire({
1496715003
background: swBg,
1496815004
position: 'center',
14969-
title: brand.about?.title && brand.about.title.trim() !== '' ? brand.about.title : 'WebRTC P2P v1.8.05',
15005+
title: brand.about?.title && brand.about.title.trim() !== '' ? brand.about.title : 'WebRTC P2P v1.8.06',
1497015006
imageUrl: brand.about?.imageUrl && brand.about.imageUrl.trim() !== '' ? brand.about.imageUrl : images.about,
1497115007
customClass: { image: 'img-about' },
1497215008
html: `

0 commit comments

Comments
 (0)