Skip to content
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

Fixes input dict display in UI #1254

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ui/frontend/src/components/dashboard/Runs/Run/Run.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ const VariableTable = (props: {
<code>{variableKey}</code>
</td>
{values.map((value, i) => {
let json_string = "";
if (value) {
json_string = JSON.stringify(value, null, 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider checking if the value is already a string before using JSON.stringify to avoid unnecessary quotes around string values.

Suggested change
json_string = JSON.stringify(value, null, 2);
json_string = typeof value === 'string' ? value : JSON.stringify(value, null, 2);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to do this unless you want strings to show up as not quoted (which is odd, the type is a string so a quote makes sense).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I'm not going to do the typeof value thing -- since quotes seem fine above (see screenshot).

if (json_string.length > 10000) {
json_string = json_string.substring(0, 10000) + " (truncated)";
}
}
return (
<td
onMouseEnter={() => {
Expand Down Expand Up @@ -175,7 +182,7 @@ const VariableTable = (props: {
>
<div className="max-w-64 max-h-48 overflow-scroll scrollbar-hide">
<code className="whitespace-pre-wrap truncate">
{value?.toString()}
{json_string}
</code>
</div>
</td>
Expand Down
Loading