JACoB PR for Issue Bug: Application Fetches Files from "main" Branch Even When "master" is Selected #500
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
When a user selects the "master" branch from the branch dropdown menu within the application, the file fetching functionality continues to retrieve files from the "main" branch instead of the selected "master" branch. This results in the application displaying files that do not correspond to the user's selected branch.
Expected Behavior
The application should fetch and display files from the branch that the user selects in the branch dropdown. Specifically:
Actual Behavior
Despite selecting "master" in the branch dropdown:
Impact
This bug affects users who:
The inability to access the correct branch's files can:
@jacob-ai-bot --skip-build
@jacob-ai-bot --skip-build
Plan:
Step 1: Edit
/src/app/dashboard/[org]/[repo]/layout.tsx
Task: Manage selectedBranch state in parent component
Instructions:
In the parent component located at '/src/app/dashboard/[org]/[repo]/layout.tsx', add state management for 'selectedBranch'. Initialize 'selectedBranch' using 'useState', starting with the repository's default branch (e.g., 'main'). Pass 'selectedBranch' and 'setSelectedBranch' as props to the 'Header' component and any child components that require the selected branch information, such as components that fetch files.
Exit Criteria:
The 'selectedBranch' state is managed in the parent component and is passed down to the 'Header' component and other relevant child components.
Step 2: Edit
/src/app/dashboard/[org]/[repo]/components/Header.tsx
Task: Update Header component to use selectedBranch from props
Instructions:
In '/src/app/dashboard/[org]/[repo]/components/Header.tsx', remove the local state management of 'selectedBranch'. Modify the component to accept 'selectedBranch' and 'setSelectedBranch' as props. Update the branch dropdown select input to use 'selectedBranch' from props. In the 'handleBranchChange' function, use 'setSelectedBranch' from props to update the selected branch when the user selects a different branch. Save it to local storage so that it persists when the user returns to the app (if it's the correct repo)
Exit Criteria:
The 'Header' component uses 'selectedBranch' from props, and updates it correctly when the branch selection changes. The selectedBranch is saved to local storage, it works for server rendering, and there are corner cases that are addressed when the user changes the repository and then changes it back to the original repo, we want to persist that original selectedBranch.