Skip to content

Commit d0c01b7

Browse files
Alexwang-solgaohan1
andauthored
fix(repo-page): pass 'include' params to API (#268)
Co-authored-by: gaohan1 <[email protected]>
1 parent e6c9f37 commit d0c01b7

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

src/app/[owner]/[repo]/page.tsx

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/* eslint-disable @typescript-eslint/no-unused-vars */
22
'use client';
33

4-
import React, { useCallback, useState, useMemo, useEffect, useRef } from 'react';
5-
import { useParams, useSearchParams } from 'next/navigation';
6-
import { FaExclamationTriangle, FaBookOpen, FaGithub, FaGitlab, FaBitbucket, FaDownload, FaFileExport, FaHome, FaFolder, FaSync, FaChevronUp, FaChevronDown, FaComments, FaTimes } from 'react-icons/fa';
7-
import Link from 'next/link';
8-
import ThemeToggle from '@/components/theme-toggle';
9-
import Markdown from '@/components/Markdown';
104
import Ask from '@/components/Ask';
5+
import Markdown from '@/components/Markdown';
116
import ModelSelectionModal from '@/components/ModelSelectionModal';
7+
import ThemeToggle from '@/components/theme-toggle';
128
import WikiTreeView from '@/components/WikiTreeView';
139
import { useLanguage } from '@/contexts/LanguageContext';
1410
import { RepoInfo } from '@/types/repoinfo';
15-
import { extractUrlDomain, extractUrlPath } from '@/utils/urlDecoder';
1611
import getRepoUrl from '@/utils/getRepoUrl';
12+
import { extractUrlDomain, extractUrlPath } from '@/utils/urlDecoder';
13+
import Link from 'next/link';
14+
import { useParams, useSearchParams } from 'next/navigation';
15+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
16+
import { FaBitbucket, FaBookOpen, FaComments, FaDownload, FaExclamationTriangle, FaFileExport, FaFolder, FaGithub, FaGitlab, FaHome, FaSync, FaTimes } from 'react-icons/fa';
1717
// Define the WikiSection and WikiStructure types directly in this file
1818
// since the imported types don't have the sections and rootSections properties
1919
interface WikiSection {
@@ -105,6 +105,8 @@ const addTokensToRequestBody = (
105105
language: string = 'en',
106106
excludedDirs?: string,
107107
excludedFiles?: string,
108+
includedDirs?: string,
109+
includedFiles?: string
108110
): void => {
109111
if (token !== '') {
110112
requestBody.token = token;
@@ -126,6 +128,13 @@ const addTokensToRequestBody = (
126128
if (excludedFiles) {
127129
requestBody.excluded_files = excludedFiles;
128130
}
131+
if (includedDirs) {
132+
requestBody.included_dirs = includedDirs;
133+
}
134+
if (includedFiles) {
135+
requestBody.included_files = includedFiles;
136+
}
137+
129138
};
130139

131140
const createGithubHeaders = (githubToken: string): HeadersInit => {
@@ -226,6 +235,11 @@ export default function RepoWikiPage() {
226235
const excludedFiles = searchParams.get('excluded_files') || '';
227236
const [modelExcludedDirs, setModelExcludedDirs] = useState(excludedDirs);
228237
const [modelExcludedFiles, setModelExcludedFiles] = useState(excludedFiles);
238+
const includedDirs = searchParams.get('included_dirs') || '';
239+
const includedFiles = searchParams.get('included_files') || '';
240+
const [modelIncludedDirs, setModelIncludedDirs] = useState(includedDirs);
241+
const [modelIncludedFiles, setModelIncludedFiles] = useState(includedFiles);
242+
229243

230244
// Wiki type state - default to comprehensive view
231245
const isComprehensiveParam = searchParams.get('comprehensive') !== 'false';
@@ -487,7 +501,7 @@ Remember:
487501
};
488502

489503
// Add tokens if available
490-
addTokensToRequestBody(requestBody, currentToken, effectiveRepoInfo.type, selectedProviderState, selectedModelState, isCustomSelectedModelState, customSelectedModelState, language, modelExcludedDirs, modelExcludedFiles);
504+
addTokensToRequestBody(requestBody, currentToken, effectiveRepoInfo.type, selectedProviderState, selectedModelState, isCustomSelectedModelState, customSelectedModelState, language, modelExcludedDirs, modelExcludedFiles, modelIncludedDirs, modelIncludedFiles);
491505

492506
// Use WebSocket for communication
493507
let content = '';
@@ -780,7 +794,7 @@ IMPORTANT:
780794
};
781795

782796
// Add tokens if available
783-
addTokensToRequestBody(requestBody, currentToken, effectiveRepoInfo.type, selectedProviderState, selectedModelState, isCustomSelectedModelState, customSelectedModelState, language, modelExcludedDirs, modelExcludedFiles);
797+
addTokensToRequestBody(requestBody, currentToken, effectiveRepoInfo.type, selectedProviderState, selectedModelState, isCustomSelectedModelState, customSelectedModelState, language, modelExcludedDirs, modelExcludedFiles, modelIncludedDirs, modelIncludedFiles);
784798

785799
// Use WebSocket for communication
786800
let responseText = '';
@@ -2209,6 +2223,10 @@ IMPORTANT:
22092223
setExcludedDirs={setModelExcludedDirs}
22102224
excludedFiles={modelExcludedFiles}
22112225
setExcludedFiles={setModelExcludedFiles}
2226+
includedDirs={modelIncludedDirs}
2227+
setIncludedDirs={setModelIncludedDirs}
2228+
includedFiles={modelIncludedFiles}
2229+
setIncludedFiles={setModelIncludedFiles}
22122230
onApply={confirmRefresh}
22132231
showWikiType={true}
22142232
showTokenInput={effectiveRepoInfo.type !== 'local' && !currentToken} // Show token input if not local and no current token

0 commit comments

Comments
 (0)