Changesets · Branches · Tags · Compare
| Changeset | f90cd713edb943fb7c8cc6410795f623af42b45ddc394037aa165f86b5a59b4d |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-07-11 00:22 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-07-11 00:22 -07:00 |
| Parents | a4e52f074c38, 89b0d08ea1d4 |
2 files changed
modified core/config/profile/doLoadConfig.ts +12 −0
| @@ -20,6 +20,7 @@ | ||
| 20 | 20 | Tool, |
| 21 | 21 | } from "../../"; |
| 22 | 22 | import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton"; |
| 23 | +import CurrentFileContextProvider from "../../context/providers/CurrentFileContextProvider"; | |
| 23 | 24 | import MCPContextProvider from "../../context/providers/MCPContextProvider"; |
| 24 | 25 | import RulesContextProvider from "../../context/providers/RulesContextProvider"; |
| 25 | 26 | import { ControlPlaneProxyInfo } from "../../control-plane/analytics/IAnalyticsProvider.js"; |
| @@ -152,6 +153,17 @@ | ||
| 152 | 153 | newConfig.rules.unshift(...rules); |
| 153 | 154 | newConfig.contextProviders.push(new RulesContextProvider({})); |
| 154 | 155 | |
| 156 | + // Add current file as context if setting is enabled | |
| 157 | + if ( | |
| 158 | + newConfig.experimental?.useCurrentFileAsContext === true && | |
| 159 | + !newConfig.contextProviders.find( | |
| 160 | + (c) => | |
| 161 | + c.description.title === CurrentFileContextProvider.description.title, | |
| 162 | + ) | |
| 163 | + ) { | |
| 164 | + newConfig.contextProviders.push(new CurrentFileContextProvider({})); | |
| 165 | + } | |
| 166 | + | |
| 155 | 167 | // Add rules from colocated rules.md files in the codebase |
| 156 | 168 | const { rules: codebaseRules, errors: codebaseRulesErrors } = |
| 157 | 169 | await loadCodebaseRules(ide); |
modified gui/src/components/mainInput/TipTapEditor/utils/insertCurrentFileContextMention.ts +24 −0
| @@ -2,15 +2,39 @@ | ||
| 2 | 2 | import { ContextProviderDescription } from "core"; |
| 3 | 3 | import { Mention } from "../extensions"; |
| 4 | 4 | |
| 5 | +function isEditorContentEmpty(editor: Editor): boolean { | |
| 6 | + const editorContent = editor.getJSON(); | |
| 7 | + | |
| 8 | + if (!editorContent.content || editorContent.content.length === 0) { | |
| 9 | + return true; | |
| 10 | + } | |
| 11 | + | |
| 12 | + const firstNode = editorContent.content[0]; | |
| 13 | + if ( | |
| 14 | + firstNode.type === "paragraph" && | |
| 15 | + (firstNode.content || []).length === 0 | |
| 16 | + ) { | |
| 17 | + return true; | |
| 18 | + } | |
| 19 | + | |
| 20 | + return false; | |
| 21 | +} | |
| 22 | + | |
| 5 | 23 | /** |
| 6 | 24 | * inserts the current file context as a removable mention in the editor area |
| 7 | 25 | * |
| 26 | + * skips if there is any other content in the editor | |
| 27 | + * | |
| 8 | 28 | * uses tiptap's `create` method to create a new node under the hood |
| 9 | 29 | */ |
| 10 | 30 | export function insertCurrentFileContextMention( |
| 11 | 31 | editor: Editor, |
| 12 | 32 | contextProviders: ContextProviderDescription[], |
| 13 | 33 | ) { |
| 34 | + if (!isEditorContentEmpty(editor)) { | |
| 35 | + return; | |
| 36 | + } | |
| 37 | + | |
| 14 | 38 | const foundCurrentFileProvider = contextProviders.find( |
| 15 | 39 | (provider) => provider.title === "currentFile", |
| 16 | 40 | ); |