Skip to content

Commit 8edccbc

Browse files
authored
Merge pull request #183 from WolframResearch/feature/AgentPrefsTake3
More preferences UI updates
2 parents b266ebb + a8cc81c commit 8edccbc

2 files changed

Lines changed: 113 additions & 81 deletions

File tree

FrontEnd/Assets/AgentTools.wl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@
6464
"Spanish" -> "Configured on your system:"
6565
|>],
6666

67-
"prefsHarnessesDetected" -> LanguageSwitched["Detected on your system:", <|
68-
"ChineseSimplified" -> "Detected on your system:",
69-
"ChineseTraditional" -> "Detected on your system:",
70-
"French" -> "Detected on your system:",
71-
"Japanese" -> "Detected on your system:",
72-
"Korean" -> "Detected on your system:",
73-
"Spanish" -> "Detected on your system:"
67+
"prefsHarnessesDetected" -> LanguageSwitched["Unconfigured AI environments detected on your system:", <|
68+
"ChineseSimplified" -> "Unconfigured AI environments detected on your system:",
69+
"ChineseTraditional" -> "Unconfigured AI environments detected on your system:",
70+
"French" -> "Unconfigured AI environments detected on your system:",
71+
"Japanese" -> "Unconfigured AI environments detected on your system:",
72+
"Korean" -> "Unconfigured AI environments detected on your system:",
73+
"Spanish" -> "Unconfigured AI environments detected on your system:"
7474
|>],
7575

7676
"prefsHarnessesMore" -> LanguageSwitched["Other supported AI environments:", <|

Kernel/PreferencesContent.wl

Lines changed: 106 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ clientInterfaces[] :=
8383
Which[
8484
update;
8585
initDone =!= True,
86-
ProgressIndicator[Appearance -> "Necklace"],
86+
Pane[
87+
ProgressIndicator[Appearance -> "Necklace"],
88+
Alignment -> Left,
89+
ImageMargins -> {{15,0},{0,0}}
90+
],
8791

8892
MatchQ[clients, Except[{__String}]],
8993
Style[tr["prefsNoMCPClients"], Italic, FontColor -> ldsGray[0.5]],
@@ -128,7 +132,7 @@ clientInterfaces[] :=
128132
{
129133
Style[tr["prefsHarnessesDetected"],
130134
FontSize -> Inherited,
131-
FontColor -> ldsGray[0.4],
135+
FontColor -> LightDarkSwitched[RGBColor["#d45d1c"], RGBColor["#ed8549"]],
132136
FontWeight -> "DemiBold"
133137
],
134138
configureAllButton[detectedClients, Dynamic[refresh]]
@@ -138,7 +142,7 @@ clientInterfaces[] :=
138142
ItemSize -> Scaled[1],
139143
Spacings -> {Automatic, {2 -> 1, 3 -> 1}}
140144
],
141-
FrameStyle -> LightDarkSwitched[GrayLevel[0.8980], GrayLevel[0.2862]],
145+
FrameStyle -> LightDarkSwitched[RGBColor["#f6cfb6"], RGBColor["#77401a"]],
142146
FrameMargins -> 15,
143147
RoundingRadius -> 6
144148
]
@@ -222,37 +226,48 @@ clientInterfaces[] :=
222226

223227

224228
configureAllButton[detectedClients_, Dynamic[refresh_]] :=
225-
MouseAppearance[
226-
Button[
227-
Framed[
228-
Grid[{{
229-
Pane[
230-
icon["prefsConfigureAllIcon"],
231-
BaselinePosition -> Scaled[0.15]
229+
DynamicModule[{clicked = False},
230+
MouseAppearance[
231+
Button[
232+
Framed[
233+
Grid[{{
234+
Pane[
235+
icon["prefsConfigureAllIcon"],
236+
BaselinePosition -> Scaled[0.15]
237+
],
238+
PaneSelector[
239+
{
240+
False -> tr["prefsConfigureAllButton"],
241+
True -> ProgressIndicator[Appearance -> "Percolate"]
242+
},
243+
Dynamic[Now; clicked],
244+
BaselinePosition -> Baseline
245+
]
246+
}}],
247+
clientControlFrameOptions[
248+
FrameMargins -> {{15,15},{10,10}}
249+
]
250+
],
251+
clicked = True;
252+
refresh @ Do[
253+
DeployAgentTools[
254+
client,
255+
CurrentValue[$FrontEnd, {PrivateFrontEndOptions, "InterfaceSettings", "ServicesForAIs", "SelectedToolset", client}],
256+
OverwriteTarget -> True
232257
],
233-
tr["prefsConfigureAllButton"]
234-
}}],
235-
clientControlFrameOptions[
236-
FrameMargins -> {{15,15},{10,10}}
237-
]
238-
],
239-
refresh @ Do[
240-
DeployAgentTools[
241-
client,
242-
CurrentValue[$FrontEnd, {PrivateFrontEndOptions, "InterfaceSettings", "ServicesForAIs", "SelectedToolset", client}],
243-
OverwriteTarget -> True
258+
{client, detectedClients}
244259
],
245-
{client, detectedClients}
246-
],
247-
ImageSize -> Automatic,
248-
BaseStyle -> {},
249-
DefaultBaseStyle -> {},
250-
Appearance -> None,
251-
BaselinePosition -> Baseline,
252-
Method -> "Queued"
260+
ImageSize -> Automatic,
261+
BaseStyle -> {},
262+
DefaultBaseStyle -> {},
263+
Enabled -> Dynamic[!clicked],
264+
Appearance -> None,
265+
BaselinePosition -> Baseline,
266+
Method -> "Queued"
267+
]
268+
,
269+
"LinkHand"
253270
]
254-
,
255-
"LinkHand"
256271
]
257272

258273

@@ -345,7 +360,7 @@ clientControls[category_, client_, Dynamic[refresh_]] :=
345360
If[dirSettings === {},
346361
Nothing,
347362
{
348-
clientDirectorySettings[dirSettings],
363+
clientDirectorySettings[category, dirSettings],
349364
"", (* action button column *)
350365
"" (* info button column *)
351366
}
@@ -397,65 +412,82 @@ clientMenu[category_, client_, Dynamic[refresh_]] :=
397412
Alignment -> Left,
398413
BaselinePosition -> {1,1}
399414
],
400-
clientControlFrameOptions[
401-
ImageSize -> 320
415+
Sequence @@ DeleteCases[
416+
{clientControlFrameOptions[ImageSize -> 320]},
417+
_[Background | FrameStyle, _]
402418
]
403419
],
404420
ImageSize -> 320,
405421
Appearance -> "ActionMenu",
406-
BaseStyle -> {}, (* needed to avoid very strange notebook-level settings in the Preferences Dialog *)
407-
DefaultBaseStyle -> {},
422+
BaseStyle -> {}, (* needed in part to avoid very strange notebook-level settings in the Preferences Dialog *)
423+
DefaultBaseStyle -> {FrameBoxOptions -> {clientControlFrameOptions[]}},
408424
DefaultMenuStyle -> {}
425+
] // dimUnconfigured[category]
426+
427+
428+
dimUnconfigured[category_][expr_] :=
429+
If[
430+
category === "Configured",
431+
expr,
432+
RawBoxes @ Cell[
433+
BoxData @ FormBox[ToBoxes @ expr, "NoForm"],
434+
PrivateCellOptions -> {"ContentsOpacity" -> 0.3}
409435
]
436+
]
410437

411438

412439
(* ::Section::Closed:: *)
413440
(*clientButton*)
414441

415442

416-
ClearAll[clientButton]
443+
SetAttributes[clientButtonTemplate, HoldRest]
444+
clientButtonTemplate[label_, action_] :=
445+
DynamicModule[{clicked = False},
446+
MouseAppearance[
447+
Button[
448+
Framed[
449+
PaneSelector[
450+
{
451+
False -> label,
452+
True -> ProgressIndicator[Appearance -> "Percolate"]
453+
},
454+
Dynamic[Now; clicked],
455+
Alignment -> {Center, Center},
456+
BaselinePosition -> Baseline
457+
],
458+
clientControlFrameOptions[]
459+
],
460+
clicked = True; action,
461+
Method -> "Queued",
462+
BaseStyle -> {},
463+
DefaultBaseStyle -> {},
464+
Enabled -> Dynamic[!clicked],
465+
BaselinePosition -> Baseline,
466+
Appearance -> None
467+
],
468+
"LinkHand"
469+
]
470+
]
417471

418472

419473
clientButton[category: "Configured", client_, Dynamic[refresh_]] :=
420-
MouseAppearance[
421-
Button[ (* Disable button *)
422-
Framed[
423-
PaneSelector[{0 -> tr["prefsDisableButton"], 1 -> tr["prefsConfigureButton"]}, 0, Alignment -> Center],
424-
clientControlFrameOptions[]
425-
],
426-
refresh @ DeleteObject @ Select[
427-
DeployedAgentTools @ client,
428-
#["Scope"] === "Global" && MatchQ[#["Toolset"], "Wolfram"|"WolframLanguage"]&
429-
],
430-
Method -> "Queued",
431-
BaseStyle -> {},
432-
DefaultBaseStyle -> {},
433-
BaselinePosition -> Baseline,
434-
Appearance -> None
435-
],
436-
"LinkHand"
474+
clientButtonTemplate[ (* Disable button *)
475+
PaneSelector[{0 -> tr["prefsDisableButton"], 1 -> tr["prefsConfigureButton"]}, 0, Alignment -> Center],
476+
refresh @ DeleteObject @ Select[
477+
DeployedAgentTools @ client,
478+
#["Scope"] === "Global" && MatchQ[#["Toolset"], "Wolfram"|"WolframLanguage"]&
479+
]
437480
]
438481

439482

440483
clientButton[category_, client_, Dynamic[refresh_]] :=
441-
MouseAppearance[
442-
Button[ (* Configure button *)
443-
Framed[
444-
PaneSelector[{0 -> tr["prefsDisableButton"], 1 -> tr["prefsConfigureButton"]}, 1, Alignment -> Center],
445-
clientControlFrameOptions[]
446-
],
447-
refresh @ DeployAgentTools[
448-
client,
449-
CurrentValue[$FrontEnd, {PrivateFrontEndOptions, "InterfaceSettings", "ServicesForAIs", "SelectedToolset", client}],
450-
OverwriteTarget -> True
451-
],
452-
Method -> "Queued",
453-
BaseStyle -> {},
454-
DefaultBaseStyle -> {},
455-
BaselinePosition -> Baseline,
456-
Appearance -> None
457-
],
458-
"LinkHand"
484+
clientButtonTemplate[ (* Configure button *)
485+
PaneSelector[{0 -> tr["prefsDisableButton"], 1 -> tr["prefsConfigureButton"]}, 1, Alignment -> Center],
486+
refresh @ DeployAgentTools[
487+
client,
488+
CurrentValue[$FrontEnd, {PrivateFrontEndOptions, "InterfaceSettings", "ServicesForAIs", "SelectedToolset", client}],
489+
OverwriteTarget -> True
490+
]
459491
]
460492

461493

@@ -528,7 +560,7 @@ clientInfoButton[category_, client_] :=
528560
(*clientDirectorySettings*)
529561

530562

531-
clientDirectorySettings[dirSettings_] :=
563+
clientDirectorySettings[category_, dirSettings_] :=
532564
Pane[
533565
Dynamic[
534566
Grid[
@@ -556,7 +588,7 @@ clientDirectorySettings[dirSettings_] :=
556588
ImageSize -> 310,
557589
Alignment -> Left,
558590
ImageMargins -> 5
559-
]
591+
] // dimUnconfigured[category]
560592

561593

562594
(* ::Section::Closed:: *)

0 commit comments

Comments
 (0)