fix(chat): do not delete the answer when regenerating without a selected model
regenerateResponse removed the previous answer before checking for a model and then returned silently, leaving the conversation without a reply. It now checks first and explains that a model is required, like sendMessage. The duplicated streaming code in sendMessage and regenerateResponse is now a single streamAnswer helper.
This commit is contained in:
1 parent
b441339bb4
commit
1a3ce9ccec
3 files changed
+76
-106
No files matched your search
@@ -165,7 +165,7 @@ describe('ChatScreen', () => {
|
||||
expect(apiMessages[0].role).toBe('system');
|
||||
});
|
||||
|
||||
it('edits without regenerating when no model is selected', () => {
|
||||
it('edits and explains that a model is needed when none is selected', () => {
|
||||
const id = setup();
|
||||
act(() => {
|
||||
useAppStore.setState({ activeModelId: '' });
|
||||
@@ -177,8 +177,9 @@ describe('ChatScreen', () => {
|
||||
jest.advanceTimersByTime(100);
|
||||
});
|
||||
|
||||
expect(state().messages).toHaveLength(1);
|
||||
expect(state().messages).toHaveLength(2);
|
||||
expect(state().messages[0]).toMatchObject({ id, content: 'new question' });
|
||||
expect(state().messages[1].content).toContain('No model selected');
|
||||
expect(streamMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user