Skip to content

Instantly share code, notes, and snippets.

@juliusmarminge
Last active November 1, 2026 05:17
Show Gist options
  • Select an option

  • Save juliusmarminge/f1a48a8c359123d1b1460d48ca009a31 to your computer and use it in GitHub Desktop.

Select an option

Save juliusmarminge/f1a48a8c359123d1b1460d48ca009a31 to your computer and use it in GitHub Desktop.
t3code #28489 lead repro driver and timing runs (synthetic data)
#!/usr/bin/env bash
# The reporter's fixture: a git repo with N skills. usage: make-demo-project.sh <dir> <N>
set -euo pipefail
DIR=$1; N=$2; W=${#N}
mkdir -p "$DIR" && cd "$DIR" && git init -q
for i in $(seq -w 1 "$N"); do
mkdir -p ".agents/skills/demo-skill-$i"
printf -- '---\nname: demo-skill-%s\ndescription: Demo skill %s with a description about as long as a real one, so each row renders like a real skill.\n---\n\nDemo.\n' "$i" "$i" > ".agents/skills/demo-skill-$i/SKILL.md"
done
// Repro driver for pingdotgg/t3code#28489: measures key press -> first painted frame of the
// composer `/` and `$` menus and counts the mounted rows.
// usage: node measure-menu.mjs <playwrightDir> <webOrigin> <pairToken> <projectDir> <outDir> [samples]
import { createRequire } from "node:module";
import fs from "node:fs";
import path from "node:path";
const [playwrightDir, origin, token, projectDir, outDir, samplesArg] = process.argv.slice(2);
const samples = Number(samplesArg ?? 12);
const require = createRequire(path.join(playwrightDir, "package.json"));
const { chromium } = require("playwright");
fs.mkdirSync(outDir, { recursive: true });
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({ viewport: { width: 1440, height: 900 }, colorScheme: process.env.THEME === "dark" ? "dark" : "light", reducedMotion: "reduce" });
await page.goto(`${origin}/pair#token=${token}`);
await page.waitForSelector("button[aria-label='Add project']", { timeout: 60000 });
await page.click("button[aria-label='Add project']");
await page.getByText("Local folder", { exact: true }).click();
const pathInput = page.locator("[role=dialog] [role=combobox][aria-expanded=true]");
await pathInput.fill(projectDir.endsWith("/") ? projectDir : `${projectDir}/`);
await page.waitForTimeout(800);
await page.keyboard.press("Enter");
await page.waitForURL(/\/draft\//, { timeout: 30000 });
const editor = page.locator("[contenteditable=true]").first();
await editor.click();
// Reporter step 2: type one character so the project skills load, then clear.
await page.keyboard.type("a");
await page.waitForTimeout(5000);
await page.keyboard.press("Control+A");
await page.keyboard.press("Backspace");
await page.waitForTimeout(500);
await page.evaluate(() => {
const w = window;
w.__longTasks = [];
new PerformanceObserver((list) => {
for (const e of list.getEntries()) w.__longTasks.push(e.duration);
}).observe({ type: "longtask" });
const signature = () => {
const items = document.querySelectorAll("[data-composer-command-drawer] [data-composer-item-id]");
return `${items.length}:${items[0]?.getAttribute("data-composer-item-id") ?? ""}:${items[items.length - 1]?.getAttribute("data-composer-item-id") ?? ""}`;
};
w.__arm = () =>
new Promise((resolve) => {
const before = signature();
let t0 = null;
w.__longTasks = [];
window.addEventListener("keydown", () => (t0 = performance.now()), { capture: true, once: true });
const started = performance.now();
const measure = () => {
const items = document.querySelectorAll("[data-composer-command-drawer] [data-composer-item-id]");
const list = document.querySelector("[data-composer-command-drawer] [role=listbox]");
if (!list) return { mounted: 0, visible: 0, height: 0 };
const lr = list.getBoundingClientRect();
const visible = [...items].filter((el) => {
const r = el.getBoundingClientRect();
return r.bottom > lr.top + 1 && r.top < lr.bottom - 1;
}).length;
return { mounted: items.length, visible, height: Math.round(lr.height) };
};
let first = null;
let last = null;
let stableFrames = 0;
const tick = () => {
const now = signature();
if (t0 !== null && first === null && now !== before) {
first = { t: performance.now(), ...measure() };
last = JSON.stringify(measure());
} else if (first !== null) {
const m = JSON.stringify(measure());
if (m === last) stableFrames++;
else { stableFrames = 0; last = m; first.tSettled = performance.now(); }
if (stableFrames >= 10) {
const final = JSON.parse(last);
return resolve({
ms: Math.round(first.t - t0),
msSettled: Math.round((first.tSettled ?? first.t) - t0),
firstFrame: { mounted: first.mounted, visible: first.visible, height: first.height },
mounted: final.mounted, visible: final.visible, height: final.height,
longestTask: Math.round(Math.max(0, ...w.__longTasks)),
});
}
}
if (performance.now() - started > 5000) return resolve({ ms: null, mounted: null, visible: null, signature: now });
requestAnimationFrame(tick);
};
requestAnimationFrame(tick);
});
});
async function step(key) {
const result = page.evaluate(() => window.__arm());
await page.waitForTimeout(50);
await page.keyboard.press(key);
return result;
}
async function clear() {
await page.keyboard.press("Control+A");
await page.keyboard.press("Backspace");
await page.waitForTimeout(400);
}
const runs = { openSlash: [], filterSlash: [], openDollar: [], filterDollar: [] };
for (let i = 0; i < samples; i++) {
await clear();
runs.openSlash.push(await step("/"));
await page.waitForTimeout(300);
if (i === 0) await page.screenshot({ path: path.join(outDir, "slash-open.png") });
runs.filterSlash.push(await step("d"));
await page.waitForTimeout(300);
await clear();
runs.openDollar.push(await step("$"));
await page.waitForTimeout(300);
if (i === 0) await page.screenshot({ path: path.join(outDir, "dollar-open.png") });
runs.filterDollar.push(await step("d"));
await page.waitForTimeout(300);
}
const median = (xs) => {
const s = xs.filter((x) => x != null).sort((a, b) => a - b);
return s.length ? s[Math.floor(s.length / 2)] : null;
};
const p95 = (xs) => {
const s = xs.filter((x) => x != null).sort((a, b) => a - b);
return s.length ? s[Math.min(s.length - 1, Math.ceil(s.length * 0.95) - 1)] : null;
};
const summary = Object.fromEntries(
Object.entries(runs).map(([k, v]) => [
k,
{ medianMs: median(v.map((r) => r.ms)), medianSettledMs: median(v.map((r) => r.msSettled)), firstFrame: v[0]?.firstFrame, height: v[0]?.height, p95Ms: p95(v.map((r) => r.ms)), mounted: v[0]?.mounted, visible: v[0]?.visible, longestTaskMedian: median(v.map((r) => r.longestTask)), misses: v.filter((r) => r.ms == null).length },
]),
);
fs.writeFileSync(path.join(outDir, "runs.json"), JSON.stringify({ projectDir, samples, runs, summary }, null, 2));
console.log(JSON.stringify({ projectDir, summary }, null, 2));
await browser.close();
#!/usr/bin/env bash
# usage: run.sh <worktree> <webOrigin> <projectDir> <label> [samples]
set -euo pipefail
WT=$1; ORIGIN=$2; PROJ=$3; LABEL=$4; N=${5:-12}
TOK=$(cd "$WT/apps/server" && node src/bin.ts pair --base-dir "$WT/.t3" --ttl 30m 2>&1 | grep -oE 'token=[A-Z0-9]+' | head -1 | cut -d= -f2)
OUT=/tmp/issue-lead-28489-r1/runs/$LABEL-$(date +%H%M%S)
node /tmp/issue-lead-28489-r1/driver/measure-menu.mjs "$WT/node_modules/.pnpm/[email protected]/node_modules/playwright" "$ORIGIN" "$TOK" "$PROJ" "$OUT" "$N"
echo "OUT=$OUT"
[
{
"run": "main-10-022738",
"project": "demo-10",
"samples": 12,
"summary": {
"openSlash": {
"medianMs": 149,
"p95Ms": 203,
"mounted": 40,
"visible": 10,
"longestTaskMedian": 131,
"misses": 0
},
"filterSlash": {
"medianMs": 52,
"p95Ms": 64,
"mounted": 39,
"visible": 10,
"longestTaskMedian": 0,
"misses": 0
},
"openDollar": {
"medianMs": 155,
"p95Ms": 167,
"mounted": 36,
"visible": 10,
"longestTaskMedian": 130,
"misses": 0
},
"filterDollar": {
"medianMs": 51,
"p95Ms": 68,
"mounted": 35,
"visible": 10,
"longestTaskMedian": 0,
"misses": 0
}
}
},
{
"run": "main-200-022633",
"project": "demo-project",
"samples": 12,
"summary": {
"openSlash": {
"medianMs": 417,
"p95Ms": 497,
"mounted": 230,
"visible": 10,
"longestTaskMedian": 381,
"misses": 0
},
"filterSlash": {
"medianMs": 215,
"p95Ms": 243,
"mounted": 229,
"visible": 10,
"longestTaskMedian": 197,
"misses": 0
},
"openDollar": {
"medianMs": 380,
"p95Ms": 461,
"mounted": 226,
"visible": 10,
"longestTaskMedian": 348,
"misses": 0
},
"filterDollar": {
"medianMs": 201,
"p95Ms": 227,
"mounted": 225,
"visible": 10,
"longestTaskMedian": 181,
"misses": 0
}
}
},
{
"run": "main-1000-022833",
"project": "demo-1000",
"samples": 12,
"summary": {
"openSlash": {
"medianMs": 1068,
"p95Ms": 1259,
"mounted": 1030,
"visible": 10,
"longestTaskMedian": 1005,
"misses": 0
},
"filterSlash": {
"medianMs": 834,
"p95Ms": 894,
"mounted": 1029,
"visible": 10,
"longestTaskMedian": 784,
"misses": 0
},
"openDollar": {
"medianMs": 1028,
"p95Ms": 1170,
"mounted": 1026,
"visible": 10,
"longestTaskMedian": 971,
"misses": 0
},
"filterDollar": {
"medianMs": 791,
"p95Ms": 905,
"mounted": 1025,
"visible": 10,
"longestTaskMedian": 742,
"misses": 0
}
}
},
{
"run": "fix-10-024842",
"project": "demo-10",
"samples": 12,
"summary": {
"openSlash": {
"medianMs": 151,
"p95Ms": 167,
"mounted": 4,
"visible": 4,
"longestTaskMedian": 85,
"misses": 0
},
"filterSlash": {
"medianMs": 82,
"p95Ms": 98,
"mounted": 28,
"visible": 10,
"longestTaskMedian": 53,
"misses": 0
},
"openDollar": {
"medianMs": 149,
"p95Ms": 166,
"mounted": 4,
"visible": 4,
"longestTaskMedian": 95,
"misses": 0
},
"filterDollar": {
"medianMs": 67,
"p95Ms": 77,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 50,
"misses": 0
}
}
},
{
"run": "fix-200-024742",
"project": "demo-project",
"samples": 12,
"summary": {
"openSlash": {
"medianMs": 151,
"p95Ms": 173,
"mounted": 4,
"visible": 4,
"longestTaskMedian": 92,
"misses": 0
},
"filterSlash": {
"medianMs": 65,
"p95Ms": 79,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 62,
"misses": 0
},
"openDollar": {
"medianMs": 134,
"p95Ms": 164,
"mounted": null,
"visible": null,
"longestTaskMedian": 79,
"misses": 1
},
"filterDollar": {
"medianMs": 84,
"p95Ms": 94,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 55,
"misses": 0
}
}
},
{
"run": "fix-1000-024937",
"project": "demo-1000",
"samples": 12,
"summary": {
"openSlash": {
"medianMs": 158,
"p95Ms": 167,
"mounted": 4,
"visible": 4,
"longestTaskMedian": 96,
"misses": 0
},
"filterSlash": {
"medianMs": 101,
"p95Ms": 116,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 97,
"misses": 0
},
"openDollar": {
"medianMs": 150,
"p95Ms": 162,
"mounted": 4,
"visible": 4,
"longestTaskMedian": 87,
"misses": 0
},
"filterDollar": {
"medianMs": 115,
"p95Ms": 131,
"mounted": 28,
"visible": 10,
"longestTaskMedian": 87,
"misses": 0
}
}
},
{
"run": "fix-200-settle-025057",
"project": "demo-project",
"samples": 6,
"summary": {
"openSlash": {
"medianMs": 95,
"medianSettledMs": 142,
"firstFrame": {
"mounted": 4,
"visible": 4,
"height": 288
},
"height": 288,
"p95Ms": 106,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 95,
"misses": 0
},
"filterSlash": {
"medianMs": 62,
"medianSettledMs": 62,
"firstFrame": {
"mounted": 23,
"visible": 10,
"height": 288
},
"height": 288,
"p95Ms": 69,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 62,
"misses": 0
},
"openDollar": {
"medianMs": 99,
"medianSettledMs": 142,
"firstFrame": {
"mounted": 4,
"visible": 4,
"height": 288
},
"height": 288,
"p95Ms": 120,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 98,
"misses": 0
},
"filterDollar": {
"medianMs": 71,
"medianSettledMs": 93,
"firstFrame": {
"mounted": 23,
"visible": 10,
"height": 288
},
"height": 288,
"p95Ms": 79,
"mounted": 28,
"visible": 10,
"longestTaskMedian": 65,
"misses": 0
}
}
},
{
"run": "head-200-051501 (head 676ecd159a)",
"project": "demo-project",
"samples": 12,
"summary": {
"openSlash": {
"medianMs": 116,
"medianSettledMs": 142,
"firstFrame": {
"mounted": 13,
"visible": 10,
"height": 288
},
"height": 288,
"p95Ms": 128,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 115,
"misses": 0
},
"filterSlash": {
"medianMs": 69,
"medianSettledMs": 69,
"firstFrame": {
"mounted": 23,
"visible": 10,
"height": 288
},
"height": 288,
"p95Ms": 82,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 69,
"misses": 0
},
"openDollar": {
"medianMs": 119,
"medianSettledMs": 143,
"firstFrame": {
"mounted": 13,
"visible": 10,
"height": 288
},
"height": 288,
"p95Ms": 138,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 118,
"misses": 0
},
"filterDollar": {
"medianMs": 63,
"medianSettledMs": 63,
"firstFrame": {
"mounted": 23,
"visible": 10,
"height": 288
},
"height": 288,
"p95Ms": 78,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 63,
"misses": 0
}
}
},
{
"run": "head-1000-051620 (head 676ecd159a)",
"project": "demo-1000",
"samples": 12,
"summary": {
"openSlash": {
"medianMs": 119,
"medianSettledMs": 146,
"firstFrame": {
"mounted": 13,
"visible": 10,
"height": 288
},
"height": 288,
"p95Ms": 139,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 118,
"misses": 0
},
"filterSlash": {
"medianMs": 94,
"medianSettledMs": 94,
"firstFrame": {
"mounted": 23,
"visible": 10,
"height": 288
},
"height": 288,
"p95Ms": 107,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 94,
"misses": 0
},
"openDollar": {
"medianMs": 117,
"medianSettledMs": 146,
"firstFrame": {
"mounted": 13,
"visible": 10,
"height": 288
},
"height": 288,
"p95Ms": 132,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 117,
"misses": 0
},
"filterDollar": {
"medianMs": 89,
"medianSettledMs": 89,
"firstFrame": {
"mounted": 23,
"visible": 10,
"height": 288
},
"height": 288,
"p95Ms": 107,
"mounted": 23,
"visible": 10,
"longestTaskMedian": 89,
"misses": 0
}
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment