Skip to content

Commit 3b25821

Browse files
committed
fix: ui should compress traces into local storage
Signed-off-by: Nick Mitchell <[email protected]>
1 parent 0eb3974 commit 3b25821

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

pdl-live-react/package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pdl-live-react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@xterm/addon-clipboard": "^0.1.0",
3333
"@xterm/addon-fit": "^0.10.0",
3434
"@xterm/xterm": "^5.3.0",
35+
"lz-string": "^1.5.0",
3536
"pretty-bytes": "^6.1.1",
3637
"pretty-ms": "^9.2.0",
3738
"react": "^18.3.1",

pdl-live-react/src/page/MyTraces.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
import { compressToUTF16, decompressFromUTF16 } from "lz-string"
2+
13
const mytracesLocalStorageKey = "pdl.sidebar-nav-mytraces.list"
24

35
type MyTrace = {
46
title: string
57
timestamp: number
68
filename: string
79
value: string
10+
isCompressed?: boolean
811
}
12+
913
export function getMyTraces(): MyTrace[] {
1014
return (
1115
JSON.parse(
@@ -14,6 +18,9 @@ export function getMyTraces(): MyTrace[] {
1418
).map((trace) =>
1519
Object.assign(trace, {
1620
title: trace.title.replace(/(\.trace)?.json$/, ""),
21+
value: trace.isCompressed
22+
? decompressFromUTF16(trace.value)
23+
: trace.value,
1724
}),
1825
)
1926
}
@@ -24,7 +31,8 @@ export function addMyTrace(filename: string, value: string): MyTrace {
2431
title: filename.replace(/(\.trace)?.json$/, ""),
2532
timestamp: Date.now(),
2633
filename,
27-
value,
34+
isCompressed: true,
35+
value: compressToUTF16(value),
2836
}
2937

3038
const alreadyIdx = traces.findIndex((_) => _.filename === filename)

0 commit comments

Comments
 (0)