pi-hub-server 0.4.2 → 0.9.0

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.
package/web/style.css CHANGED
@@ -16,6 +16,8 @@
16
16
  --ok: #4ade80;
17
17
  --warn: #fbbf24;
18
18
  --radius: 12px;
19
+ /* 桌面折叠态侧栏宽度(图标栏);必须与 app.js 的 SIDEBAR_RAIL 一致。 */
20
+ --sidebar-rail: 56px;
19
21
  --safe-top: env(safe-area-inset-top, 0px);
20
22
  --safe-bottom: env(safe-area-inset-bottom, 0px);
21
23
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", system-ui, sans-serif;
@@ -124,6 +126,11 @@ body {
124
126
  font-size: 12px;
125
127
  }
126
128
 
129
+ /* 登录页里的教程链接:没这行浏览器默认蓝紫在暗底上不可读 */
130
+ .hint a {
131
+ color: var(--accent);
132
+ }
133
+
127
134
  .field {
128
135
  display: flex;
129
136
  flex-direction: column;
@@ -266,11 +273,15 @@ select:focus {
266
273
  background: var(--warn);
267
274
  }
268
275
 
276
+ /* 落点由 app.js 的 openMenuAt(anchor) 现算(fixed + 视口 clamp + 越界上翻):
277
+ 以前写死 `absolute; top:48px; right:8px`,菜单挂在折叠态被 hidden 的 #btn-menu 上,
278
+ 点图标栏 ⋯ 就跑到窗口右上角(R8-F1)。 */
269
279
  .menu {
270
- position: absolute;
271
- top: calc(48px + var(--safe-top));
272
- right: 8px;
273
- z-index: 30;
280
+ position: fixed;
281
+ left: 0;
282
+ top: 0;
283
+ /* 必须高于抽屉(z-index:40)与 scrim(35):rail ⋯ 的菜单要盖在侧栏上;toast(50) 仍在上 */
284
+ z-index: 45;
274
285
  background: var(--bg-raise);
275
286
  border: 1px solid var(--line);
276
287
  border-radius: 12px;
@@ -337,6 +348,12 @@ select:focus {
337
348
  max-width: 88%;
338
349
  }
339
350
 
351
+ /* 空正文气泡(只有思考/工具、还没出文字)不画框:否则「思考过程」和工具卡之间
352
+ * 会多出一个空的白板框,看着像空行。 */
353
+ .bubble:empty {
354
+ display: none;
355
+ }
356
+
340
357
  .meta {
341
358
  font-size: 11px;
342
359
  color: var(--fg-dim);
@@ -345,42 +362,39 @@ select:focus {
345
362
  flex-wrap: wrap;
346
363
  }
347
364
 
348
- /* 消息操作行:默认淡出,指针移到消息上或键盘聚焦时亮起(移动端无 hover,直接常驻) */
349
- .msg-actions {
350
- display: flex;
351
- gap: 6px;
352
- flex-wrap: wrap;
353
- opacity: 0.55;
354
- transition: opacity 0.15s ease;
355
- }
356
-
357
- .msg:hover .msg-actions,
358
- .msg-actions:focus-within {
359
- opacity: 1;
360
- }
365
+ /* 消息操作不再常显:复制/分叉/用量走气泡上的右键 / 长按上下文菜单(见 .ctx-menu)。
366
+ * 以前常显的 `.msg-actions` 行即使 hover 才提亮也永久占一行高度(W1-a/W1-b)。 */
361
367
 
362
- @media (hover: none) {
363
- .msg-actions {
364
- opacity: 0.85;
365
- }
368
+ /* 上下文菜单:position:fixed,坐标由 app.js 按指针位置给定并在视口内 clamp。 */
369
+ .ctx-menu {
370
+ position: fixed;
371
+ z-index: 70;
372
+ min-width: 132px;
373
+ background: var(--bg-raise);
374
+ border: 1px solid var(--line);
375
+ border-radius: 10px;
376
+ padding: 4px;
377
+ display: flex;
378
+ flex-direction: column;
379
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
366
380
  }
367
381
 
368
- button.mini {
369
- border: 1px solid var(--line);
382
+ .ctx-menu button {
383
+ border: none;
370
384
  background: transparent;
371
- color: var(--fg-dim);
372
- border-radius: 999px;
373
- padding: 2px 9px;
374
- font-size: 11px;
375
- line-height: 1.6;
385
+ color: var(--fg);
386
+ text-align: left;
387
+ padding: 8px 12px;
388
+ border-radius: 7px;
389
+ font-size: 13px;
390
+ font-family: inherit;
376
391
  cursor: pointer;
377
392
  touch-action: manipulation;
378
393
  }
379
394
 
380
- button.mini:hover {
381
- color: var(--fg);
382
- border-color: var(--accent-dim);
383
- background: var(--bg-raise);
395
+ .ctx-menu button:hover,
396
+ .ctx-menu button:focus-visible {
397
+ background: var(--bg-soft);
384
398
  }
385
399
 
386
400
  .empty {
@@ -406,10 +420,54 @@ button.mini:hover {
406
420
  .md ol,
407
421
  .md blockquote,
408
422
  .md pre,
409
- .md table {
423
+ .md .table-wrap {
410
424
  margin: 0 0 8px;
411
425
  }
412
426
 
427
+ /* 表格:md 表格必须画线(此前只有 margin,纯文本一样糊在一起);
428
+ * 宽表靠 .table-wrap 横向滚动,不撑破气泡。 */
429
+ .md .table-wrap {
430
+ overflow-x: auto;
431
+ -webkit-overflow-scrolling: touch;
432
+ }
433
+
434
+ .md table {
435
+ border-collapse: collapse;
436
+ border-spacing: 0;
437
+ margin: 0;
438
+ width: auto;
439
+ max-width: 100%;
440
+ font-size: 13.5px;
441
+ line-height: 1.5;
442
+ }
443
+
444
+ .md th,
445
+ .md td {
446
+ border: 1px solid var(--line);
447
+ padding: 6px 10px;
448
+ vertical-align: top;
449
+ text-align: left;
450
+ }
451
+
452
+ .md thead th {
453
+ background: var(--bg-raise);
454
+ font-weight: 600;
455
+ color: var(--fg);
456
+ white-space: nowrap;
457
+ }
458
+
459
+ .md tbody tr:nth-child(even) {
460
+ background: rgba(255, 255, 255, 0.02);
461
+ }
462
+
463
+ .md .al-c {
464
+ text-align: center;
465
+ }
466
+
467
+ .md .al-r {
468
+ text-align: right;
469
+ }
470
+
413
471
  .md h1,
414
472
  .md h2,
415
473
  .md h3,
@@ -513,22 +571,62 @@ button.mini:hover {
513
571
  color: var(--fg-dim);
514
572
  }
515
573
 
574
+ /* 折叠头:一律带 ▸/▾ 指示器(浏览器默认三角被 list-style:none 关掉了,
575
+ * 之前完全没有可点的视觉提示,看不出能展开)。 */
576
+ .thinking-block > summary,
577
+ .tool-card > summary {
578
+ display: flex;
579
+ align-items: center;
580
+ gap: 8px;
581
+ list-style: none;
582
+ user-select: none;
583
+ }
584
+
585
+ .thinking-block > summary::before,
586
+ .tool-card > summary::before {
587
+ content: "▸";
588
+ flex: none;
589
+ font-size: 10px;
590
+ line-height: 1;
591
+ color: var(--fg-dim);
592
+ transition: transform 0.12s ease;
593
+ }
594
+
595
+ .thinking-block[open] > summary::before,
596
+ .tool-card[open] > summary::before {
597
+ transform: rotate(90deg);
598
+ }
599
+
516
600
  .thinking-block > summary {
517
601
  padding: 6px 10px;
518
602
  cursor: pointer;
519
603
  font-size: 12px;
520
604
  color: var(--fg-dim);
521
- list-style: none;
522
605
  }
523
606
 
524
- .thinking-block > summary::-webkit-details-marker {
607
+ .thinking-block > summary:hover,
608
+ .tool-card > summary:hover {
609
+ color: var(--fg);
610
+ }
611
+
612
+ .thinking-block > summary::-webkit-details-marker,
613
+ .tool-card > summary::-webkit-details-marker {
525
614
  display: none;
526
615
  }
527
616
 
617
+ .thinking-hint {
618
+ margin-left: auto;
619
+ font-size: 11px;
620
+ color: var(--fg-dim);
621
+ opacity: 0.8;
622
+ }
623
+
528
624
  .thinking-body {
529
625
  padding: 0 10px 8px;
530
626
  white-space: pre-wrap;
531
627
  line-height: 1.55;
628
+ max-height: 45vh;
629
+ overflow: auto;
532
630
  }
533
631
 
534
632
  .tool-card {
@@ -542,14 +640,6 @@ button.mini:hover {
542
640
  .tool-card > summary {
543
641
  padding: 6px 10px;
544
642
  cursor: pointer;
545
- display: flex;
546
- gap: 8px;
547
- align-items: center;
548
- list-style: none;
549
- }
550
-
551
- .tool-card > summary::-webkit-details-marker {
552
- display: none;
553
643
  }
554
644
 
555
645
  .tool-name {
@@ -558,8 +648,10 @@ button.mini:hover {
558
648
  }
559
649
 
560
650
  .tool-state {
651
+ margin-left: auto;
561
652
  color: var(--fg-dim);
562
653
  font-size: 11px;
654
+ white-space: nowrap;
563
655
  }
564
656
 
565
657
  .tool-state.err {
@@ -582,6 +674,34 @@ button.mini:hover {
582
674
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
583
675
  }
584
676
 
677
+ /* 工具卡片正文:参数段 + 结果段各自带小标题,空段不画(展开后不再是空白一片) */
678
+ .tool-section {
679
+ margin: 0 0 8px;
680
+ }
681
+
682
+ .tool-section:last-child {
683
+ margin-bottom: 0;
684
+ }
685
+
686
+ .tool-section > h4 {
687
+ margin: 0 0 3px;
688
+ font-size: 10.5px;
689
+ font-weight: 600;
690
+ letter-spacing: 0.04em;
691
+ text-transform: uppercase;
692
+ color: var(--fg-dim);
693
+ }
694
+
695
+ .tool-section > pre.is-error {
696
+ color: var(--danger);
697
+ }
698
+
699
+ .tool-empty {
700
+ font-size: 11.5px;
701
+ color: var(--fg-dim);
702
+ opacity: 0.75;
703
+ }
704
+
585
705
  .typing::after {
586
706
  content: "▌";
587
707
  animation: blink 1s steps(2) infinite;
@@ -721,12 +841,27 @@ button.mini:hover {
721
841
  }
722
842
 
723
843
  .usage-bar {
724
- display: flex;
725
- justify-content: space-between;
726
- gap: 10px;
844
+ /* 一行就够:上下文/占用/tok·s/缓存命中/成本合并成一句(W1-b),窄屏再用 CSS 切窄版。 */
727
845
  font-size: 11px;
728
846
  color: var(--fg-dim);
729
847
  padding: 0 2px;
848
+ white-space: nowrap;
849
+ overflow: hidden;
850
+ text-overflow: ellipsis;
851
+ }
852
+
853
+ #usage-narrow {
854
+ display: none;
855
+ }
856
+
857
+ @media (max-width: 419.98px) {
858
+ #usage-full {
859
+ display: none;
860
+ }
861
+
862
+ #usage-narrow {
863
+ display: inline;
864
+ }
730
865
  }
731
866
 
732
867
  .attachments {
@@ -807,6 +942,66 @@ button.mini:hover {
807
942
  display: none;
808
943
  }
809
944
 
945
+ /* 折叠态图标栏(只在桌面折叠时显示,见文末 @media (min-width:900px))。 */
946
+ .rail {
947
+ display: none;
948
+ flex: 1;
949
+ flex-direction: column;
950
+ align-items: center;
951
+ gap: 6px;
952
+ padding: 10px 0;
953
+ width: 100%;
954
+ }
955
+
956
+ .rail {
957
+ display: none;
958
+ flex: 1;
959
+ flex-direction: column;
960
+ align-items: center;
961
+ gap: 4px;
962
+ padding: 10px 0;
963
+ width: 100%;
964
+ }
965
+
966
+ /* 图标栏与顶栏同一套尺寸:36×36、圆角 8px、居中留白 10px(--sidebar-rail 56 - 36 = 20) */
967
+ .rail-logo {
968
+ width: 36px;
969
+ height: 36px;
970
+ display: inline-flex;
971
+ align-items: center;
972
+ justify-content: center;
973
+ font-size: 20px;
974
+ line-height: 1;
975
+ color: var(--fg);
976
+ }
977
+
978
+ .rail-btn {
979
+ width: 36px;
980
+ height: 36px;
981
+ display: inline-flex;
982
+ align-items: center;
983
+ justify-content: center;
984
+ border: none;
985
+ border-radius: 8px;
986
+ background: transparent;
987
+ color: var(--fg-dim);
988
+ font-size: 18px;
989
+ padding: 0;
990
+ line-height: 1;
991
+ cursor: pointer;
992
+ touch-action: manipulation;
993
+ }
994
+
995
+ .rail-btn:hover,
996
+ .rail-btn:focus-visible {
997
+ color: var(--fg);
998
+ background: var(--bg-raise);
999
+ }
1000
+
1001
+ .rail-btn:last-child {
1002
+ margin-top: auto;
1003
+ }
1004
+
810
1005
  .drawer-head {
811
1006
  display: flex;
812
1007
  align-items: center;
@@ -821,14 +1016,112 @@ button.mini:hover {
821
1016
  }
822
1017
 
823
1018
  .group-title {
1019
+ display: flex;
1020
+ align-items: center;
1021
+ gap: 4px;
824
1022
  font-size: 11px;
825
1023
  color: var(--fg-dim);
826
1024
  padding: 10px 6px 4px;
827
- text-transform: uppercase;
828
- letter-spacing: 0.04em;
1025
+ }
1026
+
1027
+ /* 分组头本体是 button(可折叠,R8-F3):chevron 旋转 + aria-expanded + 折叠态显示会话数 */
1028
+ .group-title .group-toggle {
1029
+ flex: 1;
1030
+ min-width: 0;
1031
+ display: flex;
1032
+ align-items: center;
1033
+ gap: 4px;
1034
+ border: none;
1035
+ background: transparent;
1036
+ color: inherit;
1037
+ font: inherit;
1038
+ text-align: left;
1039
+ padding: 0;
1040
+ cursor: pointer;
1041
+ }
1042
+
1043
+ .group-title .group-toggle::before {
1044
+ content: "▸";
1045
+ display: inline-block;
1046
+ flex: none;
1047
+ font-size: 9px;
1048
+ line-height: 1;
1049
+ transition: transform 0.15s ease;
1050
+ }
1051
+
1052
+ .group-title .group-toggle[aria-expanded="true"]::before {
1053
+ transform: rotate(90deg);
1054
+ }
1055
+
1056
+ .group-title .group-toggle .cwd {
1057
+ flex: 0 1 auto;
1058
+ max-width: 60%;
1059
+ min-width: 0;
1060
+ overflow: hidden;
1061
+ text-overflow: ellipsis;
1062
+ white-space: nowrap;
1063
+ color: var(--fg);
1064
+ }
1065
+
1066
+ /* 组头副行 = `~` 缩写路径(对齐安卓 WorkspaceHeader);以前这里画的是整条大写绝对路径 */
1067
+ .group-title .group-toggle .cwd-path {
1068
+ flex: 1;
1069
+ min-width: 0;
829
1070
  overflow: hidden;
830
1071
  text-overflow: ellipsis;
831
1072
  white-space: nowrap;
1073
+ font-size: 10px;
1074
+ opacity: 0.75;
1075
+ }
1076
+
1077
+ /* 折叠态才显示「N 个会话」:展开时列表本身就是答案 */
1078
+ .group-title .group-toggle .count {
1079
+ display: none;
1080
+ flex: none;
1081
+ font-size: 10px;
1082
+ opacity: 0.8;
1083
+ }
1084
+
1085
+ .group-title .group-toggle[aria-expanded="false"] .count {
1086
+ display: inline;
1087
+ }
1088
+
1089
+ /* 折叠=整块不占高度(不是 visibility/高度动画),列表无缝缩短 */
1090
+ .session-group[hidden] {
1091
+ display: none;
1092
+ }
1093
+
1094
+ /* 每个仓库分组右侧的 +:在当前 cwd 直接开新会话,不用再往下找表单 */
1095
+ .group-title .group-new {
1096
+ flex: none;
1097
+ border: 1px solid transparent;
1098
+ background: transparent;
1099
+ color: var(--fg-dim);
1100
+ font-size: 12px;
1101
+ line-height: 1;
1102
+ padding: 2px 6px;
1103
+ border-radius: 6px;
1104
+ cursor: pointer;
1105
+ }
1106
+
1107
+ .group-title .group-new:hover,
1108
+ .group-title .group-more:hover {
1109
+ color: var(--fg);
1110
+ border-color: var(--line);
1111
+ background: var(--bg-raise);
1112
+ }
1113
+
1114
+ /* 组头 ⋮(P1-11):与 + 同一档视觉,菜单走 openMenuAt(anchor) */
1115
+ .group-title .group-more {
1116
+ flex: none;
1117
+ border: 1px solid transparent;
1118
+ background: transparent;
1119
+ color: var(--fg-dim);
1120
+ font-size: 12px;
1121
+ line-height: 1;
1122
+ padding: 2px 6px;
1123
+ border-radius: 6px;
1124
+ cursor: pointer;
832
1125
  }
833
1126
 
834
1127
  .session-item {
@@ -876,14 +1169,60 @@ button.mini:hover {
876
1169
  color: var(--ok);
877
1170
  }
878
1171
 
879
- .new-session {
1172
+ .drawer-foot {
880
1173
  border-top: 1px solid var(--line);
881
- padding: 8px 10px 12px;
1174
+ flex: none;
1175
+ }
1176
+
1177
+ .new-session-toggle {
1178
+ display: flex;
1179
+ align-items: center;
1180
+ gap: 6px;
1181
+ width: 100%;
1182
+ border: none;
1183
+ background: transparent;
1184
+ color: var(--fg-dim);
1185
+ padding: 11px 14px;
1186
+ font-size: 13px;
1187
+ text-align: left;
1188
+ cursor: pointer;
1189
+ font-family: inherit;
1190
+ }
1191
+
1192
+ .new-session-toggle:hover,
1193
+ .new-session-toggle[aria-expanded="true"] {
1194
+ color: var(--fg);
1195
+ background: var(--bg-raise);
1196
+ }
1197
+
1198
+ /* 展开/收起线索(R8-F2):▸ 收起 ↔ ▾ 展开,与 aria-expanded 一一对应 */
1199
+ .new-session-toggle .caret {
1200
+ display: inline-block;
1201
+ flex: none;
1202
+ width: 10px;
1203
+ font-size: 11px;
1204
+ line-height: 1;
1205
+ }
1206
+
1207
+ .new-session-toggle .caret::before {
1208
+ content: "▸";
1209
+ }
1210
+
1211
+ .new-session-toggle[aria-expanded="true"] .caret::before {
1212
+ content: "▾";
1213
+ }
1214
+
1215
+ .new-session {
1216
+ padding: 0 10px 12px;
882
1217
  display: flex;
883
1218
  flex-direction: column;
884
1219
  gap: 8px;
885
1220
  }
886
1221
 
1222
+ .new-session[hidden] {
1223
+ display: none;
1224
+ }
1225
+
887
1226
  .scrim {
888
1227
  position: fixed;
889
1228
  inset: 0;
@@ -906,6 +1245,52 @@ button.mini:hover {
906
1245
  max-width: 90vw;
907
1246
  }
908
1247
 
1248
+ /* 常驻错误横幅(P1-9):顶栏下方、不自动消失、可手动关闭;不覆盖输入框 */
1249
+ .error-banner {
1250
+ position: fixed;
1251
+ top: calc(56px + var(--safe-top));
1252
+ left: 50%;
1253
+ transform: translateX(-50%);
1254
+ display: flex;
1255
+ align-items: center;
1256
+ gap: 10px;
1257
+ width: min(720px, calc(100vw - 24px));
1258
+ background: #2a1b1f;
1259
+ border: 1px solid var(--danger);
1260
+ color: #ffd9d9;
1261
+ padding: 8px 12px;
1262
+ border-radius: 12px;
1263
+ font-size: 12.5px;
1264
+ z-index: 44;
1265
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
1266
+ }
1267
+
1268
+ .error-banner[hidden] {
1269
+ display: none;
1270
+ }
1271
+
1272
+ .error-banner #error-banner-text {
1273
+ flex: 1;
1274
+ min-width: 0;
1275
+ overflow-wrap: anywhere;
1276
+ }
1277
+
1278
+ .error-banner button {
1279
+ flex: none;
1280
+ border: none;
1281
+ background: transparent;
1282
+ color: inherit;
1283
+ font-size: 14px;
1284
+ line-height: 1;
1285
+ padding: 4px 6px;
1286
+ border-radius: 6px;
1287
+ cursor: pointer;
1288
+ }
1289
+
1290
+ .error-banner button:hover {
1291
+ background: rgba(255, 255, 255, 0.08);
1292
+ }
1293
+
909
1294
  @media (min-width: 760px) {
910
1295
  .messages {
911
1296
  padding: 16px max(16px, calc((100% - 900px) / 2));
@@ -915,11 +1300,13 @@ button.mini:hover {
915
1300
  }
916
1301
  }
917
1302
 
918
- /* ---------- 桌面(≥900px):抽屉常驻左侧固定侧栏 ---------- */
1303
+ /* ---------- 桌面(≥900px):抽屉常驻左侧固定侧栏(可折叠为 56px 图标栏) ---------- */
919
1304
  /*
920
1305
  * 移动端抽屉是浮层(hidden 控制 + scrim),桌面上改成布局的一部分:
921
- * - 不受 `hidden` 影响(JS 里 closeDrawer() 仍可调用,窄窗口恢复原语义)
922
- * - 不画 scrim、不显示开关按钮
1306
+ * - 展开态不受 `hidden` 影响(JS 里 closeDrawer() 仍可调用,窄窗口恢复原语义)
1307
+ * - 折叠态(`body.sidebar-collapsed`)把 `--sidebar` 换成 56px 图标栏:logo/+/搜索/⋯/展开
1308
+ * 仍在(对齐 DSH 的 SIDEBAR_COLLAPSED),主区靠 `left: var(--sidebar)` 自动跟着重排(W1-c)
1309
+ * - 不画 scrim;开合入口是顶栏 ☰ / 侧栏头部收起按钮 / 图标栏展开按钮
923
1310
  * - 登录页在前时整块隐藏,避免侧栏压在登录卡上方
924
1311
  */
925
1312
  @media (min-width: 900px) {
@@ -936,6 +1323,20 @@ button.mini:hover {
936
1323
  padding-bottom: 0;
937
1324
  }
938
1325
 
1326
+ body.sidebar-collapsed {
1327
+ --sidebar: var(--sidebar-rail);
1328
+ }
1329
+
1330
+ body.sidebar-collapsed .drawer-head,
1331
+ body.sidebar-collapsed .session-list,
1332
+ body.sidebar-collapsed .drawer-foot {
1333
+ display: none;
1334
+ }
1335
+
1336
+ body.sidebar-collapsed .rail {
1337
+ display: flex;
1338
+ }
1339
+
939
1340
  #login:not([hidden]) ~ #drawer {
940
1341
  display: none !important;
941
1342
  }
@@ -944,11 +1345,6 @@ button.mini:hover {
944
1345
  display: none !important;
945
1346
  }
946
1347
 
947
- #btn-drawer,
948
- #btn-drawer-close {
949
- display: none;
950
- }
951
-
952
1348
  .app {
953
1349
  left: var(--sidebar);
954
1350
  }
package/web/sw.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // 不缓存 /v1 响应(会话与 SSE 都是实时的,缓存只会让状态错乱)。
3
3
  "use strict";
4
4
 
5
- const CACHE = "pihub-shell-v2";
5
+ const CACHE = "pihub-shell-v3";
6
6
 
7
7
  // install 阶段**不**预热外壳:原来的 `cache.addAll([...])` 会让首访多下 4 个已在路上的文件
8
8
  // (实测 `GET /` 304 + `/index.html` + `/manifest.webmanifest` 全被重复拉一次),