Skip to content

Commit 1149be9

Browse files
author
Rankin Zheng
authored
Merge pull request #2 from devchat-ai/fix_chatmark_bugs
Fix chatmark bugs
2 parents 957c317 + f929b89 commit 1149be9

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

src/views/components/MessageMarkdown/Step.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ import { keyframes,css } from "@emotion/react";
1212
interface StepProps {
1313
language: string;
1414
children: string;
15-
done:boolean;
15+
done: boolean;
16+
index: number|undefined;
1617
}
1718

1819
const Step = observer((props:StepProps) => {
1920
const { chat } = useMst();
20-
const {language,children,done} = props;
21+
const {language,children,done,index} = props;
2122
const [opened, { toggle }] = useDisclosure(false);
2223

2324
// extract first line with # as button label
2425
const lines = children.split('\n');
25-
const title = lines.length>0&&lines[0].indexOf('#')>=0?lines[0].split('#')[1]:'';
26+
const title = lines.length>0&&lines[0].indexOf('#')>=0?lines[0].split('#')[1]:'Thinking...';
2627
const contents = lines.slice(1,lines.length-1);
2728

2829
const spin = keyframes`
@@ -82,7 +83,7 @@ const Step = observer((props:StepProps) => {
8283
}
8384
}}
8485
>
85-
<Accordion.Item value={title} mah='200'>
86+
<Accordion.Item value={'step'+index} mah='200'>
8687
<Accordion.Control icon={
8788
done
8889
?<IconCheck size="1.125rem"/>

src/views/components/MessageMarkdown/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const useStyles = createStyles((theme) => ({
2222
'&:hover':{
2323
color:theme.colors.merico[6]
2424
}
25+
},
26+
codeOverride:{
27+
code:{
28+
padding: "1px 0px !important",
29+
}
2530
}
2631
}));
2732
interface MessageMarkdownProps extends React.ComponentProps<typeof ReactMarkdown> {
@@ -223,7 +228,7 @@ Generate a professionally written and formatted release note in markdown with th
223228

224229
if (lanugage === 'step' || lanugage === 'Step') {
225230
let done = Number(index) < codes.length? true : lastNode.type !== 'code';
226-
return <Step language={lanugage} done={temp?done:true}>{value}</Step>;
231+
return <Step language={lanugage} done={temp?done:true} index={index}>{value}</Step>;
227232
}
228233

229234
if (lanugage === 'chatmark' || lanugage === 'ChatMark') {
@@ -236,12 +241,12 @@ Generate a professionally written and formatted release note in markdown with th
236241
}
237242

238243
return !inline && lanugage ? (
239-
<div style={{ position: 'relative' }}>
244+
<div style={{ position: 'relative' }} className={classes.codeOverride}>
240245
<LanguageCorner language={lanugage} />
241246
<CodeButtons language={lanugage} code={value} />
242247
<SyntaxHighlighter {...props}
243248
language={lanugage}
244-
customStyle={{ padding: '3em 1em 1em 2em' }}
249+
customStyle={{ padding: '35px 10px 10px 10px' }}
245250
style={okaidia}
246251
wrapLongLines={wrapLongLines}
247252
PreTag="div">

src/views/stores/ChatStore.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ChatContext } from "@/views/stores/InputStore";
44
import { features } from "process";
55
import { Slice } from "@tiptap/pm/model";
66
import yaml from "js-yaml";
7+
import { Step } from "@mantine/core";
78

89
interface Context {
910
content: string;
@@ -251,10 +252,16 @@ DevChat key is missing from your environment or settings. Kindly input your DevC
251252
${yaml.dump(values)}
252253
\`\`\`
253254
`;
254-
self.currentMessage = self.currentMessage + inputStr;
255+
self.currentMessage = `
256+
${self.currentMessage}
257+
${inputStr}
258+
\`\`\`Step
259+
Thinking...123
260+
\`\`\`
261+
`;
255262
messageUtil.sendMessage({
256263
command: "userInput",
257-
text: inputStr,
264+
text: inputStr
258265
});
259266
// goto bottom
260267
goScrollBottom();

0 commit comments

Comments
 (0)