@@ -206,12 +206,14 @@ export class TaskManager {
206206 */
207207 getCurrentTaskPanelPath ( ) : string | null {
208208 try {
209- // current-task.md 应该在 .wave 目录下
210- const panelPath = path . join ( this . docsPath , 'current-task.md' ) ;
209+ // 如果有活跃项目,优先使用该项目的 .wave 目录
210+ const active = this . projectManager ?. getActiveProject ( ) ;
211+ if ( active ?. root ) {
212+ return path . join ( active . root , '.wave' , 'current-task.md' ) ;
213+ }
211214
212- // 不检查文件是否存在,直接返回路径
213- // 这样在同步检测时可以正确找到路径
214- return panelPath ;
215+ // 回退到初始化时的 docsPath
216+ return path . join ( this . docsPath , 'current-task.md' ) ;
215217 } catch ( error ) {
216218 return null ;
217219 }
@@ -286,7 +288,8 @@ export class TaskManager {
286288 if ( ! effectiveProjectId ) {
287289 const activeProject = this . projectManager . getActiveProject ( ) ;
288290 if ( activeProject ) {
289- effectiveProjectId = activeProject . root ;
291+ // 使用项目ID而不是root路径以兼容 resolveProject 要求
292+ effectiveProjectId = activeProject . project_id ;
290293 } else {
291294 // 没有活动项目,使用默认路径
292295 return this . docsPath ;
@@ -456,7 +459,8 @@ export class TaskManager {
456459 expectedResults : task . expectedResults || [ ] ,
457460 createdAt : task . created_at ,
458461 updatedAt : task . updated_at ,
459- projectId : this . projectManager ?. getActiveProject ( ) ?. root || '' ,
462+ // 使用活动项目的ID作为 projectId,避免与路径混淆
463+ projectId : this . projectManager ?. getActiveProject ( ) ?. project_id || '' ,
460464 panelModTime, // 传递面板修改时间
461465 } ;
462466
@@ -809,7 +813,7 @@ export class TaskManager {
809813
810814 // 如果没有传入 projectId,尝试从当前活动项目获取
811815 const effectiveProjectId =
812- projectId || this . projectManager ?. getActiveProject ( ) ?. root ;
816+ projectId || this . projectManager ?. getActiveProject ( ) ?. project_id ;
813817
814818 const taskPath = await this . resolveTaskPath ( effectiveProjectId ) ;
815819
@@ -1168,19 +1172,19 @@ export class TaskManager {
11681172
11691173 // 同时保存到多任务目录结构
11701174 try {
1175+ // 使用当前项目的 .wave 路径初始化目录管理器,避免写入服务器启动目录
1176+ const docsPathForProject = await this . resolveProjectPath ( projectId ) ;
1177+ const projectDirManager = new MultiTaskDirectoryManager ( docsPathForProject ) ;
1178+
11711179 // 检查任务是否已经存在于多任务目录中
1172- const existingTaskDir =
1173- await this . multiTaskDirectoryManager . findTaskDirectory ( task . id ) ;
1180+ const existingTaskDir = await projectDirManager . findTaskDirectory ( task . id ) ;
11741181
11751182 if ( existingTaskDir ) {
11761183 // 更新现有任务
1177- await this . multiTaskDirectoryManager . updateTaskInDirectory (
1178- task ,
1179- existingTaskDir
1180- ) ;
1184+ await projectDirManager . updateTaskInDirectory ( task , existingTaskDir ) ;
11811185 } else {
11821186 // 创建新的任务目录
1183- await this . multiTaskDirectoryManager . saveTaskToDirectory ( task ) ;
1187+ await projectDirManager . saveTaskToDirectory ( task ) ;
11841188 }
11851189 } catch ( error ) {
11861190 // 多任务目录保存失败不应该影响主要功能
@@ -1787,7 +1791,18 @@ export class TaskManager {
17871791 */
17881792 async getTaskHistory ( ) : Promise < any [ ] > {
17891793 try {
1790- const historyDir = path . join ( this . docsPath , 'history' ) ;
1794+ // 优先使用当前绑定项目的 .wave 路径
1795+ let activeProjectId : string | undefined ;
1796+ try {
1797+ // 访问活跃项目(存在则使用其 project_id)
1798+ const active = this . projectManager ?. getActiveProject ( ) ;
1799+ if ( active ?. project_id ) {
1800+ activeProjectId = active . project_id ;
1801+ }
1802+ } catch { }
1803+
1804+ const docsPath = await this . resolveProjectPath ( activeProjectId ) ;
1805+ const historyDir = path . join ( docsPath , 'history' ) ;
17911806
17921807 if ( ! ( await fs . pathExists ( historyDir ) ) ) {
17931808 return [ ] ;
0 commit comments