Skip to content

add RootNodeSelector componen#646

Open
refoo0 wants to merge 1 commit intomainfrom
add-root-node-selector
Open

add RootNodeSelector componen#646
refoo0 wants to merge 1 commit intomainfrom
add-root-node-selector

Conversation

@refoo0
Copy link
Member

@refoo0 refoo0 commented Feb 13, 2026

No description provided.

Signed-off-by: rafi <refaei.shikho@hotmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for selecting an “origin” (root node) for dependency views by introducing a reusable RootNodeSelector component and wiring an origin query param through the dependencies list and graph pages.

Changes:

  • Introduce useRootNodes() hook to fetch artifact root nodes via SWR.
  • Add RootNodeSelector dropdown component that reads/writes the origin query parameter.
  • Wire origin into dependency list (/components) and dependency graph (/dependency-graph) requests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/context/AssetVersionContext.tsx Adds useRootNodes() SWR hook for fetching artifact root nodes.
src/components/RootNodeSelector.tsx New dropdown component for choosing/clearing an origin root node via query params.
src/app/(loading-group)/.../dependencies/page.tsx Adds selector to UI and forwards origin to the components query.
src/app/(loading-group)/.../dependencies/graph/page.tsx Adds selector to UI and forwards origin to the graph query.
src/app/(loading-group)/.../artifacts/page.tsx Refactors root-nodes fetching to reuse useRootNodes().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


useEffect(() => {
handleSelect(undefined);
}, [artifactName]);
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The useEffect dependency array omits handleSelect, even though it’s referenced inside the effect. This can lead to stale closures if pushQueryParameter ever changes. Include handleSelect (or inline the logic) to satisfy the rules-of-hooks/exhaustive-deps behavior.

Suggested change
}, [artifactName]);
}, [artifactName, handleSelect]);

Copilot uses AI. Check for mistakes.
<DropdownMenu open={open} onOpenChange={setOpen}>
<DropdownMenuTrigger asChild>
<Button variant="outline">
<div className="flex w-42 items-center justify-between h-4">
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w-42 is not a default Tailwind width utility, and tailwind.config.js doesn’t extend widths. This class will be ignored, so the button layout likely won’t match expectations. Use a valid utility (e.g., w-44) or an arbitrary value like w-[10.5rem].

Suggested change
<div className="flex w-42 items-center justify-between h-4">
<div className="flex w-[10.5rem] items-center justify-between h-4">

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +37
const rootnodeParam = searchParams?.get("origin");

const [selectedRootNode, setSelectedRootNode] = useState(
getRootNodeName(rootnodeParam),
);

useEffect(() => {
setSelectedRootNode(getRootNodeName(rootnodeParam));
}, [rootnodeParam]);
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rootnodeParam is not camelCased consistently with the rest of the file (should be rootNodeParam). Renaming improves readability and avoids subtle typos when adding related variables.

Suggested change
const rootnodeParam = searchParams?.get("origin");
const [selectedRootNode, setSelectedRootNode] = useState(
getRootNodeName(rootnodeParam),
);
useEffect(() => {
setSelectedRootNode(getRootNodeName(rootnodeParam));
}, [rootnodeParam]);
const rootNodeParam = searchParams?.get("origin");
const [selectedRootNode, setSelectedRootNode] = useState(
getRootNodeName(rootNodeParam),
);
useEffect(() => {
setSelectedRootNode(getRootNodeName(rootNodeParam));
}, [rootNodeParam]);

Copilot uses AI. Check for mistakes.
Comment on lines +344 to +348
if (searchParams?.has("origin")) {
params.append(
"origin",
encodeURIComponent(searchParams.get("origin") as string),
);
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params.append() will URL-encode when you later call params.toString(). Pre-encoding the value with encodeURIComponent here can double-encode (especially problematic for origin, which is likely a URL). Append the raw value and let URLSearchParams handle encoding.

Copilot uses AI. Check for mistakes.
Comment on lines 75 to 80
const params = useDecodedParams() as {
organizationSlug: string;
projectSlug: string;
assetSlug: string;
assetVersionSlug: string;
};
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params is computed via useDecodedParams() but is no longer used after switching the SWR call to useRootNodes(). Please remove this unused variable to avoid lint/build failures.

Copilot uses AI. Check for mistakes.
import { NoopUpdater, WithUpdater } from "./ClientContextWrapper";
import { fetcher } from "@/data-fetcher/fetcher";
import useSWR from "swr";
import { useActiveAsset } from "@/hooks/useActiveAsset";
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useActiveAsset is imported but never used in this file. Please remove the unused import to avoid lint/build failures and keep the module dependency graph minimal.

Suggested change
import { useActiveAsset } from "@/hooks/useActiveAsset";

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +41
useEffect(() => {
handleSelect(undefined);
}, [artifactName]);
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This effect clears the origin query param whenever artifactName changes, but it also runs on initial mount. That means deep-linking to a URL that already includes ?artifact=...&origin=... will immediately lose origin. Consider skipping the initial run (e.g., via a ref) or only clearing when the artifact actually changes from a previous value.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant