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

Custom-formatter #305

Merged
merged 15 commits into from
Jan 9, 2025
Merged

Custom-formatter #305

merged 15 commits into from
Jan 9, 2025

Conversation

skull8888888
Copy link
Collaborator

@skull8888888 skull8888888 commented Jan 5, 2025

Important

Introduces a custom formatter feature, updates database schema with new tables, and enhances UI components and dependencies.

  • Custom Formatter:
    • Added CustomRenderer component in custom-renderer.tsx for rendering custom templates.
    • Updated Formatter component in formatter.tsx to support custom rendering mode.
  • Database Changes:
    • Added render_templates and machines tables in 0012_lying_mandrill.sql.
    • Updated schema and relations in schema.ts and relations.ts to include new tables.
  • UI Components:
    • Added AlertDialog and ConfirmDialog components in alert-dialog.tsx and confirm-dialog.tsx.
    • Modified Sheet component in sheet.tsx to improve styling and functionality.
  • Dependencies:
    • Added @codemirror/lang-html to package.json for HTML support in code editor.
  • Miscellaneous:
    • Updated migration metadata in 0012_snapshot.json and _journal.json.

This description was created by Ellipsis for 65a47ff. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to 2f17a91 in 2 minutes and 20 seconds

More details
  • Looked at 7173 lines of code in 25 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. frontend/lib/flow/utils.ts:347
  • Draft comment:
    Typo in property name 'isCondtional'. It should be 'isConditional'. This typo is present in multiple node types.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. frontend/lib/flow/utils.ts:374
  • Draft comment:
    Typo in property name 'isCondtional'. It should be 'isConditional'. This typo is present in multiple node types.
  • Reason this comment was not posted:
    Marked as duplicate.
3. frontend/lib/flow/utils.ts:408
  • Draft comment:
    Typo in property name 'isCondtional'. It should be 'isConditional'. This typo is present in multiple node types.
  • Reason this comment was not posted:
    Marked as duplicate.
4. frontend/lib/flow/utils.ts:517
  • Draft comment:
    Typo in property name 'isCondtional'. It should be 'isConditional'. This typo is present in multiple node types.
  • Reason this comment was not posted:
    Marked as duplicate.
5. frontend/lib/flow/utils.ts:639
  • Draft comment:
    Typo in property name 'isCondtional'. It should be 'isConditional'. This typo is present in multiple node types.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_Cr2BOFJ2y5xuXTNs


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Member

@dinmukhamedm dinmukhamedm left a comment

Choose a reason for hiding this comment

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

From the quick glance, looks good except a couple debug changes that need to be removed. I will try and play around on the branch as well

Copy link
Member

Choose a reason for hiding this comment

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

shall we remove this file?

Comment on lines 24 to 32
{/* {isChatMessageList(span.input) ? (
<ChatMessageListTab messages={span.input} />
) : (
<Formatter
className="max-h-1/3"
collapsible
value={JSON.stringify(span.input)}
/>
)}
) : ( */}
<Formatter
className="max-h-1/3"
collapsible
value={JSON.stringify(span.input)}
/>
{/* )} */}
Copy link
Member

Choose a reason for hiding this comment

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

this should be restored to before changes. I only did this while testing

Copy link
Member

Choose a reason for hiding this comment

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

this too still holds

@dinmukhamedm
Copy link
Member

Also, where does the default template come from? Can we add some comments on what the user must fill in? We'd need to fix indentation as well. Also, HTML syntax highlighting would be good

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on 9ee640b in 1 minute and 56 seconds

More details
  • Looked at 1876 lines of code in 6 files
  • Skipped 1 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. frontend/components/ui/alert-dialog.tsx:3
  • Draft comment:
    Organize import statements by placing the React import first, followed by third-party libraries, and then local imports for better readability and maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The import statements in the alert-dialog.tsx file are not consistently ordered. The React import should be the first import statement, followed by third-party libraries, and then local imports. This is a common best practice for readability and maintainability.
2. frontend/components/ui/code-editor.tsx:60
  • Draft comment:
    The lineWrapping extension is conditionally added based on the lineWrapping prop, which is a good practice to ensure the editor behaves as expected.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    In the code-editor.tsx file, the lineWrapping prop is set to true by default, which is a good practice. However, the lineWrapping extension is only added if lineWrapping is true. This is correct and ensures that the editor behaves as expected based on the prop value.
3. frontend/lib/db/migrations/relations.ts:3
  • Draft comment:
    Format the import statement for better readability by ensuring consistent spacing between imported items.
  • Reason this comment was not posted:
    Confidence changes required: 30%
    In the relations.ts file, the import statement for the schema is not well-formatted. The items are not consistently spaced, which can affect readability. It's a good practice to format import statements for better readability.
