Repository navigation
fix(cli): prevent CLI memory leaks from oversized diffs and session accumulation #7617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
5410533
7f57983
59d1bbb
2451764
d7f73a1
1a07ad1
a3c8340
6878ddb
1c4918c
6819ee7
10e3b12
1a0536d
a7d3731
5e38d95
1596cae
5d611d6
8b676f8
3ed648d
bfbfbb9
721b3d0
664ceec
1cb4b5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,15 +121,19 @@ export namespace SessionSummary { | |
| }), | ||
| async (input) => { | ||
| const diffs = await Storage.read<Snapshot.FileDiff[]>(["session_diff", input.sessionID]).catch(() => []) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Existing oversized
|
||
| const limit = 256 * 1024 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you not use the constant here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 664ceec. Exported the constant from Snapshot and reused it here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| const next = diffs.map((item) => { | ||
| const file = unquoteGitPath(item.file) | ||
| if (file === item.file) return item | ||
| const oversized = Buffer.byteLength(item.before) > limit || Buffer.byteLength(item.after) > limit | ||
| if (file === item.file && !oversized) return item | ||
| return { | ||
| ...item, | ||
| file, | ||
| before: oversized ? "" : item.before, | ||
| after: oversized ? "" : item.after, | ||
| } | ||
| }) | ||
| const changed = next.some((item, i) => item.file !== diffs[i]?.file) | ||
| const changed = next.some((item, i) => item !== diffs[i]) | ||
| if (changed) Storage.write(["session_diff", input.sessionID], next).catch(() => {}) | ||
| return next | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR added createEffect in app.tsx that calls evict(prev) when navigating away from a session, intended to clean up memory. But it evicts ALL child sessions' data including pending permissions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a3c8340 doesn't solve the problem when navigating to or from subagent views while there is a pending permission request or question.