Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Cody invitation to include handy shortcuts #1918

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/kotlin/com/sourcegraph/cody/chat/ui/MessagesPanel.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sourcegraph.cody.chat.ui

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.keymap.KeymapUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.VerticalFlowLayout
import com.intellij.util.concurrency.annotations.RequiresEdt
Expand All @@ -16,7 +17,14 @@ class MessagesPanel(private val project: Project, private val chatSession: ChatS
JPanel(VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true)) {
init {
val welcomeText = CodyBundle.getString("messages-panel.welcome-text")
addChatMessageAsComponent(ChatMessage(Speaker.ASSISTANT, welcomeText))
val regex = Regex("\\{action\\.([^}]+)}")
val matches = regex.findAll(welcomeText)
val shortcutKeys = matches.map { it.groups[1]?.value ?: "" }.toList()
val finalWelcomeText =
shortcutKeys.fold(welcomeText) { acc, shortcutKey ->
acc.replace("{action.$shortcutKey}", KeymapUtil.getShortcutText(shortcutKey))
}
addChatMessageAsComponent(ChatMessage(Speaker.ASSISTANT, finalWelcomeText))
}

@RequiresEdt
Expand Down
32 changes: 31 additions & 1 deletion src/main/resources/CodyBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,37 @@ context-panel.tree.help-tooltip.title=About chat context
context-panel.tree.help-tooltip.description=Select up to {0} repositories to use as reference context in this chat.
context-panel.tree.help-tooltip.link.text=Context documentation
context-panel.tree.help-tooltip.link.href=https://sourcegraph.com/docs/cody/core-concepts/context
messages-panel.welcome-text=Hello! I'm Cody. I can write code and answer questions for you. See [Cody documentation](https://sourcegraph.com/docs/cody) for help and tips.
messages-panel.welcome-text=<html>\
<p>Cody is here to help you write, fix, and maintain your code more efficiently.</p>\
<br>\
<p>Here are some handy keyboard shortcuts:</p>\
<table>\
<tr>\
<td></td>\
<td>\
<b>{action.cody.triggerAutocomplete}</b><br/>\
<b>{action.cody.editCodeAction}</b><br/>\
<b>{action.cody.documentCodeAction}</b><br/>\
<b>{action.cody.testCodeAction}</b><br/>\
<b>{action.cody.newChat}</b>\
</td>\
<td>\
: Force an Autocompletion<br/>\
: Edit/Write Code<br/>\
: Generate Documentation<br/>\
: Generate Tests<br/>\
: New chat\
</td>\
</tr>\
</table>\
<table>\
<tr>\
<td><a href="https://sourcegraph.com/docs/cody">Documentation</a>&nbsp;&nbsp;&nbsp;|&nbsp;</td>\
<td><a href="https://discord.com/servers/sourcegraph-969688426372825169">Community</a>&nbsp;&nbsp;&nbsp;|&nbsp;</td>\
<td><a href="https://community.sourcegraph.com/c/cody/5">Support Forum</a></td>\
</tr>\
</table>\
</html>
EndOfTrialNotification.link-action-name=Setup Payment Info
EndOfTrialNotification.do-not-show-again=Don't show again
TrialEndedNotification.ignore=cody.ignore.notification.trial-ended
Expand Down
Loading