MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / LocalUploader

Function LocalUploader

website/src/components/LocalUploader.tsx:153–761  ·  view source on GitHub ↗
({ onComplete, plain }: { onComplete: (data: unknown) => void, plain?: boolean })

Source from the content-addressed store, hash-verified

151};
152
153export default function LocalUploader({ onComplete, plain }: { onComplete: (data: unknown) => void, plain?: boolean }) {
154 const navigate = useNavigate();
155 const [isParsing, setIsParsing] = useState(false);
156 const [progress, setProgress] = useState({ text: "", value: 0 });
157 const [activeTab, setActiveTab] = useState<'folder' | 'zip' | 'cgc' | 'remote'>('remote');
158 const [remoteRepoUrl, setRemoteRepoUrl] = useState("");
159 const [detectedProvider, setDetectedProvider] = useState<RepoProvider>("github");
160 const [pat, setPat] = useState(() => localStorage.getItem("github_pat") || "");
161
162 const [config, setConfig] = useState(() => {
163 try {
164 const saved = localStorage.getItem('cgc_indexer_config');
165 if (saved) {
166 return {
167 indexVariables: false,
168 skipTests: true,
169 maxNodes: 100000,
170 maxEdges: 50000,
171 ...JSON.parse(saved)
172 };
173 }
174 } catch (e) { }
175 return {
176 indexVariables: false,
177 skipTests: true,
178 maxNodes: 100000,
179 maxEdges: 50000,
180 };
181 });
182
183 const [isConfigOpen, setIsConfigOpen] = useState(false);
184
185 useEffect(() => {
186 if (!isConfigOpen) return;
187 const handleKeyDown = (e: KeyboardEvent) => {
188 if (e.key === "Escape") {
189 setIsConfigOpen(false);
190 }
191 };
192 window.addEventListener("keydown", handleKeyDown);
193 return () => window.removeEventListener("keydown", handleKeyDown);
194 }, [isConfigOpen]);
195
196 const updateConfig = (newConfig: Partial<typeof config>) => {
197 const updated = { ...config, ...newConfig };
198 setConfig(updated);
199 localStorage.setItem('cgc_indexer_config', JSON.stringify(updated));
200 };
201
202 const isDirIgnored = (name: string) => {
203 if (IGNORED_DIRS.has(name)) return true;
204 if (config.skipTests && ['test', 'tests', '__tests__', 'spec', 'specs'].includes(name.toLowerCase())) return true;
205 return false;
206 };
207
208 const processFiles = async (files: { path: string, content: string }[], repoName: string = "local-project") => {
209 // Build fileContents map before the worker clears content for memory
210 const fileContents: Record<string, string> = {};

Callers

nothing calls this directly

Calls 4

handleRepoUrlChangeFunction · 0.85
handlePatChangeFunction · 0.85
updateConfigFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected