-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrenderer_session.js
More file actions
48 lines (46 loc) · 1.69 KB
/
Copy pathrenderer_session.js
File metadata and controls
48 lines (46 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function serializeCanvasSessionRecord(canvasRecord, exportedCanvas) {
return {
id: canvasRecord.id,
name: exportedCanvas.name,
viewportOffset: exportedCanvas.viewportOffset,
viewportScale: exportedCanvas.viewportScale,
workspace: canvasRecord.workspace ?? null,
agentProjectTag: canvasRecord.agentProjectTag ?? null,
activeSessionKey: canvasRecord.activeSessionKey ?? null,
notes: Array.isArray(canvasRecord.notes)
? canvasRecord.notes.map((note) => ({
id: note.id,
x: note.x,
y: note.y,
width: note.width,
height: note.height,
text: typeof note.text === "string" ? note.text : ""
}))
: [],
terminalNodes: canvasRecord.nodes.map((nodeRecord, index) => ({
...exportedCanvas.terminalNodes[index],
sessionKey: nodeRecord.sessionKey,
managedAgentName: nodeRecord.managedAgentName ?? null,
managedAgentRole: nodeRecord.managedAgentRole ?? null,
managedProjectTag: nodeRecord.managedProjectTag ?? null,
managedParentAgent: nodeRecord.managedParentAgent ?? null,
managedDepth: Number.isInteger(nodeRecord.managedDepth) ? nodeRecord.managedDepth : null,
tmuxSessionName: nodeRecord.tmuxSessionName ?? null,
isExited: nodeRecord.isExited,
exitCode: nodeRecord.exitCode,
exitSignal: nodeRecord.exitSignal
}))
};
}
function serializeAppSessionSnapshot({ version, ui, canvases, activeCanvasId }) {
return {
version,
ui,
canvases: canvases.map(({ canvasRecord, exportedCanvas }) => serializeCanvasSessionRecord(canvasRecord, exportedCanvas)),
activeCanvasId
};
}
module.exports = {
serializeCanvasSessionRecord,
serializeAppSessionSnapshot
};