@@ -26,6 +26,7 @@ import (
2626)
2727
2828var aiCommandIcon = common .PluginAICommandIcon
29+ var aiCommandTitleIcon , _ = aiCommandIcon .ToImage ()
2930
3031var (
3132 // Native overlays require the app main thread. Keeping the calls replaceable
@@ -373,37 +374,15 @@ func buildAICommandLoadingOptions(name string, position mouse.Point, message str
373374 Anchor : overlay .AnchorTopLeft ,
374375 OffsetX : position .X + aiCommandLoadingOverlayOffsetX ,
375376 OffsetY : position .Y + aiCommandLoadingOverlayOffsetY ,
376- Width : estimateAICommandLoadingOverlayWidth (message ),
377+ MinWidth : aiCommandLoadingOverlayMinWidth ,
378+ MaxWidth : aiCommandLoadingOverlayMaxWidth ,
377379 },
378380 Message : message ,
379381 Loading : true ,
380- FontSize : 12 ,
381382 IconSize : aiCommandLoadingOverlayIconSize ,
382383 }
383384}
384385
385- func estimateAICommandLoadingOverlayWidth (message string ) float64 {
386- // Bug fix: the old fixed width was sized for "AI". Localized labels such as
387- // "Thinking..." need enough room after the spinner and padding are reserved,
388- // otherwise the native text view wraps into unreadable fragments.
389- textWidth := 0.0
390- for _ , r := range message {
391- if r <= 0x7f {
392- textWidth += 7
393- } else {
394- textWidth += 12
395- }
396- }
397- width := 12 + float64 (aiCommandLoadingOverlayIconSize ) + 8 + textWidth + 12
398- if width < aiCommandLoadingOverlayMinWidth {
399- return aiCommandLoadingOverlayMinWidth
400- }
401- if width > aiCommandLoadingOverlayMaxWidth {
402- return aiCommandLoadingOverlayMaxWidth
403- }
404- return width
405- }
406-
407386func (c * Plugin ) showAICommandLoadingOverlay (ctx context.Context , name string ) bool {
408387 position , ok := mouse .CurrentPosition ()
409388 if ! ok {
@@ -430,23 +409,26 @@ func (c *Plugin) currentAICommandOverlayPosition(ctx context.Context) mouse.Poin
430409 return position
431410}
432411
433- func (c * Plugin ) showAICommandResultOverlay (ctx context.Context , name string , position * mouse.Point , streamResult common.ChatStreamData ) {
412+ func (c * Plugin ) showAICommandResultOverlay (ctx context.Context , name string , title string , position * mouse.Point , streamResult common.ChatStreamData ) {
434413 message := formatAICommandResultOverlayMessage (ctx , streamResult )
435414 copyText := strings .TrimSpace (streamResult .Data )
436415 opts := textoverlay.Options {
437416 Window : overlay.WindowOptions {
438417 ID : name ,
439418 Topmost : true ,
419+ TakeFocus : true ,
420+ Width : aiCommandResultOverlayMaxWidth ,
440421 MinWidth : aiCommandResultOverlayMinWidth ,
441422 MaxWidth : aiCommandResultOverlayMaxWidth ,
442423 MaxHeight : aiCommandResultOverlayMaxHeight ,
443424 Movable : true ,
444425 CloseOnEscape : true ,
445426 },
427+ Title : title ,
428+ TitleIcon : aiCommandTitleIcon ,
446429 Closable : true ,
447430 Message : message ,
448431 Loading : streamResult .Status == common .ChatStreamStatusStreaming && copyText == "" ,
449- FontSize : 12 ,
450432 IconSize : aiCommandLoadingOverlayIconSize ,
451433 FollowScroll : true ,
452434 }
@@ -649,7 +631,7 @@ func (c *Plugin) buildAICommandActions(ctx context.Context, command commandSetti
649631 util .Go (ctx , "ai command run and show" , func () {
650632 overlayName := fmt .Sprintf ("ai_command_run_and_show_result_%s" , actionContext .ResultId )
651633 position := c .currentAICommandOverlayPosition (ctx )
652- c .showAICommandResultOverlay (ctx , overlayName , & position , common.ChatStreamData {Status : common .ChatStreamStatusStreaming })
634+ c .showAICommandResultOverlay (ctx , overlayName , command . Name , & position , common.ChatStreamData {Status : common .ChatStreamStatusStreaming })
653635 lastOverlayUpdateAt := int64 (0 )
654636 lastOverlayMessage := ""
655637
@@ -664,7 +646,7 @@ func (c *Plugin) buildAICommandActions(ctx context.Context, command commandSetti
664646 lastOverlayUpdateAt = now
665647 lastOverlayMessage = message
666648 }
667- c .showAICommandResultOverlay (ctx , overlayName , nil , streamResult )
649+ c .showAICommandResultOverlay (ctx , overlayName , command . Name , nil , streamResult )
668650 },
669651 })
670652 if final .Err != nil {
0 commit comments