Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ npm start
## Current Tabs

- Chat
- Experiments
- Launch
- Runs
- Candidates
Expand All @@ -42,3 +43,4 @@ npm start
- The shell can now review recent launch jobs and explain the latest failure from local stdout/stderr logs.
- The shell now persists decision state locally in `outputs/desktop/candidates_shortlist.json`.
- `Run`, `Compare`, `Artifacts`, `Candidates`, and `Paper Ops` are now shell-native tabs designed to support launch -> inspect -> compare -> decide continuity.
- `Experiments` is now a shell-native workspace for local sweep configs and recent sweep outputs under `configs/experiments` and `outputs/sweeps`.
35 changes: 34 additions & 1 deletion desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ function normalizeCandidatesStore(store) {

function assertPathInsideProject(targetPath) {
const resolvedProjectRoot = path.resolve(PROJECT_ROOT);
const resolvedTarget = path.resolve(String(targetPath || ""));
const rawTarget = String(targetPath || "").trim();
const resolvedTarget = path.isAbsolute(rawTarget)
? path.resolve(rawTarget)
: path.resolve(PROJECT_ROOT, rawTarget);
const relative = path.relative(resolvedProjectRoot, resolvedTarget);
if (!resolvedTarget || relative.startsWith("..") || path.isAbsolute(relative) && relative === resolvedTarget) {
throw new Error("Requested path is outside the QuantLab workspace.");
Expand Down Expand Up @@ -127,6 +130,28 @@ async function listDirectoryEntries(targetPath, maxDepth = 2) {
};
}

async function readProjectText(targetPath) {
const safePath = assertPathInsideProject(targetPath);
const stats = await fsp.stat(safePath);
if (!stats.isFile()) {
throw new Error("Requested path is not a file.");
}
return fsp.readFile(safePath, "utf8");
}

async function readProjectJson(targetPath) {
const raw = await readProjectText(targetPath);
try {
return JSON.parse(raw);
} catch (_error) {
const sanitized = raw
.replace(/\bNaN\b/g, "null")
.replace(/\b-Infinity\b/g, "null")
.replace(/\bInfinity\b/g, "null");
return JSON.parse(sanitized);
}
}

function appendLog(line) {
if (!line) return;
workspaceState.logs = [...workspaceState.logs.slice(-49), line];
Expand Down Expand Up @@ -288,6 +313,14 @@ ipcMain.handle("quantlab:list-directory", async (_event, targetPath, maxDepth =
return listDirectoryEntries(targetPath, maxDepth);
});

ipcMain.handle("quantlab:read-project-text", async (_event, targetPath) => {
return readProjectText(targetPath);
});

ipcMain.handle("quantlab:read-project-json", async (_event, targetPath) => {
return readProjectJson(targetPath);
});

ipcMain.handle("quantlab:post-json", async (_event, relativePath, payload) => {
if (!workspaceState.serverUrl) {
throw new Error("Research UI server is not ready yet.");
Expand Down
2 changes: 2 additions & 0 deletions desktop/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ contextBridge.exposeInMainWorld("quantlabDesktop", {
getCandidatesStore: () => ipcRenderer.invoke("quantlab:get-candidates-store"),
saveCandidatesStore: (store) => ipcRenderer.invoke("quantlab:save-candidates-store", store),
listDirectory: (targetPath, maxDepth) => ipcRenderer.invoke("quantlab:list-directory", targetPath, maxDepth),
readProjectText: (targetPath) => ipcRenderer.invoke("quantlab:read-project-text", targetPath),
readProjectJson: (targetPath) => ipcRenderer.invoke("quantlab:read-project-json", targetPath),
postJson: (relativePath, payload) => ipcRenderer.invoke("quantlab:post-json", relativePath, payload),
openExternal: (url) => ipcRenderer.invoke("quantlab:open-external", url),
openPath: (targetPath) => ipcRenderer.invoke("quantlab:open-path", targetPath),
Expand Down
Loading
Loading