Spaces:
Paused
Paused
Deploy Seqcolyte Studio
Browse files- studio/src/lib/reportHtml.ts +1 -1
- studio/src/lib/runner.ts +47 -15
- studio/tsconfig.tsbuildinfo +0 -0
studio/src/lib/reportHtml.ts
CHANGED
|
@@ -100,7 +100,7 @@ const CHECK_KNOWLEDGE: Record<string, CheckKnowledge> = {
|
|
| 100 |
};
|
| 101 |
|
| 102 |
/** Resolve per-check knowledge, handling the spec-driven dynamic ids (r1/r2 adapter, anchor_*). */
|
| 103 |
-
function knowledgeFor(checkId: string): CheckKnowledge | undefined {
|
| 104 |
if (CHECK_KNOWLEDGE[checkId]) return CHECK_KNOWLEDGE[checkId];
|
| 105 |
if (checkId.endsWith("_adapter_readthrough")) return CHECK_KNOWLEDGE.adapter_readthrough;
|
| 106 |
if (checkId.startsWith("anchor_")) return CHECK_KNOWLEDGE.anchor;
|
|
|
|
| 100 |
};
|
| 101 |
|
| 102 |
/** Resolve per-check knowledge, handling the spec-driven dynamic ids (r1/r2 adapter, anchor_*). */
|
| 103 |
+
export function knowledgeFor(checkId: string): CheckKnowledge | undefined {
|
| 104 |
if (CHECK_KNOWLEDGE[checkId]) return CHECK_KNOWLEDGE[checkId];
|
| 105 |
if (checkId.endsWith("_adapter_readthrough")) return CHECK_KNOWLEDGE.adapter_readthrough;
|
| 106 |
if (checkId.startsWith("anchor_")) return CHECK_KNOWLEDGE.anchor;
|
studio/src/lib/runner.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { inProject, runDir } from "./paths";
|
|
| 5 |
import { allocateRun, getProject, getRun, updateRun } from "./store";
|
| 6 |
import { killGroup, spawnLogged } from "./spawn";
|
| 7 |
import { generateAllFixes } from "./remediate";
|
|
|
|
|
|
|
| 8 |
import type { QcReport, RunRecord, StepName, StepStatus } from "./types";
|
| 9 |
|
| 10 |
async function fileExists(p: string): Promise<boolean> {
|
|
@@ -276,26 +278,56 @@ async function driveRun(projectId: string, runId: string): Promise<void> {
|
|
| 276 |
}
|
| 277 |
}
|
| 278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
async function finalize(projectId: string, runId: string, status: StepStatus): Promise<void> {
|
| 280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
...r,
|
| 282 |
overallStatus: status,
|
| 283 |
finishedAt: now(),
|
| 284 |
}));
|
| 285 |
-
// Eager remediation: after a first-pass QC run (not a re-QC on cleaned reads) succeeds, auto-author
|
| 286 |
-
// fix scripts for every solvable finding in the background so they're waiting in Files.
|
| 287 |
-
if (status === "succeeded" && run.options.fastqSource !== "remediated") {
|
| 288 |
-
void (async () => {
|
| 289 |
-
try {
|
| 290 |
-
const report = JSON.parse(
|
| 291 |
-
await fs.readFile(path.join(runDir(projectId, runId), "qc_report.json"), "utf8"),
|
| 292 |
-
) as QcReport;
|
| 293 |
-
generateAllFixes(projectId, report);
|
| 294 |
-
} catch {
|
| 295 |
-
/* best effort — remediation is optional */
|
| 296 |
-
}
|
| 297 |
-
})();
|
| 298 |
-
}
|
| 299 |
}
|
| 300 |
|
| 301 |
/** Fire-and-forget launcher. The HTTP request returns immediately; this drives to completion. */
|
|
|
|
| 5 |
import { allocateRun, getProject, getRun, updateRun } from "./store";
|
| 6 |
import { killGroup, spawnLogged } from "./spawn";
|
| 7 |
import { generateAllFixes } from "./remediate";
|
| 8 |
+
import { appendConversation } from "./chat";
|
| 9 |
+
import { knowledgeFor } from "./reportHtml";
|
| 10 |
import type { QcReport, RunRecord, StepName, StepStatus } from "./types";
|
| 11 |
|
| 12 |
async function fileExists(p: string): Promise<boolean> {
|
|
|
|
| 278 |
}
|
| 279 |
}
|
| 280 |
|
| 281 |
+
/** A conversational diagnosis + suggested-fix summary from the report (posted after each QC run). */
|
| 282 |
+
function buildDiagnosisMessage(report: QcReport): string {
|
| 283 |
+
const issues = (report.findings ?? []).filter((f) => f.verdict === "fail" || f.verdict === "warn");
|
| 284 |
+
const verdict = (report.overall ?? "").toUpperCase();
|
| 285 |
+
const lines: string[] = [`**QC complete — overall ${verdict || "done"}.**`];
|
| 286 |
+
const plan = report.plan;
|
| 287 |
+
if (plan?.diagnosis) lines.push(plan.diagnosis);
|
| 288 |
+
else if (plan?.root_cause) lines.push(`Likely root cause: ${plan.root_cause}.`);
|
| 289 |
+
if (issues.length) {
|
| 290 |
+
lines.push("", "**Issues & suggested fixes:**");
|
| 291 |
+
for (const f of issues.slice(0, 6)) {
|
| 292 |
+
const inlineFix = /Fix:/i.test(f.detail);
|
| 293 |
+
const fix = inlineFix ? null : knowledgeFor(f.check_id)?.fix ?? null;
|
| 294 |
+
lines.push(`- **${f.title}** — ${f.detail}${fix ? `\n _Suggested fix:_ ${fix}` : ""}`);
|
| 295 |
+
}
|
| 296 |
+
} else {
|
| 297 |
+
lines.push("", "All checks passed — the reads are consistent with the expected structure.");
|
| 298 |
+
}
|
| 299 |
+
lines.push(
|
| 300 |
+
"",
|
| 301 |
+
"The full report (root cause + suggested fix per issue) is open in the viewer. Any " +
|
| 302 |
+
"computationally-fixable issue also appears in the **Computational fixes** panel below — tick " +
|
| 303 |
+
"them and Apply to clean the reads and re-score.",
|
| 304 |
+
);
|
| 305 |
+
return lines.join("\n");
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
async function finalize(projectId: string, runId: string, status: StepStatus): Promise<void> {
|
| 309 |
+
if (status === "succeeded") {
|
| 310 |
+
try {
|
| 311 |
+
const report = JSON.parse(
|
| 312 |
+
await fs.readFile(path.join(runDir(projectId, runId), "qc_report.json"), "utf8"),
|
| 313 |
+
) as QcReport;
|
| 314 |
+
// Post the diagnosis + suggested fixes into the conversation (not only in the report). Awaited
|
| 315 |
+
// BEFORE the status flips so the client's post-run hydrate always sees it.
|
| 316 |
+
await appendConversation(projectId, [
|
| 317 |
+
{ role: "assistant", text: buildDiagnosisMessage(report), ts: now() },
|
| 318 |
+
]);
|
| 319 |
+
// Eager remediation (fire-and-forget): only for a first-pass run, not a re-QC on cleaned reads.
|
| 320 |
+
const cur = await getRun(projectId, runId);
|
| 321 |
+
if (cur.options.fastqSource !== "remediated") generateAllFixes(projectId, report);
|
| 322 |
+
} catch {
|
| 323 |
+
/* best effort — diagnosis/remediation are optional */
|
| 324 |
+
}
|
| 325 |
+
}
|
| 326 |
+
await updateRun(projectId, runId, (r) => ({
|
| 327 |
...r,
|
| 328 |
overallStatus: status,
|
| 329 |
finishedAt: now(),
|
| 330 |
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
}
|
| 332 |
|
| 333 |
/** Fire-and-forget launcher. The HTTP request returns immediately; this drives to completion. */
|
studio/tsconfig.tsbuildinfo
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|