Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/machine/machine-schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ export const serverlessFormSchema = z.object({
.default(true)
.optional()
.describe("Disable metadata"),
hide_community_uploads: z
.boolean()
.default(false)
.optional()
.describe("Hide community uploads"),
cpu_request: z.number().describe("CPU request").nullable().optional(),
cpu_limit: z.number().describe("CPU limit").nullable().optional(),
memory_request: z.number().describe("Memory request").nullable().optional(),
Expand Down
21 changes: 21 additions & 0 deletions src/components/machine/machine-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ function ServerlessSettings({
extra_args: machine.extra_args,
disable_metadata: machine.disable_metadata,
prestart_command: machine.prestart_command,
hide_community_uploads: machine.hide_community_uploads ?? false,

optimized_runner: machine.optimized_runner,
models_to_cache: machine.models_to_cache || [],
Expand Down Expand Up @@ -984,6 +985,26 @@ function ServerlessSettings({
</FormItem>
)}
/>

<FormField
control={form.control}
name="hide_community_uploads"
render={({ field }) => (
<FormItem>
<FormLabel>Hide Community Uploads</FormLabel>
<FormDescription>
Hide community models and uploads from view
</FormDescription>
<FormControl>
<Switch
id="hide_community_uploads"
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
</FormItem>
)}
/>
</div>
</div>
</AccordionContent>
Expand Down
81 changes: 50 additions & 31 deletions src/components/models/folder-tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
} from "lucide-react";
import { useQueryState } from "nuqs";
import type React from "react";
import { useMemo, useState } from "react";
import { useMemo, useState, useEffect } from "react";
import { toast } from "sonner";

// Format file size to human-readable format (KB, MB, GB)
Expand All @@ -71,6 +71,7 @@ interface FileEntry {
interface FolderTreeProps {
className?: string;
onAddModel: (folderPath: string) => void;
machine?: any; // Optional machine prop to access settings
}

interface TreeNode {
Expand Down Expand Up @@ -903,7 +904,7 @@ function mergeNodes(
return result;
}

export function FolderTree({ className, onAddModel }: FolderTreeProps) {
export function FolderTree({ className, onAddModel, machine }: FolderTreeProps) {
const queryClient = useQueryClient();
const [search, setSearch] = useState("");
const [filter, setFilter] = useQueryState<ModelFilter>("model_view", {
Expand All @@ -922,21 +923,33 @@ export function FolderTree({ className, onAddModel }: FolderTreeProps) {
const [sortBy, setSortBy] = useState<"name" | "size">("name");
const [sortDirection, setSortDirection] = useState<"asc" | "desc">("asc");

// Check if community uploads should be hidden based on machine setting
const shouldHideCommunityUploads = machine?.hide_community_uploads ?? false;

// Auto-set filter to private if community uploads are hidden and current filter is public/all
useEffect(() => {
if (shouldHideCommunityUploads && (filter === "public" || filter === "all")) {
setFilter("private");
}
}, [shouldHideCommunityUploads, filter, setFilter]);

const { data: privateFiles, isLoading: isLoadingPrivate } = useQuery<
FileEntry[]
>({
queryKey: ["volume", "private-models"],
refetchInterval: 5000,
});

// Only load public files if community uploads are not hidden
const { data: publicFiles, isLoading: isLoadingPublic } = useQuery<
FileEntry[]
>({
queryKey: ["volume", "public-models"],
enabled: !shouldHideCommunityUploads,
});

const privateTree = privateFiles ? buildTree(privateFiles, true) : [];
const publicTree = publicFiles ? buildTree(publicFiles, false) : [];
const publicTree = publicFiles && !shouldHideCommunityUploads ? buildTree(publicFiles, false) : [];

const injectFrontendFolders = (
tree: TreeNode[],
Expand Down Expand Up @@ -1013,7 +1026,7 @@ export function FolderTree({ className, onAddModel }: FolderTreeProps) {
injectedPrivateTree,
publicTree,
filter === "private" || filter === "all",
filter === "public" || filter === "all",
(filter === "public" || filter === "all") && !shouldHideCommunityUploads,
);

// Apply sorting to the merged tree
Expand Down Expand Up @@ -1268,32 +1281,36 @@ export function FolderTree({ className, onAddModel }: FolderTreeProps) {
Private
</TabsTrigger>
</motion.div>
<motion.div layout className="relative">
<TabsTrigger
value="public"
className={cn(
"rounded-md px-4 py-1.5 font-medium text-sm transition-all",
filter === "public"
? "bg-gradient-to-b from-white to-gray-100 shadow-sm ring-1 ring-gray-200/50 dark:from-zinc-800 dark:to-zinc-700 dark:ring-zinc-700"
: "text-gray-600 hover:bg-gray-100 dark:text-zinc-400 dark:hover:bg-zinc-700",
)}
>
Public
</TabsTrigger>
</motion.div>
<motion.div layout className="relative">
<TabsTrigger
value="all"
className={cn(
"rounded-md px-4 py-1.5 font-medium text-sm transition-all",
filter === "all"
? "bg-gradient-to-b from-white to-gray-100 shadow-sm ring-1 ring-gray-200/50 dark:from-zinc-800 dark:to-zinc-700 dark:ring-zinc-700"
: "text-gray-600 hover:bg-gray-100 dark:text-zinc-400 dark:hover:bg-zinc-700",
)}
>
All
</TabsTrigger>
</motion.div>
{!shouldHideCommunityUploads && (
<>
<motion.div layout className="relative">
<TabsTrigger
value="public"
className={cn(
"rounded-md px-4 py-1.5 font-medium text-sm transition-all",
filter === "public"
? "bg-gradient-to-b from-white to-gray-100 shadow-sm ring-1 ring-gray-200/50 dark:from-zinc-800 dark:to-zinc-700 dark:ring-zinc-700"
: "text-gray-600 hover:bg-gray-100 dark:text-zinc-400 dark:hover:bg-zinc-700",
)}
>
Public
</TabsTrigger>
</motion.div>
<motion.div layout className="relative">
<TabsTrigger
value="all"
className={cn(
"rounded-md px-4 py-1.5 font-medium text-sm transition-all",
filter === "all"
? "bg-gradient-to-b from-white to-gray-100 shadow-sm ring-1 ring-gray-200/50 dark:from-zinc-800 dark:to-zinc-700 dark:ring-zinc-700"
: "text-gray-600 hover:bg-gray-100 dark:text-zinc-400 dark:hover:bg-zinc-700",
)}
>
All
</TabsTrigger>
</motion.div>
</>
)}
</TabsList>
</motion.div>
</Tabs>
Expand Down Expand Up @@ -1338,7 +1355,9 @@ export function FolderTree({ className, onAddModel }: FolderTreeProps) {
{filter === "all"
? "No models available. Upload models to your folders or create a new folder."
: filter === "private"
? "No private models found. Upload models to your folders or create a new folder."
? shouldHideCommunityUploads
? "No private models found. Community uploads are hidden for this machine. Upload models to your folders or create a new folder."
: "No private models found. Upload models to your folders or create a new folder."
: "No public models available at the moment."}
</p>
{/* Allow upload even for public filter */}
Expand Down
8 changes: 6 additions & 2 deletions src/routes/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export const Route = createFileRoute("/models")({

export function StoragePage({
isWorkflowPage = false,
}: { isWorkflowPage?: boolean }) {
machine,
}: {
isWorkflowPage?: boolean;
machine?: any;
}) {
const [showAddModel, setShowAddModel] = useState(false);
const [selectedFolderPath, setSelectedFolderPath] = useState("");

Expand Down Expand Up @@ -41,7 +45,7 @@ export function StoragePage({
</div>
}
>
<FolderTree onAddModel={handleAddModel} />
<FolderTree onAddModel={handleAddModel} machine={machine} />
</Suspense>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/routes/workflows/$workflowId/$view.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function WorkflowPageComponent() {
);
break;
case "model":
view = <StoragePage isWorkflowPage={true} />;
view = <StoragePage isWorkflowPage={true} machine={machine} />;
break;
}

Expand Down
2 changes: 2 additions & 0 deletions src/types/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface Machine {
install_custom_node_with_gpu?: boolean;
optimized_runner?: boolean;
disable_metadata?: boolean;
hide_community_uploads?: boolean;

// Resource settings
cpu_request?: number | null;
Expand Down Expand Up @@ -79,6 +80,7 @@ export interface MachineVersion {
prestart_command?: string;
keep_warm: number;
disable_metadata?: boolean;
hide_community_uploads?: boolean;
allow_concurrent_inputs?: number;
machine_builder_version?: string;
cpu_request?: number | null;
Expand Down