forked from codinit-dev/codinit-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThinkingProcess.tsx
More file actions
65 lines (52 loc) · 1.91 KB
/
Copy pathThinkingProcess.tsx
File metadata and controls
65 lines (52 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { memo } from 'react';
interface ThinkingProcessProps {
children: React.ReactNode;
}
export const ThinkingProcess = memo(({ children }: ThinkingProcessProps) => {
const parseSteps = (content: React.ReactNode): string[] => {
if (typeof content !== 'string') {
return [];
}
const lines = content.split('\n').filter((line) => line.trim());
const steps: string[] = [];
lines.forEach((line) => {
const trimmed = line.trim();
const numberedMatch = trimmed.match(/^\d+\.\s*(.+)$/);
if (numberedMatch) {
steps.push(numberedMatch[1]);
return;
}
const bulletMatch = trimmed.match(/^[-*]\s*(.+)$/);
if (bulletMatch) {
steps.push(bulletMatch[1]);
return;
}
if (trimmed.length > 0) {
steps.push(trimmed);
}
});
return steps;
};
const steps = parseSteps(children);
if (steps.length === 0) {
return null;
}
return (
<div className="thinking-process my-4 p-4 bg-gradient-to-r from-blue-50 to-cyan-50 dark:from-blue-900/20 dark:to-cyan-900/20 border border-blue-200 dark:border-blue-700 rounded-lg shadow-sm">
<div className="flex items-center gap-2 mb-3">
<div className="i-ph:lightbulb-duotone text-xl text-blue-600 dark:text-blue-400" />
<span className="text-sm font-semibold text-blue-700 dark:text-blue-300">Reasoning Process</span>
</div>
<div className="space-y-2">
{steps.map((step, index) => (
<div key={index} className="flex items-start gap-3 group">
<div className="flex-shrink-0 w-6 h-6 rounded-full bg-blue-600 dark:bg-blue-500 text-white text-xs font-bold flex items-center justify-center mt-0.5">
{index + 1}codinit
</div>
<div className="flex-1 text-sm text-codinit-elements-textPrimary leading-relaxed pt-0.5">{step}</div>
</div>
))}
</div>
</div>
);
});