Open jacob-local-kevin[bot] opened 1 month ago
Hello human! 👋
This PR was created by JACoB to address the issue Send Filename to Chat via button on Codebase Details
Please review the PR carefully. Auto-generated code can and will contain subtle bugs and mistakes.
If you identify code that needs to be changed, please reject the PR with a specific reason. Be as detailed as possible in your comments. JACoB will take these comments, make changes to the code and push up changes. Please note that this process will take a few minutes.
Once the code looks good, approve the PR and merge the code.
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_path
and append it as a query parameter to the/chat
URL (e.g.,/chat?file_path=(url-encoded file path)
).file_path
parameter from the URL.filePath
as the selected file in the chat context for reference.Acceptance Criteria
file_path
to the/chat
URL and navigates to the chat page.file_path
parameter and sets the corresponding file as selected in the chat context.file_path
parameters gracefully, informing the user of any issues.--skip-build @jacob-ai-bot
Plan:
Step 1: Edit
/src/app/dashboard/[org]/[repo]/chat/ChatPage.tsx
Task: 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_path
query parameter from the URL using theuseSearchParams
hook from Next.js. Decode thefile_path
usingdecodeURIComponent
and pass it as a prop namedselectedFilePath
to theChat
component. Ensure that other functionalities of the ChatPage remain unaffected.Exit Criteria: The
ChatPage
component correctly extracts thefile_path
parameter from the URL, decodes it, and passes it as theselectedFilePath
prop to theChat
component without affecting other functionalities.Step 2: Edit
/src/app/dashboard/[org]/[repo]/chat/components/Chat.tsx
Task: Update Chat component to select file based on 'selectedFilePath' prop
Instructions: In the file
/src/app/dashboard/[org]/[repo]/chat/components/Chat.tsx
, update theChat
component to accept an optional propselectedFilePath
of type string. Use theuseEffect
hook 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 settingselectedFiles
state variable). If theselectedFilePath
does 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 theChat
component are not affected by this change.Exit Criteria: The
Chat
component accepts theselectedFilePath
prop and uses it to select the corresponding file in the chat context upon initialization or when the prop changes. If theselectedFilePath
is 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.tsx
Task: 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.file
property), encode the file path usingencodeURIComponent
, and redirect the user to the chat page using the router'spush
method, appending the encodedfile_path
as 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.file
is 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_path
query parameter when a file is selected. If no file is selected, an error message is displayed and the user is not redirected.