dsh-session-rewind 1.3.1 → 1.3.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/lib/client.js +16 -6
- package/package.json +1 -1
- package/test/client-smoke.mjs +12 -0
package/lib/client.js
CHANGED
|
@@ -66,7 +66,7 @@ loader.load({
|
|
|
66
66
|
const CUTS_ROUTE = '/api/session-rewind.cuts';
|
|
67
67
|
const DIAGNOSE_ROUTE = '/api/session-rewind.diagnose';
|
|
68
68
|
const TAIL_ROUTE = '/api/session-rewind.tail';
|
|
69
|
-
const BOOT_REVISION = '1.3.
|
|
69
|
+
const BOOT_REVISION = '1.3.2';
|
|
70
70
|
const HIDDEN_ATTR = 'data-session-rewind-hidden';
|
|
71
71
|
|
|
72
72
|
/** One per-message bridge per session, shared by every TurnRewind instance. */
|
|
@@ -951,11 +951,10 @@ loader.load({
|
|
|
951
951
|
};
|
|
952
952
|
|
|
953
953
|
const runRewind = async (seq, restoreFiles, notice, fromTurn = null) => {
|
|
954
|
-
notice(tr('notice.working'));
|
|
955
954
|
try {
|
|
955
|
+
notice(tr('notice.working'));
|
|
956
956
|
const result = await postJson(INPLACE_ROUTE, { sessionId, seq, restoreFiles });
|
|
957
957
|
if (state.disposed) return;
|
|
958
|
-
if (Number.isInteger(result.hiddenFromTurn)) state.cutTurn = result.hiddenFromTurn;
|
|
959
958
|
if (Array.isArray(result.hiddenTurns) && result.hiddenTurns.length > 0) {
|
|
960
959
|
for (const turn of result.hiddenTurns) {
|
|
961
960
|
if (Number.isInteger(turn)) state.hiddenTurns.add(turn);
|
|
@@ -1005,7 +1004,7 @@ loader.load({
|
|
|
1005
1004
|
}
|
|
1006
1005
|
};
|
|
1007
1006
|
|
|
1008
|
-
const openPopover = (anchor, seq, notice) => {
|
|
1007
|
+
const openPopover = (anchor, seq, notice, turn = null) => {
|
|
1009
1008
|
closePopover();
|
|
1010
1009
|
const popover = document.createElement('div');
|
|
1011
1010
|
popover.setAttribute('data-session-rewind-popover', '');
|
|
@@ -1048,7 +1047,18 @@ loader.load({
|
|
|
1048
1047
|
button.addEventListener('mouseleave', () => {
|
|
1049
1048
|
button.style.background = 'transparent';
|
|
1050
1049
|
});
|
|
1051
|
-
button.addEventListener('click',
|
|
1050
|
+
button.addEventListener('click', () => {
|
|
1051
|
+
try {
|
|
1052
|
+
onClick();
|
|
1053
|
+
} catch (error) {
|
|
1054
|
+
sendDiagnose(sessionId, {
|
|
1055
|
+
reason: 'option-failed',
|
|
1056
|
+
error: String(error && error.message ? error.message : error),
|
|
1057
|
+
boot: BOOT_REVISION,
|
|
1058
|
+
sequence: seq,
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1052
1062
|
return button;
|
|
1053
1063
|
};
|
|
1054
1064
|
popover.appendChild(makeButton(tr('popover.chat'), () => {
|
|
@@ -1186,7 +1196,7 @@ loader.load({
|
|
|
1186
1196
|
event.preventDefault();
|
|
1187
1197
|
event.stopPropagation();
|
|
1188
1198
|
sendDiagnose(sessionId, { reason: 'click', turn, seq, buttons: state.buttons.size, mapped: state.turnToSeq.size });
|
|
1189
|
-
openPopover(button, seq, notice);
|
|
1199
|
+
openPopover(button, seq, notice, turn);
|
|
1190
1200
|
});
|
|
1191
1201
|
anchor.appendChild(button);
|
|
1192
1202
|
state.buttons.set(row, button);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-rewind",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rewind a finished Turn: branch the conversation at any Turn (session header or per-Turn control) and restore every workspace file that Turn changed. · 回合回退:从任意已完成的回合重新开始,并把该回合改动过的工作区文件恢复原状。",
|
|
6
6
|
"icon": "./icon.svg",
|
package/test/client-smoke.mjs
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import assert from 'node:assert/strict';
|
|
10
10
|
import { readFile } from 'node:fs/promises';
|
|
11
|
+
import { readFileSync } from 'node:fs';
|
|
11
12
|
|
|
12
13
|
//#region stubs
|
|
13
14
|
const listeners = new Map();
|
|
@@ -437,4 +438,15 @@ assert.match(textOf(headerTree), /session-rewind\.notice\.unavailable/u);
|
|
|
437
438
|
assert.equal(forkCalls.length, 0);
|
|
438
439
|
//#endregion
|
|
439
440
|
|
|
441
|
+
// --- popover wiring --------------------------------------------------------
|
|
442
|
+
// v1.3.1 shipped a popover whose option callbacks referenced a `turn` the
|
|
443
|
+
// enclosing function never declared. That throws inside a DOM listener, which the
|
|
444
|
+
// browser swallows: clicking a control did nothing at all. Pin the wiring.
|
|
445
|
+
{
|
|
446
|
+
const source = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8');
|
|
447
|
+
assert.match(source, /const openPopover = \(anchor, seq, notice, turn/u);
|
|
448
|
+
assert.match(source, /runRewind\(seq, false, notice, turn\)/u);
|
|
449
|
+
assert.match(source, /runRewind\(seq, true, notice, turn\)/u);
|
|
450
|
+
}
|
|
451
|
+
|
|
440
452
|
console.log('client smoke: all assertions passed');
|