fix(frontend): ns aware navigation#5024
Conversation
|
🚅 Deployed to the rivet-pr-5024 environment in rivet-frontend
|
Code Review: fix(frontend): ns aware navigation (#5024)OverviewThis PR improves namespace/project switching in the frontend by preserving the user's current sub-route when switching namespaces. Instead of always resetting to the base namespace route (e.g. What's Good
Issues and Suggestions1. Unsafe type cast — potential mismatch between TypeScript type and runtime value) as "/orgs/$organization/projects/$project/ns/$namespace";The cast tells TypeScript the value is the base namespace route literal, but at runtime it may be a deeper path (e.g. 2. Detail-page navigation may 404 or show stale dataWhen a user is on a resource detail page (e.g. an actor, a specific build), the leaf Suggested fix: only preserve the path up to the 3. Duplicated logic — should be extracted to a shared hookThe exact same pattern appears in both function useNamespaceAwarePath(base: string): string {
return useMatches({
select: (matches) => {
const leaf = matches[matches.length - 1]?.fullPath;
return typeof leaf === "string" && leaf.startsWith(base) ? leaf : base;
},
});
}4. PR description and checklist are emptyNone of the type-of-change checkboxes are filled in, no test description is provided, and the checklist is unchecked. The description also has no summary of the motivation. This makes it harder to review and audit later. Minor Notes
Summary
The core idea is the right fix, but the detail-page edge case and the duplicated implementation are worth addressing. |
f2d1963 to
ded0afc
Compare
22e8455 to
a29da76
Compare
ded0afc to
aa332cf
Compare
aa332cf to
9cf6ed3
Compare

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: