Skip to content

Commit 5075804

Browse files
author
Rankin Zheng
authored
Merge pull request #6 from devchat-ai/fix_last_step
Fix last step
2 parents 00b2b4a + 711976f commit 5075804

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

src/views/components/CurrentMessage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const CurrentMessage = observer((props: any) => {
8484
whiteSpace: 'break-spaces'
8585
},
8686
}}>
87-
<MessageBody messageType="bot" temp={true} >
87+
<MessageBody messageType="bot" activeStep={true} >
8888
{renderBlocks.length>0?toMarkdown(renderBlocks[0]):''}
8989
</MessageBody>
9090
<MessageBlink />

src/views/components/InputMessage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ const InputMessage = observer((props: any) => {
456456
<Menu.Dropdown>
457457
{modelMenus.map((modelName) => {
458458
return (
459-
<Menu.Item onClick={() => changeModel(modelName)}>
459+
<Menu.Item key={modelName} onClick={() => changeModel(modelName)}>
460460
{getModelShowName(modelName)}
461461
</Menu.Item>
462462
);

src/views/components/MessageBody/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface IProps {
88
messageType: string,
99
children: string,
1010
messageDone?: boolean,
11-
temp?: boolean
11+
activeStep?: boolean
1212
}
1313

1414

@@ -24,14 +24,14 @@ const useStyles = createStyles((theme, options:any) => ({
2424
}));
2525

2626
const MessageBody = observer((props: IProps) => {
27-
const { children, messageType, temp=false ,messageDone} = props;
27+
const { children, messageType, activeStep=false ,messageDone} = props;
2828
const { chat } = useMst();
2929
const {classes} = useStyles({
3030
chatPanelWidth:chat.chatPanelWidth
3131
});
3232
return (
3333
messageType === 'bot'
34-
? <MessageMarkdown className={classes.bodyWidth} temp={temp} messageDone={messageDone}>
34+
? <MessageMarkdown className={classes.bodyWidth} activeStep={activeStep} messageDone={messageDone}>
3535
{children}
3636
</MessageMarkdown>
3737
: <Container

src/views/components/MessageMarkdown/Step.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import { keyframes,css } from "@emotion/react";
1212
interface StepProps {
1313
language: string;
1414
children: string;
15-
done: boolean;
15+
status: string;
1616
index: number|undefined;
1717
}
1818

1919
const Step = observer((props:StepProps) => {
2020
const { chat } = useMst();
21-
const {language,children,done,index} = props;
21+
const {language,children,status,index} = props;
2222
const [opened, { toggle }] = useDisclosure(false);
2323

2424
// extract first line with # as button label
@@ -85,7 +85,7 @@ const Step = observer((props:StepProps) => {
8585
>
8686
<Accordion.Item value={'step'+index} mah='200'>
8787
<Accordion.Control icon={
88-
done
88+
status === "done"
8989
?<IconCheck size="1.125rem"/>
9090
:<Loader size="xs" color="#ED6A45" speed={1} />
9191
}

src/views/components/MessageMarkdown/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface MessageMarkdownProps extends React.ComponentProps<typeof ReactMarkdown
3333
children: string,
3434
className: string,
3535
messageDone?: boolean,
36-
temp?: boolean
36+
activeStep?: boolean
3737
}
3838

3939
type Step = {
@@ -54,7 +54,7 @@ function parseMetaData(string) {
5454
}
5555

5656
const MessageMarkdown = observer((props: MessageMarkdownProps) => {
57-
const { children,temp=false,messageDone } = props;
57+
const { children,activeStep=false,messageDone } = props;
5858
const { chat } = useMst();
5959
const [steps, setSteps] = useState<Step[]>([]);
6060
const tree = fromMarkdown(children);
@@ -177,7 +177,7 @@ Generate a professionally written and formatted release note in markdown with th
177177
return <ReactMarkdown
178178
{...props}
179179
remarkPlugins={[()=> (tree) =>{
180-
let stepCount = 1;
180+
let stepCount = 0;
181181
let chatmarkCount = 0;
182182
let previousNode:any = null;
183183
visit(tree, function (node) {
@@ -227,8 +227,8 @@ Generate a professionally written and formatted release note in markdown with th
227227
}
228228

229229
if (lanugage === 'step' || lanugage === 'Step') {
230-
let done = Number(index) < codes.length? true : lastNode.type !== 'code';
231-
return <Step language={lanugage} done={temp?done:true} index={index}>{value}</Step>;
230+
const status = activeStep && Number(index) === codes.length - 1 && lastNode.type === 'code' ? "running" : "done";
231+
return <Step language={lanugage} status={status} index={index}>{value}</Step>;
232232
}
233233

234234
if (lanugage === 'chatmark' || lanugage === 'ChatMark') {

src/views/stores/ChatStore.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ Thinking...
322322
self.generating = false;
323323
self.responsed = false;
324324
self.hasDone = hasDone;
325+
self.currentMessage = message;
325326
const messagesLength = self.messages.length;
326327
if (hasDone) {
327328
if (messagesLength > 1) {

0 commit comments

Comments
 (0)