Repository navigation
Expand file tree
/
Copy pathinfo-ui.test.ts
More file actions
1468 lines (1339 loc) · 86.8 KB
/
Copy pathinfo-ui.test.ts
File metadata and controls
1468 lines (1339 loc) · 86.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { describe, expect, test } from "bun:test";
import { existsSync, readdirSync, readFileSync } from "fs";
import { join } from "path";
const settings = readFileSync(join(import.meta.dir, "InfoSettings.qml"), "utf8");
const view = readFileSync(join(import.meta.dir, "InfoView.qml"), "utf8");
const overlay = readFileSync(join(import.meta.dir, "Overlay.qml"), "utf8");
const model = readFileSync(join(import.meta.dir, "InfoModel.qml"), "utf8");
const service = readFileSync(join(import.meta.dir, "Infomarchy.qml"), "utf8");
describe("interactive information modules", () => {
test("reordering skips hidden cards instead of producing a visual no-op", () => {
const source = settings.match(/function adjacentEnabledIndex\([\s\S]*?\n \}/)?.[0];
expect(source).toBeTruthy();
const adjacentEnabledIndex = Function(`return (${source})`)();
expect(adjacentEnabledIndex(["usage", "localAi", "machine"], 0, 1, { localAi: false })).toBe(2);
expect(adjacentEnabledIndex(["changes", "needs", "projects"], 2, -1, { needs: false })).toBe(0);
expect(adjacentEnabledIndex(["usage", "localAi", "machine"], 0, -1, {})).toBe(0);
expect(adjacentEnabledIndex(["usage", "localAi", "machine", "media", "containers"], 2, 1, {})).toBe(3);
expect(settings).toContain("adjacentEnabledIndex(next, from, direction, sections)");
});
test("persists seen change fingerprints and exposes the optional change module", () => {
expect(settings).toContain('{ id: "changes", label: "CHANGES" }');
expect(settings).toContain("property var seenChanges");
expect(settings).toContain("function markChangeSeen");
expect(view).toContain('title: "WHAT CHANGED"');
expect(view).toContain("view.settings.markChangeSeen");
expect(view).toContain("changeRow.change.files");
});
test("renders specific next-action reasons and contextual controls", () => {
expect(settings).toContain('{ id: "needs", label: "NEXT ACTIONS" }');
expect(view).toContain('title: "NEXT ACTIONS"');
expect(view).toContain("attentionReason");
expect(view).toContain("attentionPrimaryLabel");
expect(view).toContain('text: "COPY DETAIL"');
expect(view).toContain("activateAttention");
});
test("renders removable, reorderable project health with dashboard filtering", () => {
expect(settings).toContain('{ id: "projects", label: "PROJECTS" }');
expect(settings).toContain('property var opsOrder: ["changes", "needs", "projects"]');
expect(settings).toContain("function enabledOpsCount");
expect(settings).toContain("function opsVisibleIndex");
expect(settings).toContain("function moveOps");
expect(view).toContain('title: "PROJECT HEALTH"');
expect(view).toContain('moveGroup: "ops"');
expect(view).toContain('dragAxis: "horizontal"');
expect(view).toContain("property string projectFilter");
expect(view).toContain("function projectMatches");
expect(view).toContain("readonly property var visibleCollisions");
expect(view).toContain("view.projectFilter === projectRow.key");
expect(view).toContain('text: "1–9, 0 MODULES');
expect(view).toContain('"SUPER+I HIDE DESK · SUPER+D SHOW OVER WINDOWS"');
expect(view).toContain('"SUPER+I HIDE DESK · SUPER+D / ESC CLOSE"');
expect(overlay).toContain("event.key <= Qt.Key_9");
});
test("shows multiplexer hosting context on live cards and the inspector", () => {
expect(view).toContain("function sessionHostLabel");
expect(view).toContain("function sessionHostDetail");
expect(view).toContain('text: "hosted in " + view.sessionHostLabel');
expect(view).toContain("view.sessionHostDetail(sessionInspector.session)");
});
test("offers safe selectable Ollama load and unload controls", () => {
expect(settings).toContain("property string selectedOllamaModel");
expect(settings).toContain("function setSelectedOllamaModel");
expect(settings).toContain("property string ollamaHost: \"\"");
expect(settings).toContain("function setOllamaHost");
expect(settings).toContain("function normalizeOllamaHost");
expect(model).toContain('ollamaControlPath: Qt.resolvedUrl("ollama-control.ts")');
expect(model).toContain("ollamaProcess.pendingFrame");
expect(model).toContain("write(JSON.stringify(pendingFrame)");
expect(model).toContain("environment: root.ollamaHost !== \"\" ? ({ OLLAMA_HOST: root.ollamaHost }) : ({})");
expect(service).toContain("function setOllamaHost(v: string): void { dashboardSettings.setOllamaHost(v) }");
expect(overlay).toContain("ollamaHost: dashboardSettings.ollamaHost");
expect(view).toContain("function needsConfirmation");
expect(view).toContain('view.desk.controlOllama("load"');
expect(view).toContain('view.desk.controlOllama("unload"');
expect(view).toContain('"CONFIRM"');
const source = settings.match(/function normalizeOllamaHost\([\s\S]*?\n \}/)?.[0];
expect(source).toBeTruthy();
const normalizeOllamaHost = Function(`return (${source})`)();
expect(normalizeOllamaHost("http://127.0.0.1:11435")).toBe("http://127.0.0.1:11435");
expect(normalizeOllamaHost("127.0.0.1:11435")).toBe("http://127.0.0.1:11435");
expect(normalizeOllamaHost("http://user:secret@127.0.0.1:11435")).toBe("");
expect(normalizeOllamaHost("")).toBe("");
});
test("deduplicates configurable attention and lifecycle notifications", () => {
expect(settings).toContain("property var notificationEvents");
expect(settings).toContain("function claimNotificationEvent");
expect(settings).toContain("function notificationsAllowed");
expect(settings).toContain("function toggleNotificationProvider");
expect(view).toContain('text: "ALERTS "');
// The chip must reflect the configured window, not a hardcoded 22–08.
expect(view).toContain('text: "QUIET " + (view.settings.quietStartHour < 10 ? "0" : "") + view.settings.quietStartHour');
expect(view).not.toContain('"QUIET 22–08 "');
expect(service).toContain('"omarchy-notification-send"');
expect(service).toContain("dashboardSettings.claimNotificationEvent");
expect(service).toContain('"nixfred.infomarchy", "{}"');
});
});
describe("usage trend chart", () => {
test("renders a per-provider 7-day series with a tokens / value toggle and estimated value lines", () => {
const view = readFileSync(join(import.meta.dir, "InfoView.qml"), "utf8");
expect(view).toContain('property string usageMetric: "tokens"');
expect(view).toContain("readonly property var usageSeries");
expect(view).toContain("id: trendCanvas");
expect(view).toContain('text: view.usageMetric === "value" ? "≈ $ VALUE" : "TOKENS"');
expect(view).toContain("up.u.usageStatusText");
expect(view).toContain("color: Util.alpha(up.tone, 0.07)");
expect(view).toContain("border.color: Util.alpha(up.tone, 0.28)");
expect(view).toContain("usageTrend.hovered");
expect(view).toContain('"% cache reads"');
expect(view).toContain('"unpriced"');
});
});
describe("multiplexer-aware focus", () => {
test("cards, attention rows and the inspector jump into the hosting multiplexer", () => {
const model = readFileSync(join(import.meta.dir, "InfoModel.qml"), "utf8");
const view = readFileSync(join(import.meta.dir, "InfoView.qml"), "utf8");
expect(model).toContain("function focusHerdrPane(host)");
expect(model).toContain('["bun", root.herdrFocusPath, sock, workspace, tab, pane]');
expect(model).toContain('["select-window", "-t", pane]');
expect(model).not.toContain('["pane", "focus", "--pane", pane]');
expect(view).toContain("else if (view.desk.focusSession(sc.modelData)) view.navigated()");
expect(model).toContain("function focusBoomuxShell(host)");
expect(model).toContain('["boomux", "open", shell]');
expect(view).toContain("view.desk.focusSession(item); view.navigated(); return true");
expect(view).toContain("view.desk.focusSession(sessionInspector.session)");
});
});
describe("overlay shows the real desktop", () => {
test("SUPER+D paints the wallpaper, and SUPER+I applies inside the overlay", () => {
const overlay = readFileSync(join(import.meta.dir, "Overlay.qml"), "utf8");
expect(overlay).toContain('source: root.videoBackground ? "" : Util.fileUrl(root.background)');
expect(overlay).toContain("opacity: dashboardSettings.ready && dashboardSettings.dashboardVisible ? root.wallpaperOpacity : 1.0");
expect(overlay).toContain("visible: dashboardSettings.ready && dashboardSettings.dashboardVisible\n onNavigated: root.close()");
expect(overlay).not.toContain("Util.alpha(infoModel.themeBackground, 0.88)");
});
test("SUPER+D leaves the bar visible", () => {
expect(overlay).toContain("exclusionMode: ExclusionMode.Normal");
});
});
describe("a video wallpaper is OWE's, and the desk steps aside for it", () => {
// Omarchy 4.5 plays video in its own daemon (OWE) on its own background layer.
// Its BackgroundMedia is stills-only, so a player of ours would be dead code
// that logs a warning on every video. The desk goes see-through instead.
const wallpaper = readFileSync(join(import.meta.dir, "Infomarchy.qml"), "utf8");
const overlay = readFileSync(join(import.meta.dir, "Overlay.qml"), "utf8");
test("each surface is handed only its own kind of file", () => {
expect(wallpaper).toContain("readonly property bool videoBackground: root.isVideo(root.background)");
expect(overlay).toContain("readonly property bool videoBackground: root.isVideo(root.background)");
expect(wallpaper).toContain('source: root.videoBackground ? "" : root.imageUrl(root.background)');
expect(overlay).toContain('source: root.videoBackground ? "" : Util.fileUrl(root.background)');
});
test("Omarchy decides what a video is, and an older one still gets an answer", () => {
// Both surfaces paint the wallpaper, so both must agree on what a video is
// — and agree with the Omarchy they are running on.
for (const [name, source] of [["Infomarchy.qml", wallpaper], ["Overlay.qml", overlay]] as const) {
const fn = source.match(/function isVideo\(path\) \{[\s\S]*?\n \}/)?.[0];
expect(fn, name).toBeTruthy();
// A format added to Omarchy is understood here without a change.
const withUtil = Function("Util", `return (${fn})`)({ isVideoPath: (p: string) => /\.(mp4|gif)$/i.test(String(p || "")) });
expect(withUtil("/bg/matrix-vortex.mp4"), name).toBe(true);
expect(withUtil("/bg/added-later.gif"), name).toBe(true);
expect(withUtil("/bg/still.png"), name).toBe(false);
// An Omarchy whose Util predates video wallpapers has no such function.
// Calling it anyway would take the plugin down on exactly the desktops
// the fallback exists for.
const noUtil = Function("Util", `return (${fn})`)({});
expect(() => noUtil("/bg/still.png"), name).not.toThrow();
expect(noUtil("/bg/matrix-vortex.mp4"), name).toBe(true);
expect(noUtil("/bg/clip.WEBM"), name).toBe(true);
expect(noUtil("/bg/still.png"), name).toBe(false);
expect(noUtil(""), name).toBe(false);
expect(noUtil(null), name).toBe(false);
}
});
test("the desk goes see-through for a video instead of painting a player", () => {
expect(wallpaper).toContain("readonly property bool passthrough: dashboardSettings.wallpaperPassthrough || root.videoBackground");
expect(wallpaper).toContain('color: root.passthrough ? "transparent" : infoModel.themeBackground');
expect(wallpaper).toContain("WlrLayershell.layer: root.raised ? WlrLayer.Bottom : WlrLayer.Background");
expect(wallpaper).toContain("visible: !root.passthrough");
});
test("no file carries a video player of its own, and the background IPC keeps the stock contract", () => {
for (const name of readdirSync(import.meta.dir).filter((n) => n.endsWith(".qml"))) {
const src = readFileSync(join(import.meta.dir, name), "utf8");
expect(src, name).not.toMatch(/BackgroundMedia|BackgroundWallpaper|playbackEnabled|audioEnabled|streamUrl|videoAudio/);
}
expect(existsSync(join(import.meta.dir, "BackgroundWallpaper.qml"))).toBe(false);
for (const fn of ["stream", "stopStream", "streaming", "playback", "audio"])
expect(wallpaper).not.toContain(`function ${fn}(`);
});
});
describe("wallpaper passthrough is opt-in (#43)", () => {
const wallpaper = readFileSync(join(import.meta.dir, "Infomarchy.qml"), "utf8");
test("passthrough does not paint a wallpaper and sits above the background layer", () => {
expect(wallpaper).toContain("color: root.passthrough ? \"transparent\" : infoModel.themeBackground");
expect(wallpaper).toContain("WlrLayershell.layer: root.raised ? WlrLayer.Bottom : WlrLayer.Background");
expect(wallpaper).toContain("visible: !root.passthrough");
expect(wallpaper).toContain("visible: dashboardSettings.ready && root.passthrough && dashboardSettings.dashboardVisible");
expect(wallpaper).toContain("opacity: Math.max(0, Math.min(1, 1 - root.wallpaperOpacity))");
});
test("passthrough is off by default, and off keeps the original layer, colour and wallpaper", () => {
expect(settings).toContain("property bool wallpaperPassthrough: false");
expect(settings).toContain("wallpaperPassthrough = !!(parsed && parsed.wallpaperPassthrough === true)");
expect(settings).toMatch(/catch \(e\) \{[\s\S]*?wallpaperPassthrough = false/);
// With the flag off, every branch pinned above reduces to the original value;
// the surface only waits for settings so a saved flag picks the right layer.
expect(wallpaper).toContain("visible: dashboardSettings.ready && !remapGuard.remapping && !(root.passthrough && !dashboardSettings.dashboardVisible)");
});
});
describe("OWE can suspend the desk instead of disabling the plugin", () => {
// OWE calls `background setSuspended` before it draws an intro or a video.
// When the owner of that IPC target has no such function, OWE falls back to
// `shell setPluginEnabled omarchy.background`, and enabling a first-party
// plugin makes the shell disable its active clone: this plugin.
const wallpaper = readFileSync(join(import.meta.dir, "Infomarchy.qml"), "utf8");
test("the background IPC target answers setSuspended", () => {
expect(wallpaper).toContain("property bool suspended: false");
expect(wallpaper).toMatch(/target: "background"[\s\S]*?function setSuspended\(value: string\): void \{ root\.suspended = value === "true" \}/);
});
test("an intro keeps the cards on screen: passthrough, with the usual tint", () => {
expect(wallpaper).toContain("readonly property bool introActive: root.suspended && !root.videoBackground");
expect(wallpaper).toContain("readonly property bool passthrough: dashboardSettings.wallpaperPassthrough || root.videoBackground || root.suspended || root.coverUp");
expect(wallpaper).toContain("visible: dashboardSettings.ready && root.passthrough && dashboardSettings.dashboardVisible\n");
});
// The shell maps its intro cover above the desk about a second before it
// closes it again. Hyprland's layer events are the only notice a third-party
// plugin gets, and the plugin's own maps and unmaps raise the same events.
test("the desk goes up for the shell's intro cover and comes down when it closes", () => {
expect(wallpaper).toMatch(/function onRawEvent\(event\) \{\s*if \(event\.data !== "omarchy-background" \|\| ownMapGuard\.running\) return\s*if \(event\.name === "openlayer"\) \{\s*root\.coverUp = true\s*coverTimeout\.restart\(\)\s*\} else if \(event\.name === "closelayer" && root\.coverUp\) \{\s*root\.coverUp = false\s*coverTimeout\.stop\(\)/);
expect(wallpaper).toContain("onVisibleChanged: root.noteOwnMap()");
expect(wallpaper).toContain("Timer { id: coverTimeout; interval: 10000; onTriggered: root.coverUp = false }");
expect(wallpaper).toContain("Timer { id: ownMapGuard; interval: 5000; running: true }");
});
test("what the desk paints and which layer it sits on are decided separately", () => {
expect(wallpaper).toContain("readonly property bool raised: dashboardSettings.wallpaperPassthrough || root.videoBackground || root.coverUp || root.suspendedWithoutCover");
expect(wallpaper).toContain("WlrLayershell.layer: root.raised ? WlrLayer.Bottom : WlrLayer.Background");
expect(wallpaper).toContain("onSuspendedChanged: suspendedWithoutCover = suspended && !coverUp");
});
});
describe("background sessions are reachable", () => {
test("a card with a background host attaches a terminal on click", () => {
const model = readFileSync(join(import.meta.dir, "InfoModel.qml"), "utf8");
const view = readFileSync(join(import.meta.dir, "InfoView.qml"), "utf8");
expect(model).toContain("function attachBackground(session)");
expect(model).toContain('["bun", root.resumePath, "claude-attach", id, String(item.cwd || "")]');
expect(view).toContain('" · click attaches a terminal"');
});
});
describe("zombie cleanup is explicit and two-click", () => {
test("cards flag STALE and the inspector offers STOP SESSION / END PROCESS with confirmation", () => {
const model = readFileSync(join(import.meta.dir, "InfoModel.qml"), "utf8");
const view = readFileSync(join(import.meta.dir, "InfoView.qml"), "utf8");
expect(view).toContain('text: "STALE · idle "');
expect(view).toContain('text: armed ? "CONFIRM STOP" : "STOP SESSION"');
expect(model).toContain('["bun", root.stopPath, "claude-stop", String(item.jobId)]');
expect(model).toContain('["bun", root.stopPath, "term", String(Number(item.pid)), String(Math.round(Number(item.startedAt)))]');
});
test("END PROCESS is offered for any inspected session, not only a stale one", () => {
// If the desk is where you noticed the session, the desk is where you
// should be able to stop it. The old gate hid this behind stale === true,
// so a live agent could be inspected but never ended.
const end = view.slice(view.indexOf("id: endTag"), view.indexOf("Item { Layout.fillWidth: true }", view.indexOf("id: endTag")));
const visible = end.match(/visible: (.+)/)![1];
expect(visible).toContain("canEndProcess");
expect(visible).not.toContain("stale");
// Still two clicks, and the armed state still expires on its own.
expect(end).toContain("if (endTag.armed) { view.desk.endProcess(sessionInspector.session)");
expect(end).toContain("else endTag.armed = true");
expect(end).toContain("Timer { interval: 4000; running: endTag.armed; onTriggered: endTag.armed = false }");
// A live session's confirmation names what it is about to kill.
expect(end).toContain('"CONFIRM: END "');
expect(end).toContain('"END PROCESS"');
});
});
describe("module strip spacing matches the rest of the desk", () => {
test("the gap under the chip row is view.gap, not the tighter chip-to-chip sm", () => {
const start = view.indexOf("id: moduleStrip");
const column = view.lastIndexOf("ColumnLayout {", start);
const beforeFlow = view.slice(column, view.lastIndexOf("Flow {", start));
expect(beforeFlow).toContain("spacing: view.gap");
expect(beforeFlow).not.toContain("spacing: Style.spacing.sm");
const flow = view.slice(view.lastIndexOf("Flow {", start), view.indexOf("Repeater {", start));
expect(flow).toContain("spacing: Style.spacing.sm");
});
});
describe("right column fits a 1080p desk", () => {
test("the per-model rows name no model, so a new one needs no edit here", () => {
const block = view.match(/Repeater \{\s*\n\s*model: \(up\.u\.models[\s\S]*?\n \}/)?.[0];
expect(block).toBeTruthy();
// Driven entirely by what the provider reported.
expect(block).toContain("label: modelData.id");
expect(block).toContain("fraction: up.u.hasTokenData ? (modelData.share || 0) : 0");
// No model name may be hardcoded in the CODE. Prose may name one to
// explain where the behaviour came from; a branch on one is the bug.
const code = view.split("\n").filter(line => !line.trim().startsWith("//")).join("\n").toLowerCase();
for (const name of ["fable", "opus", "astra", "gpt-", "grok-4", "sonnet", "haiku"])
expect(code, name).not.toContain(name);
});
test("a Herdr card jumps to its own pane, not just the Herdr window", () => {
// Herdr draws every workspace inside ONE window, so an agent's ancestry
// resolves that window directly and the collector's client-window lookup
// never runs. Gating the pane focus on `attached` meant every ordinary
// Herdr card focused Herdr and left it on whatever was already showing.
const branch = model.match(/else if \(host\.kind === "herdr".*?\) focusHerdrPane\(host\)/)?.[0];
expect(branch).toBeTruthy();
expect(branch).not.toContain("attached");
expect(branch).toBe('else if (host.kind === "herdr") focusHerdrPane(host)');
// The card promises this in its own label whenever there is a window, so
// the promise and the behaviour have to agree.
expect(view).toContain('" · click jumps to the pane"');
// focusHerdrPane is the guard now: no valid ids, no request.
const source = model.match(/function focusHerdrPane\(host\) \{[\s\S]*?\n \}/)?.[0];
expect(source).toBeTruthy();
expect(source).toContain('if (!workspace && !tab && !pane) return false');
});
test("a busy desk shrinks its session cards instead of burying everything below them", () => {
// 25 sessions at six columns was five rows of eight-line cards — the whole
// screen, with no ACTIVITY, RECENT TASKS or ops cards under it.
expect(view).toContain("readonly property bool dense: view.sortedSessions.length > 8");
// Columns bound the number of ROWS, because rows are what push the desk off.
const columns = view.match(/readonly property int targetColumns: dense[\s\S]*?\n : [^\n]*/)?.[0];
expect(columns).toBeTruthy();
expect(columns).toContain("Math.ceil(view.sortedSessions.length / 4)");
const density = (n: number) => Math.max(6, Math.min(8, Math.ceil(n / 4)));
// Measured on a real desk: left column 1327, card padding 13, gap 11.
const rows = (n: number) => {
const cols = density(n);
const fitted = (1301 - 11 * (cols - 1)) / cols;
const width = Math.max(112 * 1.3333, fitted);
return Math.ceil(n / Math.floor((1301 + 11) / (width + 11)));
};
for (const n of [9, 12, 20, 25, 32]) expect(rows(n), `${n} sessions`).toBeLessThanOrEqual(4);
// The minimum is multiplied by fontScale. A dense minimum of 138 came out
// at 184 on a 1.33 desk, wider than the fitted width, so Flow fell back to
// six per row and the extra columns bought nothing at all.
expect(view).toContain("dense ? 112 :");
expect(Math.max(112 * 1.3333, (1301 - 11 * 6) / 7)).toBeCloseTo((1301 - 11 * 6) / 7, 5);
// A dense card drops what a glance does not need; the inspector keeps it.
expect(view).toContain("maximumLineCount: sessionFlow.dense ? 1 : 2");
expect((view.match(/visible: !sessionFlow\.dense && \(/g) || []).length).toBe(4);
});
test("a provider with no token data says so instead of reporting zero", () => {
// Grok publishes prompts and sessions but no token totals or rate-limit
// windows. "0 tok" would read as a measurement it never made.
expect(view).toContain("up.u.hasTokenData ?");
expect(view).toContain('(up.u.todaySessions ? " · " + up.u.todaySessions + " sess" : "")');
// usageStatusText reached the QML for months and was never drawn; it is
// the only place a provider can explain why it has no limit bars.
expect(view).toContain("visible: !!up.u.usageStatusText && !(up.u.limits || []).length");
expect(view).toContain('text: up.u.usageStatusText || ""');
});
test("ABOUT carries the version, the repo and the author, and the version is read from the manifest", () => {
// A hardcoded version string drifts from the one the plugin ships as.
expect(model).toContain('id: manifestFile');
expect(model).toContain('Qt.resolvedUrl("manifest.json")');
expect(model).toContain("root.version = String(parsed && parsed.version");
// An in-place plugin update rewrites manifest.json under a running shell.
expect(model).toContain("watchChanges: true");
expect(model).toContain("onFileChanged: reload()");
expect(model).toContain('readonly property string repoUrl: "https://github.com/nixfred/infomarchy"');
expect(model).toContain('readonly property string authorUrl: "https://nixfred.com"');
// The version is on the desk itself, at the quiet end of the legend line.
expect(view).toContain('text: "Infomarchy v" + view.desk.version');
expect(view).toContain("onClicked: view.aboutOpen = true");
// All three required entries appear in the panel.
expect(view).toContain('AboutLink { label: "REPOSITORY"; url: view.desk.repoUrl');
expect(view).toContain('AboutLink { label: "AUTHOR"; url: view.desk.authorUrl');
expect(view).toContain('text: "v" + view.desk.version');
// Esc closes the panel before it closes the whole desk.
expect(overlay).toContain("if (infoView.aboutOpen) infoView.aboutOpen = false; else root.close()");
});
test("openUrl refuses any address the plugin does not itself ship", () => {
const source = model.match(/function openUrl\(url\) \{[\s\S]*?\n \}/)?.[0];
expect(source).toBeTruthy();
const calls: string[][] = [];
const root = { repoUrl: "https://github.com/nixfred/infomarchy", authorUrl: "https://nixfred.com" };
const Quickshell = { execDetached: (argv: string[]) => { calls.push(argv); } };
const openUrl = Function("root", "Quickshell", `return (${source})`)(root, Quickshell);
expect(openUrl(root.repoUrl)).toBe(true);
expect(openUrl(root.authorUrl)).toBe(true);
expect(calls).toEqual([["xdg-open", root.repoUrl], ["xdg-open", root.authorUrl]]);
// Anything else — including a lookalike host — never reaches xdg-open.
for (const hostile of ["https://nixfred.com.evil.test", "file:///etc/passwd", "https://github.com/attacker/x", "", null, undefined])
expect(openUrl(hostile as any)).toBe(false);
expect(calls).toHaveLength(2);
});
test("MACHINE is a two-column grid with a one-line footer, and the SUPER legend sits under it", () => {
const view = readFileSync(join(import.meta.dir, "InfoView.qml"), "utf8");
expect(view).toContain("// Cockpit density: two meters per row");
expect(view).toContain('text: "WAN " + view.wanText()');
expect(view).toContain('"SUPER+I hide desk · SUPER+D show desktop") + " · SUPER+SHIFT+I privacy ×3 off · right-click a card to inspect"');
expect(view).toContain("readonly property int metaWidth");
});
});
describe("containers card", () => {
test("registers a reorderable lower-right module with per-row on/off toggles", () => {
expect(settings).toContain('{ id: "containers", label: "CONTAINERS" }');
expect(settings).toContain('property var rightOrder: ["usage", "localAi", "remoteRoster", "fleet", "hermesHosts", "machine", "media", "containers"]');
expect(settings).toContain('var allowed = ["usage", "localAi", "remoteRoster", "fleet", "hermesHosts", "machine", "media", "containers"]');
expect(view).toContain('title: "CONTAINERS"');
expect(view).toContain('moveId: "containers"');
expect(view).toContain("component PowerToggle: Item");
expect(view).toContain('view.desk.controlContainer(item.running ? "stop" : "start", item.name)');
expect(view).toContain("readonly property int visibleLimit: 8");
expect(view).toContain('visible: view.sectionEnabled("usage") || view.sectionEnabled("localAi") || view.sectionEnabled("machine") || view.sectionEnabled("media") || view.sectionEnabled("containers")');
expect(model).toContain('containerControlPath: Qt.resolvedUrl("container-control.ts")');
expect(model).toContain("containerProcess.pendingFrame");
expect(model).toContain('["start", "stop"].indexOf(operation)');
expect(view).toContain("lit: !!modelData.running");
});
});
describe("LOCAL AI rows stay inside the card body", () => {
const view = readFileSync(join(import.meta.dir, "InfoView.qml"), "utf8");
test("the provider chips are a Flow, so no rigid row can raise the column minimum above the body width", () => {
// Four rigid Tags in a RowLayout gave the column a 514 px minimum in a 512 px body: every
// row then laid out 2 px past the clip and lost its right border. A Flow has no minimum.
const start = view.indexOf("id: provRow");
const opener = view.lastIndexOf("{", start);
const type = view.slice(view.lastIndexOf("\n", opener) + 1, opener).trim();
expect(type).toBe("Flow");
expect(view.slice(start, view.indexOf("\n }", start))).not.toContain("Item { Layout.fillWidth: true }");
});
test("the live geometry report is exposed over IPC for measuring, not guessing", () => {
expect(view).toContain("function geometryReport(): string");
const service = readFileSync(join(import.meta.dir, "Infomarchy.qml"), "utf8");
expect(service).toContain("function geometry(): string { return root.deskView ? root.deskView.geometryReport() : \"{}\" }");
});
});
describe("the desk can be pinned to one workspace", () => {
const settings = readFileSync(join(import.meta.dir, "InfoSettings.qml"), "utf8");
const service = readFileSync(join(import.meta.dir, "Infomarchy.qml"), "utf8");
test("0 means every workspace, so an install that never sets it is unchanged", () => {
expect(settings).toContain("property int deskWorkspace: 0");
// Both halves of applyConfig: a missing or malformed key must land on 0,
// never on some workspace the user never asked for.
expect(settings).toContain("deskWorkspace = parsed && Number.isInteger(parsed.deskWorkspace) ? Math.max(0, Math.min(maxWorkspace, parsed.deskWorkspace)) : 0");
expect(settings).toContain("persist({ deskWorkspace: deskWorkspace })");
});
test("an out-of-range workspace is refused, not clamped", () => {
// Clamping would pin the desk to workspace 1 for anyone who fat-fingers a
// value, which reads as the gate being broken rather than as a bad input.
// Hyprland's special workspaces are negative (olrec is -1337) and are not
// places the desk belongs.
const setter = settings.match(/function setDeskWorkspace\(workspace\) \{[\s\S]*?\n \}/)?.[0];
expect(setter, "InfoSettings must expose setDeskWorkspace").toBeTruthy();
expect(setter).toContain("value < 0 || value > maxWorkspace");
expect(setter).toContain("value !== Math.round(value)");
expect(setter).toContain("return false");
});
test("the gate hides the cards, never the wallpaper", () => {
// Hiding the PanelWindow would take the wallpaper with it and leave every
// other workspace on the flat theme colour. The gate belongs on the view.
expect(service).toContain("visible: dashboardSettings.ready && dashboardSettings.dashboardVisible && panel.deskWorkspaceMatches");
expect(service).not.toMatch(/visible: !remapGuard\.remapping && .*deskWorkspace/);
});
test("an unknown workspace shows the desk rather than hiding it", () => {
// Early in startup there is no Hyprland monitor yet. An unset gate must
// never be the reason the dashboard is missing.
const match = service.match(/readonly property bool deskWorkspaceMatches:[\s\S]*?deskWorkspace\n/)?.[0];
expect(match, "Infomarchy must resolve deskWorkspaceMatches").toBeTruthy();
expect(match).toContain("dashboardSettings.deskWorkspace === 0");
expect(match).toContain("!visibleWorkspace");
});
test("the workspace is reachable over IPC, both ways", () => {
expect(service).toContain("function setDeskWorkspace(v: string): string");
expect(service).toContain("function getDeskWorkspace(): string");
});
});
describe("the desk keeps refreshing", () => {
const model = readFileSync(join(import.meta.dir, "InfoModel.qml"), "utf8");
test("a repeating timer drives refresh, at the interval the hosts set", () => {
// This shipped broken: the poll was replaced by FileView watches and the
// only refresh left was one shot 750 ms after start. The desk populated
// once and froze until you toggled it, which re-armed the one-shot and
// made it look alive. Nothing tested that the desk refreshes at all.
const timer = model.match(/Timer \{[^}]*interval: root\.refreshMs[^}]*\}/)?.[0];
expect(timer, "InfoModel must poll on refreshMs").toBeTruthy();
expect(timer).toContain("repeat: true");
expect(timer).toContain("running: root.active");
// Covers the first tick, so no separate initial timer is needed.
expect(timer).toContain("triggeredOnStart: true");
});
test("refreshMs is actually read by something", () => {
// Both hosts set it (4s/16s on the desk, 3s in the overlay). A property
// set by two callers and read by none is a cadence that does not exist.
expect(model).toContain("interval: root.refreshMs");
});
test("no QML file hardcodes an absolute path into somebody's home", () => {
// The watches named a contributor's own home directory, so they could
// never fire anywhere else. Paths come from HOME or Quickshell.env.
for (const name of ["InfoModel.qml", "InfoView.qml", "InfoSettings.qml", "Infomarchy.qml", "Overlay.qml"]) {
const source = readFileSync(join(import.meta.dir, name), "utf8");
const hits = source.split("\n").filter(line => /path:\s*"\/home\//.test(line) || /"\/home\/[a-z_]/.test(line));
expect(hits, `${name} hardcodes a home path: ${hits.join(" | ")}`).toEqual([]);
}
});
});
describe("an idle session drops off the desk and comes back on its own", () => {
// Reported from a live desk: 14 cards, only two agents actually in use, the
// rest sitting idle in herdr panes for two days. The desk is for what is
// happening now.
test("quiet sessions are filtered out of what the desk renders", () => {
expect(view).toContain("readonly property var visibleSessions");
expect(view).toContain("if (!settings.hideQuietSessions) return displaySessions");
// The render path, the keyboard walk and the density maths must all agree
// on the same list, or Enter focuses a card nobody can see.
// sortedSessions IS visibleSessions in recency order and a regrouping of
// it in "terminal" order: same cards, different sequence. Everything that
// draws, measures or navigates must use the rendered list, or the keyboard
// index points at a different card than the one under it.
expect(view).toContain("model: view.sortedSessions");
expect(view).toContain("var session = sortedSessions[keyboardSessionIndex]");
expect(view).toContain("readonly property bool dense: view.sortedSessions.length > 8");
expect(view).not.toContain("model: view.displaySessions");
});
test("a provider you explicitly grouped keeps its card", () => {
// Asking to group a fanned-out roster is asking to keep seeing it.
expect(view).toContain("item.grouped === true || !sessionIsQuiet(item, sessionQuietMs, now)");
});
test("the desk says how many it dropped, in the hint and when empty", () => {
expect(view).toContain("readonly property int hiddenQuietCount: displaySessions.length - visibleSessions.length");
expect(view).toContain('" idle over "');
expect(view).toContain("still running and hidden");
});
test("hiding is on by default, persisted, and reversible without a rebuild", () => {
expect(settings).toContain("property bool hideQuietSessions: true");
expect(settings).toContain("persist({ hideQuietSessions: hideQuietSessions })");
expect(settings).toContain("function setHideQuietSessions(enabled)");
// An older config file predates the key; absent must not read as off.
expect(settings).toContain("hideQuietSessions = !parsed || parsed.hideQuietSessions !== false");
const wallpaper = readFileSync(join(import.meta.dir, "Infomarchy.qml"), "utf8");
expect(wallpaper).toContain("function toggleHideQuiet()");
expect(wallpaper).toContain("function setQuietMinutes(v: string)");
});
});
describe("a project filter never makes the desk misreport the machine", () => {
// Reported from two surfaces side by side: the wallpaper desk said
// "1 running" while the overlay said "24 running". The filter is per-view by
// design — the overlay is the unfiltered picture — but the desk was counting
// its own filtered subset and presenting it as the machine's state.
test("the header reports the real total and names the filter hiding the rest", () => {
expect(view).toContain('" of " + view.allSessions.length + " running · filtered by "');
// The unfiltered wording must stay exactly as it was.
expect(view).toContain('view.sessions.length + " running"');
});
test("an empty list caused by a filter does not tell you to go start something", () => {
// The advice has to match the reason. "go start something" while two dozen
// agents run is worse than no message at all.
const emptyState = view.match(/text: view\.desk\.bunChecked[\s\S]*?"collecting…"/)?.[0] || "";
expect(emptyState).toContain("view.projectFilter && view.allSessions.length > 0");
expect(emptyState).toContain("running elsewhere");
// The filter branch must be tested BEFORE the ready branch, or the old
// message wins and the fix is dead code.
expect(emptyState.indexOf("view.projectFilter"))
.toBeLessThan(emptyState.indexOf("no agents running"));
});
});
describe("session card lines never spill into the neighbouring card", () => {
const view = readFileSync(join(import.meta.dir, "InfoView.qml"), "utf8");
const start = view.indexOf("hosted in \" + view.sessionHostLabel(sc.modelData)");
// Anchored on `id: sc`: the grouped-roster list nests a second
// `delegate: Rectangle {` inside this one, and a bare search finds that.
const card = view.slice(view.lastIndexOf("delegate: Rectangle {\n id: sc", start), view.indexOf("\n MouseArea {", start));
const block = view.slice(view.lastIndexOf("ColumnLayout", start), view.indexOf("\n }", start));
const tag = view.slice(view.indexOf("component Tag: Rectangle"), view.indexOf("component PowerToggle"));
const stale = card.slice(card.indexOf("sc.modelData.stale === true"), card.indexOf("Item { Layout.fillWidth: true; Layout.minimumWidth: 0 }"));
// Anchored on the arrow rather than on the expression: the topic is read
// through a masked binding now, so the old literal no longer appears.
const topicMark = block.indexOf('? "↳ "');
const topic = block.slice(block.lastIndexOf("PlainText {", topicMark), block.indexOf("maximumLineCount", topicMark));
test("every fill-width single-line text in a session card elides", () => {
// The merged pid/cpu line had no elide: the taller first card's line ran under its
// neighbour's git line ("git mainc·uclean · ram 360M"). Fill-width, one line ⇒ elide.
const lines = block.split("\n").filter(l => l.includes("PlainText {") && l.includes("Layout.fillWidth: true") && !l.includes("wrapMode"));
expect(lines.length).toBeGreaterThan(3);
for (const line of lines)
expect(line).toMatch(/elide: Text\.Elide(Right|Middle|Left)/);
});
test("fill-width session text can shrink below the unelided string", () => {
// elide is a no-op until the layout may assign a width smaller than implicitWidth.
// A STALE card's topic/git/pid then painted into the next card.
const lines = block.split("\n").filter(l => l.includes("PlainText {") && l.includes("Layout.fillWidth: true"));
expect(lines.length).toBeGreaterThan(3);
for (const line of lines)
expect(line).toMatch(/Layout\.minimumWidth: 0/);
expect(topic).toContain("Layout.minimumWidth: 0");
expect(topic).toContain("wrapMode: Text.Wrap");
});
test("the STALE chip shares leftover header space and the Tag elides when squeezed", () => {
expect(stale).toContain("Layout.fillWidth: true");
expect(stale).toContain("Layout.minimumWidth: 0");
expect(stale).toContain("Layout.maximumWidth: implicitWidth");
expect(tag).toContain("clip: true");
expect(tag).toContain("elide: Text.ElideRight");
expect(card).toMatch(/clip: true/);
});
});
describe("recent tasks keep quieter providers", () => {
test("the default 80-row window still includes OpenCode and Pi when Claude dominates", () => {
const source = view.match(/function fairRecentWindow\([\s\S]*?\n \}/)?.[0];
expect(source).toBeTruthy();
const fairRecentWindow = Function(`return (${source})`)();
const rows = [];
for (let i = 0; i < 90; i++) rows.push({ provider: "claude", ts: 1000 - i, session: "c" + i, text: "c" + i });
rows.push({ provider: "opencode", ts: 10, session: "o1", text: "oc" });
rows.push({ provider: "pi", ts: 9, session: "p1", text: "pi" });
const mixed = fairRecentWindow(rows, 80, 6);
expect(mixed.some((row: any) => row.provider === "opencode")).toBe(true);
expect(mixed.some((row: any) => row.provider === "pi")).toBe(true);
expect(mixed).toHaveLength(80);
expect(mixed.map((row: any) => row.ts)).toEqual(mixed.map((row: any) => row.ts).sort((a: number, b: number) => b - a));
});
test("provider reservations preserve pinned-first ordering even below the row limit", () => {
const source = view.match(/function fairRecentWindow\([\s\S]*?\n \}/)?.[0];
const fairRecentWindow = Function(`return (${source})`)();
const pinned = { provider: "pi", ts: 1, session: "pin", text: "pinned old prompt" };
const recent = Array.from({ length: 10 }, (_, i) => ({ provider: "claude", ts: 100 - i, session: "c" + i, text: "c" + i }));
const quiet = { provider: "opencode", ts: 2, session: "o", text: "older quiet prompt" };
const rows = [pinned, ...recent, quiet];
expect(fairRecentWindow(rows, 80, 6)).toEqual(rows);
// Selection may drop rows, but must preserve the input's relative order.
const limited = fairRecentWindow(rows, 8, 2);
expect(limited[0]).toBe(pinned);
expect(limited).toContain(quiet);
expect(limited).toHaveLength(8);
const positions = limited.map((row: any) => rows.indexOf(row));
expect(positions).toEqual(positions.slice().sort((a: number, b: number) => a - b));
expect(fairRecentWindow([...rows, quiet], 80, 6)).toEqual(rows);
});
});
describe("stream privacy mode", () => {
test("persists a toggle that masks identity and leaves OSS project names", () => {
expect(settings).toContain("property bool privacyMode: false");
expect(settings).toContain("function togglePrivacyMode()");
expect(settings).toContain("privacyMode: privacyMode");
expect(settings).toContain("readonly property int privacyUnlockNeeded: 3");
expect(service).toContain("function togglePrivacy(): void { dashboardSettings.togglePrivacyMode() }");
expect(overlay).toContain("if (!event.isAutoRepeat) dashboardSettings.togglePrivacyMode()");
expect(service).toContain("function getPrivacy(): string");
expect(view).toContain("function wanText()");
expect(view).toContain("function wifiLabel(net)");
expect(view).toContain("function machineHint()");
expect(view).toContain("function displayPath(path)");
expect(view).toContain('return privacyMode ? "—" : (view.machine.externalIp || "—")');
expect(view).toContain('return privacyMode ? "WIFI" : ("WIFI " + (n.ssid || ""))');
expect(view).toContain('if (privacyMode) return "privacy · " + up');
expect(view).toContain("p.replace(/^\\/home\\/[^/]+/, \"~\")");
expect(view).toContain("visible: !view.privacyMode && !!mc.net.addr");
expect(view).toContain("privacyMode || !github.login");
expect(view).toContain("privacyMode || !view.gitea.login");
expect(view).toContain("function displayTitle(title)");
expect(view).toContain("view.displayTitle((sessionInspector.session.window || {}).title)");
expect(view).toContain("view.displayTitle((sc.modelData.window || {}).title)");
expect(view).not.toContain('text: sc.modelData.window ? (sc.modelData.window.title || "") : ""');
expect(view).not.toContain('(sessionInspector.session.window || {}).title || "no window title"');
expect(view).toContain("onPrivacyModeChanged: if (privacyMode && previewsEnabled) previewsEnabled = false");
expect(view).toContain("view.previewsEnabled && !view.privacyMode");
expect(view).toContain('text: !view.privacyMode ? "PRIVACY" : (view.settings.privacyUnlockCount > 0 ? "PRIVACY ON · " + view.settings.privacyUnlockCount + "/" + view.settings.privacyUnlockNeeded : "PRIVACY ON")');
expect(view).not.toContain('text: "WAN " + (view.machine.externalIp || "—")');
expect(view).not.toContain("WIFI \" + (mc.net.ssid");
});
test("one press enables privacy, three presses disable it", () => {
const source = settings.match(/function privacyUnlockStep\([\s\S]*?\n \}/)?.[0];
expect(source).toBeTruthy();
const privacyUnlockStep = Function(`return (${source})`)();
expect(privacyUnlockStep(false, 0, 3)).toEqual({ on: true, count: 0 });
expect(privacyUnlockStep(true, 0, 3)).toEqual({ on: true, count: 1 });
expect(privacyUnlockStep(true, 1, 3)).toEqual({ on: true, count: 2 });
expect(privacyUnlockStep(true, 2, 3)).toEqual({ on: false, count: 0 });
expect(privacyUnlockStep(true, 5, 3)).toEqual({ on: false, count: 0 });
expect(settings).toContain("privacyUnlockReset.restart()");
expect(settings).toContain("readonly property int privacyUnlockMs: 2000");
expect(service).toContain("function setPrivacy(v: string): void { dashboardSettings.setPrivacyMode(");
});
test("window titles lose account, host and home path under privacy", () => {
const source = view.match(/function displayTitle\([\s\S]*?\n \}/)?.[0];
expect(source).toBeTruthy();
const masked = Function("privacyMode", `return (${source})`)(true);
const clear = Function("privacyMode", `return (${source})`)(false);
expect(masked("larry@box: /home/larry/Projects/x")).toBe("user@host: ~/Projects/x");
expect(masked("claude — /home/larry/work")).toBe("claude — ~/work");
expect(masked("Processing… task")).toBe("Processing… task");
expect(masked("")).toBe("");
expect(clear("larry@box: /home/larry/Projects/x")).toBe("larry@box: /home/larry/Projects/x");
});
test("recent-task prompts keep the first four words and mask the rest", () => {
const source = view.match(/function obfuscatePrompt\([\s\S]*?\n \}/)?.[0];
expect(source).toBeTruthy();
const obfuscatePrompt = Function(`return (${source})`)();
expect(obfuscatePrompt("one two three four five six seven")).toBe("one two three four ···");
expect(obfuscatePrompt("one two three four five")).toBe("one two three four ···");
expect(obfuscatePrompt("one two three four")).toBe("one two three four");
expect(obfuscatePrompt("one two three")).toBe("one two three");
expect(obfuscatePrompt(" one two three four five ")).toBe("one two three four ···");
expect(obfuscatePrompt("")).toBe("");
expect(obfuscatePrompt(null)).toBe("");
expect(view).toContain("function displayPrompt(text)");
expect(view).toContain("view.displayPrompt(ri.modelData.text)");
expect(view).toContain("view.displayPrompt(promptDrawer.prompt.text)");
expect(view).toContain("view.displayPrompt(modelData.text)");
expect(view).not.toContain("text: ri.modelData.text || \"\"");
expect(view).not.toContain("text: promptDrawer.prompt.text || \"\"");
});
});
describe("github activity heatmap", () => {
test("registers GITHUB as a removable module beside ACTIVITY and reaches it from the keyboard", () => {
const ids = [...settings.matchAll(/\{ id: "([a-zA-Z]+)", label: "[^"]+" \}/g)].map(match => match[1]);
expect(ids.indexOf("github")).toBe(ids.indexOf("activity") + 1);
// 16 with CONTAINERS (#19), FLEET (#35) and HERMES HOSTS. Pinned on purpose: a module
// added without a decision shows up here.
expect(ids).toHaveLength(16);
expect(ids[10]).toBe("media");
expect(ids[11]).toBe("gitea");
expect(ids[12]).toBe("apps");
expect(overlay).toContain("event.key >= Qt.Key_0 && event.key <= Qt.Key_9");
expect(overlay).toContain("event.key === Qt.Key_0 ? 9 : event.key - Qt.Key_1");
// Key n toggles definitions[n-1]; 0 is the tenth. Documented as 4 = GITHUB, 0 = PROJECTS.
expect(ids[3]).toBe("github");
expect(ids[9]).toBe("projects");
// Appended in landing order: APPS 12, CONTAINERS 13, FLEET 14 — all
// beyond the keyboard's ten digit slots, so no existing shortcut moved.
expect(ids[13]).toBe("containers");
expect(ids[14]).toBe("fleet");
});
test("shares one HeatPanel across equally sized activity, GitHub and Gitea cards", () => {
expect(view).toContain("component HeatPanel: Item");
expect(view.match(/HeatPanel \{/g)).toHaveLength(3);
expect(view).toContain('title: "GITEA · LAST 7 DAYS"');
expect(view).toContain("cells: view.gitea.cells || []");
expect(view).toContain("onCellClicked: function(index) { view.toggleGiteaCell(index) }");
expect(view).toContain('title: "ACTIVITY · LAST 7 DAYS"');
expect(view).toContain('title: "GITHUB · LAST 7 DAYS"');
expect(view).toContain('visible: view.sectionEnabled("activity") || view.sectionEnabled("github") || view.sectionEnabled("gitea")');
// Both cards ask for an equal share; neither may impose a minimum that pushes the other off screen.
expect(view.match(/Layout\.preferredWidth: 1\n\s+Layout\.minimumWidth: 0\n\s+visible: view\.sectionEnabled\("(activity|github|gitea)"\)/g)).toHaveLength(3);
expect(view).toContain("cells: view.github.cells || []");
expect(view).toContain("kindFiltersCells: true");
expect(view).toContain("showRepos: true");
expect(view).toContain('kinds: ["claude", "codex", "grok", "hermes", "opencode", "pi", "omp", "muse", "cursor", "gemini", "ollama"]');
});
test("explains every GitHub feed state and keeps the AI activity filter wiring intact", () => {
for (const state of ["missing", "unauthenticated", "pending", "unavailable", "stale", "ok"]) expect(view).toContain(`case "${state}":`);
expect(view).toContain("run gh auth login");
expect(view).toContain("onCellClicked: function(index) { view.toggleActivityCell(index) }");
expect(view).toContain("onKindClicked: function(kind) { view.toggleActivityProvider(kind) }");
expect(view).toContain("onCellClicked: function(index) { view.toggleGithubCell(index) }");
expect(view).toContain('githubCellFilter = -1; githubKindFilter = ""');
// A pinned GitHub cell keeps its breakdown in the status line once the pointer leaves it.
expect(view).toContain("pinnedBreakdown: true");
expect(view).toContain('"pinned · " + panel.cellLabel(panel.selectedCell)');
});
});
test("persisted Ollama origins reject credentials and request paths", () => {
const source = settings.match(/function normalizeOllamaHost\([\s\S]*?\n \}/)?.[0];
const normalize = Function(`return (${source})`)();
expect(normalize("127.0.0.1:11435")).toBe("http://127.0.0.1:11435");
expect(normalize("https://ollama.example/")).toBe("https://ollama.example");
expect(normalize("http://[::1]:11434")).toBe("http://[::1]:11434");
for (const invalid of ["http://u:password@host", "http://host/api", "http://host?q=x", "http://host#x", "http://host:65536"]) expect(normalize(invalid)).toBe("");
});
describe("media controls card", () => {
test("registers a reorderable lower-right MPRIS card with prev/play/next and a title line", () => {
expect(settings).toContain('{ id: "media", label: "MEDIA" }');
expect(settings).toContain('property var rightOrder: ["usage", "localAi", "remoteRoster", "fleet", "hermesHosts", "machine", "media", "containers"]');
expect(view).toContain('title: "MEDIA CONTROLS"');
expect(view).toContain('moveId: "media"');
expect(view).toContain("import Quickshell.Services.Mpris");
expect(view).toContain('text: "PREV"');
expect(view).toContain('text: mediaCard.playing ? "PAUSE" : "PLAY"');
expect(view).toContain('text: "NEXT"');
expect(view).toContain('onClicked: mediaCard.run("previous")');
expect(view).toContain('onClicked: mediaCard.run("playPause")');
expect(view).toContain('onClicked: mediaCard.run("next")');
expect(view).toContain("mediaCard.displayTitle");
expect(view).toContain("readonly property string displayTitle: rawTitle || (player || demo ? \"no title\" : \"no media player\")");
expect(view).not.toContain("trackArtUrl");
const mediaBlock = view.slice(view.indexOf('id: mediaCard'), view.indexOf("Legend"));
expect(mediaBlock).not.toContain("Image {");
expect(mediaBlock).not.toContain("privacyMode");
});
});
test("media selection prefers playback and skips playerctld when another player exists", () => {
const proxySource = view.match(/function mediaIsProxy\([\s\S]*?\n \}/)?.[0];
const mediaIsProxy = Function(`return (${proxySource})`)();
const body = view.match(/readonly property var mediaPlayer: \{([\s\S]*?)\n \}/)?.[1];
const choose = Function("view", body || "");
const proxy = { dbusName: "org.mpris.MediaPlayer2.playerctld", isPlaying: true };
const paused = { dbusName: "org.mpris.MediaPlayer2.test", isPlaying: false };
const playing = { dbusName: "org.mpris.MediaPlayer2.music", isPlaying: true };
expect(choose({ mprisPlayers: [proxy, paused, playing], mediaIsProxy })).toBe(playing);
expect(choose({ mprisPlayers: [proxy, paused], mediaIsProxy })).toBe(paused);
expect(choose({ mprisPlayers: [proxy], mediaIsProxy })).toBe(proxy);
expect(choose({ mprisPlayers: [], mediaIsProxy })).toBeNull();
});
// Grok Bot runs one Electron process and the collector expands its roster into
// one card per bot, so a nine-bot roster is nine cards and, on its own, trips
// the dense-layout threshold and shrinks every other card on the desk. The desk
// groups the quiet ones back into a single card, per provider and optionally.
describe("quiet sessions group into one card per provider", () => {
const qml = (() => {
const names = ["sessionActivityAt", "sessionIsQuiet", "sessionGroupRow", "groupQuietSessions"];
const sources = names.map(name => {
const source = view.match(new RegExp(`function ${name}\\([\\s\\S]*?\\n \\}`))?.[0];
expect(source, `${name} is missing from InfoView.qml`).toBeTruthy();
return source;
});
// Evaluated together: they call each other by bare name in QML, so they
// have to share one scope here too.
return Function(`${sources.join("\n")}\nreturn { sessionActivityAt, sessionIsQuiet, sessionGroupRow, groupQuietSessions }`)();
})();
const NOW = 1_700_000_000_000;
const HOUR = 3_600_000;
const GROUPED = { "grok-bot": true };
const bot = (project: string, agoMs: number, extra: Record<string, unknown> = {}) => ({
provider: "grok-bot", name: "Grok Bot", project, pid: 4242,
topicAt: NOW - agoMs, resources: { cpuPct: null, rss: null }, ...extra,
});
const claude = (project: string, agoMs: number) => ({
provider: "claude", name: "claude", project, pid: 900 + agoMs, topicAt: NOW - agoMs,
});
const group = (rows: any[]) => qml.groupQuietSessions(rows, GROUPED, HOUR, 2, NOW);
test("groups a provider's quiet sessions into one row after that provider's cards", () => {
const rows = [claude("api", 0), bot("news", 4 * HOUR), bot("recipes", 9 * HOUR), claude("web", 0)];
const grouped = group(rows);
expect(grouped.length).toBe(3);
// A group is taller than its neighbours and a Flow row is as tall as its
// tallest card, so every group goes at the very end: the live cards stay
// one uniform grid and the only overhang is at the bottom edge.
expect(grouped[0]).toBe(rows[0]);
expect(grouped[1]).toBe(rows[3]);
expect(grouped[2].grouped).toBe(true);
expect(grouped[2].provider).toBe("grok-bot");
expect(grouped[2].members.map((m: any) => m.project)).toEqual(["news", "recipes"]);
expect(grouped[2].project).toBe("2 quiet");
});
test("the group lands after the provider's loud cards, never in front of them", () => {
const rows = [
bot("news", 9 * HOUR),
bot("asking", 9 * HOUR, { attention: "waiting" }),
bot("recipes", 9 * HOUR),
bot("broken", 9 * HOUR, { attention: "blocked" }),
claude("api", 0),
];
const grouped = group(rows);
expect(grouped.map((r: any) => r.grouped === true ? "GROUP" : r.project))
.toEqual(["asking", "broken", "api", "GROUP"]);
});
test("two grouped providers keep first-appearance order at the end", () => {
const rows = [
claude("api", 9 * HOUR), bot("news", 9 * HOUR), claude("web", 9 * HOUR),
bot("recipes", 9 * HOUR), bot("live", 1000),
];
const grouped = qml.groupQuietSessions(rows, { "grok-bot": true, claude: true }, HOUR, 2, NOW);
expect(grouped.map((r: any) => r.grouped === true ? `GROUP:${r.provider}` : r.project))
.toEqual(["live", "GROUP:claude", "GROUP:grok-bot"]);
});
test("a request never groups, however old; a stale notification does", () => {
// attentionSignal has three states and they are not the same kind of thing.
// "waiting" (blocked on your answer) and "blocked" (conflict, crash,
// failure) are requests, and a request does not expire. "done" — ready for
// review, or a bot holding unread replies — is a notification, and one
// nobody has looked at for a month has stopped being news.
const rows = [
bot("news", 9 * HOUR),
bot("asking", 400 * HOUR, { attention: "waiting", attentionReason: "asking is waiting for your answer" }),
bot("broken", 400 * HOUR, { attention: "blocked" }),
bot("stale-unread", 400 * HOUR, { attention: "done" }),
bot("fresh-unread", 60_000, { attention: "done" }),
bot("working", 400 * HOUR, { busy: true }),
bot("recipes", 9 * HOUR),
];
const grouped = group(rows);
expect(grouped.map((row: any) => row.grouped === true ? "GROUP" : row.project))
.toEqual(["asking", "broken", "fresh-unread", "working", "GROUP"]);
expect(grouped[4].members.map((m: any) => m.project)).toEqual(["news", "stale-unread", "recipes"]);
// Grouped-but-unseen is counted so the card can say so rather than hide it.
expect(grouped[4].review).toBe(1);
});
test("a recently active session keeps its own card", () => {
const rows = [bot("news", 9 * HOUR), bot("live", 2 * 60_000), bot("recipes", 9 * HOUR)];
const grouped = group(rows);
expect(grouped.length).toBe(2);
expect(grouped[0].project).toBe("live");
expect(grouped[1].members.map((m: any) => m.project)).toEqual(["news", "recipes"]);
});
test("grouping one card into one card is refused", () => {
const rows = [bot("news", 9 * HOUR), bot("live", 60_000)];
expect(group(rows)).toEqual(rows);
// ...and the floor cannot be argued below two.
expect(qml.groupQuietSessions(rows, GROUPED, HOUR, 1, NOW)).toEqual(rows);
expect(qml.groupQuietSessions(rows, GROUPED, HOUR, 0, NOW)).toEqual(rows);
});
test("a provider with grouping off is passed through untouched", () => {
const rows = [bot("news", 9 * HOUR), bot("recipes", 9 * HOUR), bot("chat", 9 * HOUR)];
expect(qml.groupQuietSessions(rows, { "grok-bot": false }, HOUR, 2, NOW)).toEqual(rows);
expect(qml.groupQuietSessions(rows, {}, HOUR, 2, NOW)).toEqual(rows);
// Enabling one provider never groups another.
const mixed = [claude("api", 9 * HOUR), claude("web", 9 * HOUR), ...rows];
const grouped = qml.groupQuietSessions(mixed, GROUPED, HOUR, 2, NOW);
expect(grouped.slice(0, 2)).toEqual([mixed[0], mixed[1]]);
expect(grouped[2].grouped).toBe(true);
expect(grouped.length).toBe(3);
});
test("a zero window groups every idle session whatever its age", () => {
const rows = [bot("news", 1000), bot("recipes", 2000), bot("asking", 1000, { attention: "waiting" })];
const grouped = qml.groupQuietSessions(rows, GROUPED, 0, 2, NOW);
expect(grouped.length).toBe(2);
expect(grouped[0].project).toBe("asking");
expect(grouped[1].members.map((m: any) => m.project)).toEqual(["news", "recipes"]);
});