Skip to content

Commit 3e47e88

Browse files
roomote[bot]roomotemrubens
authored
fix: show send button when only images are selected in chat textarea (#8423)
Co-authored-by: Roo Code <[email protected]> Co-authored-by: Matt Rubens <[email protected]>
1 parent c552027 commit 3e47e88

File tree

2 files changed

+85
-3
lines changed

2 files changed

+85
-3
lines changed

webview-ui/src/components/chat/ChatTextArea.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
247247

248248
const allModes = useMemo(() => getAllModes(customModes), [customModes])
249249

250-
// Memoized check for whether the input has content
250+
// Memoized check for whether the input has content (text or images)
251251
const hasInputContent = useMemo(() => {
252-
return inputValue.trim().length > 0
253-
}, [inputValue])
252+
return inputValue.trim().length > 0 || selectedImages.length > 0
253+
}, [inputValue, selectedImages])
254254

255255
const queryItems = useMemo(() => {
256256
return [

webview-ui/src/components/chat/__tests__/ChatTextArea.spec.tsx

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,4 +1057,86 @@ describe("ChatTextArea", () => {
10571057
expect(apiConfigDropdown).toHaveAttribute("disabled")
10581058
})
10591059
})
1060+
1061+
describe("send button visibility", () => {
1062+
it("should show send button when there are images but no text", () => {
1063+
const { container } = render(
1064+
<ChatTextArea
1065+
{...defaultProps}
1066+
inputValue=""
1067+
selectedImages={["data:image/png;base64,test1", "data:image/png;base64,test2"]}
1068+
/>,
1069+
)
1070+
1071+
// Find the send button by looking for the button with SendHorizontal icon
1072+
const buttons = container.querySelectorAll("button")
1073+
const sendButton = Array.from(buttons).find(
1074+
(button) => button.querySelector(".lucide-send-horizontal") !== null,
1075+
)
1076+
1077+
expect(sendButton).toBeInTheDocument()
1078+
1079+
// Check that the button is visible (has opacity-100 class when content exists)
1080+
expect(sendButton).toHaveClass("opacity-100")
1081+
expect(sendButton).toHaveClass("pointer-events-auto")
1082+
expect(sendButton).not.toHaveClass("opacity-0")
1083+
expect(sendButton).not.toHaveClass("pointer-events-none")
1084+
})
1085+
1086+
it("should hide send button when there is no text and no images", () => {
1087+
const { container } = render(<ChatTextArea {...defaultProps} inputValue="" selectedImages={[]} />)
1088+
1089+
// Find the send button by looking for the button with SendHorizontal icon
1090+
const buttons = container.querySelectorAll("button")
1091+
const sendButton = Array.from(buttons).find(
1092+
(button) => button.querySelector(".lucide-send-horizontal") !== null,
1093+
)
1094+
1095+
expect(sendButton).toBeInTheDocument()
1096+
1097+
// Check that the button is hidden (has opacity-0 class when no content)
1098+
expect(sendButton).toHaveClass("opacity-0")
1099+
expect(sendButton).toHaveClass("pointer-events-none")
1100+
expect(sendButton).not.toHaveClass("opacity-100")
1101+
expect(sendButton).not.toHaveClass("pointer-events-auto")
1102+
})
1103+
1104+
it("should show send button when there is text but no images", () => {
1105+
const { container } = render(<ChatTextArea {...defaultProps} inputValue="Some text" selectedImages={[]} />)
1106+
1107+
// Find the send button by looking for the button with SendHorizontal icon
1108+
const buttons = container.querySelectorAll("button")
1109+
const sendButton = Array.from(buttons).find(
1110+
(button) => button.querySelector(".lucide-send-horizontal") !== null,
1111+
)
1112+
1113+
expect(sendButton).toBeInTheDocument()
1114+
1115+
// Check that the button is visible
1116+
expect(sendButton).toHaveClass("opacity-100")
1117+
expect(sendButton).toHaveClass("pointer-events-auto")
1118+
})
1119+
1120+
it("should show send button when there is both text and images", () => {
1121+
const { container } = render(
1122+
<ChatTextArea
1123+
{...defaultProps}
1124+
inputValue="Some text"
1125+
selectedImages={["data:image/png;base64,test1"]}
1126+
/>,
1127+
)
1128+
1129+
// Find the send button by looking for the button with SendHorizontal icon
1130+
const buttons = container.querySelectorAll("button")
1131+
const sendButton = Array.from(buttons).find(
1132+
(button) => button.querySelector(".lucide-send-horizontal") !== null,
1133+
)
1134+
1135+
expect(sendButton).toBeInTheDocument()
1136+
1137+
// Check that the button is visible
1138+
expect(sendButton).toHaveClass("opacity-100")
1139+
expect(sendButton).toHaveClass("pointer-events-auto")
1140+
})
1141+
})
10601142
})

0 commit comments

Comments
 (0)