dsh-synapse 0.5.2 → 0.5.3
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/app.js +19 -2
- package/client.js +13 -4
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -268,6 +268,24 @@ function openNewSession() {
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
async function archiveThread(thread) {
|
|
271
|
+
// A DSH-backed thread is archived in DSH itself, so the sidebar and this map
|
|
272
|
+
// share one archive set (issue #21 / #19). Keeping a second local delete is
|
|
273
|
+
// what made the map claim "archived" while DSH still listed the session.
|
|
274
|
+
if (thread.dshSessionId !== null) {
|
|
275
|
+
if (!window.confirm(`在 DSH 中归档「${thread.title}」及其分支?DSH 侧会话也会被归档。`)) return
|
|
276
|
+
try {
|
|
277
|
+
await dshRpc('synapse:archive-session', { sessionId: thread.dshSessionId })
|
|
278
|
+
} catch (error) {
|
|
279
|
+
setError(error instanceof Error ? error.message : '归档失败')
|
|
280
|
+
return
|
|
281
|
+
}
|
|
282
|
+
state.archivedSessionIds.add(thread.dshSessionId)
|
|
283
|
+
state.activeId = state.activeId === thread.id ? (state.workspace?.threads.find(item => item.id !== thread.id)?.id ?? null) : state.activeId
|
|
284
|
+
if (state.inspectorCardId !== null && state.canvasCardsById?.get(state.inspectorCardId)?.dshThreadId === thread.id) state.inspectorCardId = null
|
|
285
|
+
render()
|
|
286
|
+
await refreshSummaries()
|
|
287
|
+
return
|
|
288
|
+
}
|
|
271
289
|
if (!window.confirm(`归档画布中的「${thread.title}」及其分支?DSH 原会话会保留,可在 DSH 内继续查看。`)) return
|
|
272
290
|
await api(`/synapse/api/threads/${thread.id}`, { method: 'DELETE' })
|
|
273
291
|
state.historyBySession.delete(thread.dshSessionId)
|
|
@@ -303,8 +321,6 @@ async function archiveThread(thread) {
|
|
|
303
321
|
} else {
|
|
304
322
|
state.activeId = null
|
|
305
323
|
}
|
|
306
|
-
// Archive in DSH as well, so both sides agree on one archive set (#21 / #19).
|
|
307
|
-
if (thread.dshSessionId !== null) post('synapse:archive-session', { sessionId: thread.dshSessionId })
|
|
308
324
|
await refreshSummaries()
|
|
309
325
|
}
|
|
310
326
|
|
|
@@ -1872,6 +1888,7 @@ window.addEventListener('message', event => {
|
|
|
1872
1888
|
}
|
|
1873
1889
|
}
|
|
1874
1890
|
if (data.type === 'synapse:forked-session' || data.type === 'synapse:created-session' || data.type === 'synapse:message-sent') settleRpc(data.requestId, data.session ?? data)
|
|
1891
|
+
if (data.type === 'synapse:archived-session') settleRpc(data.requestId, data)
|
|
1875
1892
|
if (data.type === 'synapse:bridge-error') { settleRpc(data.requestId, undefined, new Error(data.message)); if (data.requestId === undefined) setError(data.message) }
|
|
1876
1893
|
})
|
|
1877
1894
|
|
package/client.js
CHANGED
|
@@ -316,14 +316,23 @@ window.__ModuleLoader__.load({
|
|
|
316
316
|
}
|
|
317
317
|
if (event.data.type === 'synapse:archive-session') {
|
|
318
318
|
// One archive set only: archive through the Workspace action so DSH's
|
|
319
|
-
// sidebar and this map agree, then
|
|
319
|
+
// sidebar and this map agree, then acknowledge the request so the map
|
|
320
|
+
// can hide the card instead of silently diverging (#21 / #19).
|
|
320
321
|
const sessionId = event.data.sessionId
|
|
322
|
+
const requestId = event.data.requestId
|
|
321
323
|
if (typeof sessionId !== 'string' || sessionId === '') return
|
|
322
|
-
if (typeof ctx.workspaces.archiveSession !== 'function')
|
|
324
|
+
if (typeof ctx.workspaces.archiveSession !== 'function') {
|
|
325
|
+
return send('synapse:bridge-error', { requestId, message: '当前 DSH 版本不支持归档接口' })
|
|
326
|
+
}
|
|
323
327
|
Promise.resolve()
|
|
324
328
|
.then(() => ctx.workspaces.archiveSession(sessionId))
|
|
325
|
-
.then(() =>
|
|
326
|
-
|
|
329
|
+
.then(() => {
|
|
330
|
+
send('synapse:archived-session', { requestId, sessionId })
|
|
331
|
+
send('synapse:workspaces', { workspaces: workspaceSnapshot(ctx), archivedSessionIds: archivedSessionIds(ctx) })
|
|
332
|
+
})
|
|
333
|
+
.catch(error => {
|
|
334
|
+
send('synapse:bridge-error', { requestId, message: `DSH 归档失败:${error instanceof Error ? error.message : String(error)}` })
|
|
335
|
+
})
|
|
327
336
|
return
|
|
328
337
|
}
|
|
329
338
|
if (event.data.type === 'synapse:fork-session') {
|