Improvement: Improved 404 page error for /browse#837
Open
imsarang wants to merge 4 commits intosourcebot-dev:mainfrom
Open
Improvement: Improved 404 page error for /browse#837imsarang wants to merge 4 commits intosourcebot-dev:mainfrom
imsarang wants to merge 4 commits intosourcebot-dev:mainfrom
Conversation
Contributor
WalkthroughAdds a new FileNotFound component that renders a 404 UI for missing files in the browse flow and updates codePreviewPanel to render this component when the file-source response returns NOT_FOUND instead of a generic error. Changes
Sequence Diagram(s)sequenceDiagram
participant Browser
participant CodePreviewPanel
participant FileSourceAPI
participant RepoInfoAPI
participant FileNotFoundComponent
Browser->>CodePreviewPanel: Request file preview (repo, path, revision)
CodePreviewPanel->>RepoInfoAPI: fetch repoInfo
CodePreviewPanel->>FileSourceAPI: fetch fileSource
FileSourceAPI-->>CodePreviewPanel: NOT_FOUND
RepoInfoAPI-->>CodePreviewPanel: repoInfo (or error)
CodePreviewPanel->>FileNotFoundComponent: render(repoInfoResponse, fileSourceResponse, revision, path, repoName)
FileNotFoundComponent-->>Browser: display 404 UI with repo/branch/path and "Return to repository overview" link
Browser->>CodePreviewPanel: click "Return to repository overview"
CodePreviewPanel->>Browser: navigate to getBrowsePath(repoName, '/', pathType='tree', revision)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@packages/web/src/app/`[domain]/browse/[...path]/components/404NotFound.tsx:
- Around line 101-107: The "Return to the repository overview" Link in
404NotFound builds its href via getBrowsePath but omits the optional
revisionName, causing the link to drop branch context; update the Link's
getBrowsePath call to pass the component's revisionName value (alongside
repoName/repoInfoResponse.name, path '/', pathType 'tree' and
SINGLE_TENANT_ORG_DOMAIN) so the generated URL preserves the current branch;
modify the Link invocation where getBrowsePath is called (inside the 404NotFound
component) to include revisionName as the appropriate argument.
- Around line 1-22: Remove the client-side rendering directive and the unused
hook: delete the "'use client';" line at the top of 404NotFound.tsx and remove
the unused import "useEffect" so the component becomes a server component; keep
the RepoInfoResponse type (with indexedAt: Date | undefined) as-is since it will
now stay on the server, and ensure no client-only hooks or "use client"
directives are reintroduced in this file or in any components that receive
repoInfoResponse (refer to RepoInfoResponse and PathHeader to locate usages).
packages/web/src/app/[domain]/browse/[...path]/components/404NotFound.tsx
Outdated
Show resolved
Hide resolved
packages/web/src/app/[domain]/browse/[...path]/components/404NotFound.tsx
Show resolved
Hide resolved
Author
|
@brendan-kellam @msukkari |
Contributor
|
I will take a look at this later today |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The below ss is the updated screen for 404 not found when trying to browse for file that doesnot exist.
inspiration: Github
issue link: #827
Summary by CodeRabbit