feat(viewers): sort, filter, summarize, group and chart tables

The CSV/TSV viewer (explorer, gists, the author's preview) becomes an
analysis view that runs on the anonymized text already in the page:
click-to-sort headers (numbers, dates, natural text; stable, empty cells
last), a search box and per-column range or value filters, a summary row
(Average by default; Sum, Median, Min, Max, Count, Std dev) over the
filtered rows, group by with an aggregate, column stats with a histogram,
copy as CSV or Markdown and download of the current view, and a Chart
view (bar, line, scatter) drawn in inline SVG. The view lives in the URL
fragment (#table:group=model, #table-2:... for a gist file) so a link
can carry it; links without it open as before.

Markdown and notebook tables (pandas DataFrames) get sortable headers,
an optional summary row and "Open as table" for the full view.
Redaction slots keep rendering; sorting uses the XXXX-n text.

The 1 MB limit holds: rows render 200 at a time as one escaped HTML
string while aggregates, filters and charts use every row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Thomas DurieuxandClaude Opus 5.5 committed 2026-11-29 10:04:19 +00:00
1 parent 98bf382fa8
commit 43e92bef53
19 files changed
+2094 -98

No files matched your search

+58 -3
View File
@@ -447,7 +447,60 @@ const galleryNotebook = JSON.stringify({
{ cell_type: "code", execution_count: 4, metadata: {}, source: ["ax = df.groupby(\"model\").accuracy.mean().plot.bar()\n", "ax.figure.savefig(\"figures/accuracy.png\")"], outputs: [{ output_type: "display_data", metadata: {}, data: { "image/png": galleryPng.toString("base64"), "text/plain": ["<Figure size 720x400 with 1 Axes>"] } }] },
],
}, null, 1);
// Table viewer fixtures (tables/): a per-seed results table, a TSV with dates and
// thousands separators, a table with redacted cells, a README with a Markdown
// results table, and a ~1 MB CSV for the viewer's timing. All deterministic.
const tableRng = (seed) => () => { seed = (seed * 1103515245 + 12345) % 2147483648; return seed / 2147483648; };
const tableFixtures = (() => {
const rnd = tableRng(42);
const models = [["Baseline", 71.2, 410], ["+ Aug.", 74.0, 447], ["+ Pretrain", 76.1, 471], ["Ours", 78.9, 503]];
const perSeed = ["model,dataset,seed,accuracy,precision,recall,plausible"];
for (const [model, acc, plaus] of models) for (const [dataset, shift] of [["Defects4J", 0], ["QuixBugs", 3.6]]) for (let seed = 1; seed <= 5; seed++) {
const a = acc + shift + (rnd() - 0.5) * 0.8;
perSeed.push([model, dataset, seed, a.toFixed(1), (a / 100 + 0.04 + (rnd() - 0.5) * 0.02).toFixed(3), (a / 100 - 0.03 + (rnd() - 0.5) * 0.02).toFixed(3),
model === "+ Aug." && dataset === "QuixBugs" && seed === 3 ? "" : Math.round(plaus + shift * 8 + (rnd() - 0.5) * 10)].join(","));
}
const runs = ["date\tmodel\taccuracy\truntime_s\tdelta\tgpu_share"];
const start = Date.UTC(2026, 2, 2);
for (let day = 0; day < 14; day++) for (const [model, acc] of models.slice(1)) {
const date = new Date(start + day * 86400000).toISOString().slice(0, 10);
const a = acc - 4 + day * 0.32 + (rnd() - 0.5) * 0.9;
runs.push([date, model, a.toFixed(1), Math.round(900 + rnd() * 900 + (model === "Ours" ? 400 : 0)).toLocaleString("en-US"), (rnd() - 0.4).toFixed(2), (40 + rnd() * 55).toFixed(1) + "%"].join("\t"));
}
const redacted = [
"run,author,cluster,model,accuracy,notes",
"1,XXXX-1,XXXX-2,Ours,78.7,first run",
"2,XXXX-1,XXXX-2,Ours,79.1,",
"3,XXXX-4,XXXX-2,Baseline,71.0,rerun by XXXX-4",
"4,XXXX-4,XXXX-5,Baseline,71.4,",
"5,XXXX-1,XXXX-5,+ Aug.,74.2,\"uses XXXX-3's split, seed 2\"",
];
const large = ["run_id,date,model,dataset,seed,accuracy,f1,loss,latency_ms,coverage"];
const datasets = ["Defects4J", "QuixBugs", "Bears", "BugsInPy", "ManyBugs"];
let size = large[0].length + 1, id = 0;
while (true) {
const [model, acc] = models[id % 4];
const dataset = datasets[Math.floor(id / 4) % 5];
const a = acc - (datasets.indexOf(dataset) * 2.1) + (rnd() - 0.5) * 3;
const row = [id + 1, new Date(start + Math.floor(id / 40) * 3600000).toISOString().slice(0, 16).replace("T", " "), model, dataset, (id % 10) + 1,
a.toFixed(2), (a / 100 - 0.02).toFixed(3), (rnd() * 0.004).toExponential(2), '"' + Math.round(800 + rnd() * 2400).toLocaleString("en-US") + '"', (50 + rnd() * 50).toFixed(1) + "%"].join(",");
if (size + row.length + 1 > 1000 * 1024) break;
large.push(row); size += row.length + 1; id++;
}
return {
"tables/per-seed.csv": perSeed.join("\n") + "\n",
"tables/runs.tsv": runs.join("\n") + "\n",
"tables/redacted.csv": redacted.join("\n") + "\n",
"tables/benchmark-1mb.csv": large.join("\n") + "\n",
"tables/README.md": "# Result tables\n\nAccuracy (%) on each benchmark, averaged over five seeds. Runs by XXXX-1 on the XXXX-2 cluster.\n\n"
+ "| Model | Defects4J | QuixBugs | Bears | Train time (h) |\n| --- | ---: | ---: | ---: | ---: |\n"
+ "| Baseline | 71.2 | 75.0 | 52.4 | 3.1 |\n| + Aug. | 74.0 | 78.1 | 55.0 | 3.4 |\n| + Pretrain | 76.1 | 80.2 | 58.7 | 6.2 |\n| XXXX-3 | 77.5 | 81.0 | 59.9 | 5.8 |\n| Ours | 78.9 | 82.5 | 61.2 | 6.0 |\n\n"
+ "`per-seed.csv` has the runs behind this table; `runs.tsv` tracks the nightly evaluation.\n",
};
})();
const galleryText = {
...tableFixtures,
"README.md": "# Replication package\n\nArtifact for *Learning Robust Repair Strategies from Developer Histories*, prepared by XXXX-1.\n\n| File | What it shows |\n| --- | --- |\n| `paper.pdf` | The submitted paper |\n| `analysis.ipynb` | Notebook that rebuilds Table 2 and Figure 1 |\n| `figures/` | Figures as PNG and SVG |\n| `demo/` | A short screen recording of a full run |\n\n![Accuracy](figures/accuracy.png)\n",
"results.csv": "model,seed,accuracy,plausible\nBaseline,1,71.0,410\nBaseline,2,71.4,414\n+ Aug.,1,73.8,445\n+ Aug.,2,74.2,449\n+ Pretrain,1,76.0,470\n+ Pretrain,2,76.2,472\nOurs,1,78.7,501\nOurs,2,79.1,505\n",
"figures/pipeline.svg": '<svg xmlns="http://www.w3.org/2000/svg" width="640" height="200" viewBox="0 0 640 200" font-family="Inter, Arial, sans-serif" font-size="14"><rect width="640" height="200" fill="#ffffff"/><g fill="#eef6f4" stroke="#1f6f66" stroke-width="1.5"><rect x="20" y="70" width="150" height="60" rx="8"/><rect x="245" y="70" width="150" height="60" rx="8"/><rect x="470" y="70" width="150" height="60" rx="8"/></g><g fill="#1b1a18" text-anchor="middle"><text x="95" y="105">Mine histories</text><text x="320" y="105">Pretrain on edits</text><text x="545" y="105">Rank patches</text></g><g stroke="#6f6a61" stroke-width="1.5" marker-end="url(#a)"><line x1="172" y1="100" x2="240" y2="100"/><line x1="397" y1="100" x2="465" y2="100"/></g><defs><marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto"><path d="M0 0L10 5L0 10z" fill="#6f6a61"/></marker></defs></svg>\n',
@@ -463,7 +516,8 @@ const gallerySize = (name) =>
: name === "data/train.parquet" ? 312 * 1024 * 1024
: Buffer.byteLength(galleryText[name] || "");
const galleryTree = {
"": ["data", "demo", "figures", "logs", "models", "outputs", "README.md", "analysis.ipynb", "paper.pdf", "results.csv"],
"": ["data", "demo", "figures", "logs", "models", "outputs", "tables", "README.md", "analysis.ipynb", "paper.pdf", "results.csv"],
tables: ["README.md", "benchmark-1mb.csv", "per-seed.csv", "redacted.csv", "runs.tsv"],
data: ["train.parquet"],
demo: ["demo.mp4", "demo.webm"],
figures: ["accuracy.png", "pipeline.svg"],
@@ -479,7 +533,7 @@ app.get(`/api/repo/${GALLERY_ID}/options`, (req, res) =>
res.json({ url: null, download: true, lastUpdateDate: ago(5), anonymizedAt: ago(5), sourceCommitDate: ago(6), expirationDate: ahead(90), isAdmin: false, isOwner: false, hasWebsite: false, truncatedFolders: [], hasSubmodules: false })
);
app.get(`/api/repo/${GALLERY_ID}/files/counts`, (req, res) =>
res.json({ "": 13, data: 1, demo: 2, figures: 2, logs: 1, models: 1, outputs: 0 })
res.json({ "": 18, data: 1, demo: 2, figures: 2, logs: 1, models: 1, outputs: 0, tables: 5 })
);
app.get(`/api/repo/${GALLERY_ID}/files`, (req, res) => res.json(galleryFiles(req.query.path || "")));
app.get(`/api/repo/${GALLERY_ID}/file/{*rest}`, (req, res) => {
@@ -509,6 +563,7 @@ const sourceText = {
"src/jsmith-utils/io.js": "// Helpers shared by the evaluation scripts. Author: Jane Smith <jane.smith@csail.mit.edu>\nconst fs = require(\"fs\");\n\n/** Reads one JSON object per line. */\nfunction readJsonLines(path) {\n return fs.readFileSync(path, \"utf8\").split(\"\\n\").filter(Boolean).map((line) => JSON.parse(line));\n}\n\nmodule.exports = { readJsonLines, lab: \"MIT CSAIL\" };\n",
"paper/main.tex": "\\documentclass{article}\n\\title{Learning Robust Repair Strategies from Developer Histories}\n\\author{Jane Smith \\\\ MIT CSAIL}\n\n\\begin{document}\n\\maketitle\n\n\\section{Introduction}\nWe build on our earlier work~\\cite{smith2024repair}, done at MIT CSAIL.\n\n\\bibliographystyle{plain}\n\\bibliography{refs}\n\\end{document}\n",
"paper/refs.bib": "@inproceedings{smith2024repair,\n title = {Repairing Programs with Developer Histories},\n author = {Jane Smith and Ana Lopez},\n booktitle = {Proceedings of ICSE},\n year = {2024},\n note = {MIT CSAIL}\n}\n",
"results/per-seed.csv": "model,seed,accuracy,run_by\nBaseline,1,71.0,Jane Smith\nBaseline,2,71.4,Jane Smith\n+ Aug.,1,73.8,jsmith\n+ Aug.,2,74.2,jsmith\nOurs,1,78.7,MIT CSAIL\nOurs,2,79.1,MIT CSAIL\n",
"configs/base.yaml": "# Base configuration (Jane Smith)\ndata: data/train.jsonl\nmodel: transformer-small\nseed: 1\noutput: /home/jsmith/out\n",
"requirements.txt": "torch>=2.3\nnumpy\npyyaml\n",
LICENSE: "MIT License\n\nCopyright (c) 2026 Jane Smith\n",
@@ -1552,7 +1607,7 @@ const formatsGist = {
anonymizeDate: ago(2), isPublic: true, description: "Replication files for the XXXX-1 artifact, one of each format",
ownerLogin: "XXXX-3", creationDate: ago(12), updatedDate: ago(2),
files: [
{ filename: "README.md", language: "Markdown", type: "text/markdown", size: 320, content: "# Replication files\n\nOne file of each kind the reviewer page renders, prepared by XXXX-1.\n\n## Contents\n\n- `results.csv`: the per-seed table\n- `analysis.ipynb`: the notebook behind Figure 1\n\n## Contact\n\nThrough the conference system.\n" },
{ filename: "README.md", language: "Markdown", type: "text/markdown", size: 320, content: "# Replication files\n\nOne file of each kind the reviewer page renders, prepared by XXXX-1.\n\n## Contents\n\n- `results.csv`: the per-seed table\n- `analysis.ipynb`: the notebook behind Figure 1\n\n## Results\n\n| Model | Accuracy | Plausible |\n| --- | ---: | ---: |\n| Baseline | 71.2 | 412 |\n| + Aug. | 74.0 | 447 |\n| + Pretrain | 76.1 | 471 |\n| Ours | 78.9 | 503 |\n\n## Contact\n\nThrough the conference system.\n" },
{ filename: "results.csv", language: "CSV", type: "text/csv", size: galleryText["results.csv"].length, content: galleryText["results.csv"].replace("Baseline,1", "XXXX-2 baseline,1") },
{ filename: "analysis.ipynb", language: "Jupyter Notebook", type: "application/x-ipynb+json", size: galleryNotebook.length, content: galleryNotebook },
{ filename: "train.py", language: "Python", type: "application/x-python", size: 160, content: "# Copyright 2026 XXXX-1\nimport argparse\n\n\ndef main():\n parser = argparse.ArgumentParser()\n parser.add_argument(\"--seed\", type=int, default=1)\n print(parser.parse_args())\n" },