Skip to content

Commit 1bc1092

Browse files
committed
chat: better control mode UI
1 parent f0d6795 commit 1bc1092

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

chat/src/components/MessageInput.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default function MessageInput({
2222
const [sentChars, setSentChars] = useState<SentChar[]>([]);
2323
const textareaRef = useRef<HTMLTextAreaElement>(null);
2424
const nextCharId = useRef(0);
25+
const [controlAreaFocused, setControlAreaFocused] = useState(false);
2526

2627
const handleSubmit = (e: FormEvent) => {
2728
e.preventDefault();
@@ -128,6 +129,9 @@ export default function MessageInput({
128129
useEffect(() => {
129130
if (textareaRef.current) {
130131
textareaRef.current.focus();
132+
if (inputMode === "control") {
133+
setControlAreaFocused(true);
134+
}
131135
}
132136
}, [inputMode]);
133137

@@ -162,6 +166,10 @@ export default function MessageInput({
162166
Control
163167
</button>
164168
</div>
169+
<span className="ml-3 text-xs text-gray-600">
170+
Switch to <span className="font-medium">Control</span> mode to send
171+
raw keystrokes (↑,↓,Tab,Ctrl+C) directly to the terminal
172+
</span>
165173
</div>
166174

167175
{inputMode === "control" && !disabled && (
@@ -196,9 +204,13 @@ export default function MessageInput({
196204
tabIndex={0}
197205
// eslint-disable-next-line @typescript-eslint/no-explicit-any
198206
onKeyDown={handleKeyDown as any}
207+
onFocus={() => setControlAreaFocused(true)}
208+
onBlur={() => setControlAreaFocused(false)}
199209
className="flex-1 cursor-text border rounded-lg p-2 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-500 bg-gray-50 border-blue-200 min-h-[3.5rem] flex items-center justify-center"
200210
>
201-
Press any key to send to terminal
211+
{controlAreaFocused
212+
? "Press any key to send to terminal (arrows, Ctrl+C, etc.)"
213+
: "Click or focus this area to send keystrokes to terminal"}
202214
</div>
203215
) : (
204216
<>

0 commit comments

Comments
 (0)