@pactor-app/chat 1.16.0 → 1.17.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pactor-app/chat",
3
- "version": "1.16.0",
3
+ "version": "1.17.1",
4
4
  "description": "Pactor chat: AI message rendering protocol (message model, streaming reducer, safe registry, capability action) and chat runtime view (ChatView / MessageBubble / PartRenderer / Composer / chat layout)",
5
5
  "keywords": [
6
6
  "pactor",
@@ -49,11 +49,11 @@
49
49
  "access": "public"
50
50
  },
51
51
  "dependencies": {
52
- "@pactor-app/core": "1.16.0",
53
- "@pactor-app/permission": "1.16.0",
54
- "@pactor-app/runtime": "1.16.0",
55
- "@pactor-app/markdown": "1.16.0",
56
- "@pactor-app/ui": "1.16.0"
52
+ "@pactor-app/core": "1.17.1",
53
+ "@pactor-app/permission": "1.17.1",
54
+ "@pactor-app/markdown": "1.17.1",
55
+ "@pactor-app/ui": "1.17.1",
56
+ "@pactor-app/runtime": "1.17.1"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "react": ">=18"
package/styles.css CHANGED
@@ -54,6 +54,17 @@
54
54
  transparent
55
55
  );
56
56
  --pactor-chat-code-bg: var(--muted, #f6f7f9);
57
+ /* 产出物卡片图标盒 tone 配色(表格 green / 数据 amber / 代码 blue /
58
+ 图片 violet;文档与兜底走 --pactor-chat-muted(-fg) 不入列)。
59
+ 暗色值见下方 [data-pactor-theme='dark'] 载体块 */
60
+ --pactor-chat-artifact-tone-green-fg: #16a34a;
61
+ --pactor-chat-artifact-tone-green-bg: #dcfce7;
62
+ --pactor-chat-artifact-tone-blue-fg: #2563eb;
63
+ --pactor-chat-artifact-tone-blue-bg: #dbeafe;
64
+ --pactor-chat-artifact-tone-amber-fg: #d97706;
65
+ --pactor-chat-artifact-tone-amber-bg: #fef3c7;
66
+ --pactor-chat-artifact-tone-violet-fg: #7c3aed;
67
+ --pactor-chat-artifact-tone-violet-bg: #ede9fe;
57
68
  /* 旧通用圆角令牌(保留兼容);新组件改用下方圆角阶梯 */
58
69
  --pactor-chat-radius: 12px;
59
70
  /* 圆角阶梯:sm 控件 / md 卡片 / lg 气泡 / xl composer */
@@ -77,10 +88,10 @@
77
88
  --pactor-chat-shell-scrim: rgb(0 0 0 / 40%);
78
89
  /* 产出物面板(spec: chat-artifact-panel):桌面固定宽右栏。
79
90
  默认宽与对话列一致(--pactor-chat-content-width),
80
- 拖拽调宽下限为 --pactor-chat-inspector-min-width;
91
+ 宽度夹取 [--pactor-chat-inspector-min-width, host 宽 2/3];
81
92
  背景略深于聊天区底色,视觉上与消息流区分 */
82
93
  --pactor-chat-inspector-width: var(--pactor-chat-content-width);
83
- --pactor-chat-inspector-min-width: 320px;
94
+ --pactor-chat-inspector-min-width: 480px;
84
95
  --pactor-chat-inspector-bg: color-mix(
85
96
  in srgb,
86
97
  var(--pactor-chat-bg) 96%,
@@ -115,6 +126,15 @@
115
126
  0 1px 2px rgb(0 0 0 / 4%),
116
127
  0 12px 32px -10px rgb(0 0 0 / 55%);
117
128
  --pactor-chat-shell-scrim: rgb(0 0 0 / 55%);
129
+ /* 产出物卡片图标盒 tone 配色(暗色) */
130
+ --pactor-chat-artifact-tone-green-fg: #4ade80;
131
+ --pactor-chat-artifact-tone-green-bg: #14532d;
132
+ --pactor-chat-artifact-tone-blue-fg: #93c5fd;
133
+ --pactor-chat-artifact-tone-blue-bg: #1e3a8a;
134
+ --pactor-chat-artifact-tone-amber-fg: #fbbf24;
135
+ --pactor-chat-artifact-tone-amber-bg: #451a03;
136
+ --pactor-chat-artifact-tone-violet-fg: #c4b5fd;
137
+ --pactor-chat-artifact-tone-violet-bg: #2e1065;
118
138
  }
119
139
 
120
140
  /* 系统偏好暗色兜底:未显式设置 data-pactor-theme 时跟随系统
@@ -127,6 +147,15 @@
127
147
  0 1px 2px rgb(0 0 0 / 4%),
128
148
  0 12px 32px -10px rgb(0 0 0 / 55%);
129
149
  --pactor-chat-shell-scrim: rgb(0 0 0 / 55%);
150
+ /* 产出物卡片图标盒 tone 配色(暗色) */
151
+ --pactor-chat-artifact-tone-green-fg: #4ade80;
152
+ --pactor-chat-artifact-tone-green-bg: #14532d;
153
+ --pactor-chat-artifact-tone-blue-fg: #93c5fd;
154
+ --pactor-chat-artifact-tone-blue-bg: #1e3a8a;
155
+ --pactor-chat-artifact-tone-amber-fg: #fbbf24;
156
+ --pactor-chat-artifact-tone-amber-bg: #451a03;
157
+ --pactor-chat-artifact-tone-violet-fg: #c4b5fd;
158
+ --pactor-chat-artifact-tone-violet-bg: #2e1065;
130
159
  }
