@xsok/dsh-enhanced 0.2.2-5 → 0.2.2-6
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/CHANGELOG.md +20 -0
- package/client.js +1 -1
- package/host/engine/index.js +12 -1
- package/host/engine/sessions.js +15 -2
- package/host/engine/workspace.js +32 -0
- package/host/envcheck.js +3 -2
- package/index.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
版本号前三位对应主程序版本,最后一段是插件自身的发布序号。
|
|
4
4
|
|
|
5
|
+
## 0.2.2-6
|
|
6
|
+
|
|
7
|
+
### 改进
|
|
8
|
+
|
|
9
|
+
- 同步日志展开时隐藏“上次同步”摘要,避免与列表首行重复。
|
|
10
|
+
- 环境检测显示的插件版本改为读取 `package.json`,与发布版本保持一致。
|
|
11
|
+
|
|
12
|
+
### 修复
|
|
13
|
+
|
|
14
|
+
- 会话移动后同步不生效:旧工作区目录残留同一会话,云端出现两份。
|
|
15
|
+
- 工作区合并按会话 cwd 去重,一个会话不再挂在两个工作区。
|
|
16
|
+
- 推送阶段清理同一会话的重复副本,避免每次同步都推送一次。
|
|
17
|
+
|
|
18
|
+
## 0.2.2-5
|
|
19
|
+
|
|
20
|
+
### 改进
|
|
21
|
+
|
|
22
|
+
- 包元数据补充 `repository`、`homepage`、`bugs`,npm 页面可直接跳转 GitHub 仓库。
|
|
23
|
+
- 发布流程迁移到 GitHub Actions:推送 tag 后自动发布,使用 OIDC 可信发布并附带 provenance 证明。
|
|
24
|
+
|
|
5
25
|
## 0.2.2-4
|
|
6
26
|
|
|
7
27
|
### 改进
|
package/client.js
CHANGED
|
@@ -2131,7 +2131,7 @@ const displayName = (value) => {
|
|
|
2131
2131
|
onClick: () => runtime.store.openRestart(),
|
|
2132
2132
|
}, runtime.t('restart.button')),
|
|
2133
2133
|
),
|
|
2134
|
-
h('button', {
|
|
2134
|
+
state.sync.showLog === true ? null : h('button', {
|
|
2135
2135
|
type: 'button',
|
|
2136
2136
|
className: 'dshe-row-desc dshe-log-toggle',
|
|
2137
2137
|
title: runtime.t('sync.logToggle'),
|
package/host/engine/index.js
CHANGED
|
@@ -10,7 +10,8 @@ import { promises as fsp } from 'node:fs';
|
|
|
10
10
|
import { randomUUID } from 'node:crypto';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { syncSessions } from './sessions.js';
|
|
13
|
-
import { scanSessionGroups } from './scan.js';
|
|
13
|
+
import { scanSessionGroups, scanSessions } from './scan.js';
|
|
14
|
+
import { readSessionFile } from './session.js';
|
|
14
15
|
import { loadPathMap, resolveLocalPath } from './paths.js';
|
|
15
16
|
import { mergeWorkspaceFiles } from './workspace.js';
|
|
16
17
|
import { pruneArchiveEvents, syncArchiveState, writeArchiveEvents } from './archive.js';
|
|
@@ -195,6 +196,16 @@ async function runSyncJsInner(deps) {
|
|
|
195
196
|
sharedFile: path.join(sharedConfig, 'storages', 'workspace.json'),
|
|
196
197
|
tombstones,
|
|
197
198
|
resolvePath: async (value) => (await resolveCwd(value)).path,
|
|
199
|
+
// Lazy session lookup: only paid when a merge finds duplicate memberships.
|
|
200
|
+
sessionCwd: async (id) => {
|
|
201
|
+
const found = (await scanSessions(path.join(dshHome, 'sessions'))).get(id);
|
|
202
|
+
if (found === undefined) return null;
|
|
203
|
+
try {
|
|
204
|
+
return (await readSessionFile(found.file)).header.cwd ?? null;
|
|
205
|
+
} catch {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
},
|
|
198
209
|
isDirectory,
|
|
199
210
|
stateDir,
|
|
200
211
|
machineId,
|
package/host/engine/sessions.js
CHANGED
|
@@ -262,9 +262,13 @@ export async function syncSessions(deps) {
|
|
|
262
262
|
continue;
|
|
263
263
|
}
|
|
264
264
|
const sharedEntry = shared.get(id);
|
|
265
|
+
// A session parked under another workspace folder was moved here: the file
|
|
266
|
+
// is authoritative locally even when no new event was appended.
|
|
267
|
+
const relocated = sharedEntry !== undefined
|
|
268
|
+
&& path.basename(path.dirname(entry.file)) !== path.basename(path.dirname(sharedEntry.file));
|
|
265
269
|
// Append-only logs: the one holding more events is the newer one. Upload and
|
|
266
270
|
// download timestamps are meaningless here because each transfer rewrites them.
|
|
267
|
-
if (sharedEntry !== undefined) {
|
|
271
|
+
if (sharedEntry !== undefined && !relocated) {
|
|
268
272
|
const localSeq = await lastContentSeq(entry.file);
|
|
269
273
|
const sharedSeq = await lastContentSeq(sharedEntry.file);
|
|
270
274
|
if (sharedSeq >= 0 && localSeq >= 0) {
|
|
@@ -278,7 +282,16 @@ export async function syncSessions(deps) {
|
|
|
278
282
|
}
|
|
279
283
|
}
|
|
280
284
|
try {
|
|
281
|
-
if (apply)
|
|
285
|
+
if (apply) {
|
|
286
|
+
const written = await copySessionTo(entry, sharedRoot);
|
|
287
|
+
// A moved session can still exist under its previous project key in the
|
|
288
|
+
// share; leaving it makes every later run look like a push.
|
|
289
|
+
if (relocated && sharedEntry !== undefined) {
|
|
290
|
+
await fsp.rm(sharedEntry.dir, { recursive: true, force: true }).catch(() => {});
|
|
291
|
+
shared.delete(id);
|
|
292
|
+
}
|
|
293
|
+
await dropOtherCopies(sharedRoot, id, path.dirname(written));
|
|
294
|
+
}
|
|
282
295
|
pushed += 1;
|
|
283
296
|
if (pushedIds.length < 300) pushedIds.push(id);
|
|
284
297
|
} catch (error) {
|
package/host/engine/workspace.js
CHANGED
|
@@ -61,6 +61,7 @@ export async function mergeWorkspaceDocuments(localDoc, sharedDoc, options = {})
|
|
|
61
61
|
stateDir = null,
|
|
62
62
|
machineId = null,
|
|
63
63
|
apply = true,
|
|
64
|
+
sessionCwd = null,
|
|
64
65
|
} = options;
|
|
65
66
|
|
|
66
67
|
// Workspace deletions used to be silent: the other machine's document still
|
|
@@ -145,6 +146,37 @@ export async function mergeWorkspaceDocuments(localDoc, sharedDoc, options = {})
|
|
|
145
146
|
else missing.push({ title: entry.title, path: entry.path });
|
|
146
147
|
}
|
|
147
148
|
|
|
149
|
+
// A session belongs to one workspace only. Older merges unioned membership, so a
|
|
150
|
+
// moved session stayed listed under its previous workspace; resolve the real one
|
|
151
|
+
// from the session header and drop the rest.
|
|
152
|
+
if (typeof sessionCwd === 'function') {
|
|
153
|
+
const owners = new Map();
|
|
154
|
+
for (const [uuid, record] of Object.entries(shared)) {
|
|
155
|
+
for (const id of record.sessionIds) {
|
|
156
|
+
const list = owners.get(id) ?? [];
|
|
157
|
+
list.push(uuid);
|
|
158
|
+
owners.set(id, list);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
for (const [id, uuids] of owners) {
|
|
162
|
+
if (uuids.length < 2) continue;
|
|
163
|
+
let cwd = null;
|
|
164
|
+
try {
|
|
165
|
+
cwd = await sessionCwd(id);
|
|
166
|
+
} catch {
|
|
167
|
+
cwd = null;
|
|
168
|
+
}
|
|
169
|
+
const normalized = typeof cwd === 'string' && cwd !== '' ? await resolvePath(cwd) : null;
|
|
170
|
+
const keep = normalized === null
|
|
171
|
+
? uuids[0]
|
|
172
|
+
: (uuids.find((uuid) => shared[uuid]?.path === normalized) ?? uuids[0]);
|
|
173
|
+
for (const uuid of uuids) {
|
|
174
|
+
if (uuid === keep) continue;
|
|
175
|
+
shared[uuid].sessionIds = shared[uuid].sessionIds.filter((value) => value !== id);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
148
180
|
const archived = [];
|
|
149
181
|
const pinned = [];
|
|
150
182
|
let initialized = false;
|
package/host/envcheck.js
CHANGED
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
* A failed check never throws; it is reported so the user can export a report.
|
|
7
7
|
*/
|
|
8
8
|
import { promises as fsp } from 'node:fs';
|
|
9
|
+
import { pluginVersion } from './version.js';
|
|
9
10
|
import path from 'node:path';
|
|
10
11
|
import os from 'node:os';
|
|
11
12
|
import zlib from 'node:zlib';
|
|
12
13
|
import { scanFrames } from './engine/zstd.js';
|
|
13
14
|
import { scanSessions, projectKey } from './engine/scan.js';
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
|
|
16
17
|
|
|
17
18
|
async function readJson(file) {
|
|
18
19
|
try {
|
|
@@ -227,7 +228,7 @@ export async function runEnvironmentCheck(deps) {
|
|
|
227
228
|
return {
|
|
228
229
|
ok: failed.length === 0,
|
|
229
230
|
checkedAt: new Date().toISOString(),
|
|
230
|
-
pluginVersion:
|
|
231
|
+
pluginVersion: pluginVersion(),
|
|
231
232
|
appVersion: version.version,
|
|
232
233
|
appVersionSource: version.source,
|
|
233
234
|
checks,
|
package/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import path from 'node:path';
|
|
|
26
26
|
import { appendFile } from 'node:fs/promises';
|
|
27
27
|
import { createSearch } from './host/search.js';
|
|
28
28
|
import { restartApplication } from './host/restart.js';
|
|
29
|
+
import { pluginVersion } from './host/version.js';
|
|
29
30
|
import { inspectOverride, overwriteCloud, overwriteLocal } from './host/overwrite.js';
|
|
30
31
|
import { moveCandidates, moveSession, readAllEvents } from './host/move.js';
|
|
31
32
|
import { inspectSyncTarget, readSyncHistory, readSyncState, recordOverwrite, resolveSyncTarget, runSync } from './host/sync.js';
|
|
@@ -216,7 +217,7 @@ export function apply(ctx, config = {}) {
|
|
|
216
217
|
const record = await readEnvRecord(paths);
|
|
217
218
|
return {
|
|
218
219
|
appVersion: current.version,
|
|
219
|
-
pluginVersion:
|
|
220
|
+
pluginVersion: pluginVersion(),
|
|
220
221
|
lastAppVersion: record.lastAppVersion ?? null,
|
|
221
222
|
changed: current.version !== null && record.lastAppVersion !== undefined && record.lastAppVersion !== current.version,
|
|
222
223
|
};
|