-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1192 lines (1043 loc) · 41.7 KB
/
Copy pathindex.html
File metadata and controls
1192 lines (1043 loc) · 41.7 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.0">
<title>GitPR Analyzer - AI Model</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
<link rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Fira+Code:wght@400;500&display=swap">
<style>
* {
transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
body {
background: linear-gradient(135deg, #F0F9FF 0%, #E0F2FE 50%, #F8FBFF 100%);
font-family: 'Plus Jakarta Sans', sans-serif;
min-height: 100vh;
}
.syne {
font-family: 'Syne', sans-serif;
}
.fira {
font-family: 'Fira Code', monospace;
}
/* ── Cards ── */
.card {
background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.8) 100%);
border: 1.5px solid rgba(14, 165, 233, 0.2);
border-radius: 24px;
box-shadow: 0 20px 40px rgba(14, 165, 233, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.5);
backdrop-filter: blur(10px);
}
.card:hover {
box-shadow: 0 25px 50px rgba(14, 165, 233, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.5);
border-color: rgba(14, 165, 233, 0.3);
}
/* ── Inputs ── */
.input-field {
background: rgba(255, 255, 255, 0.8);
border: 2px solid rgba(14, 165, 233, 0.15);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
font-weight: 500;
color: #1e293b;
}
.input-field::placeholder {
color: #94a3b8;
}
.input-field:focus {
background: white;
border-color: #0EA5E9;
box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15), inset 0 2px 4px rgba(14, 165, 233, 0.05);
outline: none;
}
/* ── Flow cards ── */
.flow-card {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
background: rgba(255, 255, 255, 0.6);
border: 2px solid rgba(14, 165, 233, 0.1);
position: relative;
overflow: hidden;
}
.flow-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(135deg, rgba(56, 189, 248, 0.1) 0%, transparent 100%);
opacity: 0;
transition: opacity 0.3s ease;
}
.flow-card:hover {
border-color: rgba(14, 165, 233, 0.3);
background: rgba(255, 255, 255, 0.8);
box-shadow: 0 12px 24px rgba(14, 165, 233, 0.1);
transform: translateY(-2px);
}
.flow-card:hover::before {
opacity: 1;
}
.flow-card.active {
border-color: #0EA5E9;
background: linear-gradient(135deg, #F0F9FF 0%, rgba(255, 255, 255, 0.9) 100%);
box-shadow: 0 12px 24px rgba(14, 165, 233, 0.15), inset 0 1px 0 rgba(56, 189, 248, 0.2);
}
/* ── Primary button ── */
.btn-primary {
background: linear-gradient(135deg, #0EA5E9 0%, #0284C7 50%, #0369A1 100%);
box-shadow: 0 15px 30px rgba(14, 165, 233, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
font-weight: 700;
letter-spacing: 0.5px;
position: relative;
overflow: hidden;
}
.btn-primary::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
transition: left 0.6s ease;
}
.btn-primary:hover::before {
left: 100%;
}
.btn-primary:hover {
box-shadow: 0 20px 40px rgba(14, 165, 233, 0.4);
transform: translateY(-2px);
}
.btn-primary:active {
transform: translateY(0);
}
.btn-primary:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none !important;
}
/* ── Secondary button (for apply/create) ── */
.btn-secondary {
background: linear-gradient(135deg, #475569 0%, #334155 100%);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.btn-secondary:hover {
transform: translateY(-1px);
}
/* ── Stat card ── */
.stat-card {
background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.8) 100%);
border: 1px solid rgba(14, 165, 233, 0.15);
border-radius: 16px;
padding: 20px;
position: relative;
overflow: hidden;
}
.stat-card::after {
content: '';
position: absolute;
top: -50%;
right: -50%;
width: 200px;
height: 200px;
background: radial-gradient(circle, rgba(14, 165, 233, 0.08) 0%, transparent 70%);
border-radius: 50%;
}
.stat-label {
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
color: #64748b;
}
.stat-value {
font-size: 26px;
font-weight: 700;
color: #0EA5E9;
margin-top: 6px;
}
/* ── Badges ── */
.badge {
display: inline-block;
padding: 5px 14px;
border-radius: 10px;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.5px;
font-family: 'Fira Code', monospace;
}
.badge-pr {
background: rgba(14, 165, 233, 0.1);
color: #0284C7;
border: 1px solid rgba(14, 165, 233, 0.25);
}
.badge-issue {
background: rgba(124, 92, 252, 0.1);
color: #7c5cfc;
border: 1px solid rgba(124, 92, 252, 0.25);
}
.badge-manual {
background: rgba(100, 116, 139, 0.1);
color: #64748b;
border: 1px solid rgba(100, 116, 139, 0.2);
}
.badge-open {
background: rgba(34, 197, 94, 0.1);
color: #16a34a;
border: 1px solid rgba(34, 197, 94, 0.25);
}
.badge-closed {
background: rgba(239, 68, 68, 0.1);
color: #dc2626;
border: 1px solid rgba(239, 68, 68, 0.25);
}
.badge-merged {
background: rgba(124, 92, 252, 0.1);
color: #7c3aed;
border: 1px solid rgba(124, 92, 252, 0.25);
}
/* ── Label chips ── */
.label-chip {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 5px 13px;
border-radius: 20px;
border: 1px solid;
font-family: 'Fira Code', monospace;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.03em;
}
.chip-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: currentColor;
opacity: 0.6;
flex-shrink: 0;
}
.chip-bug {
color: #dc2626;
border-color: rgba(220, 38, 38, 0.35);
background: rgba(220, 38, 38, 0.07);
}
.chip-enhancement {
color: #0284C7;
border-color: rgba(2, 132, 199, 0.35);
background: rgba(2, 132, 199, 0.07);
}
.chip-documentation {
color: #d97706;
border-color: rgba(217, 119, 6, 0.35);
background: rgba(217, 119, 6, 0.07);
}
.chip-test {
color: #16a34a;
border-color: rgba(22, 163, 74, 0.35);
background: rgba(22, 163, 74, 0.07);
}
.chip-request {
color: #ea580c;
border-color: rgba(234, 88, 12, 0.35);
background: rgba(234, 88, 12, 0.07);
}
.chip-unclassified {
color: #64748b;
border-color: rgba(100, 116, 139, 0.3);
background: rgba(100, 116, 139, 0.07);
}
.chip-critical {
color: #be123c;
border-color: rgba(190, 18, 60, 0.4);
background: rgba(190, 18, 60, 0.08);
animation: pulse-border 2s infinite;
}
.chip-high-priority {
color: #e11d48;
border-color: rgba(225, 29, 72, 0.35);
background: rgba(225, 29, 72, 0.07);
}
.chip-normal-priority {
color: #2563eb;
border-color: rgba(37, 99, 235, 0.35);
background: rgba(37, 99, 235, 0.07);
}
.chip-low-priority {
color: #64748b;
border-color: rgba(100, 116, 139, 0.35);
background: rgba(100, 116, 139, 0.07);
}
.chip-existing {
color: #475569;
border-color: rgba(71, 85, 105, 0.25);
background: rgba(241, 245, 249, 0.8);
font-weight: 400;
}
@keyframes pulse-border {
0% {
border-color: rgba(190, 18, 60, 0.4);
}
50% {
border-color: rgba(190, 18, 60, 0.8);
}
100% {
border-color: rgba(190, 18, 60, 0.4);
}
}
/* ── Section heading ── */
.section-heading {
font-size: 10px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 1.2px;
color: #94a3b8;
margin-bottom: 10px;
}
/* ── Progress bar ── */
.prog-track {
width: 100%;
height: 6px;
background: rgba(14, 165, 233, 0.12);
border-radius: 3px;
overflow: hidden;
margin-top: 8px;
}
.prog-fill {
height: 100%;
border-radius: 3px;
transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
/* ── Structured text box ── */
.structured-box {
background: rgba(248, 250, 252, 0.8);
border: 1.5px solid rgba(14, 165, 233, 0.12);
border-radius: 12px;
padding: 14px 16px;
font-family: 'Fira Code', monospace;
font-size: 11px;
color: #64748b;
line-height: 1.7;
white-space: pre-wrap;
word-break: break-word;
max-height: 110px;
overflow-y: auto;
}
/* ── History item ── */
.history-item {
background: rgba(255, 255, 255, 0.7);
border: 1px solid rgba(14, 165, 233, 0.12);
border-radius: 14px;
padding: 14px 18px;
display: flex;
align-items: center;
gap: 14px;
transition: all 0.2s;
}
.history-item:hover {
border-color: rgba(14, 165, 233, 0.3);
box-shadow: 0 4px 12px rgba(14, 165, 233, 0.08);
}
/* ── Error ── */
.error-box {
background: rgba(239, 68, 68, 0.06);
border: 1px solid rgba(239, 68, 68, 0.25);
border-radius: 12px;
padding: 12px 16px;
font-size: 13px;
color: #dc2626;
font-weight: 500;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(16px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.animate-in {
animation: fadeInUp 0.5s ease-out;
}
.loading-spinner {
width: 46px;
height: 46px;
border: 4px solid rgba(14, 165, 233, 0.2);
border-top-color: #0EA5E9;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
</style>
</head>
<body class="min-h-screen pb-20">
<!-- Background blobs -->
<div class="fixed inset-0 overflow-hidden pointer-events-none">
<div
class="absolute top-0 right-0 w-96 h-96 bg-gradient-to-b from-sky-200 to-transparent rounded-full mix-blend-multiply filter blur-3xl opacity-20">
</div>
<div
class="absolute bottom-0 left-1/2 w-96 h-96 bg-gradient-to-t from-sky-200 to-transparent rounded-full mix-blend-multiply filter blur-3xl opacity-20">
</div>
</div>
<div class="max-w-4xl mx-auto px-6 pt-16 relative z-10">
<!-- ── HEADER ── -->
<div class="text-center mb-16">
<div class="inline-flex items-center gap-4 mb-4">
<div
class="w-16 h-16 bg-gradient-to-br from-[#38BDF8] to-[#0284C7] rounded-3xl flex items-center justify-center text-4xl shadow-2xl animate-in">
⚡</div>
<div class="text-left">
<h1
class="syne text-5xl font-bold tracking-tighter bg-gradient-to-r from-[#0284C7] to-[#0EA5E9] bg-clip-text text-transparent">
GitPR Analyzer</h1>
<p class="text-slate-500 text-sm mt-1">Pull Request/Issue Classification · MultiTask DistilBERT</p>
</div>
</div>
<p class="text-slate-500 text-base max-w-xl mx-auto mt-4">AI-powered classification of GitHub Pull Requests &
Issues — labels, sentiment, and priority in one shot.</p>
<div class="mt-4">
<span class="fira text-xs text-sky-500 bg-sky-50 border border-sky-100 rounded-full px-4 py-1.5">
Session analyses: <strong id="session-count">0</strong>
</span>
</div>
</div>
<!-- ── TOKEN CARD (New) ── -->
<div class="card p-6 mb-8 animate-in">
<div class="flex items-center gap-3 mb-4">
<div class="w-8 h-8 rounded-xl bg-sky-100 flex items-center justify-center">🔑</div>
<div>
<p class="font-semibold text-slate-800">GitHub Token (optional)</p>
<p class="text-xs text-slate-400">For private repos and automated label creation — PAT or GitHub App token</p>
</div>
</div>
<input type="password" id="githubToken" class="input-field w-full px-5 py-3 rounded-2xl border text-sm fira"
placeholder="ghp_... or github_pat_...">
<p class="fira text-xs text-slate-400 mt-2">Token is never stored on server, only in sessionStorage (cleared when
tab closes).</p>
</div>
<!-- ── FLOW SELECTION ── -->
<div class="mb-10">
<p class="section-heading mb-5">Choose input method</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
<button onclick="switchFlow('A')" id="btnA"
class="flow-card active p-7 rounded-3xl text-left cursor-pointer group">
<div class="flex items-start gap-4">
<div
class="w-12 h-12 rounded-2xl flex items-center justify-center text-2xl bg-gradient-to-br from-sky-100 to-sky-50 border border-sky-100 group-hover:scale-110 transition-transform">
🔗</div>
<div>
<h3 class="font-bold text-slate-900 group-hover:text-sky-600">Flow A — GitHub URL</h3>
<p class="text-slate-400 text-sm mt-1">Fetch title, body & metadata directly from GitHub</p>
</div>
</div>
</button>
<button onclick="switchFlow('B')" id="btnB" class="flow-card p-7 rounded-3xl text-left cursor-pointer group">
<div class="flex items-start gap-4">
<div
class="w-12 h-12 rounded-2xl flex items-center justify-center text-2xl bg-gradient-to-br from-sky-100 to-sky-50 border border-sky-100 group-hover:scale-110 transition-transform">
✏️</div>
<div>
<h3 class="font-bold text-slate-900 group-hover:text-sky-600">Flow B — Manual Input</h3>
<p class="text-slate-400 text-sm mt-1">Type a title & body to classify without a URL</p>
</div>
</div>
</button>
</div>
</div>
<!-- ── FORM ── -->
<div class="space-y-5">
<!-- Flow A -->
<div id="flowA" class="card p-8 animate-in">
<label class="block text-sm font-semibold text-slate-700 mb-3">GitHub PR or Issue URL</label>
<input type="url" id="pr_url" placeholder="https://github.com/owner/repo/pull/123 or .../issues/456"
class="input-field w-full px-5 py-4 rounded-2xl border text-sm fira" />
<p class="fira text-xs text-slate-400 mt-2">Supports /pull/ and /issues/ · Public repos work without auth;
private repos require a token above.</p>
</div>
<!-- Flow B -->
<div id="flowB" class="hidden space-y-5">
<div class="card p-8 animate-in">
<label class="block text-sm font-semibold text-slate-700 mb-3">
PR / Issue Title <span class="text-red-500">*</span>
</label>
<input type="text" id="manual_title" placeholder="Fix: null pointer in auth middleware"
class="input-field w-full px-5 py-4 rounded-2xl border text-sm" />
</div>
<div class="card p-8 animate-in">
<label class="block text-sm font-semibold text-slate-700 mb-3">Body / Description</label>
<textarea id="manual_body" rows="5" placeholder="Describe the changes or issue in detail…"
class="input-field w-full px-5 py-4 rounded-2xl border text-sm resize-none"></textarea>
</div>
<div class="card p-8 animate-in">
<label class="block text-sm font-semibold text-slate-700 mb-3">
Repository (for Create Issue) <span class="text-slate-400 font-normal">· owner/repo</span>
</label>
<input type="text" id="manual_repo" placeholder="e.g., facebook/react"
class="input-field w-full px-5 py-4 rounded-2xl border text-sm fira" />
<p class="fira text-xs text-slate-400 mt-2">Required if you want to create a new issue after analysis.</p>
</div>
</div>
<!-- Error -->
<div id="error-box" class="error-box hidden"></div>
<!-- Submit -->
<button id="analyze-btn" onclick="analyze()"
class="btn-primary w-full py-5 text-base text-white rounded-2xl flex items-center justify-center gap-3">
<span id="btn-icon">⚡</span>
<span id="btn-text">Analyze</span>
</button>
</div>
<!-- ── RESULT CARD ── -->
<div id="result-card" class="hidden mt-14 animate-in">
<!-- Title row -->
<div class="flex items-start justify-between gap-4 mb-5 flex-wrap">
<div class="flex-1 min-w-0">
<div class="flex flex-wrap gap-2 mb-3" id="result-badges"></div>
<h2 class="text-2xl font-bold text-slate-900 leading-snug" id="result-title"></h2>
<a id="result-link" href="#" target="_blank" rel="noopener"
class="fira text-xs text-sky-500 hover:text-sky-700 mt-1 block break-all" style="display:none;"></a>
</div>
<a id="gh-open-btn" href="#" target="_blank" rel="noopener"
class="hidden shrink-0 inline-flex items-center gap-2 px-4 py-2 rounded-xl bg-sky-50 hover:bg-sky-100 text-sky-600 font-semibold text-sm border border-sky-100 transition-all">
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor">
<path
d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" />
</svg>
Open on GitHub
</a>
</div>
<div class="card p-8">
<!-- Predicted Labels
<div class="mb-7">
<p class="section-heading">Predicted Labels</p>
<div class="flex flex-wrap gap-2" id="predicted-labels"></div>
</div> -->
<!-- Predicted Labels Section -->
<div class="mb-7">
<div class="flex items-center justify-between mb-4">
<p class="section-heading !mb-0">Predicted Labels</p>
<!-- Buttons will live here in both flows -->
<div id="automation-buttons" class="flex gap-3"></div>
</div>
<div class="flex flex-wrap gap-2" id="predicted-labels"></div>
</div>
<!-- Existing GitHub Labels -->
<div id="existing-labels-section" class="hidden mb-7">
<p class="section-heading">Already on GitHub</p>
<div class="flex flex-wrap gap-2" id="existing-labels"></div>
</div>
<!-- Automation Buttons (dynamic)
<div id="automation-buttons" class="flex flex-wrap gap-4 mb-7"></div> -->
<div class="border-t border-slate-100 my-6"></div>
<!-- Sentiment + Priority -->
<div class="grid grid-cols-1 sm:grid-cols-2 gap-5 mb-7">
<div class="stat-card">
<p class="stat-label">Sentiment</p>
<p class="stat-value" id="sentiment-value">—</p>
<div class="prog-track">
<div class="prog-fill" id="sentiment-bar" style="width:0%"></div>
</div>
<p class="fira text-xs text-slate-400 mt-2">
Confidence: <span class="text-slate-600 font-semibold" id="sentiment-conf">—</span>
</p>
</div>
<div class="stat-card">
<p class="stat-label">Priority Score</p>
<p class="stat-value" id="priority-value">—</p>
<div class="prog-track">
<div class="prog-fill" id="priority-bar" style="width:0%"></div>
</div>
<p class="fira text-xs text-slate-400 mt-2">
Level: <span class="font-semibold" id="priority-level">—</span>
</p>
</div>
</div>
<!-- Confidence Breakdown -->
<div id="conf-breakdown-section" class="hidden mb-7">
<p class="section-heading">Label Confidence Breakdown</p>
<div class="space-y-3" id="conf-breakdown"></div>
</div>
<!-- GitHub Metadata -->
<div id="gh-meta-section" class="hidden mb-7">
<p class="section-heading">GitHub Metadata</p>
<div class="grid grid-cols-2 sm:grid-cols-4 gap-3" id="gh-meta-grid"></div>
</div>
<div class="border-t border-slate-100 my-6"></div>
<!-- Structured Input -->
<div>
<button onclick="toggleStructured()"
class="section-heading flex items-center gap-2 hover:text-slate-500 cursor-pointer w-full text-left">
<span>Structured Input</span>
<span id="structured-arrow" class="ml-1">▾</span>
</button>
<div id="structured-wrap" class="mt-2">
<div class="structured-box" id="structured-text"></div>
</div>
</div>
<!-- Footer -->
<div class="flex justify-between items-center mt-6 flex-wrap gap-2">
<span class="fira text-xs text-slate-400" id="result-ts"></span>
</div>
</div>
</div><!-- /result-card -->
<!-- ── HISTORY ── -->
<div class="mt-20">
<p class="section-heading mb-5">Session History</p>
<div id="history-list">
<p class="fira text-xs text-slate-400 text-center py-8">No analyses yet this session.</p>
</div>
</div>
</div><!-- /container -->
<script>
/* ─── STATE ─── */
let currentFlow = 'A';
let structOpen = true;
let sessionCount = 0;
// Token management
function getToken() {
return sessionStorage.getItem('github_token') || '';
}
function setToken(token) {
if (token) sessionStorage.setItem('github_token', token);
else sessionStorage.removeItem('github_token');
}
// Custom function definitions for token management and history management
window.addEventListener('load', () => {
const tokenInput = document.getElementById('githubToken');
tokenInput.value = getToken();
tokenInput.addEventListener('input', () => setToken(tokenInput.value));
switchFlow('A');
const history = getHistory();
sessionCount = history.length;
document.getElementById('session-count').textContent = sessionCount;
renderHistory(history);
});
// History management
function getHistory() {
return JSON.parse(sessionStorage.getItem('analysis_history') || '[]');
}
function setHistory(history) {
sessionStorage.setItem('analysis_history', JSON.stringify(history));
}
function addToHistory(result) {
const history = getHistory();
history.unshift(result);
// Keep only latest 25 analyses
const trimmed = history.slice(0, 25);
setHistory(trimmed);
return trimmed;
}
/*------POPUP FUNCTIONS---------*/
function showOverlay(title, message) {
const overlay = document.getElementById('action-overlay');
document.getElementById('overlay-title').textContent = title;
document.getElementById('overlay-message').textContent = message;
overlay.classList.remove('hidden');
// Disable scrolling
document.body.style.overflow = 'hidden';
}
function hideOverlay() {
const overlay = document.getElementById('action-overlay');
overlay.classList.add('hidden');
document.body.style.overflow = '';
}
function showResultPopup(success, message) {
const overlay = document.getElementById('action-overlay');
const icon = success ? '✅' : '❌';
document.getElementById('overlay-title').textContent = success ? 'Success' : 'Action Failed';
document.getElementById('overlay-message').innerHTML = `${icon} ${message}`;
// Auto close after 2.2s
setTimeout(() => { hideOverlay(); }, 2200);
}
/* ─── FLOW SWITCH ─── */
function switchFlow(f) {
currentFlow = f;
document.getElementById('flowA').classList.toggle('hidden', f !== 'A');
document.getElementById('flowB').classList.toggle('hidden', f !== 'B');
document.getElementById('btnA').classList.toggle('active', f === 'A');
document.getElementById('btnB').classList.toggle('active', f === 'B');
hideError();
document.getElementById('result-card').classList.add('hidden');
}
/* ─── STRUCTURED TOGGLE ─── */
function toggleStructured() {
structOpen = !structOpen;
document.getElementById('structured-wrap').style.display = structOpen ? '' : 'none';
document.getElementById('structured-arrow').textContent = structOpen ? '▾' : '▸';
}
/* ─── ERROR ─── */
function showError(msg) {
const el = document.getElementById('error-box');
el.textContent = '⚠ ' + msg;
el.classList.remove('hidden');
}
function hideError() { document.getElementById('error-box').classList.add('hidden'); }
/* ─── LOADING ─── */
function setLoading(on) {
document.getElementById('analyze-btn').disabled = on;
document.getElementById('btn-icon').textContent = on ? '⏳' : '⚡';
document.getElementById('btn-text').textContent = on
? (currentFlow === 'A' ? 'Fetching from GitHub…' : 'Running model…')
: 'Analyze';
}
/* ─── HELPERS ─── */
function priorityColor(s) {
if (s >= 0.75) return '#dc2626';
if (s >= 0.5) return '#d97706';
if (s >= 0.25) return '#0284C7';
return '#94a3b8';
}
function renderPriority(r) {
const label = r.priority_label;
if (!label) return 'Unknown';
return label.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
}
function sentimentColor(s) {
if (s === 'Negative') return '#dc2626';
if (s === 'Positive') return '#16a34a';
return '#d97706';
}
function labelChip(label, conf) {
const confStr = (conf !== undefined && conf !== null) ? ` ${Math.round(conf * 100)}%` : '';
const cssClass = label.toLowerCase().replace(/\s+/g, '-');
return `<span class="label-chip chip-${cssClass}"><span class="chip-dot"></span>${label}${confStr}</span>`;
}
function existingChip(label) {
return `<span class="label-chip chip-existing">${label}</span>`;
}
/* ─── RENDER RESULT (same as before, but with new automation buttons placeholder) ─── */
function renderResult(r) {
/* Meta badges */
let badges = '';
if (r.kind) badges += `<span class="badge badge-${r.kind === 'PR' ? 'pr' : 'issue'}">${r.kind}</span>`;
else badges += `<span class="badge badge-manual">Manual</span>`;
if (r.state) badges += `<span class="badge badge-${r.state}">${r.state}</span>`;
if (r.author) badges += `<span class="fira text-xs text-slate-400 self-center">by @${r.author}</span>`;
document.getElementById('result-badges').innerHTML = badges;
/* Title */
document.getElementById('result-title').textContent = r.display_title || r.title || 'Analysis Result';
/* Link below title */
const linkEl = document.getElementById('result-link');
if (r.html_url) {
linkEl.href = r.html_url;
linkEl.textContent = r.html_url;
linkEl.style.display = '';
} else {
linkEl.style.display = 'none';
}
/* Open on GitHub button */
const ghBtn = document.getElementById('gh-open-btn');
if (r.html_url) { ghBtn.href = r.html_url; ghBtn.classList.remove('hidden'); }
else { ghBtn.classList.add('hidden'); }
/* Predicted Labels (final_labels) */
const labels = r.final_labels || [];
document.getElementById('predicted-labels').innerHTML = labels.length
? labels.map(l => labelChip(l, r.github_confidences?.[l])).join('')
: '<span class="fira text-xs text-slate-400">No labels detected</span>';
/* Existing GitHub labels */
const existSec = document.getElementById('existing-labels-section');
if (r.existing_labels && r.existing_labels.length > 0) {
document.getElementById('existing-labels').innerHTML = r.existing_labels.map(existingChip).join('');
existSec.classList.remove('hidden');
} else {
existSec.classList.add('hidden');
}
// Custom Automation Buttons Logic: Show Apply Labels for URL flow if we have necessary info, and Create Issue for Manual flow if we have title + repo
/* Automation buttons: rendered on the far right of 'Predicted Labels' */
const token = getToken();
const autoDiv = document.getElementById('automation-buttons');
autoDiv.innerHTML = '';
if (token) {
// REMOVE bg-indigo classes since gradient replaces them
const btnClasses = `text-white inline-flex items-center gap-2 px-6 py-2.5 rounded-xl text-sm font-bold whitespace-nowrap shadow-lg transition-all active:scale-95 hover:brightness-110 relative top-1`;
// Determine priority color
const pColor = priorityColor(r.priority_score || r.score || 0);
// Premium gradient style
const btnStyle = `background: linear-gradient(135deg,${pColor}DD 0%,${pColor} 55%,${pColor}EE 100%);box-shadow: 0 4px 14px ${pColor}55;`;
// URL Flow: Apply Labels button
if (r.number && r.owner && r.repo) {
const applyBtn = document.createElement('button');
applyBtn.innerHTML = `<span>🏷️</span> Apply Labels to #${r.number}`;
applyBtn.className = btnClasses;
// APPLY STYLE HERE
applyBtn.style = btnStyle;
applyBtn.onclick = () => applyLabels(r.owner, r.repo, r.number, r.final_labels || [], token);
autoDiv.appendChild(applyBtn);
}
// Manual Flow: Create Issue button
if (currentFlow === 'B' && r.title && document.getElementById('manual_repo').value.trim()) {
const createBtn = document.createElement('button');
createBtn.innerHTML = `<span>✨</span> Create Issue`;
createBtn.className = btnClasses;
// APPLY STYLE HERE
createBtn.style = btnStyle;
createBtn.onclick = () => createIssue(document.getElementById('manual_repo').value.trim(), r.title, r.body || '', r.final_labels || [], token);
autoDiv.appendChild(createBtn);
}
}
/* Sentiment */
const sColor = sentimentColor(r.sentiment);
const sentEl = document.getElementById('sentiment-value');
sentEl.textContent = r.sentiment || '—';
sentEl.style.color = sColor;
const sentPct = Math.round((r.sentiment_confidence || 0) * 100);
document.getElementById('sentiment-conf').textContent = sentPct + '%';
const sBar = document.getElementById('sentiment-bar');
sBar.style.width = sentPct + '%';
sBar.style.background = `linear-gradient(90deg, ${sColor}66, ${sColor})`;
/* Priority */
const score = r.priority_score || 0;
const pColor = priorityColor(score);
const pvEl = document.getElementById('priority-value');
pvEl.textContent = score.toFixed(2);
pvEl.style.color = pColor;
const pBar = document.getElementById('priority-bar');
pBar.style.width = (score * 100) + '%';
pBar.style.background = `linear-gradient(90deg, ${pColor}66, ${pColor})`;
const plEl = document.getElementById('priority-level');
plEl.textContent = renderPriority(r);
plEl.style.color = pColor;
/* Confidence breakdown */
const confMap = r.github_confidences || {};
const confKeys = Object.keys(confMap);
const confSec = document.getElementById('conf-breakdown-section');
if (confKeys.length > 0) {
document.getElementById('conf-breakdown').innerHTML = confKeys.map(lbl => {
const pct = Math.round(confMap[lbl] * 100);
return `<div>
<div class="flex justify-between items-center mb-1">
<span class="label-chip chip-${lbl} py-0.5">${lbl}</span>
<span class="fira text-xs font-semibold text-slate-500">${pct}%</span>
</div>
<div class="prog-track">
<div class="prog-fill bg-gradient-to-r from-sky-300 to-sky-500" style="width:${pct}%"></div>
</div>
</div>`;
}).join('');
confSec.classList.remove('hidden');
} else {
confSec.classList.add('hidden');
}
/* GitHub metadata */
const metaSec = document.getElementById('gh-meta-section');
const metaGrid = document.getElementById('gh-meta-grid');
const metaItems = [];
if (r.owner && r.repo) metaItems.push(['Repo', `${r.owner}/${r.repo}`]);
if (r.number) metaItems.push(['Number', `#${r.number}`]);
if (r.comments !== undefined) metaItems.push(['Comments', r.comments]);
if (r.created_at) metaItems.push(['Created', r.created_at.slice(0, 10)]);
if (metaItems.length > 0) {
metaGrid.innerHTML = metaItems.map(([k, v]) => `
<div class="bg-slate-50 border border-slate-100 rounded-xl px-4 py-3">
<p class="stat-label">${k}</p>
<p class="fira text-sm font-semibold text-slate-700 mt-1 truncate" title="${v}">${v}</p>
</div>`).join('');
metaSec.classList.remove('hidden');
} else {
metaSec.classList.add('hidden');
}
/* Structured text */
document.getElementById('structured-text').textContent = r.structured_text || '';
/* Timestamp */
document.getElementById('result-ts').textContent = r.timestamp || '';
/* Show card */
const card = document.getElementById('result-card');
card.classList.remove('hidden');
setTimeout(() => card.scrollIntoView({ behavior: 'smooth', block: 'start' }), 50);
}
// Custom version of applyLabels that uses the same endpoint but with a different popup style for success/failure instead of alert
async function applyLabels(owner, repo, number, labels, token) {
if (!labels.length) {
showResultPopup(false, 'No labels to apply.');
return;
}
const payload = {
repo: `${owner}/${repo}`,
number: number,
labels: labels,
token: token
};
try {
showOverlay(
'Applying Labels',
`Applying ${labels.length} label(s) to #${number}...`
);