diff --git a/src/pages/chat-dev/components/OpencodeChat.tsx b/src/pages/chat-dev/components/OpencodeChat.tsx
index d9b971d..69d1081 100644
--- a/src/pages/chat-dev/components/OpencodeChat.tsx
+++ b/src/pages/chat-dev/components/OpencodeChat.tsx
@@ -1,6 +1,6 @@
-import { useEffect } from 'react';
+import { useEffect, useState } from 'react';
import { useShallow } from 'zustand/react/shallow';
-import { FileIcon, FolderIcon, RefreshCwIcon, TrashIcon } from 'lucide-react';
+import { FileIcon, FolderIcon, RefreshCwIcon, TrashIcon, PencilIcon, CheckIcon, XIcon } from 'lucide-react';
import { useChatDevStore } from '../store';
import { useCodeGraphStore } from '@/pages/code-graph/store';
@@ -29,6 +29,36 @@ export const OpencodeChat = () => {
url: s.url,
})));
+ // 编辑节点信息的状态
+ const [isEditing, setIsEditing] = useState(false);
+ const [editFilepath, setEditFilepath] = useState('');
+ const [editProjectPath, setEditProjectPath] = useState('');
+
+ const startEditing = () => {
+ setEditFilepath(projectInfo?.filepath || '');
+ setEditProjectPath(projectInfo?.projectPath || '');
+ setIsEditing(true);
+ };
+
+ const cancelEditing = () => {
+ setIsEditing(false);
+ setEditFilepath('');
+ setEditProjectPath('');
+ };
+
+ const saveEditing = () => {
+ setData({
+ projectInfo: {
+ filepath: editFilepath,
+ projectPath: editProjectPath,
+ kind: projectInfo?.kind || 'file',
+ },
+ });
+ setIsEditing(false);
+ setEditFilepath('');
+ setEditProjectPath('');
+ };
+
// 初始化后尝试从 sessionStorage 恢复 opencode session 并加载历史消息
useEffect(() => {
if (!codeGraphStore.url) return;
@@ -88,21 +118,69 @@ export const OpencodeChat = () => {
{/* 内容区 */}
{/* 节点信息 */}
- {relativePath && (
-
-
-
- {relativePath}
-
-
- )}
- {projectInfo?.projectPath && !relativePath && (
-
-
-
- {projectInfo.projectPath}
-
+ {isEditing ? (
+
+
+
+ setEditProjectPath(e.target.value)}
+ />
+
+
+
+ setEditFilepath(e.target.value)}
+ />
+
+
+
+
+
+ ) : (
+ (relativePath || projectInfo?.projectPath) && (
+
+ {relativePath ? (
+ <>
+
+
+ {relativePath}
+
+ >
+ ) : (
+ <>
+
+
+ {projectInfo?.projectPath}
+
+ >
+ )}
+
+
+ )
)}
{/* 问题输入区 */}
diff --git a/src/pages/chat-dev/store/index.ts b/src/pages/chat-dev/store/index.ts
index 4a4199e..5079620 100644
--- a/src/pages/chat-dev/store/index.ts
+++ b/src/pages/chat-dev/store/index.ts
@@ -113,7 +113,6 @@ export const useChatDevStore = create
()((set, get) => ({
initFromTimestamp: (timestamp: string) => {
const key = SESSION_KEY_PREFIX + timestamp;
-
// 优先从 localStorage 读取(首次打开)
const localRaw = localStorage.getItem(key);
if (localRaw) {
@@ -123,7 +122,22 @@ export const useChatDevStore = create()((set, get) => ({
sessionStorage.setItem(SESSION_KEY, localRaw);
// 清除 localStorage
localStorage.removeItem(key);
- set({ question: data.question, engine: data.engine, projectInfo: data.projectInfo });
+
+ // filepath和projectPath可以通过URL参数传递,优先级高于存储的内容
+ const urlParams = new URLSearchParams(window.location.search);
+ const urlFilepath = urlParams.get('filepath');
+ const urlProjectPath = urlParams.get('projectPath');
+
+ if (urlFilepath || urlProjectPath) {
+ const projectInfo = {
+ ...data.projectInfo,
+ filepath: urlFilepath ? decodeURI(urlFilepath) : data.projectInfo?.filepath ?? '',
+ projectPath: urlProjectPath ? decodeURI(urlProjectPath) : data.projectInfo?.projectPath ?? '',
+ };
+ set({ question: data.question, engine: data.engine, projectInfo });
+ } else {
+ set({ question: data.question, engine: data.engine, projectInfo: data.projectInfo });
+ }
return;
} catch {
localStorage.removeItem(key);
@@ -135,7 +149,22 @@ export const useChatDevStore = create()((set, get) => ({
if (sessionRaw) {
try {
const data: ChatDevData = JSON.parse(sessionRaw);
- set({ question: data.question, engine: data.engine, projectInfo: data.projectInfo });
+
+ // filepath和projectPath可以通过URL参数传递,优先级高于存储的内容
+ const urlParams = new URLSearchParams(window.location.search);
+ const urlFilepath = urlParams.get('filepath');
+ const urlProjectPath = urlParams.get('projectPath');
+
+ if (urlFilepath || urlProjectPath) {
+ const projectInfo = {
+ ...data.projectInfo,
+ filepath: urlFilepath ? decodeURI(urlFilepath) : data.projectInfo?.filepath ?? '',
+ projectPath: urlProjectPath ? decodeURI(urlProjectPath) : data.projectInfo?.projectPath ?? '',
+ };
+ set({ question: data.question, engine: data.engine, projectInfo });
+ } else {
+ set({ question: data.question, engine: data.engine, projectInfo: data.projectInfo });
+ }
return;
} catch {
sessionStorage.removeItem(SESSION_KEY);
diff --git a/src/pages/code-graph/components/ProjectPanel.tsx b/src/pages/code-graph/components/ProjectPanel.tsx
index f46a1eb..230eb0e 100644
--- a/src/pages/code-graph/components/ProjectPanel.tsx
+++ b/src/pages/code-graph/components/ProjectPanel.tsx
@@ -18,7 +18,7 @@ export function ProjectPanel({
onStopProject,
}: ProjectPanelProps) {
const [isDragging, setIsDragging] = useState(false);
- const [position, setPosition] = useState({ x: 20, y: 80 });
+ const [position, setPosition] = useState({ x: 20, y: 100 });
const dragOffset = useRef({ x: 0, y: 0 });
const panelRef = useRef(null);
@@ -132,7 +132,7 @@ export function ProjectPanel({
{/* 项目列表 */}
-
+
{activeProjects.map((project) => {
const projectName = project.name || project.path.split('/').pop() || project.path;
const nodeInfoData = {