feat: added vscode start task button (#1201)
Co-authored-by: Carlos Montoya <carlos@Carloss-MacBook-Pro.local> Co-authored-by: Carlos Montoya <los@losmontoya.com>
This commit is contained in:
5
.changeset/wild-ears-look.md
Normal file
5
.changeset/wild-ears-look.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"extension": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Added a Start Build button to the VSCODE Task Properties Right Panel
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Loader2 } from 'lucide-react';
|
import { Loader2, Play } from 'lucide-react';
|
||||||
import { PriorityBadge } from './PriorityBadge';
|
import { PriorityBadge } from './PriorityBadge';
|
||||||
import type { TaskMasterTask } from '../../webview/types';
|
import type { TaskMasterTask } from '../../webview/types';
|
||||||
|
import { useVSCodeContext } from '../../webview/contexts/VSCodeContext';
|
||||||
|
|
||||||
interface TaskMetadataSidebarProps {
|
interface TaskMetadataSidebarProps {
|
||||||
currentTask: TaskMasterTask;
|
currentTask: TaskMasterTask;
|
||||||
@@ -28,10 +29,12 @@ export const TaskMetadataSidebar: React.FC<TaskMetadataSidebarProps> = ({
|
|||||||
isRegenerating = false,
|
isRegenerating = false,
|
||||||
isAppending = false
|
isAppending = false
|
||||||
}) => {
|
}) => {
|
||||||
|
const { vscode } = useVSCodeContext();
|
||||||
const [isLoadingComplexity, setIsLoadingComplexity] = useState(false);
|
const [isLoadingComplexity, setIsLoadingComplexity] = useState(false);
|
||||||
const [mcpComplexityScore, setMcpComplexityScore] = useState<
|
const [mcpComplexityScore, setMcpComplexityScore] = useState<
|
||||||
number | undefined
|
number | undefined
|
||||||
>(undefined);
|
>(undefined);
|
||||||
|
const [isStartingTask, setIsStartingTask] = useState(false);
|
||||||
|
|
||||||
// Get complexity score from task
|
// Get complexity score from task
|
||||||
const currentComplexityScore = complexity?.score;
|
const currentComplexityScore = complexity?.score;
|
||||||
@@ -97,6 +100,29 @@ export const TaskMetadataSidebar: React.FC<TaskMetadataSidebarProps> = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle starting a task
|
||||||
|
const handleStartTask = () => {
|
||||||
|
if (!currentTask || isStartingTask) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsStartingTask(true);
|
||||||
|
|
||||||
|
// Send message to extension to open terminal
|
||||||
|
if (vscode) {
|
||||||
|
vscode.postMessage({
|
||||||
|
type: 'openTerminal',
|
||||||
|
taskId: currentTask.id,
|
||||||
|
taskTitle: currentTask.title
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset loading state after a short delay
|
||||||
|
setTimeout(() => {
|
||||||
|
setIsStartingTask(false);
|
||||||
|
}, 500);
|
||||||
|
};
|
||||||
|
|
||||||
// Effect to handle complexity on task change
|
// Effect to handle complexity on task change
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentTask?.id) {
|
if (currentTask?.id) {
|
||||||
@@ -284,6 +310,24 @@ export const TaskMetadataSidebar: React.FC<TaskMetadataSidebarProps> = ({
|
|||||||
{currentTask.dependencies && currentTask.dependencies.length > 0 && (
|
{currentTask.dependencies && currentTask.dependencies.length > 0 && (
|
||||||
<div className="border-b border-textSeparator-foreground" />
|
<div className="border-b border-textSeparator-foreground" />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Start Task Button */}
|
||||||
|
<div className="mt-4">
|
||||||
|
<Button
|
||||||
|
onClick={handleStartTask}
|
||||||
|
variant="default"
|
||||||
|
size="sm"
|
||||||
|
className="w-full text-xs"
|
||||||
|
disabled={isRegenerating || isAppending || isStartingTask || currentTask?.status === 'done'}
|
||||||
|
>
|
||||||
|
{isStartingTask ? (
|
||||||
|
<Loader2 className="w-4 h-4 mr-2 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<Play className="w-4 h-4 mr-2" />
|
||||||
|
)}
|
||||||
|
{isStartingTask ? 'Starting...' : 'Start Task'}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -202,16 +202,16 @@ export const TaskDetailsView: React.FC<TaskDetailsViewProps> = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right column - Metadata (1/3 width) */}
|
{/* Right column - Metadata (1/3 width) */}
|
||||||
<TaskMetadataSidebar
|
<TaskMetadataSidebar
|
||||||
currentTask={currentTask}
|
currentTask={currentTask}
|
||||||
tasks={allTasks}
|
tasks={allTasks}
|
||||||
complexity={complexity}
|
complexity={complexity}
|
||||||
isSubtask={isSubtask}
|
isSubtask={isSubtask}
|
||||||
sendMessage={sendMessage}
|
sendMessage={sendMessage}
|
||||||
onStatusChange={handleStatusChange}
|
onStatusChange={handleStatusChange}
|
||||||
onDependencyClick={handleDependencyClick}
|
onDependencyClick={handleDependencyClick}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -361,6 +361,25 @@ export class WebviewManager {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case 'openTerminal':
|
||||||
|
// Open VS Code terminal for task execution
|
||||||
|
this.logger.info(`Opening terminal for task ${data.taskId}: ${data.taskTitle}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const terminal = vscode.window.createTerminal({
|
||||||
|
name: `Task ${data.taskId}: ${data.taskTitle}`,
|
||||||
|
cwd: this.workspaceRoot
|
||||||
|
});
|
||||||
|
terminal.show();
|
||||||
|
|
||||||
|
this.logger.info('Terminal created and shown successfully');
|
||||||
|
response = { success: true };
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('Failed to create terminal:', error);
|
||||||
|
response = { success: false, error: error.message };
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown message type: ${type}`);
|
throw new Error(`Unknown message type: ${type}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user