Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cc46b34
feat: Add advanced web crawling with domain filtering
leex279 Sep 22, 2025
a9f54f2
feat: Improve domain filtering UI and add metadata viewer
leex279 Sep 22, 2025
8344ee0
fix: Resolve button nesting error and improve metadata display
leex279 Sep 22, 2025
c8ba28e
refactor: Move metadata display to content viewer area
leex279 Sep 22, 2025
cc3c176
feat: Make metadata panel always visible as collapsible section
leex279 Sep 22, 2025
a4848dc
fix: Move metadata panel to bottom and improve visibility
leex279 Sep 22, 2025
1bc2d64
feat: Add comprehensive edit crawler configuration and metadata viewing
leex279 Sep 22, 2025
9138fef
fix: Remove View Source links from document sidebar
leex279 Sep 22, 2025
476e15a
fix: Correct ActiveOperationsResponse handling in useCrawlUrlV2
leex279 Sep 22, 2025
7ea4d99
fix: Improve domain filter robustness in crawling service
leex279 Sep 22, 2025
dbe5855
docs: Add comprehensive JSDoc documentation for CrawlConfig
leex279 Sep 22, 2025
2dbf6c3
fix: Ensure Edit Crawler Configuration loads initial data properly
leex279 Sep 22, 2025
ec01e91
fix: Address CodeRabbit review comments
leex279 Sep 22, 2025
4291385
fix: Resolve TypeScript parsing error in JSDoc comments
leex279 Sep 22, 2025
1053d5c
fix: Replace asterisk characters in JSDoc to prevent TypeScript parsi…
leex279 Sep 22, 2025
a7768c2
fix: Improve Edit Crawler Configuration dialog layout and data loading
leex279 Sep 22, 2025
3ed3dc6
fix: Add missing GET endpoint for single knowledge item
leex279 Sep 22, 2025
4876cc9
fix: Use original_url for Edit Crawler Configuration
leex279 Sep 22, 2025
b76c7cf
fix: Event propagation and data loading in Edit Crawler Configuration
leex279 Sep 22, 2025
487c83d
fix: Keyboard event propagation and auto-expand advanced config
leex279 Sep 22, 2025
45c394b
fix: Proper deletion and persistence for crawler configuration updates
leex279 Sep 22, 2025
277ac35
fix: Improve dialog scrolling and add debug logging for config persis…
leex279 Sep 22, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { Button, Input, Label } from "../../ui/primitives";
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "../../ui/primitives/dialog";
import { cn } from "../../ui/primitives/styles";
import { Tabs, TabsContent } from "../../ui/primitives/tabs";
import { useCrawlUrl, useUploadDocument } from "../hooks";
import type { CrawlRequest, UploadMetadata } from "../types";
import { useCrawlUrl, useCrawlUrlV2, useUploadDocument } from "../hooks";
import type { CrawlConfig, CrawlRequest, CrawlRequestV2, UploadMetadata } from "../types";
import { AdvancedCrawlConfig } from "./AdvancedCrawlConfig";
import { KnowledgeTypeSelector } from "./KnowledgeTypeSelector";
import { LevelSelector } from "./LevelSelector";
import { TagInput } from "./TagInput";
Expand All @@ -32,6 +33,7 @@ export const AddKnowledgeDialog: React.FC<AddKnowledgeDialogProps> = ({
const [activeTab, setActiveTab] = useState<"crawl" | "upload">("crawl");
const { showToast } = useToast();
const crawlMutation = useCrawlUrl();
const crawlV2Mutation = useCrawlUrlV2();
const uploadMutation = useUploadDocument();

// Generate unique IDs for form elements
Expand All @@ -43,6 +45,7 @@ export const AddKnowledgeDialog: React.FC<AddKnowledgeDialogProps> = ({
const [crawlType, setCrawlType] = useState<"technical" | "business">("technical");
const [maxDepth, setMaxDepth] = useState("2");
const [tags, setTags] = useState<string[]>([]);
const [crawlConfig, setCrawlConfig] = useState<CrawlConfig>({});

// Upload form state
const [selectedFile, setSelectedFile] = useState<File | null>(null);
Expand All @@ -54,6 +57,7 @@ export const AddKnowledgeDialog: React.FC<AddKnowledgeDialogProps> = ({
setCrawlType("technical");
setMaxDepth("2");
setTags([]);
setCrawlConfig({});
setSelectedFile(null);
setUploadType("technical");
setUploadTags([]);
Expand All @@ -66,21 +70,42 @@ export const AddKnowledgeDialog: React.FC<AddKnowledgeDialogProps> = ({
}

try {
const request: CrawlRequest = {
url: crawlUrl,
knowledge_type: crawlType,
max_depth: parseInt(maxDepth, 10),
tags: tags.length > 0 ? tags : undefined,
};
// Check if we have any domain filtering configuration
const hasCrawlConfig =
(crawlConfig.allowed_domains && crawlConfig.allowed_domains.length > 0) ||
(crawlConfig.excluded_domains && crawlConfig.excluded_domains.length > 0) ||
(crawlConfig.include_patterns && crawlConfig.include_patterns.length > 0) ||
(crawlConfig.exclude_patterns && crawlConfig.exclude_patterns.length > 0);

let response;

const response = await crawlMutation.mutateAsync(request);
if (hasCrawlConfig) {
// Use v2 endpoint with domain filtering
const requestV2: CrawlRequestV2 = {
url: crawlUrl,
knowledge_type: crawlType,
max_depth: parseInt(maxDepth, 10),
tags: tags.length > 0 ? tags : undefined,
crawl_config: crawlConfig,
};
response = await crawlV2Mutation.mutateAsync(requestV2);
} else {
// Use regular endpoint
const request: CrawlRequest = {
url: crawlUrl,
knowledge_type: crawlType,
max_depth: parseInt(maxDepth, 10),
tags: tags.length > 0 ? tags : undefined,
};
response = await crawlMutation.mutateAsync(request);
}

// Notify parent about the new crawl operation
if (response?.progressId && onCrawlStarted) {
onCrawlStarted(response.progressId);
}

showToast("Crawl started successfully", "success");
showToast(hasCrawlConfig ? "Crawl started with domain filtering" : "Crawl started successfully", "success");
resetForm();
onSuccess();
onOpenChange(false);
Expand Down Expand Up @@ -123,19 +148,19 @@ export const AddKnowledgeDialog: React.FC<AddKnowledgeDialogProps> = ({
}
};

const isProcessing = crawlMutation.isPending || uploadMutation.isPending;
const isProcessing = crawlMutation.isPending || crawlV2Mutation.isPending || uploadMutation.isPending;

return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-[600px]">
<DialogHeader>
<DialogContent className="sm:max-w-[600px]" style={{ maxHeight: "85vh", display: "flex", flexDirection: "column" }}>
<DialogHeader className="flex-shrink-0">
<DialogTitle>Add Knowledge</DialogTitle>
<DialogDescription>Crawl websites or upload documents to expand your knowledge base.</DialogDescription>
</DialogHeader>

<Tabs value={activeTab} onValueChange={(v) => setActiveTab(v as "crawl" | "upload")}>
<Tabs value={activeTab} onValueChange={(v) => setActiveTab(v as "crawl" | "upload")} className="flex-1 flex flex-col min-h-0">
{/* Enhanced Tab Buttons */}
<div className="grid grid-cols-2 gap-3 p-2 rounded-xl backdrop-blur-md bg-gradient-to-b from-gray-100/30 via-gray-50/20 to-white/40 dark:from-gray-900/30 dark:via-gray-800/20 dark:to-black/40 border border-gray-200/40 dark:border-gray-700/40">
<div className="grid grid-cols-2 gap-3 p-2 rounded-xl backdrop-blur-md bg-gradient-to-b from-gray-100/30 via-gray-50/20 to-white/40 dark:from-gray-900/30 dark:via-gray-800/20 dark:to-black/40 border border-gray-200/40 dark:border-gray-700/40 flex-shrink-0">
{/* Crawl Website Tab */}
<button
type="button"
Expand Down Expand Up @@ -190,7 +215,16 @@ export const AddKnowledgeDialog: React.FC<AddKnowledgeDialogProps> = ({
</div>

{/* Crawl Tab */}
<TabsContent value="crawl" className="space-y-6 mt-6">
<TabsContent value="crawl" className="mt-6 flex-1 min-h-0">
<div
className="overflow-y-auto overflow-x-hidden pr-2 scrollbar-thin scrollbar-thumb-gray-400 dark:scrollbar-thumb-gray-600 scrollbar-track-transparent"
style={{
maxHeight: "calc(85vh - 200px)",
overflowY: "scroll",
WebkitOverflowScrolling: "touch",
scrollbarWidth: "thin"
}}>
<div className="space-y-6 pb-4">
{/* Enhanced URL Input Section */}
<div className="space-y-3">
<Label htmlFor={urlId} className="text-sm font-medium text-gray-900 dark:text-white/90">
Expand All @@ -215,6 +249,9 @@ export const AddKnowledgeDialog: React.FC<AddKnowledgeDialogProps> = ({
</p>
</div>

{/* Advanced Configuration - positioned directly below URL */}
<AdvancedCrawlConfig config={crawlConfig} onChange={setCrawlConfig} />

<div className="space-y-6">
<KnowledgeTypeSelector value={crawlType} onValueChange={setCrawlType} disabled={isProcessing} />

Expand All @@ -233,7 +270,7 @@ export const AddKnowledgeDialog: React.FC<AddKnowledgeDialogProps> = ({
disabled={isProcessing || !crawlUrl}
className="w-full bg-gradient-to-r from-cyan-500 to-cyan-600 hover:from-cyan-600 hover:to-cyan-700 backdrop-blur-md border border-cyan-400/50 shadow-[0_0_20px_rgba(6,182,212,0.25)] hover:shadow-[0_0_30px_rgba(6,182,212,0.35)] transition-all duration-200"
>
{crawlMutation.isPending ? (
{(crawlMutation.isPending || crawlV2Mutation.isPending) ? (
<>
<Loader2 className="w-4 h-4 mr-2 animate-spin" />
Starting Crawl...
Expand All @@ -245,10 +282,21 @@ export const AddKnowledgeDialog: React.FC<AddKnowledgeDialogProps> = ({
</>
)}
</Button>
</div>
</div>
</TabsContent>

{/* Upload Tab */}
<TabsContent value="upload" className="space-y-6 mt-6">
<TabsContent value="upload" className="mt-6 flex-1 min-h-0">
<div
className="overflow-y-auto overflow-x-hidden pr-2 scrollbar-thin scrollbar-thumb-gray-400 dark:scrollbar-thumb-gray-600 scrollbar-track-transparent"
style={{
maxHeight: "calc(85vh - 200px)",
overflowY: "scroll",
WebkitOverflowScrolling: "touch",
scrollbarWidth: "thin"
}}>
<div className="space-y-6 pb-4">
{/* Enhanced File Input Section */}
<div className="space-y-3">
<Label htmlFor={fileId} className="text-sm font-medium text-gray-900 dark:text-white/90">
Expand Down Expand Up @@ -326,6 +374,8 @@ export const AddKnowledgeDialog: React.FC<AddKnowledgeDialogProps> = ({
</>
)}
</Button>
</div>
</div>
</TabsContent>
</Tabs>
</DialogContent>
Expand Down
Loading