-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.html
More file actions
1377 lines (1328 loc) · 67.5 KB
/
Copy pathcontroller.html
File metadata and controls
1377 lines (1328 loc) · 67.5 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ltbv — Controller</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><polygon points='32,25 12,42 2,42 2,58 12,58 32,75' fill='%23e8e8e8'/><path d='M50,32 Q68,50 50,68' fill='none' stroke='%23e8e8e8' stroke-width='7' stroke-linecap='round'/><path d='M62,20 Q85,50 62,80' fill='none' stroke='%23e8e8e8' stroke-width='6' stroke-linecap='round'/></svg>">
<style>
:root {
color-scheme: dark;
--bg: #141414;
--panel: #1a1a1a;
--panel-2: #1f1f1f;
--ink: #101010;
--line: #2b2b2b;
--line-soft: #242424;
--text: #e8e8e8;
--muted: #9a9a9a;
--faint: #6a6a6a;
--green: #58d68d;
--blue: #68a4ff;
--yellow: #f2c94c;
--red: #ff6b6b;
--mono: "Share Tech Mono", ui-monospace, Menlo, monospace;
--sans: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; border-radius: 0 !important; }
body {
margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
font-family: var(--sans); font-size: 12px; line-height: 1.45;
}
code, .num, input, select, textarea { font-family: var(--mono); }
::selection { background: #2a3f5f; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 14px 16px 48px; }
/* ---------- top ---------- */
.topbar {
display: grid; grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
gap: 8px; align-items: center; padding: 9px 12px; margin-bottom: 10px;
border: 1px solid var(--line); background: var(--panel);
}
.topbar h1 { margin: 0; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.top-actions { display: flex; gap: 6px; justify-content: flex-end; }
.pill {
display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px;
border: 1px solid var(--line); background: var(--panel-2);
color: var(--muted); font-size: 10px; white-space: nowrap;
font-family: var(--mono); letter-spacing: 0.04em;
}
.dot { width: 6px; height: 6px; background: var(--faint); }
.dot.on { background: var(--green); }
.btn {
padding: 5px 10px; border: 1px solid var(--line); background: var(--panel-2);
color: var(--text); cursor: pointer; font-size: 10px; font-family: var(--sans);
text-transform: uppercase; letter-spacing: 0.06em;
}
.btn:hover { border-color: var(--blue); }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.danger.busy { border-color: var(--yellow); color: var(--yellow); }
.btn.danger.done { border-color: var(--green); color: var(--green); }
.btn.toggle.on { border-color: var(--yellow); color: var(--yellow); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.wide { width: 100%; padding: 10px; font-size: 11px; letter-spacing: 0.08em; }
#mute { min-width: 116px; }
#shutup { min-width: 74px; }
@media (max-width: 820px) {
.topbar { grid-template-columns: 1fr; }
.pills, .top-actions { justify-content: flex-start; }
}
/* now speaking strip */
#nowstrip {
display: none; align-items: center; gap: 10px; margin-bottom: 10px;
padding: 8px 12px; border: 1px solid var(--line); background: var(--panel);
overflow: hidden;
}
#nowstrip.on { display: flex; }
.pulse { width: 8px; height: 8px; background: var(--green); flex: none; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.7); } }
#now-meta { font-family: var(--mono); font-size: 10px; color: var(--muted); flex: none; text-transform: uppercase; letter-spacing: 0.05em; }
#now-meta b { color: var(--text); font-weight: 400; }
#stage { flex: none; width: 220px; height: 30px; }
#now-text { flex: 1; min-width: 0; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) { #stage { display: none; } }
/* ---------- layout ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.grid2.single { grid-template-columns: 1fr; }
.col { display: grid; gap: 10px; min-width: 0; }
@media (max-width: 1140px) { .grid2 { grid-template-columns: 1fr; } }
.view-tabs {
display: flex; gap: 0; margin-bottom: 10px; border: 1px solid var(--line);
background: var(--panel); overflow-x: auto;
}
.view-tab {
flex: 1; min-width: 110px; padding: 7px 12px; border: 0; border-right: 1px solid var(--line);
background: transparent; color: var(--faint); cursor: pointer; font-family: var(--mono);
font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
}
.view-tab:last-child { border-right: 0; }
.view-tab.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px var(--blue); }
[hidden] { display: none !important; }
section { border: 1px solid var(--line); background: var(--panel); min-width: 0; }
section > header {
display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
padding: 8px 12px; border-bottom: 1px solid var(--line-soft); background: #171717;
}
section > header h2 { margin: 0; font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; }
section > header span { color: var(--faint); font-size: 10px; }
.body { padding: 12px; }
.err-line { color: var(--red); font-size: 10px; font-family: var(--mono); min-height: 14px; margin-top: 6px; }
.saved { color: var(--green); font-size: 10px; font-family: var(--mono); opacity: 0; transition: opacity 0.25s; }
.saved.show { opacity: 1; }
/* ---------- histogram ---------- */
.histo-wrap { position: relative; }
#histo { display: block; width: 100%; height: 130px; cursor: ew-resize; touch-action: none; }
#histo-tip {
position: absolute; display: none; pointer-events: none; z-index: 3;
background: var(--ink); border: 1px solid var(--line); padding: 3px 7px;
font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap;
}
.legend { display: flex; gap: 14px; margin-top: 8px; color: var(--faint); font-size: 10px; font-family: var(--mono); flex-wrap: wrap; }
.legend b { color: var(--text); font-weight: 400; }
.sw { display: inline-block; width: 8px; height: 8px; vertical-align: -1px; margin-right: 5px; }
/* ---------- scrub controls ---------- */
.scrubs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin-top: 12px; }
@media (max-width: 620px) { .scrubs { grid-template-columns: 1fr; } }
.scrub { cursor: ew-resize; user-select: none; padding: 4px 0 6px; position: relative; }
.scrub .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.scrub .lbl { color: var(--muted); font-size: 11px; }
.scrub .val { font-family: var(--mono); font-size: 12px; color: var(--text); }
.scrub .val input {
width: 74px; background: var(--ink); border: 1px solid var(--blue); color: var(--text);
font-size: 12px; padding: 0 4px; text-align: right;
}
.scrub .track { margin-top: 5px; height: 2px; background: var(--line-soft); position: relative; }
.scrub .fill { position: absolute; left: 0; top: 0; bottom: 0; background: #3d5a86; }
.scrub .nub { position: absolute; top: -2px; width: 2px; height: 6px; background: var(--blue); }
.scrub:hover .track { background: var(--line); }
.scrub.err .val { color: var(--red); }
.scrub.err .fill, .scrub.err .nub { background: var(--red); }
/* ---------- quiet hours strip ---------- */
.quiet { margin-top: 14px; }
.quiet .cap { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.quiet .cap .lbl { color: var(--muted); font-size: 11px; }
.quiet .cap .st { font-family: var(--mono); font-size: 10px; color: var(--faint); }
#qstrip {
position: relative; height: 26px; border: 1px solid var(--line-soft); background: var(--ink);
cursor: ew-resize; touch-action: none;
background-image: repeating-linear-gradient(90deg, transparent 0, transparent calc(100%/24 - 1px), #1e1e1e calc(100%/24 - 1px), #1e1e1e calc(100%/24));
}
.qsel { position: absolute; top: 0; bottom: 0; background: rgba(242, 201, 76, 0.16); border-left: 1px solid var(--yellow); border-right: 1px solid var(--yellow); pointer-events: none; }
.qlabels { display: flex; justify-content: space-between; margin-top: 3px; color: var(--faint); font-size: 9px; font-family: var(--mono); }
.quiet .actions { display: flex; gap: 8px; margin-top: 7px; align-items: center; }
/* ---------- inspector ---------- */
.stages { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 620px) { .stages { grid-template-columns: 1fr; } }
.pane-title { color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 5px; display: flex; justify-content: space-between; }
.pane {
border: 1px solid var(--line-soft); background: var(--ink); padding: 9px;
min-height: 70px; max-height: 220px; overflow: auto; font-size: 11px;
color: var(--muted); white-space: pre-wrap; word-break: break-word; line-height: 1.55;
}
.cut { background: #33181a; color: #c98f92; text-decoration: line-through; }
.spoken-row { margin-top: 8px; }
.badges { display: inline-flex; gap: 5px; }
.badge { font-family: var(--mono); font-size: 9px; padding: 1px 6px; letter-spacing: 0.05em; }
.badge.g { background: #10281b; color: var(--green); }
.badge.y { background: #2b250f; color: var(--yellow); }
.badge.r { background: #2e1416; color: var(--red); }
.badge.b { background: #16233a; color: var(--blue); }
/* ---------- voice lab ---------- */
.assigns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
@media (max-width: 620px) { .assigns { grid-template-columns: 1fr; } }
.assign { border: 1px solid var(--line-soft); background: var(--panel-2); padding: 9px; }
.assign .who { display: flex; align-items: center; gap: 6px; font-size: 9px; margin-bottom: 7px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-family: var(--mono); }
.slotdot { width: 7px; height: 7px; flex: none; }
.slotdot.claude { background: var(--blue); }
.slotdot.codex { background: var(--green); }
.slotdot.notification { background: var(--red); }
.assign .row { display: flex; gap: 6px; }
select {
background: var(--ink); border: 1px solid var(--line); color: var(--text);
padding: 4px 6px; font-size: 11px; flex: 1; min-width: 0;
}
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
display: inline-flex; align-items: center; gap: 7px; padding: 2px 3px 2px 8px;
border: 1px solid var(--line-soft); background: var(--panel-2); font-size: 10px;
color: var(--muted); font-family: var(--mono);
}
.chip .cdots { display: inline-flex; gap: 3px; }
.chip button { padding: 2px 7px; font-size: 9px; }
.audition-row { margin-bottom: 10px; }
#audition-text { width: 100%; background: var(--ink); border: 1px solid var(--line-soft); color: var(--text); padding: 6px 8px; font-size: 11px; }
#audition-text:focus { border-color: var(--blue); outline: none; }
.clone { margin-top: 12px; }
.clone-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
#clone-name { flex: 1; min-width: 120px; background: var(--ink); border: 1px solid var(--line); color: var(--text); padding: 4px 6px; font-size: 11px; }
.dropzone {
padding: 11px; border: 1px dashed var(--line-soft); color: var(--faint);
font-size: 10px; text-align: center; font-family: var(--mono); letter-spacing: 0.03em;
}
.dropzone.hot { border-color: var(--blue); color: var(--blue); }
.dropzone.rec { border-color: var(--red); color: var(--red); }
.chip .cx { padding: 2px 6px; font-size: 9px; color: var(--faint); }
.chip .cx:hover { color: var(--red); }
/* ---------- ledger ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
@media (max-width: 620px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { border: 1px solid var(--line-soft); background: var(--panel-2); padding: 8px 10px; }
.tile b { display: block; font-family: var(--mono); font-size: 17px; font-weight: 400; margin-bottom: 1px; }
.tile span { color: var(--faint); font-size: 10px; }
.lanes { display: grid; gap: 6px; }
.lane { display: grid; grid-template-columns: 130px 1fr; gap: 8px; align-items: center; }
.lane .name { color: var(--muted); font-size: 10px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane .track {
position: relative; height: 20px; background: var(--ink); border: 1px solid var(--line-soft);
background-image: repeating-linear-gradient(90deg, transparent 0, transparent calc(100%/6 - 1px), #1d1d1d calc(100%/6 - 1px), #1d1d1d calc(100%/6));
}
.lane .track::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 2px; background: #3a3a3a; }
.blip { position: absolute; top: 50%; transform: translate(-50%,-50%); background: var(--blue); }
.blip.condensed { background: var(--green); }
.blip.table { background: var(--yellow); }
.blip.notif { background: var(--red); }
.axis { display: grid; grid-template-columns: 130px 1fr; gap: 8px; margin-top: 3px; }
.axis .ticks { display: flex; justify-content: space-between; color: var(--faint); font-size: 9px; font-family: var(--mono); }
/* ---------- personality ---------- */
textarea#prompt {
width: 100%; min-height: 104px; resize: vertical; line-height: 1.55; font-size: 11px;
background: var(--ink); border: 1px solid var(--line-soft); color: var(--text); padding: 9px;
}
.row-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.style-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.style-row span { color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
#recondense-out { margin-top: 8px; display: none; }
.hint { color: var(--faint); font-size: 10px; }
kbd { font-family: var(--mono); font-size: 9px; border: 1px solid var(--line); padding: 0 4px; color: var(--muted); }
.engine-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
#condense-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 620px) { .engine-grid { grid-template-columns: 1fr; } }
.engine-card { border: 1px solid var(--line-soft); background: var(--panel-2); padding: 8px; display: grid; gap: 6px; }
.engine-card.active { border-color: var(--blue); }
.engine-card b { font-family: var(--mono); font-weight: 400; font-size: 12px; }
.engine-card span { color: var(--muted); font-size: 10px; }
.engine-card code { color: var(--yellow); font-size: 10px; word-break: break-all; }
.bench-row { display: flex; gap: 6px; align-items: stretch; margin-bottom: 8px; }
#bench-text { flex: 1; background: var(--ink); border: 1px solid var(--line-soft); color: var(--text); padding: 6px 8px; font-size: 11px; min-height: 32px; }
table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 10px; }
th, td { border-bottom: 1px solid var(--line-soft); padding: 5px 4px; text-align: left; }
th { color: var(--faint); font-weight: 400; text-transform: uppercase; letter-spacing: 0.06em; }
td { color: var(--muted); }
td strong { color: var(--text); font-weight: 400; }
.blind { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
#cleanup { margin-top: 8px; display: none; }
.doctor-summary { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.doctor-summary b { font-family: var(--mono); font-size: 16px; font-weight: 400; }
.doctor-summary span { color: var(--muted); }
.check-list { display: grid; border: 1px solid var(--line-soft); }
.check-row { display: grid; grid-template-columns: 10px 140px 1fr; gap: 8px; align-items: center; padding: 7px 9px; border-bottom: 1px solid var(--line-soft); }
.check-row:last-child { border-bottom: 0; }
.check-row i { width: 7px; height: 7px; background: var(--red); }
.check-row.ok i { background: var(--green); }
.check-row.optional i { background: var(--yellow); }
.check-row b { font-family: var(--mono); font-size: 10px; font-weight: 400; }
.check-row span { color: var(--muted); font-size: 10px; }
</style>
</head>
<body>
<div class="wrap">
<div class="topbar">
<h1>let-there-be-voice</h1>
<div class="pills">
<span class="pill"><i class="dot" id="dot"></i><span id="h-status">checking</span></span>
<span class="pill">engine <span id="h-engine">…</span></span>
<span class="pill">branch <span id="h-branch">…</span></span>
<span class="pill">condense <span id="h-provider">…</span></span>
<span class="pill">up <span id="h-uptime">…</span></span>
<span class="pill">spoke <span id="h-spoke">never</span></span>
</div>
<div class="top-actions">
<button class="btn" id="restart" title="respawn the daemon process, picks up code/config changes">restart</button>
<button class="btn toggle" id="mute" title="spacebar">shut up <kbd>space</kbd></button>
<button class="btn danger" id="shutup" title="stop current speech">chill</button>
</div>
</div>
<div id="nowstrip">
<i class="pulse"></i>
<span id="now-meta"></span>
<canvas id="stage" title="live waveform"></canvas>
<span id="now-text"></span>
<button class="btn danger" id="now-stop">chill</button>
</div>
<nav class="view-tabs" aria-label="Controller mode">
<button class="view-tab active" data-view="cockpit">Cockpit</button>
<button class="view-tab" data-view="lab">Lab</button>
<button class="view-tab" data-view="history">History</button>
<button class="view-tab" data-view="diagnostics">Diagnostics</button>
</nav>
<div class="grid2">
<div class="col">
<section data-view="cockpit">
<header><h2>Mixing Desk</h2><span class="saved" id="saved-desk">saved</span></header>
<div class="body">
<div class="histo-wrap">
<canvas id="histo"></canvas>
<div id="histo-tip"></div>
</div>
<div class="legend">
<span><i class="sw" style="background:#274064"></i>spoken raw</span>
<span><i class="sw" style="background:#2e5731"></i>would condense</span>
<span>threshold <b id="r-thresh">…</b></span>
<span>condenses <b id="r-pct">…</b> of recent</span>
<span>median <b id="r-median">…</b></span>
</div>
<div class="scrubs" id="scrubs"></div>
<div class="row-actions">
<button class="btn toggle" id="duck-toggle">spotify duck off</button>
<button class="btn toggle" id="browser-duck-toggle">browser / youtube duck off</button>
<span class="hint">fade media during speech, restore after</span>
</div>
<div class="row-actions">
<button class="btn toggle" id="inbox-toggle">voice inbox off</button>
<button class="btn" id="return-briefing">I'm back</button>
<button class="btn" id="inbox-clear">clear</button>
<span class="hint" id="inbox-state">no updates waiting</span>
</div>
<div class="row-actions">
<button class="btn" data-backchannel="repeat">repeat</button>
<button class="btn" data-backchannel="slower">slower</button>
<button class="btn" data-backchannel="faster">faster</button>
<button class="btn" data-backchannel="brief">brief</button>
<button class="btn" data-backchannel="normal">normal</button>
<button class="btn" data-backchannel="recap">recap</button>
<span class="hint">backchannel the last spoken line</span>
</div>
<div class="quiet">
<div class="cap">
<span class="lbl">quiet hours · drag across the day</span>
<span class="st" id="q-state">disabled</span>
</div>
<div id="qstrip"></div>
<div class="qlabels"><span>00</span><span>06</span><span>12</span><span>18</span><span>24</span></div>
<div class="actions">
<button class="btn" id="q-clear">clear</button>
<span class="hint">speech is accepted but stays silent inside the window</span>
</div>
</div>
<div class="err-line" id="err-desk"></div>
</div>
</section>
<section data-view="lab">
<header><h2>Voice Lab</h2><span>generated live from one reference sample each</span></header>
<div class="body">
<div class="assigns">
<div class="assign"><div class="who"><i class="slotdot claude"></i>claude</div><div class="row"><select id="voice-claude"></select><button class="btn" data-audition="claude">play</button></div></div>
<div class="assign"><div class="who"><i class="slotdot codex"></i>codex</div><div class="row"><select id="voice-codex"></select><button class="btn" data-audition="codex">play</button></div></div>
<div class="assign"><div class="who"><i class="slotdot notification"></i>notify</div><div class="row"><select id="voice-notification"></select><button class="btn" data-audition="notification">play</button></div></div>
</div>
<div class="audition-row">
<input type="text" id="audition-text" placeholder="text to audition (blank = default sample)" value="The quick brown fox jumps over the lazy dog, and reads it back to you.">
</div>
<div class="pane-title"><span>catalog</span><span id="lab-state"></span></div>
<div class="chips" id="catalog"></div>
<div class="clone">
<div class="clone-row">
<input type="text" id="clone-name" placeholder="new voice name" maxlength="24">
<button class="btn" id="clone-rec">record 15s</button>
<label class="btn" for="clone-file">drop / pick a wav</label>
<input type="file" id="clone-file" accept="audio/*" hidden>
</div>
<div id="clone-drop" class="dropzone">drop an audio file here, or record yourself, to mint a new voice</div>
<div class="err-line" id="err-lab"></div>
</div>
</div>
</section>
<section data-view="history">
<header><h2>Ledger</h2><span>last 12 hours</span></header>
<div class="body">
<div class="tiles">
<div class="tile"><b id="t-talk">…</b><span>talk-time today</span></div>
<div class="tile"><b id="t-speaks">…</b><span>speaks today</span></div>
<div class="tile"><b id="t-condense">…</b><span>condense rate</span></div>
<div class="tile"><b id="t-tables">…</b><span>tables skipped</span></div>
</div>
<div class="lanes" id="lanes"></div>
<div class="axis"><span></span><div class="ticks"><span>-12h</span><span>-10h</span><span>-8h</span><span>-6h</span><span>-4h</span><span>-2h</span><span>now</span></div></div>
<div class="legend" style="margin-top:8px">
<span><i class="sw" style="background:var(--blue)"></i>raw</span>
<span><i class="sw" style="background:var(--green)"></i>condensed</span>
<span><i class="sw" style="background:var(--yellow)"></i>table</span>
<span><i class="sw" style="background:var(--red)"></i>notification</span>
</div>
</div>
</section>
</div>
<div class="col">
<section data-view="lab">
<header><h2>TTS Shootout</h2><span id="bench-state">Pocket stays default</span></header>
<div class="body">
<div class="engine-grid" id="engine-grid"></div>
<div class="bench-row">
<input id="bench-text" value="Codex finished the task and is ready for your next instruction.">
<button class="btn" id="bench-run">compare</button>
</div>
<table>
<thead><tr><th>engine</th><th>voice</th><th>rtf</th><th>ttfa</th><th>synth</th><th>dur</th><th></th><th></th></tr></thead>
<tbody id="bench-body"><tr><td colspan="8">no bench run yet</td></tr></tbody>
</table>
<div class="blind" id="blind"></div>
<div class="pane" id="cleanup"></div>
</div>
</section>
<section data-view="diagnostics">
<header><h2>Strip Inspector</h2><span>last reply through the pipeline</span></header>
<div class="body">
<div class="stages">
<div><div class="pane-title"><span>raw</span><span id="raw-count"></span></div><div class="pane" id="raw-pane">no reply seen yet by this daemon</div></div>
<div><div class="pane-title"><span>cleaned</span><span id="clean-count"></span></div><div class="pane" id="clean-pane">…</div></div>
</div>
<div class="spoken-row">
<div class="pane-title"><span>final audio text</span><span class="badges" id="stage-badges"></span></div>
<div class="pane" id="spoken-pane">…</div>
</div>
</div>
</section>
<section data-view="diagnostics">
<header><h2>System Diagnostics</h2><button class="btn" id="doctor-refresh">refresh</button></header>
<div class="body">
<div class="doctor-summary"><b id="doctor-state">checking</b><span id="doctor-meta"></span></div>
<div class="check-list" id="doctor-list"></div>
</div>
</section>
<section data-view="diagnostics">
<header><h2>Session Arc</h2><button class="btn" id="timeline-refresh">refresh</button></header>
<div class="body">
<div class="pane" id="timeline-recap">no recent work recorded</div>
<div class="check-list" id="timeline-events"></div>
</div>
</section>
<section data-view="lab">
<header><h2>Personality</h2><span class="saved" id="saved-prompt">saved</span></header>
<div class="body">
<textarea id="prompt" spellcheck="false"></textarea>
<div class="hint" style="margin-top:6px">autosaves as you type</div>
<div class="row-actions">
<button class="btn wide" id="recondense">hear the last reply condensed with this prompt</button>
</div>
<div class="pane" id="recondense-out"></div>
<div class="err-line" id="err-prompt"></div>
<div class="style-row" style="margin-top:10px"><span>condense provider</span></div>
<div class="engine-grid" id="condense-grid"></div>
</div>
</section>
</div>
</div>
</div>
<script>
const $ = (id) => document.getElementById(id);
const api = async (path, body) => {
const res = await fetch(path, body ? { method: "POST", body: JSON.stringify(body) } : {});
return res.json();
};
const flash = (id) => { const el = $(id); el.classList.add("show"); setTimeout(() => el.classList.remove("show"), 1100); };
let cfg = null;
let entries = [];
let dragThresh = null;
let engines = [];
let benchResults = [];
let blindOrder = [];
let isMuted = false;
let activeView = "cockpit";
function setView(view) {
const valid = new Set(["cockpit", "lab", "history", "diagnostics"]);
activeView = valid.has(view) ? view : "cockpit";
for (const section of document.querySelectorAll("section[data-view]")) {
section.hidden = section.dataset.view !== activeView;
}
let visibleCols = 0;
for (const col of document.querySelectorAll(".grid2 > .col")) {
const visible = !!col.querySelector(`section[data-view="${activeView}"]`);
col.hidden = !visible;
if (visible) visibleCols++;
}
document.querySelector(".grid2").classList.toggle("single", visibleCols === 1);
for (const tab of document.querySelectorAll(".view-tab")) {
tab.classList.toggle("active", tab.dataset.view === activeView);
}
localStorage.setItem("ltbv-controller-view", activeView);
if (activeView === "cockpit") setTimeout(drawHisto, 0);
if (activeView === "history") setTimeout(renderLedger, 0);
if (activeView === "diagnostics") { runDoctor(); fetchTimeline(); }
}
for (const tab of document.querySelectorAll(".view-tab")) {
tab.onclick = () => setView(tab.dataset.view);
}
// ---------- config save with inline armor errors ----------
let saveTimer = null;
function pushConfig(patch, savedId, errId) {
clearTimeout(saveTimer);
saveTimer = setTimeout(async () => {
const out = await api("/config", patch);
cfg = out.config;
if (out.errors && out.errors.length) {
if (errId) $(errId).textContent = "rejected: " + out.errors.join(", ") + " (reverted to last valid)";
for (const key of out.errors) {
const el = document.querySelector(`.scrub[data-key="${key}"]`);
if (el) { el.classList.add("err"); setTimeout(() => el.classList.remove("err"), 1400); }
}
} else {
if (errId) $(errId).textContent = "";
if (savedId) flash(savedId);
}
renderScrubs(); renderQuiet(); drawHisto();
}, 300);
}
// ---------- health ----------
const fmtDur = (s) => s >= 5940 ? (s/3600).toFixed(1) + "h" : s >= 120 ? Math.round(s/60) + "m" : Math.round(s) + "s";
const fmtAgo = (ts) => {
if (!ts) return "never";
const seconds = Math.max(0, Date.now() / 1000 - ts);
return seconds < 5 ? "now" : fmtDur(seconds) + " ago";
};
async function pollHealth() {
try {
const h = await api("/health");
$("dot").classList.add("on");
$("h-status").textContent = h.muted ? "muted" : h.now_speaking ? "speaking" : "ready";
$("h-engine").textContent = h.engine + " · " + (h.model_loaded ? "loaded" : "cold");
$("h-branch").textContent = (h.git_branch || "?") + (h.git_dirty ? " · dirty" : "");
$("h-provider").textContent = (h.condense_provider || "none") + " · " + (h.condense_locality || "local");
$("h-uptime").textContent = fmtDur(h.uptime_s);
$("h-spoke").textContent = fmtAgo(h.last_spoken_ts);
setMuteState(!!h.muted);
} catch {
$("dot").classList.remove("on");
$("h-status").textContent = "offline";
}
}
function setMuteState(muted) {
isMuted = muted;
$("mute").classList.toggle("on", muted);
$("mute").innerHTML = muted ? 'shut up on <kbd>space</kbd>' : 'shut up <kbd>space</kbd>';
$("dot").classList.toggle("on", !muted);
if (muted) $("h-status").textContent = "muted";
}
// ---------- diagnostics ----------
async function runDoctor() {
const state = $("doctor-state"), list = $("doctor-list");
state.textContent = "checking";
list.innerHTML = "";
try {
const out = await api("/doctor");
state.textContent = out.ok ? "ready" : "attention needed";
state.style.color = out.ok ? "var(--green)" : "var(--red)";
$("doctor-meta").textContent = `${out.git.branch}${out.git.dirty ? " · dirty" : ""} · ${out.provider} ${out.locality}`;
for (const check of out.checks || []) {
const row = document.createElement("div");
row.className = "check-row " + (check.ok ? "ok" : check.required ? "" : "optional");
const dot = document.createElement("i");
const name = document.createElement("b"); name.textContent = check.name;
const detail = document.createElement("span"); detail.textContent = check.detail;
row.append(dot, name, detail); list.appendChild(row);
}
} catch {
state.textContent = "daemon unreachable";
state.style.color = "var(--red)";
}
}
$("doctor-refresh").onclick = runDoctor;
// ---------- TTS shootout ----------
async function initEngines() {
const out = await api("/engines");
engines = out.engines || [];
renderEngines(out.active);
}
function renderEngines(active) {
const grid = $("engine-grid");
grid.innerHTML = "";
for (const e of engines) {
const card = document.createElement("div");
card.className = "engine-card" + (e.name === active ? " active" : "");
const status = e.installed ? (e.loaded ? "loaded" : "installed, cold") : "not installed";
card.innerHTML = `<b>${e.name}</b><span>${status} · rss ${e.rss_mb} MB</span>`;
if (e.install_command) {
const c = document.createElement("code");
c.textContent = e.install_command;
card.appendChild(c);
}
const b = document.createElement("button");
b.className = "btn";
b.textContent = e.name === active ? "active" : "set active";
b.disabled = !e.installed || e.name === active;
b.onclick = async () => {
const out = await api("/engine", { name: e.name });
if (out.ok) {
cfg = out.config;
await initEngines();
await initVoices();
renderScrubs(); renderQuiet(); drawHisto();
}
};
card.appendChild(b);
grid.appendChild(card);
}
}
// ---------- condense provider ----------
const CONDENSE_PROVIDERS = [
{ name: "ollama", detail: () => cfg.condense_ollama_model || "qwen3.5:4b" },
{ name: "none", detail: () => "skip condensing" },
];
function renderCondense() {
const grid = $("condense-grid");
grid.innerHTML = "";
const active = cfg.condense_provider || "ollama";
for (const p of CONDENSE_PROVIDERS) {
const card = document.createElement("div");
card.className = "engine-card" + (p.name === active ? " active" : "");
card.innerHTML = `<b>${p.name}</b><span>${p.detail()}</span>`;
const b = document.createElement("button");
b.className = "btn";
b.textContent = p.name === active ? "active" : "set active";
b.disabled = p.name === active;
b.onclick = async () => {
const out = await api("/config", { condense_provider: p.name });
cfg = out.config;
renderCondense();
};
card.appendChild(b);
grid.appendChild(card);
}
}
function renderBench() {
const body = $("bench-body");
body.innerHTML = "";
if (!benchResults.length) {
body.innerHTML = '<tr><td colspan="8">no bench run yet</td></tr>';
return;
}
for (const r of benchResults) {
const tr = document.createElement("tr");
if (r.ok === false) {
tr.innerHTML = `<td><strong>${r.engine}</strong></td><td colspan="7">bench failed, see .voice.log</td>`;
body.appendChild(tr);
continue;
}
tr.innerHTML = `<td><strong>${r.engine}</strong></td><td>${r.voice}</td><td>${r.rtf}</td><td>${r.ttfa_s}s</td><td>${r.synth_s}s</td><td>${r.duration_s}s</td>`;
const play = document.createElement("td");
const pb = document.createElement("button");
pb.className = "btn"; pb.textContent = "play"; pb.onclick = () => api("/replay", { clip: r.clip_id });
play.appendChild(pb);
const keep = document.createElement("td");
const kb = document.createElement("button");
kb.className = "btn"; kb.textContent = "keep"; kb.onclick = () => keepEngine(r.engine);
keep.appendChild(kb);
tr.append(play, keep);
body.appendChild(tr);
}
blindOrder = [...benchResults].filter((r) => r.clip_id).sort(() => Math.random() - 0.5);
renderBlind(false);
}
function renderBlind(reveal) {
const host = $("blind");
host.innerHTML = "";
if (!blindOrder.length) return;
blindOrder.forEach((r, i) => {
const b = document.createElement("button");
b.className = "btn";
b.textContent = reveal ? `${String.fromCharCode(65 + i)} · ${r.engine}` : String.fromCharCode(65 + i);
b.onclick = () => api("/replay", { clip: r.clip_id });
host.appendChild(b);
});
const rev = document.createElement("button");
rev.className = "btn";
rev.textContent = reveal ? "hide" : "reveal";
rev.onclick = () => renderBlind(!reveal);
host.appendChild(rev);
}
async function runBench() {
$("bench-run").disabled = true;
$("bench-state").textContent = "running…";
const out = await api("/bench", { text: $("bench-text").value.trim() });
benchResults = out.results || [];
renderBench();
await initEngines();
$("bench-state").textContent = "daemon-measured RTF";
$("bench-run").disabled = false;
}
async function keepEngine(name) {
const out = await api("/engine", { name });
if (out.ok) cfg = out.config;
const losers = engines.filter((e) => e.name !== name && e.installed).map((e) => e.name);
const lines = [`default engine: ${name}`, "", "cleanup candidates:"];
for (const loser of losers) {
if (loser === "kokoro") lines.push("uv remove kokoro");
else if (loser === "pocket") lines.push("uv remove pocket-tts");
else lines.push(`# remove ${loser} package and cached model files`);
}
$("cleanup").style.display = "block";
$("cleanup").textContent = lines.join("\n");
await initEngines();
await initVoices();
}
// ---------- now speaking strip + stage waveform ----------
let stageWave = null, stageStart = 0, stageDur = 0, stageRAF = null;
function setNow(now) {
const on = !!(now && now.text);
$("nowstrip").classList.toggle("on", on);
if (on) {
$("now-meta").innerHTML = `<b>${now.voice || "?"}</b> · ${now.kind || "reply"}${now.project ? " · " + now.project : ""}`;
$("now-text").textContent = now.text;
} else {
stageWave = null;
if (stageRAF) cancelAnimationFrame(stageRAF);
}
auditionPlaying = on && now.kind === "audition";
setLabButtons();
}
function startStage(peaks, duration) {
stageWave = peaks; stageDur = duration; stageStart = performance.now();
if (stageRAF) cancelAnimationFrame(stageRAF);
drawStage();
}
function drawStage() {
const cv = $("stage"), ctx = cv.getContext("2d");
const dpr = window.devicePixelRatio || 1;
const W = cv.clientWidth, H = cv.clientHeight;
if (cv.width !== W * dpr) { cv.width = W * dpr; cv.height = H * dpr; }
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
ctx.clearRect(0, 0, W, H);
if (!stageWave || !stageWave.length) return;
const n = stageWave.length, bw = W / n, mid = H / 2;
const prog = stageDur > 0 ? Math.min(1, (performance.now() - stageStart) / (stageDur * 1000)) : 1;
for (let i = 0; i < n; i++) {
const h = Math.max(1, stageWave[i] * (H - 2));
ctx.fillStyle = (i / n) <= prog ? "#58d68d" : "#3a4650";
ctx.fillRect(i * bw, mid - h / 2, Math.max(1, bw - 0.5), h);
}
const px = prog * W;
ctx.fillStyle = "#e8e8e8";
ctx.fillRect(px, 0, 1, H);
if (prog < 1) stageRAF = requestAnimationFrame(drawStage);
}
// ---------- scrub controls ----------
const KNOBS = [
{ key: "rate", label: "playback rate", min: 0.5, max: 2, step: 0.05, fmt: (v) => v.toFixed(2) + "x" },
{ key: "volume", label: "volume", min: 0, max: 1, step: 0.05, fmt: (v) => Math.round(v * 100) + "%" },
{ key: "duck_target_volume", label: "Spotify duck volume", min: 0, max: 100, step: 5, fmt: (v) => Math.round(v) + "%" },
{ key: "temperature", label: "temperature · reloads model", min: 0.1, max: 1.5, step: 0.05, fmt: (v) => v.toFixed(2) },
{ key: "idle_exit_s", label: "idle exit", min: 60, max: 3600, step: 30, fmt: fmtDur },
{ key: "project_window_s", label: "prefix window", min: 60, max: 3600, step: 30, fmt: fmtDur },
{ key: "condense_timeout_s", label: "summary timeout", min: 2, max: 30, step: 1, fmt: (v) => v + "s" },
];
function buildScrubs() {
const host = $("scrubs");
for (const k of KNOBS) {
const el = document.createElement("div");
el.className = "scrub"; el.dataset.key = k.key;
el.innerHTML = `<div class="row"><span class="lbl">${k.label}</span><b class="val"></b></div>
<div class="track"><div class="fill"></div><div class="nub"></div></div>`;
host.appendChild(el);
attachScrub(el, k);
}
}
function renderScrubs() {
for (const k of KNOBS) renderScrub(document.querySelector(`.scrub[data-key="${k.key}"]`), k, cfg[k.key]);
renderDucking();
}
function renderScrub(el, k, v) {
el.querySelector(".val").textContent = k.fmt(v);
const frac = (v - k.min) / (k.max - k.min);
el.querySelector(".fill").style.width = (frac * 100) + "%";
el.querySelector(".nub").style.left = `calc(${frac * 100}% - 1px)`;
}
function renderDucking() {
if (!cfg) return;
$("duck-toggle").classList.toggle("on", !!cfg.ducking_enabled);
$("duck-toggle").textContent = cfg.ducking_enabled ? "spotify duck on" : "spotify duck off";
$("browser-duck-toggle").classList.toggle("on", !!cfg.browser_youtube_ducking_enabled);
$("browser-duck-toggle").textContent = cfg.browser_youtube_ducking_enabled ? "browser / youtube duck on" : "browser / youtube duck off";
$("inbox-toggle").classList.toggle("on", !!cfg.voice_inbox_enabled);
$("inbox-toggle").textContent = cfg.voice_inbox_enabled ? "voice inbox on" : "voice inbox off";
}
function attachScrub(el, k) {
let x0 = 0, v0 = 0, live = null, moved = false, pid = null;
const quant = (v) => Math.min(k.max, Math.max(k.min, Math.round(v / k.step) * k.step));
el.addEventListener("pointerdown", (e) => {
if (e.target.tagName === "INPUT") return;
x0 = e.clientX; v0 = cfg[k.key]; moved = false; pid = e.pointerId;
el.setPointerCapture(pid);
});
el.addEventListener("pointermove", (e) => {
if (pid === null) return;
const dx = e.clientX - x0;
if (!moved && Math.abs(dx) < 3) return;
moved = true;
const span = e.shiftKey ? 1200 : 240;
live = quant(v0 + (dx / span) * (k.max - k.min));
renderScrub(el, k, live);
});
const finish = () => {
if (pid === null) return;
el.releasePointerCapture?.(pid); pid = null;
if (moved && live !== null && live !== cfg[k.key]) {
cfg[k.key] = live;
pushConfig({ [k.key]: live }, "saved-desk", "err-desk");
} else if (!moved) {
typeIn(el, k);
}
live = null;
};
el.addEventListener("pointerup", finish);
el.addEventListener("pointercancel", finish);
}
function typeIn(el, k) {
const valEl = el.querySelector(".val");
const input = document.createElement("input");
input.value = cfg[k.key];
valEl.textContent = ""; valEl.appendChild(input);
input.focus(); input.select();
const done = (commit) => {
const v = parseFloat(input.value);
if (commit && !isNaN(v)) {
cfg[k.key] = Math.min(k.max, Math.max(k.min, v));
pushConfig({ [k.key]: cfg[k.key] }, "saved-desk", "err-desk");
}
renderScrub(el, k, cfg[k.key]);
};
input.addEventListener("keydown", (e) => {
if (e.key === "Enter") done(true);
if (e.key === "Escape") done(false);
e.stopPropagation();
});
input.addEventListener("blur", () => done(true));
}
// ---------- quiet hours paint strip ----------
function hm(mins) { return String(Math.floor(mins / 60)).padStart(2, "0") + ":" + String(mins % 60).padStart(2, "0"); }
function renderQuiet() {
const strip = $("qstrip");
strip.querySelectorAll(".qsel").forEach((n) => n.remove());
const q = cfg.quiet_hours;
$("q-state").textContent = q ? `${q.start} → ${q.end}` : "disabled";
if (!q) return;
const toMin = (s) => parseInt(s.slice(0, 2)) * 60 + parseInt(s.slice(3));
const a = toMin(q.start), b = toMin(q.end);
const seg = (from, to) => {
const d = document.createElement("div");
d.className = "qsel";
d.style.left = (from / 1440 * 100) + "%";
d.style.width = ((to - from) / 1440 * 100) + "%";
strip.appendChild(d);
};
if (a < b) seg(a, b); else { seg(a, 1440); seg(0, b); }
}
(() => {
const strip = $("qstrip");
let startMin = null, dragging = false;
const toMin = (e) => {
const r = strip.getBoundingClientRect();
const frac = Math.min(1, Math.max(0, (e.clientX - r.left) / r.width));
return Math.round(frac * 1440 / 15) * 15;
};
strip.addEventListener("pointerdown", (e) => {
dragging = true; startMin = toMin(e); strip.setPointerCapture(e.pointerId);
});
strip.addEventListener("pointermove", (e) => {
if (!dragging) return;
const cur = toMin(e);
cfg.quiet_hours = startMin === cur ? null : { start: hm(startMin % 1440), end: hm(cur % 1440) };
renderQuiet();
});
strip.addEventListener("pointerup", (e) => {
if (!dragging) return;
dragging = false;
const cur = toMin(e);
if (cur === startMin) { return; }
const q = { start: hm(startMin % 1440), end: hm(cur % 1440) };
cfg.quiet_hours = q;
pushConfig({ quiet_hours: q }, "saved-desk", "err-desk");
});
$("q-clear").onclick = () => { cfg.quiet_hours = null; renderQuiet(); pushConfig({ quiet_hours: null }, "saved-desk", "err-desk"); };
})();
// ---------- histogram ----------
const BUCKET = 50, MAXCH = 1200;
const speakEntries = () => entries.filter((e) => e.event === "speak" && e.kind !== "audition");
function drawHisto() {
const cv = $("histo"), ctx = cv.getContext("2d");
const dpr = window.devicePixelRatio || 1;
const W = cv.clientWidth, H = cv.clientHeight;
cv.width = W * dpr; cv.height = H * dpr;
ctx.scale(dpr, dpr);
ctx.clearRect(0, 0, W, H);
const chars = speakEntries().map((e) => e.spoken_chars || 0);
const nb = Math.ceil(MAXCH / BUCKET);
const buckets = new Array(nb).fill(0);
for (const c of chars) buckets[Math.min(nb - 1, Math.floor(c / BUCKET))]++;
const peak = Math.max(1, ...buckets);
const bw = W / nb;
const thresh = dragThresh ?? (cfg ? cfg.max_direct_chars : 400);
for (let i = 0; i < nb; i++) {
const h = (buckets[i] / peak) * (H - 26);
ctx.fillStyle = (i + 1) * BUCKET > thresh ? "#2e5731" : "#274064";
ctx.fillRect(i * bw + 1, H - 14 - h, bw - 2, h);
}
ctx.fillStyle = "#6a6a6a"; ctx.font = "9px 'Share Tech Mono', monospace";
for (let c = 0; c <= MAXCH; c += 200) {
const x = (c / MAXCH) * W;
ctx.fillRect(x, H - 13, 1, 3);
ctx.fillText(c, Math.min(x + 2, W - 24), H - 3);
}
const sorted = [...chars].sort((a, b) => a - b);
const median = sorted.length ? sorted[Math.floor(sorted.length / 2)] : null;
if (median !== null) {
const mx = (median / MAXCH) * W;
ctx.fillStyle = "#9a9a9a";
ctx.fillRect(mx, 0, 1, H - 14);
}
const x = (thresh / MAXCH) * W;
ctx.strokeStyle = "#f2c94c"; ctx.lineWidth = 1.5;
ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x, H - 14); ctx.stroke();
ctx.fillStyle = "#f2c94c";
ctx.fillText(thresh, Math.min(x + 5, W - 34), 10);
const over = chars.filter((c) => c > thresh).length;
$("r-thresh").textContent = thresh;
$("r-pct").textContent = chars.length ? Math.round(100 * over / chars.length) + "%" : "n/a";
$("r-median").textContent = median ?? "n/a";
cv._buckets = buckets; cv._peak = peak;
}
(() => {
const cv = $("histo"), tip = $("histo-tip");
let dragging = false;
const toThresh = (e) => {
const r = cv.getBoundingClientRect();
const frac = Math.min(1, Math.max(0, (e.clientX - r.left) / r.width));
return Math.max(50, Math.min(MAXCH, Math.round(frac * MAXCH / 10) * 10));
};
cv.addEventListener("pointerdown", (e) => { dragging = true; cv.setPointerCapture(e.pointerId); dragThresh = toThresh(e); drawHisto(); });
cv.addEventListener("pointermove", (e) => {
if (dragging) { dragThresh = toThresh(e); drawHisto(); tip.style.display = "none"; return; }
const r = cv.getBoundingClientRect();
const i = Math.floor(((e.clientX - r.left) / r.width) * (MAXCH / BUCKET));
const b = cv._buckets;
if (!b || i < 0 || i >= b.length) { tip.style.display = "none"; return; }
tip.textContent = `${i * BUCKET}-${(i + 1) * BUCKET} chars · ${b[i]} speak${b[i] === 1 ? "" : "s"}`;
tip.style.display = "block";
tip.style.left = Math.min(e.clientX - r.left + 10, r.width - 130) + "px";
tip.style.top = "8px";
});
cv.addEventListener("pointerleave", () => { tip.style.display = "none"; });
cv.addEventListener("pointerup", () => {
dragging = false;
if (dragThresh != null && cfg && dragThresh !== cfg.max_direct_chars) {
cfg.max_direct_chars = dragThresh;
pushConfig({ max_direct_chars: dragThresh }, "saved-desk", "err-desk");
}
});
})();
// ---------- strip inspector: token LCS diff ----------
function lcsKeep(rawT, cleanT) {
const n = rawT.length, m = cleanT.length;
if (n * m > 400000) {