Skip to content

Commit a8bd902

Browse files
committed
hint QOL
1 parent 72cdb87 commit a8bd902

2 files changed

Lines changed: 65 additions & 5 deletions

File tree

webviews/dashboardView/components/ChatInput.tsx

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,45 @@ interface ChatInputProps {
148148

149149
export const ChatInput: React.FC<ChatInputProps> = ({ data, isGlobal }) => {
150150
const [chatInput, setChatInput] = useState('');
151+
const [editor, setEditor] = useState<monaco.editor.IStandaloneCodeEditor | null>(null);
151152
const [showDropdown, setShowDropdown] = useState(false);
152153

153154
// Handle content changes
154155
const handleEditorChange = useCallback((value: string | undefined) => {
155156
setChatInput(value || '');
156157
}, []);
157158

159+
const handleAgentClick = useCallback((agent: string) => {
160+
let finalInput: string;
161+
const currentInput = chatInput.trim();
162+
163+
if (!currentInput) {
164+
// Empty input - just set the agent
165+
finalInput = agent;
166+
} else {
167+
// Check if input starts with an agent pattern
168+
const agentMatch = currentInput.match(/^@(local|copilot)\s*/);
169+
if (agentMatch) {
170+
// Replace existing agent with the clicked one
171+
finalInput = agent + currentInput.substring(agentMatch[0].length);
172+
} else {
173+
// No agent at start - prepend the clicked agent
174+
finalInput = agent + currentInput;
175+
}
176+
}
177+
178+
setChatInput(finalInput);
179+
if (editor) {
180+
editor.focus();
181+
// Position cursor at the end
182+
const model = editor.getModel();
183+
if (model) {
184+
const position = model.getPositionAt(finalInput.length);
185+
editor.setPosition(position);
186+
}
187+
}
188+
}, [chatInput, editor]);
189+
158190
const handleSendChat = useCallback(() => {
159191
if (chatInput.trim()) {
160192
const trimmedInput = chatInput.trim();
@@ -206,6 +238,8 @@ export const ChatInput: React.FC<ChatInputProps> = ({ data, isGlobal }) => {
206238

207239
// Setup editor instance when it mounts
208240
const handleEditorDidMount = useCallback((editorInstance: monaco.editor.IStandaloneCodeEditor, monaco: Monaco) => {
241+
setEditor(editorInstance);
242+
209243
// Auto-resize editor based on content
210244
const updateHeight = () => {
211245
const model = editorInstance.getModel();
@@ -346,7 +380,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({ data, isGlobal }) => {
346380
</div>
347381
</div>
348382

349-
{isGlobal && <GlobalInstructions />}
383+
{isGlobal && <GlobalInstructions onAgentClick={handleAgentClick} />}
350384

351385
<div className="quick-actions">
352386
{!isGlobal && (
@@ -356,7 +390,15 @@ export const ChatInput: React.FC<ChatInputProps> = ({ data, isGlobal }) => {
356390
<strong>Reference issues:</strong> Use the syntax <code>org/repo#123</code> to start work on specific issues from any repository.
357391
</p>
358392
<p>
359-
<strong>Choose your agent:</strong> Use <code>@local</code> to work locally or <code>@copilot</code> to use GitHub Copilot.
393+
<strong>Choose your agent:</strong> Use <code
394+
style={{ cursor: 'pointer' }}
395+
onClick={() => handleAgentClick('@local ')}
396+
title="Click to add @local to input"
397+
>@local</code> to work locally or <code
398+
style={{ cursor: 'pointer' }}
399+
onClick={() => handleAgentClick('@copilot ')}
400+
title="Click to add @copilot to input"
401+
>@copilot</code> to use GitHub Copilot.
360402
</p>
361403
<p>
362404
<strong>Mention projects:</strong> You can talk about projects by name to work across multiple repositories.

webviews/dashboardView/components/GlobalInstructions.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,38 @@
55

66
import React from 'react';
77

8-
export const GlobalInstructions: React.FC = () => {
8+
interface GlobalInstructionsProps {
9+
onAgentClick?: (agent: string) => void;
10+
}
11+
12+
export const GlobalInstructions: React.FC<GlobalInstructionsProps> = ({ onAgentClick }) => {
13+
const handleAgentClick = (agent: string) => {
14+
if (onAgentClick) {
15+
onAgentClick(agent);
16+
}
17+
};
18+
919
return (
1020
<div className="global-instructions">
1121
<div className="instructions-content">
1222
<p>
1323
<strong>Reference issues:</strong> Use the syntax <code>org/repo#123</code> to start work on specific issues from any repository.
1424
</p>
1525
<p>
16-
<strong>Choose your agent:</strong> Use <code>@local</code> to work locally or <code>@copilot</code> to use GitHub Copilot.
26+
<strong>Choose your agent:</strong> Use <code
27+
style={{ cursor: 'pointer' }}
28+
onClick={() => handleAgentClick('@local ')}
29+
title="Click to add @local to input"
30+
>@local</code> to work locally or <code
31+
style={{ cursor: 'pointer' }}
32+
onClick={() => handleAgentClick('@copilot ')}
33+
title="Click to add @copilot to input"
34+
>@copilot</code> to use GitHub Copilot.
1735
</p>
1836
<p>
1937
<strong>Mention projects:</strong> You can talk about projects by name to work across multiple repositories.
2038
</p>
2139
</div>
2240
</div>
2341
);
24-
};
42+
};

0 commit comments

Comments
 (0)