fix(webui): persist chatbot sidebar input text across route navigation

This commit is contained in:
yiling
2026-07-30 17:01:03 +08:00
parent fd1ff8d70e
commit 04f0a39300
3 changed files with 25 additions and 2 deletions
+17
View File
@@ -39,9 +39,26 @@ describe('useChatbotStore', () => {
historySessions: [],
isStreaming: false,
selectedAgentId: 'agent-1',
inputText: '',
})
})
it('should persist and reset inputText', () => {
expect(useChatbotStore.getState().inputText).toBe('')
useChatbotStore.getState().setInputText('Draft text in progress')
expect(useChatbotStore.getState().inputText).toBe('Draft text in progress')
useChatbotStore.setState({
currentSessionId: 'sess-abc',
messages: [{ id: 'msg-1', role: 'user', content: 'test' } as unknown as ChatMessage],
})
// Navigating or changing other state does not wipe inputText
expect(useChatbotStore.getState().inputText).toBe('Draft text in progress')
useChatbotStore.getState().startNewSession()
expect(useChatbotStore.getState().inputText).toBe('')
})
it('should add, remove and clear assets in context', () => {
const store = useChatbotStore.getState()
expect(store.chatAssets).toHaveLength(0)