Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: git commit push feature from workbench #818

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
basic git status is added
thecodacus committed Dec 30, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d3e4f04bbba1c659b3cd8a12c2c40fdee39c8422
4 changes: 2 additions & 2 deletions app/components/chat/BaseChat.tsx
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ import styles from './BaseChat.module.scss';
import { ExportChatButton } from '~/components/chat/chatExportAndImport/ExportChatButton';
import { ImportButtons } from '~/components/chat/chatExportAndImport/ImportButtons';
import { ExamplePrompts } from '~/components/chat/ExamplePrompts';
import GitCloneButton from './GitCloneButton';
import GitCloneButton from './GitCloneButton.client';

import FilePreview from './FilePreview';
import { ModelSelector } from '~/components/chat/ModelSelector';
@@ -574,7 +574,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
{!chatStarted && (
<div className="flex justify-center gap-2">
{ImportButtons(importChat)}
<GitCloneButton importChat={importChat} />
<ClientOnly>{() => <GitCloneButton importChat={importChat} />}</ClientOnly>
</div>
)}
{!chatStarted &&
Original file line number Diff line number Diff line change
@@ -32,7 +32,11 @@ const ig = ignore().add(IGNORE_PATTERNS);

interface GitCloneButtonProps {
className?: string;
importChat?: (description: string, messages: Message[]) => Promise<void>;
importChat?: (
description: string,
messages: Message[],
gitMeta?: { url: string; branch: string; sourceHash: string },
) => Promise<void>;
}

export default function GitCloneButton({ importChat }: GitCloneButtonProps) {
@@ -92,7 +96,11 @@ ${file.content}
messages.push(commandsMessage);
}

await importChat(`Git Project:${repoUrl.split('/').slice(-1)[0]}`, messages);
await importChat(`Git Project:${repoUrl.split('/').slice(-1)[0]}`, messages, {
url: repoUrl,
branch: 'main',
sourceHash: '',
});
}
}
};
65 changes: 49 additions & 16 deletions app/components/workbench/EditorPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useStore } from '@nanostores/react';
import { memo, useMemo } from 'react';
import { memo, useMemo, useState } from 'react';
import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels';
import {
CodeMirrorEditor,
@@ -21,6 +21,9 @@ import { FileTree } from './FileTree';
import { DEFAULT_TERMINAL_SIZE, TerminalTabs } from './terminal/TerminalTabs';
import { workbenchStore } from '~/lib/stores/workbench';
import WithTooltip from '~/components/ui/Tooltip';
import { IconButton } from '~/components/ui/IconButton';
import { classNames } from '~/utils/classNames';
import GitPanel from './GitPanel';

interface EditorPanelProps {
files?: FileMap;
@@ -39,6 +42,17 @@ const DEFAULT_EDITOR_SIZE = 100 - DEFAULT_TERMINAL_SIZE;

const editorSettings: EditorSettings = { tabSize: 2 };

interface TabItem {
name: string;
label: string;
icon: string;
}

const tabs: TabItem[] = [
{ name: 'files', label: 'Files', icon: 'i-ph:files-fill' },
{ name: 'git', label: 'Git', icon: 'i-ph:git-branch-duotone' },
];

export const EditorPanel = memo(
({
files,
@@ -58,6 +72,7 @@ export const EditorPanel = memo(

const theme = useStore(themeStore);
const showTerminal = useStore(workbenchStore.showTerminal);
const [activeTab, setActiveTab] = useState<TabItem>(tabs[0]);

const activeFileSegments = useMemo(() => {
if (!editorDocument) {
@@ -77,25 +92,43 @@ export const EditorPanel = memo(
<PanelGroup direction="horizontal">
<Panel defaultSize={25} minSize={15} collapsible>
<div className="flex h-full">
<div className="flex flex-col w-8 min-w-8 border-r border-bolt-elements-borderColor h-full">
<WithTooltip tooltip="Files">
<div className="i-ph:files-fill mx-auto m-4 text-lg text-bolt-elements-textSecondary hover:text-bolt-elements-item-contentAccent" />
</WithTooltip>
<div className="flex flex-col w-8 min-w-12 border-r border-bolt-elements-borderColor h-full">
{tabs.map((tab) => (
<WithTooltip tooltip={tab.label} key={tab.name} position="left">
<IconButton
icon={tab.icon}
className={classNames('mx-auto m-3 text-lg', {
'bg-bolt-elements-item-backgroundAccent': activeTab.name === tab.name,
})}
iconClassName={classNames({
'text-bolt-elements-item-contentAccent': activeTab.name === tab.name,
})}
onClick={() => setActiveTab(tab)}
></IconButton>
</WithTooltip>
))}
</div>
<div className="flex flex-col flex-1 border-r border-bolt-elements-borderColor h-full">
<PanelHeader>
<div className="i-ph:tree-structure-duotone shrink-0" />
Files
<div className={classNames(' shrink-0', activeTab.icon)} />
{activeTab.label}
</PanelHeader>
<FileTree
className="h-full"
files={files}
hideRoot
unsavedFiles={unsavedFiles}
rootFolder={WORK_DIR}
selectedFile={selectedFile}
onFileSelect={onFileSelect}
/>
{activeTab.name === 'files' && (
<FileTree
className="h-full"
files={files}
hideRoot
unsavedFiles={unsavedFiles}
rootFolder={WORK_DIR}
selectedFile={selectedFile}
onFileSelect={onFileSelect}
/>
)}
{activeTab.name === 'git' && (
<div className="h-full flex-1 overflow-hidden">
<GitPanel files={files} />
</div>
)}
</div>
</div>
</Panel>
Loading
Loading