Skip to content

Commit 22ded73

Browse files
authored
Merge pull request #176 from chrisglein/copilot/fix-143
Add "Copy entire chat log" button to bottom more menu
2 parents 5b41f50 + 81de49a commit 22ded73

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Chat.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { PopupsContext } from './Popups';
1616
import { SettingsContext } from './Settings';
1717
import { FluentButton as Button } from './FluentControls';
1818
import { Speak } from './Speech';
19+
import Clipboard from '@react-native-clipboard/clipboard';
1920
import { WelcomeMessage } from './WelcomeMessage';
2021

2122
enum ChatSource {
@@ -158,6 +159,19 @@ function Chat({
158159
}
159160
};
160161

162+
const copyEntireChatLog = () => {
163+
const chatLogText = entries.map((entry) => {
164+
const content = entry.responses ? entry.responses[0] : '';
165+
if (entry.type === ChatSource.Human) {
166+
return `Prompt: ${content}`;
167+
} else {
168+
return `OpenAI: ${content}`;
169+
}
170+
}).join('\n\n');
171+
172+
Clipboard.setString(chatLogText);
173+
};
174+
161175
return (
162176
<FeedbackContext.Provider value={feedbackContext}>
163177
<ChatScrollContext.Provider value={{scrollToEnd: scrollToEnd}}>
@@ -218,6 +232,11 @@ function Chat({
218232
icon: 0xE897,
219233
onPress: () => popups.setShowAbout(true),
220234
},
235+
{
236+
title: 'Copy all',
237+
icon: 0xE8C8,
238+
onPress: () => copyEntireChatLog(),
239+
},
221240
{
222241
title: 'Settings',
223242
icon: 0xE713,

0 commit comments

Comments
 (0)