Forge
csharpdeeb25a2
1#nullable enable
2
3namespace CascadeIDE.Features.Chat;
4
5/// <summary>Обработчики <c>kind=report</c> (поле <c>report_handler</c> в intent-catalog).</summary>
6public static class ChatSlashReportHandlers
7{
8 public static class Ids
9 {
10 public const string TopicListText = "topic_list_text";
11 public const string TopicTreeText = "topic_tree_text";
12 public const string SpineList = "spine_list";
13 public const string SpineTree = "spine_tree";
14 public const string SedmScopeText = "sedm_scope_text";
15 public const string SedmScopeDetail = "sedm_scope_detail";
16 }
17
18 private static readonly IReadOnlyDictionary<string, Func<ChatSurfaceSnapshot, string>> Formatters =
19 new Dictionary<string, Func<ChatSurfaceSnapshot, string>>(StringComparer.OrdinalIgnoreCase)
20 {
21 [Ids.TopicListText] = ChatThreadPresentation.FormatTopicList,
22 [Ids.TopicTreeText] = ChatThreadPresentation.FormatTopicTree,
23 [Ids.SpineList] = static s => ChatSlashSessionReports.FormatSpineList(s.ProductSpine),
24 [Ids.SpineTree] = static s => ChatSlashSessionReports.FormatSpineTree(s.ProductSpine),
25 [Ids.SedmScopeText] = static s => ChatSlashSessionReports.FormatSedmScope(s.SedmScopeStrip),
26 [Ids.SedmScopeDetail] = static s => ChatSlashSessionReports.FormatSedmScopeDetail(s),
27 };
28
29 public static bool IsKnown(string handlerId) => Formatters.ContainsKey(handlerId);
30
31 public static bool TryFormat(string handlerId, ChatSurfaceSnapshot snapshot, out string text)
32 {
33 if (Formatters.TryGetValue(handlerId, out var format))
34 {
35 text = format(snapshot);
36 return true;
37 }
38
39 text = "";
40 return false;
41 }
42}
43
View only · write via MCP/CIDE