-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.html
More file actions
1639 lines (1588 loc) · 123 KB
/
Copy pathapp.html
File metadata and controls
1639 lines (1588 loc) · 123 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" />
<title>RootVector — Production Overview</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M25 7C25 16 18 24 8 24C8 15 15 7 25 7Z' fill='none' stroke='%231B1A17' stroke-width='2'/%3E%3Ccircle cx='9.6' cy='22.4' r='1.9' fill='%231B1A17'/%3E%3C/svg%3E">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Expires" content="0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<style>
:root{
--bg:#fff; --panel:#fff; --line:#ECEDF1; --line-2:#F3F3F6; --hover:#F7F7FA;
--ink:#161922; --ink-2:#3A3F4C; --muted:#6B7280; --muted-2:#9AA1AD;
--violet:#6D5AE6; --violet-ink:#5B49D6; --violet-soft:#EEEBFB; --violet-soft-2:#F5F3FD;
--green:#16A34A; --green-soft:#E7F6EC; --red:#DC2626;
--sans:'Plus Jakarta Sans',ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
--shadow:0 1px 2px rgba(17,20,28,.04),0 8px 24px -16px rgba(17,20,28,.18);
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{font-family:var(--sans);color:var(--ink);-webkit-font-smoothing:antialiased;font-size:14px;
background:
radial-gradient(38% 46% at 12% 16%, rgba(126,166,255,.55), transparent 62%),
radial-gradient(42% 46% at 88% 10%, rgba(255,196,150,.52), transparent 62%),
radial-gradient(46% 52% at 84% 84%, rgba(150,238,176,.52), transparent 62%),
radial-gradient(46% 52% at 14% 88%, rgba(255,224,150,.52), transparent 62%),
radial-gradient(52% 56% at 50% 52%, rgba(214,180,255,.42), transparent 66%),
#EEF1F5;
background-attachment:fixed}
a{color:inherit;text-decoration:none}
button{font-family:inherit;cursor:pointer}
::-webkit-scrollbar{width:10px;height:10px}::-webkit-scrollbar-thumb{background:#E4E4EA;border-radius:8px;border:3px solid #fff}
/* ---------- top bar ---------- */
.topbar{height:72px;display:flex;align-items:center;gap:26px;padding:0 26px;border-bottom:1px solid var(--line);position:sticky;top:0;background:rgba(255,255,255,.92);backdrop-filter:saturate(180%) blur(8px);z-index:30}
.brand{display:flex;align-items:center;gap:9px;font-weight:650;font-size:23px;letter-spacing:-.03em;color:var(--ink)}
.brand .mk{width:30px;height:30px}
.topnav{display:flex;gap:28px;align-items:center}
.topnav a{position:relative;font-size:14.5px;font-weight:500;color:var(--muted);padding:26px 0}
.topnav a:hover{color:var(--ink)}
.topnav a.on{color:var(--ink);font-weight:600}
.topnav a.on::after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:2px;background:var(--violet);border-radius:2px}
.tb-right{margin-left:auto;display:flex;align-items:center;gap:16px}
.search{display:flex;align-items:center;gap:9px;width:340px;max-width:32vw;background:#F4F4F7;border:1px solid transparent;border-radius:11px;padding:10px 12px;color:var(--muted)}
.search svg{width:16px;height:16px}
.search input{border:0;outline:0;background:transparent;font:inherit;font-size:14px;color:var(--ink);width:100%}
.search .kbd{margin-left:auto;font-size:12px;color:var(--muted-2);border:1px solid var(--line);border-radius:6px;padding:1px 7px;background:#fff}
.bell{position:relative;width:40px;height:40px;border-radius:11px;border:1px solid var(--line);background:#fff;display:flex;align-items:center;justify-content:center;color:var(--ink-2)}
.bell:hover{background:var(--hover)}
.bell svg{width:18px;height:18px}
.bell .badge{position:absolute;top:-6px;right:-6px;min-width:18px;height:18px;padding:0 4px;border-radius:9px;background:var(--violet);color:#fff;font-size:11px;font-weight:700;display:flex;align-items:center;justify-content:center;border:2px solid #fff}
.acct{display:flex;align-items:center;gap:7px;padding:3px 6px 3px 3px;border-radius:12px;cursor:pointer;position:relative}
.acct:hover{background:var(--hover)}
.avatar{width:38px;height:38px;border-radius:50%;overflow:hidden;flex:0 0 auto;display:flex;align-items:center;justify-content:center;background:var(--violet-soft);border:1px solid var(--line);color:var(--muted)}
.avatar img{width:100%;height:100%;object-fit:cover;display:block}
.avatar svg{width:20px;height:20px}
.avatar.lg{width:44px;height:44px}
.acct .chev{width:16px;height:16px;color:var(--muted-2)}
.menu{position:absolute;top:52px;right:0;width:262px;background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:0 20px 50px -18px rgba(17,20,28,.38);padding:7px;z-index:50}
.menu[hidden]{display:none}
.menu-head{display:flex;align-items:center;gap:11px;padding:11px 10px 13px;border-bottom:1px solid var(--line);margin-bottom:6px}
.menu-head .nm{font-size:14px;font-weight:650;line-height:1.2}
.menu-head .em{font-size:12.5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:175px}
.menu-head .pv{font-size:11px;color:var(--muted-2);margin-top:2px;text-transform:capitalize}
.menu a,.menu button{display:flex;align-items:center;gap:10px;width:100%;text-align:left;font:inherit;font-size:14px;color:var(--ink-2);background:none;border:0;border-radius:9px;padding:10px;cursor:pointer}
.menu a:hover,.menu button:hover{background:var(--hover);color:var(--ink)}
.menu .sep{height:1px;background:var(--line);margin:6px 4px}
.menu .danger:hover{color:var(--red)}
.menu svg{width:16px;height:16px;color:var(--muted-2)}
/* ---------- shell ---------- */
.shell{display:grid;grid-template-columns:236px 1fr;min-height:calc(100vh - 72px)}
.side{border-right:1px solid var(--line);padding:22px 16px;display:flex;flex-direction:column;gap:4px;position:sticky;top:72px;height:calc(100vh - 72px);background:#fff}
.side a.nav{display:flex;align-items:center;gap:12px;padding:11px 12px;border-radius:11px;color:var(--muted);font-size:14.5px;font-weight:500}
.side a.nav svg{width:19px;height:19px}
.side a.nav:hover{background:var(--hover);color:var(--ink)}
.side a.nav.on{background:var(--violet-soft);color:var(--violet-ink);font-weight:600}
.navbadge{margin-left:auto;min-width:22px;height:22px;padding:0 7px;border-radius:11px;background:#EFEDF9;color:var(--violet-ink);font-size:12px;font-weight:700;display:none;align-items:center;justify-content:center;line-height:1}
.side a.nav.on .navbadge{background:#fff}
.side .spacer{flex:1}
.side .agentcard{border:1px solid var(--line);border-radius:12px;padding:12px;margin-bottom:6px}
.side .agentcard .t{display:flex;align-items:center;gap:8px;font-size:13.5px;font-weight:600}
.side .agentcard .s{font-size:12px;color:var(--muted);margin-top:3px;padding-left:16px}
.side .mini{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:10px;color:var(--muted);font-size:13.5px}
.side .mini:hover{background:var(--hover);color:var(--ink)}
.side .mini svg{width:17px;height:17px}
.side .ver{font-size:12px;color:var(--muted-2);padding:8px 12px 0}
.dot{width:9px;height:9px;border-radius:50%;background:var(--green);flex:0 0 auto;box-shadow:0 0 0 3px var(--green-soft)}
.dot.violet{background:var(--violet);box-shadow:0 0 0 3px var(--violet-soft)}
/* ---------- main ---------- */
.main{padding:34px 40px 60px;width:100%;min-width:0;background:transparent}
.h1{font-size:38px;font-weight:750;letter-spacing:-.02em;margin:0}
.statusline{display:flex;align-items:center;gap:9px;color:var(--muted);font-size:15px;margin:14px 0 26px}
.kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:18px;margin-bottom:22px}
.kpi{border:1px solid var(--line);border-radius:16px;padding:20px;display:flex;align-items:center;gap:16px;background:var(--panel);box-shadow:var(--shadow)}
.kpi .tile{width:52px;height:52px;border-radius:13px;background:var(--violet-soft);display:flex;align-items:center;justify-content:center;color:var(--violet);flex:0 0 auto}
.kpi .tile svg{width:24px;height:24px}
.kpi .v{font-size:30px;font-weight:750;line-height:1}
.kpi .l{font-size:13.5px;color:var(--muted);margin-top:5px}
.row3{display:grid;grid-template-columns:repeat(3,1fr);gap:18px;margin-bottom:22px}
.card{border:1px solid #EEEFF3;border-radius:18px;background:#fff;box-shadow:0 1px 2px rgba(17,20,28,.04),0 16px 34px -20px rgba(17,20,28,.24);padding:20px 20px}
.card-h{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}
.card-h h3{font-size:16px;font-weight:650;margin:0;display:flex;align-items:center;gap:7px}
.card-h .info{width:15px;height:15px;color:var(--muted-2)}
.viewall{font-size:13px;font-weight:600;color:var(--violet);display:flex;align-items:center;gap:4px}
.viewall:hover{color:var(--violet-ink)}
.agent-status{display:flex;align-items:center;gap:9px;font-size:14px;font-weight:500;color:var(--ink-2);margin-bottom:20px}
.brands{display:flex;align-items:center;gap:20px;justify-content:flex-start;padding:6px 0 4px}
.brands .b{width:34px;height:34px;display:flex;align-items:center;justify-content:center}
.brands .b svg{width:28px;height:28px}
.brands-cap{font-size:13px;color:var(--muted);margin-top:8px}
.agent-foot{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:13px;margin-top:22px}
.agent-foot svg{width:15px;height:15px}
.act{display:flex;align-items:center;gap:13px;padding:13px 4px;border-top:1px solid var(--line-2)}
.act:first-of-type{border-top:0;padding-top:2px}
.act .ic{width:38px;height:38px;border-radius:10px;background:var(--hover);display:flex;align-items:center;justify-content:center;flex:0 0 auto}
.act .ic svg{width:19px;height:19px}
.act .m{flex:1;min-width:0}
.act .m .tt{font-size:14px;font-weight:600}
.act .m .sub{font-size:13px;color:var(--muted)}
.act .time{font-size:12.5px;color:var(--muted-2);white-space:nowrap}
.empty{display:flex;flex-direction:column;align-items:center;text-align:center;padding:14px 6px 6px}
.empty .orb{width:88px;height:88px;border-radius:50%;background:radial-gradient(circle at 50% 42%,var(--violet-soft),var(--violet-soft-2));display:flex;align-items:center;justify-content:center;color:var(--violet);margin-bottom:16px;position:relative}
.empty .orb svg{width:34px;height:34px}
.empty .spark{position:absolute;color:var(--violet);opacity:.5}
.empty h4{font-size:15.5px;font-weight:650;margin:0 0 6px}
.empty p{font-size:13.5px;color:var(--muted);margin:0 0 16px;max-width:34ch;line-height:1.5}
.btn-outline{border:1px solid var(--line);background:#fff;border-radius:10px;padding:10px 16px;font-size:13.5px;font-weight:600;color:var(--ink)}
.btn-outline:hover{background:var(--hover);border-color:#DDD}
.health{border:1px solid var(--line);border-radius:16px;background:var(--panel);box-shadow:var(--shadow);padding:22px 24px}
.health-h{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px}
.health-h h3{font-size:17px;font-weight:650;margin:0}
.tbl{width:100%;border-collapse:collapse}
.tbl th{text-align:left;font-size:12.5px;font-weight:600;color:var(--muted);padding:14px 10px;border-bottom:1px solid var(--line)}
.tbl td{padding:16px 10px;border-bottom:1px solid var(--line-2);font-size:14px;vertical-align:middle}
.tbl tr:last-child td{border-bottom:0}
.svc{display:flex;align-items:center;gap:10px;font-weight:600}
.svc svg{width:18px;height:18px;color:var(--muted)}
.badge-h{display:inline-flex;align-items:center;gap:7px;color:var(--green);font-weight:600}
.spark{display:block}
.tbl-foot{text-align:center;color:var(--muted);font-size:13px;padding-top:16px;display:flex;align-items:center;justify-content:center;gap:6px;cursor:pointer}
.tbl-foot svg{width:14px;height:14px}
.muted{color:var(--muted);font-size:14px;padding:20px 2px}
.tag{font-size:11px;font-weight:600;color:var(--muted);background:var(--hover);border:1px solid var(--line);border-radius:6px;padding:1px 7px;margin-left:6px}
.btn-primary{border:0;border-radius:10px;background:var(--violet);color:#fff;padding:10px 16px;font-size:13.5px;font-weight:600}
.btn-primary:hover{background:var(--violet-ink)}
.int-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:18px}
.int-card{border:1px solid var(--line);border-radius:16px;background:#fff;box-shadow:var(--shadow);padding:20px;display:flex;flex-direction:column;gap:16px}
.int-top{display:flex;align-items:flex-start;gap:12px}
.int-logo{width:40px;height:40px;flex:0 0 auto;display:flex;align-items:center;justify-content:center}
.int-logo svg{width:30px;height:30px}
.int-name{font-size:15.5px;font-weight:650}
.int-blurb{font-size:12.5px;color:var(--muted);margin-top:2px}
.int-badge{margin-left:auto;font-size:11.5px;font-weight:600;padding:3px 9px;border-radius:20px}
.int-badge.on{color:var(--green);background:var(--green-soft)}
.int-foot{margin-top:auto;display:flex;align-items:center;justify-content:space-between;gap:10px}
.int-sub{font-size:13px;color:var(--muted)}
.int-soon{font-size:12.5px;color:var(--muted-2)}
@media(max-width:1080px){.int-grid{grid-template-columns:1fr}}
/* ---- investigation ---- */
.backlink{display:inline-block;font-size:13.5px;color:var(--muted);margin-bottom:12px}
.backlink:hover{color:var(--ink)}
.inv-head{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:20px}
.sev{font-size:12px;font-weight:800;border-radius:6px;padding:3px 8px;letter-spacing:.03em}
.sev1{background:#FDECEC;color:#DC2626}.sev2{background:#FEF3E2;color:#C77A0A}.sev3{background:var(--violet-soft);color:var(--violet-ink)}
.inv-grid{display:grid;grid-template-columns:1.35fr 1fr;gap:18px;align-items:start}
.agent-live{font-size:13px;font-weight:600;color:var(--violet-ink);display:flex;align-items:center;gap:7px}
.agent-live.done{color:var(--green)}
.timeline{padding-left:2px}
.tl-row{display:flex;gap:12px;padding:9px 0;align-items:flex-start;animation:tlIn .3s ease}
@keyframes tlIn{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
.tl-time{font:12px/1.5 var(--mono,ui-monospace,monospace);color:var(--muted-2);width:58px;flex:0 0 auto}
.tl-ic{width:22px;height:22px;border-radius:50%;flex:0 0 auto;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700}
.tl-ic.ok{background:var(--green-soft);color:var(--green)}
.tl-ic.run{background:var(--violet-soft);color:var(--violet)}
.tl-ic.warn{background:#FDECEC;color:#DC2626}
.tl-msg{font-size:14px;color:var(--ink-2);padding-top:1px}
.inv-side{display:flex;flex-direction:column;gap:18px}
.hy{margin-bottom:13px}
.hy-top{display:flex;justify-content:space-between;font-size:13.5px;margin-bottom:5px}
.hy-top b{font-weight:600}.hy-top .p{font-weight:700}
.hy-bar{height:7px;border-radius:6px;background:var(--panel-2);overflow:hidden}
.hy-bar i{display:block;height:100%;border-radius:6px;background:#C9C3E8;transition:width .5s}
.hy.lead .hy-bar i{background:var(--violet)}
.hy.lead .hy-top .p{color:var(--violet-ink)}
.hy-sub{font-size:12px;color:var(--muted);margin-top:4px}
.conf{margin-left:auto;font-size:12px;font-weight:700;color:var(--green);background:var(--green-soft);padding:3px 10px;border-radius:20px}
.why{list-style:none;margin:0;padding:0}
.why li{display:flex;gap:8px;font-size:13.5px;color:var(--ink-2);padding:5px 0}
.why li::before{content:"✓";color:var(--green);font-weight:800}
.rec-box{border:1px solid var(--line);border-radius:12px;padding:14px;margin-bottom:14px}
.rec-box .a{font-size:16px;font-weight:650}
.rec-box .m{font-size:13px;color:var(--muted);margin-top:4px}
.rec-tags{display:flex;gap:8px;margin-top:10px}
.rec-tags span{font-size:12px;font-weight:600;border-radius:20px;padding:3px 10px;background:var(--green-soft);color:var(--green)}
.inv-actions{display:flex;gap:10px}
.btn-approve{border:0;border-radius:11px;background:var(--violet);color:#fff;font-weight:600;font-size:14px;padding:12px 18px;flex:1;cursor:pointer}
.btn-approve:hover{background:var(--violet-ink)}
.btn-approve[disabled]{opacity:.6;cursor:default}
.btn-reject{border:1px solid var(--line);border-radius:11px;background:#fff;padding:12px 18px;font-weight:600;font-size:14px}
.verified{border:1px solid #BBF7D0;background:#F0FDF4}
.verified .vok{font-size:18px;font-weight:750;color:var(--green);letter-spacing:.02em}
.modal-ov{position:fixed;inset:0;background:rgba(20,22,28,.42);display:flex;align-items:center;justify-content:center;z-index:80}
.modal{background:#fff;border-radius:16px;padding:24px;width:420px;max-width:92vw;box-shadow:0 30px 70px -20px rgba(0,0,0,.4)}
.modal h3{margin:0 0 6px;font-size:18px}
.modal p{margin:0 0 4px;font-size:14px;color:var(--muted)}
.modal .kv{font-size:14px;margin:12px 0}.modal .kv b{font-weight:650}
.modal-act{display:flex;gap:10px;margin-top:20px}
.kvrow{display:flex;justify-content:space-between;padding:11px 0;border-top:1px solid var(--line-2);font-size:14px}
.kvrow span{color:var(--muted)}.kvrow b{font-weight:600}
.sep2{height:1px;background:var(--line);margin:16px 0}
.cmdk-row{padding:11px 12px;border-radius:9px;cursor:pointer}
.cmdk-row:hover{background:var(--hover)}
.notif-item{display:flex;gap:11px;padding:10px;border-radius:9px}
.notif-item:hover{background:var(--hover)}
.notif-item .ic{width:30px;height:30px;border-radius:8px;background:var(--hover);display:flex;align-items:center;justify-content:center;flex:0 0 auto}
.notif-item .ic svg{width:16px;height:16px}
/* ================= responsive ================= */
.hamburger{display:none;width:40px;height:40px;border-radius:11px;border:1px solid var(--line);background:#fff;color:var(--ink-2);align-items:center;justify-content:center;flex:0 0 auto}
.hamburger svg{width:20px;height:20px}
.side-backdrop{display:none;position:fixed;inset:0;background:rgba(15,18,26,.45);z-index:45;backdrop-filter:blur(2px)}
@media(max-width:1080px){.kpis{grid-template-columns:repeat(2,1fr)}.row3{grid-template-columns:1fr}}
@media(max-width:960px){.inv-grid{grid-template-columns:1fr}}
@media(max-width:900px){.ov-row1{grid-template-columns:1fr}.ov-kpis{grid-template-columns:repeat(2,1fr)}.ip-grid{grid-template-columns:1fr}}
/* tablet & phone: sidebar becomes a slide-in drawer */
@media(max-width:820px){
.hamburger{display:flex}
.shell{grid-template-columns:1fr}
.side{position:fixed;top:0;left:0;height:100dvh;width:252px;transform:translateX(-100%);transition:transform .25s ease;z-index:50;box-shadow:0 24px 70px -10px rgba(0,0,0,.45);padding-top:18px;overflow-y:auto}
body.side-open .side{transform:translateX(0)}
body.side-open .side-backdrop{display:block}
.main{padding:22px 16px 64px}
.search{display:none}
.ov-head{gap:10px}
.ov-title{font-size:26px}
}
@media(max-width:560px){
.topbar{padding:0 14px;gap:12px;height:64px}
.shell{min-height:calc(100vh - 64px)}
.brand b{font-size:20px}.brand .mk{width:26px;height:26px}
.ov-kpis{grid-template-columns:1fr}
.ov-title{font-size:22px}
.card{padding:16px 14px}
.health{overflow-x:auto;-webkit-overflow-scrolling:touch}
.tbl{min-width:520px}
.ov-kspark{display:none} /* keep KPI numbers clean on small phones */
.modal{width:94vw;padding:20px}
.menu{width:min(320px,92vw)}
.help-card{padding:22px 16px}
}
</style>
</head>
<body>
<!-- ===== top bar ===== -->
<header class="topbar">
<button class="hamburger" id="hamburger" aria-label="Menu" onclick="rvToggleSidebar()"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 6h18M3 12h18M3 18h18"/></svg></button>
<a class="brand" href="index.html" title="Back to rootvector.ai">
<svg class="mk" viewBox="0 0 32 32" fill="none" aria-hidden="true">
<path d="M25 7C25 16 18 24 8 24C8 15 15 7 25 7Z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/>
<path d="M11.5 20.5C15 18.5 19 14.5 21.5 10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/>
<circle cx="9.6" cy="22.4" r="1.75" fill="currentColor"/>
</svg>
<b>rootvector</b>
</a>
<div style="flex:1"></div>
<div class="tb-right">
<div class="search" onclick="openPalette()"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg><input placeholder="Search anything…" readonly><span class="kbd">⌘K</span></div>
<button class="bell" id="bell" aria-label="Notifications" onclick="toggleNotif(event)"><span class="badge" id="bellBadge" hidden>0</span><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.7 21a2 2 0 0 1-3.4 0"/></svg></button>
<div class="acct" id="acct" onclick="rvToggleMenu(event)">
<span class="avatar" id="rvAvatar"></span>
<svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m6 9 6 6 6-6"/></svg>
</div>
<div class="menu" id="rvMenu" hidden>
<div class="menu-head">
<span class="avatar lg" id="rvAvatar2"></span>
<div style="min-width:0">
<div class="nm" id="rvName">Account</div>
<div class="em" id="rvEmail"></div>
<div class="pv" id="rvProv"></div>
</div>
</div>
<a href="#/account" onclick="rvCloseMenu()">Account</a>
<a href="#/settings" onclick="rvCloseMenu()">Settings</a>
<a href="#/integrations" onclick="rvCloseMenu()">Integrations</a>
<div class="sep"></div>
<button type="button" class="danger" onclick="rvSignOut()">Sign out</button>
</div>
</div>
</header>
<div class="side-backdrop" id="sideBackdrop" onclick="rvCloseSidebar()"></div>
<!-- ===== shell ===== -->
<div class="shell">
<aside class="side" id="side">
<a class="nav" href="#/overview" data-k="overview"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/><path d="M9 21v-6h6v6"/></svg>Overview</a>
<a class="nav" href="#/investigations" data-k="investigations"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>Investigations<span class="navbadge" id="navInv"></span></a>
<a class="nav" href="#/services" data-k="services"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="3" y="3" width="8" height="8" rx="2"/><rect x="13" y="3" width="8" height="8" rx="2"/><rect x="3" y="13" width="8" height="8" rx="2"/><rect x="13" y="13" width="8" height="8" rx="2"/></svg>Services</a>
<a class="nav" href="#/history" data-k="history"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l3 2"/></svg>History</a>
<a class="nav" href="#/repositories" data-k="repositories"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M4 4v14a2 2 0 0 0 2 2h14"/><rect x="8" y="3" width="12" height="12" rx="2"/></svg>Repositories</a>
<a class="nav" href="#/integrations" data-k="integrations"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M8 7 3 12l5 5M16 7l5 5-5 5M13 4l-2 16"/></svg>Integrations</a>
<a class="nav" href="#/help" data-k="help"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M21 11.5a8.4 8.4 0 0 1-9 8.3L4 21l1.2-3.6A8.4 8.4 0 1 1 21 11.5Z"/><path d="M9 10.5a3 3 0 1 1 4 2.8c-.6.3-1 .8-1 1.4"/><path d="M12 17h.01"/></svg>Ask AI</a>
<div class="spacer"></div>
<div class="agentcard">
<div class="t"><span class="dot violet"></span>RootVector Agent</div>
<div class="s">All systems operational</div>
</div>
<a class="mini" href="#" onclick="feedbackModal();return false"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>Give feedback</a>
<a class="mini" href="#/settings"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.9 1.2 2 2 0 1 1-4 0 1.7 1.7 0 0 0-2.9-1.2l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1A1.7 1.7 0 0 0 2.6 15a2 2 0 1 1 0-4 1.7 1.7 0 0 0 1.2-2.9l-.1-.1A2 2 0 1 1 6.5 5.2l.1.1A1.7 1.7 0 0 0 9 4.6a2 2 0 1 1 4 0 1.7 1.7 0 0 0 2.9 1.2l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1A1.7 1.7 0 0 0 21.4 11a2 2 0 1 1 0 4z"/></svg>Settings</a>
<div class="ver">RootVector v1.0.0</div>
</aside>
<main class="main" id="main"></main>
</div>
<script>
/* Local dev serves the frontend on :4178 (separate backend on :4000).
In production the backend serves this page itself, so use a same-origin path. */
const RV_API = (location.port === "4178" || location.protocol === "file:")
? "http://localhost:4000/api"
: "/api";
let RV_USER = null;
const $ = id => document.getElementById(id);
/* ---------- brand + status icons ---------- */
const ICN = {
cube:'<path d="M21 16V8a2 2 0 0 0-1-1.7l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.7l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><path d="m3.3 7 8.7 5 8.7-5M12 22V12"/>',
shield:'<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>',
rocket:'<path d="M4.5 16.5c-1.5 1.3-2 5-2 5s3.7-.5 5-2c.7-.9.7-2.2-.1-3a2.1 2.1 0 0 0-2.9 0zM12 15l-3-3a22 22 0 0 1 10-11 22 22 0 0 1-1 10z"/><path d="M9 12H4s.5-2.8 2-4a4 4 0 0 1 3 0M12 15v5s2.8-.5 4-2a4 4 0 0 0 0-3"/>',
bell:'<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.7 21a2 2 0 0 1-3.4 0"/>',
clock:'<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',
xcircle:'<circle cx="12" cy="12" r="9"/><path d="m15 9-6 6M9 9l6 6"/>',
search:'<circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/>',
info:'<circle cx="12" cy="12" r="9"/><path d="M12 16v-4M12 8h.01"/>',
check:'<circle cx="12" cy="12" r="9"/><path d="m8.5 12 2.5 2.5 4.5-5"/>'
};
const B = {
github:'<svg viewBox="0 0 24 24"><path fill="#181717" d="M12 .5A11.5 11.5 0 0 0 .5 12a11.5 11.5 0 0 0 7.9 10.9c.6.1.8-.2.8-.5v-2c-3.2.7-3.9-1.4-3.9-1.4-.5-1.3-1.3-1.7-1.3-1.7-1.1-.7.1-.7.1-.7 1.2.1 1.8 1.2 1.8 1.2 1 1.8 2.8 1.3 3.5 1 .1-.8.4-1.3.7-1.6-2.6-.3-5.3-1.3-5.3-5.7 0-1.3.5-2.3 1.2-3.1-.1-.3-.5-1.5.1-3.2 0 0 1-.3 3.3 1.2a11.5 11.5 0 0 1 6 0C17.3 5 18.3 5.3 18.3 5.3c.7 1.7.3 2.9.1 3.2.8.8 1.2 1.8 1.2 3.1 0 4.4-2.7 5.4-5.3 5.7.4.4.8 1.1.8 2.2v3.3c0 .3.2.6.8.5A11.5 11.5 0 0 0 23.5 12 11.5 11.5 0 0 0 12 .5Z"/></svg>',
sentry:'<svg viewBox="0 0 24 24" fill="none"><path d="M13.3 3.6a1.5 1.5 0 0 0-2.6 0L7.9 8.4a10.5 10.5 0 0 1 5.6 8.6h-2a8.5 8.5 0 0 0-4.6-7L5 12.7a6 6 0 0 1 3 4.3H4.2c-.4 0-.6-.4-.4-.7l1.5-2.6a4.4 4.4 0 0 0-1.3-.8l-1.5 2.6A2 2 0 0 0 4.2 19h6.3a8 8 0 0 0-3.8-8l1-1.7a10 10 0 0 1 4.8 9.7h4.4c1.1 0 2-1.3 1.4-2.4L13.3 3.6Z" fill="#362D59"/></svg>',
deploy:'<svg viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#EEEBFB"/><path d="M8 12h8M13 9l3 3-3 3" stroke="#6D5AE6" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'
};
const svg = (p,cls) => `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" ${cls?`class="${cls}"`:''}>${p}</svg>`;
function sparkline(pts,color){
const w=110,h=30, xs=w/(pts.length-1);
const min=Math.min(...pts),max=Math.max(...pts),rng=(max-min)||1;
const d=pts.map((v,i)=>`${i?'L':'M'}${(i*xs).toFixed(1)} ${(h-((v-min)/rng)*(h-6)-3).toFixed(1)}`).join(' ');
return `<svg class="spark" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}" fill="none"><path d="${d}" stroke="${color||'#6D5AE6'}" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
}
/* ---------- pages ---------- */
/* First name for the greeting: real profile name, else derived from the email. */
function rvFirstName(){
const u = RV_USER || {};
if(u.firstName) return u.firstName;
if(u.name) return String(u.name).trim().split(/\s+/)[0];
if(u.email){
let p = String(u.email).split('@')[0].replace(/[._+\-].*$/,'').replace(/[0-9]+$/,'');
if(p) return p.charAt(0).toUpperCase()+p.slice(1);
}
return 'there';
}
function pageOverview(){
ovEnsureStyle();
setTimeout(loadOverview,0);
return `
<div class="ov-head">
<div>
<div class="ov-greet" id="ovGreet">Welcome back, <b>${rvFirstName()}</b> <span class="wave">👋</span></div>
<h1 class="ov-title" id="ovTitle">Production Overview</h1>
<div class="ov-status" id="ovStatus"><span class="dot"></span> All systems operational</div>
</div>
<div style="display:flex;gap:10px" id="ovActions">
<button class="btn-outline" onclick="clearDemo(this)" title="Remove demo incidents + seeded activity">Clear demo data</button>
<button class="btn-approve" onclick="simulateIncident(this)" title="Runs the real incident pipeline (demo)">⚡ Simulate incident</button>
</div>
</div>
<div id="ovMain">
<div class="ov-kpis">
<div class="ov-kpi"><span class="ov-tile red">${svg(ICN.shield)}</span><span class="ov-kspark" id="sActive"></span><div class="v" id="kActive">—</div><div class="l">Active incidents</div><div class="ov-delta" id="dActive"></div></div>
<div class="ov-kpi"><span class="ov-tile violet">${svg(ICN.cube)}</span><span class="ov-kspark" id="sServices"></span><div class="v" id="kServices">—</div><div class="l">Services monitored</div><div class="ov-delta" id="dServices"></div></div>
<div class="ov-kpi"><span class="ov-tile amber">${svg(ICN.bell)}</span><span class="ov-kspark" id="sAlerts"></span><div class="v" id="kAlerts">—</div><div class="l">Alerts analyzed</div><div class="ov-delta" id="dAlerts"></div></div>
<div class="ov-kpi"><span class="ov-tile green">${svg(ICN.check)}</span><span class="ov-kspark" id="sResolved"></span><div class="v" id="kResolved">—</div><div class="l">Resolved</div><div class="ov-delta" id="dResolved"></div></div>
<div class="ov-kpi"><span class="ov-tile blue">${svg(ICN.rocket)}</span><span class="ov-kspark" id="sDeploys"></span><div class="v" id="kDeploys">—</div><div class="l">Deployments</div><div class="ov-delta" id="dDeploys"></div></div>
</div>
<div class="ov-row1">
<div class="card"><div class="card-h"><h3>Production Health</h3><span class="muted" style="padding:0;font-size:12px">Error rate · last 24h</span></div><div id="ovHealth" class="muted">Loading…</div></div>
<div class="card"><div class="card-h"><h3>Active Incidents</h3><a class="viewall" href="#/investigations">View all →</a></div><div id="ovActive"><div class="muted">Loading…</div></div></div>
<div class="card"><div class="card-h"><h3>AI Investigation Summary</h3><span class="tag" style="background:#EEE9FE;color:#5B49D6">BETA</span></div><div id="ovAI"><div class="muted">Loading…</div></div></div>
</div>
<div class="ov-row1">
<div class="card"><div class="card-h"><h3>Recent Deployments</h3><a class="viewall" href="#/repositories">View all →</a></div><div id="ovDeploys"><div class="muted">Loading…</div></div></div>
<div class="card"><div class="card-h"><h3>Recent Activity</h3><a class="viewall" href="#/investigations">View all →</a></div><div id="ovActivity"><div class="muted">Loading…</div></div></div>
<div class="card"><div class="card-h"><h3>Top Affected Services</h3><a class="viewall" href="#/services">View all →</a></div><div id="ovServices"><div class="muted">Loading…</div></div></div>
</div>
</div>
<div id="ovOnboard" hidden>
<div class="onb-card">
<div class="onb-orb"></div>
<h3>Connect your stack to begin</h3>
<p>RootVector detects and investigates <b>real</b> incidents from your tools. Connect one to see live health, investigations and root-cause analysis here.</p>
<div class="onb-tools">
<a class="onb-tool" href="#/integrations">${B.github} GitHub</a>
<a class="onb-tool" href="#/integrations">${B.sentry} Sentry</a>
<a class="onb-tool" href="#/integrations">${svg(ICN.cube)} Datadog</a>
<a class="onb-tool" href="#/integrations">${svg(ICN.cube)} Grafana</a>
</div>
<a class="btn-approve" style="display:inline-block;margin-top:18px" href="#/integrations">Go to Integrations →</a>
</div>
</div>`;
}
function ovEnsureStyle(){
if(document.getElementById('ov-style')) return;
const s=document.createElement('style'); s.id='ov-style';
s.textContent=`
.ov-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;flex-wrap:wrap;margin-bottom:20px}
.ov-greet{font-size:14px;color:var(--muted);margin-bottom:4px;display:flex;align-items:center;gap:7px}
.ov-greet b{color:var(--violet-ink);font-weight:700}
.ov-title{font-size:clamp(28px,3.4vw,38px);font-weight:800;letter-spacing:-.03em;color:#12141C;margin:0}
.wave{display:inline-block;transform-origin:72% 78%;animation:wave 2.4s ease-in-out infinite}
@keyframes wave{0%,62%,100%{transform:rotate(0)}10%,30%{transform:rotate(15deg)}20%{transform:rotate(-9deg)}40%{transform:rotate(11deg)}50%{transform:rotate(-3deg)}}
.ov-status{display:inline-flex;align-items:center;gap:8px;font-size:13.5px;color:#1F9D57;font-weight:600;margin-top:8px}
.ov-status .dot{width:8px;height:8px;border-radius:50%;background:#1F9D57}
.ov-kpis{display:grid;grid-template-columns:repeat(5,1fr);gap:14px;margin-bottom:16px}
@media(max-width:1100px){.ov-kpis{grid-template-columns:repeat(2,1fr)}}
.ov-kpi{position:relative;background:#fff;border:1px solid #EEEFF3;border-radius:18px;padding:17px 18px;box-shadow:0 1px 2px rgba(17,20,28,.04),0 14px 30px -18px rgba(17,20,28,.22)}
.ov-kspark{position:absolute;right:16px;top:50%;transform:translateY(-42%);width:90px;height:40px;opacity:.95}
.ov-kpi .v{font-size:28px;font-weight:800;color:#1A1630;line-height:1.05;margin-top:12px}
.ov-kpi .l{font-size:12.5px;color:var(--muted);margin-top:2px}
.ov-delta{font-size:11.5px;margin-top:10px}
.ov-tile{width:40px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;flex:0 0 auto}
.ov-tile svg{width:19px;height:19px}
.ov-tile.red{background:#FDECEC;color:#DC2626}.ov-tile.violet{background:#EEE9FE;color:#5B49D6}.ov-tile.amber{background:#FEF3E2;color:#D97706}.ov-tile.green{background:#E7F6EC;color:#1F9D57}.ov-tile.blue{background:#E7EEFC;color:#2563EB}
.ov-row1{display:grid;grid-template-columns:1.5fr 1fr 1fr;gap:16px;margin-bottom:16px}
@media(max-width:1100px){.ov-row1{grid-template-columns:1fr}}
.ov-inc{display:flex;align-items:center;gap:11px;padding:10px 0;border-bottom:1px solid var(--line)}
.ov-inc:last-child{border-bottom:0}
.ov-inc .tt{font-size:13.5px;font-weight:600;color:#211C3A;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ov-inc .sub{font-size:12px;color:var(--muted)}
.ov-inc .ic{width:26px;height:26px;display:flex;align-items:center;justify-content:center;flex:0 0 auto}
.ov-inc .ic svg{width:16px;height:16px}
.sev{font-size:10.5px;font-weight:800;padding:3px 7px;border-radius:6px;flex:0 0 auto}
.sev.s1{background:#FDECEC;color:#DC2626}.sev.s2{background:#FEF3E2;color:#D97706}.sev.s3{background:#FDF6E3;color:#B8860B}
.ov-pill{font-size:11px;font-weight:700;padding:3px 8px;border-radius:999px;background:#F1F1F4;color:#6E6A78;display:inline-block}
.ov-spark{width:64px;height:20px;vertical-align:middle}
/* onboarding (first-time, nothing connected) */
.type-caret::after{content:"";display:inline-block;width:2px;height:1em;background:var(--violet-ink);margin-left:2px;vertical-align:-2px;animation:caret .8s step-end infinite}
@keyframes caret{50%{opacity:0}}
.onb-card{max-width:620px;margin:20px auto 0;background:#fff;border:1px solid #EEEFF3;border-radius:24px;box-shadow:0 1px 2px rgba(17,20,28,.04),0 30px 60px -30px rgba(17,20,28,.28);padding:38px 34px;text-align:center}
.onb-orb{width:78px;height:78px;border-radius:50%;margin:0 auto 20px;background:radial-gradient(circle at 34% 30%,#fff 0%,#ffd9e6 32%,#cfe0ff 62%,#dcc9ff 100%);box-shadow:0 0 0 10px rgba(180,200,255,.10),0 14px 34px -8px rgba(150,160,255,.55);animation:orbF 3s ease-in-out infinite}
.onb-card h3{font-size:22px;font-weight:800;color:#1A1630;margin:0 0 8px}
.onb-card p{color:var(--muted);font-size:14px;max-width:44ch;margin:0 auto 20px;line-height:1.55}
.onb-tools{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
.onb-tool{display:inline-flex;align-items:center;gap:8px;border:1px solid #E9E9F0;border-radius:12px;padding:9px 14px;font-size:13px;font-weight:600;color:#3A3552;background:#fff}
.onb-tool:hover{border-color:var(--violet);color:var(--violet-ink)}
.onb-tool svg{width:16px;height:16px}
/* one-time attention pulse on the Investigations sidebar item */
.nav-pulse{animation:navPulse 1s ease-in-out 3;border-radius:11px}
@keyframes navPulse{0%,100%{box-shadow:0 0 0 0 rgba(109,90,230,0)}50%{box-shadow:0 0 0 4px rgba(109,90,230,.28);background:var(--violet-soft)}}
.side a.nav.hintline{text-decoration:underline;text-decoration-color:var(--violet);text-underline-offset:3px;color:var(--violet-ink);font-weight:700}`;
document.head.appendChild(s);
}
function actIcon(kind){
if(kind==='pr_merged'||kind==='push') return `<span class="ic">${B.github}</span>`;
if(kind==='deployment') return `<span class="ic" style="color:#6D5AE6">${svg(ICN.rocket)}</span>`;
if(kind==='error') return `<span class="ic" style="color:#DC2626">${svg(ICN.xcircle)}</span>`;
return `<span class="ic">${svg(ICN.info)}</span>`;
}
/* typewriter: types `text` into el then calls done() */
let ovTypeTimer=null;
function ovTypewriter(el, text, done){
if(!el) return;
if(ovTypeTimer){ clearInterval(ovTypeTimer); ovTypeTimer=null; }
el.classList.add('type-caret'); el.textContent='';
let i=0;
ovTypeTimer=setInterval(()=>{
el.textContent=text.slice(0,++i);
if(i>=text.length){ clearInterval(ovTypeTimer); ovTypeTimer=null; setTimeout(()=>{ el.classList.remove('type-caret'); if(done) done(); }, 450); }
}, 36);
}
/* one-time attention pulse + underline on the Investigations sidebar item */
function ovHintInvestigations(){
const nav=document.querySelector('.side a.nav[data-k="investigations"]');
if(!nav) return;
nav.classList.add('nav-pulse','hintline');
setTimeout(()=>nav.classList.remove('nav-pulse'), 3200); // pulse ~3×, keep the underline hint
}
/* Is the user connected? (their own GitHub). Gates the incident pages. */
async function rvConnected(){ try{ const o=await (await rvApi('/overview')).json(); return !!o.githubConnected; }catch(e){ return false; } }
function connectGate(kind){
const msg={investigations:'Connect a tool and RootVector will investigate your real incidents here.',services:"Connect a tool to start tracking your services' health here.",history:'Your solved and cancelled incidents will appear here once you connect a tool.'};
return `<div class="health"><div class="empty" style="padding:44px 6px"><div class="orb">${svg(ICN.cube)}</div><h4>Connect your stack first</h4><p>${msg[kind]||'Connect a tool from Integrations to begin.'}</p><a class="btn-approve" href="#/integrations" style="display:inline-block">Go to Integrations →</a></div></div>`;
}
async function loadOverview(){
let d, all;
try{ [d, all] = await Promise.all([ (await rvApi('/overview')).json(), (await rvApi('/incidents')).json() ]); }catch(e){ return; }
all = all || [];
// The only real PER-USER connection is the user's own GitHub. (Sentry/Datadog/
// etc. are configured server-side, so they look "connected" for everyone — they
// must NOT count here.) No GitHub connected yet → first-time onboarding.
const connected = !!d.githubConnected;
const main=$('ovMain'), onboard=$('ovOnboard'), greet=$('ovGreet'), title=$('ovTitle'), status=$('ovStatus'), acts=$('ovActions');
if(!connected){
if(main) main.hidden=true; if(onboard) onboard.hidden=false; if(acts) acts.style.display='none';
if(greet) greet.style.display='none';
if(title) title.textContent="Hello "+rvFirstName()+", let’s get started 👋";
if(status){ status.style.color='var(--muted)'; status.innerHTML='<span></span>'; }
ovTypewriter(status, 'Connect your GitHub from Integrations to see your real incidents →', ()=>{ ovHintInvestigations(); });
return; // skip filling KPIs/charts while empty
}
if(main) main.hidden=false; if(onboard) onboard.hidden=true; if(acts) acts.style.display='';
if(greet) greet.style.display='';
if(title) title.textContent='Production Overview';
const S=d.stats||{}; const set=(id,v)=>{const el=document.getElementById(id); if(el) el.textContent=v;};
const active=all.filter(i=>i.status!=='resolved'&&i.status!=='rejected');
const resolved=all.filter(i=>i.status==='resolved').length;
set('kActive', active.length); set('kServices', S.servicesMonitored);
set('kAlerts', S.alertsAnalyzed); set('kResolved', resolved); set('kDeploys', S.recentDeployments);
// per-tile 7-day trend deltas + sparklines (all from real timestamps)
const tsInc = all.map(i=>i.startedAt);
const tsResolved = all.filter(i=>i.status==='resolved').map(i=>i.resolvedAt||i.startedAt);
const tsDeploy = (d.activity||[]).filter(a=>a.kind==='deployment').map(a=>a.at);
const tsAlerts = tsInc.concat((d.activity||[]).filter(a=>a.kind==='error').map(a=>a.at));
const setD=(id,pct,goodDown)=>{const el=$(id); if(el) el.innerHTML=ovDeltaHtml(pct,goodDown);};
const setS=(id,ts,idx,c)=>{const el=$(id); if(el) el.innerHTML=sparkFor(ts,idx,c);};
setD('dActive',delta7(tsInc),true); setS('sActive',tsInc,0,'#DC2626');
setD('dServices',distinctDelta7(all),false); setS('sServices',tsInc,1,'#6B7280');
setD('dAlerts',delta7(tsAlerts),true); setS('sAlerts',tsAlerts,2,'#D97706');
setD('dResolved',delta7(tsResolved),false); setS('sResolved',tsResolved,3,'#16A34A');
setD('dDeploys',delta7(tsDeploy),false); setS('sDeploys',tsDeploy,4,'#2563EB');
const stt=$('ovStatus');
if(stt){ if(active.length){ stt.style.color='#DC2626'; stt.innerHTML=`<span class="dot" style="background:#DC2626"></span> ${active.length} active incident${active.length>1?'s':''}`; }
else { stt.style.color='#1F9D57'; stt.innerHTML='<span class="dot" style="background:#1F9D57"></span> All systems operational'; } }
// Production Health chart (real error rates over 24h)
const hv=$('ovHealth'); if(hv) hv.innerHTML=ovChart(all);
// Active Incidents
const ai=$('ovActive');
if(ai){ ai.innerHTML = active.length ? active.slice(0,6).map(i=>{
const pill = i.confidence ? 'Awaiting approval' : 'Investigating';
return `<div class="ov-inc" style="cursor:pointer" onclick="location.hash='#/investigations/${i.key}'"><span class="sev s${i.severity||1}">SEV-${i.severity||1}</span>
<div class="m" style="flex:1;min-width:0"><div class="tt">${i.title} ${i.isDemo?'<span class="tag">DEMO</span>':''}</div><div class="sub">${i.service||''}</div></div>
<div style="text-align:right;flex:0 0 auto"><div class="time">${timeAgo(i.startedAt)}</div><span class="ov-pill" style="color:#5B49D6">${pill}</span></div></div>`;
}).join('') : `<div class="empty" style="padding:24px 6px"><div class="orb">${svg(ICN.check)}</div><h4>No active incidents</h4><p>All clear across your connected stacks.</p></div>`; }
// AI Investigation Summary
ovAISummary(active);
// Recent Deployments
const dp=$('ovDeploys'); const deps=(d.activity||[]).filter(a=>a.kind==='deployment'||a.kind==='pr_merged'||a.kind==='push');
if(dp){ dp.innerHTML = deps.length ? deps.slice(0,5).map(a=>`<div class="ov-inc"><span class="ic">${a.kind==='deployment'?svg(ICN.rocket):B.github}</span>
<div class="m" style="flex:1;min-width:0"><div class="tt">${a.title}</div><div class="sub">${a.service||''}</div></div>
<div style="text-align:right;flex:0 0 auto"><div class="time">${timeAgo(a.at)}</div>${a.kind==='deployment'?'<span class="ov-pill" style="background:#E7F6EC;color:#1F9D57">Successful</span>':''}</div></div>`).join('')
: `<div class="muted" style="padding:16px 2px">No deployments yet — connect GitHub to see live deploys.</div>`; }
// Recent Activity
const av=$('ovActivity');
if(av){ av.innerHTML = (d.activity&&d.activity.length) ? d.activity.slice(0,6).map(a=>`<div class="ov-inc">${actIcon(a.kind)}
<div class="m" style="flex:1;min-width:0"><div class="tt">${a.title}</div><div class="sub">${a.service||''}</div></div>
<div class="time" style="flex:0 0 auto">${timeAgo(a.at)}</div></div>`).join('')
: '<div class="muted" style="padding:16px 2px">No recent activity yet — connect GitHub or simulate an incident.</div>'; }
// Top Affected Services (real, from incident error rates)
const sv=$('ovServices');
if(sv){
const by={};
all.forEach(i=>{ const s=i.service||'unknown'; const o=(by[s]=by[s]||{name:s,er:0,open:0,ers:[]});
if(i.status!=='resolved'&&i.status!=='rejected') o.open++;
if(i.errorRate){ o.er=Math.max(o.er,i.errorRate); o.ers.push(i.errorRate); } });
const rows=Object.values(by).sort((a,b)=>b.er-a.er||b.open-a.open).slice(0,6);
const maxEr=Math.max(1,...rows.map(r=>r.er));
sv.innerHTML = rows.length ? rows.map(r=>{
const lvl=r.er>=8?['Critical','#DC2626']:r.er>=3?['High','#D97706']:r.er>=1?['Medium','#B8860B']:['Low','#1F9D57'];
const pct=Math.max(6,Math.round((r.er/maxEr)*100));
return `<div class="ov-inc"><div class="svc" style="flex:0 0 130px;min-width:0">${svg(ICN.cube)} <span style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis">${r.name}</span></div>
<div style="flex:1;min-width:40px"><div style="height:7px;border-radius:4px;background:#EEECF4;overflow:hidden"><i style="display:block;height:100%;width:${pct}%;background:${lvl[1]}"></i></div></div>
<div style="flex:0 0 auto;font-weight:700;font-size:13px;width:48px;text-align:right">${r.er?r.er.toFixed(1)+'%':'—'}</div>
<span class="ov-pill" style="color:${lvl[1]};flex:0 0 auto">${lvl[0]}</span></div>`;
}).join('') : '<div class="muted" style="padding:16px 2px">No services yet — services appear once an incident is detected.</div>';
}
}
async function ovAISummary(active){
const el=$('ovAI'); if(!el) return;
const top=(active||[]).find(i=>i.confidence) || (active||[])[0];
if(!top){ el.innerHTML=`<div class="empty" style="padding:24px 6px"><div class="orb">${svg(ICN.search)}</div><h4>No analysis yet</h4><p>The AI summary appears when an incident is investigated.</p></div>`; return; }
let inc=top; try{ inc=await (await rvApi('/incidents/'+top.key)).json(); }catch(e){}
const evs=inc.events||[]; const rc=[...evs].reverse().find(e=>e.kind==='root_cause'); const conf=inc.confidence||(rc&&rc.data&&rc.data.confidence)||0;
const evidence=evs.filter(e=>e.kind==='evidence').slice(0,3);
el.innerHTML=`<div style="display:flex;align-items:center;gap:9px;margin-bottom:8px"><span class="sev s${inc.severity||1}">SEV-${inc.severity||1}</span><b style="font-size:14.5px">${inc.title}</b></div>
<div class="muted" style="padding:0;font-size:12px;margin-bottom:14px">${inc.key} · Started ${timeAgo(inc.startedAt)}</div>
<div style="display:flex;justify-content:space-between;font-size:13px;font-weight:700"><span>AI Confidence</span><span>${conf}%</span></div>
<div style="height:9px;border-radius:5px;background:#EEECF4;overflow:hidden;margin:6px 0 14px"><i style="display:block;height:100%;width:${conf}%;background:linear-gradient(90deg,#8B72F0,#5B49D6)"></i></div>
${inc.rootCause?`<div style="font-size:11.5px;font-weight:800;color:#8A869A;text-transform:uppercase;letter-spacing:.05em;margin-bottom:5px">Root cause</div><div style="font-weight:700;margin-bottom:2px">${inc.rootCause}</div>`:'<div class="muted" style="padding:0">Investigation in progress…</div>'}
${evidence.length?`<div style="font-size:11.5px;font-weight:800;color:#8A869A;text-transform:uppercase;letter-spacing:.05em;margin:13px 0 6px">Evidence</div>${evidence.map(e=>`<div style="display:flex;gap:8px;font-size:12.5px;color:#4A4560;padding:3px 0"><span style="color:#1F9D57">✓</span><span>${e.message}</span></div>`).join('')}`:''}
<a class="btn-outline" style="display:block;text-align:center;margin-top:15px" href="#/investigations/${inc.key}">View full investigation →</a>`;
}
function ovSpark(vals,color){
if(!vals||!vals.length) return '';
const v=vals.slice(-8); const max=Math.max(...v,1),w=64,h=20,n=v.length,X=i=>n<2?w/2:i/(n-1)*w,Y=x=>h-2-(x/max)*(h-4);
let d='M'+X(0).toFixed(1)+' '+Y(v[0]).toFixed(1); v.forEach((x,i)=>d+=' L'+X(i).toFixed(1)+' '+Y(x).toFixed(1));
return `<svg class="ov-spark" viewBox="0 0 ${w} ${h}"><path d="${d}" fill="none" stroke="${color}" stroke-width="1.6"/></svg>`;
}
/* 7-day-vs-previous-7-day % change from a list of timestamps (real trend). */
function delta7(ts){ const now=Date.now(),d=864e5*7; let cur=0,prev=0; (ts||[]).forEach(x=>{const t=new Date(x).getTime(); if(t>now-d)cur++; else if(t>now-2*d)prev++;}); return prev===0?(cur>0?100:0):Math.round((cur-prev)/prev*100); }
function distinctDelta7(incidents){ const now=Date.now(),d=864e5*7,a=new Set(),b=new Set(); (incidents||[]).forEach(i=>{const t=new Date(i.startedAt).getTime(); if(t>now-d)a.add(i.service); else if(t>now-2*d)b.add(i.service);}); return b.size===0?(a.size>0?100:0):Math.round((a.size-b.size)/b.size*100); }
/* daily counts over the last 7 days → sparkline */
function spark7(ts,color){ const now=Date.now(),bk=new Array(7).fill(0); (ts||[]).forEach(x=>{const days=Math.floor((now-new Date(x).getTime())/864e5); if(days>=0&&days<7)bk[6-days]++;}); return ovSpark(bk,color); }
/* KPI sparkline = the REAL last-7-days daily counts. No data → a clean flat line. */
function ovSparkFlat(color){ const w=64,h=20; return `<svg class="ov-spark" viewBox="0 0 ${w} ${h}"><path d="M0 ${h/2} L${w} ${h/2}" fill="none" stroke="${color}" stroke-width="1.6" opacity=".4"/></svg>`; }
function sparkFor(ts,idx,color){
const now=Date.now(),bk=new Array(7).fill(0);
(ts||[]).forEach(x=>{const days=Math.floor((now-new Date(x).getTime())/864e5); if(days>=0&&days<7)bk[6-days]++;});
if(bk.reduce((a,b)=>a+b,0)===0) return ovSparkFlat(color); // nothing happened → flat line
return ovSpark(bk, color);
}
function ovDeltaHtml(pct,goodWhenDown){ const good = pct===0?null:(goodWhenDown? pct<0 : pct>0); const color = pct===0?'#9AA1AD':(good?'#16A34A':'#DC2626'); const arrow=pct>0?'↑':pct<0?'↓':''; return `<span style="color:${color};font-weight:700">${arrow}${Math.abs(pct)}%</span> <span style="color:#9AA1AD">vs last 7 days</span>`; }
function ovChart(incidents){
const now=Date.now(), start=now-24*3600*1000, w=560, h=170, base=0.3;
const pts=(incidents||[]).filter(i=>i.errorRate && new Date(i.startedAt).getTime()>=start).map(i=>({t:new Date(i.startedAt).getTime(),v:i.errorRate,key:i.key}));
const N=80, xs=[];
for(let k=0;k<N;k++){ const t=start+(k/(N-1))*(now-start); let val=base; pts.forEach(p=>{ const dt=(t-p.t)/(3600*1000); val+=p.v*Math.exp(-(dt*dt)/(2*0.6*0.6)); }); xs.push(val); }
const max=Math.max(4, Math.max.apply(null,xs))*1.08, X=i=>i/(N-1)*w, Y=v=>h-6-(v/max)*(h-16);
let area='M0 '+(h-6); xs.forEach((v,i)=>area+=' L'+X(i).toFixed(1)+' '+Y(v).toFixed(1)); area+=' L'+w+' '+(h-6)+' Z';
let line='M0 '+Y(xs[0]).toFixed(1); xs.forEach((v,i)=>line+=' L'+X(i).toFixed(1)+' '+Y(v).toFixed(1));
const latest=pts.slice().sort((a,b)=>b.t-a.t)[0];
const current = xs[xs.length-1];
let marker='';
let cap=`<div style="font-size:30px;font-weight:800;color:#12141C;margin:0 0 12px">${current.toFixed(2)}% <span style="font-size:13px;font-weight:500;color:var(--muted)">Error rate</span></div>`;
if(latest){ const mx=(latest.t-start)/(now-start)*w; marker=`<line x1="${mx.toFixed(1)}" y1="0" x2="${mx.toFixed(1)}" y2="${h-6}" stroke="#DC2626" stroke-width="1.4" stroke-dasharray="5 4"/>`;
cap=`<div style="font-size:12px;color:#DC2626;font-weight:700;margin-bottom:4px">⚠ Latest incident · ${latest.key}</div>`+cap; }
const yl=[max,max*0.75,max*0.5,max*0.25,0].map(v=>v.toFixed(1));
const t0=new Date(start).toLocaleTimeString([],{hour:'2-digit',minute:'2-digit',hour12:false});
return `${cap}<div style="display:flex;gap:8px"><div style="display:flex;flex-direction:column;justify-content:space-between;font-size:10px;color:#9A96A8;padding:2px 0 20px">${yl.map(v=>`<span>${v}%</span>`).join('')}</div>
<div style="flex:1;min-width:0"><svg viewBox="0 0 ${w} ${h}" preserveAspectRatio="none" style="width:100%;height:190px;display:block"><defs><linearGradient id="ovg" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#9AA1AD" stop-opacity=".35"/><stop offset="1" stop-color="#9AA1AD" stop-opacity="0"/></linearGradient></defs><path d="${area}" fill="url(#ovg)"/><path d="${line}" fill="none" stroke="#2A2E39" stroke-width="2"/>${marker}</svg>
<div style="display:flex;justify-content:space-between;font-size:10px;color:#9A96A8;margin-top:4px"><span>${t0}</span><span>Now</span></div></div></div>`;
}
async function simulateIncident(btn){
if(btn){ btn.disabled=true; btn.textContent='Simulating…'; }
try{ await rvApi('/dev/simulate-incident',{method:'POST'}); }catch(e){}
if(btn){ btn.disabled=false; btn.textContent='⚡ Simulate incident'; }
if(currentKey()==='overview') loadOverview(); else location.hash='#/overview';
}
async function clearDemo(btn){
if(btn){ btn.disabled=true; btn.textContent='Clearing…'; }
try{ await rvApi('/dev/reset-demo',{method:'POST'}); }catch(e){}
if(btn){ btn.disabled=false; btn.textContent='Clear demo data'; }
loadOverview();
}
function pageEmpty(title, icon, head, body, cta){
return `
<h1 class="h1">${title}</h1>
<div class="statusline"><span class="dot"></span> All systems operational</div>
<div class="health"><div class="empty" style="padding:40px 6px">
<div class="orb">${svg(icon)}</div>
<h4>${head}</h4>
<p>${body}</p>
${cta||''}
</div></div>`;
}
async function rvApi(path, opts){ return fetch(RV_API + path, Object.assign({credentials:'include'}, opts||{})); }
function timeAgo(iso){ if(!iso) return '—'; const s=(Date.now()-new Date(iso).getTime())/1000; const d=Math.floor(s/86400); if(d>0)return d+'d ago'; const h=Math.floor(s/3600); if(h>0)return h+'h ago'; const m=Math.floor(s/60); return (m||1)+'m ago'; }
/* ---- Integrations (real) ---- */
function pageIntegrations(){
setTimeout(loadIntegrations,0);
return `<h1 class="h1">Integrations</h1>
<div class="statusline"><span class="dot"></span> Connect your engineering stack</div>
<div id="intList" class="int-grid"><div class="muted">Loading integrations…</div></div>`;
}
async function loadIntegrations(){
const el=document.getElementById('intList'); if(!el) return;
try{
const list=await (await rvApi('/integrations')).json();
const base = RV_API.startsWith('http') ? RV_API.replace(/\/api$/,'') : location.origin;
el.innerHTML=list.map(p=>{
const connected=p.status==='connected';
const brand=p.key==='github'?B.github:p.key==='sentry'?B.sentry:svg(ICN.cube);
let foot;
if(p.key==='github'){
foot = connected
? `<span class="int-sub">${p.externalLogin?('@'+p.externalLogin):'Connected'}</span><button class="btn-outline" onclick="disconnectGithub()">Disconnect</button>`
: `<button class="btn-primary" onclick="connectProvider('github')">Connect GitHub</button>`;
} else if(p.key==='sentry'){
foot = connected
? `<span class="int-sub">Webhook configured${p.lastEventAt?' · last event '+timeAgo(p.lastEventAt):' · waiting for events'}</span>`
: `<button class="btn-primary" onclick="sentrySetup()">Set up Sentry</button>`;
} else if(p.style==='webhook'){
const url = base + p.webhookPath;
const ready = connected || p.ready;
const label = connected
? ('Connected'+(p.lastEventAt?' · last alert '+timeAgo(p.lastEventAt):''))
: (p.ready ? 'Ready · waiting for alerts' : 'Add ALERT_WEBHOOK_SECRET to enable');
foot = `<span class="int-sub">${label}</span>
<button class="${ready?'btn-outline':'btn-primary'}" onclick="webhookSetup('${p.key}','${p.name}','${url}')">Webhook URL</button>`;
} else if(p.style==='outbound'){
foot = connected
? `<span class="int-sub">Notifications on · posts new incidents to Slack</span>`
: `<button class="btn-primary" onclick="slackSetup()">Set up Slack</button>`;
} else {
foot = `<span class="int-soon">Coming soon</span>`;
}
return `<div class="int-card"><div class="int-top"><span class="int-logo">${brand}</span>
<div><div class="int-name">${p.name}</div><div class="int-blurb">${p.blurb}</div></div>
${connected?'<span class="int-badge on">Connected</span>':(p.ready&&p.style==='webhook'?'<span class="int-badge on" style="background:#EEF2FF;color:#2563EB">Ready</span>':'')}</div>
<div class="int-foot">${foot}</div></div>`;
}).join('');
}catch(e){ el.innerHTML='<div class="muted">Could not load integrations.</div>'; }
}
function connectProvider(key){ if(key==='github') location.href=RV_API+'/integrations/github/connect'; }
async function disconnectGithub(){ try{ await rvApi('/integrations/github/disconnect',{method:'POST'}); }catch(e){} loadIntegrations(); }
function webhookSetup(key,name,url){
const hints={
datadog:'Datadog → Integrations → Webhooks: add a webhook with this URL and a JSON body such as {"title":"$EVENT_TITLE","service":"$HOSTNAME","severity":"$ALERT_PRIORITY","state":"$ALERT_TRANSITION"}.',
grafana:'Grafana → Alerting → Contact points: add a Webhook contact point with this URL. Grafana sends its standard alert JSON.',
kubernetes:'Point Alertmanager (Prometheus) at this URL as a webhook receiver — standard Alertmanager JSON is supported.',
opentelemetry:'From your OpenTelemetry Collector / alert backend, POST alerts to this URL as {title, service, severity, state}.'
};
const ov=document.createElement('div'); ov.className='modal-ov'; ov.id='whModal';
ov.innerHTML=`<div class="modal" style="max-width:580px">
<h3>Connect ${name}</h3>
<p class="muted" style="padding:0">Send ${name} alerts here. A <b>firing</b> alert opens a real incident; a <b>resolved</b> one closes it.</p>
<div style="font-size:12.5px;font-weight:700;margin:14px 0 5px">Webhook URL</div>
<div style="display:flex;gap:8px"><input readonly value="${url}" onclick="this.select()" style="flex:1;border:1px solid var(--line);border-radius:9px;padding:9px 11px;font:inherit;font-size:12.5px"><button class="btn-outline" onclick="navigator.clipboard&&navigator.clipboard.writeText('${url}');toast('URL copied')">Copy</button></div>
<div style="font-size:12.5px;margin-top:14px"><b>Auth:</b> add header <code>x-rootvector-token</code> (or <code>?token=</code>) equal to your <code>ALERT_WEBHOOK_SECRET</code>.</div>
<p class="muted" style="margin-top:12px;font-size:12.5px;line-height:1.55">${hints[key]||''}</p>
<div class="modal-act"><button class="btn-approve" onclick="document.getElementById('whModal').remove()">Done</button></div></div>`;
ov.addEventListener('click',e=>{ if(e.target===ov) ov.remove(); });
document.body.appendChild(ov);
}
function slackSetup(){
const ov=document.createElement('div'); ov.className='modal-ov'; ov.id='slackModal';
ov.innerHTML=`<div class="modal" style="max-width:520px"><h3>Connect Slack</h3>
<p class="muted" style="padding:0">RootVector posts every new incident to your Slack channel via an Incoming Webhook.</p>
<ol class="muted" style="margin:10px 0 12px;padding-left:18px;line-height:1.75;font-size:12.5px"><li>In Slack → <b>Apps → Incoming Webhooks</b>, add one for your channel.</li><li>Copy its URL (starts with <code>https://hooks.slack.com/services/…</code>) and paste it below.</li></ol>
<input id="slackUrl" placeholder="https://hooks.slack.com/services/..." style="width:100%;border:1px solid var(--line);border-radius:9px;padding:11px;font:inherit;font-size:13px">
<p class="err" id="slackErr" style="display:none;color:var(--red);font-size:13px;margin:8px 2px 0"></p>
<div class="modal-act"><button class="btn-reject" onclick="document.getElementById('slackModal').remove()" style="flex:1">Cancel</button><button class="btn-approve" onclick="connectSlack()">Connect Slack</button></div></div>`;
ov.addEventListener('click',e=>{ if(e.target===ov) ov.remove(); });
document.body.appendChild(ov);
setTimeout(()=>{const i=document.getElementById('slackUrl'); if(i) i.focus();},40);
}
async function connectSlack(){
const url=(document.getElementById('slackUrl')||{}).value||'';
const err=document.getElementById('slackErr');
if(!/^https:\/\/hooks\.slack\.com\/services\//.test(url.trim())){ if(err){ err.textContent='Enter a valid Slack Incoming Webhook URL.'; err.style.display='block'; } return; }
try{
const r=await rvApi('/integrations/slack/connect',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({url:url.trim()})});
if(r.ok){ const m=document.getElementById('slackModal'); if(m) m.remove(); toast('Slack connected — new incidents will post there'); loadIntegrations(); }
else { if(err){ err.textContent='Could not connect Slack. Check the URL.'; err.style.display='block'; } }
}catch(e){ if(err){ err.textContent='Could not reach the server.'; err.style.display='block'; } }
}
function sentrySetup(){
const ov=document.createElement('div'); ov.className='modal-ov'; ov.id='sentryModal';
ov.innerHTML=`<div class="modal" style="width:520px">
<h3>Connect Sentry</h3>
<p>Sentry sends signed webhooks when a real error fires. RootVector opens an incident and investigates it automatically.</p>
<ol style="font-size:13.5px;color:var(--ink-2);line-height:1.7;padding-left:18px;margin:14px 0">
<li>Expose your backend publicly: <code style="background:var(--hover);padding:1px 6px;border-radius:5px">ngrok http 4000</code></li>
<li>In Sentry → <b>Settings → Developer Settings → New Internal Integration</b>. Enable <b>Webhooks</b>.</li>
<li>Webhook URL: <code style="background:var(--hover);padding:1px 6px;border-radius:5px">https://<your-ngrok>/api/webhooks/sentry</code></li>
<li>Subscribe to <b>issue</b> and <b>error</b> (and alert rules).</li>
<li>Copy the integration's <b>Client Secret</b> into <code style="background:var(--hover);padding:1px 6px;border-radius:5px">server/.env → SENTRY_CLIENT_SECRET</code> and restart.</li>
</ol>
<p style="font-size:12.5px;color:var(--muted-2)">Every delivery is HMAC-verified server-side; the secret never touches the browser.</p>
<div class="modal-act"><button class="btn-approve" style="flex:1" onclick="document.getElementById('sentryModal').remove()">Got it</button></div>
</div>`;
ov.addEventListener('click', e=>{ if(e.target===ov) ov.remove(); });
document.body.appendChild(ov);
}
/* ---- Repositories (real GitHub) ---- */
function pageRepositories(){
setTimeout(loadRepos,0);
return `<h1 class="h1">Repositories</h1>
<div class="statusline"><span class="dot"></span> From your connected GitHub</div>
<div id="repoList"><div class="muted">Loading repositories…</div></div>`;
}
async function loadRepos(){
const el=document.getElementById('repoList'); if(!el) return;
const r=await rvApi('/github/repositories');
if(r.status===400 || r.status===401){
el.innerHTML=`<div class="health"><div class="empty" style="padding:40px 6px">
<div class="orb">${B.github}</div><h4>Connect GitHub</h4>
<p>Connect your GitHub account to see your real repositories, pull requests and deployments.</p>
<a class="btn-outline" href="#/integrations">Go to Integrations</a></div></div>`; return;
}
const repos=await r.json();
if(!Array.isArray(repos) || !repos.length){ el.innerHTML='<div class="muted">No repositories found on this account.</div>'; return; }
el.innerHTML=`<div class="health"><table class="tbl">
<thead><tr><th>Repository</th><th>Language</th><th>Open issues</th><th>Updated</th></tr></thead>
<tbody>${repos.map(x=>`<tr>
<td><div class="svc">${B.github}<a href="${x.url}" target="_blank" rel="noreferrer">${x.fullName}</a>${x.private?'<span class="tag">private</span>':''}</div></td>
<td>${x.language||'—'}</td><td>${x.openIssues??0}</td><td>${timeAgo(x.pushedAt)}</td></tr>`).join('')}
</tbody></table></div>`;
}
/* ---------- services (real, from incidents) ---------- */
function pageServices(){
setTimeout(loadServices,0);
return `<h1 class="h1">Services</h1>
<div class="statusline"><span class="dot"></span> Health across the services RootVector is watching</div>
<div id="svcList"><div class="muted">Loading services…</div></div>`;
}
async function loadServices(){
const el=document.getElementById('svcList'); if(!el) return;
if(!(await rvConnected())){ el.innerHTML=connectGate('services'); return; }
let list; try{ list=await (await rvApi('/incidents')).json(); }catch(e){ el.innerHTML='<div class="muted">Could not load.</div>'; return; }
const by={};
(list||[]).forEach(i=>{ const s=i.service||'unknown'; const o=(by[s]=by[s]||{name:s,total:0,open:0,last:null,src:i.source}); o.total++; if(i.status!=='resolved'&&i.status!=='rejected') o.open++; if(!o.last||new Date(i.startedAt)>new Date(o.last)) o.last=i.startedAt; });
const rows=Object.values(by).sort((a,b)=>b.open-a.open || new Date(b.last)-new Date(a.last));
if(!rows.length){ el.innerHTML=`<div class="health"><div class="empty" style="padding:40px 6px"><div class="orb">${svg(ICN.cube)}</div><h4>No services yet</h4><p>Services appear here as soon as an incident is detected from any connected stack (GitHub, Sentry, Datadog, Grafana…).</p><a class="btn-outline" href="#/integrations">Connect your stack</a></div></div>`; return; }
el.innerHTML=`<div class="health"><table class="tbl">
<thead><tr><th>Service</th><th>Status</th><th>Open</th><th>Total incidents</th><th>Last incident</th></tr></thead>
<tbody>${rows.map(r=>{const bad=r.open>0;return `<tr>
<td><div class="svc">${svg(ICN.cube)} ${r.name}${r.src?`<span class="tag">${String(r.src).toUpperCase()}</span>`:''}</div></td>
<td>${bad?'<span class="badge-h" style="color:#DC2626"><span class="dot" style="background:#DC2626;box-shadow:0 0 0 3px rgba(220,38,38,.15)"></span>Degraded</span>':'<span class="badge-h"><span class="dot"></span>Healthy</span>'}</td>
<td>${r.open}</td><td>${r.total}</td><td>${r.last?timeAgo(r.last):'—'}</td></tr>`;}).join('')}
</tbody></table></div>`;
}
/* ---------- history (resolved + cancelled) ---------- */
function pageHistory(){
setTimeout(loadHistory,0);
return `<h1 class="h1">History</h1>
<div class="statusline"><span class="dot"></span> Completed incidents — solved or cancelled</div>
<div id="histList"><div class="muted">Loading history…</div></div>`;
}
async function loadHistory(){
const el=document.getElementById('histList'); if(!el) return;
if(!(await rvConnected())){ el.innerHTML=connectGate('history'); return; }
let list; try{ list=await (await rvApi('/incidents')).json(); }catch(e){ el.innerHTML='<div class="muted">Could not load.</div>'; return; }
const done=(list||[]).filter(i=>i.status==='resolved'||i.status==='rejected').sort((a,b)=>new Date(b.resolvedAt||b.startedAt)-new Date(a.resolvedAt||a.startedAt));
if(!done.length){ el.innerHTML=`<div class="health"><div class="empty" style="padding:40px 6px"><div class="orb">${svg(ICN.check)}</div><h4>No history yet</h4><p>Once you approve a fix (solved) or cancel a recommendation, it's recorded here.</p><a class="btn-outline" href="#/investigations">Go to investigations</a></div></div>`; return; }
el.innerHTML=`<div class="health">${done.map(i=>{
const solved=i.status==='resolved';
const outcome=solved?'✓ You solved the problem':'✕ You cancelled the request';
const col=solved?'#1F9D57':'#8A8F9A';
return `<div class="act" style="cursor:pointer" onclick="location.hash='#/investigations/${i.key}'">
<span class="ic" style="color:${col}">${svg(solved?ICN.check:ICN.xcircle)}</span>
<div class="m"><div class="tt">${i.title} ${i.isDemo?'<span class="tag">DEMO</span>':''}</div>
<div class="sub">${i.key} · ${i.service} · <b style="color:${col}">${outcome}</b></div></div>
<div class="time">${timeAgo(i.resolvedAt||i.startedAt)}</div></div>`;
}).join('')}</div>`;
}
/* ---------- Ask AI (help assistant) ---------- */
const HELP_FAQ=[
{q:'How does RootVector work?', k:['how','work','rootvector','what is','about','explain','overview'],
a:'RootVector connects to your engineering stack (GitHub, Sentry, Datadog, Grafana, Kubernetes, OpenTelemetry) and watches for real signals. When something breaks it opens an incident and runs an autonomous AI investigation — correlating deployments, pull requests, errors and traces — to surface a <b>root cause with a confidence score</b>, then recommends a fix. A human approves before anything is executed, and RootVector verifies recovery afterwards.'},
{q:'How are incidents solved?', k:['solve','solved','fix','remediat','resolve','approve','rollback'],
a:'When an incident is detected, the AI agent gathers evidence, ranks competing <b>hypotheses with confidence</b>, identifies the most likely <b>root cause</b>, and recommends a reversible fix (e.g. a rollback). Nothing runs automatically — a person must click <b>Approve & Execute</b>. After approval, RootVector executes the remediation, verifies the error rate is back to baseline, and marks the incident <b>Resolved</b>. If you reject it, it’s logged in <b>History</b> as cancelled.'},
{q:'How does the AI investigation work?', k:['ai','investigation','investigate','agent','hypothes','confidence','evidence','llm','gemini'],
a:'The agent pulls real evidence from your connected sources, produces competing hypotheses each with a confidence %, picks the most likely root cause, and recommends a reversible remediation. It uses an <b>LLM (Gemini)</b> when configured, and a grounded correlation engine otherwise. You can watch every step stream live on the investigation page.'},
{q:'Is human approval required?', k:['human','approval','approve','manual','permission','safe','gate'],
a:'Yes — always. The AI investigates and recommends, but <b>a person must click "Approve & Execute"</b> before any remediation runs. That human-in-the-loop gate is exactly why nothing is ever changed in production automatically.'},
{q:'What integrations are supported?', k:['integration','connect','stack','github','sentry','datadog','grafana','kubernetes','slack','opentelemetry','webhook'],
a:'<b>GitHub</b> (OAuth), <b>Sentry</b> (signed webhook), and generic alert webhooks for <b>Datadog, Grafana, Kubernetes and OpenTelemetry</b> — a firing alert opens a real incident, a resolved one closes it. <b>Slack</b> is an outbound channel that posts new incidents to a channel. Connect them all on the <b>Integrations</b> page.'},
{q:'How do notifications work?', k:['notif','bell','alert','new','badge','unread'],
a:'The bell shows a live count of <b>new</b> incidents since you last looked. When a new one arrives (from GitHub, Sentry, Datadog, etc.) the number appears; click the bell or open <b>Investigations</b> to see what’s new and the count clears.'},
{q:'How do I navigate the app?', k:['navigat','where','start','page','menu','sidebar','find','scroll'],
a:'Use the left sidebar: <b>Overview</b> (KPIs + production health), <b>Investigations</b> (run/watch investigations), <b>Services</b> (health per service), <b>History</b> (solved & cancelled), <b>Repositories</b> (your GitHub), and <b>Integrations</b> (connect your stack). The bell (top-right) shows new incidents.'},
{q:'Who made RootVector?', k:['who made','who built','who created','creator','author','owner','manvi','developer','behind','made by','built by'],
a:'RootVector was built by <b>Manvi Yadav</b> (GitHub: <b>@Manvi0408</b>). If you like it, please ⭐ the repo: <b>github.com/Manvi0408/Rootvector</b> 🙌'}
];
const HELP_CHIPS=['How does RootVector work?','How are incidents solved?','How does the AI investigation work?','Is human approval required?','What integrations are supported?','How do notifications work?','How do I navigate the app?'];
let helpMsgs=[];
function helpAnswer(q){
const t=(q||'').toLowerCase();
let best=null,score=0;
HELP_FAQ.forEach(f=>{ let s=0; f.k.forEach(w=>{ if(t.includes(w)) s++; }); if(f.q.toLowerCase()===t) s+=10; if(s>score){score=s;best=f;} });
if(best && score>0) return best.a;
return 'I can explain how RootVector works, how incidents are solved, the AI investigation, human approval, integrations, notifications, and how to navigate the app. Try one of the suggested questions above.';
}
function helpEnsureStyle(){
if(document.getElementById('help-style')) return;
const s=document.createElement('style'); s.id='help-style';
s.textContent=`
.help-wrap{max-width:560px;margin:0 auto;text-align:center}
.help-h{font-size:18px;font-weight:800;color:var(--violet-ink);margin:6px 0 22px}
.help-card{background:#fff;border:1px solid #EEEFF3;border-radius:26px;box-shadow:0 1px 2px rgba(17,20,28,.04),0 30px 60px -30px rgba(17,20,28,.28);padding:26px 22px 20px;text-align:left}
.help-orb{width:74px;height:74px;border-radius:50%;margin:10px auto 16px;background:radial-gradient(circle at 34% 30%,#ffffff 0%,#ffd9e6 32%,#cfe0ff 62%,#dcc9ff 100%);box-shadow:0 0 0 10px rgba(180,200,255,.10),0 14px 34px -8px rgba(150,160,255,.55);animation:orbF 3s ease-in-out infinite}
@keyframes orbF{0%,100%{transform:translateY(0)}50%{transform:translateY(-5px)}}
.help-ask{text-align:center;font-size:20px;font-weight:700;color:#1A1630;margin-bottom:8px}
.help-conv{display:flex;flex-direction:column;gap:12px;max-height:46vh;overflow:auto;padding:6px 2px 10px}
.help-b{max-width:88%;padding:11px 14px;border-radius:14px;font-size:13.5px;line-height:1.55}
.help-b.me{align-self:flex-end;background:var(--violet);color:#fff;border-bottom-right-radius:5px}
.help-b.ai{align-self:flex-start;background:#F5F5F9;color:#241F35;border-bottom-left-radius:5px}
.help-chips{display:flex;gap:10px;overflow-x:auto;padding:14px 2px 10px;scrollbar-width:thin}
.help-chip{flex:0 0 auto;display:flex;align-items:center;gap:8px;background:#fff;border:1px solid #E9E9F0;border-radius:13px;padding:11px 14px;font-size:13px;font-weight:600;color:#3A3552;cursor:pointer;box-shadow:0 6px 16px -12px rgba(17,20,28,.4);white-space:nowrap}
.help-chip:hover{border-color:var(--violet);color:var(--violet-ink)}
.help-chip .sp{color:var(--violet)}
.help-input{display:flex;align-items:center;gap:8px;border:1px solid #E9E9F0;border-radius:16px;padding:7px 7px 7px 16px;margin-top:6px;background:#fff}
.help-input input{flex:1;border:0;outline:0;font:inherit;font-size:14px;background:transparent}
.help-send{width:42px;height:42px;border-radius:50%;border:0;background:#1B1B22;color:#fff;font-size:18px;display:flex;align-items:center;justify-content:center;flex:0 0 auto}
.help-send:hover{background:#000}
.help-sub{color:var(--muted-2);font-size:14px;margin-top:22px}
.help-typing{display:inline-flex;gap:4px;align-items:center;padding:2px 0}
.help-typing i{width:6px;height:6px;border-radius:50%;background:#B5B2C4;display:inline-block;animation:helpDot 1.2s infinite ease-in-out}
.help-typing i:nth-child(2){animation-delay:.18s}.help-typing i:nth-child(3){animation-delay:.36s}
@keyframes helpDot{0%,80%,100%{transform:scale(.6);opacity:.4}40%{transform:scale(1);opacity:1}}`;
document.head.appendChild(s);
}
function pageHelp(){
helpEnsureStyle();
setTimeout(helpRender,0);
return `<div class="help-wrap">
<div class="help-h">Ask AI</div>
<div class="help-card">
<div id="helpBody"></div>
<div class="help-chips" id="helpChips"></div>
<div class="help-input"><input id="helpMsg" placeholder="Message" onkeydown="if(event.key==='Enter'){event.preventDefault();helpSend();}"><button class="help-send" onclick="helpSend()" aria-label="Send">↑</button></div>
</div>
<div class="help-sub">Ask about how RootVector works — instant answers.</div>
</div>`;
}
function helpRender(){
const body=$('helpBody'); const chips=$('helpChips');
if(chips) chips.innerHTML=HELP_CHIPS.map(q=>`<div class="help-chip" onclick="helpAsk(this.dataset.q)" data-q="${q.replace(/"/g,'"')}"><span class="sp">✦</span>${q}</div>`).join('');
if(!body) return;
if(!helpMsgs.length){
body.innerHTML=`<div class="help-orb"></div><div class="help-ask">Ask RootVector anything</div>`;
} else {
body.innerHTML=`<div class="help-conv" id="helpConv">${helpMsgs.map(m=>`<div class="help-b ${m.role}">${m.text}</div>`).join('')}</div>`;
const c=$('helpConv'); if(c) c.scrollTop=c.scrollHeight;
}
}
function helpGreeting(q){
const t=q.toLowerCase().trim();
if(/^(hi+|hey+|hello+|yo|hola|namaste|sup|greetings)\b/.test(t)) return 'Hello! 👋 How can I help you today? You can ask me how RootVector works, how incidents are solved, or anything about the app.';
if(/\b(thank|thanks|thx|thnx|ty|appreciate)\b/.test(t)) return "You're welcome! 😊 Anything else you'd like to know about RootVector?";
if(/\b(bye|goodbye|see ya|cya|later)\b/.test(t)) return "Take care! I'm right here whenever you need help with RootVector. 👋";
if(/\b(who are you|what are you|your name|what can you do)\b/.test(t)) return "I'm the RootVector Assistant 🤖 — I help you understand how the platform detects, investigates and resolves production incidents. Ask me anything!";
if(/\b(how are you|how'?s it going|how do you do)\b/.test(t)) return "I'm doing great, thanks for asking! Ready to help. What would you like to know about RootVector?";
if(/^(ok|okay|cool|nice|great|got it|thanks bro|👍)/.test(t)) return "Glad that helps! Ask me anything else about RootVector whenever you like.";
return null;
}
function helpFormat(t){ let s=String(t).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); s=s.replace(/\*\*(.+?)\*\*/g,'<b>$1</b>').replace(/\n/g,'<br>'); return s; }
async function helpReply(q){
const g=helpGreeting(q); if(g) return g; // conversational replies, instant
try{ // real LLM answer when Gemini is configured
const r=await rvApi('/help/chat',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({message:q})});
if(r.ok){ const d=await r.json(); if(d && d.reply) return helpFormat(d.reply); }
}catch(e){}
return helpAnswer(q); // fallback: built-in knowledge base
}
async function helpAsk(q){
q=(q||'').trim(); if(!q) return;
helpMsgs.push({role:'me',text:q.replace(/</g,'<')});
helpMsgs.push({role:'ai',text:'<span class="help-typing"><i></i><i></i><i></i></span>'});
helpRender();
const reply=await helpReply(q);
helpMsgs[helpMsgs.length-1]={role:'ai',text:reply};
helpRender();
}
function helpSend(){ const i=$('helpMsg'); if(!i) return; const v=i.value; i.value=''; helpAsk(v); i.focus(); }
const PAGES = {
overview: pageOverview,
investigations: () => pageInvestigationsList(),
services: pageServices,
history: pageHistory,
repositories: pageRepositories,
integrations: pageIntegrations,
help: pageHelp,
settings: pageSettings,
account: pageSettings
};
/* ---------- router ---------- */
let rvES = null;
function closeStream(){ if(rvES){ try{ rvES.close(); }catch(e){} rvES=null; } }
function currentKey(){ return (location.hash.replace('#/','').split('/')[0]) || 'overview'; }
function route(){
closeStream();
rvCloseSidebar(); // navigating closes the mobile drawer
const parts = location.hash.replace('#/','').split('/');
const k = parts[0] || 'overview';
const navKey = (k==='investigations') ? 'investigations' : (PAGES[k] ? k : 'overview');