Trim comments and docs to what the code needs

AI Assisted
This commit is contained in:
Seth committed 2026-12-05 13:19:59 -08:00
1 parent eba3c3bf0c
commit 0bd721fc27
33 files changed
+292 -392

No files matched your search

+5 -8
View File
@@ -20,9 +20,8 @@ const SERVER_JS = path.join(ROOT, "src", "web-console", "server.mjs");
// Boot a session server whose environment carries PLAN2CODE_EMBED_ORIGIN set
// to `origin` (or does not carry it at all when origin is undefined). Returns
// the child and its base URL; the caller always kills the child. `platform`
// fakes process.platform in the server before it loads (the whole server
// sees it, not only frameKey()), so the macOS-only frame sign-in is tested on
// every OS. `state` adds fields to state.json.
// fakes process.platform for the whole server, so the macOS-only frame sign-in
// is tested on every OS. `state` adds fields to state.json.
async function bootServer(origin, { platform, token = "t", state = {} } = {}) {
const dir = fs.mkdtempSync(path.join(HOME, "embed-"));
fs.writeFileSync(path.join(dir, "state.json"), JSON.stringify({ sid: path.basename(dir), phase: "collecting", ...state }));
@@ -148,8 +147,7 @@ function raw(port, urlPath, { method = "GET", headers = {}, body, head = false }
});
}
// The frame's key: a hash of the token, so the token the terminal prints
// never sits in the frame's address, and still 128 bits.
// The frame's key, as routes.mjs makes it from the token.
const frameKey = (token) => crypto.createHash("sha256").update(token).digest("hex").slice(0, 32);
// A real token's shape: 16 random bytes in base64url, uppercase included.
@@ -287,7 +285,7 @@ test("a browser tab on the macOS app's console keeps the cookie and `/`", async
assert.equal(signIn.status, 302);
assert.equal(signIn.headers.location, "/");
// The tauri://localhost cookie (cookieSameSite): Lax, never Secure,
// since Safari drops a Secure cookie on plain http.
// since WebKit drops a Secure cookie on plain http.
assert.match(String(signIn.headers["set-cookie"]), /HttpOnly; SameSite=Lax;/);
assert.doesNotMatch(String(signIn.headers["set-cookie"]), /Secure/);
const cookie = cookieFor(`http://127.0.0.1:${port}`, MIXED_TOKEN);
@@ -327,8 +325,7 @@ test("the frame prefix is off everywhere but the macOS app, where `/f/` is just
test("the page-closed signal is a keepalive fetch, which carries the page's origin, not a beacon", () => {
// A body-less sendBeacon is a no-cors POST: under the console's
// `referrer-policy: no-referrer` it goes out with `Origin: null`, which /bye's
// origin check refuses (WebKit showed it; the Fetch standard says every engine
// does the same). A keepalive fetch is a cors request and sends the real origin.
// origin check refuses. A keepalive fetch is a cors request and sends the real origin.
const core = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "screens", "core.js"), "utf8");
const wire = core.slice(core.indexOf("export function wireChrome()"));
const pagehide = wire.slice(0, wire.indexOf("});"));