synth-shell-theme 1.3.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. synth_shell_theme/__init__.py +7 -0
  2. synth_shell_theme/__main__.py +8 -0
  3. synth_shell_theme/assets/studio.html +1920 -0
  4. synth_shell_theme/cli.py +887 -0
  5. synth_shell_theme/core.py +1695 -0
  6. synth_shell_theme/ecosystem.py +537 -0
  7. synth_shell_theme/patches.py +1853 -0
  8. synth_shell_theme/paths.py +363 -0
  9. synth_shell_theme/separators.py +320 -0
  10. synth_shell_theme/server.py +506 -0
  11. synth_shell_theme/themes/01-screenshot-match.conf +30 -0
  12. synth_shell_theme/themes/02-current-live-theme.conf +30 -0
  13. synth_shell_theme/themes/03-dracula-punch.conf +30 -0
  14. synth_shell_theme/themes/04-nord-ice.conf +30 -0
  15. synth_shell_theme/themes/05-matrix-green.conf +30 -0
  16. synth_shell_theme/themes/06-amber-heat.conf +30 -0
  17. synth_shell_theme/themes/07-cloud-ops.conf +30 -0
  18. synth_shell_theme/themes/08-catppuccin-mauve.conf +30 -0
  19. synth_shell_theme/themes/09-solarized-night.conf +30 -0
  20. synth_shell_theme/themes/10-gruvbox-dark.conf +30 -0
  21. synth_shell_theme/themes/11-monokai-neon.conf +30 -0
  22. synth_shell_theme/themes/12-tokyo-night.conf +30 -0
  23. synth_shell_theme/themes/13-synthwave-pink.conf +30 -0
  24. synth_shell_theme/themes/14-forest-mint.conf +30 -0
  25. synth_shell_theme/themes/15-ruby-steel.conf +30 -0
  26. synth_shell_theme/themes/16-ice-gold.conf +30 -0
  27. synth_shell_theme/themes/17-aqua-slate.conf +30 -0
  28. synth_shell_theme/themes/18-cyber-lime.conf +30 -0
  29. synth_shell_theme/themes/19-lavender-sunset.conf +30 -0
  30. synth_shell_theme/themes/20-minimal-mono.conf +30 -0
  31. synth_shell_theme/themes/21-rose-pine.conf +30 -0
  32. synth_shell_theme/themes/22-kanagawa.conf +30 -0
  33. synth_shell_theme/themes/23-everforest.conf +30 -0
  34. synth_shell_theme/themes/24-one-dark.conf +30 -0
  35. synth_shell_theme/themes/25-ayu-dark.conf +30 -0
  36. synth_shell_theme/themes/26-nightfox.conf +30 -0
  37. synth_shell_theme/themes/27-palenight.conf +30 -0
  38. synth_shell_theme/themes/28-cyberdream.conf +30 -0
  39. synth_shell_theme/themes/29-moonlight.conf +30 -0
  40. synth_shell_theme/themes/30-poimandres.conf +30 -0
  41. synth_shell_theme/themes/31-tokyo-storm.conf +30 -0
  42. synth_shell_theme/themes/32-catppuccin-mocha.conf +30 -0
  43. synth_shell_theme/themes/33-nordic-aurora.conf +30 -0
  44. synth_shell_theme/themes/34-horizon-synth.conf +30 -0
  45. synth_shell_theme/themes/35-gruvbox-material.conf +30 -0
  46. synth_shell_theme/themes/36-oxocarbon.conf +30 -0
  47. synth_shell_theme/themes/37-catppuccin-latte.conf +30 -0
  48. synth_shell_theme/themes/38-tokyo-twilight.conf +30 -0
  49. synth_shell_theme/themes/39-solarized-ocean.conf +30 -0
  50. synth_shell_theme/themes/40-vaporwave-sunset.conf +30 -0
  51. synth_shell_theme/themes/41-deep-abyss.conf +30 -0
  52. synth_shell_theme/themes/42-sakura-blossom.conf +30 -0
  53. synth_shell_theme/themes/43-emerald-forest.conf +30 -0
  54. synth_shell_theme/themes/44-vesper.conf +30 -0
  55. synth_shell_theme/themes/45-cobalt-neon.conf +30 -0
  56. synth_shell_theme/themes/46-desert-dunes.conf +30 -0
  57. synth_shell_theme/themes/47-cyber-samurai.conf +30 -0
  58. synth_shell_theme/themes/48-glacier-mint.conf +30 -0
  59. synth_shell_theme/themes/49-carbon-titanium.conf +30 -0
  60. synth_shell_theme/themes/50-matcha-latte.conf +30 -0
  61. synth_shell_theme/themes/51-volcanic-magma.conf +30 -0
  62. synth_shell_theme/themes/52-catppuccin-frappe.conf +30 -0
  63. synth_shell_theme/themes/53-bioluminescence.conf +30 -0
  64. synth_shell_theme/themes/54-mocha-caramel.conf +30 -0
  65. synth_shell_theme/themes/55-neon-genesis.conf +30 -0
  66. synth_shell_theme/themes/56-midnight-amethyst.conf +30 -0
  67. synth_shell_theme/themes/57-andromeda.conf +30 -0
  68. synth_shell_theme/themes/58-golden-velvet.conf +30 -0
  69. synth_shell_theme/themes/59-miami-vice.conf +30 -0
  70. synth_shell_theme/themes/60-zen-garden.conf +30 -0
  71. synth_shell_theme/themes/61-google-cloud.conf +30 -0
  72. synth_shell_theme/themes/62-github-dark.conf +30 -0
  73. synth_shell_theme/themes/63-cyberpunk-edgerunners.conf +30 -0
  74. synth_shell_theme/themes/64-vscode-dark.conf +30 -0
  75. synth_shell_theme/themes.py +580 -0
  76. synth_shell_theme/tui.py +632 -0
  77. synth_shell_theme-1.3.9.dist-info/METADATA +261 -0
  78. synth_shell_theme-1.3.9.dist-info/RECORD +82 -0
  79. synth_shell_theme-1.3.9.dist-info/WHEEL +5 -0
  80. synth_shell_theme-1.3.9.dist-info/entry_points.txt +3 -0
  81. synth_shell_theme-1.3.9.dist-info/licenses/LICENSE +21 -0
  82. synth_shell_theme-1.3.9.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1920 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Synth-Shell Theme Studio</title>
