tavern-harness 0.1.13 → 0.1.14

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 (40) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/index.html +1 -1
  3. package/package.json +1 -1
  4. package/persistence-server.mjs +54 -2
  5. package/src/App.tsx +91 -25
  6. package/src/components/AchievementModal.tsx +4 -2
  7. package/src/components/CharactersView.tsx +53 -25
  8. package/src/components/ChatView.tsx +264 -135
  9. package/src/components/Dashboard.tsx +12 -8
  10. package/src/components/DeleteConfirmDialog.tsx +1 -1
  11. package/src/components/FileDisplayModal.tsx +1 -1
  12. package/src/components/GameplayDialogs.tsx +2 -2
  13. package/src/components/NewSessionMenu.tsx +1 -1
  14. package/src/components/SettingsView.tsx +46 -29
  15. package/src/components/Sidebar.tsx +30 -3
  16. package/src/components/StatsView.tsx +55 -45
  17. package/src/components/VersionHistoryModal.tsx +1 -1
  18. package/src/components/WorkspaceFileManagerModal.tsx +1 -1
  19. package/src/components/shared.tsx +84 -24
  20. package/src/core/achievements.ts +22 -4
  21. package/src/core/avatarThumbnail.ts +245 -0
  22. package/src/core/characterBook.ts +2 -1
  23. package/src/core/i18n.ts +42 -6
  24. package/src/core/mobileViewport.ts +18 -3
  25. package/src/core/openai.ts +41 -19
  26. package/src/core/randomId.ts +19 -0
  27. package/src/core/rowFingerprint.ts +75 -0
  28. package/src/core/stats.ts +50 -5
  29. package/src/core/stickyBottom.ts +10 -1
  30. package/src/core/textPreview.ts +16 -0
  31. package/src/db/database.ts +101 -13
  32. package/src/generated/changelog.json +87 -1
  33. package/src/main.tsx +12 -21
  34. package/src/store/store.ts +179 -53
  35. package/src/theme/chat.css +62 -71
  36. package/src/theme/global.css +85 -21
  37. package/src/theme/theme.ts +13 -10
  38. package/src/theme/views.css +82 -5
  39. package/src/types/models.ts +2 -0
  40. package/vite.config.ts +8 -2
@@ -4,7 +4,7 @@
4
4
  ============================================================ */
5
5
 
