Skip to content

Commit

Permalink
Merge branch 'frontend_dev' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
HollaG committed Nov 13, 2024
2 parents 10afc06 + ecbf72a commit 7fef99a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
cursor: pointer;

.textBox {
overflow: hidden;
display: flex;
flex-direction: column;
padding-top: 0.5rem;
Expand Down
35 changes: 19 additions & 16 deletions peer-prep/src/components/Communication/Text/TextChatWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,29 +364,32 @@ export default function TextChatWidget({
// message: responseText,
// replyToId: replyToMessage?.messageId,
// });

console.log({ aiButtonType });
let message;
message = `Q: ${messageToSend}
_________________
**Response from Gemini:**
${responseText}`;
// if (isAiChat) {
// message = `${messageToSend}\n--------------\n${responseText}`;
// } else {
// if (aiButtonType === AiAssistButtonType.GEN_HINTS) {
// message = `Sure! Here are the hints to the question:\n\n${responseText}`;
// } else if (aiButtonType === AiAssistButtonType.GEN_SOLUTION) {
// message = `Sure! Here is the solution to the question:\n\n${responseText}`;
// } else if (aiButtonType === AiAssistButtonType.CODE_EXPLANATION) {
// message = `Sure! Here is the explanation of your current code:\n\n${responseText}`;
// } else if (
// aiButtonType === AiAssistButtonType.QUESTION_EXPLANATION
// ) {
// message = `Sure! Here is the explanation of the question:\n\n${responseText}`;
// }
// }

if (aiButtonType === AiAssistButtonType.GEN_HINTS) {
message = `**Sure! Here are the hints to the question:**
_________________
${responseText}`;
} else if (aiButtonType === AiAssistButtonType.GEN_SOLUTION) {
message = `**Sure! Here is the solution to the question:**
_________________
${responseText}`;
} else if (aiButtonType === AiAssistButtonType.CODE_EXPLANATION) {
message = `**Sure! Here is the explanation of your current code:**
_________________
${responseText}`;
} else if (aiButtonType === AiAssistButtonType.QUESTION_EXPLANATION) {
message = `**Sure! Here is the explanation of the question:**
_________________
${responseText}`;
}

socket.emit("chat-message", {
roomId: roomId,
Expand Down
16 changes: 15 additions & 1 deletion peer-prep/src/utils/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CodeHighlight } from "@mantine/code-highlight";
import { Accordion, AccordionItem, Collapse } from "@mantine/core";
import ReactMarkdown from "react-markdown";

/**
Expand Down Expand Up @@ -64,7 +65,7 @@ export function secondsToMsIfappropriate(s: number): string {
return s < 0.1 ? `${s * 1000} ms` : `${s} s`;
}

export type FormattableTextOption = "plain" | "code";
export type FormattableTextOption = "plain" | "code" | "collapse";

export type FormattableText = {
content: string;
Expand All @@ -79,6 +80,7 @@ export function splitTextIntoObjects(text: string): FormattableText[] {
// Future patterns like bold, underline can be added here
// bold: /\*\*([^*]+)\*\*/g,
// underline: /__(.*?)__/g
// match [collapse]asdasd[collapse]
};

let lastIndex = 0;
Expand Down Expand Up @@ -183,6 +185,18 @@ export const generateReactObjects = (text: string) => {
return <ReactMarkdown key={i}>{textObj.content}</ReactMarkdown>;
// return <Text key={i}> {textObj.content} </Text>;
break;
case "collapse":
return (
<Accordion>
<Accordion.Item value="aa">
<Accordion.Control>Click to open</Accordion.Control>
<Accordion.Panel>
<ReactMarkdown>{textObj.content}</ReactMarkdown>
</Accordion.Panel>
</Accordion.Item>
</Accordion>
);
break;
default:
return <ReactMarkdown key={i}>{textObj.content}</ReactMarkdown>;
}
Expand Down

0 comments on commit 7fef99a

Please sign in to comment.