131
160
  }
132
161
 
@@ -191,7 +220,9 @@
191
220
 
192
221
  /* ------------------------------------------------------------
193
222
  * ChatWorkspace(spec: chat-dsl-page):createChatWorkspace 工厂
194
- * 返回组件的外层容器 = 可选头部(title + headerExtra)+ ChatView。
223
+ * 返回组件的外层容器 = 对话列(ChatView);工作区头部(header)
224
+ * 收进面板 host 的 __main 左列——面板打开时与对话区同宽(不覆盖
225
+ * 面板上方),面板关闭时随 __main 通栏;不随对话列限宽。
195
226
  * ------------------------------------------------------------ */
196
227
 
197
228
  .pactor-chat-workspace {
@@ -212,6 +243,20 @@
212
243
  line-height: 1.6;
213
244
  }
214
245
 
246
+ /* header 承载容器(无产物面板路径):header 通栏 + 主区填满剩余高度 */
247
+ .pactor-chat-with-header {
248
+ display: flex;
249
+ flex-direction: column;
250
+ height: 100%;
251
+ min-height: 0;
252
+ }
253
+
254
+ .pactor-chat-with-header > .pactor-chat-shell,
255
+ .pactor-chat-with-header > .pactor-chat-workspace {
256
+ flex: 1;
257
+ min-height: 0;
258
+ }
259
+
215
260
  .pactor-chat-workspace__header {
216
261
  display: flex;
217
262
  align-items: center;
@@ -313,10 +358,12 @@
313
358
  * 面板关闭 / 未配置时不渲染 DOM(组合层保证)。
314
359
  * ------------------------------------------------------------ */
315
360
 
316
- /* 面板打开时的同行容器:workspace(或 AppShell)与面板 flex 并排,
317
- * host 在 shell content 内撑满剩余高度与宽度 */
361
+ /* 面板打开时的容器:行内容器 __row 承载左右两列——__main 左列
362
+ * (header + 对话区,同宽;header 不覆盖面板上方)与面板右列
363
+ * (独占全高);host 在 shell content 内撑满剩余高度与宽度 */
318
364
  .pactor-chat-inspector-host {
319
365
  display: flex;
366
+ flex-direction: column;
320
367
  flex: 1;
321
368
  width: 100%;
322
369
  min-height: 0;
@@ -324,28 +371,42 @@
324
371
  background: var(--pactor-chat-bg);
325
372
  }
326
373
 
327
- /* 面板打开时 host 内的直子:AppShell 填满剩余空间;workspace 只缩不伸,
328
- * 宽度受 --pactor-chat-content-width 限宽,margin auto 在剩余空间内居中 */
329
- .pactor-chat-inspector-host > .pactor-chat-shell {
374
+ /* host 行内容器:__main 左列与面板的 flex 行(gutter 契约挂在行上——
375
+ * __main 内的 header / 对话列共享行 padding 的左 gutter) */
376
+ .pactor-chat-inspector-host__row {
377
+ display: flex;
378
+ flex: 1;
379
+ width: 100%;
380
+ min-height: 0;
381
+ }
382
+
383
+ /* __main 左列:header + 主区(AppShell / workspace)纵向堆叠,
384
+ * 宽度 = 行宽减去面板宽(面板打开时 header 与对话区同宽) */
385
+ .pactor-chat-inspector-host__main {
386
+ display: flex;
387
+ flex-direction: column;
330
388
  flex: 1;
331
389
  min-width: 0;
390
+ min-height: 0;
332
391
  }
333
392
 
334
- .pactor-chat-inspector-host > .pactor-chat-workspace {
335
- flex: 0 1 auto;
393
+ .pactor-chat-inspector-host__main > .pactor-chat-shell,
394
+ .pactor-chat-inspector-host__main > .pactor-chat-workspace {
395
+ flex: 1;
396
+ min-height: 0;
336
397
  min-width: 0;
337
398
  }
338
399
 
339
400
  /* 对话列左右最小内间距(gutter 契约,spec: chat-artifact-panel / 拖拽调宽):
340
401
  * 对话列自身的 calc 宽度在 flex 行内会把面板宽度一并计入 100% 基准,
341
402
  * shrink 后 margin auto 塌到 0;因此面板打开时的 gutter 由容器侧保证——
342
- * 左:host padding-left;右:面板 margin-left(对话列与分隔线的间距)。
343
- * 面板关闭(:has 不命中)时不加 host padding,避免与对话列 calc 重复计算 */
344
- .pactor-chat-inspector-host:has(> .pactor-chat-inspector) {
403
+ * 左:row padding-left;右:面板 margin-left(对话列与分隔线的间距)。
404
+ * 面板关闭(:has 不命中)时不加 row padding,避免与对话列 calc 重复计算 */
405
+ .pactor-chat-inspector-host__row:has(> .pactor-chat-inspector) {
345
406
  padding-left: var(--pactor-chat-content-gutter);
346
407
  }
347
408
 
348
- .pactor-chat-inspector-host > .pactor-chat-inspector {
409
+ .pactor-chat-inspector-host__row > .pactor-chat-inspector {
349
410
  margin-left: var(--pactor-chat-content-gutter);
350
411
  }
351
412
 
@@ -353,8 +414,11 @@
353
414
  position: relative;
354
415
  display: flex;
355
416
  flex-direction: column;
356
- /* 默认宽对齐对话列;上限 70% host(与拖拽夹取一致),下限 min-width 令牌 */
357
- width: min(var(--pactor-chat-inspector-width), 70%);
417
+ /* 默认宽对齐对话列;上限 host 宽 2/3(与拖拽夹取一致),下限 min-width 令牌。
418
+ * max-width 是拖拽 inline 宽度的硬兜底:inline width 不能覆盖 max-width,
419
+ * 拖拽夹取偏差 / 拖拽后窗口尺寸变化时面板也不会突破 2/3 上限 */
420
+ width: min(var(--pactor-chat-inspector-width), calc(100% * 2 / 3));
421
+ max-width: calc(100% * 2 / 3);
358
422
  min-width: var(--pactor-chat-inspector-min-width);
359
423
  flex-shrink: 0;
360
424
  border-left: 1px solid var(--pactor-chat-border);
@@ -398,9 +462,8 @@
398
462
  font-weight: 600;
399
463
  }
400
464
 
401
- /* kind 角标(与产出物卡片角标同款) */
402
- .pactor-chat-inspector__kind,
403
- .pactor-chat-artifact-card__kind {
465
+ /* kind 角标 */
466
+ .pactor-chat-inspector__kind {
404
467
  flex-shrink: 0;
405
468
  padding: 0 6px;
406
469
  border-radius: 999px;
@@ -418,47 +481,32 @@
418
481
  flex-shrink: 0;
419
482
  }
420
483
 
421
- /* 多产物 tab 条(spec: chat-artifact-panel / 多产物切换):
422
- * header 下沿横向滚动条;激活 tab 以底色 + 底部分隔反色标识 */
423
- .pactor-chat-inspector__tabs {
484
+ /* 产物切换下拉(spec: chat-artifact-panel / 多产物切换):
485
+ * header 文件名处触发器(图标 + 名称 + chevron),占用标题区剩余宽度 */
486
+ .pactor-chat-inspector__header .dropdown-menu-trigger-wrap {
487
+ flex: 1;
488
+ min-width: 0;
424
489
  display: flex;
425
- gap: 2px;
426
- padding: 4px 8px 0;
427
- border-bottom: 1px solid var(--pactor-chat-border);
428
- overflow-x: auto;
429
- flex-shrink: 0;
430
490
  }
431
491
 
432
- .pactor-chat-inspector__tab {
433
- display: flex;
492
+ .pactor-chat-inspector__menu-trigger {
493
+ display: inline-flex;
434
494
  align-items: center;
435
495
  gap: 6px;
436
- max-width: 180px;
437
- padding: 6px 10px;
438
- border: none;
439
- border-bottom: 2px solid transparent;
440
- background: transparent;
441
- color: var(--pactor-chat-muted-fg);
442
- font-size: 12px;
443
- line-height: 18px;
496
+ min-width: 0;
497
+ max-width: 100%;
498
+ padding: 3px 6px;
499
+ border-radius: var(--pactor-chat-radius-sm);
444
500
  cursor: pointer;
445
- white-space: nowrap;
446
- flex-shrink: 0;
447
- }
448
-
449
- .pactor-chat-inspector__tab:hover {
450
501
  color: var(--pactor-chat-fg);
451
502
  }
452
503
 
453
- .pactor-chat-inspector__tab[data-active='true'] {
454
- color: var(--pactor-chat-fg);
455
- border-bottom-color: var(--pactor-chat-primary);
456
- font-weight: 600;
504
+ .pactor-chat-inspector__menu-trigger:hover {
505
+ background: var(--pactor-chat-muted);
457
506
  }
458
507
 
459
- .pactor-chat-inspector__tab-title {
460
- overflow: hidden;
461
- text-overflow: ellipsis;
508
+ .pactor-chat-inspector__menu-trigger .pactor-chat-inspector__title {
509
+ min-width: 0;
462
510
  }
463
511
 
464
512
  /* 产物目录列表视图(spec: chat-artifact-panel / 产物目录):
@@ -588,8 +636,10 @@
588
636
  right: 0;
589
637
  z-index: 50;
590
638
  box-shadow: var(--pactor-chat-shadow-composer);
591
- /* 抽屉形态:宽度不超出视口,下限令牌不适用 */
639
+ /* 抽屉形态:宽度不超出视口,下限令牌不适用;
640
+ * max-width 兜底拖拽残留的 inline 宽度(桌面拖拽后切窄屏) */
592
641
  width: min(var(--pactor-chat-inspector-width), 92vw);
642
+ max-width: 92vw;
593
643
  min-width: 0;
594
644
  }
595
645
 
@@ -605,23 +655,79 @@
605
655
 
606
656
  /* ------------------------------------------------------------
607
657
  * 产出物卡片(spec: chat-artifact-panel / artifact 消息 part):
608
- * 消息流内 artifact part 的内联呈现——标题 + kind 角标 + 打开按钮。
658
+ * 消息流内 artifact part 的内联呈现——整卡可点击:着色图标盒
659
+ * (按文件类型 tone 取色)+ 标题 + 元信息行(尺寸 · 类型)+
660
+ * 右上箭头。结构与 ChatArtifactCard 内部组件一一对应。
609
661
  * ------------------------------------------------------------ */
610
662
 
611
663
  .pactor-chat-artifact-card {
612
664
  display: flex;
613
665
  align-items: center;
614
- gap: 8px;
666
+ gap: 10px;
667
+ box-sizing: border-box;
668
+ width: 100%;
615
669
  margin: 8px 0;
616
- padding: 10px 12px;
670
+ padding: 12px 14px;
617
671
  border: 1px solid var(--pactor-chat-border);
618
672
  border-radius: var(--pactor-chat-radius-md);
619
673
  background: var(--pactor-chat-card);
674
+ color: var(--pactor-chat-fg);
620
675
  box-shadow: var(--pactor-chat-shadow-sm);
676
+ font: inherit;
677
+ cursor: pointer;
678
+ text-align: left;
679
+ transition: background-color 0.15s ease;
680
+ }
681
+
682
+ .pactor-chat-artifact-card:hover {
683
+ background: var(--pactor-chat-muted);
684
+ }
685
+
686
+ /* 着色图标盒(36px 圆角盒;tone 着色,暗色值见下方覆盖块) */
687
+ .pactor-chat-artifact-card__icon {
688
+ display: inline-flex;
689
+ align-items: center;
690
+ justify-content: center;
691
+ flex: none;
692
+ width: 36px;
693
+ height: 36px;
694
+ border-radius: var(--pactor-chat-radius-sm);
695
+ background: var(--pactor-chat-muted);
696
+ color: var(--pactor-chat-muted-fg);
697
+ }
698
+
699
+ /* 按文件类型着色(tone 见 artifact.ts resolveArtifactIcon;色值走
700
+ * --pactor-chat-artifact-tone-* 令牌,暗色经载体块覆盖、皮肤可精调):
701
+ * 表格 green / 数据 amber / 代码 blue / 图片 violet / 文档与兜底 slate */
702
+ .pactor-chat-artifact-card--green .pactor-chat-artifact-card__icon {
703
+ color: var(--pactor-chat-artifact-tone-green-fg);
704
+ background: var(--pactor-chat-artifact-tone-green-bg);
705
+ }
706
+
707
+ .pactor-chat-artifact-card--blue .pactor-chat-artifact-card__icon {
708
+ color: var(--pactor-chat-artifact-tone-blue-fg);
709
+ background: var(--pactor-chat-artifact-tone-blue-bg);
710
+ }
711
+
712
+ .pactor-chat-artifact-card--amber .pactor-chat-artifact-card__icon {
713
+ color: var(--pactor-chat-artifact-tone-amber-fg);
714
+ background: var(--pactor-chat-artifact-tone-amber-bg);
715
+ }
716
+
717
+ .pactor-chat-artifact-card--violet .pactor-chat-artifact-card__icon {
718
+ color: var(--pactor-chat-artifact-tone-violet-fg);
719
+ background: var(--pactor-chat-artifact-tone-violet-bg);
720
+ }
721
+
722
+ .pactor-chat-artifact-card__text {
723
+ display: flex;
724
+ flex-direction: column;
725
+ gap: 2px;
726
+ flex: 1 1 auto;
727
+ min-width: 0;
621
728
  }
622
729
 
623
730
  .pactor-chat-artifact-card__title {
624
- flex: 1;
625
731
  min-width: 0;
626
732
  overflow: hidden;
627
733
  text-overflow: ellipsis;
@@ -630,23 +736,45 @@
630
736
  font-size: 13px;
631
737
  }
632
738
 
633
- .pactor-chat-artifact-card__open {
634
- flex-shrink: 0;
739
+ /* 元信息行(尺寸 · 类型标签) */
740
+ .pactor-chat-artifact-card__meta {
741
+ font-size: 11px;
742
+ color: var(--pactor-chat-muted-fg);
743
+ }
744
+
745
+ /* 右上箭头(打开面板暗示) */
746
+ .pactor-chat-artifact-card__arrow {
747
+ flex: none;
748
+ color: var(--pactor-chat-muted-fg);
749
+ }
750
+
751
+ /* 连续产物卡片组(spec: chat-artifact-panel / 卡片区收起):
752
+ * 同一消息内连续 artifact part 合组;超 4 个收起,footer 右端
753
+ * 「展开 / 收起」+「查看所有产物(n) ›」(打开面板产物目录视图) */
754
+ .pactor-chat-artifact-group__footer {
755
+ display: flex;
756
+ justify-content: flex-end;
757
+ align-items: center;
758
+ gap: 12px;
759
+ margin: -2px 0 8px;
760
+ }
761
+
762
+ .pactor-chat-artifact-group__toggle,
763
+ .pactor-chat-artifact-group__all {
635
764
  display: inline-flex;
636
765
  align-items: center;
637
- gap: 4px;
638
- white-space: nowrap;
639
- padding: 4px 10px;
640
- border: 1px solid var(--pactor-chat-border);
766
+ gap: 3px;
767
+ padding: 2px 4px;
768
+ border: none;
641
769
  border-radius: var(--pactor-chat-radius-sm);
642
770
  background: transparent;
643
771
  color: var(--pactor-chat-primary);
644
772
  font-size: 12px;
645
773
  cursor: pointer;
646
- transition: background 0.15s ease;
647
774
  }
648
775
 
649
- .pactor-chat-artifact-card__open:hover {
776
+ .pactor-chat-artifact-group__toggle:hover,
777
+ .pactor-chat-artifact-group__all:hover {
650
778
  background: var(--pactor-chat-muted);
651
779
  }
652
780
 
@@ -772,7 +900,7 @@
772
900
  display: flex;
773
901
  flex-direction: column;
774
902
  gap: 16px;
775
- padding: 24px 2px 4px;
903
+ padding: 24px 2px;
776
904
  scrollbar-width: thin;
777
905
  scrollbar-color: var(--pactor-chat-border) transparent;
778
906
  -webkit-mask-image: linear-gradient(
@@ -948,7 +1076,6 @@
948
1076
  .pactor-chat-message__actions {
949
1077
  display: flex;
950
1078
  gap: 4px;
951
- opacity: 0;
952
1079
  transition: opacity 0.15s ease;
953
1080
  }
954
1081
 
@@ -962,6 +1089,19 @@
962
1089
  opacity: 1;
963
1090
  }
964
1091
 
1092
+ /* assistant 终态消息底部行:操作条 + 常显时间戳 */
1093
+ .pactor-chat-message__footer {
1094
+ display: flex;
1095
+ align-items: center;
1096
+ gap: 8px;
1097
+ }
1098
+
1099
+ .pactor-chat-message__time {
1100
+ flex-shrink: 0;
1101
+ color: var(--pactor-chat-muted-fg);
1102
+ line-height: 18px;
1103
+ }
1104
+
965
1105
  /* user 消息内联编辑框(编辑重发) */
966
1106
  .pactor-chat-message__edit {
967
1107
  display: flex;