zcode-pro 1.8.1 → 1.8.2
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/README.en.md +37 -27
- package/README.md +42 -32
- package/dist/inject.js +460 -54
- package/package.json +1 -1
- package/src/host/helper.mjs +33 -4
- package/src/host/main.mjs +27 -12
- package/src/inject/core.js +12 -4
- package/src/inject/features/composer-edit-model.js +312 -0
- package/src/inject/features/settings-dialog.js +8 -2
- package/src/inject/features/status-bar.js +59 -8
- package/src/inject/features/styles.js +48 -28
- package/src/inject/features/theme.js +10 -0
- package/src/inject/features/ws-running.js +68 -12
- package/src/inject/index.js +2 -0
- package/src/inject/ui.js +2 -2
package/dist/inject.js
CHANGED
|
@@ -366,8 +366,10 @@
|
|
|
366
366
|
devReloadDesc: "\u70B9\u51FB\u540E\u7EA6 2-3 \u79D2\u5185\u6240\u6709 ZCode \u7A97\u53E3\u81EA\u52A8\u5237\u65B0\u4E00\u6B21\u5E76\u52A0\u8F7D\u65B0\u811A\u672C\u3002",
|
|
367
367
|
devToolsSwitch: "\u5F00\u53D1\u8005\u5DE5\u5177",
|
|
368
368
|
devToolsSwitchDesc: "\u5B98\u65B9\u4FA7\u680F\u7684\u201C\u5F00\u53D1\u8005\u5DE5\u5177\u201D\u9762\u677F\uFF08Token \u8C03\u8BD5 / \u7F51\u7EDC\u72B6\u6001\uFF09\uFF0C\u9ED8\u8BA4\u5173\u95ED\u3002\u6539\u52A8\u5199\u5165\u5B98\u65B9\u6BCF\u79D2\u8F6E\u8BE2\u7684\u5F00\u5173\uFF0C1 \u79D2\u5185\u751F\u6548\u3002",
|
|
369
|
-
|
|
370
|
-
|
|
369
|
+
thinkingRowGapName: "\u601D\u8003\u6BB5\u843D\u95F4\u8DDD",
|
|
370
|
+
thinkingRowGapDesc: "\u201C\u5DF2\u5DE5\u4F5C/\u5DE5\u4F5C\u4E2D\u201D\u8FC7\u7A0B\u8BB0\u5F55\u91CC\u5404\u884C\u3001\u601D\u8003\u6B63\u6587\u4E4B\u95F4\u7684\u5782\u76F4\u95F4\u8DDD\u3002",
|
|
371
|
+
answerRowGapName: "\u56DE\u7B54\u6BB5\u843D\u95F4\u8DDD",
|
|
372
|
+
answerRowGapDesc: "\u56DE\u7B54\u6B63\u6587\u91CC\u6BB5\u843D\u7B49\u6587\u672C\u5757\u4E4B\u95F4\u3001\u4EE5\u53CA\u56DE\u5408\u4E4B\u95F4\u7684\u5782\u76F4\u95F4\u8DDD\u3002",
|
|
371
373
|
listSpacingName: "\u5217\u8868\u4E0A\u4E0B\u8FB9\u8DDD",
|
|
372
374
|
listSpacingDesc: "\u7B54\u6848\u4E2D\u5217\u8868\u4E0A\u4E0B\u7684\u7559\u767D\u3002",
|
|
373
375
|
listItemSpacingName: "\u5217\u8868\u9879\u95F4\u8DDD",
|
|
@@ -626,6 +628,8 @@
|
|
|
626
628
|
featureSessionLink: "\u4F1A\u8BDD ID \u663E\u793A\u4E3A\u4EFB\u52A1\u540D\u94FE\u63A5",
|
|
627
629
|
featureSessionLinkDesc: "\u63D0\u95EE\u4E0E\u56DE\u7B54\u91CC\u7684\u4F1A\u8BDD ID\uFF08sess_ / session_ \u5F00\u5934\uFF09\u663E\u793A\u4E3A\u4EFB\u52A1\u540D\uFF0C\u70B9\u51FB\u5207\u6362\u5230\u8BE5\u4F1A\u8BDD\uFF0C\u60AC\u505C\u53EF\u770B\u539F\u59CB ID\u3002",
|
|
628
630
|
featureComposerProviderDesc: "\u6A21\u578B\u540D\u524D\u663E\u793A\u4F9B\u5E94\u5546\u540D\uFF08\u5982 BigModel-Max1 / glm-5.3\uFF09\uFF0C\u533A\u5206\u540C\u540D\u6A21\u578B\u3002",
|
|
631
|
+
featureComposerEditModel: "\u7F16\u8F91\u65F6\u4FDD\u6301\u5F53\u524D\u6A21\u578B",
|
|
632
|
+
featureComposerEditModelDesc: "\u70B9\u7F16\u8F91\u4E0A\u4E00\u6761\u6D88\u606F\u65F6\uFF0C\u4FDD\u6301\u4F60\u70B9\u7F16\u8F91\u524D\u9009\u7684\u6A21\u578B\uFF0C\u4E0D\u4F1A\u6362\u6210\u8FD9\u6761\u6D88\u606F\u5F53\u65F6\u7528\u7684\u6A21\u578B\uFF1B\u8FDB\u5165\u7F16\u8F91\u540E\u4ECD\u7136\u53EF\u4EE5\u518D\u6362\uFF0C\u91CD\u8DD1\u7528\u6700\u7EC8\u9009\u7684\u6A21\u578B\u3002",
|
|
629
633
|
featureSessionImport: "\u5BFC\u5165\u4F1A\u8BDD",
|
|
630
634
|
featureSessionImportDesc: "\u5728\u8BBE\u7F6E\u5F39\u7A97\u91CC\u628A Codex\u3001Claude Code\u3001dsh\u3001pi \u7684\u5386\u53F2\u4F1A\u8BDD\u5BFC\u5165\u6210 ZCode \u4EFB\u52A1\u3002",
|
|
631
635
|
imageCopy: "\u590D\u5236\u56FE\u7247",
|
|
@@ -998,8 +1002,10 @@
|
|
|
998
1002
|
devToolsSwitchDesc: 'The official "Developer tools" side pane (Token debug / Network status), off by default. The change goes to the flag the official app polls every second.',
|
|
999
1003
|
devReloading: "Reloading\u2026",
|
|
1000
1004
|
devReloadDesc: "Every ZCode window refreshes automatically within 2-3 seconds to load the new script.",
|
|
1001
|
-
|
|
1002
|
-
|
|
1005
|
+
thinkingRowGapName: "Thinking paragraph spacing",
|
|
1006
|
+
thinkingRowGapDesc: 'Vertical spacing between rows of the "Worked/Working" process view and thinking text.',
|
|
1007
|
+
answerRowGapName: "Answer paragraph spacing",
|
|
1008
|
+
answerRowGapDesc: "Vertical spacing between text blocks inside answers and between turns.",
|
|
1003
1009
|
listSpacingName: "List spacing",
|
|
1004
1010
|
listSpacingDesc: "Space above and below lists.",
|
|
1005
1011
|
listItemSpacingName: "List item spacing",
|
|
@@ -1257,6 +1263,8 @@
|
|
|
1257
1263
|
featureSessionLink: "Session ID links",
|
|
1258
1264
|
featureSessionLinkDesc: "Shows session IDs (sess_ / session_) in chat as task names; click to switch to that session, hover for the raw ID.",
|
|
1259
1265
|
featureComposerProviderDesc: "Shows the provider before the model name (e.g. BigModel-Max1 / glm-5.3).",
|
|
1266
|
+
featureComposerEditModel: "Keep current model when editing",
|
|
1267
|
+
featureComposerEditModelDesc: "Keeps the model you selected before clicking edit instead of switching to the model the message was sent with. You can still change it in the editor; the rerun uses the final selection.",
|
|
1260
1268
|
featureSessionImport: "Session import",
|
|
1261
1269
|
featureSessionImportDesc: "Import sessions from Codex, Claude Code, dsh and pi as ZCode tasks from the settings dialog.",
|
|
1262
1270
|
imageCopy: "Copy image",
|
|
@@ -2317,8 +2325,8 @@
|
|
|
2317
2325
|
color: var(--color-muted-foreground, #888);
|
|
2318
2326
|
}
|
|
2319
2327
|
/* \u72B6\u6001\u680F\u7EDF\u8BA1\uFF08status-bar.js\uFF09\uFF1A\u8F93\u5165\u6846\u4E0B\u65B9\u53F3\u5BF9\u9F50\u7684\u4E00\u884C\u5C0F\u5B57\uFF0C\u6BCF\u9879\u5E26 lucide \u5C0F\u56FE\u6807\u3002
|
|
2320
|
-
\
|
|
2321
|
-
\
|
|
2328
|
+
\u4F1A\u8BDD\u89C6\u56FE\u91CC\u7EDD\u5BF9\u5B9A\u4F4D\u5230\u6EDA\u52A8\u5BB9\u5668\u5916\u7684\u5E95\u90E8\uFF08\u907F\u5F00\u6EDA\u52A8\u88C1\u526A\uFF09\uFF0C\u65B0\u5EFA\u4F1A\u8BDD\u89C6\u56FE\u5728\u8F93\u5165\u6846\u540E
|
|
2329
|
+
\u6309\u539F\u6837\u6392\uFF1B\u4F4D\u7F6E\u4E0E\u95F4\u8DDD\u7531\u811A\u672C\u63A7\u5236 */
|
|
2322
2330
|
.zcodepro-statusbar {
|
|
2323
2331
|
display: flex;
|
|
2324
2332
|
justify-content: flex-end;
|
|
@@ -2678,12 +2686,12 @@
|
|
|
2678
2686
|
return null;
|
|
2679
2687
|
}
|
|
2680
2688
|
}
|
|
2681
|
-
function listActiveIdsCached(base) {
|
|
2689
|
+
function listActiveIdsCached(base, fresh = false) {
|
|
2682
2690
|
const key = String(base).replace(/[\\/]+$/, "");
|
|
2683
2691
|
const now = Date.now();
|
|
2684
2692
|
const hit = activeIdsCache.get(key);
|
|
2685
2693
|
if (hit && hit.pending) return hit.pending;
|
|
2686
|
-
if (hit && now - hit.doneAt < ACTIVE_IDS_TTL_MS) return Promise.resolve(hit.ids);
|
|
2694
|
+
if (!fresh && hit && now - hit.doneAt < ACTIVE_IDS_TTL_MS) return Promise.resolve(hit.ids);
|
|
2687
2695
|
const services = findServices();
|
|
2688
2696
|
const ts = services && services.zcodeTaskService;
|
|
2689
2697
|
if (!ts || typeof ts.listActiveTaskIds !== "function") return Promise.resolve(null);
|
|
@@ -2752,6 +2760,7 @@
|
|
|
2752
2760
|
}
|
|
2753
2761
|
function scan() {
|
|
2754
2762
|
wsWithRows = /* @__PURE__ */ new Set();
|
|
2763
|
+
const changed = /* @__PURE__ */ new Set();
|
|
2755
2764
|
for (const el of document.querySelectorAll(TASK_SEL)) {
|
|
2756
2765
|
const key = el.getAttribute("data-task-item-key") || "";
|
|
2757
2766
|
const ws = workspaceOf(key);
|
|
@@ -2764,11 +2773,22 @@
|
|
|
2764
2773
|
set = /* @__PURE__ */ new Set();
|
|
2765
2774
|
runningByWs.set(ws, set);
|
|
2766
2775
|
}
|
|
2776
|
+
if (!set.has(key)) changed.add(ws);
|
|
2767
2777
|
set.add(key);
|
|
2768
2778
|
} else if (set) {
|
|
2769
|
-
set.delete(key);
|
|
2779
|
+
if (set.delete(key)) changed.add(ws);
|
|
2770
2780
|
}
|
|
2771
2781
|
}
|
|
2782
|
+
if (changed.size) {
|
|
2783
|
+
for (const ws of changed) activeIdsCache.delete(String(ws).replace(/[\\/]+$/, ""));
|
|
2784
|
+
for (const ws of changed) {
|
|
2785
|
+
const set = runningByWs.get(ws);
|
|
2786
|
+
if (set && set.size) continue;
|
|
2787
|
+
const norm3 = (v) => String(v || "").replace(/[\\/]+$/, "");
|
|
2788
|
+
for (const p of [...activeProjectPaths]) if (norm3(p) === norm3(ws)) activeProjectPaths.delete(p);
|
|
2789
|
+
}
|
|
2790
|
+
scheduleForceScan();
|
|
2791
|
+
}
|
|
2772
2792
|
syncPeeks();
|
|
2773
2793
|
apply();
|
|
2774
2794
|
}
|
|
@@ -2855,8 +2875,29 @@
|
|
|
2855
2875
|
return { head, cont: contOk ? cont : null, kind };
|
|
2856
2876
|
}).filter((x) => x.head);
|
|
2857
2877
|
}
|
|
2858
|
-
function
|
|
2859
|
-
|
|
2878
|
+
function anySpinLit() {
|
|
2879
|
+
return anyActiveCache.value === true || sectionActive.task || sectionActive.project || sectionActive.pinned || activeProjectPaths.size > 0;
|
|
2880
|
+
}
|
|
2881
|
+
function scheduleGlobalScan() {
|
|
2882
|
+
clearTimeout(globalScanTimer);
|
|
2883
|
+
const wait = anySpinLit() ? 1e4 : 3e4;
|
|
2884
|
+
globalScanTimer = setTimeout(() => {
|
|
2885
|
+
if (!document.hidden && enabled2 && !anyActiveCache.busy) {
|
|
2886
|
+
if (anySpinLit()) globalAnyActive(true);
|
|
2887
|
+
else if (Date.now() - anyActiveCache.at >= 3e4) globalAnyActive();
|
|
2888
|
+
}
|
|
2889
|
+
scheduleGlobalScan();
|
|
2890
|
+
}, wait);
|
|
2891
|
+
}
|
|
2892
|
+
function scheduleForceScan() {
|
|
2893
|
+
if (forceScanTimer) return;
|
|
2894
|
+
forceScanTimer = setTimeout(() => {
|
|
2895
|
+
forceScanTimer = 0;
|
|
2896
|
+
if (!document.hidden && enabled2) globalAnyActive(true);
|
|
2897
|
+
}, 800);
|
|
2898
|
+
}
|
|
2899
|
+
function globalAnyActive(force) {
|
|
2900
|
+
if (!force && anyActiveCache.value !== null && Date.now() - anyActiveCache.at < 3e4) return anyActiveCache.value;
|
|
2860
2901
|
if (anyActiveCache.busy) return anyActiveCache.value === true;
|
|
2861
2902
|
anyActiveCache.busy = true;
|
|
2862
2903
|
sectionActive.task = false;
|
|
@@ -2903,7 +2944,8 @@
|
|
|
2903
2944
|
}
|
|
2904
2945
|
projectPaths.set(proj.name, names);
|
|
2905
2946
|
}
|
|
2906
|
-
const
|
|
2947
|
+
const hot = /* @__PURE__ */ new Set([...activeProjectPaths, ...authActiveByWs.keys()]);
|
|
2948
|
+
const pairs = await Promise.all([...scanPaths].map(async (base) => [base, await listActiveIdsCached(base, force && hot.has(base)) || []]));
|
|
2907
2949
|
for (const [base, ids] of pairs) {
|
|
2908
2950
|
if (!ids.length) continue;
|
|
2909
2951
|
byKindByPath.set(base, ids);
|
|
@@ -2914,13 +2956,25 @@
|
|
|
2914
2956
|
const st = allIds.length ? await rpc("/task-statuses?ids=" + encodeURIComponent(allIds.join(","))).catch(() => null) : null;
|
|
2915
2957
|
const TERMINAL = /* @__PURE__ */ new Set(["completed", "error", "interrupted"]);
|
|
2916
2958
|
const recOf = (id) => st && st.ok && st.available ? st.statuses[id] : void 0;
|
|
2959
|
+
const domIdle = /* @__PURE__ */ new Set();
|
|
2960
|
+
const domRunningIds = /* @__PURE__ */ new Set();
|
|
2961
|
+
for (const el of document.querySelectorAll(TASK_SEL)) {
|
|
2962
|
+
const k = el.getAttribute("data-task-item-key") || "";
|
|
2963
|
+
const id = k.slice(k.lastIndexOf(":") + 1);
|
|
2964
|
+
if (!id) continue;
|
|
2965
|
+
if (isRunningRow(el)) domRunningIds.add(id);
|
|
2966
|
+
else domIdle.add(id);
|
|
2967
|
+
}
|
|
2968
|
+
for (const id of domRunningIds) domIdle.delete(id);
|
|
2917
2969
|
const live = (id) => {
|
|
2970
|
+
if (domIdle.has(id)) return false;
|
|
2918
2971
|
const rec = recOf(id);
|
|
2919
2972
|
if (rec === void 0) return true;
|
|
2920
2973
|
if (!TERMINAL.has(rec.status)) return true;
|
|
2921
2974
|
return Date.now() - rec.updatedAt < 3e5;
|
|
2922
2975
|
};
|
|
2923
2976
|
const liveSession = (id) => {
|
|
2977
|
+
if (domIdle.has(id)) return false;
|
|
2924
2978
|
const rec = recOf(id);
|
|
2925
2979
|
if (rec === void 0) return !!domRowKeyOf(id);
|
|
2926
2980
|
if (!TERMINAL.has(rec.status)) return true;
|
|
@@ -3276,7 +3330,7 @@
|
|
|
3276
3330
|
if (row) wsTouchAt.set(row, Date.now());
|
|
3277
3331
|
}, true);
|
|
3278
3332
|
}
|
|
3279
|
-
var installed, enabled2, SCAN_DEBOUNCE_MS, SCAN_FALLBACK_MS, PEEK_FIRST_MS, PEEK_REPEAT_MS, PEEK_SETTLE_MS, PEEK_MAX_MS, PEEK_UNMOUNT_WAIT_MS, CONFIG_POLL_MIN_MS, CONFIG_POLL_MAX_MS, TASK_SEL, WS_SEL, LOADER_FALLBACK_PATHS, runningByWs, peekTimers, activePeeks, peekedWs, wsWithRows, servicesRef, servicesMissAt, ACTIVE_IDS_TTL_MS, ACTIVE_IDS_TIMEOUT_MS, activeIdsCache, synthClick, headInfoCache, PROJECT_HEAD_TEXTS, TASK_HEAD_TEXTS, SEC_SPIN_CLASS, anyActiveCache, sectionActive, activeProjectPaths, authActiveByWs, peekChain, PEEK_EXEMPT_CLASS, cssAttr, TOUCH_WINDOW_MS, wsTouchAt, pollMs, scanDebounce;
|
|
3333
|
+
var installed, enabled2, SCAN_DEBOUNCE_MS, SCAN_FALLBACK_MS, PEEK_FIRST_MS, PEEK_REPEAT_MS, PEEK_SETTLE_MS, PEEK_MAX_MS, PEEK_UNMOUNT_WAIT_MS, CONFIG_POLL_MIN_MS, CONFIG_POLL_MAX_MS, TASK_SEL, WS_SEL, LOADER_FALLBACK_PATHS, runningByWs, peekTimers, activePeeks, peekedWs, wsWithRows, servicesRef, servicesMissAt, ACTIVE_IDS_TTL_MS, ACTIVE_IDS_TIMEOUT_MS, activeIdsCache, synthClick, headInfoCache, PROJECT_HEAD_TEXTS, TASK_HEAD_TEXTS, SEC_SPIN_CLASS, anyActiveCache, sectionActive, activeProjectPaths, authActiveByWs, globalScanTimer, forceScanTimer, peekChain, PEEK_EXEMPT_CLASS, cssAttr, TOUCH_WINDOW_MS, wsTouchAt, pollMs, scanDebounce;
|
|
3280
3334
|
var init_ws_running = __esm({
|
|
3281
3335
|
"src/inject/features/ws-running.js"() {
|
|
3282
3336
|
init_core();
|
|
@@ -3328,10 +3382,9 @@
|
|
|
3328
3382
|
sectionActive = { task: false, project: false, pinned: false };
|
|
3329
3383
|
activeProjectPaths = /* @__PURE__ */ new Set();
|
|
3330
3384
|
authActiveByWs = /* @__PURE__ */ new Map();
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
}, 3e4);
|
|
3385
|
+
globalScanTimer = 0;
|
|
3386
|
+
scheduleGlobalScan();
|
|
3387
|
+
forceScanTimer = 0;
|
|
3335
3388
|
peekChain = Promise.resolve();
|
|
3336
3389
|
PEEK_EXEMPT_CLASS = "zcodepro-peek-exempt";
|
|
3337
3390
|
cssAttr = (v) => String(v).replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
@@ -4809,10 +4862,10 @@
|
|
|
4809
4862
|
function startImageMenu() {
|
|
4810
4863
|
if (typeof window === "undefined") return;
|
|
4811
4864
|
if (typeof navigator.clipboard?.write !== "function" || typeof window.ClipboardItem === "undefined") return;
|
|
4812
|
-
let
|
|
4865
|
+
let enabled16 = true;
|
|
4813
4866
|
const refresh = () => {
|
|
4814
4867
|
void getConfig().then((c) => {
|
|
4815
|
-
|
|
4868
|
+
enabled16 = !(c.features && c.features.imageCopy === false);
|
|
4816
4869
|
});
|
|
4817
4870
|
};
|
|
4818
4871
|
refresh();
|
|
@@ -4821,7 +4874,7 @@
|
|
|
4821
4874
|
const img = copyTargetOf(e.target, e.clientX, e.clientY);
|
|
4822
4875
|
if (!img) return;
|
|
4823
4876
|
e.preventDefault();
|
|
4824
|
-
if (
|
|
4877
|
+
if (enabled16) showMenu(e.clientX, e.clientY, img);
|
|
4825
4878
|
refresh();
|
|
4826
4879
|
}, true);
|
|
4827
4880
|
}
|
|
@@ -5333,8 +5386,10 @@
|
|
|
5333
5386
|
// src/inject/features/styles.js
|
|
5334
5387
|
init_core();
|
|
5335
5388
|
var STYLE_DEFAULTS = {
|
|
5336
|
-
|
|
5337
|
-
//
|
|
5389
|
+
thinkingRowGap: 20,
|
|
5390
|
+
// 思考段落间距:“已工作/工作中”过程视图内各行之间的距离
|
|
5391
|
+
answerRowGap: 20,
|
|
5392
|
+
// 回答段落间距:回答正文内文本块、回合之间的垂直间距
|
|
5338
5393
|
listSpacing: 12,
|
|
5339
5394
|
// 列表上下留白(my-3)
|
|
5340
5395
|
listItemSpacing: 6,
|
|
@@ -5387,43 +5442,57 @@
|
|
|
5387
5442
|
var SEL_TABLE = `${CONV} .space-y-4 > div:has(table)`;
|
|
5388
5443
|
function buildCss(styles) {
|
|
5389
5444
|
const parts = [];
|
|
5390
|
-
const
|
|
5391
|
-
const
|
|
5392
|
-
|
|
5445
|
+
const num = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : null;
|
|
5446
|
+
const tg = num(styles.thinkingRowGap);
|
|
5447
|
+
const ag = num(styles.answerRowGap);
|
|
5448
|
+
const thinkingSet = tg !== null;
|
|
5449
|
+
const answerSet = ag !== null;
|
|
5450
|
+
if (answerSet) {
|
|
5393
5451
|
parts.push(
|
|
5394
5452
|
// 回合内外各级容器(SECTION 自身或后代,二者都覆盖)
|
|
5395
|
-
`${CONV}.pb-5,${CONV} .pb-5{padding-bottom:${
|
|
5396
|
-
`${CONV}.pt-5,${CONV} .pt-5{padding-top:${
|
|
5397
|
-
`${CONV} .flex.flex-col.gap-5{gap:${
|
|
5398
|
-
`${CONV} .flex.flex-col.gap-4{gap:${
|
|
5453
|
+
`${CONV}.pb-5,${CONV} .pb-5{padding-bottom:${ag}px !important;}`,
|
|
5454
|
+
`${CONV}.pt-5,${CONV} .pt-5{padding-top:${ag}px !important;}`,
|
|
5455
|
+
`${CONV} .flex.flex-col.gap-5{gap:${ag}px !important;}`,
|
|
5456
|
+
`${CONV} .flex.flex-col.gap-4{gap:${ag}px !important;}`,
|
|
5399
5457
|
// 答案内相邻文本块之间(特殊块除外,走各自间距项)
|
|
5400
|
-
`${CONV} .space-y-4 > * + *:not(${SPECIAL}){margin-block-start:${
|
|
5458
|
+
`${CONV} .space-y-4 > * + *:not(${SPECIAL}){margin-block-start:${ag}px !important;margin-top:${ag}px !important;}`,
|
|
5401
5459
|
// 特殊块后接文本块:去掉文本块的段落间距,避免与特殊块自身留白叠加
|
|
5402
5460
|
`${CONV} .space-y-4 > ${SPECIAL} + *:not(${SPECIAL}){margin-block-start:0 !important;margin-top:0 !important;}`,
|
|
5403
|
-
//
|
|
5404
|
-
`.history-message.flex.flex-col > * +
|
|
5461
|
+
// 历史回合里“已工作”展开块之后接回答正文:这段距离算回答间距
|
|
5462
|
+
`.history-message.flex.flex-col > * + *[class~="group/assistant-row"]{margin-block-start:${ag}px !important;margin-top:${ag}px !important;}`,
|
|
5405
5463
|
// 工具/状态卡片(“N 个文件已更改”等)上方间距下限 8px:
|
|
5406
|
-
//
|
|
5407
|
-
`${CONV} .flex.flex-col.gap-5 > [data-slot="collapsible"]{margin-block-start:max(0px, calc(8px - ${
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5464
|
+
// 回答段落间距调到 0 时也不至于贴死(gap 与 margin 在弹性布局里相加)
|
|
5465
|
+
`${CONV} .flex.flex-col.gap-5 > [data-slot="collapsible"]{margin-block-start:max(0px, calc(8px - ${ag}px)) !important;margin-top:max(0px, calc(8px - ${ag}px)) !important;}`
|
|
5466
|
+
);
|
|
5467
|
+
}
|
|
5468
|
+
if (thinkingSet) {
|
|
5469
|
+
parts.push(
|
|
5412
5470
|
// 过程视图(思考/工具摘要/过程正文)的行块:应用给容器 4px gap + 每行
|
|
5413
|
-
// 12px 上内边距(共 16px
|
|
5471
|
+
// 12px 上内边距(共 16px)。思考段落间距设置时直接接管:gap 归零、上内边距
|
|
5414
5472
|
// 按设置值,总间距等于设置值(设 0 就完全贴紧)
|
|
5415
5473
|
`${CONV} [data-conversation-work-items]{gap:0 !important;}`,
|
|
5416
|
-
`${CONV} [data-conversation-work-items] > * + *{padding-top:${
|
|
5474
|
+
`${CONV} [data-conversation-work-items] > * + *{padding-top:${tg}px !important;}`,
|
|
5475
|
+
// 过程视图里的叙述正文按思考算(比回答间距规则多一层容器限定,优先命中)
|
|
5476
|
+
`${CONV} [data-conversation-work-items] .space-y-4 > * + *:not(${SPECIAL}){margin-block-start:${tg}px !important;margin-top:${tg}px !important;}`,
|
|
5477
|
+
// 过程视图里特殊块后接文本块同样清零,避免与特殊块自身留白叠加(后写覆盖上一条)
|
|
5478
|
+
`${CONV} [data-conversation-work-items] .space-y-4 > ${SPECIAL} + *:not(${SPECIAL}){margin-block-start:0 !important;margin-top:0 !important;}`,
|
|
5479
|
+
// “已工作”展开块顶部留白(包裹层在历史内容容器内)
|
|
5480
|
+
`${CONV} [data-testid^="chat-assistant-history-content"] .pt-5{padding-top:${tg}px !important;}`,
|
|
5481
|
+
// 历史回合里“已工作”触发行等过程行之间;回答正文那一行走回答间距规则
|
|
5482
|
+
`.history-message.flex.flex-col > * + *:not([data-slot="collapsible-content"]):not([class~="group/assistant-row"]){margin-block-start:${tg}px !important;margin-top:${tg}px !important;}`
|
|
5417
5483
|
);
|
|
5418
5484
|
}
|
|
5419
|
-
|
|
5485
|
+
if (thinkingSet || answerSet) {
|
|
5486
|
+
parts.push(`${CONV} .flex.flex-col.gap-5 > [data-zcode-chat-loading-slot]:not(:first-child){margin-block-start:0 !important;margin-top:0 !important;}`);
|
|
5487
|
+
}
|
|
5488
|
+
const own = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : answerSet ? ag : null;
|
|
5420
5489
|
const ls = own(styles.listSpacing);
|
|
5421
5490
|
const qc = own(styles.quoteCodeSpacing);
|
|
5422
5491
|
const tsp = own(styles.tableSpacing);
|
|
5423
5492
|
const anySet = ls !== null || qc !== null || tsp !== null;
|
|
5424
5493
|
if (ls !== null) parts.push(`${SEL_LIST}{margin-block:${ls}px !important;}`);
|
|
5425
5494
|
if (qc !== null) parts.push(`${SEL_QUOTE}{margin-block:${qc}px !important;}`);
|
|
5426
|
-
if (
|
|
5495
|
+
if (thinkingSet || answerSet || anySet) {
|
|
5427
5496
|
parts.push(`${CONV} .space-y-4 > :not(${SPECIAL}){margin-block-end:0 !important;margin-bottom:0 !important;}`);
|
|
5428
5497
|
}
|
|
5429
5498
|
if (tsp !== null) {
|
|
@@ -5571,7 +5640,8 @@
|
|
|
5571
5640
|
});
|
|
5572
5641
|
}
|
|
5573
5642
|
var HL_SELECTORS = {
|
|
5574
|
-
|
|
5643
|
+
thinkingRowGap: `${CONV} [data-conversation-work-items] > * + *, .history-message.flex.flex-col > * + *:not([data-slot="collapsible-content"]):not([class~="group/assistant-row"])`,
|
|
5644
|
+
answerRowGap: `${CONV} .space-y-4 > *, ${CONV} .flex.flex-col.gap-5 > *`,
|
|
5575
5645
|
listSpacing: `${CONV} :is(ul, ol)`,
|
|
5576
5646
|
listItemSpacing: `${CONV} :is(ul, ol) > li`,
|
|
5577
5647
|
quoteCodeSpacing: SEL_QUOTE,
|
|
@@ -5589,7 +5659,8 @@
|
|
|
5589
5659
|
sidebarTaskSpacing: "li[data-task-item-key]"
|
|
5590
5660
|
};
|
|
5591
5661
|
var HL_MARGIN = {
|
|
5592
|
-
|
|
5662
|
+
thinkingRowGap: { sel: `${CONV} [data-conversation-work-items] > * + *`, top: true, insideTop: true },
|
|
5663
|
+
answerRowGap: { sel: `${CONV} .space-y-4 > * + *:not(${SPECIAL}):not(${SPECIAL} + *)`, top: true },
|
|
5593
5664
|
listSpacing: { sel: SEL_LIST, top: true, bottom: true },
|
|
5594
5665
|
listItemSpacing: { sel: `${CONV} :is(ul, ol) > li + li`, top: true },
|
|
5595
5666
|
quoteCodeSpacing: { sel: SEL_QUOTE, top: true, bottom: true },
|
|
@@ -5613,7 +5684,7 @@
|
|
|
5613
5684
|
if (margin) {
|
|
5614
5685
|
const v = typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
5615
5686
|
parts.push(`${margin.sel}{position:relative !important;}`);
|
|
5616
|
-
if (margin.top) parts.push(`${margin.sel}::before{content:'' !important;position:absolute;left:0;right:0
|
|
5687
|
+
if (margin.top) parts.push(`${margin.sel}::before{content:'' !important;position:absolute;left:0;right:0;${margin.insideTop ? "top:0" : "bottom:100%"};height:${v}px;background:${HL_AMBER};pointer-events:none;}`);
|
|
5617
5688
|
if (margin.bottom) parts.push(`${margin.sel}::after{content:'' !important;position:absolute;left:0;right:0;top:100%;height:${v}px;background:${HL_AMBER};pointer-events:none;}`);
|
|
5618
5689
|
}
|
|
5619
5690
|
hlEl.textContent = parts.join("");
|
|
@@ -6016,13 +6087,26 @@
|
|
|
6016
6087
|
return `html,body{background:rgba(${rgb},${veil}) !important}`;
|
|
6017
6088
|
}
|
|
6018
6089
|
function applyWebviewTransparency() {
|
|
6090
|
+
const guestUrl = (w) => {
|
|
6091
|
+
try {
|
|
6092
|
+
return String(w.getURL ? w.getURL() : w.src || "");
|
|
6093
|
+
} catch {
|
|
6094
|
+
return "";
|
|
6095
|
+
}
|
|
6096
|
+
};
|
|
6097
|
+
const maybeCard = (w) => {
|
|
6098
|
+
const u = guestUrl(w);
|
|
6099
|
+
return u === "" || /^zcode-sandbox:\/\//i.test(u);
|
|
6100
|
+
};
|
|
6019
6101
|
const hook = (w, css) => {
|
|
6102
|
+
if (!maybeCard(w)) return;
|
|
6020
6103
|
const on = document.documentElement.classList.contains("zcodepro-bg-on");
|
|
6021
6104
|
const rec = wvStyled.find((r) => r.el === w);
|
|
6022
6105
|
if (on && !rec) {
|
|
6023
6106
|
const entry = { el: w, key: null, css, handler: null };
|
|
6024
6107
|
entry.handler = () => {
|
|
6025
6108
|
if (!wvStyled.includes(entry)) return;
|
|
6109
|
+
if (!maybeCard(w)) return;
|
|
6026
6110
|
const myCss = entry.css;
|
|
6027
6111
|
try {
|
|
6028
6112
|
void w.insertCSS(myCss).then((k) => {
|
|
@@ -6043,6 +6127,7 @@
|
|
|
6043
6127
|
wvStyled.push(entry);
|
|
6044
6128
|
entry.handler();
|
|
6045
6129
|
} else if (on && rec && rec.css !== css) {
|
|
6130
|
+
if (!maybeCard(w)) return;
|
|
6046
6131
|
rec.css = css;
|
|
6047
6132
|
const oldKey = rec.key;
|
|
6048
6133
|
rec.key = null;
|
|
@@ -7502,6 +7587,11 @@
|
|
|
7502
7587
|
if (await setFeature("composerProvider", next)) f.composerProvider = next;
|
|
7503
7588
|
refreshRows();
|
|
7504
7589
|
}),
|
|
7590
|
+
settingRow(L.featureComposerEditModel, L.featureComposerEditModelDesc, f.composerEditModel !== false, async () => {
|
|
7591
|
+
const next = !(f.composerEditModel !== false);
|
|
7592
|
+
if (await setFeature("composerEditModel", next)) f.composerEditModel = next;
|
|
7593
|
+
refreshRows();
|
|
7594
|
+
}),
|
|
7505
7595
|
settingRow(L.featureSessionImport, L.featureSessionImportDesc, f.sessionImport !== false, async () => {
|
|
7506
7596
|
const next = !(f.sessionImport !== false);
|
|
7507
7597
|
if (await setFeature("sessionImport", next)) f.sessionImport = next;
|
|
@@ -7886,10 +7976,11 @@
|
|
|
7886
7976
|
styleCell(L.sidebarProjectSpacingName, L.sidebarProjectSpacingDesc, "sidebarProjectSpacing", { max: 24 }),
|
|
7887
7977
|
styleCell(L.sidebarTaskSpacingName, L.sidebarTaskSpacingDesc, "sidebarTaskSpacing", { max: 24 }),
|
|
7888
7978
|
widthCell,
|
|
7889
|
-
styleCell(L.rowGapName, L.rowGapDesc, "rowGap"),
|
|
7890
7979
|
styleCell(L.userLineHeightName, L.userLineHeightDesc, "userLineHeight", { min: 1, max: 3, step: 0.05, unit: "x" }),
|
|
7891
|
-
styleCell(L.lineHeightName, L.lineHeightDesc, "lineHeight", { min: 1, max: 3, step: 0.05, unit: "x" }),
|
|
7892
7980
|
styleCell(L.thinkingLineHeightName, L.thinkingLineHeightDesc, "thinkingLineHeight", { min: 1, max: 3, step: 0.05, unit: "x" }),
|
|
7981
|
+
styleCell(L.thinkingRowGapName, L.thinkingRowGapDesc, "thinkingRowGap"),
|
|
7982
|
+
styleCell(L.lineHeightName, L.lineHeightDesc, "lineHeight", { min: 1, max: 3, step: 0.05, unit: "x" }),
|
|
7983
|
+
styleCell(L.answerRowGapName, L.answerRowGapDesc, "answerRowGap"),
|
|
7893
7984
|
styleCell(L.codeLineHeightName, L.codeLineHeightDesc, "codeLineHeight", { min: 1, max: 3, step: 0.05, unit: "x" }),
|
|
7894
7985
|
styleCell(L.listSpacingName, L.listSpacingDesc, "listSpacing"),
|
|
7895
7986
|
styleCell(L.listItemSpacingName, L.listItemSpacingDesc, "listItemSpacing"),
|
|
@@ -11395,6 +11486,8 @@
|
|
|
11395
11486
|
var enabled4 = true;
|
|
11396
11487
|
var items = DEFAULT_STATUS_ITEMS.map((x) => ({ ...x }));
|
|
11397
11488
|
var barEl = null;
|
|
11489
|
+
var liftedPane = null;
|
|
11490
|
+
var BAR_LIFT = 10;
|
|
11398
11491
|
var lastStats = null;
|
|
11399
11492
|
var lastSid = null;
|
|
11400
11493
|
var statsSid = null;
|
|
@@ -11628,26 +11721,68 @@
|
|
|
11628
11721
|
return null;
|
|
11629
11722
|
}
|
|
11630
11723
|
}
|
|
11724
|
+
function clipPane(el) {
|
|
11725
|
+
for (let n = el.parentElement; n && n !== document.body; n = n.parentElement) {
|
|
11726
|
+
if (/(auto|scroll|hidden)/.test(getComputedStyle(n).overflowY)) return n;
|
|
11727
|
+
}
|
|
11728
|
+
return null;
|
|
11729
|
+
}
|
|
11631
11730
|
function renderBar() {
|
|
11632
11731
|
const ta = composerEl();
|
|
11633
11732
|
const host = ta && (ta.closest("form") || ta.parentElement);
|
|
11634
11733
|
if (!enabled4 || !host || !host.parentElement) {
|
|
11635
11734
|
if (barEl) barEl.remove();
|
|
11636
11735
|
barEl = null;
|
|
11736
|
+
if (liftedPane) {
|
|
11737
|
+
liftedPane.style.marginBottom = "";
|
|
11738
|
+
liftedPane = null;
|
|
11739
|
+
}
|
|
11637
11740
|
lastRenderedHtml = null;
|
|
11638
11741
|
return;
|
|
11639
11742
|
}
|
|
11640
|
-
|
|
11743
|
+
const hasSession = !!selectedSessionId();
|
|
11744
|
+
const pane = hasSession ? clipPane(host) : null;
|
|
11745
|
+
const mount = pane && pane.parentElement && getComputedStyle(pane.parentElement).position !== "static" ? pane.parentElement : host.parentElement;
|
|
11746
|
+
if (!barEl || !barEl.isConnected || barEl.parentElement !== mount) {
|
|
11641
11747
|
if (!barEl) {
|
|
11642
11748
|
barEl = document.createElement("div");
|
|
11643
11749
|
barEl.className = "zcodepro-statusbar";
|
|
11644
11750
|
lastRenderedHtml = null;
|
|
11645
11751
|
}
|
|
11646
|
-
host.parentElement.insertBefore(barEl, host.nextSibling);
|
|
11752
|
+
if (mount === host.parentElement) mount.insertBefore(barEl, host.nextSibling);
|
|
11753
|
+
else mount.append(barEl);
|
|
11754
|
+
}
|
|
11755
|
+
if (mount !== host.parentElement) {
|
|
11756
|
+
if (liftedPane && liftedPane !== pane) liftedPane.style.marginBottom = "";
|
|
11757
|
+
liftedPane = pane;
|
|
11758
|
+
liftedPane.style.marginBottom = `${BAR_LIFT}px`;
|
|
11759
|
+
const hr = host.getBoundingClientRect();
|
|
11760
|
+
const mr = mount.getBoundingClientRect();
|
|
11761
|
+
barEl.style.position = "absolute";
|
|
11762
|
+
barEl.style.left = `${Math.round(hr.left - mr.left - mount.clientLeft)}px`;
|
|
11763
|
+
barEl.style.width = `${Math.round(hr.width)}px`;
|
|
11764
|
+
barEl.style.top = `${Math.round(hr.bottom - mr.top - mount.clientTop)}px`;
|
|
11765
|
+
const below = innerHeight - mr.bottom;
|
|
11766
|
+
barEl.style.bottom = `${below >= 0 && below <= 8 ? Math.round(mr.bottom - innerHeight) : 0}px`;
|
|
11767
|
+
barEl.style.zIndex = "20";
|
|
11768
|
+
barEl.style.marginBottom = "0";
|
|
11769
|
+
barEl.style.paddingTop = "0";
|
|
11770
|
+
barEl.style.paddingBottom = "0";
|
|
11771
|
+
} else {
|
|
11772
|
+
if (liftedPane) {
|
|
11773
|
+
liftedPane.style.marginBottom = "";
|
|
11774
|
+
liftedPane = null;
|
|
11775
|
+
}
|
|
11776
|
+
barEl.style.position = "";
|
|
11777
|
+
barEl.style.left = "";
|
|
11778
|
+
barEl.style.width = "";
|
|
11779
|
+
barEl.style.top = "";
|
|
11780
|
+
barEl.style.bottom = "";
|
|
11781
|
+
barEl.style.zIndex = "";
|
|
11782
|
+
barEl.style.paddingTop = "";
|
|
11783
|
+
barEl.style.marginBottom = hasSession ? "-14px" : "0";
|
|
11784
|
+
barEl.style.paddingBottom = hasSession ? "0" : "7px";
|
|
11647
11785
|
}
|
|
11648
|
-
const hasSession = !!selectedSessionId();
|
|
11649
|
-
barEl.style.marginBottom = hasSession ? "-14px" : "0";
|
|
11650
|
-
barEl.style.paddingBottom = hasSession ? "0" : "7px";
|
|
11651
11786
|
const L = t();
|
|
11652
11787
|
const entries = [];
|
|
11653
11788
|
for (const it of items) {
|
|
@@ -12516,11 +12651,11 @@
|
|
|
12516
12651
|
async function injectHoverButtons() {
|
|
12517
12652
|
const cfg = await getConfig();
|
|
12518
12653
|
if (!cfg || !cfg.titleGen) return;
|
|
12519
|
-
const
|
|
12654
|
+
const enabled16 = cfg.titleGen.hoverBtn !== false;
|
|
12520
12655
|
const L = t();
|
|
12521
12656
|
for (const area of document.querySelectorAll(ACTIONS_SEL)) {
|
|
12522
12657
|
const existing = area.querySelector('[data-zcodepro-item="auto-rename"]');
|
|
12523
|
-
if (!
|
|
12658
|
+
if (!enabled16) {
|
|
12524
12659
|
existing?.remove();
|
|
12525
12660
|
continue;
|
|
12526
12661
|
}
|
|
@@ -14163,6 +14298,273 @@
|
|
|
14163
14298
|
apply4();
|
|
14164
14299
|
}
|
|
14165
14300
|
|
|
14301
|
+
// src/inject/features/composer-edit-model.js
|
|
14302
|
+
init_core();
|
|
14303
|
+
var TRIGGER_SEL2 = '[data-testid="chat-model-select-trigger"]';
|
|
14304
|
+
var PROVIDER_TRIGGER_SEL = '[data-testid="composer-provider-trigger"]';
|
|
14305
|
+
var EDIT_BAR_SEL = '[data-testid="v4-composer-edit-bar"]';
|
|
14306
|
+
var EDIT_BTN_PREFIX = "v4-edit-";
|
|
14307
|
+
var ITEM_PREFIX = "chat-model-select-item-";
|
|
14308
|
+
var GROUP_PREFIX = "chat-model-select-group-";
|
|
14309
|
+
var installed10 = false;
|
|
14310
|
+
var enabled15 = true;
|
|
14311
|
+
var modelBeforeEdit = null;
|
|
14312
|
+
var pendingEdit = false;
|
|
14313
|
+
var editRequestAt = 0;
|
|
14314
|
+
var providerListAt = 0;
|
|
14315
|
+
var applying = false;
|
|
14316
|
+
function currentModelValue() {
|
|
14317
|
+
const trigger = document.querySelector(TRIGGER_SEL2);
|
|
14318
|
+
return trigger ? trigger.getAttribute("data-model-current-value") || "" : "";
|
|
14319
|
+
}
|
|
14320
|
+
function decodeProviderId(value) {
|
|
14321
|
+
if (!value || !value.startsWith("custom:")) return null;
|
|
14322
|
+
const body = value.slice("custom:".length);
|
|
14323
|
+
const index = body.indexOf(":");
|
|
14324
|
+
const encoded = index < 0 ? body : body.slice(0, index);
|
|
14325
|
+
try {
|
|
14326
|
+
return decodeURIComponent(encoded);
|
|
14327
|
+
} catch {
|
|
14328
|
+
return encoded;
|
|
14329
|
+
}
|
|
14330
|
+
}
|
|
14331
|
+
function findByTestId(exact) {
|
|
14332
|
+
return [...document.querySelectorAll("[data-testid]")].find(
|
|
14333
|
+
(el) => el.getAttribute("data-testid") === exact
|
|
14334
|
+
) || null;
|
|
14335
|
+
}
|
|
14336
|
+
function clickModelItem(value) {
|
|
14337
|
+
const item = findByTestId(ITEM_PREFIX + value);
|
|
14338
|
+
if (!item) return false;
|
|
14339
|
+
item.click();
|
|
14340
|
+
return true;
|
|
14341
|
+
}
|
|
14342
|
+
function openProviderList() {
|
|
14343
|
+
const trigger = document.querySelector(PROVIDER_TRIGGER_SEL);
|
|
14344
|
+
if (!trigger) return false;
|
|
14345
|
+
trigger.focus();
|
|
14346
|
+
for (const name of ["pointerenter", "mouseenter", "mousemove"]) {
|
|
14347
|
+
trigger.dispatchEvent(new MouseEvent(name, { bubbles: true, cancelable: true, view: window }));
|
|
14348
|
+
}
|
|
14349
|
+
trigger.click();
|
|
14350
|
+
return true;
|
|
14351
|
+
}
|
|
14352
|
+
function openProviderGroup(providerId) {
|
|
14353
|
+
const group = findByTestId(GROUP_PREFIX + "registry-provider:" + providerId);
|
|
14354
|
+
if (!group) {
|
|
14355
|
+
if (Date.now() - providerListAt > 400) {
|
|
14356
|
+
providerListAt = Date.now();
|
|
14357
|
+
openProviderList();
|
|
14358
|
+
}
|
|
14359
|
+
return false;
|
|
14360
|
+
}
|
|
14361
|
+
group.focus();
|
|
14362
|
+
for (const name of ["pointerenter", "mouseenter", "mousemove"]) {
|
|
14363
|
+
group.dispatchEvent(new MouseEvent(name, { bubbles: true, cancelable: true, view: window }));
|
|
14364
|
+
}
|
|
14365
|
+
group.click();
|
|
14366
|
+
return true;
|
|
14367
|
+
}
|
|
14368
|
+
function menuIsOpen() {
|
|
14369
|
+
return Boolean(
|
|
14370
|
+
document.querySelector(`[data-testid^="${ITEM_PREFIX}"]`) || document.querySelector(`[data-testid^="${GROUP_PREFIX}"]`)
|
|
14371
|
+
);
|
|
14372
|
+
}
|
|
14373
|
+
function openModelMenu() {
|
|
14374
|
+
const trigger = document.querySelector(TRIGGER_SEL2);
|
|
14375
|
+
if (!trigger || trigger.disabled || trigger.getAttribute("aria-disabled") === "true") {
|
|
14376
|
+
return false;
|
|
14377
|
+
}
|
|
14378
|
+
if (trigger.getAttribute("aria-expanded") === "true" || menuIsOpen()) return true;
|
|
14379
|
+
trigger.focus();
|
|
14380
|
+
const base = {
|
|
14381
|
+
bubbles: true,
|
|
14382
|
+
cancelable: true,
|
|
14383
|
+
composed: true,
|
|
14384
|
+
view: window,
|
|
14385
|
+
button: 0,
|
|
14386
|
+
pointerId: 1,
|
|
14387
|
+
pointerType: "mouse",
|
|
14388
|
+
isPrimary: true
|
|
14389
|
+
};
|
|
14390
|
+
trigger.dispatchEvent(new PointerEvent("pointerdown", { ...base, buttons: 1 }));
|
|
14391
|
+
trigger.dispatchEvent(new PointerEvent("pointerup", { ...base, buttons: 0 }));
|
|
14392
|
+
trigger.click();
|
|
14393
|
+
return true;
|
|
14394
|
+
}
|
|
14395
|
+
function setModelDirect(value) {
|
|
14396
|
+
const trigger = document.querySelector(TRIGGER_SEL2);
|
|
14397
|
+
if (!trigger) return false;
|
|
14398
|
+
const fiberKey = Object.keys(trigger).find((k) => k.startsWith("__reactFiber$"));
|
|
14399
|
+
if (!fiberKey) return false;
|
|
14400
|
+
let fiber = trigger[fiberKey];
|
|
14401
|
+
for (let i = 0; fiber && i < 80; i += 1) {
|
|
14402
|
+
const props = fiber.memoizedProps || {};
|
|
14403
|
+
if (props.composerOptions && typeof props.composerOptions === "object" && typeof props.onValueChange === "function") {
|
|
14404
|
+
try {
|
|
14405
|
+
props.onValueChange(value);
|
|
14406
|
+
return true;
|
|
14407
|
+
} catch {
|
|
14408
|
+
return false;
|
|
14409
|
+
}
|
|
14410
|
+
}
|
|
14411
|
+
fiber = fiber.return;
|
|
14412
|
+
}
|
|
14413
|
+
return false;
|
|
14414
|
+
}
|
|
14415
|
+
function applyModel(value) {
|
|
14416
|
+
if (!setModelDirect(value)) {
|
|
14417
|
+
selectModel(value);
|
|
14418
|
+
return;
|
|
14419
|
+
}
|
|
14420
|
+
setTimeout(() => {
|
|
14421
|
+
if (!enabled15 || !document.querySelector(EDIT_BAR_SEL)) return;
|
|
14422
|
+
if (currentModelValue() !== value) selectModel(value);
|
|
14423
|
+
}, 300);
|
|
14424
|
+
}
|
|
14425
|
+
function closeModelMenu() {
|
|
14426
|
+
const base = {
|
|
14427
|
+
bubbles: true,
|
|
14428
|
+
cancelable: true,
|
|
14429
|
+
composed: true,
|
|
14430
|
+
view: window,
|
|
14431
|
+
button: 0,
|
|
14432
|
+
pointerId: 1,
|
|
14433
|
+
pointerType: "mouse",
|
|
14434
|
+
isPrimary: true
|
|
14435
|
+
};
|
|
14436
|
+
document.body.dispatchEvent(new PointerEvent("pointerdown", { ...base, buttons: 1 }));
|
|
14437
|
+
document.body.dispatchEvent(new PointerEvent("pointerup", { ...base, buttons: 0 }));
|
|
14438
|
+
document.body.dispatchEvent(new MouseEvent("click", { ...base, buttons: 0 }));
|
|
14439
|
+
}
|
|
14440
|
+
function selectModel(value) {
|
|
14441
|
+
if (applying || !enabled15) return;
|
|
14442
|
+
if (currentModelValue() === value) return;
|
|
14443
|
+
applying = true;
|
|
14444
|
+
let attempts = 0;
|
|
14445
|
+
let groupOpened = false;
|
|
14446
|
+
const step = () => {
|
|
14447
|
+
if (!enabled15 || currentModelValue() === value) {
|
|
14448
|
+
applying = false;
|
|
14449
|
+
return;
|
|
14450
|
+
}
|
|
14451
|
+
if (!menuIsOpen()) {
|
|
14452
|
+
openModelMenu();
|
|
14453
|
+
groupOpened = false;
|
|
14454
|
+
}
|
|
14455
|
+
if (clickModelItem(value)) {
|
|
14456
|
+
setTimeout(() => {
|
|
14457
|
+
closeModelMenu();
|
|
14458
|
+
applying = false;
|
|
14459
|
+
}, 100);
|
|
14460
|
+
return;
|
|
14461
|
+
}
|
|
14462
|
+
const providerId = decodeProviderId(value);
|
|
14463
|
+
if (providerId) {
|
|
14464
|
+
if (!groupOpened) groupOpened = openProviderGroup(providerId);
|
|
14465
|
+
} else {
|
|
14466
|
+
for (const group of document.querySelectorAll(`[data-testid^="${GROUP_PREFIX}"]`)) {
|
|
14467
|
+
group.focus();
|
|
14468
|
+
for (const name of ["pointerenter", "mouseenter", "mousemove"]) {
|
|
14469
|
+
group.dispatchEvent(
|
|
14470
|
+
new MouseEvent(name, { bubbles: true, cancelable: true, view: window })
|
|
14471
|
+
);
|
|
14472
|
+
}
|
|
14473
|
+
group.click();
|
|
14474
|
+
if (clickModelItem(value)) {
|
|
14475
|
+
applying = false;
|
|
14476
|
+
return;
|
|
14477
|
+
}
|
|
14478
|
+
}
|
|
14479
|
+
}
|
|
14480
|
+
attempts += 1;
|
|
14481
|
+
if (attempts < 20) setTimeout(step, 120);
|
|
14482
|
+
else {
|
|
14483
|
+
applying = false;
|
|
14484
|
+
console.warn("[zcodepro] composer-edit-model: \u6CA1\u80FD\u9009\u56DE\u6A21\u578B " + value);
|
|
14485
|
+
}
|
|
14486
|
+
};
|
|
14487
|
+
if (!menuIsOpen() && !openModelMenu()) {
|
|
14488
|
+
applying = false;
|
|
14489
|
+
return;
|
|
14490
|
+
}
|
|
14491
|
+
setTimeout(step, 80);
|
|
14492
|
+
}
|
|
14493
|
+
function onEditClick(event) {
|
|
14494
|
+
if (!enabled15) return;
|
|
14495
|
+
const target = event.target;
|
|
14496
|
+
if (!(target instanceof Element)) return;
|
|
14497
|
+
if (!target.closest(`[data-testid^="${EDIT_BTN_PREFIX}"]`)) return;
|
|
14498
|
+
const value = currentModelValue();
|
|
14499
|
+
if (document.querySelector(EDIT_BAR_SEL)) return;
|
|
14500
|
+
if (!value) return;
|
|
14501
|
+
modelBeforeEdit = value;
|
|
14502
|
+
pendingEdit = true;
|
|
14503
|
+
editRequestAt = Date.now();
|
|
14504
|
+
}
|
|
14505
|
+
function onMutate() {
|
|
14506
|
+
if (!enabled15) return;
|
|
14507
|
+
const bar = document.querySelector(EDIT_BAR_SEL);
|
|
14508
|
+
if (!bar) {
|
|
14509
|
+
if (!pendingEdit || Date.now() - editRequestAt > 3e3) {
|
|
14510
|
+
pendingEdit = false;
|
|
14511
|
+
modelBeforeEdit = null;
|
|
14512
|
+
}
|
|
14513
|
+
applying = false;
|
|
14514
|
+
return;
|
|
14515
|
+
}
|
|
14516
|
+
if (!pendingEdit || !modelBeforeEdit) return;
|
|
14517
|
+
if (Date.now() - editRequestAt > 3e3) {
|
|
14518
|
+
pendingEdit = false;
|
|
14519
|
+
modelBeforeEdit = null;
|
|
14520
|
+
return;
|
|
14521
|
+
}
|
|
14522
|
+
pendingEdit = false;
|
|
14523
|
+
const target = modelBeforeEdit;
|
|
14524
|
+
let checks = 0;
|
|
14525
|
+
const tick7 = () => {
|
|
14526
|
+
if (!enabled15 || !document.querySelector(EDIT_BAR_SEL)) return;
|
|
14527
|
+
const current2 = currentModelValue();
|
|
14528
|
+
if (current2 && current2 !== target) {
|
|
14529
|
+
const official2 = current2;
|
|
14530
|
+
applyModel(target);
|
|
14531
|
+
const watch = (left) => {
|
|
14532
|
+
if (!enabled15 || !document.querySelector(EDIT_BAR_SEL)) return;
|
|
14533
|
+
if (currentModelValue() === official2 && left > 0) {
|
|
14534
|
+
applyModel(target);
|
|
14535
|
+
setTimeout(() => watch(left - 1), 400);
|
|
14536
|
+
}
|
|
14537
|
+
};
|
|
14538
|
+
setTimeout(() => watch(2), 400);
|
|
14539
|
+
return;
|
|
14540
|
+
}
|
|
14541
|
+
checks += 1;
|
|
14542
|
+
if (checks < 16) setTimeout(tick7, 50);
|
|
14543
|
+
};
|
|
14544
|
+
setTimeout(tick7, 60);
|
|
14545
|
+
}
|
|
14546
|
+
function startComposerEditModel() {
|
|
14547
|
+
if (installed10 || typeof document === "undefined") return;
|
|
14548
|
+
installed10 = true;
|
|
14549
|
+
void getConfig().then((cfg) => {
|
|
14550
|
+
enabled15 = cfg.features ? cfg.features.composerEditModel !== false : true;
|
|
14551
|
+
}).catch(() => {
|
|
14552
|
+
});
|
|
14553
|
+
window.addEventListener("zcodepro:config-changed", () => {
|
|
14554
|
+
void getConfig(true).then((cfg) => {
|
|
14555
|
+
enabled15 = cfg.features ? cfg.features.composerEditModel !== false : true;
|
|
14556
|
+
if (!enabled15) {
|
|
14557
|
+
pendingEdit = false;
|
|
14558
|
+
modelBeforeEdit = null;
|
|
14559
|
+
}
|
|
14560
|
+
}).catch(() => {
|
|
14561
|
+
});
|
|
14562
|
+
});
|
|
14563
|
+
document.addEventListener("click", onEditClick, true);
|
|
14564
|
+
new MutationObserver(onMutate).observe(document.body, { childList: true, subtree: true });
|
|
14565
|
+
onMutate();
|
|
14566
|
+
}
|
|
14567
|
+
|
|
14166
14568
|
// src/inject/index.js
|
|
14167
14569
|
init_ui();
|
|
14168
14570
|
(function zcodeproInject() {
|
|
@@ -14307,6 +14709,10 @@
|
|
|
14307
14709
|
startComposerProvider();
|
|
14308
14710
|
} catch {
|
|
14309
14711
|
}
|
|
14712
|
+
try {
|
|
14713
|
+
startComposerEditModel();
|
|
14714
|
+
} catch {
|
|
14715
|
+
}
|
|
14310
14716
|
try {
|
|
14311
14717
|
startSettingsEntry();
|
|
14312
14718
|
} catch {
|