@firstpick/pi-package-webui 0.8.4 → 0.8.6

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 (50) hide show
  1. package/README.md +24 -2
  2. package/bin/pi-webui.mjs +383 -31
  3. package/index.ts +8 -1
  4. package/lib/git-workflow-preferences.mjs +3 -0
  5. package/lib/session-summary-core.mjs +4 -3
  6. package/lib/trust-boundaries.mjs +13 -0
  7. package/lib/workspace-session-summaries.mjs +400 -0
  8. package/package.json +2 -2
  9. package/public/app.js +1242 -267
  10. package/public/index.html +77 -4
  11. package/public/service-worker.js +3 -1
  12. package/public/stream-output-controller.mjs +327 -0
  13. package/public/styles.css +249 -70
  14. package/public/theme-contract.mjs +244 -0
  15. package/session-summary.ts +164 -4
  16. package/tests/aur-review-widget-static.test.mjs +2 -1
  17. package/tests/boot-failure-diagnostics.test.mjs +2 -2
  18. package/tests/browser/interaction-continuity.spec.mjs +2 -2
  19. package/tests/browser/session-summary.spec.mjs +131 -3
  20. package/tests/browser/stream-output-isolation.spec.mjs +510 -0
  21. package/tests/codex-fast-mode-static.test.mjs +2 -2
  22. package/tests/composer-action-grid-reorder-static.test.mjs +2 -2
  23. package/tests/fast-mode-client-static.test.mjs +3 -2
  24. package/tests/feature-decision-output-popup-static.test.mjs +1 -1
  25. package/tests/fixtures/fake-pi.mjs +203 -2
  26. package/tests/git-workflow-preferences.test.mjs +7 -1
  27. package/tests/guided-git-aur-review.test.mjs +4 -3
  28. package/tests/http-endpoints-harness.test.mjs +224 -13
  29. package/tests/mobile-continuity-tablet-static.test.mjs +2 -2
  30. package/tests/mobile-foundation-static.test.mjs +3 -4
  31. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  32. package/tests/mobile-static.test.mjs +63 -29
  33. package/tests/native-parity.test.mjs +1 -1
  34. package/tests/open-issue-wizard-static.test.mjs +2 -3
  35. package/tests/optional-feature-migration-frontend.test.mjs +3 -0
  36. package/tests/persistent-ui-layout-static.test.mjs +2 -2
  37. package/tests/questionnaire-dialog.test.mjs +2 -2
  38. package/tests/remote-auth-settings-harness.test.mjs +9 -0
  39. package/tests/session-summary-core.test.mjs +183 -1
  40. package/tests/side-panel-section-reorder-static.test.mjs +2 -2
  41. package/tests/stream-lifecycle-core.test.mjs +134 -0
  42. package/tests/stream-output-controller.test.mjs +252 -0
  43. package/tests/stream-output-isolation-static.test.mjs +89 -0
  44. package/tests/streaming-ui-coupling.test.mjs +50 -0
  45. package/tests/subagent-gate-visibility.test.mjs +1 -1
  46. package/tests/subagent-launch-slots-static.test.mjs +1 -1
  47. package/tests/theme-contract.test.mjs +104 -0
  48. package/tests/theme-customizer-static.test.mjs +82 -0
  49. package/tests/theme-scheme-mode.test.mjs +15 -0
  50. package/tests/workspace-session-summaries.test.mjs +288 -0
package/public/styles.css CHANGED
@@ -2271,6 +2271,173 @@ body.embedded-split .side-panel-backdrop {
2271
2271
  border-color: rgba(137, 180, 250, 0.34);
2272
2272
  background: rgba(137, 180, 250, 0.12);
2273
2273
  }
