-
Notifications
You must be signed in to change notification settings - Fork 218
Improvement: Improved 404 page error for /browse #837
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: main
Are you sure you want to change the base?
Conversation
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 |
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.
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).
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