-
Notifications
You must be signed in to change notification settings - Fork 9
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
Chat with your pipelines functionality #56
base: develop
Are you sure you want to change the base?
Conversation
…I keys with the VSCode SecretsStorage API
Co-authored-by: Nathaniel Xu <[email protected]> Co-authored-by: Alan Cho <[email protected]>
Added functionality to the chat window in the sidebar (activity bar). User input is now sent to the Gemini API using TokenJS, and the response from the API is displayed in the chat window. Co-authored-by: Nathaniel Xu <[email protected]> Co-authored-by: Alan Cho <[email protected]>
Co-authored-by: Nathaniel-Xu <[email protected]> Co-authored-by: William Yennie <[email protected]>
Co-authored-by: Will Yennie <[email protected]> Co-authored-by: Alan Cho <[email protected]>
Co-authored-by: William Yennie <[email protected]> Co-authored-by: Nathaniel Xu <[email protected]>
Co-authored-by: William Yennie <[email protected]> Co-authored-by: Nathaniel Xu <[email protected]>
Integrated `marked` library to convert Markdown text to HTML. Updated `ChatViewProvider` to process and render Markdown in chat message. Modified `renderChatLog` to parse Markdown before displaying message.
…re files Renamed ChatViewProvider to ChatDataProvider for consistency with other files Moved ChatDataProvider class from extension.ts to src/activityBar/chatView Moved chat.js, chat.html, and chat.css to resources/chat-view
removed typescript error Co-authored-by: William Yennie <[email protected]>
Added missing semicolons and formatted code Fixed TypeScript linting issues with type checks and type guards Improved error handling and logging
…e/chatbot merge: feature/secrets into feature/chatbot Integrates updates from the `feature/secrets` branch in sklar-fork into `feature/chatbot`. Includes changes related to chatbot functionality improvements.
…showInfo message to extension host
ff7852b
to
39bcbab
Compare
- Changed `pipelineRuns` property from public to private to better encapsulate internal state. - Added `getPipelineRuns` method to provide controlled access to the `pipelineRuns` data. - Included documentation for the `pipelineRuns` property and `getPipelineRuns` method.
…ogic - Wrapped fs.readFileSync in a try-catch block to handle potential errors and prevent uncaught exceptions. - Added type guard to ensure proper error message display. - Updated pagination button logic to ensure correct assignment of next and previous buttons.
…n reference - Store the bound function reference for `refreshWebview` in a variable `refreshWebviewBound`. - Update event listener addition and removal to use `refreshWebviewBound`.
…rovider - Ensure currentModel is initialized using the first model from getAvailableModels() for the 'Gemini' provider. - This prevents potential issues where currentModel does not match an available model.
…lay in response streaming - Updated error message in `addMessage` to dynamically include the current provider name instead of hardcoding 'Gemini'. - Removed the unnecessary 1ms delay in the response streaming loop to improve performance.
- Added a check to ensure `pipelineRunSteps[0]` exists before mapping in `getLogData` to prevent potential undefined access. - Refactored null checks using optional chaining in `getLogData` for cleaner and more concise code. - Added error handling for axios GET request in `getPipelineRunLogs` to handle potential request failures and log errors appropriately.
- Added a try-catch block around JSON.parse in the default case of addContext to handle potential parsing errors. - Logged errors to the console and added a fallback message to systemMessage to inform the user when pipeline run data cannot be parsed.
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.
Actionable comments posted: 8
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
📒 Files selected for processing (2)
- resources/chat-view/chat.js (1 hunks)
- src/views/chatView/utils/ContextUtils.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- resources/chat-view/chat.js
🧰 Additional context used
📓 Path-based instructions (1)
src/views/chatView/utils/ContextUtils.ts (1)
Pattern
**/*.ts
: Review the Typescript code for conformity with industry standards and best practices, highlighting any deviations.
🪛 Biome
src/views/chatView/utils/ContextUtils.ts
[error] 124-124: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
resources/chat-view/chat.js (1)
151-158
: Ensure strict sanitization when rendering markdown contentWhile you're sanitizing the HTML output of
marked.parse
usingDOMPurify
, it's important to verify that the configuration prevents potential XSS attacks, especially ifcurrentAssistantMessage
contains user-generated content.Consider setting up
DOMPurify
with strict policies and configuringmarked
to disallow embedded HTML:marked.setOptions({ gfm: true, breaks: true, headerIds: false, mangle: false, }); const html = marked.parse(currentAssistantMessage); const sanitizeHtml = DOMPurify.sanitize(html, { ALLOWED_TAGS: [], ALLOWED_ATTR: [] });This configuration ensures that only basic text formatting is allowed, mitigating XSS risks.
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (3)
- package.json (7 hunks)
- resources/chat-view/chat.html (1 hunks)
- resources/chat-view/chat.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- package.json
- resources/chat-view/chat.html
🧰 Additional context used
📓 Path-based instructions (1)
resources/chat-view/chat.js (1)
Pattern
**/*.js
: Review the JavaScript code for conformity with the Google JavaScript style guide, highlighting any deviations.
🪛 Biome
resources/chat-view/chat.js
[error] 193-193: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
🔇 Additional comments (2)
resources/chat-view/chat.js (2)
110-112
: Potential XSS vulnerability: settinginnerHTML
without sanitizationAt line 111,
document.getElementById('chatMessages').innerHTML = message.chatLogHtml;
is settinginnerHTML
without sanitization. This could expose the application to Cross-Site Scripting (XSS) attacks ifmessage.chatLogHtml
contains malicious content.
209-214
: Cannot usevscode.window.showInformationMessage
in the webviewThe method
vscode.window.showInformationMessage
is not available in the webview context. Attempting to call it from the webview will result in an error.
Replaced CDN styles with Tailwind CSS. Configured build process and updated paths to ensure proper loading in the VSCode extension.
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.
Actionable comments posted: 7
🧹 Outside diff range and nitpick comments (2)
tailwind.config.js (2)
4-6
: Consider custom theme extensions for chat view.The theme configuration is correctly structured with an empty
extend
object. This is valid and allows for future extensions. However, consider if any custom theme extensions (e.g., colors, fonts, or spacing) might be beneficial for the chat view's specific design requirements.If custom theme extensions are needed, you can add them like this:
theme: { extend: { colors: { 'chat-primary': '#your-color-here', 'chat-secondary': '#your-color-here', }, fontFamily: { 'chat': ['Your-Font-Here', 'sans-serif'], }, // Add other extensions as needed }, },
7-7
: Consider useful Tailwind plugins for chat functionality.The empty plugins array is valid. However, consider if any Tailwind plugins could enhance the chat view's functionality or styling. For example, the
@tailwindcss/typography
plugin could be useful for styling markdown content in chat messages.If you decide to use plugins, you can add them like this:
module.exports = { // ...other config plugins: [ require('@tailwindcss/typography'), // Add other plugins as needed ], }Don't forget to install any plugins you add:
npm install -D @tailwindcss/typography
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (7)
- noxfile.py (1 hunks)
- package.json (8 hunks)
- postcss.config.js (1 hunks)
- resources/chat-view/chat.html (1 hunks)
- resources/chat-view/styles.css (1 hunks)
- src/views/chatView/chatRenderer.ts (1 hunks)
- tailwind.config.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- package.json
- resources/chat-view/chat.html
- src/views/chatView/chatRenderer.ts
🧰 Additional context used
📓 Path-based instructions (3)
noxfile.py (1)
Pattern
**/*.py
: "Review the Python code for conformity with Python best practices and industry standards, highlighting any deviations."postcss.config.js (1)
Pattern
**/*.js
: Review the JavaScript code for conformity with the Google JavaScript style guide, highlighting any deviations.tailwind.config.js (1)
Pattern
**/*.js
: Review the JavaScript code for conformity with the Google JavaScript style guide, highlighting any deviations.
🔇 Additional comments (2)
tailwind.config.js (2)
1-1
: LGTM: Proper type annotation for Tailwind config.The JSDoc type annotation is correctly used to provide TypeScript support for the Tailwind configuration object.
2-2
: LGTM: Correct module export syntax.The configuration object is properly exported using CommonJS syntax, which is appropriate for Node.js environments and consistent with Tailwind's documentation.
- Added a check to handle context strings starting with 'Pipeline Run:'. - Expanded ContextType union to include string for dynamic context handling. - Retained switch case for other context types and added a default case to log unknown context types. This ensures that pipeline run contexts are correctly parsed and processed, preventing unknown context type warnings in the console.
- Updated addContext function to handle dynamic pipeline run contexts and log unknown context types. - Added error handling to getServerData function to ensure it always returns a string, even on failure. - Enhanced getStackComponentData function with error handling and improved type safety using type guards. - Added error handling to getEnvironmentData function to handle potential promise rejections. - Improved getStackData function with error handling and safer property access using type guards. These changes improve the robustness and maintainability of the utility functions by ensuring they handle errors gracefully and enforce type safety.
- Refactored getLogData: - Extracted fetchLogs function. - Improved error handling and logging. - Refactored getPipelineRunLogs: - Extracted common logic into fetchLogs. - Enhanced type annotations and error handling. - Refactored getPipelineRunNodes: - Added NodeType type. - Improved error handling and variable naming. - Extracted node filtering logic. These changes improve robustness, maintainability, and readability.
- Replaced Event constructor with CustomEvent for better compatibility in VSCode webview environment. - Wrapped case body in braces to prevent variable hoisting issues in switch-case statements.
- Added error handling, logging, and optional watch flag to build_css. - Removed the redundant dev function.
- Replaced `display: contents;` with `display: flex;` for the `<form>` element to maintain accessibility. - Changed hardcoded `color: black !important;` to `color: var(--vscode-editor-foreground);` for `ul` elements to ensure theme consistency. - Removed redundant color properties from `#chatMessages` child elements to allow inheritance and simplify the CSS.
Summary
This pull request introduces a comprehensive set of features and improvements to the chatbot functionality within the VSCode ZenML extension. The updates enhance user interaction, context management, and overall user experience.
Chat Interface Enhancements:
Context Management:
Pipeline Integration:
UI and UX Improvements:
Contributors
@wyennie
@Nathaniel-Xu
@alan-cho
Summary by CodeRabbit
New Features
Bug Fixes
Style
Documentation
Tests