JACoB PR for Issue Send Filename to Chat via button on Codebase Details #130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Description
Enhance collaboration within the Codebase Details page by implementing a new "Send Filename to Chat" button. This feature allows users to quickly share specific code files within project conversations, streamlining discussions by enabling the direct transfer of filenames to the chat interface. By reducing the need to manually type out filenames, teams can reference and discuss code more efficiently, improving overall productivity.
User Story
As a user, I want to send the filename of a selected code file directly to the chat page, so that I can easily reference and discuss specific files with my team without manually typing out filenames.
Features
Button Placement
Functionality
file_pathand append it as a query parameter to the/chatURL (e.g.,/chat?file_path=(url-encoded file path)).file_pathparameter from the URL.filePathas the selected file in the chat context for reference.Acceptance Criteria
file_pathto the/chatURL and navigates to the chat page.file_pathparameter and sets the corresponding file as selected in the chat context.file_pathparameters gracefully, informing the user of any issues.--skip-build @jacob-ai-bot
Plan:
Step 1: Edit
/src/app/dashboard/[org]/[repo]/chat/ChatPage.tsxTask: Handle 'file_path' query parameter in ChatPage component
Instructions:
In the file
/src/app/dashboard/[org]/[repo]/chat/ChatPage.tsx, modify the component to extract thefile_pathquery parameter from the URL using theuseSearchParamshook from Next.js. Decode thefile_pathusingdecodeURIComponentand pass it as a prop namedselectedFilePathto theChatcomponent. Ensure that other functionalities of the ChatPage remain unaffected.Exit Criteria:
The
ChatPagecomponent correctly extracts thefile_pathparameter from the URL, decodes it, and passes it as theselectedFilePathprop to theChatcomponent without affecting other functionalities.Step 2: Edit
/src/app/dashboard/[org]/[repo]/chat/components/Chat.tsxTask: Update Chat component to select file based on 'selectedFilePath' prop
Instructions:
In the file
/src/app/dashboard/[org]/[repo]/chat/components/Chat.tsx, update theChatcomponent to accept an optional propselectedFilePathof type string. Use theuseEffecthook to watch for changes toselectedFilePath, and when it is provided and valid, set the corresponding file as selected in the chat context or state (e.g., by settingselectedFilesstate variable). If theselectedFilePathdoes not correspond to any file in the context items, display an appropriate error message to the user (e.g., using a toast notification). Ensure that existing functionalities of theChatcomponent are not affected by this change.Exit Criteria:
The
Chatcomponent accepts theselectedFilePathprop and uses it to select the corresponding file in the chat context upon initialization or when the prop changes. If theselectedFilePathis invalid or not found, an error message is displayed to the user. Existing functionalities of the Chat component continue to work as before.Step 3: Edit
/src/app/dashboard/[org]/[repo]/code-visualizer/codebase/CodebaseDetails.tsxTask: Add Send Filename to Chat button in CodebaseDetails component
Instructions:
In the file
/src/app/dashboard/[org]/[repo]/code-visualizer/codebase/CodebaseDetails.tsx, add a new button labeled 'Send Filename to Chat' at the bottom of the component UI. The button should be styled to adapt to both light and dark themes, and remain fixed at the bottom even when the content is scrolled. When clicked, the button should retrieve the file path of the currently selected code file (from theitem.fileproperty), encode the file path usingencodeURIComponent, and redirect the user to the chat page using the router'spushmethod, appending the encodedfile_pathas a query parameter to the URL (e.g.,/dashboard/[org]/[repo]/chat?file_path=(encoded file path)). Ensure that if no file is selected (i.e.,item.fileis undefined or empty), an appropriate error message is displayed to the user and the redirection does not occur.Exit Criteria:
The 'Send Filename to Chat' button is visible at the bottom of the Codebase Details component, adapts to light and dark themes, and remains fixed while content scrolls. Clicking the button redirects to the chat page with the encoded
file_pathquery parameter when a file is selected. If no file is selected, an error message is displayed and the user is not redirected.