mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-19 07:54:46 +00:00
refactor: remove ProxyAI Docs support
This commit is contained in:
parent
37960489e4
commit
7cee32a080
19 changed files with 5 additions and 513 deletions
|
|
@ -3,7 +3,6 @@ package ee.carlrobert.codegpt.conversations.message;
|
|||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import ee.carlrobert.codegpt.ui.DocumentationDetails;
|
||||
import ee.carlrobert.llm.client.openai.completion.response.ToolCall;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -22,7 +21,6 @@ public class Message {
|
|||
private List<UUID> conversationsHistoryIds;
|
||||
private String imageFilePath;
|
||||
private boolean webSearchIncluded;
|
||||
private DocumentationDetails documentationDetails;
|
||||
private String personaName;
|
||||
private List<ToolCall> toolCalls;
|
||||
private Map<String, String> toolCallResults;
|
||||
|
|
@ -94,14 +92,6 @@ public class Message {
|
|||
this.webSearchIncluded = webSearchIncluded;
|
||||
}
|
||||
|
||||
public @Nullable DocumentationDetails getDocumentationDetails() {
|
||||
return documentationDetails;
|
||||
}
|
||||
|
||||
public void setDocumentationDetails(DocumentationDetails documentationDetails) {
|
||||
this.documentationDetails = documentationDetails;
|
||||
}
|
||||
|
||||
public @Nullable String getPersonaName() {
|
||||
return personaName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ import com.intellij.ui.JBColor;
|
|||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import ee.carlrobert.codegpt.CodeGPTKeys;
|
||||
import ee.carlrobert.codegpt.CodeGPTBundle;
|
||||
import ee.carlrobert.codegpt.CodeGPTKeys;
|
||||
import ee.carlrobert.codegpt.EncodingManager;
|
||||
import ee.carlrobert.codegpt.ReferencedFile;
|
||||
import ee.carlrobert.codegpt.actions.ActionType;
|
||||
|
|
@ -101,7 +101,7 @@ public class ChatToolWindowTabPanel implements Disposable {
|
|||
private final TagManager tagManager;
|
||||
private final JPanel mcpApprovalContainer;
|
||||
private @Nullable ToolwindowChatCompletionRequestHandler requestHandler;
|
||||
private JBLabel loadingLabel;
|
||||
private final JBLabel loadingLabel;
|
||||
private final JPanel queuedMessageContainer;
|
||||
|
||||
public ChatToolWindowTabPanel(@NotNull Project project, @NotNull Conversation conversation) {
|
||||
|
|
@ -465,7 +465,7 @@ public class ChatToolWindowTabPanel implements Disposable {
|
|||
false,
|
||||
false,
|
||||
message.isWebSearchIncluded(),
|
||||
fileContextIncluded || message.getDocumentationDetails() != null,
|
||||
fileContextIncluded,
|
||||
false,
|
||||
this));
|
||||
return panel;
|
||||
|
|
@ -568,6 +568,7 @@ public class ChatToolWindowTabPanel implements Disposable {
|
|||
hideInputLoading();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTokensExceededPolicyAccepted() {
|
||||
call(callParameters, responseMessagePanel, userMessagePanel);
|
||||
|
|
|
|||
|
|
@ -223,7 +223,6 @@ class PsiStructureRepository(
|
|||
|
||||
is HistoryTagDetails -> null
|
||||
is EditorSelectionTagDetails -> null
|
||||
is DocumentationTagDetails -> null
|
||||
is CurrentGitChangesTagDetails -> null
|
||||
is GitCommitTagDetails -> null
|
||||
is PersonaTagDetails -> null
|
||||
|
|
@ -252,7 +251,6 @@ class PsiStructureRepository(
|
|||
is FolderTagDetails -> false
|
||||
|
||||
is HistoryTagDetails -> false
|
||||
is DocumentationTagDetails -> false
|
||||
is CurrentGitChangesTagDetails -> false
|
||||
is GitCommitTagDetails -> false
|
||||
is PersonaTagDetails -> false
|
||||
|
|
@ -281,7 +279,6 @@ class PsiStructureRepository(
|
|||
is FolderTagDetails -> null
|
||||
|
||||
is HistoryTagDetails -> null
|
||||
is DocumentationTagDetails -> null
|
||||
is CurrentGitChangesTagDetails -> null
|
||||
is GitCommitTagDetails -> null
|
||||
is PersonaTagDetails -> null
|
||||
|
|
|
|||
|
|
@ -137,13 +137,6 @@ class PromptEnhancer(private val project: Project) {
|
|||
builder.append("- ").append(path).append("\n")
|
||||
}
|
||||
}
|
||||
message.documentationDetails?.let { details ->
|
||||
builder.append("\nDocumentation:\n")
|
||||
.append(details.name)
|
||||
.append(" (")
|
||||
.append(details.url)
|
||||
.append(")\n")
|
||||
}
|
||||
message.personaName?.takeIf { it.isNotBlank() }?.let { persona ->
|
||||
builder.append("\nPersona:\n").append(persona).append("\n")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,9 +61,6 @@ class CodeGPTRequestFactory(private val classStructureSerializer: ClassStructure
|
|||
if (params.message.isWebSearchIncluded) {
|
||||
requestBuilder.setWebSearchIncluded(true)
|
||||
}
|
||||
params.message.documentationDetails?.let {
|
||||
requestBuilder.setDocumentationDetails(DocumentationDetails(it.name, it.url))
|
||||
}
|
||||
|
||||
val contextFiles = params.referencedFiles
|
||||
?.mapNotNull { file ->
|
||||
|
|
|
|||
|
|
@ -463,7 +463,6 @@ class InlineEditSearchReplaceListener(
|
|||
copy.referencedFilePaths = original.referencedFilePaths
|
||||
copy.conversationsHistoryIds = original.conversationsHistoryIds
|
||||
copy.imageFilePath = original.imageFilePath
|
||||
copy.documentationDetails = original.documentationDetails
|
||||
copy.personaName = original.personaName
|
||||
newConversation.addMessage(copy)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
package ee.carlrobert.codegpt.settings.documentation
|
||||
|
||||
import com.intellij.openapi.components.*
|
||||
import java.time.Instant
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
@Service
|
||||
@State(
|
||||
name = "CodeGPT_DocumentationSettings",
|
||||
storages = [Storage("CodeGPT_DocumentationSettings.xml")]
|
||||
)
|
||||
class DocumentationSettings :
|
||||
SimplePersistentStateComponent<DocumentationSettingsState>(DocumentationSettingsState()) {
|
||||
|
||||
fun updateLastUsedDateTime(url: String) {
|
||||
state.documentations
|
||||
.find { it.url == url }
|
||||
?.run {
|
||||
lastUsedDateTime = DateTimeFormatter.ISO_INSTANT.format(Instant.now())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DocumentationSettingsState : BaseState() {
|
||||
var documentations by list<DocumentationDetailsState>()
|
||||
|
||||
init {
|
||||
documentations.addAll(DEFAULT_DOCUMENTATIONS)
|
||||
}
|
||||
}
|
||||
|
||||
class DocumentationDetailsState : BaseState() {
|
||||
var name by string("ProxyAI Docs")
|
||||
var url by string("https://docs.tryproxy.io")
|
||||
var lastUsedDateTime by string()
|
||||
}
|
||||
|
||||
private val DEFAULT_DOCUMENTATIONS = mutableListOf(
|
||||
getDocState("Spring Framework API", "https://docs.spring.io/spring-framework/docs/current/javadoc-api/"),
|
||||
getDocState("Astro Runtime API", "https://docs.astro.build/en/reference/api-reference/"),
|
||||
getDocState("Flask API", "https://flask.palletsprojects.com/en/3.0.x/api/"),
|
||||
getDocState("Flutter API", "https://api.flutter.dev/"),
|
||||
getDocState("IPFS Kubo CLI", "https://docs.ipfs.tech/reference/kubo/cli/#ipfs"),
|
||||
getDocState("Kotlin Coding Conventions", "https://kotlinlang.org/docs/coding-conventions.html"),
|
||||
getDocState(
|
||||
"Next.js Authentication",
|
||||
"https://nextjs.org/docs/app/building-your-application/authentication"
|
||||
),
|
||||
getDocState("SolidJS Documentation", "https://www.solidjs.com/docs"),
|
||||
getDocState("SvelteKit Modules", "https://kit.svelte.dev/docs/modules"),
|
||||
getDocState("SwiftUI Updates", "https://developer.apple.com/documentation/updates/swiftui"),
|
||||
getDocState("Zapier CLI Documentation", "https://platform.zapier.com/reference/cli-docs"),
|
||||
)
|
||||
|
||||
private fun getDocState(name: String, url: String): DocumentationDetailsState {
|
||||
return DocumentationDetailsState().apply {
|
||||
this.name = name
|
||||
this.url = url
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
package ee.carlrobert.codegpt.settings.documentation
|
||||
|
||||
import com.intellij.openapi.options.Configurable
|
||||
import javax.swing.JComponent
|
||||
|
||||
class DocumentationsConfigurable : Configurable {
|
||||
|
||||
private lateinit var component: DocumentationsSettingsForm
|
||||
|
||||
override fun getDisplayName(): String {
|
||||
return "ProxyAI: Documentations"
|
||||
}
|
||||
|
||||
override fun createComponent(): JComponent {
|
||||
component = DocumentationsSettingsForm()
|
||||
return component.createPanel()
|
||||
}
|
||||
|
||||
override fun isModified(): Boolean = component.isModified()
|
||||
|
||||
override fun apply() {
|
||||
component.applyChanges()
|
||||
}
|
||||
|
||||
override fun reset() {
|
||||
component.resetChanges()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
package ee.carlrobert.codegpt.settings.documentation
|
||||
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.ui.DialogPanel
|
||||
import com.intellij.ui.ToolbarDecorator
|
||||
import com.intellij.ui.dsl.builder.Align
|
||||
import com.intellij.ui.dsl.builder.panel
|
||||
import com.intellij.ui.table.JBTable
|
||||
import ee.carlrobert.codegpt.CodeGPTBundle
|
||||
import java.awt.Dimension
|
||||
import javax.swing.table.DefaultTableModel
|
||||
|
||||
class DocumentationsSettingsForm {
|
||||
|
||||
private val tableModel = DefaultTableModel(arrayOf("Name", "URL"), 0)
|
||||
private val table = JBTable(tableModel).apply {
|
||||
setupTableColumns()
|
||||
}
|
||||
private val documentationSettings = service<DocumentationSettings>()
|
||||
private var originalDocumentations: List<DocumentationDetailsState> = emptyList()
|
||||
|
||||
init {
|
||||
setupForm()
|
||||
}
|
||||
|
||||
fun createPanel(): DialogPanel {
|
||||
return panel {
|
||||
row {
|
||||
val toolbarDecorator = ToolbarDecorator.createDecorator(table)
|
||||
.setAddAction { handleAddItem() }
|
||||
.setRemoveAction { handleRemoveItem() }
|
||||
.addExtraAction(object :
|
||||
AnAction("Duplicate", "Duplicate documentation", AllIcons.Actions.Copy) {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
handleDuplicateItem()
|
||||
}
|
||||
})
|
||||
.disableUpDownActions()
|
||||
|
||||
cell(toolbarDecorator.createPanel())
|
||||
.align(Align.FILL)
|
||||
.resizableColumn()
|
||||
.applyToComponent {
|
||||
preferredSize = Dimension(600, 400)
|
||||
}
|
||||
}
|
||||
row {
|
||||
text(CodeGPTBundle.get("settingsConfigurable.documentations.description"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun applyChanges() {
|
||||
val newDocumentations = (0 until tableModel.rowCount).map { row ->
|
||||
DocumentationDetailsState().apply {
|
||||
name = tableModel.getValueAt(row, 0) as String
|
||||
url = tableModel.getValueAt(row, 1) as String
|
||||
}
|
||||
}
|
||||
documentationSettings.state.documentations.clear()
|
||||
documentationSettings.state.documentations.addAll(newDocumentations)
|
||||
originalDocumentations = newDocumentations
|
||||
}
|
||||
|
||||
fun isModified(): Boolean {
|
||||
val currentDocumentations = (0 until tableModel.rowCount).map { row ->
|
||||
DocumentationDetailsState().apply {
|
||||
name = tableModel.getValueAt(row, 0) as String
|
||||
url = tableModel.getValueAt(row, 1) as String
|
||||
}
|
||||
}
|
||||
return currentDocumentations != originalDocumentations
|
||||
}
|
||||
|
||||
fun resetChanges() {
|
||||
tableModel.rowCount = 0
|
||||
setupForm()
|
||||
}
|
||||
|
||||
private fun handleAddItem() {
|
||||
addDocumentationToTable(DocumentationDetailsState().apply {
|
||||
name = "New Documentation"
|
||||
url = "https://example.com"
|
||||
})
|
||||
}
|
||||
|
||||
private fun handleDuplicateItem() {
|
||||
val selectedRow = table.selectedRow
|
||||
if (selectedRow != -1) {
|
||||
val originalName = tableModel.getValueAt(selectedRow, 0) as String
|
||||
val originalUrl = tableModel.getValueAt(selectedRow, 1) as String
|
||||
addDocumentationToTable(DocumentationDetailsState().apply {
|
||||
name = "$originalName Copy"
|
||||
url = originalUrl
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun addDocumentationToTable(doc: DocumentationDetailsState) {
|
||||
tableModel.addRow(arrayOf(doc.name, doc.url))
|
||||
selectLastRowAndUpdateUI()
|
||||
}
|
||||
|
||||
private fun selectLastRowAndUpdateUI() {
|
||||
val lastRow = table.rowCount - 1
|
||||
table.setRowSelectionInterval(lastRow, lastRow)
|
||||
scrollToLastRow()
|
||||
}
|
||||
|
||||
private fun handleRemoveItem() {
|
||||
val selectedRow = table.selectedRow
|
||||
if (selectedRow != -1) {
|
||||
tableModel.removeRow(selectedRow)
|
||||
|
||||
val newSelectedRow = if (selectedRow > 0) selectedRow - 1 else 0
|
||||
if (table.rowCount > 0) {
|
||||
table.setRowSelectionInterval(newSelectedRow, newSelectedRow)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupForm() {
|
||||
originalDocumentations = documentationSettings.state.documentations.toList()
|
||||
originalDocumentations.forEach { doc ->
|
||||
tableModel.addRow(arrayOf(doc.name, doc.url))
|
||||
}
|
||||
}
|
||||
|
||||
private fun scrollToLastRow() {
|
||||
table.scrollRectToVisible(table.getCellRect(table.rowCount - 1, 0, true))
|
||||
}
|
||||
|
||||
private fun JBTable.setupTableColumns() {
|
||||
columnModel.apply {
|
||||
getColumn(0).preferredWidth = 200
|
||||
getColumn(1).preferredWidth = 400
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,6 @@ import com.intellij.util.ui.components.BorderLayoutPanel
|
|||
import ee.carlrobert.codegpt.CodeGPTBundle
|
||||
import ee.carlrobert.codegpt.Icons
|
||||
import ee.carlrobert.codegpt.conversations.message.Message
|
||||
import ee.carlrobert.codegpt.events.WebSearchEventDetails
|
||||
import ee.carlrobert.codegpt.settings.GeneralSettings
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.ChatToolWindowContentManager
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.ui.ChatMessageResponseBody
|
||||
|
|
@ -137,9 +136,8 @@ class UserMessagePanel(
|
|||
}
|
||||
|
||||
private fun getAdditionalContextPanel(project: Project, message: Message): JPanel? {
|
||||
val documentationDetails = message.documentationDetails
|
||||
val referencedFilePaths = message.referencedFilePaths ?: emptyList()
|
||||
if (documentationDetails == null && referencedFilePaths.isEmpty() && message.personaName.isNullOrEmpty()) {
|
||||
if (referencedFilePaths.isEmpty() && message.personaName.isNullOrEmpty()) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
@ -164,18 +162,6 @@ class UserMessagePanel(
|
|||
)
|
||||
}
|
||||
|
||||
documentationDetails?.let {
|
||||
val listModel = DefaultListModel<WebSearchEventDetails>().apply {
|
||||
addElement(WebSearchEventDetails(UUID.randomUUID(), it.name, it.url, it.url))
|
||||
}
|
||||
additionalContextPanel.add(
|
||||
createAdditionalContextPanel(
|
||||
CodeGPTBundle.get("userMessagePanel.documentation.title"),
|
||||
WebpageList(listModel)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
message.conversationsHistoryIds?.let { ids ->
|
||||
additionalContextPanel.add(JPanel().apply {
|
||||
layout = BoxLayout(this, BoxLayout.Y_AXIS)
|
||||
|
|
|
|||
|
|
@ -1,72 +0,0 @@
|
|||
package ee.carlrobert.codegpt.ui
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.ui.components.JBCheckBox
|
||||
import com.intellij.ui.components.JBTextField
|
||||
import com.intellij.ui.dsl.builder.LabelPosition
|
||||
import com.intellij.ui.dsl.builder.TopGap
|
||||
import com.intellij.ui.dsl.builder.panel
|
||||
import ee.carlrobert.codegpt.CodeGPTBundle
|
||||
import ee.carlrobert.codegpt.settings.documentation.DocumentationDetailsState
|
||||
import ee.carlrobert.codegpt.settings.documentation.DocumentationSettings
|
||||
import javax.swing.JComponent
|
||||
|
||||
class AddDocumentationDialog(project: Project) : DialogWrapper(project) {
|
||||
|
||||
private var nameField = JBTextField("", 40).apply {
|
||||
emptyText.text = "ProxyAI docs"
|
||||
}
|
||||
private var urlField = JBTextField("", 40).apply {
|
||||
emptyText.text = "https://docs.tryproxy.io"
|
||||
}
|
||||
private var saveCheckbox =
|
||||
JBCheckBox(CodeGPTBundle.get("addDocumentation.popup.form.saveCheckbox.label"), true)
|
||||
|
||||
val documentationDetails: DocumentationDetails
|
||||
get() = DocumentationDetails(nameField.text, urlField.text)
|
||||
|
||||
init {
|
||||
title = CodeGPTBundle.get("addDocumentation.popup.title")
|
||||
init()
|
||||
}
|
||||
|
||||
override fun createCenterPanel(): JComponent = panel {
|
||||
row {
|
||||
cell(nameField)
|
||||
.label(
|
||||
CodeGPTBundle.get("addDocumentation.popup.form.name.label"),
|
||||
LabelPosition.TOP
|
||||
)
|
||||
.focused()
|
||||
}
|
||||
row {
|
||||
cell(urlField)
|
||||
.label(
|
||||
CodeGPTBundle.get("addDocumentation.popup.form.url.label"),
|
||||
LabelPosition.TOP
|
||||
)
|
||||
}.rowComment(CodeGPTBundle.get("addDocumentation.popup.form.url.comment"))
|
||||
row { cell(saveCheckbox) }.topGap(TopGap.SMALL)
|
||||
}
|
||||
|
||||
override fun doOKAction() {
|
||||
if (saveCheckbox.isSelected) {
|
||||
service<DocumentationSettings>().state.documentations.add(DocumentationDetailsState().apply {
|
||||
url = urlField.text
|
||||
name = nameField.text
|
||||
})
|
||||
}
|
||||
|
||||
super.doOKAction()
|
||||
}
|
||||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class DocumentationDetails(
|
||||
@JsonProperty(value = "name") var name: String,
|
||||
@JsonProperty(value = "url") var url: String
|
||||
)
|
||||
|
|
@ -57,7 +57,6 @@ class SearchManager(
|
|||
GitGroupItem(project),
|
||||
HistoryGroupItem(),
|
||||
PersonasGroupItem(tagManager),
|
||||
DocsGroupItem(tagManager),
|
||||
MCPGroupItem(tagManager, featureType ?: FeatureType.CHAT),
|
||||
DiagnosticsActionItem(tagManager),
|
||||
WebActionItem(tagManager),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ internal class TagDetailsComparator : Comparator<TagDetails> {
|
|||
is EditorSelectionTagDetails -> 0
|
||||
|
||||
is SelectionTagDetails -> 5
|
||||
is DocumentationTagDetails,
|
||||
is PersonaTagDetails,
|
||||
is GitCommitTagDetails,
|
||||
is CurrentGitChangesTagDetails,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ object TagProcessorFactory {
|
|||
is SelectionTagDetails -> SelectionTagProcessor(project, tagDetails)
|
||||
is EditorSelectionTagDetails -> EditorSelectionTagProcessor(project, tagDetails)
|
||||
is HistoryTagDetails -> ConversationTagProcessor(tagDetails)
|
||||
is DocumentationTagDetails -> DocumentationTagProcessor(tagDetails)
|
||||
is PersonaTagDetails -> PersonaTagProcessor(tagDetails)
|
||||
is FolderTagDetails -> FolderTagProcessor(project, tagDetails)
|
||||
is WebTagDetails -> WebTagProcessor()
|
||||
|
|
@ -118,14 +117,6 @@ class EditorSelectionTagProcessor(
|
|||
}
|
||||
}
|
||||
|
||||
class DocumentationTagProcessor(
|
||||
private val tagDetails: DocumentationTagDetails,
|
||||
) : TagProcessor {
|
||||
override fun process(message: Message, promptBuilder: StringBuilder) {
|
||||
message.documentationDetails = tagDetails.documentationDetails
|
||||
}
|
||||
}
|
||||
|
||||
class PersonaTagProcessor(
|
||||
private val tagDetails: PersonaTagDetails,
|
||||
) : TagProcessor {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import ee.carlrobert.codegpt.mcp.ConnectionStatus
|
|||
import ee.carlrobert.codegpt.mcp.McpResource
|
||||
import ee.carlrobert.codegpt.mcp.McpTool
|
||||
import ee.carlrobert.codegpt.settings.prompts.PersonaDetails
|
||||
import ee.carlrobert.codegpt.ui.DocumentationDetails
|
||||
import git4idea.GitCommit
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.Serializable
|
||||
|
|
@ -127,11 +126,6 @@ class EditorSelectionTagDetails(
|
|||
}
|
||||
}
|
||||
|
||||
data class DocumentationTagDetails(var documentationDetails: DocumentationDetails) :
|
||||
TagDetails(documentationDetails.name, AllIcons.Toolwindows.Documentation) {
|
||||
override fun getTooltipText(): String = documentationDetails.url
|
||||
}
|
||||
|
||||
data class PersonaTagDetails(var personaDetails: PersonaDetails) :
|
||||
TagDetails(personaDetails.name, AllIcons.General.User) {
|
||||
override fun getTooltipText(): String? = null
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
package ee.carlrobert.codegpt.ui.textarea.lookup.action.docs
|
||||
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
import ee.carlrobert.codegpt.CodeGPTBundle
|
||||
import ee.carlrobert.codegpt.settings.documentation.DocumentationSettings
|
||||
import ee.carlrobert.codegpt.settings.service.FeatureType
|
||||
import ee.carlrobert.codegpt.settings.service.ModelSelectionService
|
||||
import ee.carlrobert.codegpt.settings.service.ServiceType
|
||||
import ee.carlrobert.codegpt.ui.AddDocumentationDialog
|
||||
import ee.carlrobert.codegpt.ui.textarea.UserInputPanel
|
||||
import ee.carlrobert.codegpt.ui.textarea.header.tag.DocumentationTagDetails
|
||||
import ee.carlrobert.codegpt.ui.textarea.lookup.action.AbstractLookupActionItem
|
||||
|
||||
class AddDocActionItem : AbstractLookupActionItem() {
|
||||
|
||||
override val displayName: String =
|
||||
CodeGPTBundle.get("suggestionActionItem.createDocumentation.displayName")
|
||||
override val icon = AllIcons.General.Add
|
||||
override val enabled = ModelSelectionService.getInstance().getServiceForFeature(FeatureType.CHAT) == ServiceType.PROXYAI
|
||||
|
||||
override fun execute(project: Project, userInputPanel: UserInputPanel) {
|
||||
val addDocumentationDialog = AddDocumentationDialog(project)
|
||||
if (addDocumentationDialog.showAndGet()) {
|
||||
service<DocumentationSettings>()
|
||||
.updateLastUsedDateTime(addDocumentationDialog.documentationDetails.url)
|
||||
userInputPanel.addTag(DocumentationTagDetails(addDocumentationDialog.documentationDetails))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package ee.carlrobert.codegpt.ui.textarea.lookup.action.docs
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
import ee.carlrobert.codegpt.settings.documentation.DocumentationSettings
|
||||
import ee.carlrobert.codegpt.settings.service.FeatureType
|
||||
import ee.carlrobert.codegpt.settings.service.ModelSelectionService
|
||||
import ee.carlrobert.codegpt.settings.service.ServiceType
|
||||
import ee.carlrobert.codegpt.ui.DocumentationDetails
|
||||
import ee.carlrobert.codegpt.ui.textarea.UserInputPanel
|
||||
import ee.carlrobert.codegpt.ui.textarea.header.tag.DocumentationTagDetails
|
||||
import ee.carlrobert.codegpt.ui.textarea.lookup.action.AbstractLookupActionItem
|
||||
|
||||
class DocActionItem(
|
||||
private val documentationDetails: DocumentationDetails
|
||||
) : AbstractLookupActionItem() {
|
||||
|
||||
override val displayName = documentationDetails.name
|
||||
override val icon = AllIcons.Toolwindows.Documentation
|
||||
override val enabled = ModelSelectionService.getInstance().getServiceForFeature(FeatureType.CHAT) == ServiceType.PROXYAI
|
||||
|
||||
override fun setPresentation(element: LookupElement, presentation: LookupElementPresentation) {
|
||||
super.setPresentation(element, presentation)
|
||||
|
||||
presentation.typeText = documentationDetails.url
|
||||
presentation.isTypeGrayed = true
|
||||
}
|
||||
|
||||
override fun execute(project: Project, userInputPanel: UserInputPanel) {
|
||||
service<DocumentationSettings>().updateLastUsedDateTime(documentationDetails.url)
|
||||
userInputPanel.addTag(DocumentationTagDetails(documentationDetails))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
package ee.carlrobert.codegpt.ui.textarea.lookup.action.docs
|
||||
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.options.ShowSettingsUtil
|
||||
import com.intellij.openapi.project.Project
|
||||
import ee.carlrobert.codegpt.CodeGPTBundle
|
||||
import ee.carlrobert.codegpt.settings.documentation.DocumentationsConfigurable
|
||||
import ee.carlrobert.codegpt.settings.service.FeatureType
|
||||
import ee.carlrobert.codegpt.settings.service.ModelSelectionService
|
||||
import ee.carlrobert.codegpt.settings.service.ServiceType
|
||||
import ee.carlrobert.codegpt.ui.textarea.UserInputPanel
|
||||
import ee.carlrobert.codegpt.ui.textarea.lookup.action.AbstractLookupActionItem
|
||||
|
||||
class ViewAllDocsActionItem : AbstractLookupActionItem() {
|
||||
|
||||
override val displayName: String =
|
||||
"${CodeGPTBundle.get("suggestionActionItem.viewDocumentations.displayName")} →"
|
||||
override val icon = null
|
||||
override val enabled = ModelSelectionService.getInstance().getServiceForFeature(FeatureType.CHAT) == ServiceType.PROXYAI
|
||||
|
||||
override fun execute(project: Project, userInputPanel: UserInputPanel) {
|
||||
service<ShowSettingsUtil>().showSettingsDialog(
|
||||
project,
|
||||
DocumentationsConfigurable::class.java
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
package ee.carlrobert.codegpt.ui.textarea.lookup.group
|
||||
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.openapi.components.service
|
||||
import ee.carlrobert.codegpt.CodeGPTBundle
|
||||
import ee.carlrobert.codegpt.settings.documentation.DocumentationSettings
|
||||
import ee.carlrobert.codegpt.settings.service.FeatureType
|
||||
import ee.carlrobert.codegpt.settings.service.ModelSelectionService
|
||||
import ee.carlrobert.codegpt.settings.service.ServiceType
|
||||
import ee.carlrobert.codegpt.ui.DocumentationDetails
|
||||
import ee.carlrobert.codegpt.ui.textarea.header.tag.DocumentationTagDetails
|
||||
import ee.carlrobert.codegpt.ui.textarea.header.tag.TagManager
|
||||
import ee.carlrobert.codegpt.ui.textarea.lookup.LookupActionItem
|
||||
import ee.carlrobert.codegpt.ui.textarea.lookup.action.docs.AddDocActionItem
|
||||
import ee.carlrobert.codegpt.ui.textarea.lookup.action.docs.DocActionItem
|
||||
import ee.carlrobert.codegpt.ui.textarea.lookup.action.docs.ViewAllDocsActionItem
|
||||
import java.time.Instant
|
||||
import java.time.format.DateTimeParseException
|
||||
|
||||
class DocsGroupItem(
|
||||
private val tagManager: TagManager
|
||||
) : AbstractLookupGroupItem() {
|
||||
|
||||
override val displayName: String = CodeGPTBundle.get("suggestionGroupItem.docs.displayName")
|
||||
override val icon = AllIcons.Toolwindows.Documentation
|
||||
override val enabled: Boolean
|
||||
get() = enabled()
|
||||
|
||||
fun enabled(): Boolean {
|
||||
if (ModelSelectionService.getInstance().getServiceForFeature(FeatureType.CHAT) != ServiceType.PROXYAI) {
|
||||
return false
|
||||
}
|
||||
|
||||
return tagManager.getTags().none { it is DocumentationTagDetails }
|
||||
}
|
||||
|
||||
override suspend fun getLookupItems(searchText: String): List<LookupActionItem> =
|
||||
listOf(AddDocActionItem(), ViewAllDocsActionItem()) +
|
||||
service<DocumentationSettings>().state.documentations
|
||||
.sortedByDescending { parseDateTime(it.lastUsedDateTime) }
|
||||
.filter {
|
||||
searchText.isEmpty() || (it.name?.contains(searchText, true) ?: false)
|
||||
}
|
||||
.take(10)
|
||||
.map {
|
||||
DocActionItem(DocumentationDetails(it.name ?: "", it.url ?: ""))
|
||||
}
|
||||
|
||||
private fun parseDateTime(dateTimeString: String?): Instant {
|
||||
return dateTimeString?.let {
|
||||
try {
|
||||
Instant.parse(it)
|
||||
} catch (e: DateTimeParseException) {
|
||||
Instant.EPOCH
|
||||
}
|
||||
} ?: Instant.EPOCH
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue