Elffuss BraidHub

kikocis/continue public

main · 3.7 KiBRawPermalink
1import {
2 SharedConfigSchema,
3 modifyAnyConfigWithSharedConfig,
4} from "core/config/sharedConfig";
5import { useContext } from "react";
6import Alert from "../../../components/gui/Alert";
7import { Card, Divider } from "../../../components/ui";
8import { IdeMessengerContext } from "../../../context/IdeMessenger";
9import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
10import { updateConfig } from "../../../redux/slices/configSlice";
11import { selectCurrentOrg } from "../../../redux/slices/profilesSlice";
12import { ConfigHeader } from "../components/ConfigHeader";
13import { UserSetting } from "../components/UserSetting";
14import IndexingProgress from "../features/indexing";
15import { DocsSection } from "./DocsSection";
16
17function CodebaseSubSection() {
18 const config = useAppSelector((state) => state.config.config);
19
20 return (
21 <div>
22 <div className="mb-4 flex items-center justify-between">
23 <h3 className="mb-0 text-sm font-semibold">@codebase index</h3>
24 </div>
25
26 <Card>
27 <div className="py-2">
28 {config.disableIndexing ? (
29 <div className="p-1">
30 <p className="text-center font-semibold">Indexing is disabled</p>
31 </div>
32 ) : (
33 <IndexingProgress />
34 )}
35 </div>
36 </Card>
37 </div>
38 );
39}
40
41function EnableIndexingSetting() {
42 const dispatch = useAppDispatch();
43 const ideMessenger = useContext(IdeMessengerContext);
44 const config = useAppSelector((state) => state.config.config);
45 const currentOrg = useAppSelector(selectCurrentOrg);
46
47 function handleUpdate(sharedConfig: SharedConfigSchema) {
48 const updatedConfig = modifyAnyConfigWithSharedConfig(config, sharedConfig);
49 dispatch(updateConfig(updatedConfig));
50 ideMessenger.post("config/updateSharedConfig", sharedConfig);
51 }
52
53 const disableIndexing = config.disableIndexing ?? false;
54 const disableIndexingToggle =
55 currentOrg?.policy?.allowCodebaseIndexing === false;
56
57 return (
58 <div className="flex flex-col gap-4">
59 <UserSetting
60 title="Enable indexing"
61 type="toggle"
62 description={
63 <div className="text-foreground">
64 Allows indexing of your codebase for search and context
65 understanding.
66 <br />
67 <br />
68 Note that indexing can consume significant system resources,
69 especially on larger codebases.
70 </div>
71 }
72 value={!disableIndexing}
73 disabled={disableIndexingToggle}
74 onChange={(value) => handleUpdate({ disableIndexing: !value })}
75 />
76 </div>
77 );
78}
79
80export function IndexingSettingsSection() {
81 const config = useAppSelector((state) => state.config.config);
82 const disableIndexing = config.disableIndexing ?? false;
83
84 return (
85 <>
86 <ConfigHeader title="Indexing" />
87
88 <Alert type="warning" className="mb-6">
89 <div className="space-y-4">
90 <div>
91 <div className="-mt-0.5 text-sm font-medium">
92 Indexing has been deprecated
93 </div>
94 <div className="mt-1 text-xs">
95 Learn how to{" "}
96 <a
97 href="https://docs.continue.dev/guides/codebase-documentation-awareness"
98 target="_blank"
99 rel="noopener noreferrer"
100 className="text-inherit underline hover:brightness-125"
101 >
102 make your agent aware of your codebase and documentation
103 </a>
104 </div>
105 </div>
106 <Divider className="border-inherit" />
107 <EnableIndexingSetting />
108 </div>
109 </Alert>
110
111 {!disableIndexing && (
112 <div className="space-y-8">
113 <CodebaseSubSection />
114 <DocsSection />
115 </div>
116 )}
117 </>
118 );
119}