Forge
csharpdeeb25a2
1using CascadeIDE.Features.UiChrome;
2using CascadeIDE.Features.Workspace;
3using CascadeIDE.Services;
4using Xunit;
5
6namespace CascadeIDE.Tests;
7
8public sealed class AttentionZonePanelRuntimeTests : IDisposable
9{
10 public AttentionZonePanelRuntimeTests() =>
11 AttentionZonePanelRuntime.ResetToCodeDefaults();
12
13 public void Dispose() =>
14 AttentionZonePanelRuntime.ResetToCodeDefaults();
15
16 [Fact]
17 public void Defaults_match_adr_semantics()
18 {
19 AttentionZonePanelRuntime.ResetToCodeDefaults();
20 Assert.True(AttentionZonePanelRuntime.TryGetZone(AttentionPanelIds.SolutionExplorer, out var se));
21 Assert.Equal(AttentionZone.Pfd, se);
22 Assert.True(AttentionZonePanelRuntime.TryGetZone(AttentionPanelIds.ChatPanel, out var ch));
23 Assert.Equal(AttentionZone.Mfd, ch);
24 Assert.True(AttentionZonePanelRuntime.TryGetZone(AttentionPanelIds.Terminal, out var term));
25 Assert.Equal(AttentionZone.Mfd, term);
26 Assert.True(AttentionZonePanelRuntime.TryGetZone(AttentionPanelIds.Editor, out var ed));
27 Assert.Equal(AttentionZone.Forward, ed);
28 Assert.True(AttentionZonePanelRuntime.TryGetZone(AttentionPanelIds.EditorHud, out var hud));
29 Assert.Equal(AttentionZone.Hud, hud);
30 }
31
32 [Fact]
33 public void ApplyWorkspaceToml_overrides_single_panel()
34 {
35 AttentionZonePanelRuntime.ApplyWorkspaceToml(new RepositoryWorkspaceToml
36 {
37 Routing = new UiWorkspaceRoutingToml
38 {
39 Attention = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
40 {
41 [AttentionRoutingIntentIds.SolutionExplorer] = AttentionZoneIds.Mfd,
42 }
43 }
44 });
45
46 Assert.True(AttentionZonePanelRuntime.TryGetZone(AttentionPanelIds.SolutionExplorer, out var z));
47 Assert.Equal(AttentionZone.Mfd, z);
48 Assert.True(AttentionZonePanelRuntime.TryGetZone(AttentionPanelIds.ChatPanel, out var chat));
49 Assert.Equal(AttentionZone.Mfd, chat);
50 }
51
52 [Fact]
53 public void Toml_deserializes_attention_routing_table()
54 {
55 const string toml = """
56 [chrome]
57 pfd_region_default_width_pixels = 220
58
59 [routing]
60 attention = { solution_explorer = "pfd", git = "mfd", terminal = "pfd" }
61 """;
62
63 var w = CascadeTomlSerializer.Deserialize<RepositoryWorkspaceToml>(toml);
64 Assert.NotNull(w);
65 Assert.NotNull(w!.Routing?.Attention);
66 Assert.Equal("pfd", w.Routing.Attention!["solution_explorer"]);
67 AttentionZonePanelRuntime.ApplyWorkspaceToml(w);
68 Assert.True(AttentionZonePanelRuntime.TryGetZone(AttentionPanelIds.Git, out var g));
69 Assert.Equal(AttentionZone.Mfd, g);
70 Assert.True(AttentionZonePanelRuntime.TryGetZone(AttentionPanelIds.Terminal, out var term));
71 Assert.Equal(AttentionZone.Pfd, term);
72 }
73
74 [Fact]
75 public void ApplyWorkspaceToml_rejects_non_spatial_zone_for_terminal_intent()
76 {
77 AttentionZonePanelRuntime.ApplyWorkspaceToml(new RepositoryWorkspaceToml
78 {
79 Routing = new UiWorkspaceRoutingToml
80 {
81 Attention = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
82 {
83 [AttentionRoutingIntentIds.Terminal] = AttentionZoneIds.Hud,
84 }
85 }
86 });
87
88 Assert.True(AttentionZonePanelRuntime.TryGetZone(AttentionPanelIds.Terminal, out var term));
89 Assert.Equal(AttentionZone.Mfd, term);
90 }
91
92 [Fact]
93 public void ApplyWorkspaceToml_does_not_allow_editor_hud_override_via_attention_routing()
94 {
95 AttentionZonePanelRuntime.ApplyWorkspaceToml(new RepositoryWorkspaceToml
96 {
97 Routing = new UiWorkspaceRoutingToml
98 {
99 Attention = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
100 {
101 ["editor_hud"] = AttentionZoneIds.Mfd,
102 }
103 }
104 });
105
106 Assert.True(AttentionZonePanelRuntime.TryGetZone(AttentionPanelIds.EditorHud, out var hud));
107 Assert.Equal(AttentionZone.Hud, hud);
108 }
109}
110
View only · write via MCP/CIDE