Skip to content

Commit 103015e

Browse files
kfaracikclaude
andcommitted
fix(drawer): seed rename with the raw chat title, not the placeholder
The drawer rename modal was seeded with chatLabel(), which pre-filled "Chat N" for untitled chats — pressing Save without editing then persisted the placeholder as the title. Seed with the raw title (empty for untitled) to match the chat-screen rename. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 378eb4f commit 103015e

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

__tests__/useDrawerChatMenu.test.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ const setPlatform = (os: string) => {
5252
Object.defineProperty(Platform, 'OS', { get: () => os, configurable: true });
5353
};
5454

55+
const ORIGINAL_OS = Platform.OS;
56+
5557
const captureSheet = () => {
5658
let callback: ((index: number) => void) | null = null;
5759
jest
@@ -84,7 +86,10 @@ beforeEach(() => {
8486
mockExportChatRoom.mockResolvedValue(undefined);
8587
});
8688

87-
afterEach(() => jest.restoreAllMocks());
89+
afterEach(() => {
90+
jest.restoreAllMocks();
91+
setPlatform(ORIGINAL_OS);
92+
});
8893

8994
describe('opening the menu', () => {
9095
it('offers rename, export and delete for the long-pressed chat', () => {
@@ -263,7 +268,7 @@ describe('rename flow', () => {
263268
expect(screen.queryByDisplayValue('Trip to Rome')).toBeNull();
264269
});
265270

266-
it('opens the rename modal seeded with the chat label', () => {
271+
it('opens the rename modal seeded with the chat title', () => {
267272
const getCallback = captureSheet();
268273
const { result } = renderHook(() => useDrawerChatMenu());
269274
const { rerender } = render(<>{result.current.MenuElements}</>);
@@ -275,6 +280,19 @@ describe('rename flow', () => {
275280
expect(screen.getByDisplayValue('Trip to Rome')).toBeTruthy();
276281
});
277282

283+
it('seeds the rename modal empty for an untitled chat, not its "Chat N" label', () => {
284+
const getCallback = captureSheet();
285+
const { result } = renderHook(() => useDrawerChatMenu());
286+
const { rerender } = render(<>{result.current.MenuElements}</>);
287+
288+
act(() => result.current.openMenuFor(untitledChat));
289+
act(() => getCallback()(0));
290+
rerender(<>{result.current.MenuElements}</>);
291+
292+
expect(screen.queryByDisplayValue('Chat 9')).toBeNull();
293+
expect(screen.getByPlaceholderText('Chat name').props.value).toBe('');
294+
});
295+
278296
it('renames the long-pressed chat on submit', async () => {
279297
const getCallback = captureSheet();
280298
const { result } = renderHook(() => useDrawerChatMenu());

components/drawer/useDrawerChatMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const useDrawerChatMenu = ({ onMenuActiveChange }: Options = {}) => {
127127
{ConfirmElement}
128128
<RenameChatModal
129129
visible={renameVisible}
130-
initialTitle={targetChat ? chatLabel(targetChat) : ''}
130+
initialTitle={targetChat?.title ?? ''}
131131
onCancel={handleRenameCancel}
132132
onSubmit={handleRenameSubmit}
133133
/>

0 commit comments

Comments
 (0)