-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathAIAgents.xaml
More file actions
723 lines (704 loc) · 47.3 KB
/
Copy pathAIAgents.xaml
File metadata and controls
723 lines (704 loc) · 47.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
<!--
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
the MIT License. See LICENSE in the project root for license information.
-->
<Page x:Class="Microsoft.Terminal.Settings.Editor.AIAgents"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Microsoft.Terminal.Settings.Editor"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mtu="using:Microsoft.Terminal.UI"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="CommonResources.xaml" />
</ResourceDictionary.MergedDictionaries>
<DataTemplate x:Key="AgentEntryTemplate"
x:DataType="local:AgentEntry">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center"
Text="{x:Bind DisplayLabel}"
Opacity="{x:Bind local:AIAgents.InstalledOpacity(IsInstalled)}" />
<Button Grid.Column="1"
x:Uid="AIAgents_CustomAgentRemove"
Margin="8,0,0,0"
Click="{x:Bind Remove}"
Loaded="CustomAgentRemove_Loaded"
Style="{StaticResource ExtraSmallButtonStyle}"
Visibility="Collapsed">
<FontIcon FontSize="12"
Glyph="" />
</Button>
</Grid>
</DataTemplate>
<DataTemplate x:Key="EnumComboBoxTemplate"
x:DataType="local:EnumEntry">
<TextBlock Text="{x:Bind EnumName, Mode=OneWay}" />
</DataTemplate>
<DataTemplate x:Key="AcpModelEntryTemplate"
x:DataType="local:AcpModelEntry">
<TextBlock Text="{x:Bind DisplayName}" />
</DataTemplate>
</ResourceDictionary>
</Page.Resources>
<StackPanel>
<StackPanel Style="{StaticResource SettingsStackStyle}">
<!-- Page subtitle. The page title itself is rendered by the
Settings BreadcrumbBar from Nav_AIAgents.Content, so we only
add the subtitle below it here. The inline Run/Hyperlink
text is populated from the ResourceLoader in code-behind
(x:Uid on inline Run is not honored in this codebase).
The muted "secondary" foreground is applied only to the
non-link Runs so the Hyperlink keeps its full theme
accent contrast (and its hover/pressed affordance). -->
<TextBlock Margin="0,0,0,16"
TextWrapping="Wrap">
<Run x:Name="PageSubtitlePrefix"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="" /><Run Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text=" " /><Hyperlink NavigateUri="https://aka.ms/intelligent-terminal-privacy">
<Run x:Name="PageSubtitlePrivacyLink" Text="" />
</Hyperlink>
</TextBlock>
<!-- ═══ Agent pane group ═══
First sub-header on the page: override the style's 32px
top margin to 0 so the page subtitle's bottom margin is
the only gap above the header. Otherwise, the page
subtitle + sub-header margins stack to ~48px and look
visibly larger than every other settings page (which
doesn't render a page subtitle). -->
<TextBlock x:Uid="AIAgents_AcpGroupHeader"
Style="{StaticResource TextBlockSubHeaderStyle}"
Margin="0,0,0,4" />
<!-- Agent (ACP CLI) — hand-built Grid mimicking the NonExpanderGrid chrome of
local:SettingContainer, so the description TextBlock can host an inline Hyperlink. -->
<Grid x:Name="AcpAgent"
Background="{ThemeResource ExpanderHeaderBackground}"
BorderThickness="{ThemeResource ExpanderHeaderBorderThickness}"
BorderBrush="{ThemeResource ExpanderHeaderBorderBrush}"
CornerRadius="{ThemeResource ControlCornerRadius}"
MinHeight="64"
MinWidth="{ThemeResource FlyoutThemeMinWidth}"
MaxWidth="1000"
HorizontalAlignment="Stretch"
Padding="16,0,8,0"
Margin="0,4,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0"
VerticalAlignment="Center"
Padding="0,12,0,12">
<TextBlock x:Name="AcpAgentHeaderText"
Style="{StaticResource SettingsPageItemHeaderStyle}" />
<!-- Run.Text values populated from code-behind by splitting on "ACP". -->
<TextBlock x:Name="AcpAgentDescriptionText"
Style="{StaticResource SettingsPageItemDescriptionStyle}">
<Run x:Name="AcpAgentDescriptionBefore" />
<Hyperlink NavigateUri="https://aka.ms/intelligent-terminal-acpref">
<Run x:Name="AcpAgentDescriptionAcpToken" />
</Hyperlink>
<Run x:Name="AcpAgentDescriptionAfter" />
</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Margin="0,12,0,12">
<ComboBox AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource AgentEntryTemplate}"
ItemsSource="{x:Bind ViewModel.AcpAgentList, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.CurrentAcpAgent, Mode=TwoWay}"
Style="{StaticResource ComboBoxSettingStyle}" />
<TextBlock x:Uid="AIAgents_PolicyLocked"
Visibility="{x:Bind ViewModel.IsAgentPolicyLocked, Mode=OneWay}"
Opacity="0.6"
Margin="0,4,0,0" />
<!-- Read-only preview when custom agent is selected on page load -->
<StackPanel Orientation="Vertical"
Visibility="{x:Bind ViewModel.IsCustomAcpAgentSelected, Mode=OneWay}"
Margin="0,8,0,0"
Spacing="8">
<TextBlock Text="{x:Bind ViewModel.CustomAcpCommandPreview, Mode=OneWay}"
IsTextSelectionEnabled="True"
TextWrapping="Wrap"
Opacity="0.8" />
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Spacing="8">
<Button Content="Edit" Click="{x:Bind ViewModel.EditCustomAcpAgent}" />
</StackPanel>
</StackPanel>
<!-- Editable panel (adding new or editing existing) -->
<StackPanel Orientation="Vertical"
Visibility="{x:Bind ViewModel.IsAddingCustomAcpAgent, Mode=OneWay}"
Margin="0,8,0,0"
Spacing="8">
<TextBox Text="{x:Bind ViewModel.CustomAcpCommand, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
PlaceholderForeground="{ThemeResource TextFillColorTertiaryBrush}"
PlaceholderText="my-agent --acp --stdio"
Style="{StaticResource TextBoxSettingStyle}" />
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Spacing="8">
<Button Content="Save" Click="{x:Bind ViewModel.SaveCustomAcpAgent}" Style="{StaticResource AccentButtonStyle}" />
<Button Content="Cancel" Click="{x:Bind ViewModel.CancelCustomAcpAgent}" />
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
<!-- Model picker — shown for every selected agent (built-in
or custom) so a stale acpModel value is always visible
and clearable. HasAcpModelList picks between the
dropdown (helper published available_models) and the
free-form textbox fallback. -->
<local:SettingContainer x:Name="AcpModel"
x:Uid="AIAgents_AcpModel"
Visibility="{x:Bind ViewModel.ShowAcpModel, Mode=OneWay}">
<Grid>
<!-- Dropdown: shown when wta has pushed a model list via agent_status -->
<ComboBox AutomationProperties.AccessibilityView="Content"
ItemsSource="{x:Bind ViewModel.AcpModelList, Mode=OneWay}"
ItemTemplate="{StaticResource AcpModelEntryTemplate}"
SelectedItem="{x:Bind ViewModel.CurrentAcpModelEntry, Mode=TwoWay}"
PlaceholderText="Default"
Style="{StaticResource ComboBoxSettingStyle}"
Visibility="{x:Bind ViewModel.HasAcpModelList, Mode=OneWay}" />
<!-- Free-form fallback: agent pane never connected, custom agent, or agent didn't advertise models -->
<TextBox Text="{x:Bind ViewModel.AcpModel, Mode=TwoWay}"
PlaceholderText="Default"
Style="{StaticResource TextBoxSettingStyle}"
Visibility="{x:Bind ViewModel.ShowAcpModelTextBox, Mode=OneWay}" />
</Grid>
</local:SettingContainer>
<muxc:Expander x:Name="CustomModelProvidersExpander"
Margin="0,4,0,0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
IsExpanded="{x:Bind ViewModel.IsCustomModelProvidersExpanded, Mode=TwoWay}">
<muxc:Expander.Header>
<StackPanel MinHeight="64"
VerticalAlignment="Center">
<TextBlock x:Name="CustomModelsHeaderText"
Style="{StaticResource SettingsPageItemHeaderStyle}" />
<TextBlock Style="{StaticResource CaptionTextBlockStyle}"
TextWrapping="Wrap">
<Run x:Name="CustomModelsCaptionPrefix"
Foreground="{ThemeResource TextFillColorSecondaryBrush}" /><Hyperlink NavigateUri="https://github.com/microsoft/intelligent-terminal#custom-providers-byok">
<Run x:Name="CustomModelsCaptionLink" />
</Hyperlink>
</TextBlock>
</StackPanel>
</muxc:Expander.Header>
<StackPanel>
<TextBlock Margin="0,12,0,0"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{x:Bind ViewModel.CustomModelProviderUnsupportedMessage, Mode=OneWay}"
TextWrapping="Wrap"
Visibility="{x:Bind mtu:Converters.StringNotEmptyToVisibility(ViewModel.CustomModelProviderUnsupportedMessage), Mode=OneWay}" />
<ItemsControl ItemsSource="{x:Bind ViewModel.CustomModelProviders, Mode=OneWay}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="local:CustomModelProviderEntry">
<Border Padding="0,4">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel VerticalAlignment="Center" Spacing="2">
<TextBlock Text="{x:Bind ModelsDisplayText, Mode=OneWay}"
TextWrapping="Wrap" />
<TextBlock Style="{StaticResource CaptionTextBlockStyle}"
Opacity="0.6"
Text="{x:Bind BaseUrl, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
<StackPanel Orientation="Horizontal"
Spacing="6"
Visibility="{x:Bind IsApiKeyMissing, Mode=OneWay}">
<FontIcon FontSize="12"
Foreground="{ThemeResource SystemFillColorCriticalBrush}"
Glyph="" />
<TextBlock x:Uid="AIAgents_CustomProviderApiKeyMissing"
Foreground="{ThemeResource SystemFillColorCriticalBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
TextWrapping="Wrap" />
</StackPanel>
</StackPanel>
<Button Grid.Column="1"
x:Uid="AIAgents_CustomProviderRemove"
VerticalAlignment="Center"
Click="{x:Bind Remove}"
MinWidth="120" />
<muxc:InfoBar Grid.Row="1"
Grid.ColumnSpan="2"
Margin="0,12,0,0"
IsClosable="False"
IsOpen="{x:Bind HasRemovalError, Mode=OneWay}"
Message="{x:Bind RemovalErrorMessage, Mode=OneWay}"
Severity="Error"
Visibility="{x:Bind HasRemovalError, Mode=OneWay}" />
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Border Padding="0,8,0,16">
<StackPanel Spacing="12">
<TextBlock x:Uid="AIAgents_CustomProviderAddHeader"
FontWeight="SemiBold"
Style="{StaticResource SettingsPageItemHeaderStyle}" />
<StackPanel Spacing="4">
<TextBox x:Uid="AIAgents_CustomProviderBaseUrl"
AutomationProperties.HelpText="{Binding Text, ElementName=CustomProviderBaseUrlHint}"
PlaceholderForeground="{ThemeResource TextFillColorTertiaryBrush}"
Style="{StaticResource TextBoxSettingStyle}"
Text="{x:Bind ViewModel.NewCustomModelProviderBaseUrl, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock x:Name="CustomProviderBaseUrlHint"
x:Uid="AIAgents_CustomProviderBaseUrlHint"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
TextWrapping="Wrap" />
</StackPanel>
<StackPanel Spacing="4">
<TextBox x:Uid="AIAgents_CustomModelId"
AutomationProperties.HelpText="{Binding Text, ElementName=CustomModelIdHint}"
PlaceholderForeground="{ThemeResource TextFillColorTertiaryBrush}"
Style="{StaticResource TextBoxSettingStyle}"
Text="{x:Bind ViewModel.NewCustomModelId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock x:Name="CustomModelIdHint"
x:Uid="AIAgents_CustomModelIdHint"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
TextWrapping="Wrap" />
</StackPanel>
<StackPanel Spacing="4">
<PasswordBox x:Uid="AIAgents_CustomProviderApiKey"
AutomationProperties.HelpText="{Binding Text, ElementName=CustomProviderApiKeyHint}"
Password="{x:Bind ViewModel.NewCustomModelProviderApiKey, Mode=TwoWay}" />
<TextBlock x:Name="CustomProviderApiKeyHint"
x:Uid="AIAgents_CustomProviderApiKeyHint"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
TextWrapping="Wrap" />
</StackPanel>
<StackPanel Spacing="4">
<TextBlock x:Uid="AIAgents_CustomProviderSaveHint"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
TextWrapping="Wrap" />
<StackPanel HorizontalAlignment="Right"
Orientation="Horizontal"
Spacing="8">
<Button x:Uid="AIAgents_CustomProviderSave"
IsEnabled="{x:Bind ViewModel.CanSaveCustomModelProvider, Mode=OneWay}"
Click="{x:Bind ViewModel.SaveCustomModelProvider}"
Style="{StaticResource AccentButtonStyle}" />
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</StackPanel>
</muxc:Expander>
<!-- Pane position -->
<local:SettingContainer x:Name="AgentPanePosition"
x:Uid="AIAgents_PanePosition">
<ComboBox AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumComboBoxTemplate}"
ItemsSource="{x:Bind ViewModel.AgentPanePositionList, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.CurrentAgentPanePosition, Mode=TwoWay}"
Style="{StaticResource ComboBoxSettingStyle}" />
</local:SettingContainer>
<!-- Global Yolo preference: asks supported providers to enable
their advertised ACP session mode. High-risk toggle, so it
is disabled outright (IsYoloModePolicyLocked) when the
AllowYoloMode GPO policy blocks it. -->
<local:SettingContainer x:Name="AgentPaneYoloMode"
x:Uid="AIAgents_YoloMode">
<StackPanel>
<ToggleSwitch AutomationProperties.AutomationId="AgentPaneYoloModeToggle"
IsOn="{x:Bind ViewModel.AgentPaneYoloMode, Mode=TwoWay}"
IsEnabled="{x:Bind mtu:Converters.InvertBoolean(ViewModel.IsYoloModePolicyLocked), Mode=OneWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
<TextBlock x:Uid="AIAgents_PolicyLocked"
Visibility="{x:Bind ViewModel.IsYoloModePolicyLocked, Mode=OneWay}"
Opacity="0.6"
Margin="0,4,0,0" />
</StackPanel>
</local:SettingContainer>
<muxc:InfoBar x:Uid="AIAgents_YoloOpenCodeWarning"
AutomationProperties.AutomationId="OpenCodeYoloCompatibilityInfoBar"
HorizontalAlignment="Stretch"
IsClosable="False"
IsOpen="{x:Bind ViewModel.ShowOpenCodeYoloWarning, Mode=OneWay}"
Margin="0,4,0,0"
MaxWidth="1000"
Severity="Warning"
Visibility="{x:Bind ViewModel.ShowOpenCodeYoloWarning, Mode=OneWay}" />
<muxc:InfoBar x:Uid="AIAgents_YoloGeminiInfo"
AutomationProperties.AutomationId="GeminiYoloCompatibilityInfoBar"
HorizontalAlignment="Stretch"
IsClosable="False"
IsOpen="{x:Bind ViewModel.ShowGeminiYoloInfo, Mode=OneWay}"
Margin="0,4,0,0"
MaxWidth="1000"
Severity="Informational"
Visibility="{x:Bind ViewModel.ShowGeminiYoloInfo, Mode=OneWay}" />
<local:SettingContainer x:Name="ShowTokenUsageAndCost"
x:Uid="AIAgents_ShowTokenUsageAndCost">
<ToggleSwitch x:Name="ShowTokenUsageAndCostToggle"
MinWidth="0"
AutomationProperties.AccessibilityView="Content"
IsOn="{x:Bind ViewModel.ShowTokenUsageAndCost, Mode=TwoWay}" />
</local:SettingContainer>
<!-- Automatic error detection (parent) + Automatic error
suggestion (dependent child). Modeled as an Expander so the
hierarchy is explicit: detection's master toggle lives in the
always-visible header; suggestion is nested in the expand body
and stays disabled until detection is on (ViewModel.
CanSuggestErrors). Hand-built header (vs. ExpanderSetting
ContainerStyle) because that style's header-right slot is a
read-only text preview and can't host the master toggle. -->
<muxc:Expander x:Name="AutoErrorDetectionExpander"
Margin="0,4,0,0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
IsExpanded="True">
<muxc:Expander.Header>
<Grid MinHeight="64">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0"
VerticalAlignment="Center"
Spacing="2">
<TextBlock x:Uid="AIAgents_AutoErrorDetectionTitle"
FontWeight="SemiBold"
TextWrapping="Wrap" />
<!-- Caption hosts an inline Hyperlink to the full
supported-shells list, so it is built from
Run + Hyperlink populated in code-behind (RS_)
rather than a single x:Uid (x:Uid on inline Run
is not honored in this codebase). The muted
"secondary" foreground is applied only to the
prefix Run so the Hyperlink keeps its full theme
accent contrast (matches the page-subtitle
pattern above). -->
<TextBlock Style="{StaticResource CaptionTextBlockStyle}"
TextWrapping="Wrap">
<Run x:Name="AutoErrorDetectionCaptionPrefix"
Foreground="{ThemeResource TextFillColorSecondaryBrush}" /><Hyperlink NavigateUri="https://aka.ms/intelligent-terminal-dependency#4-shell-integration">
<Run x:Name="AutoErrorDetectionCaptionLink" />
</Hyperlink>
</TextBlock>
</StackPanel>
<ToggleSwitch Grid.Column="1"
MinWidth="0"
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Content"
IsOn="{x:Bind ViewModel.AutoErrorDetectionEnabled, Mode=TwoWay}" />
</Grid>
</muxc:Expander.Header>
<!-- Nested dependent setting: suggestion. Plain rows (no nested
SettingContainer) so it sits inside the detection Expander
body with no "card-in-card" background. Greyed out
whenever detection is off or auto-fix is GPO-locked
(ViewModel.CanSuggestErrors). Its On/Off reflects the
user's own value and is independent of the detection
toggle. -->
<StackPanel Margin="0,4,0,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0"
VerticalAlignment="Center"
Spacing="2">
<TextBlock x:Uid="AIAgents_AutoErrorSuggestionTitle"
TextWrapping="Wrap" />
<TextBlock x:Uid="AIAgents_AutoErrorSuggestionCaption"
Style="{StaticResource CaptionTextBlockStyle}"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
TextWrapping="Wrap" />
</StackPanel>
<ToggleSwitch Grid.Column="1"
MinWidth="0"
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Content"
IsOn="{x:Bind ViewModel.AutoFixEnabled, Mode=TwoWay}"
IsEnabled="{x:Bind ViewModel.CanSuggestErrors, Mode=OneWay}" />
</Grid>
<TextBlock x:Uid="AIAgents_PolicyLocked"
Visibility="{x:Bind ViewModel.IsAutoFixPolicyLocked, Mode=OneWay}"
Opacity="0.6"
Margin="0,4,0,0" />
</StackPanel>
</muxc:Expander>
<!-- Agent session tracking (hooks) — last entry in the Agent pane group.
Collapsible SettingContainer (Expander style). When expanded:
1. Top row: "Install hooks" action (accent button) — runs
the installer across every detected CLI.
2. One row per CLI that has any wt-agent-hooks state on disk
(whether fully installed or partial); each row carries a
Remove button and an optional subtitle describing the
current install state when it isn't clean.
Each row is wrapped in a Border with a thin top divider to
match the design's "faint separator between rows". -->
<local:SettingContainer x:Name="AgentHooksInstall"
x:Uid="AIAgents_HooksInstall"
Style="{StaticResource ExpanderSettingContainerStyle}">
<StackPanel Orientation="Vertical">
<!-- Row 1: "Install hooks" action. Always present; enabled
when at least one agent CLI is on PATH. The most recent
install/remove progress + result message is shown as a
subtitle under the row label (same layout pattern as
the per-CLI rows below). -->
<Border BorderThickness="0,1,0,0"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
Padding="0,16,0,16">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" Spacing="2">
<TextBlock x:Uid="AIAgents_HooksInstallRowLabel"
TextWrapping="Wrap" />
<TextBlock Text="{x:Bind ViewModel.AgentHooksInstallSummary, Mode=OneWay}"
Visibility="{x:Bind ViewModel.HasAgentHooksInstallSummary, Mode=OneWay}"
Style="{StaticResource CaptionTextBlockStyle}"
Opacity="0.6"
TextWrapping="Wrap" />
</StackPanel>
<Button Grid.Column="1"
x:Uid="AIAgents_HooksInstallButton"
Click="{x:Bind ViewModel.InstallAllAgentHooks}"
IsEnabled="{x:Bind ViewModel.CanInstallAgentHooks, Mode=OneWay}"
Style="{StaticResource AccentButtonStyle}"
MinWidth="120" />
</Grid>
<!-- Installing or removing hooks only affects agents that
start afterwards. This note is deliberately persistent
rather than folded into the post-action summary above:
it has to be visible before the user clicks Install,
and it also covers the per-CLI Remove buttons below,
which have no summary of their own. -->
<TextBlock x:Uid="AIAgents_HooksRestartNote"
Style="{StaticResource CaptionTextBlockStyle}"
Opacity="0.6"
TextWrapping="Wrap"
Margin="0,4,0,0" />
<TextBlock x:Uid="AIAgents_PolicyLocked"
Visibility="{x:Bind ViewModel.IsAgentSessionHooksPolicyLocked, Mode=OneWay}"
Opacity="0.6"
Margin="0,4,0,0" />
</StackPanel>
</Border>
<!-- Per-CLI rows surface installed or partial hook state.
A row disappears once its hooks are removed, so the
Remove button is never shown with nothing to remove. -->
<Border Visibility="{x:Bind ViewModel.ShowCopilotHookRow, Mode=OneWay}"
BorderThickness="0,1,0,0"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
Padding="0,16,0,16">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" Spacing="2">
<TextBlock Text="GitHub Copilot" TextWrapping="Wrap" />
<!-- Subtitle collapses to zero height when empty (no MinHeight
reservation), so the agent name stays vertically centered
in the row in the typical clean-install state. -->
<TextBlock Text="{x:Bind ViewModel.CopilotHooksSubtitle, Mode=OneWay}"
Visibility="{x:Bind ViewModel.ShowCopilotHooksSubtitle, Mode=OneWay}"
Style="{StaticResource CaptionTextBlockStyle}"
Opacity="0.6"
TextWrapping="Wrap" />
</StackPanel>
<Button Grid.Column="1"
x:Uid="AIAgents_HooksRemoveButton"
Click="{x:Bind ViewModel.RemoveCopilotHooks}"
IsEnabled="{x:Bind ViewModel.CanRemoveAgentHooks, Mode=OneWay}"
MinWidth="120" />
</Grid>
</Border>
<Border Visibility="{x:Bind ViewModel.ShowClaudeHookRow, Mode=OneWay}"
BorderThickness="0,1,0,0"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
Padding="0,16,0,16">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" Spacing="2">
<TextBlock Text="Claude Code" TextWrapping="Wrap" />
<TextBlock Text="{x:Bind ViewModel.ClaudeHooksSubtitle, Mode=OneWay}"
Visibility="{x:Bind ViewModel.ShowClaudeHooksSubtitle, Mode=OneWay}"
Style="{StaticResource CaptionTextBlockStyle}"
Opacity="0.6"
TextWrapping="Wrap" />
</StackPanel>
<Button Grid.Column="1"
x:Uid="AIAgents_HooksRemoveButton"
Click="{x:Bind ViewModel.RemoveClaudeHooks}"
IsEnabled="{x:Bind ViewModel.CanRemoveAgentHooks, Mode=OneWay}"
MinWidth="120" />
</Grid>
</Border>
<Border Visibility="{x:Bind ViewModel.ShowGeminiHookRow, Mode=OneWay}"
BorderThickness="0,1,0,0"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
Padding="0,16,0,16">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" Spacing="2">
<TextBlock Text="Gemini CLI" TextWrapping="Wrap" />
<TextBlock Text="{x:Bind ViewModel.GeminiHooksSubtitle, Mode=OneWay}"
Visibility="{x:Bind ViewModel.ShowGeminiHooksSubtitle, Mode=OneWay}"
Style="{StaticResource CaptionTextBlockStyle}"
Opacity="0.6"
TextWrapping="Wrap" />
</StackPanel>
<Button Grid.Column="1"
x:Uid="AIAgents_HooksRemoveButton"
Click="{x:Bind ViewModel.RemoveGeminiHooks}"
IsEnabled="{x:Bind ViewModel.CanRemoveAgentHooks, Mode=OneWay}"
MinWidth="120" />
</Grid>
</Border>
<Border Visibility="{x:Bind ViewModel.ShowCodexHookRow, Mode=OneWay}"
BorderThickness="0,1,0,0"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
Padding="0,16,0,16">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" Spacing="2">
<TextBlock Text="Codex CLI" TextWrapping="Wrap" />
<TextBlock Text="{x:Bind ViewModel.CodexHooksSubtitle, Mode=OneWay}"
Visibility="{x:Bind ViewModel.ShowCodexHooksSubtitle, Mode=OneWay}"
Style="{StaticResource CaptionTextBlockStyle}"
Opacity="0.6"
TextWrapping="Wrap" />
<!-- Codex is the only CLI whose hook commands must be
individually trusted by the user before they fire.
Surface the one-line "run /hooks and approve"
reminder right under the row title so users see it
both before clicking Install (anticipation) and
after install (the row only becomes visible once
Codex has any hook state, which is the moment the
reminder is most actionable). -->
<TextBlock x:Uid="AIAgents_CodexTrustHint"
Style="{StaticResource CaptionTextBlockStyle}"
Opacity="0.6"
TextWrapping="Wrap" />
</StackPanel>
<Button Grid.Column="1"
x:Uid="AIAgents_HooksRemoveButton"
Click="{x:Bind ViewModel.RemoveCodexHooks}"
IsEnabled="{x:Bind ViewModel.CanRemoveAgentHooks, Mode=OneWay}"
MinWidth="120" />
</Grid>
</Border>
<Border Visibility="{x:Bind ViewModel.ShowOpenCodeHookRow, Mode=OneWay}"
BorderThickness="0,1,0,0"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
Padding="0,16,0,16">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" Spacing="2">
<TextBlock Text="OpenCode" TextWrapping="Wrap" />
<TextBlock Text="{x:Bind ViewModel.OpenCodeHooksSubtitle, Mode=OneWay}"
Visibility="{x:Bind ViewModel.ShowOpenCodeHooksSubtitle, Mode=OneWay}"
Style="{StaticResource CaptionTextBlockStyle}"
Opacity="0.6"
TextWrapping="Wrap" />
</StackPanel>
<Button Grid.Column="1"
x:Uid="AIAgents_HooksRemoveButton"
Click="{x:Bind ViewModel.RemoveOpenCodeHooks}"
IsEnabled="{x:Bind ViewModel.CanRemoveAgentHooks, Mode=OneWay}"
MinWidth="120" />
</Grid>
</Border>
</StackPanel>
</local:SettingContainer>
<!-- ═══ Command palette group ═══ -->
<TextBlock x:Uid="AIAgents_DelegateGroupHeader"
Style="{StaticResource TextBlockSubHeaderStyle}" />
<!-- Agent (delegate / on-demand CLI) -->
<local:SettingContainer x:Name="DelegateAgent"
x:Uid="AIAgents_DelegateAgent">
<!-- Vertical Margin — same rationale as the AcpAgent
container above: when a custom delegate agent is
selected the content grows past the SettingContainer's
MinHeight=64 and would otherwise hug the card edges. -->
<StackPanel Margin="0,12,0,12">
<ComboBox AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource AgentEntryTemplate}"
ItemsSource="{x:Bind ViewModel.DelegateAgentList, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.CurrentDelegateAgent, Mode=TwoWay}"
Style="{StaticResource ComboBoxSettingStyle}" />
<TextBlock x:Uid="AIAgents_PolicyLocked"
Visibility="{x:Bind ViewModel.IsAgentPolicyLocked, Mode=OneWay}"
Opacity="0.6"
Margin="0,4,0,0" />
<StackPanel Orientation="Vertical"
Visibility="{x:Bind ViewModel.IsCustomDelegateAgentSelected, Mode=OneWay}"
Margin="0,8,0,0"
Spacing="8">
<TextBlock Text="{x:Bind ViewModel.CustomDelegateCommandPreview, Mode=OneWay}"
IsTextSelectionEnabled="True"
TextWrapping="Wrap"
Opacity="0.8" />
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Spacing="8">
<Button Content="Edit" Click="{x:Bind ViewModel.EditCustomDelegateAgent}" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical"
Visibility="{x:Bind ViewModel.IsAddingCustomDelegateAgent, Mode=OneWay}"
Margin="0,8,0,0"
Spacing="8">
<TextBox Text="{x:Bind ViewModel.CustomDelegateCommand, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
PlaceholderForeground="{ThemeResource TextFillColorTertiaryBrush}"
PlaceholderText="my-cli --flag"
Style="{StaticResource TextBoxSettingStyle}" />
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Spacing="8">
<Button Content="Save" Click="{x:Bind ViewModel.SaveCustomDelegateAgent}" Style="{StaticResource AccentButtonStyle}" />
<Button Content="Cancel" Click="{x:Bind ViewModel.CancelCustomDelegateAgent}" />
</StackPanel>
</StackPanel>
</StackPanel>
</local:SettingContainer>
</StackPanel>
</StackPanel>
</Page>