Add Rescan Channel option to channels tab

Co-authored-by: xCyanGrizzly <53275238+xCyanGrizzly@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-05 20:34:53 +00:00
parent 71a2e6a5e8
commit e45de85c69
8 changed files with 94 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ import {
Power,
ArrowDownToLine,
ArrowUpFromLine,
RefreshCcw,
} from "lucide-react";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -23,12 +24,14 @@ interface ChannelColumnsProps {
onToggleActive: (id: string) => void;
onDelete: (id: string) => void;
onSetType: (id: string, type: "SOURCE" | "DESTINATION") => void;
onRescan: (id: string) => void;
}
export function getChannelColumns({
onToggleActive,
onDelete,
onSetType,
onRescan,
}: ChannelColumnsProps): ColumnDef<ChannelRow, unknown>[] {
return [
{
@@ -121,6 +124,14 @@ export function getChannelColumns({
Set as Source
</DropdownMenuItem>
)}
{row.original.type === "SOURCE" && (
<DropdownMenuItem
onClick={() => onRescan(row.original.id)}
>
<RefreshCcw className="mr-2 h-3.5 w-3.5" />
Rescan Channel
</DropdownMenuItem>
)}
<DropdownMenuItem
onClick={() => onToggleActive(row.original.id)}
>

View File

@@ -8,6 +8,7 @@ import {
deleteChannel,
toggleChannelActive,
setChannelType,
rescanChannel,
} from "../actions";
import { DataTable } from "@/components/shared/data-table";
import { DeleteDialog } from "@/components/shared/delete-dialog";
@@ -22,6 +23,7 @@ interface ChannelsTabProps {
export function ChannelsTab({ channels, globalDestination }: ChannelsTabProps) {
const [isPending, startTransition] = useTransition();
const [deleteId, setDeleteId] = useState<string | null>(null);
const [rescanId, setRescanId] = useState<string | null>(null);
const columns = getChannelColumns({
onToggleActive: (id) => {
@@ -39,6 +41,7 @@ export function ChannelsTab({ channels, globalDestination }: ChannelsTabProps) {
else toast.error(result.error);
});
},
onRescan: (id) => setRescanId(id),
});
const { table } = useDataTable({
@@ -60,6 +63,19 @@ export function ChannelsTab({ channels, globalDestination }: ChannelsTabProps) {
});
};
const handleRescan = () => {
if (!rescanId) return;
startTransition(async () => {
const result = await rescanChannel(rescanId);
if (result.success) {
toast.success("Channel scan progress reset — it will be fully rescanned on the next sync");
setRescanId(null);
} else {
toast.error(result.error);
}
});
};
return (
<div className="space-y-4">
<DestinationCard destination={globalDestination} />
@@ -83,6 +99,16 @@ export function ChannelsTab({ channels, globalDestination }: ChannelsTabProps) {
onConfirm={handleDelete}
isLoading={isPending}
/>
<DeleteDialog
open={!!rescanId}
onOpenChange={(open) => !open && setRescanId(null)}
title="Rescan Channel"
description="This will reset all scan progress for this channel. On the next sync the worker will re-process every message from the beginning. Packages that are already in the library will be skipped (deduplication by hash), but any missing files will be re-downloaded and re-uploaded. This may take a long time for large channels."
confirmLabel="Rescan"
onConfirm={handleRescan}
isLoading={isPending}
/>
</div>
);
}