-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Reverted to vs-code-dev and added export button #629
Conversation
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.
Consider implementing the following changes to improve the code.
extensions/src/SidebarProvider.ts
Outdated
const [updatedEndpoint] = this.apiHistory.splice(existingIndex, 1); | ||
this.apiHistory.unshift(updatedEndpoint); | ||
} else { | ||
this.apiHistory.unshift(endpoint); |
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.
Comment: Potential exposure of sensitive data in API history.
Solution: Implement data sanitization or encryption for sensitive fields before storing or displaying them.
!! Make sure the following suggestion is correct before committing it !!
this.apiHistory.unshift(endpoint); | |
this.apiHistory.unshift(sanitizeEndpoint(endpoint)); |
extensions/src/SidebarProvider.ts
Outdated
|
||
// Write API history to MessagePack file | ||
const packedData = msgpack.encode(this.apiHistory); // Encode data using MessagePack | ||
fs.writeFileSync(filePath, packedData); // Write packed data to file |
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.
Comment: Synchronous file system operations may block the event loop.
Solution: Use asynchronous file operations instead to improve performance.
!! Make sure the following suggestion is correct before committing it !!
fs.writeFileSync(filePath, packedData); // Write packed data to file | |
await fs.promises.writeFile(filePath, packedData); |
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.
Consider implementing the following changes to improve the code.
const history = this.context.globalState.get<ApiEndpoint[]>('apiHistory', []); | ||
this.apiHistory = history; | ||
} catch (error) { | ||
console.error('Error loading API history:', error); |
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.
Comment: Potential exposure of sensitive data in console logs.
Solution: Avoid logging sensitive data or implement a logging framework with configurable log levels.
!! Make sure the following suggestion is correct before committing it !!
console.error('Error loading API history:', error); | |
console.error('Error loading API history'); |
|
||
const filePath = path.join(downloadsFolder, 'history.msgpack'); | ||
const packedData = msgpack.encode(this.apiHistory); | ||
fs.writeFileSync(filePath, packedData); |
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.
Comment: Synchronous file write operation in exportHistory method.
Solution: Use asynchronous file writing methods to improve performance.
!! Make sure the following suggestion is correct before committing it !!
fs.writeFileSync(filePath, packedData); | |
await fs.promises.writeFile(filePath, packedData); |
} | ||
private async exportHistory() { | ||
try { | ||
console.log("Exporting API history..."); |
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.
Comment: Potential exposure of sensitive data in console logs.
Solution: Avoid logging sensitive information such as API endpoints or user data.
!! Make sure the following suggestion is correct before committing it !!
console.log("Exporting API history..."); | |
// console.log('Exporting API history...'); |
|
||
const filePath = path.join(downloadsFolder, 'history.msgpack'); | ||
const packedData = msgpack.encode(this.apiHistory); | ||
fs.writeFileSync(filePath, packedData); |
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.
Comment: Synchronous file writing in exportHistory method.
Solution: Use asynchronous file writing to prevent blocking the event loop.
!! Make sure the following suggestion is correct before committing it !!
fs.writeFileSync(filePath, packedData); | |
await fs.promises.writeFile(filePath, packedData); |
🔍 Code Review Summary❗ Attention Required: This push has potential issues. 🚨 Overview
🚨 Critical Issuessecurity (2 issues)1. Potential exposure of sensitive data in console logs.📁 File: extensions/src/SidebarProvider.ts 💡 Solution: Current Code: console.error('Error saving API history:', error); Suggested Code: console.error('Error saving API history.'); // Avoid logging the error object directly. 2. Synchronous file write operation may block the event loop.📁 File: extensions/src/SidebarProvider.ts 💡 Solution: Current Code: fs.writeFileSync(filePath, packedData); Suggested Code: fs.promises.writeFile(filePath, packedData).then(() =>{
vscode.window.showInformationMessage(`API History Exported to: ${filePath}`);
}).catch(error =>{
vscode.window.showErrorMessage(`Failed to save API history: ${error.message}`);
}); Test Cases20 file need updates to their tests. Run
Useful Commands
|
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.
Consider implementing the following changes to improve the code.
console.error('Error saving API history:', error); | ||
vscode.window.showErrorMessage('Failed to save API history. Please try again.'); |
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.
Comment: Potential exposure of sensitive data in console logs.
Solution: Avoid logging sensitive information or ensure it is sanitized before logging.
!! Make sure the following suggestion is correct before committing it !!
console.error('Error saving API history:', error); | |
vscode.window.showErrorMessage('Failed to save API history. Please try again.'); | |
console.error('Error saving API history.'); // Avoid logging the error object directly. |
|
||
const filePath = path.join(downloadsFolder, 'history.msgpack'); | ||
const packedData = msgpack.encode(this.apiHistory); | ||
fs.writeFileSync(filePath, packedData); |
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.
Comment: Synchronous file write operation may block the event loop.
Solution: Use asynchronous file writing methods to prevent blocking the event loop.
!! Make sure the following suggestion is correct before committing it !!
fs.writeFileSync(filePath, packedData); | |
fs.promises.writeFile(filePath, packedData).then(() =>{ | |
vscode.window.showInformationMessage(`API History Exported to: ${filePath}`); | |
}).catch(error =>{ | |
vscode.window.showErrorMessage(`Failed to save API history: ${error.message}`); | |
}); |
Comprehensive API and Sidebar Management Enhancements
Integrate API history management and enhance sidebar functionality for improved user experience and performance.
SidebarProvider
,ChatRepoProvider
, andDocManagementProvider
for better sidebar management.ApiRequestView
class for API request handling and response display.These changes significantly improve the developer experience by providing robust API management features and a more responsive, maintainable sidebar interface.
Original Description
# Unified API and Sidebar Enhancements**
Introduce a comprehensive sidebar for managing API requests, history, chat, and document management with improved UI and functionality.
SidebarProvider
class for managing the sidebar view and integrating new functionalities.ChatRepoProvider
andDocManagementProvider
to handle chat and document management capabilities.ApiRequestProvider
to handle API requests and save history.package.json
.**
These changes streamline the sidebar's functionality, making it easier to manage APIs, chat interactions, and documentation within the extension, while providing a more organized and user-friendly experience.
Original Description
# Unified API History and Sidebar Enhancements**
**
Adds the ability to export the API history to a MessagePack file and extends the functionality of the sidebar provider to include new features like Chat Repo and Documentation Management.
exportApiHistory
function to save the API history to a MessagePack file in theapi_history
folder.**
**
Users can now easily export their API history for backup or analysis purposes, and access the Chat Repo and Documentation Management features directly from the sidebar, improving the overall usability and functionality of the extension.
Original Description
This code is able to do all that vs-code-dev code did namely : - created a new window when clicking on new request - open a history on click (Api method and URL) - maintaining the same UINew changes :
Known issues: