@logictan/dsh-easyrewrite 2.6.0 → 2.7.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/lib/client.js +22 -36
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -83,7 +83,7 @@ window.__ModuleLoader__.load({
|
|
|
83
83
|
function recallVisualMode() { return getSetting(SETTING_KEYS.visualMode, "simple"); }
|
|
84
84
|
function showOriginalImages() { return getBool("dsh-easyrewrite:showOriginalImages", true); }
|
|
85
85
|
// 行为开关(设置页控制)
|
|
86
|
-
function rewriteOnClick() { return getBool("dsh-easyrewrite:rewriteOnClick",
|
|
86
|
+
function rewriteOnClick() { return getBool("dsh-easyrewrite:rewriteOnClick", false); }
|
|
87
87
|
function editOffShowRecall() { return getBool("dsh-easyrewrite:editOffShowRecall", true); }
|
|
88
88
|
function recallConfirmEnabled() { return getBool("dsh-easyrewrite:recallConfirm", true); }
|
|
89
89
|
|
|
@@ -1592,7 +1592,7 @@ window.__ModuleLoader__.load({
|
|
|
1592
1592
|
errNoBoundary: "该消息之前没有可截断的闭合回合边界(截断/首条消息无法撤回或编辑)",
|
|
1593
1593
|
errTurnOpen: "该消息所在回合尚未结束,请等待回复完成后再操作",
|
|
1594
1594
|
errGeneric: "操作失败,请重试",
|
|
1595
|
-
resetNotice: "
|
|
1595
|
+
resetNotice: "该消息之前没有可保留的历史,已重置——修改后的内容将作为新对话的第一条发出",
|
|
1596
1596
|
turnOpenNotice: "回复仍在生成中,请等待回复完成后再撤回。",
|
|
1597
1597
|
sectionUpdate: "更新",
|
|
1598
1598
|
currentVersion: "当前版本",
|
|
@@ -1685,7 +1685,7 @@ window.__ModuleLoader__.load({
|
|
|
1685
1685
|
errNoBoundary: "No truncation boundary before this message (first/truncated message cannot be recalled or edited)",
|
|
1686
1686
|
errTurnOpen: "This message's turn is still running; wait for the reply to finish",
|
|
1687
1687
|
errGeneric: "Operation failed, please retry",
|
|
1688
|
-
resetNotice: "
|
|
1688
|
+
resetNotice: "There is no earlier history to keep, so the conversation was reset — your edit will be sent as the first message of a new conversation",
|
|
1689
1689
|
turnOpenNotice: "A reply is still being generated. Please wait for it to finish before recalling.",
|
|
1690
1690
|
sectionUpdate: "Update",
|
|
1691
1691
|
currentVersion: "Current version",
|
|
@@ -1778,7 +1778,7 @@ window.__ModuleLoader__.load({
|
|
|
1778
1778
|
errNoBoundary: "このメッセージの前に切り詰め境界がありません(切り詰め後・最初のメッセージは撤回/編集できません)",
|
|
1779
1779
|
errTurnOpen: "このメッセージのターンはまだ終了していません。返信完了後にお試しください",
|
|
1780
1780
|
errGeneric: "操作に失敗しました。もう一度お試しください",
|
|
1781
|
-
resetNotice: "
|
|
1781
|
+
resetNotice: "このメッセージより前の履歴がないためリセットしました——編集内容は新しい会話の最初のメッセージとして送信されます",
|
|
1782
1782
|
turnOpenNotice: "返信がまだ生成中です。返信が完了してから取り消してください",
|
|
1783
1783
|
sectionUpdate: "更新",
|
|
1784
1784
|
currentVersion: "現在のバージョン",
|
|
@@ -2498,20 +2498,19 @@ window.__ModuleLoader__.load({
|
|
|
2498
2498
|
}
|
|
2499
2499
|
|
|
2500
2500
|
/** 极限场景重置(首条消息/截断会话首条,无前置闭合边界,无法 fork):
|
|
2501
|
-
*
|
|
2502
|
-
*
|
|
2503
|
-
* - 全新会话首条(无家族):归档当前 → 回到空白新对话(官方 project() 检测归档即回 hero)。
|
|
2501
|
+
* 归档当前会话 → 在所属工作区打开空白新会话;编辑模式经 resume 机制把修改后的文本
|
|
2502
|
+
* 作为新会话的**第一条**自动发出(DESIGN §2.3:目标消息之前没有历史,新对话即修改稿本身)。
|
|
2504
2503
|
* @param mode - "recall" | "edit"
|
|
2505
2504
|
* @param text - edit 模式的修改后文本
|
|
2506
2505
|
* @param props - 组件 inject 面
|
|
2507
2506
|
*/
|
|
2508
2507
|
function resetConversation(sessionId, mode, text, props, imageIds, selOverride, stagedDraft) {
|
|
2509
2508
|
log("info", "reset", "首条消息重置对话", { sessionId: sessionId, mode: mode });
|
|
2510
|
-
// v2.1.1
|
|
2509
|
+
// v2.1.1:新会话发送前需要恢复当前模型/挡位
|
|
2511
2510
|
// v2.2:气泡编辑 chip 的本地选择优先(selOverride),撤回键路径不传 → 原语义
|
|
2512
2511
|
var msel = selOverride || (props.modelSel ? props.modelSel.capture(sessionId) : null);
|
|
2513
2512
|
writePending(sessionId, null);
|
|
2514
|
-
// 1)
|
|
2513
|
+
// 1) 归档当前会话(project() 检测 current 归档 → 自动回 hero;新会话随后被打开)
|
|
2515
2514
|
try {
|
|
2516
2515
|
var archiver = typeof props.archiveSession === "function"
|
|
2517
2516
|
? props.archiveSession
|
|
@@ -2524,26 +2523,10 @@ window.__ModuleLoader__.load({
|
|
|
2524
2523
|
log("warn", "reset", "归档能力不可用", { sessionId: sessionId });
|
|
2525
2524
|
}
|
|
2526
2525
|
} catch (e) { /* ignore */ }
|
|
2527
|
-
// 2)
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
var parentId = fam && fam.versions.length >= 2 && fam.index > 0 ? fam.versions[fam.index - 1] : null;
|
|
2532
|
-
if (parentId) {
|
|
2533
|
-
if (mode === "edit" && typeof text === "string") {
|
|
2534
|
-
try { localStorage.setItem("dsh-easyrewrite:resume-send:" + parentId, JSON.stringify({ draftText: text, t: Date.now(), imageIds: imageIds || [], sel: msel, stagedDraft: stagedDraft || null })); } catch (e) { /* ignore */ }
|
|
2535
|
-
}
|
|
2536
|
-
var doOpenParent = function () {
|
|
2537
|
-
safeOpenSession(parentId, props);
|
|
2538
|
-
};
|
|
2539
|
-
if (typeof props.restoreSession === "function") {
|
|
2540
|
-
try { props.restoreSession(parentId).then(doOpenParent, doOpenParent); return; } catch (e) { /* fallthrough */ }
|
|
2541
|
-
}
|
|
2542
|
-
doOpenParent();
|
|
2543
|
-
return;
|
|
2544
|
-
}
|
|
2545
|
-
} catch (e) { /* ignore */ }
|
|
2546
|
-
// 3) 场景 1:全新会话首条 → 无缝打开空白新会话(编辑模式经 resume 自动发送编辑文本)
|
|
2526
|
+
// 2) 打开空白新会话(编辑模式经 resume 自动发送编辑文本)
|
|
2527
|
+
// 目标消息之前没有任何历史 → 新对话 = 修改后的消息本身(DESIGN §2.3)。
|
|
2528
|
+
// 此前这里先走「家族父版本」分支,把修改后的文本**追加到父版本历史末尾**:
|
|
2529
|
+
// 首条消息的编辑于是变成「整段旧历史 + 修改稿」,与 §2.3 的截断语义相反。
|
|
2547
2530
|
try {
|
|
2548
2531
|
var wsId = null;
|
|
2549
2532
|
if (props.ctxWorkspaces && typeof props.ctxWorkspaces.list === "object" && typeof props.ctxWorkspaces.list.getSnapshot === "function") {
|
|
@@ -2557,7 +2540,7 @@ window.__ModuleLoader__.load({
|
|
|
2557
2540
|
}
|
|
2558
2541
|
}
|
|
2559
2542
|
}
|
|
2560
|
-
log("info", "reset", "
|
|
2543
|
+
log("info", "reset", "空白新会话:工作区定位", { sessionId: sessionId, wsId: wsId, hasConnect: !!(ctxUiWorkspaceRef && typeof ctxUiWorkspaceRef.connectWorkspace === "function") });
|
|
2561
2544
|
var wsConnector = (ctxUiWorkspaceRef && typeof ctxUiWorkspaceRef.connectWorkspace === "function") ? ctxUiWorkspaceRef : ((props.ctxWorkspaces && typeof props.ctxWorkspaces.connectWorkspace === "function") ? props.ctxWorkspaces : null);
|
|
2562
2545
|
if (wsId && wsConnector) {
|
|
2563
2546
|
wsConnector.connectWorkspace(wsId).then(function (newId) {
|
|
@@ -2572,7 +2555,7 @@ window.__ModuleLoader__.load({
|
|
|
2572
2555
|
}
|
|
2573
2556
|
} catch (e) { /* ignore */ }
|
|
2574
2557
|
// 兜底:归档已生效,官方自动回 hero
|
|
2575
|
-
log("
|
|
2558
|
+
log("warn", "reset", "无可用的空白新会话通道(已归档,回 hero)", { sessionId: sessionId, mode: mode, wsId: wsId });
|
|
2576
2559
|
}
|
|
2577
2560
|
|
|
2578
2561
|
/** 版本翻页器 < X >:撤回/编辑重发产生的版本家族切换(官方 assistant-actions 操作区)。
|
|
@@ -3849,7 +3832,7 @@ window.__ModuleLoader__.load({
|
|
|
3849
3832
|
),
|
|
3850
3833
|
React.createElement(
|
|
3851
3834
|
"div", { style: actionsStyle },
|
|
3852
|
-
actionButton(
|
|
3835
|
+
actionButton(L.sectionRecall, L.sectionRecall, function (e) {
|
|
3853
3836
|
e.stopPropagation();
|
|
3854
3837
|
// 编辑态直接转撤回:丢弃编辑草稿 → 确认胶囊(首条消息同样走确认,确定后重置对话)
|
|
3855
3838
|
if (isEditPending) writePending(sessionId, null);
|
|
@@ -3879,7 +3862,7 @@ window.__ModuleLoader__.load({
|
|
|
3879
3862
|
"div", { style: rowStyle, "data-dsh-easyrewrite": "user", "data-time-hover-root": true },
|
|
3880
3863
|
renderMessageImagesCompat(msgImages, props),
|
|
3881
3864
|
React.createElement(
|
|
3882
|
-
"div", { className: "dsh-easyrewrite-bubble", style: bubbleStyle, onClick: onBubbleClick, title: L.clickEdit },
|
|
3865
|
+
"div", { className: "dsh-easyrewrite-bubble", style: bubbleStyle, onClick: onBubbleClick, title: rewriteOnClick() ? L.clickEdit : undefined },
|
|
3883
3866
|
text || L.emptyMsg
|
|
3884
3867
|
),
|
|
3885
3868
|
confirming
|
|
@@ -3946,7 +3929,7 @@ window.__ModuleLoader__.load({
|
|
|
3946
3929
|
// 撤回键:rewrite 关闭且二级「关闭时显示撤回键」也关闭 → 隐藏
|
|
3947
3930
|
(!rewriteOnClick() && !editOffShowRecall())
|
|
3948
3931
|
? null
|
|
3949
|
-
: actionButton(
|
|
3932
|
+
: actionButton(L.sectionRecall, L.sectionRecall, function (e) {
|
|
3950
3933
|
e.stopPropagation();
|
|
3951
3934
|
if (pending && pending.type === "recall") {
|
|
3952
3935
|
log("warn", "recall", "已有待处理撤回(单待定约束)");
|
|
@@ -3977,7 +3960,7 @@ window.__ModuleLoader__.load({
|
|
|
3977
3960
|
}
|
|
3978
3961
|
}, iconImg(ICONS.recall, L.recall), "recall-key"),
|
|
3979
3962
|
// 编辑键:rewrite 关闭时显示(与撤回键同时)
|
|
3980
|
-
rewriteOnClick() ? null : actionButton(
|
|
3963
|
+
rewriteOnClick() ? null : actionButton(L.sectionEdit, L.sectionEdit, function (e) {
|
|
3981
3964
|
e.stopPropagation();
|
|
3982
3965
|
enterEdit(e.currentTarget ? e.currentTarget.offsetWidth : 0);
|
|
3983
3966
|
}, iconImg(ICONS.edit, "编辑")),
|
|
@@ -4087,7 +4070,10 @@ window.__ModuleLoader__.load({
|
|
|
4087
4070
|
} catch (eDbg) { /* ignore */ }
|
|
4088
4071
|
try { ctxConversationRef = ctx.conversation; } catch (e) { ctxConversationRef = null; }
|
|
4089
4072
|
try { ctxUiConversationRef = (typeof ctx.get === "function") ? (ctx.get("uiConversation") || null) : null; } catch (eUic) { ctxUiConversationRef = null; }
|
|
4090
|
-
|
|
4073
|
+
// 注意:uiWorkspace 不在本插件的 inject 清单内,`ctx.uiWorkspace` 抛错(见下方
|
|
4074
|
+
// invokeOpenSession 的 try/catch);此前把它放在 || 左侧,抛错被 catch 吞掉,导致
|
|
4075
|
+
// ctx.get("uiWorkspace") 永远不可达、ctxUiWorkspaceRef 恒为 null(空白新会话通道自 2.6.0 起失效)。
|
|
4076
|
+
try { ctxUiWorkspaceRef = (typeof ctx.get === "function") ? (ctx.get("uiWorkspace") || null) : null; } catch (eUiw) { ctxUiWorkspaceRef = null; }
|
|
4091
4077
|
function invokeOpenSession(id) {
|
|
4092
4078
|
try {
|
|
4093
4079
|
if (ctx.uiWorkspace && typeof ctx.uiWorkspace.openSession === "function") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logictan/dsh-easyrewrite",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "DSH Web内目前最无感的消息撤回、重编辑插件,原版体验,兼容性强,功能简单可开关,设置丰富,现代化轻量ui框架。The most seamless message recall & re-edit plugin for DSH Web — native experience, strong compatibility, simple toggles, rich settings, modern lightweight UI. DSH Web で最もシームレスなメッセージ撤回・再編集プラグイン——ネイティブ体験、高い互換性、シンプルなトグル、充実した設定、モダンで軽量な UI。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|