4. frontend/lib/db/migrations/schema.ts:14
  • Draft comment:
    Remove defaultRandom() from the projectId field in the renderTemplates table as it is a foreign key and should not have a default value.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_Ag2UhWmYmtDVTs03


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

<CodeEditor
value={jsonData}
onChange={setJsonData}
language="html"
Copy link
Contributor

Choose a reason for hiding this comment

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

The language prop for the CodeEditor handling jsonData should be set to json instead of html to match the data type.

Copy link
Member

Choose a reason for hiding this comment

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

this file still needs to be removed

Comment on lines 24 to 32
{/* {isChatMessageList(span.input) ? (
<ChatMessageListTab messages={span.input} />
) : (
<Formatter
className="max-h-1/3"
collapsible
value={JSON.stringify(span.input)}
/>
)}
) : ( */}
<Formatter
className="max-h-1/3"
collapsible
value={JSON.stringify(span.input)}
/>
{/* )} */}
Copy link
Member

Choose a reason for hiding this comment

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

this too still holds

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 5d2959c in 1 minute and 31 seconds

More details
  • Looked at 222 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. frontend/components/ui/custom-renderer.tsx:273
  • Draft comment:
    Consider using a more secure and consistent method than localStorage for storing template IDs, especially in a multi-user environment.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The use of localStorage here seems reasonable. The stored data is just an ID that gets validated against server data before use. Even if someone tampered with the localStorage value, it would just result in a failed template lookup. The actual template data and permissions are still controlled server-side. This appears to be a reasonable use of client-side storage for UI state persistence.
    I could be underestimating security risks. Perhaps there are edge cases where template IDs could be sensitive information that shouldn't be stored client-side.
    The template IDs appear to be used purely for UI state persistence, with all actual template data and access controls handled server-side. The security risk seems minimal given the architecture.
    The comment should be deleted as it raises a speculative security concern without strong evidence of an actual issue. The current implementation appears to be a reasonable and safe use of localStorage.
2. frontend/components/ui/formatter.tsx:43
  • Draft comment:
    Consider using a more secure and consistent method than localStorage for storing formatter modes, especially in a multi-user environment.
  • Reason this comment was not posted:
    Marked as duplicate.
3. frontend/components/ui/custom-renderer.tsx:279
  • Draft comment:
    Ensure to handle non-200 HTTP responses in fetch requests to improve error handling and user experience.
  • Reason this comment was not posted:
    Comment did not seem useful.
4. frontend/components/ui/custom-renderer.tsx:319
  • Draft comment:
    Ensure to handle non-200 HTTP responses in fetch requests to improve error handling and user experience.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_vqvecWEvgiokXJZs


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 3024085 in 1 minute and 41 seconds

More details
  • Looked at 192 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. frontend/components/queue/queue.tsx:163
  • Draft comment:
    Ensure that data is not empty before accessing data[0] to avoid potential runtime errors.
                {data && data.length > 0 && <span>Item {data[0]?.position} of {data[0]?.count}</span>}
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The code already handles empty data cases gracefully. The UI buttons that would trigger actions are disabled when data is empty. The suggested change would add redundant checks that make the code more verbose without adding real safety. The current optional chaining with ?. already provides null/undefined safety.
    I could be underestimating the importance of defensive programming. There could be edge cases where data is an empty array that I'm not considering.
    The component has comprehensive handling of all data states - null, empty array, and populated array. The existing optional chaining provides sufficient safety.
    This comment should be deleted as it suggests adding redundant checks when the code already handles empty data cases appropriately through other means.
2. frontend/components/queue/queue.tsx:168
  • Draft comment:
    Ensure that data is not empty before accessing data[0] to avoid potential runtime errors.
                    onClick={() => data && data.length > 0 && data[0]?.queueData && next(data[0].queueData.createdAt, 'prev')}
  • Reason this comment was not posted:
    Marked as duplicate.
3. frontend/components/queue/queue.tsx:176
  • Draft comment:
    Ensure that data is not empty before accessing data[0] to avoid potential runtime errors.
                    onClick={() => data && data.length > 0 && data[0]?.queueData && next(data[0].queueData.createdAt, 'next')}
  • Reason this comment was not posted:
    Marked as duplicate.
4. frontend/app/api/projects/[projectId]/queues/[queueId]/move/route.ts:66
  • Draft comment:
    Ensure that nextItem and stats are not empty before accessing their first elements to avoid potential runtime errors.
if (nextItem.length > 0 && stats.length > 0) {
  return Response.json([{
    ...nextItem[0],
    count: stats[0].count,
    position: stats[0].position
  }]);
}
  • Reason this comment was not posted:
    Comment did not seem useful.
5. frontend/app/api/projects/[projectId]/queues/[queueId]/move/route.ts:112
  • Draft comment:
    Ensure that prevItem and stats are not empty before accessing their first elements to avoid potential runtime errors.
