Skip to content

Commit 5fc6656

Browse files
authored
Merge pull request #724 from devoxx/feat-723
Feat #723 Show msg when default file is included in context
2 parents aad6d3f + 15291f7 commit 5fc6656

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

src/main/java/com/devoxx/genie/ui/webview/handler/WebViewFileReferenceManager.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.devoxx.genie.ui.webview.handler;
22

33
import com.devoxx.genie.model.request.ChatMessageContext;
4+
import com.devoxx.genie.ui.settings.DevoxxGenieStateService;
45
import com.devoxx.genie.ui.util.ThemeDetector;
56
import com.devoxx.genie.ui.webview.template.ResourceLoader;
67
import com.intellij.openapi.vfs.VirtualFile;
@@ -51,8 +52,18 @@ public void addFileReferences(ChatMessageContext chatMessageContext, List<Virtua
5152
.append(" </div>\n");
5253

5354
// Add the file list container (initially collapsed)
54-
fileReferencesHtml.append(" <div class=\"file-references-content\" style=\"display: none;\">\n")
55-
.append(" <ul class=\"file-list\">\n");
55+
fileReferencesHtml.append(" <div class=\"file-references-content\" style=\"display: none;\">\n");
56+
57+
// Add info message about including currently open file if the setting is enabled
58+
if (Boolean.TRUE.equals(DevoxxGenieStateService.getInstance().getUseFileInEditor())) {
59+
fileReferencesHtml.append(" <div class=\"file-references-info\">\n")
60+
.append(" <span class=\"info-icon\">ℹ️</span>\n")
61+
.append(" <span class=\"info-text\">The currently open file in the editor is automatically included in the context. ")
62+
.append("You can disable this in Settings → LLM Settings.</span>\n")
63+
.append(" </div>\n");
64+
}
65+
66+
fileReferencesHtml.append(" <ul class=\"file-list\">\n");
5667

5768
// Add each file as a list item - make items clickable with data attributes to store path
5869
for (int i = 0; i < files.size(); i++) {

src/main/java/com/devoxx/genie/util/ChatMessageContextUtil.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,14 @@ private static void addDefaultEditorInfoToMessageContext(Editor editor,
141141
originalFile.putUserData(SELECTION_END_KEY, endOffset);
142142
originalFile.putUserData(SELECTION_START_LINE_KEY, startLine);
143143
originalFile.putUserData(SELECTION_END_LINE_KEY, endLine);
144-
FileListManager.getInstance().addFile(chatMessageContext.getProject(), editor.getVirtualFile());
144+
// When text is selected, always add the file to FileListManager
145+
FileListManager.getInstance().addFile(chatMessageContext.getProject(), originalFile);
145146
} else {
146147
originalFile.putUserData(SELECTED_TEXT_KEY, "");
148+
// When no text is selected, only add file if useFileInEditor is enabled
149+
if (originalFile != null && Boolean.TRUE.equals(DevoxxGenieStateService.getInstance().getUseFileInEditor())) {
150+
FileListManager.getInstance().addFile(chatMessageContext.getProject(), originalFile);
151+
}
147152
}
148153

149154
}

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<LI>Feat #700: Conversation history returns full conversation</LI>
4545
<LI>Fix #685: Open browser when links are clicked in conversation webview</LI>
4646
<LI>Fix #705: Removed obsolete GitDiff/Merge replaced by MCP</LI>
47+
<LI>Feat #723: Show msg when default file is included in context</LI>
4748
</UL>
4849
<h2>v0.6.6</h2>
4950
<UL>

src/main/resources/webview/js/file-references.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function openFile(fileId) {
1010
}
1111
}
1212

13+
1314
/**
1415
* Toggles the visibility of file references section
1516
* @param {HTMLElement} header - The header element that was clicked
@@ -107,6 +108,23 @@ function addFileReferencesStyles(isDarkTheme) {
107108
font-style: italic;
108109
font-size: 0.9em;
109110
}
111+
.file-references-info {
112+
display: flex;
113+
align-items: flex-start;
114+
padding: 8px;
115+
margin-bottom: 10px;
116+
background-color: var(--info-bg-color, rgba(33, 150, 243, 0.1));
117+
border-radius: 4px;
118+
border: 1px solid var(--info-border-color, rgba(33, 150, 243, 0.3));
119+
}
120+
.info-icon {
121+
margin-right: 8px;
122+
flex-shrink: 0;
123+
}
124+
.info-text {
125+
font-size: 0.9em;
126+
line-height: 1.4;
127+
}
110128
`;
111129

112130
document.head.appendChild(styleEl);

0 commit comments

Comments
 (0)