6
6
  :root {
7
- background: #F7F2E9;
7
+ background: #F7F0E4;
8
8
  color-scheme: light;
9
9
  --radius: 14px;
10
10
  --radius-lg: 18px;
@@ -34,7 +34,7 @@ body,
34
34
 
35
35
  html,
36
36
  body {
37
- background: var(--bg, #F7F2E9);
37
+ background: var(--bg, #F7F0E4);
38
38
  }
39
39
 
40
40
  body {
@@ -82,6 +82,7 @@ body {
82
82
  button {
83
83
  font-family: inherit;
84
84
  cursor: pointer;
85
+ white-space: nowrap;
85
86
  -webkit-tap-highlight-color: transparent;
86
87
  }
87
88
 
@@ -139,16 +140,6 @@ html.wechat-android .session-item * {
139
140
  -webkit-user-select: none;
140
141
  user-select: none;
141
142
  }
142
- /* 消息内联编辑 / 其它输入控件:恢复选词,避免再次出现无法聚焦或键盘被收起。 */
143
- html.wechat-android .msg-row input,
144
- html.wechat-android .msg-row textarea,
145
- html.wechat-android .msg-row [contenteditable=""],
146
- html.wechat-android .msg-row [contenteditable="true"] {
147
- -webkit-touch-callout: default;
148
- -webkit-user-select: text;
149
- user-select: text;
150
- pointer-events: auto;
151
- }
152
143
  /* 微信 Android 在气泡不可选时会“退而求其次”选中附近其它文字(典型是输入区
153
144
  左侧的模型名称)。聊天区、顶栏、底部输入区外壳一并禁止选词;真正的输入
154
145
  控件仍保持可选。注意不要作用到 .composer / .app-shell 这类输入框祖先上,
@@ -171,15 +162,6 @@ html.wechat-android .composer-model-label,
171
162
  html.wechat-android .model-option-name {
172
163
  pointer-events: none;
173
164
  }
174
- /* 聊天区里的内联消息编辑器仍然可选中。 */
175
- html.wechat-android .chat-scroll input,
176
- html.wechat-android .chat-scroll textarea,
177
- html.wechat-android .chat-scroll [contenteditable=""],
178
- html.wechat-android .chat-scroll [contenteditable="true"] {
179
- -webkit-touch-callout: default;
180
- -webkit-user-select: text;
181
- user-select: text;
182
- }
183
165
  /* 拖拽排序的卡片:任何指针下都不希望拖动过程选中文本。 */
184
166
  .sort-item,
185
167
  .list-item.sortable-skill {
@@ -190,6 +172,18 @@ html.wechat-android .chat-scroll [contenteditable="true"] {
190
172
 
191
173
  /* ---------- 启动失败 ---------- */
192
174
  /* 核心数据加载不出来时的兜底页(App.tsx 的 initStatus === 'error')。 */
175
+ .startup-loading {
176
+ position: fixed;
177
+ inset: 0;
178
+ display: grid;
179
+ place-items: center;
180
+ /* 与主内容区 .main-area 使用同一个实色底。 */
181
+ background: var(--surface);
182
+ }
183
+ .startup-loading .spinner {
184
+ width: 24px;
185
+ height: 24px;
186
+ }
193
187
  .init-error {
194
188
  position: fixed;
195
189
  inset: 0;
@@ -919,6 +913,32 @@ body.resizing .sidebar-resizer {
919
913
 
920
914
  /* 右侧所有 Tab 共用同一块主区域实色底。 */
921
915
 
916
+ /* 已访问的视图保持挂载,隐藏时跳过绘制。 */
917
+ .view-slot {
918
+ display: flex;
919
+ flex-direction: column;
920
+ flex: 1;
921
+ min-width: 0;
922
+ min-height: 0;
923
+ }
924
+ .view-slot[data-active='false'] {
925
+ display: none;
926
+ }
927
+ /* 隐藏页面在新主题下重新显示时,禁止颜色过渡首帧使用已缓存的旧色。 */
928
+ .view-slot[data-theme-reveal='true'],
929
+ .view-slot[data-theme-reveal='true'] * {
930
+ transition: none !important;
931
+ }
932
+ @supports (content-visibility: hidden) {
933
+ .view-slot[data-active='false'] {
934
+ display: flex;
935
+ position: absolute;
936
+ inset: 0;
937
+ content-visibility: hidden;
938
+ pointer-events: none;
939
+ }
940
+ }
941
+
922
942
  .chat-scroll {
923
943
  flex: 1;
924
944
  overflow-y: auto;
@@ -1386,6 +1406,12 @@ body.resizing .sidebar-resizer {
1386
1406
  0 0 0 12px rgba(255, 233, 168, 0.12),
1387
1407
  0 18px 60px rgba(240, 180, 60, 0.55);
1388
1408
  }
1409
+ .ach-trophy-image {
1410
+ width: 100%;
1411
+ height: 100%;
1412
+ border-radius: inherit;
1413
+ object-fit: cover;
1414
+ }
1389
1415
  .ach-trophy-glow {
1390
1416
  position: absolute;
1391
1417
  inset: -34px;
@@ -1640,6 +1666,44 @@ hr.sep {
1640
1666
  display: none;
1641
1667
  }
1642
1668
 
1669
+ .mobile-home-button {
1670
+ display: inline-flex;
1671
+ align-items: center;
1672
+ justify-content: center;
1673
+ width: 32px;
1674
+ height: 32px;
1675
+ flex: 0 0 32px;
1676
+ padding: 0;
1677
+ border: 1px solid transparent;
1678
+ border-radius: 50%;
1679
+ background: transparent;
1680
+ transition: all 0.32s cubic-bezier(0.16, 1, 0.3, 1);
1681
+ }
1682
+
1683
+ .mobile-home-button img {
1684
+ width: 32px;
1685
+ height: 32px;
1686
+ border-radius: 50%;
1687
+ object-fit: cover;
1688
+ transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), filter 0.32s ease;
1689
+ }
1690
+
1691
+ @media (hover: hover) {
1692
+ .mobile-home-button:hover img {
1693
+ transform: scale(0.9);
1694
+ filter: brightness(1.08);
1695
+ }
1696
+ }
1697
+
1698
+ .mobile-home-button:active img {
1699
+ transform: scale(0.84);
1700
+ }
1701
+
1702
+ .mobile-home-button:focus-visible {
1703
+ outline: 2px solid var(--primary);
1704
+ outline-offset: 2px;
1705
+ }
1706
+
1643
1707
  .mobile-topbar-nav .nav-chip {
1644
1708
  flex: 0 0 auto;
1645
1709
  }
@@ -77,6 +77,11 @@ export function applyTheme(mode: ThemeMode): void {
77
77
 
78
78
  root.dataset.theme = dark ? 'dark' : 'light';
79
79
  root.style.colorScheme = dark ? 'dark' : 'light';
80
+ root.style.backgroundColor = dark ? '#20160E' : '#F7F0E4';
81
+ document.querySelector<HTMLMetaElement>('meta[name="theme-color"]')?.setAttribute(
82
+ 'content',
83
+ dark ? '#20160E' : '#F7F0E4',
84
+ );
80
85
 
81
86
  const vars: Record<string, string> = {
82
87
  // 主色:浅色模式用深色变体(羊皮纸底上对比足够),深色模式用烛光浅亮色
@@ -87,17 +92,17 @@ export function applyTheme(mode: ThemeMode): void {
87
92
  '--grad-to': is(p.primaryLight, p.gradientTo),
88
93
  '--glow': is('color-mix(in srgb, var(--primary) 28%, transparent)', p.glow),
89
94
 
90
- '--bg': is('#F7F2E9', '#17120A'),
91
- '--bg-deep': is('#efe8da', '#0f0b06'),
92
- '--surface': is('#FDFBF5', '#211A10'),
93
- '--surface-2': is('#efe8da', '#2B2215'),
94
- '--surface-3': is('#e6ddca', '#362A1A'),
95
+ '--bg': is('#F7F0E4', '#17120A'),
96
+ '--bg-deep': is('#E9DDCA', '#0f0b06'),
97
+ '--surface': is('#FFFDF8', '#211A10'),
98
+ '--surface-2': is('#F3E7D5', '#2B2215'),
99
+ '--surface-3': is('#DFCFB8', '#362A1A'),
95
100
  '--border': is('rgba(60,40,10,0.14)', 'rgba(255,214,160,0.13)'),
96
101
  '--border-soft': is('rgba(60,40,10,0.08)', 'rgba(255,214,160,0.07)'),
97
102
 
98
- '--text': is('#241c10', '#F2EADC'),
99
- '--text-dim': is('#7a6a50', '#AA9C86'),
100
- '--text-faint': is('#a3957c', '#6f6352'),
103
+ '--text': is('#30251C', '#F2EADC'),
104
+ '--text-dim': is('#66574A', '#AA9C86'),
105
+ '--text-faint': is('#887665', '#6f6352'),
101
106
 
102
107
  // 用户气泡:全场唯一保留品牌色的实心块。浓度提到 20% 才和
103
108
  // 思考/工具的浅色卡片拉开层级(11% 时与 --surface-2 只差 3 个色阶)
@@ -145,6 +150,4 @@ export function applyThemeFromCache(): void {
145
150
  ? 'dark'
146
151
  : 'light');
147
152
  applyTheme(mode);
148
- // 背景在 body 上,确保首帧背景色一致
149
- document.documentElement.style.backgroundColor = isDarkMode(mode) ? '#20160E' : '#F7F2E9';
150
153
  }
@@ -27,7 +27,7 @@
27
27
  }
28
28
  .modal {
29
29
  pointer-events: auto;
30
- width: min(480px, calc(100vw - 32px));
30
+ width: min(640px, calc(100vw - 32px));
31
31
  max-height: calc(100dvh - 60px);
32
32
  display: flex;
33
33
  flex-direction: column;
@@ -60,14 +60,20 @@
60
60
  border-top: 1px solid var(--border);
61
61
  }
62
62
 
63
- .modal.confirm {
63
+ .modal-size-compact {
64
64
  width: min(420px, calc(100vw - 32px));
65
65
  }
66
+ .modal-size-standard {
67
+ width: min(640px, calc(100vw - 32px));
68
+ }
69
+ .modal-size-wide {
70
+ width: min(880px, calc(100vw - 32px));
71
+ }
66
72
 
67
73
  /* ---------- 大尺寸编辑弹窗(角色卡 / Lorebook) ---------- */
68
74
  .modal-editor {
69
75
  width: min(1040px, calc(100vw - 32px));
70
- height: min(90dvh, 960px);
76
+ height: min(90%, 960px);
71
77
  }
72
78
  .character-editor-modal .modal-head,
73
79
  .editor-modal-with-tabs .modal-head {
@@ -294,6 +300,13 @@
294
300
  flex-direction: column;
295
301
  gap: 16px;
296
302
  }
303
+ /* 隐藏未激活的角色工坊面板,同时保留已访问的面板状态。 */
304
+ .workshop-tab-panel {
305
+ display: contents;
306
+ }
307
+ .workshop-tab-panel[data-active='false'] {
308
+ display: none;
309
+ }
297
310
  .view-title {
298
311
  font-family: var(--font-serif);
299
312
  font-size: 24px;
@@ -606,6 +619,15 @@
606
619
  align-items: center;
607
620
  gap: 8px;
608
621
  }
622
+ .settings-section-head {
623
+ display: flex;
624
+ align-items: center;
625
+ justify-content: space-between;
626
+ gap: 12px;
627
+ }
628
+ .settings-gen-reset {
629
+ flex-shrink: 0;
630
+ }
609
631
  .settings-reset-section {
610
632
  flex-direction: row;
611
633
  align-items: center;
@@ -675,6 +697,13 @@
675
697
  font-size: 26px;
676
698
  line-height: 1;
677
699
  }
700
+ .ach-card-image {
701
+ display: block;
702
+ width: 26px;
703
+ height: 26px;
704
+ border-radius: 50%;
705
+ object-fit: cover;
706
+ }
678
707
  .ach-card-status {
679
708
  font-size: 10.5px;
680
709
  font-weight: 700;
@@ -707,6 +736,31 @@
707
736
  .ach-shelf-summary b {
708
737
  color: var(--text);
709
738
  }
739
+ .stats-reset-card {
740
+ display: flex;
741
+ align-items: center;
742
+ justify-content: space-between;
743
+ gap: 16px;
744
+ padding: 14px;
745
+ border: 1px solid color-mix(in srgb, var(--danger) 58%, var(--border));
746
+ border-radius: var(--radius);
747
+ background: color-mix(in srgb, var(--danger) 14%, var(--surface));
748
+ }
749
+ .stats-reset-card h3 {
750
+ margin: 0;
751
+ font-family: var(--font-serif);
752
+ font-size: 15.5px;
753
+ }
754
+ .stats-reset-card p {
755
+ margin: 5px 0 0;
756
+ color: var(--text-dim);
757
+ font-size: 12.5px;
758
+ line-height: 1.55;
759
+ }
760
+ .stats-reset-card:hover {
761
+ border-color: color-mix(in srgb, var(--danger) 78%, var(--border));
762
+ background: color-mix(in srgb, var(--danger) 19%, var(--surface));
763
+ }
710
764
  .set-row {
711
765
  display: flex;
712
766
  align-items: center;
@@ -1196,9 +1250,32 @@
1196
1250
 
1197
1251
  .modal {
1198
1252
  width: 100% !important;
1253
+ }
1254
+
1255
+ /* 移动端按内容层级统一高度:短操作不占满屏,阅读型弹窗保留大滚动区,
1256
+ 编辑器全屏以避免键盘改变高度时出现二段动画。 */
1257
+ .modal-size-compact {
1258
+ max-height: 48%;
1259
+ }
1260
+
1261
+ .modal-size-standard {
1262
+ max-height: 72%;
1263
+ }
1264
+
1265
+ .modal-size-wide {
1266
+ max-height: 88%;
1267
+ }
1268
+
1269
+ .modal-editor,
1270
+ .message-editor-modal {
1271
+ height: 100%;
1199
1272
  max-height: 100%;
1200
1273
  }
1201
1274
 
1275
+ .ws-fm-modal {
1276
+ height: min(72%, 560px);
1277
+ }
1278
+
1202
1279
  .modal-head,
1203
1280
  .modal-body,
1204
1281
  .modal-foot {
@@ -1334,7 +1411,7 @@
1334
1411
  /* ---------- 文件展示弹窗(file_display) ---------- */
1335
1412
  .display-modal {
1336
1413
  width: min(880px, calc(100vw - 32px));
1337
- height: min(82dvh, 720px);
1414
+ height: min(82%, 720px);
1338
1415
  }
1339
1416
  .display-pip {
1340
1417
  position: fixed;
@@ -1578,7 +1655,7 @@
1578
1655
  /* ---------- 会话工作区文件管理器(只读) ---------- */
1579
1656
  .ws-fm-modal {
1580
1657
  width: min(640px, calc(100vw - 32px));
1581
- height: min(70dvh, 560px);
1658
+ height: min(70%, 560px);
1582
1659
  }
1583
1660
  .ws-fm-head {
1584
1661
  gap: 10px;
@@ -193,6 +193,8 @@ export interface ChatMessage {
193
193
  toolCallsJson: string;
194
194
  toolCallId: string | null;
195
195
  thinkingContent: string | null;
196
+ /** 流式响应在生成后中断时为 true;正文可阅读,但工具调用不会执行或写入上下文。 */
197
+ interrupted?: boolean;
196
198
  /** 群聊:该消息所属的循环序号(0 起)。用于对话与发言队列联动滚动 / 点击定位 */
197
199
  loopIndex: number | null;
198
200
  timestamp: number;
package/vite.config.ts CHANGED
@@ -6,7 +6,7 @@ import net from 'node:net';
6
6
  import { randomBytes } from 'node:crypto';
7
7
  import { spawn, type ChildProcess } from 'node:child_process';
8
8
  import { readFileSync, existsSync } from 'node:fs';
9
- import { dirname, join } from 'node:path';
9
+ import { dirname, join, resolve } from 'node:path';
10
10
  import { fileURLToPath } from 'node:url';
11
11
  import { networkInterfaces } from 'node:os';
12
12
  import type { IncomingMessage, ServerResponse } from 'node:http';
@@ -246,7 +246,13 @@ function persistenceProxyPlugin(): Plugin {
246
246
  return {
247
247
  name: 'persistence-proxy',
248
248
  closeBundle: stopPersistence,
249
- configureServer: registerMiddleware,
249
+ configureServer(server) {
250
+ server.watcher.add(persistenceScript);
251
+ server.watcher.on('change', (path) => {
252
+ if (resolve(path) === persistenceScript) stopPersistence();
253
+ });
254
+ registerMiddleware(server);
255
+ },
250
256
  configurePreviewServer: registerMiddleware,
251
257
  };
252
258
  }