7
+ <style>
8
+ :root {
9
+ color-scheme: dark;
10
+ --bg: #0a0c10;
11
+ --panel: #12161f;
12
+ --panel-elev: #171c28;
13
+ --card: #151923;
14
+ --card-hover: #1b2130;
15
+ --border: #262e40;
16
+ --border-strong: #394663;
17
+ --accent: #58a6ff;
18
+ --accent-hover: #79b8ff;
19
+ --success: #3fb950;
20
+ --warn: #d29922;
21
+ --text: #eef2f8;
22
+ --muted: #9aa5b8;
23
+ --soft: #6e7a90;
24
+ --mono: "JetBrainsMono Nerd Font", "MesloLGS NF", "FiraCode Nerd Font", "CaskaydiaCove Nerd Font", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
25
+ --sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
26
+ }
27
+
28
+ * { box-sizing: border-box; }
29
+
30
+ body {
31
+ margin: 0;
32
+ background: radial-gradient(circle at top right, #131b2e 0%, var(--bg) 45%);
33
+ color: var(--text);
34
+ font-family: var(--sans);
35
+ line-height: 1.45;
36
+ min-height: 100vh;
37
+ }
38
+
39
+ .container {
40
+ width: min(1480px, calc(100% - 32px));
41
+ margin: 0 auto;
42
+ padding: 20px 0 56px;
43
+ }
44
+
45
+ /* Top Header */
46
+ .topbar {
47
+ display: flex;
48
+ flex-wrap: wrap;
49
+ justify-content: space-between;
50
+ align-items: center;
51
+ gap: 14px;
52
+ margin-bottom: 16px;
53
+ }
54
+
55
+ .brand {
56
+ display: flex;
57
+ align-items: center;
58
+ gap: 12px;
59
+ }
60
+
61
+ .brand-badge {
62
+ padding: 4px 10px;
63
+ border-radius: 999px;
64
+ background: rgba(88, 166, 255, 0.14);
65
+ border: 1px solid rgba(88, 166, 255, 0.35);
66
+ color: var(--accent);
67
+ font-size: 12px;
68
+ font-weight: 700;
69
+ letter-spacing: 0.04em;
70
+ text-transform: uppercase;
71
+ }
72
+
73
+ .brand h1 {
74
+ margin: 0;
75
+ font-size: 22px;
76
+ letter-spacing: -0.02em;
77
+ }
78
+
79
+ .top-actions {
80
+ display: flex;
81
+ flex-wrap: wrap;
82
+ gap: 8px;
83
+ align-items: center;
84
+ }
85
+
86
+ button {
87
+ font: inherit;
88
+ cursor: pointer;
89
+ border-radius: 10px;
90
+ border: 1px solid var(--border);
91
+ background: var(--panel-elev);
92
+ color: var(--text);
93
+ padding: 8px 14px;
94
+ font-size: 13px;
95
+ font-weight: 600;
96
+ transition: all 0.14s ease;
97
+ }
98
+
99
+ button:hover {
100
+ border-color: var(--border-strong);
101
+ background: #202738;
102
+ }
103
+
104
+ button.primary {
105
+ background: var(--accent);
106
+ border-color: var(--accent);
107
+ color: #07101d;
108
+ font-weight: 700;
109
+ }
110
+
111
+ button.primary:hover {
112
+ background: var(--accent-hover);
113
+ border-color: var(--accent-hover);
114
+ }
115
+
116
+ button.sm {
117
+ padding: 5px 11px;
118
+ font-size: 12px;
119
+ border-radius: 8px;
120
+ }
121
+
122
+ /* Sticky Live Workbench */
123
+ .workbench {
124
+ position: sticky;
125
+ top: 10px;
126
+ z-index: 40;
127
+ background: rgba(18, 22, 31, 0.94);
128
+ backdrop-filter: blur(12px);
129
+ border: 1px solid var(--border-strong);
130
+ border-radius: 16px;
131
+ padding: 16px 18px;
132
+ margin-bottom: 20px;
133
+ box-shadow: 0 16px 38px rgba(0, 0, 0, 0.45);
134
+ }
135
+
136
+ .wb-meta {
137
+ display: flex;
138
+ flex-wrap: wrap;
139
+ justify-content: space-between;
140
+ align-items: center;
141
+ gap: 10px;
142
+ margin-bottom: 12px;
143
+ }
144
+
145
+ .wb-pills {
146
+ display: flex;
147
+ flex-wrap: wrap;
148
+ gap: 8px;
149
+ align-items: center;
150
+ font-size: 13px;
151
+ }
152
+
153
+ .pill {
154
+ display: inline-flex;
155
+ align-items: center;
156
+ gap: 6px;
157
+ padding: 4px 10px;
158
+ border-radius: 999px;
159
+ background: #0d1017;
160
+ border: 1px solid var(--border);
161
+ color: var(--muted);
162
+ font-size: 12px;
163
+ }
164
+
165
+ .pill strong { color: var(--text); font-family: var(--mono); }
166
+
167
+ .terminal-screen {
168
+ background: #040507;
169
+ border: 1px solid #222938;
170
+ border-radius: 12px;
171
+ padding: 14px 16px;
172
+ font-family: var(--mono);
173
+ font-size: 13.5px;
174
+ overflow-x: auto;
175
+ }
176
+
177
+ .term-row {
178
+ white-space: nowrap;
179
+ line-height: 1.55;
180
+ }
181
+
182
+ .term-row + .term-row {
183
+ margin-top: 10px;
184
+ }
185
+
186
+ .prompt-strip {
187
+ display: inline-flex;
188
+ align-items: stretch;
189
+ vertical-align: middle;
190
+ }
191
+
192
+ .seg {
193
+ display: inline-flex;
194
+ align-items: center;
195
+ height: 24px;
196
+ padding: 0 9px;
197
+ font-weight: 700;
198
+ line-height: 1;
199
+ }
200
+
201
+ .sep-glyph {
202
+ display: inline-flex;
203
+ align-items: center;
204
+ height: 24px;
205
+ font-size: 19px;
206
+ font-weight: 400;
207
+ line-height: 1;
208
+ }
209
+
210
+ .cmd-text {
211
+ font-weight: 700;
212
+ margin-left: 6px;
213
+ }
214
+
215
+ .newline-connector {
216
+ color: #6b768c;
217
+ user-select: none;
218
+ }
219
+
220
+ /* Navigation Tabs */
221
+ .tabs {
222
+ display: flex;
223
+ flex-wrap: wrap;
224
+ gap: 8px;
225
+ margin-bottom: 18px;
226
+ border-bottom: 1px solid var(--border);
227
+ padding-bottom: 12px;
228
+ }
229
+
230
+ .tab-btn {
231
+ padding: 9px 16px;
232
+ border-radius: 10px;
233
+ font-size: 14px;
234
+ background: transparent;
235
+ color: var(--muted);
236
+ border: 1px solid transparent;
237
+ }
238
+
239
+ .tab-btn.active {
240
+ background: var(--panel-elev);
241
+ color: var(--text);
242
+ border-color: var(--border-strong);
243
+ }
244
+
245
+ .tab-panel { display: none; }
246
+ .tab-panel.active { display: block; }
247
+
248
+ /* Toolbar */
249
+ .toolbar {
250
+ display: flex;
251
+ flex-wrap: wrap;
252
+ gap: 12px 16px;
253
+ align-items: center;
254
+ padding: 14px 16px;
255
+ background: var(--panel);
256
+ border: 1px solid var(--border);
257
+ border-radius: 14px;
258
+ margin-bottom: 16px;
259
+ }
260
+
261
+ input[type="text"], input[type="search"] {
262
+ background: #0b0e14;
263
+ border: 1px solid var(--border);
264
+ border-radius: 10px;
265
+ color: var(--text);
266
+ padding: 8px 12px;
267
+ font: inherit;
268
+ font-size: 13.5px;
269
+ min-width: 250px;
270
+ }
271
+
272
+ input[type="text"]:focus, input[type="search"]:focus {
273
+ outline: none;
274
+ border-color: var(--accent);
275
+ }
276
+
277
+ .toggle-label {
278
+ display: inline-flex;
279
+ align-items: center;
280
+ gap: 7px;
281
+ font-size: 13px;
282
+ color: var(--muted);
283
+ cursor: pointer;
284
+ user-select: none;
285
+ }
286
+
287
+ .badge-bar {
288
+ display: flex;
289
+ flex-wrap: wrap;
290
+ gap: 6px;
291
+ margin-bottom: 16px;
292
+ }
293
+
294
+ .badge-chip {
295
+ padding: 4px 11px;
296
+ border-radius: 999px;
297
+ font-size: 12px;
298
+ background: var(--panel);
299
+ border: 1px solid var(--border);
300
+ color: var(--muted);
301
+ cursor: pointer;
302
+ }
303
+
304
+ .badge-chip.active {
305
+ background: rgba(88, 166, 255, 0.18);
306
+ border-color: var(--accent);
307
+ color: var(--text);
308
+ }
309
+
310
+ /* Theme Grid */
311
+ .theme-grid {
312
+ display: grid;
313
+ grid-template-columns: repeat(auto-fill, minmax(390px, 1fr));
314
+ gap: 16px;
315
+ }
316
+
317
+ .theme-card {
318
+ background: var(--card);
319
+ border: 1px solid var(--border);
320
+ border-radius: 14px;
321
+ overflow: hidden;
322
+ display: flex;
323
+ flex-direction: column;
324
+ transition: border-color 0.15s ease, transform 0.15s ease;
325
+ }
326
+
327
+ .theme-card:hover {
328
+ border-color: var(--border-strong);
329
+ transform: translateY(-1px);
330
+ }
331
+
332
+ .theme-card.is-active {
333
+ border-color: var(--success);
334
+ box-shadow: 0 0 0 1px rgba(63, 185, 80, 0.35);
335
+ }
336
+
337
+ .card-head {
338
+ padding: 14px 16px 10px;
339
+ display: flex;
340
+ justify-content: space-between;
341
+ align-items: flex-start;
342
+ gap: 10px;
343
+ }
344
+
345
+ .card-title {
346
+ font-size: 16px;
347
+ font-weight: 700;
348
+ margin: 0;
349
+ }
350
+
351
+ .card-num {
352
+ color: var(--soft);
353
+ font-family: var(--mono);
354
+ font-size: 12px;
355
+ margin-right: 6px;
356
+ }
357
+
358
+ .card-desc {
359
+ margin: 4px 0 0;
360
+ font-size: 12.5px;
361
+ color: var(--muted);
362
+ }
363
+
364
+ .card-badge {
365
+ padding: 3px 9px;
366
+ border-radius: 999px;
367
+ font-size: 11px;
368
+ font-weight: 700;
369
+ background: #0d1017;
370
+ border: 1px solid var(--border);
371
+ color: var(--muted);
372
+ white-space: nowrap;
373
+ }
374
+
375
+ .card-term {
376
+ background: #040507;
377
+ padding: 12px 14px;
378
+ font-family: var(--mono);
379
+ font-size: 12px;
380
+ overflow-x: auto;
381
+ border-top: 1px solid #1d2331;
382
+ border-bottom: 1px solid #1d2331;
383
+ }
384
+
385
+ .card-foot {
386
+ padding: 10px 14px;
387
+ display: flex;
388
+ justify-content: space-between;
389
+ align-items: center;
390
+ gap: 8px;
391
+ }
392
+
393
+ .swatches {
394
+ display: flex;
395
+ gap: 5px;
396
+ align-items: center;
397
+ }
398
+
399
+ .swatch-dot {
400
+ width: 18px;
401
+ height: 18px;
402
+ border-radius: 5px;
403
+ border: 1px solid rgba(255, 255, 255, 0.16);
404
+ }
405
+
406
+ /* Separators Studio */
407
+ .sep-category {
408
+ margin-bottom: 22px;
409
+ }
410
+
411
+ .sep-category h3 {
412
+ margin: 0 0 10px;
413
+ font-size: 15px;
414
+ color: var(--accent);
415
+ }
416
+
417
+ .sep-grid {
418
+ display: grid;
419
+ grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
420
+ gap: 10px;
421
+ }
422
+
423
+ .sep-card {
424
+ background: var(--card);
425
+ border: 1px solid var(--border);
426
+ border-radius: 12px;
427
+ padding: 11px 13px;
428
+ cursor: pointer;
429
+ transition: border-color 0.14s ease, background 0.14s ease;
430
+ }
431
+
432
+ .sep-card:hover {
433
+ border-color: var(--accent);
434
+ background: var(--card-hover);
435
+ }
436
+
437
+ .sep-top {
438
+ display: flex;
439
+ justify-content: space-between;
440
+ align-items: center;
441
+ margin-bottom: 6px;
442
+ }
443
+
444
+ .sep-glyph-big {
445
+ display: inline-block;
446
+ min-width: 28px;
447
+ font-family: var(--mono);
448
+ font-size: 20px;
449
+ margin-right: 10px;
450
+ vertical-align: middle;
451
+ }
452
+
453
+ .sep-code {
454
+ font-family: var(--mono);
455
+ font-size: 11.5px;
456
+ color: var(--soft);
457
+ }
458
+
459
+ .palette-grid {
460
+ display: grid;
461
+ grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
462
+ gap: 8px;
463
+ }
464
+
465
+ .glyph-btn {
466
+ display: flex;
467
+ align-items: center;
468
+ gap: 8px;
469
+ padding: 8px 10px;
470
+ background: var(--card);
471
+ border: 1px solid var(--border);
472
+ border-radius: 10px;
473
+ text-align: left;
474
+ }
475
+
476
+ .glyph-btn:hover { border-color: var(--accent); }
477
+ .glyph-char { font-family: var(--mono); font-size: 18px; min-width: 22px; text-align: center; }
478
+ .glyph-meta { font-size: 11px; color: var(--muted); line-height: 1.25; }
479
+ .glyph-meta code { color: var(--accent); display: block; font-family: var(--mono); }
480
+
481
+ /* Layout & Patches */
482
+ .settings-grid {
483
+ display: grid;
484
+ grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
485
+ gap: 16px;
486
+ }
487
+
488
+ .panel-box {
489
+ background: var(--panel);
490
+ border: 1px solid var(--border);
491
+ border-radius: 14px;
492
+ padding: 18px;
493
+ }
494
+
495
+ .panel-box h3 {
496
+ margin: 0 0 8px;
497
+ font-size: 16px;
498
+ }
499
+
500
+ .panel-box p {
501
+ margin: 0 0 14px;
502
+ font-size: 13px;
503
+ color: var(--muted);
504
+ }
505
+
506
+ .seg-toggles {
507
+ display: flex;
508
+ flex-wrap: wrap;
509
+ gap: 8px;
510
+ margin-bottom: 14px;
511
+ }
512
+
513
+ .seg-pill {
514
+ padding: 6px 12px;
515
+ border-radius: 8px;
516
+ font-family: var(--mono);
517
+ font-size: 12.5px;
518
+ border: 1px solid var(--border);
519
+ background: #0b0e14;
520
+ color: var(--muted);
521
+ cursor: pointer;
522
+ }
523
+
524
+ .seg-pill.enabled {
525
+ background: rgba(88, 166, 255, 0.16);
526
+ border-color: var(--accent);
527
+ color: var(--text);
528
+ font-weight: 700;
529
+ }
530
+
531
+ .patch-item {
532
+ display: flex;
533
+ justify-content: space-between;
534
+ align-items: center;
535
+ padding: 9px 0;
536
+ border-bottom: 1px solid var(--border);
537
+ font-size: 13px;
538
+ }
539
+
540
+ .patch-item:last-child { border-bottom: none; }
541
+
542
+ .status-ok { color: var(--success); font-weight: 700; font-family: var(--mono); font-size: 12px; }
543
+ .status-warn { color: var(--warn); font-weight: 700; font-family: var(--mono); font-size: 12px; }
544
+
545
+ /* Toast */
546
+ .toast {
547
+ position: fixed;
548
+ right: 22px;
549
+ bottom: 22px;
550
+ padding: 12px 18px;
551
+ border-radius: 12px;
552
+ background: #13261b;
553
+ border: 1px solid var(--success);
554
+ color: #d8ffe2;
555
+ font-size: 13.5px;
556
+ font-weight: 600;
557
+ box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
558
+ opacity: 0;
559
+ transform: translateY(10px);
560
+ pointer-events: none;
561
+ transition: all 0.2s ease;
562
+ z-index: 100;
563
+ }
564
+
565
+ .toast.visible {
566
+ opacity: 1;
567
+ transform: translateY(0);
568
+ }
569
+ </style>
570
+ </head>
571
+ <body>
572
+ <div class="container">
573
+ <header class="topbar">
574
+ <div class="brand">
575
+ <span class="brand-badge" id="version-badge">Studio</span>
576
+ <h1>Synth-Shell Theme Studio</h1>
577
+ </div>
578
+ <div class="top-actions">
579
+ <button id="btn-toggle-theme" title="Toggle between Light and Dark theme pair">☀ / ☾ Light·Dark</button>
580
+ <button id="btn-copy-cli" title="Copy reproducible CLI command for this setup">Share / Copy CLI</button>
581
+ <button id="btn-copy-reload" title="Copy Bash reload command">Copy Reload Cmd</button>
582
+ <button id="btn-undo" title="Restore latest configuration backup">Undo / Restore</button>
583
+ <button class="primary" id="btn-apply-active">Apply Studio Selection</button>
584
+ </div>
585
+ </header>
586
+ <div id="static-demo-banner" style="display:none;margin-bottom:14px;padding:10px 14px;border-radius:12px;background:rgba(88,166,255,0.12);border:1px solid rgba(88,166,255,0.35);font-size:13px;color:var(--text);">
587
+ <strong>Live Browser Demo:</strong> Preview all 64 themes, 48 dual separators, and right-aligned layouts right here — click <strong>Share / Copy CLI</strong> to apply locally after <code>pipx install synth-shell-theme</code>.
588
+ </div>
589
+
590
+ <!-- Sticky Live Prompt Workbench -->
591
+ <section class="workbench" aria-label="Live Prompt Workbench">
592
+ <div class="wb-meta">
593
+ <div class="wb-pills">
594
+ <span class="pill">Theme: <strong id="wb-theme-name">Loading…</strong></span>
595
+ <span class="pill">Internal Sep: <strong id="wb-int-sep"></strong></span>
596
+ <span class="pill">Ending Sep: <strong id="wb-end-sep"></strong></span>
597
+ <span class="pill">Format: <strong id="wb-format">HOST PWD GIT PYENV TF KUBE</strong></span>
598
+ </div>
599
+ <div class="wb-pills">
600
+ <label class="toggle-label">
601
+ <input type="checkbox" id="chk-force-white" />
602
+ High-Contrast White Text
603
+ </label>
604
+ <label class="toggle-label">
605
+ <input type="checkbox" id="chk-keep-input" />
606
+ Keep Current Input Color
607
+ </label>
608
+ </div>
609
+ </div>
610
+ <div class="terminal-screen" id="live-workbench-screen"></div>
611
+ <div id="seg-quick-editor" style="display:none;margin-top:10px;padding:9px 12px;border-radius:10px;background:#0c1018;border:1px solid var(--border);align-items:center;gap:12px;flex-wrap:wrap;font-size:12.5px;">
612
+ <strong>Editing <code id="qe-seg-name">host</code>:</strong>
613
+ <label class="toggle-label"><span>BG</span><input type="color" id="qe-bg" /></label>
614
+ <label class="toggle-label"><span>FG</span><input type="color" id="qe-fg" /></label>
615
+ <button class="sm primary" id="qe-save-custom">Save as Custom Theme</button>
616
+ <button class="sm" id="qe-close">Close</button>
617
+ </div>
618
+ </section>
619
+
620
+ <!-- Tabs -->
621
+ <nav class="tabs" role="tablist">
622
+ <button class="tab-btn active" data-tab="themes">64 Color Themes</button>
623
+ <button class="tab-btn" data-tab="separators">Dual Separators &amp; 60+ Nerd Font Glyphs</button>
624
+ <button class="tab-btn" data-tab="layout">Layout, Segments &amp; Runtime Optimizer</button>
625
+ <button class="tab-btn" data-tab="sync">Root, Greeter &amp; Diagnostics</button>
626
+ </nav>
627
+
628
+ <!-- TAB 1: 64 Themes -->
629
+ <section class="tab-panel active" id="tab-themes">
630
+ <div class="toolbar">
631
+ <input type="search" id="theme-search" placeholder="Search themes by name, slug, or style…" />
632
+ <span id="theme-count-label" style="font-size:13px;color:var(--muted);">64 themes</span>
633
+ <button id="btn-toggle-creator" style="margin-left:auto;">+ Create Custom TrueColor Theme</button>
634
+ </div>
635
+ <div class="panel-box" id="custom-theme-creator" style="display:none;margin-bottom:16px;">
636
+ <h3>Custom Theme Creator (24-bit TrueColor <code>#RRGGBB</code> + 256-color fallback)</h3>
637
+ <p>Pick exact hex colors for each segment and save to <code>~/.config/synth-shell/themes/</code>.</p>
638
+ <div style="display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin-bottom:12px;">
639
+ <input type="text" id="ct-name" placeholder="Theme Name (e.g. My Midnight)" style="min-width:220px;" />
640
+ <input type="text" id="ct-desc" placeholder="Short description…" style="min-width:260px;" />
641
+ </div>
642
+ <div style="display:flex;flex-wrap:wrap;gap:12px;margin-bottom:14px;">
643
+ <label class="toggle-label"><span>Host BG</span><input type="color" id="ct-bg-host" value="#3b4261" /></label>
644
+ <label class="toggle-label"><span>PWD BG</span><input type="color" id="ct-bg-pwd" value="#7aa2f7" /></label>
645
+ <label class="toggle-label"><span>Git BG</span><input type="color" id="ct-bg-git" value="#9ece6a" /></label>
646
+ <label class="toggle-label"><span>Pyenv BG</span><input type="color" id="ct-bg-pyenv" value="#bb9af7" /></label>
647
+ <label class="toggle-label"><span>TF BG</span><input type="color" id="ct-bg-tf" value="#e0af68" /></label>
648
+ <label class="toggle-label"><span>Kube BG</span><input type="color" id="ct-bg-kube" value="#7dcfff" /></label>
649
+ <label class="toggle-label"><span>Input FG</span><input type="color" id="ct-fg-input" value="#7aa2f7" /></label>
650
+ </div>
651
+ <button class="primary" id="btn-save-custom-theme">Save &amp; Apply Custom Theme</button>
652
+ </div>
653
+ <div class="badge-bar" id="badge-filter-bar"></div>
654
+ <div class="theme-grid" id="theme-grid"></div>
655
+ </section>
656
+
657
+ <!-- TAB 2: Dual Separators -->
658
+ <section class="tab-panel" id="tab-separators">
659
+ <div class="toolbar">
660
+ <strong style="font-size:13.5px;">Click Target:</strong>
661
+ <label class="toggle-label"><input type="radio" name="sep-target" value="both" checked /> Both (Internal + Ending)</label>
662
+ <label class="toggle-label"><input type="radio" name="sep-target" value="internal" /> Internal Separator Only</label>
663
+ <label class="toggle-label"><input type="radio" name="sep-target" value="end" /> Ending Separator Only</label>
664
+ <div style="margin-left:auto;display:flex;gap:8px;align-items:center;">
665
+ <input type="text" id="custom-sep-input" placeholder="Custom hex (E0B4, F0E7) or glyph…" style="min-width:220px;" />
666
+ <button id="btn-apply-custom-sep">Use Custom</button>
667
+ </div>
668
+ </div>
669
+ <div id="sep-categories-root"></div>
670
+ <div class="panel-box" style="margin-top:20px;">
671
+ <h3>60+ Nerd Font &amp; Unicode Character Matrix</h3>
672
+ <p>Click any glyph below to assign it to your selected separator target and preview immediately.</p>
673
+ <div id="palette-matrix-root"></div>
674
+ </div>
675
+ </section>
676
+
677
+ <!-- TAB 3: Layout & Runtime Patches -->
678
+ <section class="tab-panel" id="tab-layout">
679
+ <div class="settings-grid">
680
+ <div class="panel-box">
681
+ <h3>Active Prompt Segments &amp; Layout</h3>
682
+ <p>Click pills to toggle, or <strong>drag &amp; drop</strong> active pills to reorder Left &amp; Right bars. Click any segment in the Live Workbench above to tweak its color.</p>
683
+ <div style="font-size:12px;color:var(--muted);margin-bottom:6px;">Left Bar (<code>format</code>) — drag active pills to reorder:</div>
684
+ <div class="seg-toggles" id="segment-toggles"></div>
685
+ <div style="font-size:12px;color:var(--muted);margin:10px 0 6px;">Right Bar (<code>right_format</code>, 2-line top bar) — drag active pills to reorder:</div>
686
+ <div class="seg-toggles" id="right-segment-toggles"></div>
687
+ <div style="display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin:8px 0 12px;">
688
+ <label class="toggle-label">
689
+ <span>Fill Char:</span>
690
+ <input type="text" id="inp-right-fill" value="─" maxlength="1" style="min-width:46px;width:46px;padding:4px 8px;text-align:center;" />
691
+ </label>
692
+ <label class="toggle-label">
693
+ <input type="checkbox" id="chk-osc133" checked />
694
+ <span>OSC 133 semantic markers (Ghostty/Kitty/WT/VS Code)</span>
695
+ </label>
696
+ <label class="toggle-label">
697
+ <input type="checkbox" id="chk-osc7" checked />
698
+ <span>OSC 7 CWD reporting (new tabs/splits inherit folder)</span>
699
+ </label>
700
+ <label class="toggle-label">
701
+ <input type="checkbox" id="chk-term-sanitize" checked />
702
+ <span>Auto-sanitize leaked SSH/TUI mouse tracking (<code>?1000l/?1003l/?1006l</code>)</span>
703
+ </label>
704
+ <label class="toggle-label">
705
+ <input type="checkbox" id="chk-kube-ns" checked />
706
+ <span>Kube namespace + 🚨 red prod warning</span>
707
+ </label>
708
+ <label class="toggle-label">
709
+ <input type="checkbox" id="chk-git-dyn" />
710
+ <span>Dynamic Git colors (amber dirty / red rebase)</span>
711
+ </label>
712
+ <label class="toggle-label">
713
+ <input type="checkbox" id="chk-ssh-host-color" />
714
+ <span>SSH hostname auto-color</span>
715
+ </label>
716
+ <label class="toggle-label">
717
+ <span>PWD style:</span>
718
+ <select id="sel-pwd-style" style="background:#0b0e14;border:1px solid var(--border);border-radius:8px;color:var(--text);padding:4px 8px;font-size:12px;">
719
+ <option value="default">default</option>
720
+ <option value="fish">fish (~/p/repo)</option>
721
+ </select>
722
+ </label>
723
+ <label class="toggle-label">
724
+ <span>Notify &gt; (s):</span>
725
+ <input type="text" id="inp-notify-sec" value="0" style="min-width:52px;width:52px;padding:4px 8px;font-size:12px;" title="Desktop OSC 9/99 notification for slow commands (0=off)" />
726
+ </label>
727
+ <label class="toggle-label">
728
+ <span>Custom badge:</span>
729
+ <input type="text" id="inp-custom-badge" placeholder="e.g. EU-WEST" style="min-width:96px;width:96px;padding:4px 8px;font-size:12px;" />
730
+ </label>
731
+ <label class="toggle-label">
732
+ <input type="checkbox" id="chk-git-state" checked />
733
+ <span>Git rebase/merge/worktree state</span>
734
+ </label>
735
+ </div>
736
+ <div style="display:flex;flex-direction:column;gap:10px;margin:14px 0;">
737
+ <label class="toggle-label">
738
+ <input type="checkbox" id="chk-two-line" checked />
739
+ <span>Command on new line (<code>enable_command_on_new_line="true"</code>)</span>
740
+ </label>
741
+ <label class="toggle-label">
742
+ <input type="checkbox" id="chk-vert-pad" checked />
743
+ <span>Enable vertical padding between commands (<code>enable_vertical_padding="true"</code>)</span>
744
+ </label>
745
+ <label class="toggle-label">
746
+ <input type="checkbox" id="chk-term-title" checked />
747
+ <span>Restore terminal tab title (<code>enable_terminal_title="true"</code>)</span>
748
+ </label>
749
+ <div style="display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin-top:4px;">
750
+ <label class="toggle-label">
751
+ <span>Prefix:</span>
752
+ <input type="text" id="inp-prefix" placeholder='e.g. "❯ " or "auto"' style="min-width:130px;padding:5px 9px;font-size:12.5px;" />
753
+ </label>
754
+ <label class="toggle-label">
755
+ <span>Text Effect:</span>
756
+ <select id="sel-font-effect" style="background:#0b0e14;border:1px solid var(--border);border-radius:8px;color:var(--text);padding:5px 9px;font-size:12.5px;">
757
+ <option value="bold">bold</option>
758
+ <option value="regular">regular</option>
759
+ <option value="italic">italic</option>
760
+ <option value="dim">dim</option>
761
+ </select>
762
+ </label>
763
+ </div>
764
+ <label class="toggle-label">
765
+ <span>Max PWD (<code id="lbl-max-pwd">35</code>):</span>
766
+ <input type="range" id="rng-max-pwd" min="15" max="80" value="35" style="width:150px;" />
767
+ </label>
768
+ <label class="toggle-label">
769
+ <span>Max Git branch (<code id="lbl-max-git">0</code>, 0=off):</span>
770
+ <input type="range" id="rng-max-git" min="0" max="60" value="0" style="width:150px;" />
771
+ </label>
772
+ <label class="toggle-label">
773
+ <span>Max Pyenv (<code id="lbl-max-pyenv">0</code>, 0=off):</span>
774
+ <input type="range" id="rng-max-pyenv" min="0" max="50" value="0" style="width:150px;" />
775
+ </label>
776
+ <label class="toggle-label">
777
+ <span>Max Kube (<code id="lbl-max-kube">28</code>):</span>
778
+ <input type="range" id="rng-max-kube" min="10" max="60" value="28" style="width:150px;" />
779
+ </label>
780
+ <label class="toggle-label">
781
+ <span>Compact split width (<code id="lbl-compact-width">90</code> cols, 0=off):</span>
782
+ <input type="range" id="rng-compact-width" min="0" max="150" value="90" style="width:150px;" />
783
+ </label>
784
+ <label class="toggle-label">
785
+ <input type="checkbox" id="chk-git-counts" checked />
786
+ <span>Show exact Git ahead/behind counts (<code>↑2 ↓1</code>)</span>
787
+ </label>
788
+ <label class="toggle-label">
789
+ <input type="checkbox" id="chk-transient" />
790
+ <span>Enable <code>ble.sh</code> transient prompt when loaded</span>
791
+ </label>
792
+ </div>
793
+ <div style="display:flex;gap:8px;flex-wrap:wrap;">
794
+ <button class="primary" id="btn-save-layout">Save Layout Settings</button>
795
+ <button id="btn-ascii-safe" title="Switch to ASCII-safe separators & Git symbols">ASCII-Safe Mode</button>
796
+ </div>
797
+ </div>
798
+
799
+ <div class="panel-box">
800
+ <h3>Speed, Git &amp; Runtime Patches (v1.1)</h3>
801
+ <p>Idempotent zero-fork optimizations &amp; WSL2/monorepo Git guards for <code>synth-shell-prompt.sh</code>.</p>
802
+ <div style="display:flex;flex-direction:column;gap:9px;margin-bottom:14px;">
803
+ <label class="toggle-label">
804
+ <input type="checkbox" id="chk-wsl-fast" checked />
805
+ <span>Skip untracked Git files on WSL <code>/mnt/*</code></span>
806
+ </label>
807
+ <label class="toggle-label">
808
+ <input type="checkbox" id="chk-async-git" />
809
+ <span>Enable async background Git cache (<code>/dev/shm</code>)</span>
810
+ </label>
811
+ <div style="display:flex;flex-wrap:wrap;gap:10px;align-items:center;">
812
+ <label class="toggle-label">
813
+ <span>Git timeout (ms):</span>
814
+ <input type="text" id="inp-git-timeout" value="0" style="min-width:74px;width:74px;padding:4px 8px;font-size:12.5px;" />
815
+ </label>
816
+ <label class="toggle-label">
817
+ <span>Min duration (ms):</span>
818
+ <input type="text" id="inp-min-duration" value="2000" style="min-width:74px;width:74px;padding:4px 8px;font-size:12.5px;" />
819
+ </label>
820
+ </div>
821
+ </div>
822
+ <div id="patches-list"></div>
823
+ <div style="margin-top:14px;">
824
+ <button class="primary" id="btn-run-patches">Apply All v1.1 Runtime Patches</button>
825
+ </div>
826
+ </div>
827
+
828
+ <div class="panel-box">
829
+ <h3>Timestamped Backups</h3>
830
+ <p>Every change backs up <code>synth-shell-prompt.config</code> automatically. Restore any snapshot in 1 click.</p>
831
+ <div id="backups-list" style="max-height:360px;overflow-y:auto;"></div>
832
+ </div>
833
+ </div>
834
+ </section>
835
+
836
+ <!-- TAB 4: Root, Greeter & Diagnostics -->
837
+ <section class="tab-panel" id="tab-sync">
838
+ <div class="settings-grid">
839
+ <div class="panel-box">
840
+ <h3>Root Prompt &amp; Ecosystem Color Sync</h3>
841
+ <p>Sync your active theme to <code>synth-shell-prompt.root.config</code>, plus generate <code>theme-env.sh</code> (<code>FZF_DEFAULT_OPTS</code> + <code>LS_COLORS</code>), <code>tmux-theme.conf</code>, <code>wezterm-theme.lua</code> &amp; <code>starship.toml</code>.</p>
842
+ <div id="root-sync-status" style="font-size:13px;color:var(--muted);margin-bottom:14px;"></div>
843
+ <div style="display:flex;gap:8px;flex-wrap:wrap;">
844
+ <button class="primary" id="btn-sync-root">Sync Active Theme to Root Config</button>
845
+ <button id="btn-sync-ecosystem">Sync Ecosystem (fzf + LS_COLORS + tmux + WezTerm)</button>
846
+ <button id="btn-export-starship">Export starship.toml</button>
847
+ <button id="btn-auto-theme">Match OS Light/Dark</button>
848
+ </div>
849
+ </div>
850
+
851
+ <div class="panel-box">
852
+ <h3>Synth-Shell Greeter Sync &amp; Monitors</h3>
853
+ <p>Match <code>synth-shell-greeter.config</code> colors to your theme and choose which system monitors appear on login.</p>
854
+ <div class="seg-toggles" id="greeter-monitor-toggles"></div>
855
+ <div style="display:flex;gap:8px;flex-wrap:wrap;margin-top:12px;">
856
+ <button class="primary" id="btn-sync-greeter">Sync Palette &amp; Save Monitors</button>
857
+ <button id="btn-greeter-hide-swap">Auto-Hide Swap (Cloud VM)</button>
858
+ </div>
859
+ </div>
860
+
861
+ <div class="panel-box">
862
+ <h3>Environment, Terminal &amp; Live Benchmark</h3>
863
+ <p>UTF-8 locale, 24-bit TrueColor, Nerd Font readiness, and live Bash prompt latency.</p>
864
+ <div id="diagnostics-list"></div>
865
+ <div style="margin-top:14px;display:flex;gap:10px;align-items:center;flex-wrap:wrap;">
866
+ <button class="primary" id="btn-run-bench">Run Live Prompt Benchmark</button>
867
+ <span id="bench-result" style="font-family:var(--mono);font-size:12px;color:var(--muted);"></span>
868
+ </div>
869
+ </div>
870
+ </div>
871
+ </section>
872
+ </div>
873
+
874
+ <div class="toast" id="toast"></div>
875
+
876
+ <script>
877
+ const state = {
878
+ themes: [],
879
+ separators: { categories: [], palette: [] },
880
+ validSegments: [],
881
+ selectedThemeId: 1,
882
+ activeThemeId: null,
883
+ internalSep: { glyph: "\uE0B4", code: "\\uE0B4" },
884
+ endSep: { glyph: "\uE0B0", code: "\\uE0B0" },
885
+ formatSegments: ["HOST", "PWD", "GIT", "PYENV", "TF", "KUBE"],
886
+ rightSegments: [],
887
+ rightFillChar: "─",
888
+ enableOsc133: true,
889
+ enableOsc7: true,
890
+ enableTerminalSanitize: true,
891
+ kubeShowNamespace: true,
892
+ kubeProdWarning: true,
893
+ gitDynamicColor: false,
894
+ sshHostColor: false,
895
+ pwdStyle: "default",
896
+ notifyDurationSec: 0,
897
+ customSegmentText: "",
898
+ gitShowState: true,
899
+ batteryThreshold: 100,
900
+ staticDemo: false,
901
+ editingSegKey: null,
902
+ twoLine: true,
903
+ verticalPadding: true,
904
+ maxPwdChar: 35,
905
+ maxGitChar: 0,
906
+ maxPyenvChar: 0,
907
+ maxKubeChar: 28,
908
+ compactWidth: 90,
909
+ gitShowCounts: true,
910
+ transientPrompt: false,
911
+ promptPrefix: "",
912
+ fontEffect: "bold",
913
+ enableTerminalTitle: true,
914
+ gitSkipUntracked: true,
915
+ gitTimeoutMs: 0,
916
+ gitAsyncCache: false,
917
+ minDurationMs: 2000,
918
+ forceWhite: false,
919
+ keepInput: false,
920
+ searchQuery: "",
921
+ badgeFilter: "All",
922
+ patches: {},
923
+ greeter: { monitors: [], available_monitors: [] },
924
+ diagnostics: {},
925
+ rootConfigExists: false,
926
+ backups: []
927
+ };
928
+
929
+ const SAMPLE_VALUES = {
930
+ user: "alex",
931
+ host: "dev-box",
932
+ pwd: "~/workspace/service",
933
+ git: "main ◔",
934
+ pyenv: ".venv",
935
+ tf: "prod",
936
+ kube: "☸ gke-prod",
937
+ clock: "14:32",
938
+ status: "✗ 1",
939
+ duration: "⏱ 3.4s",
940
+ aws: "☁ prod",
941
+ gcp: "GCP:my-proj",
942
+ docker: "🐳 prod",
943
+ node: "⬢ v22.11",
944
+ ssh: "⇄ ssh",
945
+ jobs: "⚙ 1",
946
+ direnv: "⚡ app",
947
+ shlvl: "↳ L2",
948
+ rust: "🦀 1.82",
949
+ go: "🐹 1.23",
950
+ battery: "🔋 86%",
951
+ sudo: "🔓 sudo",
952
+ jj: "🥋 kqyx main",
953
+ custom: "★ EU-WEST"
954
+ };
955
+
956
+ function escapeHtml(str) {
957
+ return String(str)
958
+ .replace(/&/g, "&amp;")
959
+ .replace(/</g, "&lt;")
960
+ .replace(/>/g, "&gt;")
961
+ .replace(/"/g, "&quot;");
962
+ }
963
+
964
+ function showToast(msg) {
965
+ const el = document.getElementById("toast");
966
+ el.textContent = msg;
967
+ el.classList.add("visible");
968
+ clearTimeout(showToast._timer);
969
+ showToast._timer = setTimeout(() => el.classList.remove("visible"), 2800);
970
+ }
971
+
972
+ function getSelectedTheme() {
973
+ return state.themes.find(t => t.id === state.selectedThemeId) || state.themes[0];
974
+ }
975
+
976
+ function renderPromptHtml(theme, segPairs, cmdText, rightPairs = []) {
977
+ if (!theme) return "";
978
+ const intGlyph = escapeHtml(state.internalSep.glyph || "\uE0B4");
979
+ const endGlyph = escapeHtml(state.endSep.glyph || intGlyph);
980
+ let html = "";
981
+
982
+ if (state.twoLine) {
983
+ html += `<span class="newline-connector">┌─</span>`;
984
+ }
985
+ if (state.promptPrefix) {
986
+ const pref = state.promptPrefix === "auto" ? " " : state.promptPrefix;
987
+ html += `<span style="margin-right:4px;color:var(--accent);">${escapeHtml(pref)}</span>`;
988
+ }
989
+
990
+ const effStyle = state.fontEffect === "italic"
991
+ ? "font-weight:400;font-style:italic;"
992
+ : (state.fontEffect === "regular" || state.fontEffect === "none")
993
+ ? "font-weight:400;"
994
+ : state.fontEffect === "dim"
995
+ ? "font-weight:400;opacity:0.78;"
996
+ : "font-weight:700;";
997
+
998
+ const buildStrip = (pairs) => {
999
+ let s = `<span class="prompt-strip">`;
1000
+ pairs.forEach(([segKey, label], idx) => {
1001
+ const segColor = theme.segments[segKey] || { fg: "#ffffff", bg: "#333333" };
1002
+ const fg = state.forceWhite ? "#ffffff" : (segColor.fg || "#ffffff");
1003
+ const bg = segColor.bg || "#222222";
1004
+ s += `<span class="seg" data-segkey="${escapeHtml(segKey)}" title="Click to edit ${escapeHtml(segKey)} colors" style="cursor:pointer;background:${bg};color:${fg};${effStyle}">${escapeHtml(label)}</span>`;
1005
+ if (idx + 1 < pairs.length) {
1006
+ const nextKey = pairs[idx + 1][0];
1007
+ const nextBg = (theme.segments[nextKey] && theme.segments[nextKey].bg) || "#222222";
1008
+ s += `<span class="sep-glyph" style="background:${nextBg};color:${bg};">${intGlyph}</span>`;
1009
+ } else {
1010
+ s += `<span class="sep-glyph" style="background:transparent;color:${bg};">${endGlyph}</span>`;
1011
+ }
1012
+ });
1013
+ s += `</span>`;
1014
+ return s;
1015
+ };
1016
+
1017
+ if (state.twoLine && rightPairs.length) {
1018
+ const fch = escapeHtml(state.rightFillChar || "─");
1019
+ html = `<div style="display:flex;align-items:center;gap:6px;">`
1020
+ + `<span>${html}${buildStrip(segPairs)}</span>`
1021
+ + `<span style="flex:1;overflow:hidden;color:#3a455e;letter-spacing:0;user-select:none;">${fch.repeat(80)}</span>`
1022
+ + `<span>${buildStrip(rightPairs)}</span>`
1023
+ + `</div>`;
1024
+ } else {
1025
+ html += buildStrip(segPairs);
1026
+ }
1027
+
1028
+ const inputFg = (theme.segments.input && theme.segments.input.fg) || "#ffffff";
1029
+ if (state.twoLine) {
1030
+ html += `${rightPairs.length ? "" : "<br/>"}<span class="newline-connector">└─</span> <span style="color:${inputFg};font-weight:700;">$ ${escapeHtml(cmdText)}</span>`;
1031
+ } else {
1032
+ html += `<span class="cmd-text" style="color:${inputFg};">${escapeHtml(cmdText)}</span>`;
1033
+ }
1034
+ return html;
1035
+ }
1036
+
1037
+ function renderWorkbench() {
1038
+ const theme = getSelectedTheme();
1039
+ if (!theme) return;
1040
+ document.getElementById("wb-theme-name").textContent = `#${String(theme.id).padStart(2, "0")} ${theme.name}`;
1041
+ document.getElementById("wb-int-sep").textContent = `${state.internalSep.glyph} (${state.internalSep.code})`;
1042
+ document.getElementById("wb-end-sep").textContent = `${state.endSep.glyph} (${state.endSep.code})`;
1043
+ document.getElementById("wb-format").textContent = state.formatSegments.join(" ")
1044
+ + (state.rightSegments.length ? ` │ R: ${state.rightSegments.join(" ")}` : "");
1045
+
1046
+ const shortPairs = [["host", "dev-box"], ["pwd", "~/workspace/app"], ["git", "main ↑2"]];
1047
+ const activePairs = state.formatSegments.map(tok => {
1048
+ const k = tok.toLowerCase();
1049
+ return [k, SAMPLE_VALUES[k] || tok];
1050
+ });
1051
+ const rightPairs = state.rightSegments.map(tok => {
1052
+ const k = tok.toLowerCase();
1053
+ return [k, SAMPLE_VALUES[k] || tok];
1054
+ });
1055
+
1056
+ const screen = document.getElementById("live-workbench-screen");
1057
+ screen.innerHTML = `
1058
+ <div class="term-row">${renderPromptHtml(theme, shortPairs, "git status")}</div>
1059
+ <div class="term-row">${renderPromptHtml(theme, activePairs, "kubectl get pods -n prod", rightPairs)}</div>
1060
+ `;
1061
+ screen.querySelectorAll(".seg[data-segkey]").forEach(el => {
1062
+ el.addEventListener("click", () => openQuickSegEditor(el.dataset.segkey));
1063
+ });
1064
+ }
1065
+
1066
+ function openQuickSegEditor(segKey) {
1067
+ const theme = getSelectedTheme();
1068
+ if (!theme || !theme.segments[segKey]) return;
1069
+ state.editingSegKey = segKey;
1070
+ document.getElementById("qe-seg-name").textContent = segKey;
1071
+ document.getElementById("qe-bg").value = theme.segments[segKey].bg || "#3b4261";
1072
+ document.getElementById("qe-fg").value = theme.segments[segKey].fg || "#ffffff";
1073
+ document.getElementById("seg-quick-editor").style.display = "flex";
1074
+ }
1075
+
1076
+ function buildCliShareCommand() {
1077
+ const theme = getSelectedTheme();
1078
+ const parts = ["synth-shell-theme"];
1079
+ if (theme && theme.slug) parts.push(`--apply ${theme.slug}`);
1080
+ if (state.internalSep && state.endSep) {
1081
+ parts.push(`--dual ${state.internalSep.key || state.internalSep.code} ${state.endSep.key || state.endSep.code}`);
1082
+ }
1083
+ if (state.formatSegments.length) parts.push(`--format "${state.formatSegments.join(" ")}"`);
1084
+ if (state.rightSegments.length) parts.push(`--right-format "${state.rightSegments.join(" ")}"`);
1085
+ parts.push(state.twoLine ? "--two-line" : "--single-line");
1086
+ if (state.promptPrefix) parts.push(`--prefix "${state.promptPrefix}"`);
1087
+ if (state.fontEffect && state.fontEffect !== "bold") parts.push(`--text-effect ${state.fontEffect}`);
1088
+ if (state.forceWhite) parts.push("--force-white-text");
1089
+ return parts.join(" ");
1090
+ }
1091
+
1092
+ function renderBadges() {
1093
+ const badges = ["All", ...new Set(state.themes.map(t => t.badge).filter(Boolean))];
1094
+ const bar = document.getElementById("badge-filter-bar");
1095
+ bar.innerHTML = badges.map(b => `
1096
+ <button class="badge-chip ${state.badgeFilter === b ? "active" : ""}" data-badge="${escapeHtml(b)}">${escapeHtml(b)}</button>
1097
+ `).join("");
1098
+ bar.querySelectorAll(".badge-chip").forEach(btn => {
1099
+ btn.addEventListener("click", () => {
1100
+ state.badgeFilter = btn.dataset.badge;
1101
+ renderBadges();
1102
+ renderThemeGrid();
1103
+ });
1104
+ });
1105
+ }
1106
+
1107
+ function renderThemeGrid() {
1108
+ const q = state.searchQuery.trim().toLowerCase();
1109
+ const filtered = state.themes.filter(t => {
1110
+ if (state.badgeFilter !== "All" && t.badge !== state.badgeFilter) return false;
1111
+ if (!q) return true;
1112
+ const hay = `${t.id} ${t.name} ${t.slug} ${t.badge} ${t.description}`.toLowerCase();
1113
+ return hay.includes(q);
1114
+ });
1115
+
1116
+ document.getElementById("theme-count-label").textContent = `${filtered.length} of ${state.themes.length} themes`;
1117
+ const grid = document.getElementById("theme-grid");
1118
+
1119
+ grid.innerHTML = filtered.map(t => {
1120
+ const isActive = t.id === state.activeThemeId;
1121
+ const swatches = (t.swatch || []).map(c => `<span class="swatch-dot" style="background:${c};"></span>`).join("");
1122
+ const line1 = renderPromptHtml(t, [["host", "dev"], ["pwd", "~/app"], ["git", "main"]], "git status");
1123
+ return `
1124
+ <article class="theme-card ${isActive ? "is-active" : ""}" data-id="${t.id}">
1125
+ <div class="card-head">
1126
+ <div>
1127
+ <h2 class="card-title"><span class="card-num">#${String(t.id).padStart(2, "0")}</span>${escapeHtml(t.name)}</h2>
1128
+ <p class="card-desc">${escapeHtml(t.description)}</p>
1129
+ </div>
1130
+ <span class="card-badge">${isActive ? "✓ Active" : escapeHtml(t.badge)}</span>
1131
+ </div>
1132
+ <div class="card-term"><div class="term-row">${line1}</div></div>
1133
+ <div class="card-foot">
1134
+ <div class="swatches">${swatches}</div>
1135
+ <div style="display:flex;gap:6px;">
1136
+ <button class="sm btn-preview" data-id="${t.id}">Preview</button>
1137
+ <button class="sm primary btn-apply" data-id="${t.id}">Apply Theme</button>
1138
+ </div>
1139
+ </div>
1140
+ </article>
1141
+ `;
1142
+ }).join("");
1143
+
1144
+ grid.querySelectorAll(".btn-preview").forEach(btn => {
1145
+ btn.addEventListener("click", () => {
1146
+ state.selectedThemeId = Number(btn.dataset.id);
1147
+ renderWorkbench();
1148
+ });
1149
+ });
1150
+
1151
+ grid.querySelectorAll(".btn-apply").forEach(btn => {
1152
+ btn.addEventListener("click", async () => {
1153
+ const id = Number(btn.dataset.id);
1154
+ state.selectedThemeId = id;
1155
+ await applyChanges({
1156
+ theme: id,
1157
+ force_white: state.forceWhite,
1158
+ keep_input: state.keepInput
1159
+ });
1160
+ });
1161
+ });
1162
+ }
1163
+
1164
+ function assignSeparator(glyph, code) {
1165
+ const target = document.querySelector('input[name="sep-target"]:checked').value;
1166
+ if (target === "both" || target === "internal") {
1167
+ state.internalSep = { glyph, code };
1168
+ }
1169
+ if (target === "both" || target === "end") {
1170
+ state.endSep = { glyph, code };
1171
+ }
1172
+ renderWorkbench();
1173
+ renderThemeGrid();
1174
+ }
1175
+
1176
+ function renderSeparatorsTab() {
1177
+ const root = document.getElementById("sep-categories-root");
1178
+ const theme = getSelectedTheme();
1179
+ root.innerHTML = state.separators.categories.map(cat => `
1180
+ <div class="sep-category">
1181
+ <h3>${escapeHtml(cat.name)}</h3>
1182
+ <div class="sep-grid">
1183
+ ${cat.items.map(item => `
1184
+ <div class="sep-card" data-glyph="${escapeHtml(item.glyph)}" data-code="${escapeHtml(item.code)}">
1185
+ <div class="sep-top">
1186
+ <div><span class="sep-glyph-big">${escapeHtml(item.glyph)}</span><strong>${escapeHtml(item.key)}</strong></div>
1187
+ <span class="sep-code">${escapeHtml(item.code)}</span>
1188
+ </div>
1189
+ <div style="font-size:12px;color:var(--muted);">${escapeHtml(item.description)}</div>
1190
+ </div>
1191
+ `).join("")}
1192
+ </div>
1193
+ </div>
1194
+ `).join("");
1195
+
1196
+ root.querySelectorAll(".sep-card").forEach(card => {
1197
+ card.addEventListener("click", async () => {
1198
+ assignSeparator(card.dataset.glyph, card.dataset.code);
1199
+ await applyChanges({
1200
+ internal_separator: state.internalSep.code,
1201
+ end_separator: state.endSep.code
1202
+ });
1203
+ });
1204
+ });
1205
+
1206
+ const matrixRoot = document.getElementById("palette-matrix-root");
1207
+ matrixRoot.innerHTML = state.separators.palette.map(grp => `
1208
+ <div style="margin-bottom:14px;">
1209
+ <div style="font-size:12.5px;font-weight:700;color:var(--muted);margin-bottom:6px;">${escapeHtml(grp.group)}</div>
1210
+ <div class="palette-grid">
1211
+ ${grp.items.map(ch => `
1212
+ <button class="glyph-btn" data-glyph="${escapeHtml(ch.glyph)}" data-code="${escapeHtml(ch.code)}">
1213
+ <span class="glyph-char">${escapeHtml(ch.glyph)}</span>
1214
+ <span class="glyph-meta"><code>${escapeHtml(ch.code)}</code>${escapeHtml(ch.label)}</span>
1215
+ </button>
1216
+ `).join("")}
1217
+ </div>
1218
+ </div>
1219
+ `).join("");
1220
+
1221
+ matrixRoot.querySelectorAll(".glyph-btn").forEach(btn => {
1222
+ btn.addEventListener("click", async () => {
1223
+ assignSeparator(btn.dataset.glyph, btn.dataset.code);
1224
+ await applyChanges({
1225
+ internal_separator: state.internalSep.code,
1226
+ end_separator: state.endSep.code
1227
+ });
1228
+ });
1229
+ });
1230
+ }
1231
+
1232
+ function _renderDraggablePills(containerId, listKey, allowEmpty) {
1233
+ const root = document.getElementById(containerId);
1234
+ const activeList = state[listKey];
1235
+ const inactive = state.validSegments.filter(s => !activeList.includes(s));
1236
+ const ordered = [...activeList, ...inactive];
1237
+ root.innerHTML = ordered.map(seg => {
1238
+ const on = activeList.includes(seg);
1239
+ return `<button class="seg-pill ${on ? "enabled" : ""}" data-seg="${seg}" draggable="${on ? "true" : "false"}">${on ? "⋮⋮ " : ""}${seg}</button>`;
1240
+ }).join("");
1241
+
1242
+ let dragSeg = null;
1243
+ root.querySelectorAll(".seg-pill").forEach(btn => {
1244
+ const seg = btn.dataset.seg;
1245
+ btn.addEventListener("click", () => {
1246
+ if (state[listKey].includes(seg)) {
1247
+ if (allowEmpty || state[listKey].length > 1) {
1248
+ state[listKey] = state[listKey].filter(x => x !== seg);
1249
+ }
1250
+ } else {
1251
+ state[listKey].push(seg);
1252
+ }
1253
+ renderLayoutTab();
1254
+ renderWorkbench();
1255
+ });
1256
+ btn.addEventListener("dragstart", () => { dragSeg = seg; });
1257
+ btn.addEventListener("dragover", e => { if (dragSeg && state[listKey].includes(seg)) e.preventDefault(); });
1258
+ btn.addEventListener("drop", e => {
1259
+ e.preventDefault();
1260
+ if (!dragSeg || dragSeg === seg || !state[listKey].includes(seg)) return;
1261
+ const arr = state[listKey].filter(x => x !== dragSeg);
1262
+ const idx = arr.indexOf(seg);
1263
+ arr.splice(idx, 0, dragSeg);
1264
+ state[listKey] = arr;
1265
+ renderLayoutTab();
1266
+ renderWorkbench();
1267
+ });
1268
+ });
1269
+ }
1270
+
1271
+ function renderLayoutTab() {
1272
+ _renderDraggablePills("segment-toggles", "formatSegments", false);
1273
+ _renderDraggablePills("right-segment-toggles", "rightSegments", true);
1274
+ document.getElementById("inp-right-fill").value = state.rightFillChar || "─";
1275
+ document.getElementById("chk-osc133").checked = state.enableOsc133;
1276
+ document.getElementById("chk-osc7").checked = state.enableOsc7;
1277
+ document.getElementById("chk-term-sanitize").checked = state.enableTerminalSanitize;
1278
+ document.getElementById("chk-kube-ns").checked = state.kubeShowNamespace && state.kubeProdWarning;
1279
+ document.getElementById("chk-git-dyn").checked = state.gitDynamicColor;
1280
+ document.getElementById("chk-ssh-host-color").checked = state.sshHostColor;
1281
+ document.getElementById("sel-pwd-style").value = state.pwdStyle || "default";
1282
+ document.getElementById("inp-notify-sec").value = state.notifyDurationSec || 0;
1283
+ document.getElementById("inp-custom-badge").value = state.customSegmentText || "";
1284
+ document.getElementById("chk-git-state").checked = state.gitShowState;
1285
+
1286
+ document.getElementById("chk-two-line").checked = state.twoLine;
1287
+ document.getElementById("chk-vert-pad").checked = state.verticalPadding;
1288
+ document.getElementById("chk-term-title").checked = state.enableTerminalTitle;
1289
+ document.getElementById("inp-prefix").value = state.promptPrefix || "";
1290
+ document.getElementById("sel-font-effect").value = state.fontEffect || "bold";
1291
+ document.getElementById("rng-max-pwd").value = state.maxPwdChar;
1292
+ document.getElementById("lbl-max-pwd").textContent = state.maxPwdChar;
1293
+ document.getElementById("rng-max-git").value = state.maxGitChar;
1294
+ document.getElementById("lbl-max-git").textContent = state.maxGitChar;
1295
+ document.getElementById("rng-max-pyenv").value = state.maxPyenvChar;
1296
+ document.getElementById("lbl-max-pyenv").textContent = state.maxPyenvChar;
1297
+ document.getElementById("rng-max-kube").value = state.maxKubeChar;
1298
+ document.getElementById("lbl-max-kube").textContent = state.maxKubeChar;
1299
+ document.getElementById("rng-compact-width").value = state.compactWidth;
1300
+ document.getElementById("lbl-compact-width").textContent = state.compactWidth;
1301
+ document.getElementById("chk-git-counts").checked = state.gitShowCounts;
1302
+ document.getElementById("chk-transient").checked = state.transientPrompt;
1303
+ document.getElementById("chk-wsl-fast").checked = state.gitSkipUntracked;
1304
+ document.getElementById("chk-async-git").checked = state.gitAsyncCache;
1305
+ document.getElementById("inp-git-timeout").value = state.gitTimeoutMs;
1306
+ document.getElementById("inp-min-duration").value = state.minDurationMs;
1307
+
1308
+ const patchDefs = [
1309
+ ["kube_fast", "Zero-subshell Kubernetes reader + max_kube_char (no yq)"],
1310
+ ["kube_namespace_prod", "Kubernetes namespace + automatic 🚨 prod cluster red warning"],
1311
+ ["git_single_pass", "Single-pass git status check (4x faster prompt)"],
1312
+ ["git_wsl_fast", "WSL2 /mnt/* fast-untracked + timeout + async cache + max_git_char"],
1313
+ ["git_ahead_behind_counts", "Exact Git ahead/behind counts (↑N ↓M)"],
1314
+ ["git_advanced_state", "Git rebase/merge/cherry-pick/bisect & worktree state"],
1315
+ ["zero_fork_render", "Zero-fork pure-Bash segment renderer (~20 fewer subshells)"],
1316
+ ["dual_separator", "Independent ending separator (separator_char_end)"],
1317
+ ["color_256_parity", "Full 256-color & named-color parity + italic/regular effects"],
1318
+ ["truecolor_24bit", "24-bit TrueColor (#RRGGBB) with 256-color fallback"],
1319
+ ["v11_segments", "v1.1 segments (STATUS, DURATION, AWS, GCP, DOCKER, NODE, SSH)"],
1320
+ ["v12_segments", "v1.2 segments (JOBS, DIRENV, SHLVL/NIX, RUST, GO) + nounset safety"],
1321
+ ["v13_segments", "v1.3 BATTERY segment + Git state + RPROMPT + OSC 133"],
1322
+ ["osc133_semantic", "OSC 133 semantic prompt markers (Ghostty/Kitty/WezTerm/WT/VS Code)"],
1323
+ ["osc7_cwd", "OSC 7 CWD reporting (new tabs & splits inherit directory)"],
1324
+ ["v139_smart_features", "v1.3.9 smart colors (Git/SSH), SUDO/JJ/CUSTOM, Fish PWD & OSC 9 notify"],
1325
+ ["terminal_sanitize", "Auto-sanitize leaked SSH/TUI mouse tracking & focus reporting"],
1326
+ ["right_prompt", "Right-aligned top bar (right_format + connector line)"],
1327
+ ["responsive_width", "Responsive compact prompt on narrow tmux/VS Code splits"],
1328
+ ["hook_chaining", "Safe PROMPT_COMMAND chaining + PS0 reset (no DEBUG trap conflict)"],
1329
+ ["pyenv_enhanced", "Pure-Bash VIRTUAL_ENV_PROMPT / pyvenv.cfg / Conda + max_pyenv_char"],
1330
+ ["utf8_ps1_guard", "UTF-8 PS1 escape guard (prevents \\uE0B0 username bug)"],
1331
+ ["interactive_guard", "Non-interactive shell safety guard (scp/sftp/rsync safe)"]
1332
+ ];
1333
+ document.getElementById("patches-list").innerHTML = patchDefs.map(([k, desc]) => {
1334
+ const ok = Boolean(state.patches && state.patches[k]);
1335
+ return `
1336
+ <div class="patch-item">
1337
+ <span>${escapeHtml(desc)}</span>
1338
+ <span class="${ok ? "status-ok" : "status-warn"}">${ok ? "✓ ACTIVE" : "PENDING"}</span>
1339
+ </div>
1340
+ `;
1341
+ }).join("");
1342
+
1343
+ const bList = document.getElementById("backups-list");
1344
+ if (!state.backups.length) {
1345
+ bList.innerHTML = `<div style="font-size:13px;color:var(--soft);">No backups created yet.</div>`;
1346
+ } else {
1347
+ bList.innerHTML = state.backups.slice(0, 12).map(b => `
1348
+ <div class="patch-item">
1349
+ <div>
1350
+ <div style="font-family:var(--mono);font-size:12px;">${escapeHtml(b.name)}</div>
1351
+ <div style="font-size:11px;color:var(--soft);">${escapeHtml(b.modified)}</div>
1352
+ </div>
1353
+ <button class="sm btn-restore-item" data-id="${b.id}">Restore</button>
1354
+ </div>
1355
+ `).join("");
1356
+ bList.querySelectorAll(".btn-restore-item").forEach(btn => {
1357
+ btn.addEventListener("click", () => restoreBackup(Number(btn.dataset.id)));
1358
+ });
1359
+ }
1360
+ }
1361
+
1362
+ function renderSyncTab() {
1363
+ const rootEl = document.getElementById("root-sync-status");
1364
+ rootEl.innerHTML = state.rootConfigExists
1365
+ ? `<span class="status-ok">✓ synth-shell-prompt.root.config present</span>`
1366
+ : `<span class="status-warn">Not created yet — click below to generate from active theme</span>`;
1367
+
1368
+ const monRoot = document.getElementById("greeter-monitor-toggles");
1369
+ const avail = (state.greeter && state.greeter.available_monitors) || [];
1370
+ const active = (state.greeter && state.greeter.monitors) || [];
1371
+ monRoot.innerHTML = avail.map(m => {
1372
+ const on = active.includes(m);
1373
+ return `<button class="seg-pill ${on ? "enabled" : ""}" data-mon="${escapeHtml(m)}">${escapeHtml(m)}</button>`;
1374
+ }).join("");
1375
+ monRoot.querySelectorAll(".seg-pill").forEach(btn => {
1376
+ btn.addEventListener("click", () => {
1377
+ const m = btn.dataset.mon;
1378
+ if (state.greeter.monitors.includes(m)) {
1379
+ state.greeter.monitors = state.greeter.monitors.filter(x => x !== m);
1380
+ } else {
1381
+ state.greeter.monitors.push(m);
1382
+ }
1383
+ renderSyncTab();
1384
+ });
1385
+ });
1386
+
1387
+ const dList = document.getElementById("diagnostics-list");
1388
+ const loc = (state.diagnostics && state.diagnostics.locale) || {};
1389
+ const nf = (state.diagnostics && state.diagnostics.nerd_fonts) || {};
1390
+ const term = (state.diagnostics && state.diagnostics.terminal) || {};
1391
+ const samples = Array.isArray(nf.samples) && nf.samples.length ? ` (${nf.samples.slice(0, 3).join(", ")})` : "";
1392
+ dList.innerHTML = `
1393
+ <div class="patch-item">
1394
+ <span>UTF-8 Locale (${escapeHtml(loc.effective || "unknown")})</span>
1395
+ <span class="${loc.utf8 ? "status-ok" : "status-warn"}">${loc.utf8 ? "✓ UTF-8" : "NON-UTF8"}</span>
1396
+ </div>
1397
+ <div class="patch-item">
1398
+ <span>Terminal Color (${escapeHtml(term.term || "unknown")} / ${escapeHtml(term.colorterm || "unset")})</span>
1399
+ <span class="${term.truecolor ? "status-ok" : "status-warn"}">${term.truecolor ? "✓ 24-BIT TRUECOLOR" : (term.term_256 ? "256-COLOR" : "BASIC")}</span>
1400
+ </div>
1401
+ <div class="patch-item">
1402
+ <span>Nerd / Powerline Fonts${escapeHtml(samples)}</span>
1403
+ <span class="${nf.detected ? "status-ok" : "status-warn"}">${nf.detected ? `✓ ${nf.count} FOUND` : "NOT DETECTED"}</span>
1404
+ </div>
1405
+ <div class="patch-item">
1406
+ <span>System Swap Present</span>
1407
+ <span class="status-ok">${state.greeter && state.greeter.has_swap ? "YES" : "NO (hide SWAP_MON)"}</span>
1408
+ </div>
1409
+ `;
1410
+ }
1411
+
1412
+ function syncFromServerState(srvState, backups, greeterState) {
1413
+ if (srvState.active_theme_id) {
1414
+ state.activeThemeId = srvState.active_theme_id;
1415
+ state.selectedThemeId = srvState.active_theme_id;
1416
+ }
1417
+ if (srvState.internal_separator) {
1418
+ state.internalSep = srvState.internal_separator;
1419
+ }
1420
+ if (srvState.end_separator) {
1421
+ state.endSep = srvState.end_separator;
1422
+ }
1423
+ if (Array.isArray(srvState.format_segments) && srvState.format_segments.length) {
1424
+ state.formatSegments = srvState.format_segments;
1425
+ }
1426
+ if (Array.isArray(srvState.right_format_segments)) {
1427
+ state.rightSegments = srvState.right_format_segments;
1428
+ }
1429
+ state.rightFillChar = String(srvState.right_fill_char || "─");
1430
+ state.enableOsc133 = srvState.enable_osc133 !== false;
1431
+ state.enableOsc7 = srvState.enable_osc7 !== false;
1432
+ state.enableTerminalSanitize = srvState.enable_terminal_sanitize !== false;
1433
+ state.kubeShowNamespace = srvState.kube_show_namespace !== false;
1434
+ state.kubeProdWarning = srvState.kube_prod_warning !== false;
1435
+ state.gitDynamicColor = Boolean(srvState.git_dynamic_color);
1436
+ state.sshHostColor = Boolean(srvState.ssh_host_color);
1437
+ state.pwdStyle = String(srvState.pwd_style || "default");
1438
+ state.notifyDurationSec = Number(srvState.notify_duration_sec || 0);
1439
+ state.customSegmentText = String(srvState.custom_segment_text || "");
1440
+ state.gitShowState = srvState.git_show_state !== false;
1441
+ state.batteryThreshold = Number(srvState.battery_threshold || 100);
1442
+ state.twoLine = Boolean(srvState.enable_command_on_new_line);
1443
+ state.verticalPadding = Boolean(srvState.enable_vertical_padding);
1444
+ state.maxPwdChar = Number(srvState.max_pwd_char || 35);
1445
+ state.maxGitChar = Number(srvState.max_git_char || 0);
1446
+ state.maxPyenvChar = Number(srvState.max_pyenv_char || 0);
1447
+ state.maxKubeChar = Number(srvState.max_kube_char || 28);
1448
+ state.compactWidth = Number(srvState.compact_width ?? 90);
1449
+ state.gitShowCounts = srvState.git_show_counts !== false;
1450
+ state.transientPrompt = Boolean(srvState.transient_prompt);
1451
+ state.promptPrefix = String(srvState.prompt_prefix || "");
1452
+ state.fontEffect = String(srvState.font_effect || "bold");
1453
+ state.enableTerminalTitle = srvState.enable_terminal_title !== false;
1454
+ state.gitSkipUntracked = srvState.git_skip_untracked_on_slow_fs !== false;
1455
+ state.gitTimeoutMs = Number(srvState.git_timeout_ms || 0);
1456
+ state.gitAsyncCache = Boolean(srvState.git_async_cache);
1457
+ state.minDurationMs = Number(srvState.min_duration_ms || 2000);
1458
+ state.rootConfigExists = Boolean(srvState.root_config_exists);
1459
+ state.patches = srvState.patches || {};
1460
+ if (greeterState) state.greeter = greeterState;
1461
+ if (Array.isArray(backups)) state.backups = backups;
1462
+
1463
+ renderWorkbench();
1464
+ renderThemeGrid();
1465
+ renderSeparatorsTab();
1466
+ renderLayoutTab();
1467
+ renderSyncTab();
1468
+ }
1469
+
1470
+ async function applyChanges(payload) {
1471
+ if (state.staticDemo) {
1472
+ if (payload.theme) {
1473
+ const found = state.themes.find(t => t.id === Number(payload.theme) || t.slug === payload.theme);
1474
+ if (found) { state.selectedThemeId = found.id; state.activeThemeId = found.id; }
1475
+ }
1476
+ renderWorkbench();
1477
+ renderThemeGrid();
1478
+ const cmd = buildCliShareCommand();
1479
+ try { await navigator.clipboard.writeText(cmd); } catch {}
1480
+ showToast(`Static Demo: copied CLI command → ${cmd}`);
1481
+ return;
1482
+ }
1483
+ const resp = await fetch("/api/apply", {
1484
+ method: "POST",
1485
+ headers: { "Content-Type": "application/json" },
1486
+ body: JSON.stringify(payload)
1487
+ });
1488
+ const data = await resp.json();
1489
+ if (!data.ok) {
1490
+ showToast(`Error: ${data.error || "Failed to apply"}`);
1491
+ return;
1492
+ }
1493
+ syncFromServerState(data.state, data.backups);
1494
+ showToast(`Saved to synth-shell-prompt.config (${(data.applied || []).join(", ")})`);
1495
+ }
1496
+
1497
+ async function restoreBackup(target = 1) {
1498
+ if (state.staticDemo) { showToast("Static Demo: backups require local `synth-shell-theme web`."); return; }
1499
+ const resp = await fetch("/api/restore", {
1500
+ method: "POST",
1501
+ headers: { "Content-Type": "application/json" },
1502
+ body: JSON.stringify({ target })
1503
+ });
1504
+ const data = await resp.json();
1505
+ if (!data.ok) {
1506
+ showToast(data.error || "No backup available");
1507
+ return;
1508
+ }
1509
+ syncFromServerState(data.state, data.backups);
1510
+ showToast(`Restored backup: ${data.restored}`);
1511
+ }
1512
+
1513
+ async function initStudio() {
1514
+ let boot;
1515
+ if (window.__SYNTH_STATIC_BOOTSTRAP__) {
1516
+ boot = window.__SYNTH_STATIC_BOOTSTRAP__;
1517
+ state.staticDemo = true;
1518
+ document.getElementById("static-demo-banner").style.display = "block";
1519
+ } else {
1520
+ const resp = await fetch("/api/bootstrap");
1521
+ boot = await resp.json();
1522
+ }
1523
+ document.getElementById("version-badge").textContent = `Studio v${boot.version}`;
1524
+ state.themes = boot.themes || [];
1525
+ state.separators = boot.separators || { categories: [], palette: [] };
1526
+ state.validSegments = boot.valid_segments || ["USER", "HOST", "PWD", "GIT", "PYENV", "TF", "KUBE", "CLOCK"];
1527
+ state.diagnostics = boot.diagnostics || {};
1528
+ renderBadges();
1529
+ syncFromServerState(boot.state || {}, boot.backups || [], boot.greeter || null);
1530
+ }
1531
+
1532
+ // Event bindings
1533
+ document.querySelectorAll(".tab-btn").forEach(btn => {
1534
+ btn.addEventListener("click", () => {
1535
+ document.querySelectorAll(".tab-btn").forEach(b => b.classList.remove("active"));
1536
+ document.querySelectorAll(".tab-panel").forEach(p => p.classList.remove("active"));
1537
+ btn.classList.add("active");
1538
+ document.getElementById(`tab-${btn.dataset.tab}`).classList.add("active");
1539
+ });
1540
+ });
1541
+
1542
+ document.getElementById("theme-search").addEventListener("input", e => {
1543
+ state.searchQuery = e.target.value;
1544
+ renderThemeGrid();
1545
+ });
1546
+
1547
+ document.getElementById("chk-force-white").addEventListener("change", e => {
1548
+ state.forceWhite = e.target.checked;
1549
+ renderWorkbench();
1550
+ renderThemeGrid();
1551
+ });
1552
+
1553
+ document.getElementById("chk-keep-input").addEventListener("change", e => {
1554
+ state.keepInput = e.target.checked;
1555
+ });
1556
+
1557
+ document.getElementById("btn-apply-active").addEventListener("click", () => {
1558
+ applyChanges({
1559
+ theme: state.selectedThemeId,
1560
+ force_white: state.forceWhite,
1561
+ keep_input: state.keepInput,
1562
+ internal_separator: state.internalSep.code,
1563
+ end_separator: state.endSep.code,
1564
+ format: state.formatSegments,
1565
+ enable_command_on_new_line: state.twoLine,
1566
+ enable_vertical_padding: state.verticalPadding,
1567
+ max_pwd_char: state.maxPwdChar
1568
+ });
1569
+ });
1570
+
1571
+ document.getElementById("btn-copy-cli").addEventListener("click", async () => {
1572
+ const cmd = buildCliShareCommand();
1573
+ try {
1574
+ await navigator.clipboard.writeText(cmd);
1575
+ showToast(`Copied CLI: ${cmd}`);
1576
+ } catch {
1577
+ showToast(cmd);
1578
+ }
1579
+ });
1580
+
1581
+ document.getElementById("qe-bg").addEventListener("input", e => {
1582
+ const theme = getSelectedTheme();
1583
+ if (theme && state.editingSegKey && theme.segments[state.editingSegKey]) {
1584
+ theme.segments[state.editingSegKey].bg = e.target.value;
1585
+ renderWorkbench();
1586
+ }
1587
+ });
1588
+ document.getElementById("qe-fg").addEventListener("input", e => {
1589
+ const theme = getSelectedTheme();
1590
+ if (theme && state.editingSegKey && theme.segments[state.editingSegKey]) {
1591
+ theme.segments[state.editingSegKey].fg = e.target.value;
1592
+ renderWorkbench();
1593
+ }
1594
+ });
1595
+ document.getElementById("qe-close").addEventListener("click", () => {
1596
+ document.getElementById("seg-quick-editor").style.display = "none";
1597
+ state.editingSegKey = null;
1598
+ });
1599
+ document.getElementById("qe-save-custom").addEventListener("click", async () => {
1600
+ const theme = getSelectedTheme();
1601
+ if (!theme) return;
1602
+ if (state.staticDemo) { showToast("Static Demo: custom theme saving requires local `synth-shell-theme web`."); return; }
1603
+ const colors = {};
1604
+ Object.entries(theme.segments).forEach(([k, v]) => {
1605
+ if (v && v.fg) colors[`font_color_${k}`] = v.fg;
1606
+ if (v && v.bg) colors[`background_${k}`] = v.bg;
1607
+ });
1608
+ const resp = await fetch("/api/custom-theme", {
1609
+ method: "POST",
1610
+ headers: { "Content-Type": "application/json" },
1611
+ body: JSON.stringify({ name: `${theme.name} Remix`, colors, apply: true })
1612
+ });
1613
+ const data = await resp.json();
1614
+ if (data.ok) {
1615
+ if (Array.isArray(data.themes)) state.themes = data.themes;
1616
+ renderBadges();
1617
+ syncFromServerState(data.state, data.backups);
1618
+ showToast(`Saved custom remix: ${data.saved_theme}`);
1619
+ }
1620
+ });
1621
+
1622
+ document.getElementById("inp-right-fill").addEventListener("input", e => {
1623
+ state.rightFillChar = e.target.value || " ";
1624
+ renderWorkbench();
1625
+ });
1626
+ document.getElementById("chk-osc133").addEventListener("change", e => { state.enableOsc133 = e.target.checked; });
1627
+ document.getElementById("chk-osc7").addEventListener("change", e => { state.enableOsc7 = e.target.checked; });
1628
+ document.getElementById("chk-term-sanitize").addEventListener("change", e => { state.enableTerminalSanitize = e.target.checked; });
1629
+ document.getElementById("chk-kube-ns").addEventListener("change", e => { state.kubeShowNamespace = e.target.checked; state.kubeProdWarning = e.target.checked; });
1630
+ document.getElementById("chk-git-dyn").addEventListener("change", e => { state.gitDynamicColor = e.target.checked; });
1631
+ document.getElementById("chk-ssh-host-color").addEventListener("change", e => { state.sshHostColor = e.target.checked; });
1632
+ document.getElementById("sel-pwd-style").addEventListener("change", e => { state.pwdStyle = e.target.value; });
1633
+ document.getElementById("chk-git-state").addEventListener("change", e => { state.gitShowState = e.target.checked; });
1634
+
1635
+ document.getElementById("btn-sync-ecosystem").addEventListener("click", async () => {
1636
+ if (state.staticDemo) { showToast("Run locally: synth-shell-theme --sync-ecosystem"); return; }
1637
+ const resp = await fetch("/api/sync-ecosystem", { method: "POST", headers: { "Content-Type": "application/json" }, body: "{}" });
1638
+ const data = await resp.json();
1639
+ if (data.ok) showToast(`Synced fzf, LS_COLORS, tmux & WezTerm (${data.result.theme})!`);
1640
+ });
1641
+
1642
+ document.getElementById("btn-export-starship").addEventListener("click", async () => {
1643
+ if (state.staticDemo) { showToast("Run locally: synth-shell-theme export-starship"); return; }
1644
+ const resp = await fetch("/api/export-starship", { method: "POST", headers: { "Content-Type": "application/json" }, body: "{}" });
1645
+ const data = await resp.json();
1646
+ if (data.ok) showToast(`Exported starship.toml (${data.result.theme}) -> ${data.result.dest}`);
1647
+ });
1648
+
1649
+ document.getElementById("btn-auto-theme").addEventListener("click", async () => {
1650
+ if (state.staticDemo) { showToast("Run locally: synth-shell-theme --auto-theme"); return; }
1651
+ const resp = await fetch("/api/auto-theme", { method: "POST", headers: { "Content-Type": "application/json" }, body: "{}" });
1652
+ const data = await resp.json();
1653
+ if (data.ok) {
1654
+ syncFromServerState(data.state, data.backups);
1655
+ showToast(`Matched OS ${data.result.detected_scheme} mode -> ${data.result.theme}`);
1656
+ }
1657
+ });
1658
+
1659
+ document.getElementById("btn-copy-reload").addEventListener("click", async () => {
1660
+ const cmd = "source ~/.config/synth-shell/synth-shell-prompt.sh";
1661
+ try {
1662
+ await navigator.clipboard.writeText(cmd);
1663
+ showToast(`Copied: ${cmd}`);
1664
+ } catch {
1665
+ showToast(cmd);
1666
+ }
1667
+ });
1668
+
1669
+ document.getElementById("btn-undo").addEventListener("click", () => restoreBackup(1));
1670
+
1671
+ document.getElementById("btn-apply-custom-sep").addEventListener("click", async () => {
1672
+ const raw = document.getElementById("custom-sep-input").value.trim();
1673
+ if (!raw) return;
1674
+ const target = document.querySelector('input[name="sep-target"]:checked').value;
1675
+ const payload = {};
1676
+ if (target === "both" || target === "internal") payload.internal_separator = raw;
1677
+ if (target === "both" || target === "end") payload.end_separator = raw;
1678
+ await applyChanges(payload);
1679
+ });
1680
+
1681
+ document.getElementById("chk-two-line").addEventListener("change", e => {
1682
+ state.twoLine = e.target.checked;
1683
+ renderWorkbench();
1684
+ renderThemeGrid();
1685
+ });
1686
+
1687
+ document.getElementById("chk-vert-pad").addEventListener("change", e => {
1688
+ state.verticalPadding = e.target.checked;
1689
+ });
1690
+
1691
+ document.getElementById("rng-max-pwd").addEventListener("input", e => {
1692
+ state.maxPwdChar = Number(e.target.value);
1693
+ document.getElementById("lbl-max-pwd").textContent = state.maxPwdChar;
1694
+ });
1695
+
1696
+ document.getElementById("rng-max-git").addEventListener("input", e => {
1697
+ state.maxGitChar = Number(e.target.value);
1698
+ document.getElementById("lbl-max-git").textContent = state.maxGitChar;
1699
+ });
1700
+
1701
+ document.getElementById("rng-max-pyenv").addEventListener("input", e => {
1702
+ state.maxPyenvChar = Number(e.target.value);
1703
+ document.getElementById("lbl-max-pyenv").textContent = state.maxPyenvChar;
1704
+ });
1705
+
1706
+ document.getElementById("rng-max-kube").addEventListener("input", e => {
1707
+ state.maxKubeChar = Number(e.target.value);
1708
+ document.getElementById("lbl-max-kube").textContent = state.maxKubeChar;
1709
+ });
1710
+
1711
+ document.getElementById("rng-compact-width").addEventListener("input", e => {
1712
+ state.compactWidth = Number(e.target.value);
1713
+ document.getElementById("lbl-compact-width").textContent = state.compactWidth;
1714
+ });
1715
+
1716
+ document.getElementById("chk-git-counts").addEventListener("change", e => {
1717
+ state.gitShowCounts = e.target.checked;
1718
+ });
1719
+
1720
+ document.getElementById("chk-transient").addEventListener("change", e => {
1721
+ state.transientPrompt = e.target.checked;
1722
+ });
1723
+
1724
+ document.getElementById("btn-toggle-theme").addEventListener("click", async () => {
1725
+ const resp = await fetch("/api/toggle-theme", {
1726
+ method: "POST",
1727
+ headers: { "Content-Type": "application/json" },
1728
+ body: JSON.stringify({})
1729
+ });
1730
+ const data = await resp.json();
1731
+ if (data.ok) {
1732
+ syncFromServerState(data.state, data.backups);
1733
+ showToast(`Switched to ${data.result.mode} theme: ${data.result.theme}`);
1734
+ }
1735
+ });
1736
+
1737
+ document.getElementById("btn-toggle-creator").addEventListener("click", () => {
1738
+ const box = document.getElementById("custom-theme-creator");
1739
+ box.style.display = box.style.display === "none" ? "block" : "none";
1740
+ });
1741
+
1742
+ document.getElementById("btn-save-custom-theme").addEventListener("click", async () => {
1743
+ const name = document.getElementById("ct-name").value.trim() || "My TrueColor Theme";
1744
+ const description = document.getElementById("ct-desc").value.trim();
1745
+ const colors = {
1746
+ font_color_host: "white",
1747
+ background_host: document.getElementById("ct-bg-host").value,
1748
+ font_color_pwd: "black",
1749
+ background_pwd: document.getElementById("ct-bg-pwd").value,
1750
+ font_color_git: "black",
1751
+ background_git: document.getElementById("ct-bg-git").value,
1752
+ font_color_pyenv: "black",
1753
+ background_pyenv: document.getElementById("ct-bg-pyenv").value,
1754
+ font_color_tf: "black",
1755
+ background_tf: document.getElementById("ct-bg-tf").value,
1756
+ font_color_kube: "black",
1757
+ background_kube: document.getElementById("ct-bg-kube").value,
1758
+ font_color_input: document.getElementById("ct-fg-input").value,
1759
+ background_input: "none"
1760
+ };
1761
+ const resp = await fetch("/api/custom-theme", {
1762
+ method: "POST",
1763
+ headers: { "Content-Type": "application/json" },
1764
+ body: JSON.stringify({ name, description, colors, apply: true })
1765
+ });
1766
+ const data = await resp.json();
1767
+ if (data.ok) {
1768
+ if (Array.isArray(data.themes)) state.themes = data.themes;
1769
+ renderBadges();
1770
+ syncFromServerState(data.state, data.backups);
1771
+ document.getElementById("custom-theme-creator").style.display = "none";
1772
+ showToast(`Saved & applied custom TrueColor theme: ${data.saved_theme}`);
1773
+ } else {
1774
+ showToast(`Error: ${data.error || "Failed to save theme"}`);
1775
+ }
1776
+ });
1777
+
1778
+ document.getElementById("btn-run-bench").addEventListener("click", async () => {
1779
+ const out = document.getElementById("bench-result");
1780
+ out.textContent = "Benchmarking…";
1781
+ const resp = await fetch("/api/bench", {
1782
+ method: "POST",
1783
+ headers: { "Content-Type": "application/json" },
1784
+ body: JSON.stringify({ iterations: 12 })
1785
+ });
1786
+ const data = await resp.json();
1787
+ if (data.ok) {
1788
+ out.textContent = `p50: ${data.p50_ms} ms · p95: ${data.p95_ms} ms · min: ${data.min_ms} ms (${data.iterations} runs)`;
1789
+ } else {
1790
+ out.textContent = data.error || "Benchmark unavailable";
1791
+ }
1792
+ });
1793
+
1794
+ document.getElementById("inp-prefix").addEventListener("input", e => {
1795
+ state.promptPrefix = e.target.value;
1796
+ renderWorkbench();
1797
+ });
1798
+
1799
+ document.getElementById("sel-font-effect").addEventListener("change", e => {
1800
+ state.fontEffect = e.target.value;
1801
+ renderWorkbench();
1802
+ });
1803
+
1804
+ document.getElementById("chk-term-title").addEventListener("change", e => {
1805
+ state.enableTerminalTitle = e.target.checked;
1806
+ });
1807
+
1808
+ document.getElementById("chk-wsl-fast").addEventListener("change", e => {
1809
+ state.gitSkipUntracked = e.target.checked;
1810
+ });
1811
+
1812
+ document.getElementById("chk-async-git").addEventListener("change", e => {
1813
+ state.gitAsyncCache = e.target.checked;
1814
+ });
1815
+
1816
+ document.getElementById("btn-save-layout").addEventListener("click", () => {
1817
+ applyChanges({
1818
+ format: state.formatSegments,
1819
+ right_format: state.rightSegments,
1820
+ right_fill_char: state.rightFillChar,
1821
+ enable_osc133: state.enableOsc133,
1822
+ enable_osc7: state.enableOsc7,
1823
+ enable_terminal_sanitize: state.enableTerminalSanitize,
1824
+ kube_show_namespace: state.kubeShowNamespace,
1825
+ kube_prod_warning: state.kubeProdWarning,
1826
+ git_dynamic_color: state.gitDynamicColor,
1827
+ ssh_host_color: state.sshHostColor,
1828
+ pwd_style: state.pwdStyle,
1829
+ notify_duration_sec: Number(document.getElementById("inp-notify-sec").value || 0),
1830
+ custom_segment_text: document.getElementById("inp-custom-badge").value || "",
1831
+ git_show_state: state.gitShowState,
1832
+ enable_command_on_new_line: state.twoLine,
1833
+ enable_vertical_padding: state.verticalPadding,
1834
+ max_pwd_char: state.maxPwdChar,
1835
+ max_git_char: state.maxGitChar,
1836
+ max_pyenv_char: state.maxPyenvChar,
1837
+ max_kube_char: state.maxKubeChar,
1838
+ compact_width: state.compactWidth,
1839
+ git_show_counts: state.gitShowCounts,
1840
+ transient_prompt: state.transientPrompt,
1841
+ prompt_prefix: state.promptPrefix,
1842
+ font_effect: state.fontEffect,
1843
+ enable_terminal_title: state.enableTerminalTitle,
1844
+ git_skip_untracked_on_slow_fs: state.gitSkipUntracked,
1845
+ git_timeout_ms: Number(document.getElementById("inp-git-timeout").value || 0),
1846
+ git_async_cache: state.gitAsyncCache,
1847
+ min_duration_ms: Number(document.getElementById("inp-min-duration").value || 2000)
1848
+ });
1849
+ });
1850
+
1851
+ document.getElementById("btn-ascii-safe").addEventListener("click", async () => {
1852
+ const resp = await fetch("/api/ascii-safe", {
1853
+ method: "POST",
1854
+ headers: { "Content-Type": "application/json" },
1855
+ body: JSON.stringify({ separator: ">" })
1856
+ });
1857
+ const data = await resp.json();
1858
+ if (data.ok) {
1859
+ syncFromServerState(data.state, data.backups);
1860
+ showToast("ASCII-Safe separators & Git symbols applied!");
1861
+ }
1862
+ });
1863
+
1864
+ document.getElementById("btn-sync-root").addEventListener("click", async () => {
1865
+ const resp = await fetch("/api/sync-root", {
1866
+ method: "POST",
1867
+ headers: { "Content-Type": "application/json" },
1868
+ body: JSON.stringify({ root_accent: "196" })
1869
+ });
1870
+ const data = await resp.json();
1871
+ if (data.ok) {
1872
+ syncFromServerState(data.state, data.backups);
1873
+ showToast("Synced synth-shell-prompt.root.config!");
1874
+ }
1875
+ });
1876
+
1877
+ document.getElementById("btn-sync-greeter").addEventListener("click", async () => {
1878
+ const resp = await fetch("/api/greeter", {
1879
+ method: "POST",
1880
+ headers: { "Content-Type": "application/json" },
1881
+ body: JSON.stringify({ monitors: state.greeter.monitors })
1882
+ });
1883
+ const data = await resp.json();
1884
+ if (data.ok) {
1885
+ syncFromServerState(data.state, data.backups, data.greeter);
1886
+ showToast("Synced synth-shell-greeter.config!");
1887
+ }
1888
+ });
1889
+
1890
+ document.getElementById("btn-greeter-hide-swap").addEventListener("click", async () => {
1891
+ const resp = await fetch("/api/greeter", {
1892
+ method: "POST",
1893
+ headers: { "Content-Type": "application/json" },
1894
+ body: JSON.stringify({ monitors: state.greeter.monitors, hide_swap_if_unavailable: true })
1895
+ });
1896
+ const data = await resp.json();
1897
+ if (data.ok) {
1898
+ syncFromServerState(data.state, data.backups, data.greeter);
1899
+ showToast("Updated greeter monitors (swap auto-check applied)!");
1900
+ }
1901
+ });
1902
+
1903
+ document.getElementById("btn-run-patches").addEventListener("click", async () => {
1904
+ const resp = await fetch("/api/patches", {
1905
+ method: "POST",
1906
+ headers: { "Content-Type": "application/json" },
1907
+ body: JSON.stringify({ tune_defaults: false })
1908
+ });
1909
+ const data = await resp.json();
1910
+ if (data.ok) {
1911
+ syncFromServerState(data.state, data.backups, data.greeter);
1912
+ const count = (data.changes || []).length;
1913
+ showToast(count ? `Applied ${count} runtime patch(es)` : "All v1.1 runtime patches already active!");
1914
+ }
1915
+ });
1916
+
1917
+ initStudio();
1918
+ </script>
1919
+ </body>
1920
+ </html>