OR-1 dataflow CPU sketch
1import { baseStylesheet } from "@common/style";
2import type cytoscape from "cytoscape";
3import { rp, rpMoon } from "./palette";
4
5const monitorDarkModeOverrides: cytoscape.StylesheetStyle[] = [
6 // Base node: rosé pine dark background
7 {
8 selector: "node",
9 style: {
10 "background-color": rp.surface,
11 "background-opacity": 1,
12 color: rp.text,
13 "border-color": rp.highlightMed,
14 "text-outline-width": 0,
15 },
16 },
17 // Per-category border colours (override data(colour) from server)
18 {
19 selector: 'node[category = "arithmetic"]',
20 style: { "border-color": rp.foam },
21 },
22 {
23 selector: 'node[category = "logic"]',
24 style: { "border-color": rp.pine },
25 },
26 {
27 selector: 'node[category = "comparison"]',
28 style: { "border-color": rp.gold },
29 },
30 {
31 selector: 'node[category = "routing"]',
32 style: { "border-color": rp.iris },
33 },
34 {
35 selector: 'node[category = "memory"]',
36 style: { "border-color": rpMoon.rose },
37 },
38 {
39 selector: 'node[category = "io"]',
40 style: { "border-color": rpMoon.pine },
41 },
42 {
43 selector: 'node[category = "config"]',
44 style: { "border-color": rp.muted },
45 },
46 // SM node: warm gold/rose tones
47 {
48 selector: 'node[category = "structure_memory"]',
49 style: {
50 "background-color": rp.overlay,
51 "background-opacity": 0.9,
52 "border-color": rp.gold,
53 color: rp.rose,
54 },
55 },
56 // Compound node (PE clusters): rosé pine overlay
57 {
58 selector: "$node > node",
59 style: {
60 "background-color": rp.overlay,
61 "background-opacity": 0.4,
62 "border-color": rp.iris,
63 "border-style": "dashed",
64 "border-width": 1,
65 color: rp.iris,
66 },
67 },
68 // Base edge: muted on dark
69 {
70 selector: "edge",
71 style: {
72 "line-color": rp.subtle,
73 "target-arrow-color": rp.subtle,
74 color: rp.muted,
75 "text-background-color": rp.base,
76 "text-background-opacity": 0.9,
77 },
78 },
79 // Error node
80 {
81 selector: "node.error",
82 style: {
83 "border-color": rp.love,
84 },
85 },
86 // Error edge
87 {
88 selector: "edge.error",
89 style: {
90 "line-color": rp.love,
91 "target-arrow-color": rp.love,
92 },
93 },
94 // Synthetic edge (SM request/return)
95 {
96 selector: "edge.synthetic",
97 style: {
98 "line-color": rp.gold,
99 "target-arrow-color": rp.gold,
100 },
101 },
102];
103
104const monitorOverlayStyles: cytoscape.StylesheetStyle[] = [
105 // Active node: bright gold border when token received
106 {
107 selector: "node.active",
108 style: {
109 "border-color": rp.gold,
110 "border-width": 4,
111 },
112 },
113 // Executed node: pine green highlight
114 {
115 selector: "node.executed",
116 style: {
117 "background-color": rp.pine,
118 "background-opacity": 0.3,
119 },
120 },
121 // Matched node: foam cyan border
122 {
123 selector: "node.matched",
124 style: {
125 "border-color": rp.foam,
126 "border-width": 3,
127 },
128 },
129 // Half-matched node: one operand waiting
130 {
131 selector: "node.half-matched",
132 style: {
133 "border-style": "dashed",
134 "border-width": 2,
135 "border-color": rp.foam,
136 "background-opacity": 0.5,
137 },
138 },
139 // Token flow edge: animated gold dashed line
140 {
141 selector: "edge.token-flow",
142 style: {
143 "line-color": rp.gold,
144 "line-dash-pattern": [6, 3],
145 width: 3,
146 },
147 },
148 // SM cell written: rose highlight
149 {
150 selector: "node.cell-written",
151 style: {
152 "border-color": rp.rose,
153 "border-width": 3,
154 "background-opacity": 0.6,
155 },
156 },
157 // Finished indicator: dim all nodes
158 {
159 selector: "node.finished",
160 style: {
161 opacity: 0.5,
162 },
163 },
164];
165
166const physicalEdgeStyles: cytoscape.StylesheetStyle[] = [
167 // PE cluster node
168 {
169 selector: "node.pe-cluster",
170 style: {
171 shape: "roundrectangle",
172 width: "label",
173 height: "label",
174 "border-width": 1.5,
175 "border-color": rp.iris,
176 "background-color": rp.overlay,
177 "background-opacity": 0.4,
178 padding: "16px",
179 "text-valign": "top",
180 "text-halign": "center",
181 label: "data(label)",
182 "font-size": 9,
183 "font-weight": "bold",
184 color: rp.iris,
185 },
186 },
187 // Port node (bus topology endpoints)
188 {
189 selector: "node.port-node",
190 style: {
191 shape: "ellipse",
192 width: 10,
193 height: 10,
194 "background-color": rp.love,
195 "background-opacity": 1,
196 "border-width": 0,
197 label: "",
198 },
199 },
200 // Intra-PE edge
201 {
202 selector: "edge.intra-pe",
203 style: {
204 width: 0.75,
205 "line-color": rp.subtle,
206 "target-arrow-color": rp.subtle,
207 "source-label": "",
208 "target-label": "data(targetLabel)",
209 "target-text-offset": 5,
210 "target-text-margin-y": -6,
211 "font-size": 7,
212 "font-family": "monospace",
213 color: rp.muted,
214 "text-background-color": rp.base,
215 "text-background-opacity": 0.9,
216 "text-background-padding": "1px",
217 },
218 },
219 // Exit segment (node to exit port, no arrow)
220 {
221 selector: "edge.exit-segment",
222 style: {
223 width: 0.75,
224 "line-color": rp.subtle,
225 "target-arrow-shape": "none",
226 "target-label": "",
227 "source-label": "",
228 },
229 },
230 // Entry segment (entry port to destination)
231 {
232 selector: "edge.entry-segment",
233 style: {
234 width: 0.75,
235 "line-color": rp.subtle,
236 "target-arrow-color": rp.subtle,
237 "target-arrow-shape": "triangle",
238 "source-label": "",
239 "target-label": "data(targetLabel)",
240 "target-text-offset": 5,
241 "target-text-margin-y": -6,
242 "font-size": 7,
243 "font-family": "monospace",
244 color: rp.muted,
245 "text-background-color": rp.base,
246 "text-background-opacity": 0.9,
247 "text-background-padding": "1px",
248 },
249 },
250 // Bus segment (cross-PE thick edge)
251 {
252 selector: "edge.bus-segment",
253 style: {
254 width: 2,
255 "line-color": rp.love,
256 "target-arrow-color": rp.love,
257 "target-arrow-shape": "triangle",
258 "arrow-scale": 0.8,
259 label: "data(label)",
260 "target-label": "",
261 "source-label": "",
262 "text-margin-y": -8,
263 "font-size": 7,
264 "font-family": "monospace",
265 color: rp.love,
266 "text-background-color": rp.base,
267 "text-background-opacity": 0.9,
268 "text-background-padding": "1px",
269 },
270 },
271 // Seed edge (dashed, muted)
272 {
273 selector: "edge.seed-edge",
274 style: {
275 width: 1,
276 "line-style": "dashed",
277 "line-color": rp.muted,
278 "target-arrow-color": rp.muted,
279 "target-text-offset": 5,
280 "target-text-margin-y": -6,
281 },
282 },
283 // Physical edges default to bezier
284 {
285 selector: "edge.physical",
286 style: {
287 "curve-style": "bezier",
288 },
289 },
290];
291
292export const monitorStylesheet: ReadonlyArray<cytoscape.StylesheetStyle> = [
293 ...baseStylesheet,
294 ...monitorDarkModeOverrides,
295 ...physicalEdgeStyles,
296 ...monitorOverlayStyles,
297];