mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-19 22:43:38 +00:00
💾 fix: Restore Send State From Saved Drafts (#17822)
This commit is contained in:
parent
c0187d1de4
commit
e1adcda55b
3 changed files with 24 additions and 2 deletions
|
|
@ -254,6 +254,7 @@ const ChatForm = memo(function ChatForm({
|
|||
* answer box, or is locked behind the batch card that owns the answer. A
|
||||
* collapsed batch is neither, it hands the composer back to the thread. */
|
||||
const composerReserved = answerMode.composerAnswers || answerMode.composerLocked;
|
||||
const textValue = useWatch({ control: methods.control, name: 'text' });
|
||||
|
||||
const { consumeDraft, preserveText, settleText } = useAutoSave({
|
||||
index,
|
||||
|
|
@ -437,7 +438,6 @@ const ChatForm = memo(function ChatForm({
|
|||
),
|
||||
});
|
||||
|
||||
const textValue = useWatch({ control: methods.control, name: 'text' });
|
||||
const interfaceDirection = useDirection();
|
||||
/** An empty `dir="auto"` field resolves to LTR, which would park an RTL interface's placeholder on
|
||||
* the wrong edge, so the empty field follows the interface until text gives it a direction. */
|
||||
|
|
|
|||
|
|
@ -233,6 +233,17 @@ describe('ChatForm URL submission', () => {
|
|||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it('enables Send when an existing conversation restores a saved draft', async () => {
|
||||
const conversation = { ...initialConversation, conversationId: 'existing-chat' };
|
||||
setDraft({ id: conversation.conversationId, value: 'restored draft' });
|
||||
|
||||
mountComposer(conversation, { query: '' });
|
||||
await act(async () => jest.advanceTimersByTime(100));
|
||||
|
||||
expect(screen.getByTestId('text-input')).toHaveValue('restored draft');
|
||||
expect(screen.getByRole('button', { name: 'Send message' })).toBeEnabled();
|
||||
});
|
||||
|
||||
it('processes a queued prompt URL after ordinary conversation navigation without remounting', async () => {
|
||||
const source = { ...initialConversation, conversationId: 'source-chat' };
|
||||
const view = mountComposer(source, { query: '' });
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
import { expect, test } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { sendMessage, selectMockEndpoint, MOCK_ENDPOINTS, NEW_CHAT_PATH } from '../helpers';
|
||||
import {
|
||||
sendMessageAndWaitForCompletion,
|
||||
selectMockEndpoint,
|
||||
MOCK_ENDPOINTS,
|
||||
NEW_CHAT_PATH,
|
||||
sendMessage,
|
||||
} from '../helpers';
|
||||
|
||||
/**
|
||||
* Save-drafts and temporary chat are app preferences the chat reads through the host's chat
|
||||
|
|
@ -69,11 +75,15 @@ test.describe('chat settings owners', () => {
|
|||
|
||||
await setPreference(page, 'saveDrafts', true);
|
||||
await page.reload();
|
||||
await selectMockEndpoint(page, MOCK_ENDPOINTS[0]);
|
||||
await sendMessageAndWaitForCompletion(page, `draft-owner-${Date.now()}`);
|
||||
await expect(page).toHaveURL(/\/c\/(?!new)[^/?]+$/);
|
||||
const kept = `kept draft ${Date.now()}`;
|
||||
await messageInput(page).fill(kept);
|
||||
await expect.poll(() => storedDraftContains(page, kept)).toBe(true);
|
||||
await page.reload();
|
||||
await expect(messageInput(page)).toHaveValue(kept, { timeout: 20000 });
|
||||
await expect(page.getByTestId('send-button')).toBeEnabled();
|
||||
|
||||
await messageInput(page).fill('');
|
||||
await setPreference(page, 'saveDrafts', false);
|
||||
|
|
@ -86,5 +96,6 @@ test.describe('chat settings owners', () => {
|
|||
await page.reload();
|
||||
await expect(messageInput(page)).toBeVisible({ timeout: 20000 });
|
||||
await expect(messageInput(page)).toHaveValue('');
|
||||
await expect(page.getByTestId('send-button')).toBeDisabled();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue