Skip to content

Commit 100fc51

Browse files
committed
Add ability to copy ai response entirely
1 parent 0e25891 commit 100fc51

5 files changed

Lines changed: 57 additions & 7 deletions

File tree

Directory.Build.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<PropertyGroup>
5+
<PackageVersion>1.0.2</PackageVersion>
6+
</PropertyGroup>
7+
</Project>

PilotAIAssistantControl/ChatItem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class ChatItem {
2424
public HorizontalAlignment Alignment { get; set; } = HorizontalAlignment.Left;
2525
public List<CodeBlock> CodeBlocks { get; set; } = new();
2626
public bool HasCodeBlocks => CodeBlocks.Count > 0;
27+
public bool IsAI => Sender == "AI Assistant";
2728

2829
// --- Factory Methods ---
2930

PilotAIAssistantControlWPF/UCAI.xaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,20 @@
8888
HorizontalAlignment="{Binding Alignment}"
8989
MaxWidth="500">
9090
<StackPanel>
91-
<TextBlock Text="{Binding Sender}" FontWeight="SemiBold"
92-
Style="{StaticResource CaptionTextBlockStyle}"
93-
Foreground="{Binding SenderColor}"/>
91+
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
92+
<TextBlock Text="{Binding Sender}" FontWeight="SemiBold" VerticalAlignment="Center"
93+
Style="{StaticResource CaptionTextBlockStyle}"
94+
Foreground="{Binding SenderColor}"/>
95+
<Button Content="📋"
96+
Margin="6,0,0,0"
97+
Padding="2"
98+
MinWidth="0"
99+
Background="Transparent"
100+
BorderThickness="0"
101+
Click="CopyResponse_Click"
102+
ToolTip="Copy full response"
103+
Visibility="{Binding IsAI, Converter={StaticResource boolNullVisibilityCollapsedConverter}}"/>
104+
</StackPanel>
94105
<mdxaml:MarkdownScrollViewer Markdown="{Binding Message}"
95106
VerticalScrollBarVisibility="Disabled"
96107
Background="Transparent"

PilotAIAssistantControlWPF/UCAI.xaml.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.UI.Xaml.Input;
2020
using Microsoft.UI.Xaml.Media;
2121
using Microsoft.UI.Input;
22+
using Windows.ApplicationModel.DataTransfer;
2223
using Windows.System;
2324
#endif
2425

@@ -124,6 +125,22 @@ private async void ChatInput_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
124125
// Prevent focus change on Tab key
125126
//e.Handled = true;
126127
}
128+
#endif
129+
}
130+
131+
private void CopyResponse_Click(object sender, RoutedEventArgs e) {
132+
if (sender is not Button button || button.DataContext is not ChatItem item)
133+
return;
134+
135+
if (string.IsNullOrWhiteSpace(item.Message))
136+
return;
137+
138+
#if WPF
139+
Clipboard.SetText(item.Message);
140+
#else
141+
var package = new DataPackage();
142+
package.SetText(item.Message);
143+
Clipboard.SetContent(package);
127144
#endif
128145
}
129146
#if WPF
@@ -554,7 +571,7 @@ public async void TryAutoConnectOnExpand() {
554571
return;
555572

556573
_hasAutoConnectedOnExpand = true;
557-
await Task.WhenAny(Task.Delay(5000), ControlLoadedAndDataImported.Task);
574+
await await Task.WhenAny(Task.Delay(5000), ControlLoadedAndDataImported.Task);
558575
if (vm.SelectedPendingProvider?.UserData?.ModelId != null)
559576
SaveSettings_Click(default, default);
560577

PilotAIAssistantControlWinUI/UCAI.xaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,23 @@
9494
HorizontalAlignment="{Binding Alignment}"
9595
MaxWidth="500">
9696
<StackPanel>
97-
<TextBlock Text="{Binding Sender}" FontWeight="SemiBold"
98-
Style="{StaticResource CaptionTextBlockStyle}"
99-
Foreground="{Binding SenderColor}"/>
97+
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
98+
<TextBlock Text="{Binding Sender}" FontWeight="SemiBold"
99+
Style="{StaticResource CaptionTextBlockStyle}"
100+
Foreground="{Binding SenderColor}"/>
101+
<Button Content="📋"
102+
Margin="6,0,0,0"
103+
Padding="2"
104+
MinWidth="0"
105+
Background="Transparent"
106+
BorderThickness="0"
107+
Click="CopyResponse_Click"
108+
Visibility="{Binding IsAI, Converter={StaticResource boolNullVisibilityCollapsedConverter}}">
109+
<ToolTipService.ToolTip>
110+
<ToolTip Content="Copy full response"/>
111+
</ToolTipService.ToolTip>
112+
</Button>
113+
</StackPanel>
100114
<local:MarkdownViewer Markdown="{Binding Message}" />
101115
<ItemsControl ItemsSource="{Binding CodeBlocks}"
102116
Visibility="{Binding HasCodeBlocks, Converter={StaticResource boolNullVisibilityCollapsedConverter}}">

0 commit comments

Comments
 (0)