2274
+ .theme-search-result-badges {
2275
+ display: inline-flex;
2276
+ justify-self: end;
2277
+ gap: 0.28rem;
2278
+ align-items: center;
2279
+ }
2280
+ .theme-scope-badge {
2281
+ display: inline-flex;
2282
+ align-items: center;
2283
+ width: fit-content;
2284
+ min-height: 1.45rem;
2285
+ padding: 0.12rem 0.46rem;
2286
+ border: 1px solid rgba(148, 226, 213, 0.34);
2287
+ border-radius: 999px;
2288
+ color: var(--ctp-teal);
2289
+ background: rgba(148, 226, 213, 0.1);
2290
+ font-size: var(--text-xs);
2291
+ font-weight: 900;
2292
+ line-height: 1.1;
2293
+ }
2294
+ .theme-scope-badge.project { color: var(--ctp-green); border-color: rgba(166, 227, 161, 0.38); }
2295
+ .theme-scope-badge.global { color: var(--ctp-mauve); border-color: rgba(203, 166, 247, 0.38); }
2296
+ .theme-customize-button { width: 100%; }
2297
+ .theme-customizer-dialog {
2298
+ width: min(76rem, calc(100vw - 2rem));
2299
+ height: min(92dvh, 58rem);
2300
+ max-width: none;
2301
+ max-height: none;
2302
+ padding: 0;
2303
+ overflow: hidden;
2304
+ }
2305
+ .theme-customizer-shell {
2306
+ display: grid;
2307
+ grid-template-rows: auto minmax(0, 1fr) auto;
2308
+ width: 100%;
2309
+ height: 100%;
2310
+ min-height: 0;
2311
+ }
2312
+ .theme-customizer-header {
2313
+ display: flex;
2314
+ justify-content: space-between;
2315
+ gap: 1rem;
2316
+ align-items: flex-start;
2317
+ padding: 1rem 1.1rem 0.8rem;
2318
+ border-bottom: 1px solid var(--border);
2319
+ }
2320
+ .theme-customizer-header h2 { margin: 0.18rem 0 0.3rem; }
2321
+ .theme-customizer-header p { max-width: 54rem; margin: 0; line-height: 1.45; }
2322
+ .theme-customizer-kicker {
2323
+ color: var(--ctp-pink);
2324
+ font-size: var(--text-xs);
2325
+ font-weight: 900;
2326
+ letter-spacing: 0.14em;
2327
+ text-transform: uppercase;
2328
+ }
2329
+ .theme-customizer-scroll {
2330
+ display: grid;
2331
+ gap: 0.8rem;
2332
+ min-height: 0;
2333
+ padding: 0.9rem 1.1rem;
2334
+ overflow-y: auto;
2335
+ overscroll-behavior: contain;
2336
+ }
2337
+ .theme-customizer-identity {
2338
+ display: grid;
2339
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
2340
+ gap: 0.35rem 0.8rem;
2341
+ align-items: end;
2342
+ }
2343
+ .theme-customizer-identity label,
2344
+ .theme-customizer-optional-fields > label {
2345
+ display: grid;
2346
+ gap: 0.32rem;
2347
+ font-weight: 800;
2348
+ }
2349
+ .theme-customizer-identity p { margin: 0; font-size: var(--text-xs); }
2350
+ .theme-customizer-preview {
2351
+ padding: 0.85rem;
2352
+ border: 1px solid var(--border);
2353
+ border-radius: 0.85rem;
2354
+ background: var(--panel-gradient);
2355
+ }
2356
+ .theme-customizer-preview p { margin: 0.45rem 0; }
2357
+ .theme-customizer-preview div { display: flex; flex-wrap: wrap; gap: 0.65rem; font-weight: 800; }
2358
+ .theme-customizer-preview .success { color: var(--ok); }
2359
+ .theme-customizer-preview .warning { color: var(--warning); }
2360
+ .theme-customizer-preview .error { color: var(--danger); }
2361
+ .theme-customizer-scroll > details {
2362
+ border: 1px solid rgba(180, 190, 254, 0.18);
2363
+ border-radius: 0.85rem;
2364
+ background: rgba(var(--ctp-crust-rgb), 0.34);
2365
+ }
2366
+ .theme-customizer-scroll > details > summary {
2367
+ min-height: 44px;
2368
+ padding: 0.68rem 0.8rem;
2369
+ cursor: pointer;
2370
+ font-weight: 900;
2371
+ }
2372
+ .theme-customizer-visual-fields { display: grid; gap: 0.7rem; padding: 0 0.75rem 0.75rem; }
2373
+ .theme-token-group {
2374
+ min-width: 0;
2375
+ margin: 0;
2376
+ padding: 0.65rem;
2377
+ border: 1px solid rgba(180, 190, 254, 0.16);
2378
+ border-radius: 0.72rem;
2379
+ }
2380
+ .theme-token-group legend { padding: 0 0.32rem; color: var(--ctp-teal); font-weight: 900; }
2381
+ .theme-token-grid {
2382
+ display: grid;
2383
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, 25rem), 1fr));
2384
+ gap: 0.48rem 0.7rem;
2385
+ }
2386
+ .theme-token-row {
2387
+ display: grid;
2388
+ grid-template-columns: minmax(8rem, 0.9fr) 44px minmax(7rem, 1.1fr);
2389
+ gap: 0.42rem;
2390
+ align-items: center;
2391
+ min-width: 0;
2392
+ }
2393
+ .theme-token-label { min-width: 0; overflow-wrap: anywhere; font-size: var(--text-sm); font-weight: 760; }
2394
+ .theme-token-label code { display: block; color: var(--ctp-subtext); font-size: var(--text-xs); font-weight: 600; }
2395
+ .theme-token-swatch { width: 44px; min-width: 44px; height: 44px; padding: 0.2rem; cursor: pointer; }
2396
+ .theme-token-swatch:disabled { cursor: not-allowed; opacity: 0.58; }
2397
+ .theme-token-value { width: 100%; min-width: 0; }
2398
+ .theme-token-swatch-note { grid-column: 1 / -1; min-width: 0; overflow-wrap: anywhere; color: var(--ctp-subtext); font-size: var(--text-xs); }
2399
+ .theme-customizer-optional-fields { display: grid; gap: 0.75rem; padding: 0 0.75rem 0.75rem; }
2400
+ .theme-customizer-optional-fields fieldset { min-width: 0; margin: 0; border-color: rgba(180, 190, 254, 0.18); }
2401
+ .theme-customizer-export-fields {
2402
+ display: grid;
2403
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
2404
+ gap: 0.55rem;
2405
+ }
2406
+ .theme-customizer-export-fields label { display: grid; min-width: 0; gap: 0.28rem; font-size: var(--text-sm); font-weight: 800; }
2407
+ .theme-customizer-export-fields input { width: 100%; min-width: 0; }
2408
+ .theme-customizer-json { min-height: 22rem; resize: vertical; border: 0; border-top: 1px solid var(--border); border-radius: 0 0 0.8rem 0.8rem; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.82rem; }
2409
+ .theme-customizer-overwrite { padding: 0.8rem; border: 1px solid rgba(243, 139, 168, 0.48); border-radius: 0.8rem; background: rgba(243, 139, 168, 0.1); }
2410
+ .theme-customizer-overwrite p { margin: 0.35rem 0 0.65rem; }
2411
+ .theme-customizer-status { min-height: 1.4rem; margin: 0; line-height: 1.4; }
2412
+ .theme-customizer-status.error { color: var(--danger); }
2413
+ .theme-customizer-status.success { color: var(--ok); }
2414
+ .theme-customizer-status.warn { color: var(--warning); }
2415
+ .theme-customizer-actions {
2416
+ display: flex;
2417
+ justify-content: flex-end;
2418
+ gap: 0.55rem;
2419
+ margin: 0;
2420
+ padding: 0.75rem max(1.1rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(1.1rem, env(safe-area-inset-left));
2421
+ border-top: 1px solid var(--border);
2422
+ }
2423
+ @media (max-width: 720px), (pointer: coarse) and (hover: none) {
2424
+ .theme-customizer-dialog {
2425
+ width: 100vw;
2426
+ height: var(--visual-viewport-height, 100dvh);
2427
+ max-height: var(--visual-viewport-height, 100dvh);
2428
+ margin: 0;
2429
+ border-radius: 0;
2430
+ }
2431
+ .theme-customizer-header { padding-top: max(0.8rem, env(safe-area-inset-top)); }
2432
+ .theme-customizer-header { display: grid; }
2433
+ .theme-customizer-identity,
2434
+ .theme-token-grid,
2435
+ .theme-customizer-export-fields { grid-template-columns: minmax(0, 1fr); }
2436
+ .theme-token-row { grid-template-columns: minmax(0, 1fr) 44px; }
2437
+ .theme-token-value { grid-column: 1 / -1; min-height: 44px; }
2438
+ .theme-customizer-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
2439
+ .theme-customizer-actions button { min-height: 44px; padding-inline: 0.35rem; }
2440
+ }
2274
2441
  .background-input {
2275
2442
  position: absolute;
2276
2443
  width: 1px;
@@ -3849,44 +4016,6 @@ button.subagent-gate-attempt:focus-visible {
3849
4016
  .terminal-tabs-toggle-button { display: none; }
3850
4017
  .terminal-sidebar-actions { display: contents; }
3851
4018
  .terminal-sidebar-action-label { display: none; }
3852
- .terminal-split-button {
3853
- flex: 0 0 auto;
3854
- display: inline-grid;
3855
- place-items: center;
3856
- width: 2.5rem;
3857
- min-width: 2.5rem;
3858
- min-height: 2.35rem;
3859
- padding: 0.38rem;
3860
- color: var(--ctp-blue);
3861
- white-space: nowrap;
3862
- border-color: rgba(137, 180, 250, 0.32);
3863
- background:
3864
- linear-gradient(120deg, rgba(137, 180, 250, 0.12), rgba(148, 226, 213, 0.08)),
3865
- rgba(var(--ctp-crust-rgb), 0.62);
3866
- }
3867
- .terminal-split-button[aria-pressed="true"] {
3868
- color: var(--ctp-teal);
3869
- border-color: rgba(148, 226, 213, 0.48);
3870
- box-shadow: 0 0 1rem rgba(148, 226, 213, 0.16), inset 0 1px 0 rgba(255,255,255,0.05);
3871
- }
3872
- .terminal-split-button:hover,
3873
- .terminal-split-button:focus-visible {
3874
- color: #11111b;
3875
- border-color: transparent;
3876
- background: linear-gradient(120deg, var(--ctp-blue), var(--ctp-teal));
3877
- }
3878
- .terminal-split-icon {
3879
- display: block;
3880
- width: 1.18rem;
3881
- height: 1.18rem;
3882
- }
3883
- .terminal-split-icon-unsplit,
3884
- .terminal-split-button[aria-pressed="true"] .terminal-split-icon-split {
3885
- display: none;
3886
- }
3887
- .terminal-split-button[aria-pressed="true"] .terminal-split-icon-unsplit {
3888
- display: block;
3889
- }
3890
4019
  .terminal-workspace-save-button {
3891
4020
  flex: 0 0 auto;
3892
4021
  display: inline-grid;
@@ -4156,6 +4285,8 @@ button.subagent-gate-attempt:focus-visible {
4156
4285
  background: linear-gradient(120deg, rgba(137, 180, 250, 0.18), rgba(203, 166, 247, 0.12));
4157
4286
  }
4158
4287
  .terminal-tab-button,
4288
+ .terminal-tab-split-button,
4289
+ .terminal-tab-summary-button,
4159
4290
  .terminal-tab-close,
4160
4291
  .terminal-new-tab-button {
4161
4292
  min-height: 2.35rem;
@@ -4303,6 +4434,8 @@ button.subagent-gate-attempt:focus-visible {
4303
4434
  50% { opacity: 1; box-shadow: 0 0 0.95rem rgba(137, 180, 250, 0.44); }
4304
4435
  }
4305
4436
  .terminal-tab-button:hover,
4437
+ .terminal-tab-split-button:hover,
4438
+ .terminal-tab-summary-button:hover,
4306
4439
  .terminal-tab-close:hover,
4307
4440
  .terminal-new-tab-button:hover {
4308
4441
  transform: none;
@@ -4337,10 +4470,70 @@ button.subagent-gate-attempt:focus-visible {
4337
4470
  .terminal-tab-group-item.activity-blocked > .terminal-tab-button .terminal-tab-meta { color: rgba(250, 179, 135, 0.88); }
4338
4471
  .terminal-tab.activity-done > .terminal-tab-button .terminal-tab-meta,
4339
4472
  .terminal-tab-group-item.activity-done > .terminal-tab-button .terminal-tab-meta { color: rgba(166, 227, 161, 0.82); }
4473
+ .terminal-tab-actions {
4474
+ position: relative;
4475
+ flex: 0 0 2rem;
4476
+ display: flex;
4477
+ flex-direction: column;
4478
+ align-self: stretch;
4479
+ min-width: 2rem;
4480
+ min-height: 2.35rem;
4481
+ border-left: 1px solid rgba(203, 166, 247, 0.16);
4482
+ }
4483
+ .terminal-tab-split-button,
4484
+ .terminal-tab-summary-button {
4485
+ position: relative;
4486
+ flex: 1 1 50%;
4487
+ display: inline-grid;
4488
+ place-items: center;
4489
+ min-width: 0;
4490
+ min-height: 0;
4491
+ padding: 0;
4492
+ }
4493
+ .terminal-tab-split-button {
4494
+ color: var(--ctp-blue);
4495
+ }
4496
+ .terminal-tab-split-button:not(:only-child) {
4497
+ border-bottom: 1px solid rgba(137, 180, 250, 0.16);
4498
+ }
4499
+ .terminal-tab-split-button[aria-pressed="true"] {
4500
+ color: var(--ctp-teal);
4501
+ background: rgba(148, 226, 213, 0.12);
4502
+ }
4503
+ .terminal-tab-split-button:hover:not(:disabled),
4504
+ .terminal-tab-split-button:focus-visible {
4505
+ color: #11111b;
4506
+ background: linear-gradient(120deg, var(--ctp-blue), var(--ctp-teal));
4507
+ }
4508
+ .terminal-tab-summary-button {
4509
+ color: var(--ctp-mauve);
4510
+ }
4511
+ .terminal-tab-summary-button:hover:not(:disabled),
4512
+ .terminal-tab-summary-button:focus-visible {
4513
+ color: #11111b;
4514
+ background: linear-gradient(120deg, var(--ctp-mauve), var(--ctp-blue));
4515
+ }
4516
+ .terminal-tab-split-button:disabled,
4517
+ .terminal-tab-summary-button:disabled {
4518
+ color: rgba(var(--ctp-subtext-rgb), 0.58);
4519
+ cursor: progress;
4520
+ background: rgba(var(--ctp-surface-rgb), 0.18);
4521
+ }
4522
+ .terminal-tab-action-icon,
4523
+ .terminal-tab-summary-button svg {
4524
+ width: 0.72rem;
4525
+ height: 0.72rem;
4526
+ }
4527
+ .terminal-tab-summary-button[aria-busy="true"] svg {
4528
+ animation: terminal-summary-pulse 1.1s ease-in-out infinite alternate;
4529
+ }
4530
+ .terminal-tab-group-item > .terminal-tab-actions {
4531
+ background-color: rgba(203, 166, 247, 0.04);
4532
+ }
4340
4533
  .terminal-tab-close {
4341
4534
  flex: 0 0 2.1rem;
4342
4535
  color: rgba(var(--ctp-subtext-rgb), 0.72);
4343
- border-left: 1px solid rgba(180, 190, 254, 0.10);
4536
+ border-left: 1px solid rgba(243, 139, 168, 0.14);
4344
4537
  font-size: 1.2rem;
4345
4538
  line-height: 1;
4346
4539
  }
@@ -4525,7 +4718,7 @@ button.subagent-gate-attempt:focus-visible {
4525
4718
  }
4526
4719
  body.terminal-tabs-left .terminal-sidebar-actions {
4527
4720
  display: grid;
4528
- grid-template-columns: repeat(5, minmax(0, 1fr));
4721
+ grid-template-columns: repeat(3, minmax(0, 1fr));
4529
4722
  gap: 0.42rem;
4530
4723
  width: 100%;
4531
4724
  padding: 0.42rem;
@@ -13145,8 +13338,7 @@ button.git-workflow-step { min-height: 1.9rem; }
13145
13338
  min-height: 0;
13146
13339
  max-height: calc(var(--visual-viewport-height, 100dvh) - 2rem);
13147
13340
  }
13148
- .terminal-split-shell,
13149
- .terminal-split-button {
13341
+ .terminal-split-shell {
13150
13342
  display: none !important;
13151
13343
  }
13152
13344
  .file-viewer-pane {
@@ -13410,6 +13602,7 @@ button.git-workflow-step { min-height: 1.9rem; }
13410
13602
  overflow: visible;
13411
13603
  }
13412
13604
  .terminal-tab-button,
13605
+ .terminal-tab-actions,
13413
13606
  .terminal-tab-close,
13414
13607
  .terminal-new-tab-button,
13415
13608
  .terminal-new-tab-menu-item,
@@ -13417,11 +13610,12 @@ button.git-workflow-step { min-height: 1.9rem; }
13417
13610
  .terminal-tab-button { padding: 0.32rem 0.52rem; }
13418
13611
  .terminal-tab-title { font-size: 0.78rem; }
13419
13612
  .terminal-tab-meta { display: none; }
13613
+ .terminal-tab-actions,
13420
13614
  .terminal-tab-close {
13421
13615
  flex-basis: 44px;
13422
13616
  min-width: 44px;
13423
- font-size: 1rem;
13424
13617
  }
13618
+ .terminal-tab-close { font-size: 1rem; }
13425
13619
  .terminal-new-tab-button {
13426
13620
  width: auto;
13427
13621
  padding: 0.36rem 0.58rem;
@@ -13962,6 +14156,13 @@ button.git-workflow-step { min-height: 1.9rem; }
13962
14156
  overflow: auto;
13963
14157
  border-radius: 1rem 1rem 0 0;
13964
14158
  }
14159
+ .extension-dialog.theme-customizer-dialog {
14160
+ inset: 0;
14161
+ height: var(--visual-viewport-height, 100dvh);
14162
+ max-height: var(--visual-viewport-height, 100dvh);
14163
+ overflow: hidden;
14164
+ border-radius: 0;
14165
+ }
13965
14166
  .extension-dialog.questionnaire-dialog {
13966
14167
  width: 100vw;
13967
14168
  max-height: calc(var(--visual-viewport-height, 100dvh) - 0.5rem - env(safe-area-inset-top));
@@ -14427,18 +14628,18 @@ button.git-workflow-step { min-height: 1.9rem; }
14427
14628
  right: auto;
14428
14629
  bottom: calc(100% + 0.62rem);
14429
14630
  z-index: 220;
14430
- width: calc(400% + 1.26rem);
14631
+ width: calc(300% + 0.84rem);
14431
14632
  max-width: none;
14432
14633
  transform: translateY(0.2rem);
14433
14634
  }
14434
14635
  body.terminal-tabs-left .terminal-workspace-save-button[data-tooltip]::after {
14435
- left: calc(-100% - 0.42rem);
14636
+ left: 0;
14436
14637
  }
14437
14638
  body.terminal-tabs-left .terminal-command-palette-button[data-tooltip]::after {
14438
- left: calc(-200% - 0.84rem);
14639
+ left: calc(-100% - 0.42rem);
14439
14640
  }
14440
14641
  body.terminal-tabs-left .terminal-dashboard-button[data-tooltip]::after {
14441
- left: calc(-300% - 1.26rem);
14642
+ left: calc(-200% - 0.84rem);
14442
14643
  }
14443
14644
  body.terminal-tabs-left .terminal-workspace-save-button[data-tooltip]:hover::after,
14444
14645
  body.terminal-tabs-left .terminal-workspace-save-button[data-tooltip]:focus-visible::after,
@@ -16769,28 +16970,7 @@ html[data-density="compact"] .composer { padding-block: 0.5rem; }
16769
16970
  .issue-wizard-actions #issueWizardBotButton { grid-column: 1 / -1; }
16770
16971
  }
16771
16972
 
16772
- /* Native Pi session-summary controls and non-blocking Markdown panel. */
16773
- .terminal-summary-button {
16774
- position: relative;
16775
- flex: 0 0 auto;
16776
- display: inline-grid;
16777
- place-items: center;
16778
- width: 34px;
16779
- height: 30px;
16780
- padding: 0;
16781
- border: 1px solid rgba(203, 166, 247, 0.28);
16782
- border-radius: 0.62rem;
16783
- color: var(--ctp-mauve);
16784
- background: linear-gradient(120deg, rgba(203, 166, 247, 0.13), rgba(137, 180, 250, 0.08)), rgba(var(--ctp-crust-rgb), 0.58);
16785
- }
16786
- .terminal-summary-button:hover:not(:disabled),
16787
- .terminal-summary-button:focus-visible {
16788
- color: #11111b;
16789
- border-color: transparent;
16790
- background: linear-gradient(120deg, var(--ctp-mauve), var(--ctp-blue));
16791
- }
16792
- .terminal-summary-button svg { width: 1.08rem; height: 1.08rem; }
16793
- .terminal-summary-button[aria-busy="true"] svg { animation: terminal-summary-pulse 1.1s ease-in-out infinite alternate; }
16973
+ /* Native Pi session-summary setup and non-blocking Markdown panel. */
16794
16974
  @keyframes terminal-summary-pulse { to { opacity: 0.38; transform: scale(0.9); } }
16795
16975
  .native-settings-textarea-field { min-width: 0; }
16796
16976
  .native-settings-textarea {
@@ -16839,7 +17019,6 @@ html[data-density="compact"] .composer { padding-block: 0.5rem; }
16839
17019
  .session-summary-overlay-actions button { min-width: 5.5rem; }
16840
17020
 
16841
17021
  @media (max-width: 720px), (max-device-width: 720px), (pointer: coarse) and (hover: none) {
16842
- .terminal-summary-button { width: 32px; min-height: 28px; border-radius: 0.58rem; }
16843
17022
  .session-summary-overlay {
16844
17023
  inset: auto 0 0;
16845
17024
  width: 100vw;
@@ -0,0 +1,244 @@
1
+ export const PI_THEME_SCHEMA_URL = "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json";
2
+
3
+ export const THEME_TOKEN_GROUPS = Object.freeze([
4
+ { id: "core", label: "Core UI", tokens: [
5
+ ["accent", "Accent"], ["border", "Border"], ["borderAccent", "Accent border"],
6
+ ["borderMuted", "Muted border"], ["success", "Success"], ["error", "Error"],
7
+ ["warning", "Warning"], ["muted", "Muted text"], ["dim", "Dim text"],
8
+ ["text", "Text"], ["thinkingText", "Thinking text"],
9
+ ] },
10
+ { id: "content", label: "Backgrounds & Content", tokens: [
11
+ ["selectedBg", "Selected background"], ["userMessageBg", "User message background"],
12
+ ["userMessageText", "User message text"], ["customMessageBg", "Custom message background"],
13
+ ["customMessageText", "Custom message text"], ["customMessageLabel", "Custom message label"],
14
+ ["toolPendingBg", "Pending tool background"], ["toolSuccessBg", "Successful tool background"],
15
+ ["toolErrorBg", "Failed tool background"], ["toolTitle", "Tool title"], ["toolOutput", "Tool output"],
16
+ ] },
17
+ { id: "markdown", label: "Markdown", tokens: [
18
+ ["mdHeading", "Heading"], ["mdLink", "Link"], ["mdLinkUrl", "Link URL"],
19
+ ["mdCode", "Inline code"], ["mdCodeBlock", "Code block"], ["mdCodeBlockBorder", "Code block border"],
20
+ ["mdQuote", "Quote"], ["mdQuoteBorder", "Quote border"], ["mdHr", "Horizontal rule"],
21
+ ["mdListBullet", "List bullet"],
22
+ ] },
23
+ { id: "diffs", label: "Tool Diffs", tokens: [
24
+ ["toolDiffAdded", "Added line"], ["toolDiffRemoved", "Removed line"], ["toolDiffContext", "Context line"],
25
+ ] },
26
+ { id: "syntax", label: "Syntax Highlighting", tokens: [
27
+ ["syntaxComment", "Comment"], ["syntaxKeyword", "Keyword"], ["syntaxFunction", "Function"],
28
+ ["syntaxVariable", "Variable"], ["syntaxString", "String"], ["syntaxNumber", "Number"],
29
+ ["syntaxType", "Type"], ["syntaxOperator", "Operator"], ["syntaxPunctuation", "Punctuation"],
30
+ ] },
31
+ { id: "thinking", label: "Thinking Levels", tokens: [
32
+ ["thinkingOff", "Off"], ["thinkingMinimal", "Minimal"], ["thinkingLow", "Low"],
33
+ ["thinkingMedium", "Medium"], ["thinkingHigh", "High"], ["thinkingXhigh", "Extra high"],
34
+ ] },
35
+ { id: "bash", label: "Bash Mode", tokens: [["bashMode", "Bash mode"]] },
36
+ ].map((group) => Object.freeze({
37
+ ...group,
38
+ tokens: Object.freeze(group.tokens.map(([name, label]) => Object.freeze({ name, label }))),
39
+ })));
40
+
41
+ export const REQUIRED_THEME_TOKENS = Object.freeze(THEME_TOKEN_GROUPS.flatMap((group) => group.tokens.map(({ name }) => name)));
42
+ export const OPTIONAL_THEME_TOKENS = Object.freeze(["thinkingMax"]);
43
+ export const PI_THEME_EXPORT_FIELDS = Object.freeze(["pageBg", "cardBg", "infoBg"]);
44
+ export const WEBUI_THEME_EXPORT_FIELDS = Object.freeze([
45
+ "backgroundImage", "backgroundOverlay", "backgroundSize", "backgroundPosition", "backgroundRepeat",
46
+ ]);
47
+
48
+ const ROOT_FIELDS = new Set(["$schema", "name", "vars", "colors", "export"]);
49
+ const COLOR_FIELDS = new Set([...REQUIRED_THEME_TOKENS, ...OPTIONAL_THEME_TOKENS]);
50
+ const EXPORT_FIELDS = new Set([...PI_THEME_EXPORT_FIELDS, ...WEBUI_THEME_EXPORT_FIELDS]);
51
+ const FILE_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,74}\.json$/;
52
+ const HEX_COLOR_PATTERN = /^#[0-9a-fA-F]{6}$/;
53
+
54
+ export class ThemeContractError extends Error {
55
+ constructor(message, issues = []) {
56
+ super(message);
57
+ this.name = "ThemeContractError";
58
+ this.code = "THEME_INVALID";
59
+ this.issues = issues;
60
+ }
61
+ }
62
+
63
+ function isRecord(value) {
64
+ return !!value && typeof value === "object" && !Array.isArray(value);
65
+ }
66
+
67
+ function sortedRecord(record) {
68
+ return Object.fromEntries(Object.keys(record || {}).sort().map((key) => [key, record[key]]));
69
+ }
70
+
71
+ function issue(path, message) {
72
+ return { path, message };
73
+ }
74
+
75
+ function validateValue(value, path, variableNames, issues) {
76
+ if (Number.isInteger(value)) {
77
+ if (value < 0 || value > 255) issues.push(issue(path, "must be an integer from 0 to 255"));
78
+ return;
79
+ }
80
+ if (typeof value !== "string") {
81
+ issues.push(issue(path, "must be a 6-digit hex color, xterm index, variable reference, or empty string"));
82
+ return;
83
+ }
84
+ if (value === "" || HEX_COLOR_PATTERN.test(value) || variableNames.has(value)) return;
85
+ issues.push(issue(path, `references an undeclared variable: ${JSON.stringify(value)}`));
86
+ }
87
+
88
+ function validateVariableCycles(vars, issues) {
89
+ const state = new Map();
90
+ const visit = (name, stack) => {
91
+ const current = state.get(name);
92
+ if (current === "done") return;
93
+ if (current === "visiting") {
94
+ issues.push(issue(`vars.${name}`, `contains a circular variable reference: ${[...stack, name].join(" -> ")}`));
95
+ return;
96
+ }
97
+ state.set(name, "visiting");
98
+ const value = vars[name];
99
+ if (typeof value === "string" && value !== "" && !HEX_COLOR_PATTERN.test(value) && Object.hasOwn(vars, value)) {
100
+ visit(value, [...stack, name]);
101
+ }
102
+ state.set(name, "done");
103
+ };
104
+ for (const name of Object.keys(vars)) visit(name, []);
105
+ }
106
+
107
+ export function normalizeThemeFileName(value) {
108
+ const fileName = String(value || "").trim();
109
+ if (!FILE_NAME_PATTERN.test(fileName) || fileName === ".json" || fileName.includes("..")) {
110
+ throw new ThemeContractError("Theme fileName must be a safe .json basename (letters, numbers, dots, underscores, and hyphens; 1-80 characters).", [
111
+ issue("fileName", "is not a safe theme JSON basename"),
112
+ ]);
113
+ }
114
+ return fileName;
115
+ }
116
+
117
+ export function themeNameFromFileName(value) {
118
+ return normalizeThemeFileName(value).slice(0, -5);
119
+ }
120
+
121
+ export function validateTheme(theme, { allowWebuiExport = true } = {}) {
122
+ const issues = [];
123
+ if (!isRecord(theme)) return { ok: false, issues: [issue("theme", "must be an object")] };
124
+
125
+ for (const key of Object.keys(theme)) {
126
+ if (!ROOT_FIELDS.has(key)) issues.push(issue(key, "is not a supported Pi theme field"));
127
+ }
128
+ if (typeof theme.name !== "string" || theme.name.length === 0 || theme.name.includes("/")) {
129
+ issues.push(issue("name", "must be a non-empty string containing no slash"));
130
+ }
131
+ if (theme.$schema !== undefined && (typeof theme.$schema !== "string" || !theme.$schema.trim())) {
132
+ issues.push(issue("$schema", "must be a non-empty string when present"));
133
+ }
134
+
135
+ const vars = theme.vars === undefined ? {} : theme.vars;
136
+ if (!isRecord(vars)) issues.push(issue("vars", "must be an object when present"));
137
+ const safeVars = isRecord(vars) ? vars : {};
138
+ const variableNames = new Set(Object.keys(safeVars));
139
+ for (const name of variableNames) {
140
+ if (!name || HEX_COLOR_PATTERN.test(name)) issues.push(issue(`vars.${name}`, "must be a non-empty non-hex variable name"));
141
+ validateValue(safeVars[name], `vars.${name}`, variableNames, issues);
142
+ }
143
+ validateVariableCycles(safeVars, issues);
144
+
145
+ if (!isRecord(theme.colors)) {
146
+ issues.push(issue("colors", "must be an object"));
147
+ } else {
148
+ for (const key of Object.keys(theme.colors)) {
149
+ if (!COLOR_FIELDS.has(key)) issues.push(issue(`colors.${key}`, "is not a supported Pi color token"));
150
+ }
151
+ for (const token of REQUIRED_THEME_TOKENS) {
152
+ if (!Object.hasOwn(theme.colors, token)) issues.push(issue(`colors.${token}`, "is required"));
153
+ }
154
+ for (const token of [...REQUIRED_THEME_TOKENS, ...OPTIONAL_THEME_TOKENS]) {
155
+ if (Object.hasOwn(theme.colors, token)) validateValue(theme.colors[token], `colors.${token}`, variableNames, issues);
156
+ }
157
+ }
158
+
159
+ if (theme.export !== undefined) {
160
+ if (!isRecord(theme.export)) {
161
+ issues.push(issue("export", "must be an object when present"));
162
+ } else {
163
+ for (const key of Object.keys(theme.export)) {
164
+ if (!EXPORT_FIELDS.has(key) || (!allowWebuiExport && WEBUI_THEME_EXPORT_FIELDS.includes(key))) {
165
+ issues.push(issue(`export.${key}`, "is not a supported Pi theme export field"));
166
+ }
167
+ }
168
+ for (const key of PI_THEME_EXPORT_FIELDS) {
169
+ if (Object.hasOwn(theme.export, key)) validateValue(theme.export[key], `export.${key}`, variableNames, issues);
170
+ }
171
+ for (const key of WEBUI_THEME_EXPORT_FIELDS) {
172
+ if (Object.hasOwn(theme.export, key) && typeof theme.export[key] !== "string") {
173
+ issues.push(issue(`export.${key}`, "must be a string"));
174
+ }
175
+ }
176
+ }
177
+ }
178
+ return { ok: issues.length === 0, issues };
179
+ }
180
+
181
+ export function canonicalizeTheme(theme, options = {}) {
182
+ const result = validateTheme(theme, options);
183
+ if (!result.ok) throw new ThemeContractError(`Invalid Pi theme: ${result.issues.map(({ path, message }) => `${path} ${message}`).join("; ")}`, result.issues);
184
+ const canonical = {
185
+ $schema: typeof theme.$schema === "string" && theme.$schema.trim() ? theme.$schema.trim() : PI_THEME_SCHEMA_URL,
186
+ name: theme.name,
187
+ };
188
+ if (theme.vars && Object.keys(theme.vars).length) canonical.vars = sortedRecord(theme.vars);
189
+ canonical.colors = {};
190
+ for (const token of REQUIRED_THEME_TOKENS) canonical.colors[token] = theme.colors[token];
191
+ if (Object.hasOwn(theme.colors, "thinkingMax")) canonical.colors.thinkingMax = theme.colors.thinkingMax;
192
+ if (theme.export) {
193
+ const exportColors = {};
194
+ for (const key of PI_THEME_EXPORT_FIELDS) {
195
+ if (Object.hasOwn(theme.export, key)) exportColors[key] = theme.export[key];
196
+ }
197
+ if (Object.keys(exportColors).length) canonical.export = exportColors;
198
+ }
199
+ return canonical;
200
+ }
201
+
202
+ export function serializeTheme(theme, options = {}) {
203
+ return `${JSON.stringify(canonicalizeTheme(theme, options), null, 2)}\n`;
204
+ }
205
+
206
+ export function effectiveThemeColors(theme) {
207
+ const canonical = canonicalizeTheme(theme, { allowWebuiExport: true });
208
+ return {
209
+ ...canonical.colors,
210
+ thinkingMax: canonical.colors.thinkingMax ?? canonical.colors.thinkingXhigh,
211
+ };
212
+ }
213
+
214
+ export function resolveThemeColor(value, vars = {}, stack = []) {
215
+ if (value === "" || typeof value === "number" || HEX_COLOR_PATTERN.test(String(value))) return value;
216
+ if (typeof value !== "string" || !Object.hasOwn(vars, value)) throw new ThemeContractError(`Unknown theme variable: ${String(value)}`);
217
+ if (stack.includes(value)) throw new ThemeContractError(`Circular theme variable: ${[...stack, value].join(" -> ")}`);
218
+ return resolveThemeColor(vars[value], vars, [...stack, value]);
219
+ }
220
+
221
+ export function xterm256ToRgb(index) {
222
+ if (!Number.isInteger(index) || index < 0 || index > 255) throw new RangeError("xterm color index must be an integer from 0 to 255");
223
+ const ansi = [
224
+ "#000000", "#800000", "#008000", "#808000", "#000080", "#800080", "#008080", "#c0c0c0",
225
+ "#808080", "#ff0000", "#00ff00", "#ffff00", "#0000ff", "#ff00ff", "#00ffff", "#ffffff",
226
+ ];
227
+ if (index < 16) return ansi[index];
228
+ if (index >= 232) {
229
+ const level = 8 + (index - 232) * 10;
230
+ return `#${level.toString(16).padStart(2, "0").repeat(3)}`;
231
+ }
232
+ const offset = index - 16;
233
+ const levels = [0, 95, 135, 175, 215, 255];
234
+ const red = levels[Math.floor(offset / 36)];
235
+ const green = levels[Math.floor((offset % 36) / 6)];
236
+ const blue = levels[offset % 6];
237
+ return `#${[red, green, blue].map((channel) => channel.toString(16).padStart(2, "0")).join("")}`;
238
+ }
239
+
240
+ export function themeColorToRgb(value, vars = {}, fallback = "#000000") {
241
+ const resolved = resolveThemeColor(value, vars);
242
+ if (resolved === "") return fallback;
243
+ return typeof resolved === "number" ? xterm256ToRgb(resolved) : resolved.toLowerCase();
244
+ }