-
Notifications
You must be signed in to change notification settings - Fork 495
Allowing users to add tags to strings #1165
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
base: quantumstrand
Are you sure you want to change the base?
Conversation
…sponsiveness for laptops (when scaled on 150% the strings were not visible)
… strings, allowing a tag to be added to multiple strings
Accidentally reset when creating a venv
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.
Summary of Changes
Hello @FredCoast, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the string analysis tool by introducing robust tagging functionalities to the web application and integrating these capabilities with the Python backend. The changes empower users to customize and manage their string data more effectively, improving both the interactive experience and the utility of the generated analysis results.
Highlights
- Enhanced Web Application Tagging: Users can now add custom tags to individual strings directly within the web interface and apply tags to multiple selected strings via a new mass-tagging feature.
- JSON Export Capability: A new button allows users to export the current string data, including any newly added tags, as a JSON file.
- Improved Web App Responsiveness: Significant CSS updates have been implemented to address scaling issues and improve the user interface's responsiveness across different screen sizes and DPI settings.
- Python Backend Integration for User Tags: A new command-line argument (--expand) has been added to the Python tool, enabling users to import their custom-tagged string data from the web application into a personal expert database.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request introduces significant new functionality, allowing users to add custom tags to strings both in the web UI and via the command line, and then persist them to a user-specific database. The changes are extensive, touching both the Python backend and the React frontend.
In the Python code, the new --expand
argument and related functions for updating the user database are well-implemented, but there are some areas for improvement regarding code duplication, function naming, and argument parsing complexity. I've left specific comments on these points.
The web app updates are great, adding individual and mass tagging, JSON export, and improved responsive layout. The implementation is solid, though I've noted a few areas where performance could be improved and some leftover debugging code that should be removed.
Overall, this is a valuable addition to the tool. Addressing the feedback will improve the code's maintainability, robustness, and performance.
const handleAddTag = (offset: number, tag: string) => { | ||
if (!data) return; | ||
|
||
// Create a deep copy of the data to modify | ||
const updatedData = JSON.parse(JSON.stringify(data)); | ||
|
||
// Find and update the string with the specified offset | ||
const updateLayout = (layout: ResultLayout): boolean => { | ||
for (let i = 0; i < layout.strings.length; i++) { | ||
if (layout.strings[i].offset === offset) { | ||
if (!layout.strings[i].tags.includes(tag)) { | ||
layout.strings[i].tags.push(tag); | ||
} | ||
return true; | ||
} | ||
} | ||
for (const child of layout.children) { | ||
if (updateLayout(child)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
updateLayout(updatedData.layout); | ||
setData(updatedData); | ||
|
||
// Add the new tag to selectedTags if it's not already there | ||
setSelectedTags(prev => { | ||
if (!prev.includes(tag)) { | ||
return [...prev, tag]; | ||
} | ||
return prev; | ||
}); | ||
}; |
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 JSON.parse(JSON.stringify(data))
for deep cloning the state object is inefficient, especially for large datasets, and not idiomatic in React. Each time a tag is added, the entire data structure is serialized and deserialized. This can lead to performance issues. Consider using an immutability helper or manual recursive cloning to update the state more efficiently by only creating new objects for the parts of the state tree that have changed. This same issue exists in handleMassTagSubmit
.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Web App updates
Python Updates