Fix auto scroll to bottom during chat (#4923)

This commit is contained in:
Zane
2025-10-01 14:23:03 -07:00
committed by GitHub
parent 8cb6eb4185
commit 345cc65bd3
3 changed files with 167 additions and 83 deletions
@@ -166,7 +166,12 @@ describe('ContextManager', () => {
const { result } = renderContextManager();
await act(async () => {
await result.current.handleAutoCompaction(mockMessages, mockSetMessages, mockAppend, 'test-session-id');
await result.current.handleAutoCompaction(
mockMessages,
mockSetMessages,
mockAppend,
'test-session-id'
);
});
expect(mockManageContextFromBackend).toHaveBeenCalledWith({
@@ -226,7 +231,12 @@ describe('ContextManager', () => {
const { result } = renderContextManager();
await act(async () => {
await result.current.handleAutoCompaction(mockMessages, mockSetMessages, mockAppend, "test-session-id");
await result.current.handleAutoCompaction(
mockMessages,
mockSetMessages,
mockAppend,
'test-session-id'
);
});
expect(result.current.compactionError).toBe('Backend error');
@@ -257,7 +267,12 @@ describe('ContextManager', () => {
// Start compaction
act(() => {
result.current.handleAutoCompaction(mockMessages, mockSetMessages, mockAppend, "test-session-id");
result.current.handleAutoCompaction(
mockMessages,
mockSetMessages,
mockAppend,
'test-session-id'
);
});
// Should be compacting
@@ -307,7 +322,12 @@ describe('ContextManager', () => {
const { result } = renderContextManager();
await act(async () => {
await result.current.handleAutoCompaction(messages, mockSetMessages, mockAppend, "test-session-id");
await result.current.handleAutoCompaction(
messages,
mockSetMessages,
mockAppend,
'test-session-id'
);
});
// No server messages -> setMessages called with empty list
@@ -370,7 +390,12 @@ describe('ContextManager', () => {
const { result } = renderContextManager();
await act(async () => {
await result.current.handleManualCompaction(mockMessages, mockSetMessages, mockAppend, 'test-session-id');
await result.current.handleManualCompaction(
mockMessages,
mockSetMessages,
mockAppend,
'test-session-id'
);
});
expect(mockManageContextFromBackend).toHaveBeenCalledWith({
@@ -483,7 +508,12 @@ describe('ContextManager', () => {
const { result } = renderContextManager();
await act(async () => {
await result.current.handleManualCompaction(mockMessages, mockSetMessages, mockAppend, 'test-session-id');
await result.current.handleManualCompaction(
mockMessages,
mockSetMessages,
mockAppend,
'test-session-id'
);
});
// Verify all three messages are set
@@ -510,7 +540,12 @@ describe('ContextManager', () => {
const { result } = renderContextManager();
await act(async () => {
await result.current.handleAutoCompaction(mockMessages, mockSetMessages, mockAppend, "test-session-id");
await result.current.handleAutoCompaction(
mockMessages,
mockSetMessages,
mockAppend,
'test-session-id'
);
});
expect(result.current.compactionError).toBe('Unknown error during compaction');
@@ -541,7 +576,12 @@ describe('ContextManager', () => {
const { result } = renderContextManager();
await act(async () => {
await result.current.handleAutoCompaction(mockMessages, mockSetMessages, mockAppend, "test-session-id");
await result.current.handleAutoCompaction(
mockMessages,
mockSetMessages,
mockAppend,
'test-session-id'
);
});
// Should complete without error even if content is not text