fix: project-scope terminal, file browser, agent execution, and heartbeat monitor

- TerminalService: use per-project instance map instead of destructive singleton
- File browser: thread projectId through API functions, hooks, and components
- Workspace file editor: pass projectId to read/write operations
- Agent heartbeat: guard execution with project scope validation
- Agent runs/stop: validate heartbeatMonitor matches scoped project
- CLI dashboard/serve: pass rootDir to heartbeatMonitor via server options
- Add getRootDir() to HeartbeatMonitor for scope comparison

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
gsxdsm
2026-04-12 18:38:26 -07:00
parent 9204fc673c
commit 2562814518
16 changed files with 172 additions and 65 deletions

View File

@@ -32,7 +32,7 @@ describe("useWorkspaceFileBrowser", () => {
await waitFor(() => expect(result.current.loading).toBe(false));
expect(result.current.entries).toEqual(mockResponse.entries);
expect(mockFetchWorkspaceFileList).toHaveBeenCalledWith("FN-123", undefined);
expect(mockFetchWorkspaceFileList).toHaveBeenCalledWith("FN-123", undefined, undefined);
});
it("resets path when workspace changes", async () => {
@@ -53,12 +53,12 @@ describe("useWorkspaceFileBrowser", () => {
});
await waitFor(() => expect(result.current.currentPath).toBe("src"));
await waitFor(() => expect(mockFetchWorkspaceFileList).toHaveBeenLastCalledWith("FN-123", "src"));
await waitFor(() => expect(mockFetchWorkspaceFileList).toHaveBeenLastCalledWith("FN-123", "src", undefined));
rerender({ workspace: "project" });
await waitFor(() => expect(result.current.currentPath).toBe("."));
await waitFor(() => expect(mockFetchWorkspaceFileList).toHaveBeenLastCalledWith("project", undefined));
await waitFor(() => expect(mockFetchWorkspaceFileList).toHaveBeenLastCalledWith("project", undefined, undefined));
});
it("handles fetch errors", async () => {