zcode-pro 0.17.2 → 0.18.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.
@@ -20,6 +20,7 @@ export const STYLE_DEFAULTS = {
20
20
  tableCellPaddingV: 3, // 单元格上下边距(应用默认 3px)
21
21
  tableCellPaddingH: 3, // 单元格左右边距(应用默认 3px)
22
22
  lineHeight: 1.75, // 回答行高(leading-[1.75],挂在答案内容容器上)
23
+ thinkingLineHeight: 1.5, // 思考行高:“已工作/工作中”过程视图的行距(实测应用默认 1.5;范围见 buildCss 注释)
23
24
  userLineHeight: 1.5, // 提问行高(用户消息文本容器,默认 normal=1.5)
24
25
  contentWidth: null, // 内容宽度:默认 100%(跟随应用,不覆盖)
25
26
  sidebarProjectSpacing: 20, // 侧栏项目间距:项目行视觉间距(行内留白 12 + 边距 8)
@@ -137,6 +138,16 @@ function buildCss(styles) {
137
138
  // 行高挂在内容容器上,段落/列表项继承;代码块等自带行高的元素不受影响
138
139
  parts.push(`${CONV} .space-y-4{line-height:${lh} !important;}`);
139
140
  }
141
+ const tlh = styles.thinkingLineHeight;
142
+ if (typeof tlh === 'number' && Number.isFinite(tlh) && tlh >= 0.8) {
143
+ // 「思考行高」管“已工作/工作中 N 秒”过程视图的行距(读取/编辑/查阅/终端等
144
+ // 条目行、流式思考预览,默认 1.5):行高挂在历史内容容器上由各行继承;
145
+ // 过程里的叙述正文走 .space-y-4(回答行高,选择器更具体压过这里的继承)。
146
+ // 单独展开的“思考·持续了 N 秒”块内内容不在此设置范围内
147
+ parts.push(
148
+ `[data-testid^="chat-assistant-history-content"]{line-height:${tlh} !important;}`,
149
+ );
150
+ }
140
151
  const ulh = styles.userLineHeight;
141
152
  if (typeof ulh === 'number' && Number.isFinite(ulh) && ulh >= 0.8) {
142
153
  // 用户提问是独立的 whitespace-pre-wrap 文本容器,行高默认与回答不同(1.5 vs 1.75)
@@ -258,7 +269,10 @@ const HL_SELECTORS = {
258
269
  tableCellPaddingV: `${CONV} td, ${CONV} th`,
259
270
  tableCellPaddingH: `${CONV} td, ${CONV} th`,
260
271
  codeLineHeight: `${CONV} diffs-container, ${CONV} pre`,
261
- lineHeight: `${CONV} .space-y-4`,
272
+ lineHeight: `${CONV} .space-y-4:not([data-reasoning-content] *)`,
273
+ // 思考行高作用在“已工作/工作中”过程视图容器上;视图折叠未挂载时不标
274
+ // (触发行不属此设置范围,不额外描边)
275
+ thinkingLineHeight: `[data-testid^="chat-assistant-history-content"]`,
262
276
  userLineHeight: `${CONV} [class*="user-row"] .whitespace-pre-wrap`,
263
277
  contentWidth: '[data-v4-timeline-content-column]',
264
278
  sidebarProjectSpacing: '[data-testid^="workspace-item-"]',
@@ -1,5 +1,6 @@
1
1
  // ZCode Pro 注入脚本入口(由 esbuild 打包为 dist/inject.js,launcher 拼上启动参数后注入页面)。
2
- // 幂等守卫:页面刷新/重复注入时只初始化一次。
2
+ // 幂等守卫:同一启动器的重复注入(CDP 重连)只初始化一次;换了启动器(开发重载,
3
+ // token 每次启动随机生成)则让页面整页刷新,由新启动器注入唯一一份新代码。
3
4
  import { observeRadixPopups, startLocaleResolver } from './core.js';
4
5
  import { handleProjectMenu } from './features/project-menu.js';
5
6
  import { handleFileMenu } from './features/file-menu.js';
@@ -20,8 +21,17 @@ import { ensureStyle } from './ui.js';
20
21
 
21
22
  (function zcodeproInject() {
22
23
  if (typeof window === 'undefined') return;
23
- if (window.__zcodeproInjected) return;
24
+ if (window.__zcodeproInjected) {
25
+ // 已有实例在跑:bootstrap 里 token 相同 = 同一启动器的重复注入,跳过;
26
+ // token 不同(或旧版脚本没记 token)= 开发重载换了个启动器 → 刷新页面接管
27
+ const boot = window.__ZCODEPRO__ || {};
28
+ const sameGeneration = window.__zcodeproBootedToken && boot.token
29
+ && window.__zcodeproBootedToken === boot.token;
30
+ if (!sameGeneration) location.reload();
31
+ return;
32
+ }
24
33
  window.__zcodeproInjected = true;
34
+ window.__zcodeproBootedToken = (window.__ZCODEPRO__ || {}).token || '';
25
35
 
26
36
  // 尽早取回系统语言(异步 IPC):system 偏好下 macOS 的 navigator.language 可能与
27
37
  // 实际不符;start() 里会再调一次,覆盖 preload 桥未就绪的情况
package/src/inject/ui.js CHANGED
@@ -9,9 +9,10 @@ export function showToast(text, kind = 'info') {
9
9
  document.getElementById('__zcodepro_toast__')?.remove();
10
10
  const el = h('div', {
11
11
  id: '__zcodepro_toast__',
12
- class: 'fixed bottom-6 right-6 z-[100] flex max-w-md items-center gap-2 rounded-lg border px-4 py-3 text-ui-sm shadow-lg ' +
12
+ class: 'fixed bottom-6 z-[100] flex max-w-md items-center gap-2 rounded-lg border px-4 py-3 text-ui-sm shadow-lg ' +
13
13
  (kind === 'error' ? 'border-destructive/40 bg-menu text-foreground' : 'border-border bg-menu text-foreground'),
14
- style: 'animation:zcodepro-fade-in .18s ease',
14
+ // left 用内联样式:ZCode 的 Tailwind 未编译 left-6/right-6 工具类(bottom-6 有)
15
+ style: 'animation:zcodepro-fade-in .18s ease; left: 1.5rem;',
15
16
  },
16
17
  h('span', { class: 'truncate' }, text));
17
18
  document.body.append(el);