if (prevItem.length > 0 && stats.length > 0) {
  return Response.json([{
    ...prevItem[0],
    count: stats[0].count,
    position: stats[0].position
  }]);
}
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_mRBvFazB1sJtwcDh


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Skipped PR review on 91882b5 because no changed files had a supported extension. If you think this was in error, please contact us and we'll fix it right away.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 634b0f0 in 48 seconds

More details
  • Looked at 101 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. frontend/components/traces/chat-message-list-tab.tsx:98
  • Draft comment:
    Ensure presetKey is passed to ContentPartText within ContentParts for consistency.
              <ContentPartText text={contentPart.text} presetKey={presetKey} />
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.

Workflow ID: wflow_FyuNmDM67ikofJVc


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on af1e1ec in 2 minutes and 15 seconds

More details
  • Looked at 588 lines of code in 7 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. frontend/components/traces/span-view.tsx:121
  • Draft comment:
    Ensure span.events is not null or undefined before passing to JSON.stringify to avoid runtime errors.
  • Reason this comment was not posted:
    Comment did not seem useful.
2. frontend/components/traces/span-view.tsx:111
  • Draft comment:
    Ensure span.attributes is not null or undefined before passing to JSON.stringify to avoid runtime errors.
  • Reason this comment was not posted:
    Comment did not seem useful.
3. frontend/components/traces/span-view.tsx:110
  • Draft comment:
    Ensure span.attributes is not null or undefined before passing to JSON.stringify to avoid runtime errors.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_XFklugzmBxNyTpvn


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

collapsible
value={JSON.stringify(span.input) + "a".repeat(100) + "\n".repeat(100)}
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of "a".repeat(100) + "\n".repeat(100) in the Formatter component's value prop seems unintended. Consider removing these repeated characters and newlines.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Skipped PR review on a1b5071 because no changed files had a supported extension. If you think this was in error, please contact us and we'll fix it right away.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 136a902 in 27 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. frontend/components/traces/span-view-span.tsx:1
  • Draft comment:
    It's a best practice to keep the import statement for React hooks at the top of the file. Consider moving import { useEffect, useRef, useState } from 'react'; to the top.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The import statement for React hooks should be at the top of the file for better readability and organization.

Workflow ID: wflow_veRFIf3Z6eCxOhpN


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on dfded09 in 1 minute and 17 seconds

More details
  • Looked at 53 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. frontend/components/traces/span-view-span.tsx:39
  • Draft comment:
    The style prop for width should be a string with units, not a number. Consider using style={{ width: ${contentWidth}px }}.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    In React, style properties that expect a length can accept either a number (which is interpreted as pixels) or a string with units. When a number is provided, React automatically adds 'px'. So while using ${contentWidth}px would work, using just contentWidth is equally valid and will have the exact same result. The comment is technically incorrect in saying it "should" be a string with units.
    Maybe there's a specific reason they were using string units before, like supporting different units than pixels? Maybe there's a browser compatibility issue I'm not aware of?
    React's automatic handling of pixel units is well-documented and widely supported. The previous code was using pixels explicitly anyway, so there's no evidence of needing different units.
    The comment should be deleted because it suggests a change that isn't necessary - React handles number values for the width style property correctly by automatically adding 'px' units.

Workflow ID: wflow_ZzMxJnKloFq9ToEf


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.


resizeObserver.observe(scrollAreaRef.current);
return () => resizeObserver.disconnect();
}, [scrollAreaRef.current]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Using scrollAreaRef.current in the dependency array is incorrect because it is mutable and does not trigger re-renders. Use scrollAreaRef instead.

collapsible
value={JSON.stringify(span.input) + "a".repeat(100) + "\n".repeat(100)}
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition of repeated characters and newlines in the JSON string seems like a debugging artifact. Consider removing + "a".repeat(100) + "\n".repeat(100) before merging.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 65a47ff in 25 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_WhNWQ1aEYXk9HWmI


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@skull8888888 skull8888888 merged commit 8717078 into dev Jan 9, 2025
2 checks passed
@skull8888888 skull8888888 deleted the custom-formatter branch January 9, 2025 22:13
dinmukhamedm added a commit that referenced this pull request Jan 10, 2025
* Merge pull request #311 from lmnr-ai/fix/dashboard-tooltip

fix double conversion date in chart tooltip too

* Collapsable trace tree (#312)

* Add ability to rename projects (#306)

* Add ability to rename projects

* Added user feedback notifiaction and convert PUT to POST

* change to router.refresh

* add close dialog after rename

* Custom-formatter (#305)

---------

Co-authored-by: skull8888888 <skull8888888@gmail.com>
Co-authored-by: Nidhi Singh <120259299+nidhi-wa@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants