-
Notifications
You must be signed in to change notification settings - Fork 746
Fix Json Editor freezing on big input #6142
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
Conversation
Deploying windmill with
|
Latest commit: |
d4eaa1c
|
Status: | ✅ Deploy successful! |
Preview URL: | https://c862ed9e.windmill.pages.dev |
Branch Preview URL: | https://di-fix-json-editor-big-input.windmill.pages.dev |
Claude finished @diegoimbert's task —— View job PR Code Review - JsonEditor Performance FixReview Tasks:
Changes OverviewThe PR addresses JsonEditor freezing issues with large JSON inputs by:
Code Review Feedback✅ Strengths
|
on:change | ||
autoHeight | ||
lang="json" | ||
bind:code={() => (tooBig ? '// JSON is too big to edit' : code), (c) => (code = c)} |
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 bind:code
syntax here is incorrect - Svelte's binding directives don't accept functions as arguments. This will cause runtime errors or unexpected behavior.
For handling large JSON, consider one of these approaches:
- Keep the standard binding and handle the size check in a reactive statement:
bind:code={code}
$: if (tooBig && code && !code.startsWith('// JSON is too big')) {
code = '// JSON is too big to edit';
}
- Or restore the conditional rendering approach that was removed:
{#if tooBig}
<SimpleEditor code="// JSON is too big to edit" readonly />
{:else}
<SimpleEditor bind:code={code} />
{/if}
Either approach would maintain the intended functionality while using valid Svelte syntax.
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
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.
Caution
Changes requested ❌
Reviewed everything up to 132b9cc in 1 minute and 33 seconds. Click for details.
- Reviewed
64
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/src/lib/components/JsonEditor.svelte:15
- Draft comment:
Threshold lowered to 100K (from 1M). Confirm this change doesn’t inadvertently block valid JSON inputs. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
Workflow ID: wflow_LxalGWOLb0C35KIB
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
on:change | ||
autoHeight | ||
lang="json" | ||
bind:code={() => (tooBig ? '// JSON is too big to edit' : code), (c) => (code = c)} |
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.
Using a comma operator in bind:code causes only the setter to be passed, discarding the custom getter. This likely doesn’t provide the intended '// JSON is too big to edit' display.
bind:code={() => (tooBig ? '// JSON is too big to edit' : code), (c) => (code = c)} | |
bind:code={{ get: () => (tooBig ? '// JSON is too big to edit' : code), set: (c) => (code = c) }} |
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.
Important
Looks good to me! 👍
Reviewed 1764041 in 43 seconds. Click for details.
- Reviewed
31
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
2
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/src/lib/components/FakeMonacoPlaceHolder.svelte:39
- Draft comment:
Limiting the preview to the first 5000 characters improves performance on large inputs. Consider documenting the reason for this magic number or making it configurable for clarity. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
2. frontend/src/lib/components/JsonEditor.svelte:15
- Draft comment:
The tooBig threshold is increased to 1,000,000 characters, which allows larger JSON inputs to be parsed. Confirm that this change doesn't reintroduce performance issues and consider adding a comment on the rationale behind this threshold increase. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
Workflow ID: wflow_4y6WACn74sLif75Y
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
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.
Important
Looks good to me! 👍
Reviewed d4eaa1c in 1 minute and 22 seconds. Click for details.
- Reviewed
76
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
4
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/src/lib/components/JsonEditor.svelte:22
- Draft comment:
Removal of the guard (if (tooBig) return) in parseJson may lead to expensive JSON.parse calls on huge inputs. Consider conditionally skipping parsing unless the user has clicked 'Load anyway'. - Reason this comment was not posted:
Comment looked like it was already resolved.
2. frontend/src/lib/components/JsonEditor.svelte:36
- Draft comment:
The reactive statement ($: code != undefined && parseJson()) always triggers JSON.parse even for huge inputs. Consider adding a condition (e.g., !tooBig || loadTooBigAnyway) to avoid unnecessary parsing before the user opts to load. - Reason this comment was not posted:
Comment was on unchanged code.
3. frontend/src/lib/components/JsonEditor.svelte:16
- Draft comment:
The magic number 1000000 used to define 'tooBig' could be extracted into a named constant to improve maintainability and readability. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
4. frontend/src/lib/components/JsonEditor.svelte:36
- Draft comment:
If the code input is updated rapidly, repeatedly calling parseJson() might hurt performance. Consider debouncing the parseJson call. - Reason this comment was not posted:
Comment was on unchanged code.
Workflow ID: wflow_C45IeayJIC7EsDCV
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Important
Fix JSON editor freezing by limiting input size and adding a user option to load large inputs.
FakeMonacoPlaceHolder.svelte
to prevent freezing.JsonEditor.svelte
to allow users to load large JSON inputs if they exceed 1,000,000 characters.Button
component inJsonEditor.svelte
for user interaction.CHAR_LIMIT
inFakeMonacoPlaceHolder.svelte
to cap input size.loadTooBigAnyway
flag inJsonEditor.svelte
to manage large input loading.This description was created by
for d4eaa1c. You can customize this summary. It will automatically update as commits are pushed.