| | | 1 | | @inject IToolManager ToolManager |
| | | 2 | | |
| | | 3 | | <div class="tool-call-block" data-tool="@Segment.ToolName"> |
| | | 4 | | <div class="tool-call-header @StatusClass"> |
| | 0 | 5 | | @SharedResource.CallingTool: <strong>@DisplayName</strong>@(Segment.IsClosed ? "" : " ...") |
| | | 6 | | </div> |
| | | 7 | | |
| | 0 | 8 | | @if (Segment.Lines.Count > 0) |
| | | 9 | | { |
| | | 10 | | <div class="tool-call-args"> |
| | 0 | 11 | | @if (Segment.ToolName == BuiltInToolEnum.ApplyDiff) |
| | | 12 | | { |
| | | 13 | | <DiffView LinesCount="@Segment.Lines.Count" ToolParams="@Segment.ToolParams" IsClosed="@Segment.IsClosed |
| | | 14 | | } |
| | 0 | 15 | | else if (Segment.ToolName == BuiltInToolEnum.CreateFile) |
| | | 16 | | { |
| | | 17 | | <ToolCreateNewFile Lines="@Segment.Lines" /> |
| | | 18 | | } |
| | 0 | 19 | | else if (Segment.ToolName == BasicEnum.AskUser) |
| | | 20 | | { |
| | | 21 | | <ToolAskOptions Lines="@Segment.Lines" /> |
| | | 22 | | } |
| | | 23 | | else |
| | | 24 | | { |
| | 0 | 25 | | <pre>@string.Join("\n", Segment.Lines)</pre> |
| | | 26 | | } |
| | | 27 | | </div> |
| | | 28 | | } |
| | | 29 | | |
| | 0 | 30 | | @if (Segment.IsClosed) |
| | | 31 | | { |
| | | 32 | | <div class="tool-approval-footer @StatusClass"> |
| | 0 | 33 | | @if (Segment.ApprovalStatus == ToolApprovalStatus.Pending) |
| | | 34 | | { |
| | 0 | 35 | | <div class="tool-approval-label"><i class="rz-icon-notification rz-ml-2"></i>@SharedResource.ApproveRequ |
| | | 36 | | <div class="tool-approval-actions"> |
| | 0 | 37 | | <RadzenButton Icon="check" class="tool-approve-btn rz-m-2" Click="@(async () => await OnApproval.Inv |
| | 0 | 38 | | <RadzenButton Icon="close" class="tool-reject-btn rz-m-2" Click="@(async () => await OnApproval.Invo |
| | | 39 | | </div> |
| | | 40 | | } |
| | | 41 | | </div> |
| | 0 | 42 | | @if (ToolResult is not null) |
| | | 43 | | { |
| | | 44 | | <Details Text="@ToolResult.DisplayName"> |
| | 0 | 45 | | <pre class="rz-p-2 rz-background-color-base-900 rz-color-white">@ToolResult.GetDisplayContent</pre> |
| | | 46 | | </Details> |
| | | 47 | | } |
| | | 48 | | } |
| | | 49 | | </div> |
| | | 50 | | |
| | | 51 | | @code { |
| | 0 | 52 | | [Parameter] public ContentSegment Segment { get; set; } = null!; |
| | 0 | 53 | | [Parameter] public EventCallback<(string SegmentId, bool Approved)> OnApproval { get; set; } |
| | 0 | 54 | | [Parameter] public ToolResult? ToolResult { get; set; } |
| | | 55 | | |
| | 0 | 56 | | private string DisplayName => ToolManager.GetTool(Segment.ToolName)?.DisplayName ?? Segment.ToolName; |
| | | 57 | | |
| | 0 | 58 | | private string StatusClass => Segment.ApprovalStatus switch |
| | 0 | 59 | | { |
| | 0 | 60 | | ToolApprovalStatus.Approved => "approved", |
| | 0 | 61 | | ToolApprovalStatus.Rejected => "rejected", |
| | 0 | 62 | | _ => "pending" // класс по умолчанию |
| | 0 | 63 | | }; |
| | | 64 | | } |