Fix editor integration: move EditorPanel to ChatSessionView
- Fixed Ace import (default import, not named) - Moved EditorPanel from FilesPanel to ChatSessionView - Editor now replaces chat view when file is selected (per UI design guide) - FILES panel now contains only the file tree - Added editorFilePath state to track open file - File selection in tree opens editor in content area - Close button returns to chat view This matches the UI design guide specification where the File Editor replaces the Chat View in the content area when a file is selected.
This commit is contained in:
parent
1e13f95808
commit
fb8b73e290
@ -1,5 +1,5 @@
|
|||||||
import { useState, useCallback, useEffect } from 'react';
|
import { useState, useCallback, useEffect } from 'react';
|
||||||
import AceEditor from 'react-ace';
|
import Ace from 'react-ace';
|
||||||
import 'ace-builds/src-noconflict/mode-text';
|
import 'ace-builds/src-noconflict/mode-text';
|
||||||
import 'ace-builds/src-noconflict/theme-tomorrow';
|
import 'ace-builds/src-noconflict/theme-tomorrow';
|
||||||
import 'ace-builds/src-noconflict/ext-language_tools';
|
import 'ace-builds/src-noconflict/ext-language_tools';
|
||||||
@ -298,7 +298,7 @@ export default function EditorPanel({ workspaceMode, filePath, onCloseFile }: Ed
|
|||||||
{/* ACE Editor */}
|
{/* ACE Editor */}
|
||||||
{!state.isLoading && (
|
{!state.isLoading && (
|
||||||
<div className="flex-1 min-h-0">
|
<div className="flex-1 min-h-0">
|
||||||
<AceEditor
|
<Ace
|
||||||
mode={state.language}
|
mode={state.language}
|
||||||
theme="tomorrow"
|
theme="tomorrow"
|
||||||
name="editor"
|
name="editor"
|
||||||
|
|||||||
@ -1,25 +1,15 @@
|
|||||||
import { useState } from "react";
|
|
||||||
import { WorkspaceMode } from "../lib/types";
|
import { WorkspaceMode } from "../lib/types";
|
||||||
import FileTree from "./FileTree";
|
import FileTree from "./FileTree";
|
||||||
import EditorPanel from "./EditorPanel";
|
|
||||||
|
|
||||||
interface FilesPanelProps {
|
interface FilesPanelProps {
|
||||||
workspaceMode: WorkspaceMode;
|
workspaceMode: WorkspaceMode;
|
||||||
|
onFileSelect?: (path: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function FilesPanel({ workspaceMode }: FilesPanelProps) {
|
export default function FilesPanel({ workspaceMode, onFileSelect }: FilesPanelProps) {
|
||||||
const [selectedFilePath, setSelectedFilePath] = useState<string | undefined>(undefined);
|
|
||||||
const isReadOnly = workspaceMode === WorkspaceMode.Agent;
|
const isReadOnly = workspaceMode === WorkspaceMode.Agent;
|
||||||
const isReadWrite = workspaceMode === WorkspaceMode.User;
|
const isReadWrite = workspaceMode === WorkspaceMode.User;
|
||||||
|
|
||||||
const handleFileSelect = (path: string) => {
|
|
||||||
setSelectedFilePath(path);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCloseFile = () => {
|
|
||||||
setSelectedFilePath(undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="border-t border-border-subtle flex flex-col flex-1 min-h-0">
|
<div className="border-t border-border-subtle flex flex-col flex-1 min-h-0">
|
||||||
<div className="flex items-center justify-between px-4 py-2 bg-bg-tertiary">
|
<div className="flex items-center justify-between px-4 py-2 bg-bg-tertiary">
|
||||||
@ -49,27 +39,12 @@ export default function FilesPanel({ workspaceMode }: FilesPanelProps) {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex-1 overflow-auto">
|
||||||
{/* Split view: File tree on left, editor on right */}
|
<FileTree
|
||||||
<div className="flex-1 flex overflow-hidden min-h-0">
|
workspaceMode={workspaceMode}
|
||||||
{/* File Tree - 30% width, resizable in future */}
|
onFileSelect={onFileSelect}
|
||||||
<div className="w-1/3 min-w-[200px] border-r border-border-subtle overflow-auto flex-shrink-0">
|
/>
|
||||||
<FileTree
|
|
||||||
workspaceMode={workspaceMode}
|
|
||||||
onFileSelect={handleFileSelect}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Editor Panel - remaining space */}
|
|
||||||
<div className="flex-1 min-w-0">
|
|
||||||
<EditorPanel
|
|
||||||
workspaceMode={workspaceMode}
|
|
||||||
filePath={selectedFilePath}
|
|
||||||
onCloseFile={handleCloseFile}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="px-4 py-2 bg-bg-tertiary border-t border-border-subtle">
|
<div className="px-4 py-2 bg-bg-tertiary border-t border-border-subtle">
|
||||||
<p className="text-xs text-text-muted">
|
<p className="text-xs text-text-muted">
|
||||||
{isReadOnly
|
{isReadOnly
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import WorkspaceModeIndicator from '../components/WorkspaceModeIndicator';
|
|||||||
import FilesPanel from '../components/FilesPanel';
|
import FilesPanel from '../components/FilesPanel';
|
||||||
import LogPanel from '../components/LogPanel';
|
import LogPanel from '../components/LogPanel';
|
||||||
import ChatTurnComponent from '../components/ChatTurn';
|
import ChatTurnComponent from '../components/ChatTurn';
|
||||||
|
import EditorPanel from '../components/EditorPanel';
|
||||||
import { AppContext } from '../App';
|
import { AppContext } from '../App';
|
||||||
|
|
||||||
interface LogEntry {
|
interface LogEntry {
|
||||||
@ -74,6 +75,7 @@ export default function ChatSessionView() {
|
|||||||
const [_connectionState, setConnectionState] = useState<'disconnected' | 'connecting' | 'connected' | 'error'>('disconnected');
|
const [_connectionState, setConnectionState] = useState<'disconnected' | 'connecting' | 'connected' | 'error'>('disconnected');
|
||||||
const [isOtherTab, setIsOtherTab] = useState(false);
|
const [isOtherTab, setIsOtherTab] = useState(false);
|
||||||
const [reconnectAttempts, setReconnectAttempts] = useState(0);
|
const [reconnectAttempts, setReconnectAttempts] = useState(0);
|
||||||
|
const [editorFilePath, setEditorFilePath] = useState<string | undefined>(undefined);
|
||||||
|
|
||||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||||
@ -1086,18 +1088,27 @@ export default function ChatSessionView() {
|
|||||||
{isEditingProvider && (
|
{isEditingProvider && (
|
||||||
<div className="absolute inset-0 bg-bg-primary/80 z-30" />
|
<div className="absolute inset-0 bg-bg-primary/80 z-30" />
|
||||||
)}
|
)}
|
||||||
{/* Chat View (75%) */}
|
|
||||||
<div className="flex-1 flex flex-col overflow-hidden">
|
{/* File Editor View (replaces Chat View when file is open) */}
|
||||||
{/* Messages */}
|
{editorFilePath ? (
|
||||||
<div className="flex-1 overflow-y-auto p-3 space-y-2">
|
<EditorPanel
|
||||||
{turns.map((turn) => (
|
workspaceMode={workspaceMode}
|
||||||
<ChatTurnComponent
|
filePath={editorFilePath}
|
||||||
key={turn._id}
|
onCloseFile={() => setEditorFilePath(undefined)}
|
||||||
turn={turn}
|
/>
|
||||||
/>
|
) : (
|
||||||
))}
|
/* Chat View (75%) */
|
||||||
<div ref={messagesEndRef} />
|
<div className="flex-1 flex flex-col overflow-hidden">
|
||||||
</div>
|
{/* Messages */}
|
||||||
|
<div className="flex-1 overflow-y-auto p-3 space-y-2">
|
||||||
|
{turns.map((turn) => (
|
||||||
|
<ChatTurnComponent
|
||||||
|
key={turn._id}
|
||||||
|
turn={turn}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
<div ref={messagesEndRef} />
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Prompt Input */}
|
{/* Prompt Input */}
|
||||||
<div className="border-t border-border-subtle p-4 bg-bg-secondary shrink-0">
|
<div className="border-t border-border-subtle p-4 bg-bg-secondary shrink-0">
|
||||||
@ -1138,6 +1149,7 @@ export default function ChatSessionView() {
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Log Panel (25%) */}
|
{/* Log Panel (25%) */}
|
||||||
<LogPanel
|
<LogPanel
|
||||||
@ -1375,7 +1387,12 @@ export default function ChatSessionView() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* FILES Panel */}
|
{/* FILES Panel */}
|
||||||
<FilesPanel workspaceMode={workspaceMode} />
|
<FilesPanel
|
||||||
|
workspaceMode={workspaceMode}
|
||||||
|
onFileSelect={(path) => {
|
||||||
|
setEditorFilePath(path);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user