Add open in IDE button next to file path (vibe-kanban) (#449)

* Commit changes from coding agent for task attempt 5c90881e-c747-4aa5-923a-54e78c4ac2e3

* Cleanup script changes for task attempt 5c90881e-c747-4aa5-923a-54e78c4ac2e3
This commit is contained in:
Louis Knight-Webb
2025-08-11 22:34:36 +01:00
committed by GitHub
parent 6d51d0c3a5
commit 6f39cca4e6
3 changed files with 62 additions and 17 deletions

View File

@@ -2,6 +2,11 @@ import { DiffFile, DiffModeEnum, DiffView } from '@git-diff-view/react';
import { ThemeMode } from 'shared/types';
import '../styles/diff-style-overrides.css';
import { useConfig } from './config-provider';
import { useContext } from 'react';
import { TaskSelectedAttemptContext } from './context/taskDetailsContext';
import { Button } from './ui/button';
import { FolderOpen } from 'lucide-react';
import { attemptsApi } from '@/lib/api';
type Props = {
diffFile: DiffFile;
@@ -10,26 +15,51 @@ type Props = {
const DiffCard = ({ diffFile, key }: Props) => {
const { config } = useConfig();
const { selectedAttempt } = useContext(TaskSelectedAttemptContext);
let theme: 'light' | 'dark' | undefined = 'light';
if (config?.theme === ThemeMode.DARK) {
theme = 'dark';
}
const handleOpenInIDE = async () => {
if (!selectedAttempt?.id) return;
try {
await attemptsApi.openEditor(
selectedAttempt.id,
undefined,
diffFile._newFileName
);
} catch (error) {
console.error('Failed to open file in IDE:', error);
}
};
return (
<div className="my-4 border" key={key}>
<p
className="text-xs font-mono px-4 py-2 overflow-x-auto"
style={{ color: 'hsl(var(--muted-foreground) / 0.7)' }}
>
{diffFile._newFileName}{' '}
<span style={{ color: 'hsl(var(--console-success))' }}>
+{diffFile.additionLength}
</span>{' '}
<span style={{ color: 'hsl(var(--console-error))' }}>
-{diffFile.deletionLength}
</span>
</p>
<div className="flex items-center justify-between px-4 py-2">
<p
className="text-xs font-mono overflow-x-auto flex-1"
style={{ color: 'hsl(var(--muted-foreground) / 0.7)' }}
>
{diffFile._newFileName}{' '}
<span style={{ color: 'hsl(var(--console-success))' }}>
+{diffFile.additionLength}
</span>{' '}
<span style={{ color: 'hsl(var(--console-error))' }}>
-{diffFile.deletionLength}
</span>
</p>
<Button
variant="ghost"
size="sm"
onClick={handleOpenInIDE}
className="h-6 w-6 p-0 ml-2"
title="Open in IDE"
>
<FolderOpen className="h-3 w-3" />
</Button>
</div>
<DiffView
diffFile={diffFile}
diffViewWrap={false}

View File

@@ -336,13 +336,20 @@ export const attemptsApi = {
openEditor: async (
attemptId: string,
editorType?: EditorType
editorType?: EditorType,
filePath?: string
): Promise<void> => {
const requestBody: any = {};
if (editorType) requestBody.editor_type = editorType;
if (filePath) requestBody.file_path = filePath;
const response = await makeRequest(
`/api/task-attempts/${attemptId}/open-editor`,
{
method: 'POST',
body: JSON.stringify(editorType ? { editor_type: editorType } : null),
body: JSON.stringify(
Object.keys(requestBody).length > 0 ? requestBody : null
),
}
);
return handleApiResponse<void>(response);