Merge branch 'dev' into de_de-i18n
This commit is contained in:
commit
e160339c7b
@ -12,27 +12,30 @@ interface Props {
|
|||||||
// Zustand store for thinking block state
|
// Zustand store for thinking block state
|
||||||
type ThinkingBlockState = {
|
type ThinkingBlockState = {
|
||||||
thinkingState: { [id: string]: boolean }
|
thinkingState: { [id: string]: boolean }
|
||||||
toggleState: (id: string) => void
|
setThinkingState: (id: string, expanded: boolean) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const useThinkingStore = create<ThinkingBlockState>((set) => ({
|
const useThinkingStore = create<ThinkingBlockState>((set) => ({
|
||||||
thinkingState: {},
|
thinkingState: {},
|
||||||
toggleState: (id) =>
|
setThinkingState: (id, expanded) =>
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
thinkingState: {
|
thinkingState: {
|
||||||
...state.thinkingState,
|
...state.thinkingState,
|
||||||
[id]: !state.thinkingState[id],
|
[id]: expanded,
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const ThinkingBlock = ({ id, text }: Props) => {
|
const ThinkingBlock = ({ id, text }: Props) => {
|
||||||
const { thinkingState, toggleState } = useThinkingStore()
|
const { thinkingState, setThinkingState } = useThinkingStore()
|
||||||
const { streamingContent } = useAppState()
|
const { streamingContent } = useAppState()
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const loading = !text.includes('</think>') && streamingContent
|
const loading = !text.includes('</think>') && streamingContent
|
||||||
const isExpanded = thinkingState[id] ?? false
|
const isExpanded = thinkingState[id] ?? (loading ? true : false)
|
||||||
const handleClick = () => toggleState(id)
|
const handleClick = () => {
|
||||||
|
const newExpandedState = !isExpanded
|
||||||
|
setThinkingState(id, newExpandedState)
|
||||||
|
}
|
||||||
|
|
||||||
if (!text.replace(/<\/?think>/g, '').trim()) return null
|
if (!text.replace(/<\/?think>/g, '').trim()) return null
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user