-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Add MCP button to ChatTextArea with error indicator #7507
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||||||||||||||||||||||
| import React, { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react" | ||||||||||||||||||||||||||
| import { useEvent } from "react-use" | ||||||||||||||||||||||||||
| import DynamicTextArea from "react-textarea-autosize" | ||||||||||||||||||||||||||
| import { VolumeX, Image, WandSparkles, SendHorizontal } from "lucide-react" | ||||||||||||||||||||||||||
| import { VolumeX, Image, WandSparkles, SendHorizontal, Server } from "lucide-react" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import { mentionRegex, mentionRegexGlobal, commandRegexGlobal, unescapeSpaces } from "@roo/context-mentions" | ||||||||||||||||||||||||||
| import { WebviewMessage } from "@roo/WebviewMessage" | ||||||||||||||||||||||||||
|
|
@@ -82,6 +82,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>( | |||||||||||||||||||||||||
| taskHistory, | ||||||||||||||||||||||||||
| clineMessages, | ||||||||||||||||||||||||||
| commands, | ||||||||||||||||||||||||||
| mcpServers, | ||||||||||||||||||||||||||
| } = useExtensionState() | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Find the ID and display text for the currently selected API configuration. | ||||||||||||||||||||||||||
|
|
@@ -1194,6 +1195,44 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>( | |||||||||||||||||||||||||
| </StandardTooltip> | ||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||
| <SlashCommandsPopover /> | ||||||||||||||||||||||||||
| {mcpServers && mcpServers.length > 0 && ( | ||||||||||||||||||||||||||
| <StandardTooltip content={t("chat:mcpServers")}> | ||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||
| aria-label={t("chat:mcpServers")} | ||||||||||||||||||||||||||
| onClick={() => { | ||||||||||||||||||||||||||
| window.postMessage( | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| type: "action", | ||||||||||||||||||||||||||
| action: "mcpButtonClicked", | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| "*", | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||
| className={cn( | ||||||||||||||||||||||||||
| "relative inline-flex items-center justify-center", | ||||||||||||||||||||||||||
| "bg-transparent border-none p-1.5", | ||||||||||||||||||||||||||
| "rounded-md min-w-[28px] min-h-[28px]", | ||||||||||||||||||||||||||
| "text-vscode-foreground opacity-85", | ||||||||||||||||||||||||||
| "transition-all duration-150", | ||||||||||||||||||||||||||
| "hover:opacity-100 hover:bg-[rgba(255,255,255,0.03)] hover:border-[rgba(255,255,255,0.15)]", | ||||||||||||||||||||||||||
| "focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder", | ||||||||||||||||||||||||||
| "active:bg-[rgba(255,255,255,0.1)]", | ||||||||||||||||||||||||||
| "cursor-pointer", | ||||||||||||||||||||||||||
| )}> | ||||||||||||||||||||||||||
| <Server className="w-4 h-4" /> | ||||||||||||||||||||||||||
| {mcpServers.some( | ||||||||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better readability, consider extracting the error detection logic to a variable:
Suggested change
|
||||||||||||||||||||||||||
| (server) => server.status === "disconnected" && !server.disabled, | ||||||||||||||||||||||||||
| ) && ( | ||||||||||||||||||||||||||
| <span | ||||||||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error indicator (red dot) doesn't have any accessible text for screen reader users. Consider adding an aria-label to the button or the error indicator span to improve accessibility:
Suggested change
|
||||||||||||||||||||||||||
| className={cn( | ||||||||||||||||||||||||||
| "absolute top-1 right-1 w-1.5 h-1.5 rounded-full", | ||||||||||||||||||||||||||
| "bg-red-500", | ||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||
| </StandardTooltip> | ||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||
| <IndexingStatusBadge /> | ||||||||||||||||||||||||||
| <StandardTooltip content={t("chat:addImages")}> | ||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,7 @@ | |
| }, | ||
| "enhancePromptDescription": "The 'Enhance Prompt' button helps improve your prompt by providing additional context, clarification, or rephrasing. Try typing a prompt in here and clicking the button again to see how it works.", | ||
| "addImages": "Add images to message", | ||
| "mcpServers": "MCP Servers", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "mcpServers" translation key should be added to all other locale files to maintain i18n consistency. Currently it's only in the English locale. Could we ensure all locale files are updated? |
||
| "sendMessage": "Send message", | ||
| "stopTts": "Stop text-to-speech", | ||
| "typeMessage": "Type a message...", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
mcpServersproperty is destructured fromuseExtensionState()but doesn't appear to be typed in the hook's return type. Could this cause TypeScript errors if strict typing is enabled? Consider adding the proper type definition to ensure type safety.