Make every URL the console page uses page-relative, guarded by a source test

AI Assisted
This commit is contained in:
Seth committed 2026-12-05 00:10:44 -08:00
1 parent 4ced32be5c
commit 1d007737b1
47 files changed
+401 -202

No files matched your search

+3 -1
View File
@@ -364,7 +364,9 @@ function imageEntries(dirs) {
return [...seen.values()].sort((a, b) => a.at - b.at || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
}
const imageUrl = (tab, id, thumb) => "/notepad/images/" + tab + "/" + id + (thumb ? ".thumb" : "") + ".jpg";
// Page-relative, as every link the page uses is: the macOS app's frame has the
// page under a path prefix (routes.mjs, takeFramePrefix).
const imageUrl = (tab, id, thumb) => "notepad/images/" + tab + "/" + id + (thumb ? ".thumb" : "") + ".jpg";
/**
* The tabs, as `[{ id, name, sent? }]` in order (`sent` only on a tab sent
+2 -2
View File
@@ -29,7 +29,7 @@
// per game. Adding a game is one file and one line here. No DOM access and no imports: the page and `node --test` both
// import this file.
const entry = (id, title, blurb, more = {}) => Object.freeze({ id, title, blurb, module: `/activities/${id}.js`, ...more });
const entry = (id, title, blurb, more = {}) => Object.freeze({ id, title, blurb, module: `activities/${id}.js`, ...more });
export const ACTIVITIES = Object.freeze([
entry("snake", "Snake", "Eat, grow and dodge. Every level brings something new.", { music: 70 }),
@@ -43,7 +43,7 @@ export const ACTIVITIES = Object.freeze([
entry("fuse", "Hot Potato", "Pass the bomb before it blows. Last one standing wins."),
entry("hop", "Crossing Rush", "Hop through traffic and rivers. Race your rivals to the top."),
entry("bounce", "Bounce Road", "Toy-car mayhem: jump, stomp, fire rockets and beat five bosses. No two runs alike.", { music: 70 }),
entry("ghoul", "Ghoul Rush", "Run and gun through a pitch-dark haunted house. Keep moving.", { music: 65, module: "/activities/ghoul-rush/ghoul.js" }),
entry("ghoul", "Ghoul Rush", "Run and gun through a pitch-dark haunted house. Keep moving.", { music: 65, module: "activities/ghoul-rush/ghoul.js" }),
entry("flock", "Flock Dash", "Lead your flock through the sunset sky. Dodge everything, keep the line.", { music: 70 }),
]);
+1 -1
View File
@@ -65,7 +65,7 @@ async function askAgain(button, status, reply) {
button.disabled = true;
button.textContent = "Asking…";
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ actions: [{ i: "__changes", type: "changes" }], reply }),
+7 -4
View File
@@ -14,7 +14,7 @@ export function blockBody(b, doc) {
if (typeof b.image !== "string") return md(b.md, "md");
const fig = el("figure", "doc-figure");
const img = el("img", "doc-img");
img.src = "/shots/" + b.image.split("/").pop();
img.src = "shots/" + b.image.split("/").pop();
// The caption already says it: an alt repeating it is read twice, and shows
// twice in an export whose picture would not load.
img.alt = "";
@@ -126,8 +126,9 @@ h4.md-h, h5.md-h, h6.md-h { font-size: 15px; }
// Only this session's uploaded images may ride along in a saved file: any other
// address on this origin (/state, say) would copy session data into something
// meant to be shared. A remote image keeps its own address; anything else on
// this origin becomes its alt text.
const INLINE_UPLOAD = /^\/(?:uploads\/[0-9a-f-]{36}\.jpg|shots\/[A-Za-z0-9][A-Za-z0-9._-]{0,99}\.(?:png|jpe?g|webp))$/i;
// this origin becomes its alt text. Matched on the path below the page's own
// folder: `/` in a browser tab, the frame's prefix in the macOS app.
const INLINE_UPLOAD = /^(?:uploads\/[0-9a-f-]{36}\.jpg|shots\/[A-Za-z0-9][A-Za-z0-9._-]{0,99}\.(?:png|jpe?g|webp))$/i;
function imageToAlt(img) {
const alt = img.getAttribute("alt") || "";
@@ -148,7 +149,9 @@ async function inlineImage(img) {
img.setAttribute("src", url.href);
return;
}
if (!INLINE_UPLOAD.test(url.pathname) || url.search) return imageToAlt(img);
const folder = new URL(".", location.href).pathname;
const below = url.pathname.startsWith(folder) ? url.pathname.slice(folder.length) : "";
if (!INLINE_UPLOAD.test(below) || url.search) return imageToAlt(img);
try {
const res = await fetch(url);
if (!res.ok) throw new Error(String(res.status));
+2 -2
View File
@@ -69,8 +69,8 @@ export function setFavicon(state) {
const svgLink = document.querySelector('link[rel="icon"][type="image/svg+xml"]');
const pngLink = document.querySelector('link[rel="icon"][type="image/png"]');
if (state === "plain") {
if (svgLink) svgLink.href = "/favicon.svg";
if (pngLink) pngLink.href = "/favicon.png";
if (svgLink) svgLink.href = "favicon.svg";
if (pngLink) pngLink.href = "favicon.png";
return;
}
const url = "data:image/svg+xml," + encodeURIComponent(faviconSvg(state));
+65 -65
View File
@@ -5,74 +5,74 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="color-scheme" content="light dark" />
<title>Plan2Code Console</title>
<link rel="stylesheet" href="/app.css" />
<link rel="stylesheet" href="app.css" />
<!-- Every module up front. Without these the browser finds render.js and
answers.js only once app.js has arrived and been parsed, and marked
only once render.js has: three round trips in a row before the page
can draw anything real. -->
<link rel="modulepreload" href="/app.js" />
<link rel="modulepreload" href="/answers.js" />
<link rel="modulepreload" href="/skills.js" />
<link rel="modulepreload" href="/spec-states.js" />
<link rel="modulepreload" href="/state.js" />
<link rel="modulepreload" href="/doc-files.js" />
<link rel="modulepreload" href="/diff-view.js" />
<link rel="modulepreload" href="/diff-parse.js" />
<link rel="modulepreload" href="/send-state.js" />
<link rel="modulepreload" href="/mention-box.js" />
<link rel="modulepreload" href="/uploads.js" />
<link rel="modulepreload" href="/sound.js" />
<link rel="modulepreload" href="/looks.js" />
<link rel="modulepreload" href="/selectors.js" />
<link rel="modulepreload" href="/screens/core.js" />
<link rel="modulepreload" href="/screens/ending.js" />
<link rel="modulepreload" href="/screens/docs.js" />
<link rel="modulepreload" href="/screens/cards.js" />
<link rel="modulepreload" href="/screens/starting.js" />
<link rel="modulepreload" href="/screens/dashboard.js" />
<link rel="modulepreload" href="/screens/git-host.js" />
<link rel="modulepreload" href="/screens/looks.js" />
<link rel="modulepreload" href="/screens/prefs-dialog.js" />
<link rel="modulepreload" href="/screens/agents-view.js" />
<link rel="modulepreload" href="/screens/agents/agents-data.js" />
<link rel="modulepreload" href="/screens/agents/agents-list-editor.js" />
<link rel="modulepreload" href="/screens/agents/agents-summary.js" />
<link rel="modulepreload" href="/screens/agents/agents-form.js" />
<link rel="modulepreload" href="/screens/agents/agents-strengths.js" />
<link rel="modulepreload" href="/strengths.js" />
<link rel="modulepreload" href="/screens/cleanup.js" />
<link rel="modulepreload" href="/screens/help-dialog.js" />
<link rel="modulepreload" href="/screens/workspace.js" />
<link rel="modulepreload" href="/screens/ask.js" />
<link rel="modulepreload" href="/screens/notepad.js" />
<link rel="modulepreload" href="/screens/activities.js" />
<link rel="modulepreload" href="/screens/setup.js" />
<link rel="modulepreload" href="/activities.js" />
<link rel="modulepreload" href="/tones.js" />
<link rel="modulepreload" href="/net.js" />
<link rel="modulepreload" href="/render.js" />
<link rel="modulepreload" href="/palette.js" />
<link rel="modulepreload" href="/labels.js" />
<link rel="modulepreload" href="/boot.js" />
<link rel="modulepreload" href="/chat.js" />
<link rel="modulepreload" href="/help.js" />
<link rel="modulepreload" href="/tabs.js" />
<link rel="modulepreload" href="/prefs.js" />
<link rel="modulepreload" href="/starters.js" />
<link rel="modulepreload" href="/workspace.js" />
<link rel="modulepreload" href="/meter.js" />
<link rel="modulepreload" href="/subagents.js" />
<link rel="modulepreload" href="/mentions.js" />
<link rel="modulepreload" href="/favicon.js" />
<link rel="modulepreload" href="/app-bridge.js" />
<link rel="modulepreload" href="/git-board.js" />
<link rel="modulepreload" href="/git-board-view.js" />
<link rel="modulepreload" href="/pr-url.js" />
<link rel="modulepreload" href="/vendor/marked.esm.js" />
<link rel="modulepreload" href="/notepad.js" />
<link rel="modulepreload" href="/notepad-tabs.js" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="icon" type="image/png" sizes="192x192" href="/favicon.png" />
<link rel="modulepreload" href="app.js" />
<link rel="modulepreload" href="answers.js" />
<link rel="modulepreload" href="skills.js" />
<link rel="modulepreload" href="spec-states.js" />
<link rel="modulepreload" href="state.js" />
<link rel="modulepreload" href="doc-files.js" />
<link rel="modulepreload" href="diff-view.js" />
<link rel="modulepreload" href="diff-parse.js" />
<link rel="modulepreload" href="send-state.js" />
<link rel="modulepreload" href="mention-box.js" />
<link rel="modulepreload" href="uploads.js" />
<link rel="modulepreload" href="sound.js" />
<link rel="modulepreload" href="looks.js" />
<link rel="modulepreload" href="selectors.js" />
<link rel="modulepreload" href="screens/core.js" />
<link rel="modulepreload" href="screens/ending.js" />
<link rel="modulepreload" href="screens/docs.js" />
<link rel="modulepreload" href="screens/cards.js" />
<link rel="modulepreload" href="screens/starting.js" />
<link rel="modulepreload" href="screens/dashboard.js" />
<link rel="modulepreload" href="screens/git-host.js" />
<link rel="modulepreload" href="screens/looks.js" />
<link rel="modulepreload" href="screens/prefs-dialog.js" />
<link rel="modulepreload" href="screens/agents-view.js" />
<link rel="modulepreload" href="screens/agents/agents-data.js" />
<link rel="modulepreload" href="screens/agents/agents-list-editor.js" />
<link rel="modulepreload" href="screens/agents/agents-summary.js" />
<link rel="modulepreload" href="screens/agents/agents-form.js" />
<link rel="modulepreload" href="screens/agents/agents-strengths.js" />
<link rel="modulepreload" href="strengths.js" />
<link rel="modulepreload" href="screens/cleanup.js" />
<link rel="modulepreload" href="screens/help-dialog.js" />
<link rel="modulepreload" href="screens/workspace.js" />
<link rel="modulepreload" href="screens/ask.js" />
<link rel="modulepreload" href="screens/notepad.js" />
<link rel="modulepreload" href="screens/activities.js" />
<link rel="modulepreload" href="screens/setup.js" />
<link rel="modulepreload" href="activities.js" />
<link rel="modulepreload" href="tones.js" />
<link rel="modulepreload" href="net.js" />
<link rel="modulepreload" href="render.js" />
<link rel="modulepreload" href="palette.js" />
<link rel="modulepreload" href="labels.js" />
<link rel="modulepreload" href="boot.js" />
<link rel="modulepreload" href="chat.js" />
<link rel="modulepreload" href="help.js" />
<link rel="modulepreload" href="tabs.js" />
<link rel="modulepreload" href="prefs.js" />
<link rel="modulepreload" href="starters.js" />
<link rel="modulepreload" href="workspace.js" />
<link rel="modulepreload" href="meter.js" />
<link rel="modulepreload" href="subagents.js" />
<link rel="modulepreload" href="mentions.js" />
<link rel="modulepreload" href="favicon.js" />
<link rel="modulepreload" href="app-bridge.js" />
<link rel="modulepreload" href="git-board.js" />
<link rel="modulepreload" href="git-board-view.js" />
<link rel="modulepreload" href="pr-url.js" />
<link rel="modulepreload" href="vendor/marked.esm.js" />
<link rel="modulepreload" href="notepad.js" />
<link rel="modulepreload" href="notepad-tabs.js" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<link rel="icon" type="image/png" sizes="192x192" href="favicon.png" />
</head>
<body>
<a class="skip" href="#main">Skip to the questions</a>
@@ -4653,6 +4653,6 @@
</footer>
<!-- p2c:boot -->
<script type="module" src="/app.js"></script>
<script type="module" src="app.js"></script>
</body>
</html>
+2 -2
View File
@@ -139,7 +139,7 @@ export async function syncLooks() {
if (boot && "looks" in boot) saved = boot.looks ? { looks: boot.looks } : null;
else {
try {
const res = await fetch("/looks");
const res = await fetch("looks");
if (res.ok) saved = await res.json();
} catch {}
}
@@ -184,7 +184,7 @@ function pushLooks() {
undo();
return { ok: false, error: error || "Could not save." };
};
return fetch("/looks", {
return fetch("looks", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(body),
+1 -1
View File
@@ -61,7 +61,7 @@ export function makeMdField({ id, className, value = "", placeholder: hint, labe
host.className = "md-host" + (className ? " " + className : "");
if (id) host.id = id;
const root = host.attachShadow({ mode: "open" });
const sheets = ["/notepad-editor.css", "/md-field.css"].map((href) => {
const sheets = ["notepad-editor.css", "md-field.css"].map((href) => {
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = href;
+1 -1
View File
@@ -413,7 +413,7 @@ let songTicker = null;
function songElement(name) {
if (!songAudio.has(name)) {
const el = new Audio(`/${SONGS[name]}`);
const el = new Audio(SONGS[name]);
el.preload = "auto";
el.volume = 0;
songAudio.set(name, el);
+1 -1
View File
@@ -208,7 +208,7 @@ export function makeCodeMirrorEditor(parent, { onChange, label }) {
const root = host.attachShadow({ mode: "open" });
const sheet = document.createElement("link");
sheet.rel = "stylesheet";
sheet.href = "/notepad-editor.css";
sheet.href = "notepad-editor.css";
const mount = document.createElement("div");
mount.className = "notepad-cm";
root.append(sheet, mount);
+1 -1
View File
@@ -73,7 +73,7 @@ function safeHref(href) {
if (!href) return null;
const trimmed = String(href).trim();
const kept = KEPT_ATTACHMENT.exec(trimmed);
if (kept) return "/attachments/" + kept[1].toLowerCase();
if (kept) return "attachments/" + kept[1].toLowerCase();
// Blocks javascript: and data: hrefs before they can reach the DOM, and a
// protocol-relative `//host` (or `/\host`), which leaves the page for another site.
return SAFE_PROTOCOL.test(trimmed) ? trimmed : null;
+3 -1
View File
@@ -654,7 +654,9 @@ async function loadGame(entry) {
if (games.has(entry.id)) return games.get(entry.id);
if (!loading.has(entry.id)) {
const made = (async () => {
const def = entry.game || (await import(entry.module)).default;
// `module` is page-relative, as every URL the page uses is, and import()
// takes no bare path: resolved against the page, as fetch() would.
const def = entry.game || (await import(new URL(entry.module, document.baseURI).href)).default;
defs.set(entry.id, def);
if (def.lowerIsBetter) lowerIsBetter.add(entry.id);
else lowerIsBetter.delete(entry.id);
+10 -10
View File
@@ -306,7 +306,7 @@ export function mountAgentsView(container, opts = {}) {
let state = ctx.templateState.get(command) || "unknown";
if (state === "unknown") {
try {
const res = await fetch("/agents/test", {
const res = await fetch("agents/test", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ command }),
@@ -337,7 +337,7 @@ export function mountAgentsView(container, opts = {}) {
rows.map(async (row) => {
let state = "unknown";
try {
const res = await fetch("/agents/test", {
const res = await fetch("agents/test", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ command: row.command }),
@@ -355,7 +355,7 @@ export function mountAgentsView(container, opts = {}) {
// The command's Test: where it would run from. Never saves.
async function testCommand(command) {
try {
const res = await fetch("/agents/test", {
const res = await fetch("agents/test", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ command }),
@@ -373,7 +373,7 @@ export function mountAgentsView(container, opts = {}) {
// press is the one failure the status line gets.
async function useFromHere(entry) {
try {
const res = await fetch("/agents/use-path", {
const res = await fetch("agents/use-path", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ id: entry.id }),
@@ -436,7 +436,7 @@ export function mountAgentsView(container, opts = {}) {
const modelIds = [...ctx.saved.shipped[cli], ...sent].map((m) => m.id);
const payload = { models: { ...ctx.saved.user, [cli]: sent } };
if (ctx.modelsLoaded) payload.strengths = strengthsToSend(cli, key, modelIds);
const { res, body } = await postJson("/models", payload);
const { res, body } = await postJson("models", payload);
if (!res.ok) {
formMark({ ok: false, error: body.error || "Could not save." });
return false;
@@ -465,7 +465,7 @@ export function mountAgentsView(container, opts = {}) {
const agents = ctx.saved.agents.map((a) => cleanAgent(a));
agents.splice(at, isNew ? 0 : 1, cleanAgent(draft));
try {
const { res, body } = await postJson("/agents", replace ? { agents, replace: true } : { agents });
const { res, body } = await postJson("agents", replace ? { agents, replace: true } : { agents });
if (res.status === 409) {
ctx.formError = { field: null, error: body.error || "Not saved." };
ctx.formReplace = Array.isArray(body.warnings) ? body.warnings : [];
@@ -504,7 +504,7 @@ export function mountAgentsView(container, opts = {}) {
return false;
};
try {
const { res, body } = await postJson("/models", { models: ctx.saved.user, strengths: strengthsToSend(id, key, modelIds) });
const { res, body } = await postJson("models", { models: ctx.saved.user, strengths: strengthsToSend(id, key, modelIds) });
if (!res.ok) return strengthsFailed(body.error || "Saved, but the strengths could not be.");
ctx.saved.strengths.user = body.strengths || {};
} catch {
@@ -526,7 +526,7 @@ export function mountAgentsView(container, opts = {}) {
const agents = ctx.saved.agents.filter((a) => a.id !== agentId(key)).map(cleanAgent);
ctx.confirming = false;
try {
const { res, body } = await postJson("/agents", { agents });
const { res, body } = await postJson("agents", { agents });
if (!res.ok) {
ctx.formError = { field: null, error: body.error || "Could not delete." };
drawForm(ctx);
@@ -592,8 +592,8 @@ export function mountAgentsView(container, opts = {}) {
ctx.formReplace = null;
ctx.confirming = false;
const [agents, models] = await Promise.all([
fetch("/agents").then((r) => (r.ok ? r.json() : null)).catch(() => null),
mode === "setup" ? Promise.resolve(null) : fetch("/models").then((r) => (r.ok ? r.json() : null)).catch(() => null),
fetch("agents").then((r) => (r.ok ? r.json() : null)).catch(() => null),
mode === "setup" ? Promise.resolve(null) : fetch("models").then((r) => (r.ok ? r.json() : null)).catch(() => null),
]);
if (seq !== loadSeq) return;
const problems = [];
+4 -4
View File
@@ -592,7 +592,7 @@ async function postChat(pend) {
let res = null;
let body = {};
try {
res = await fetch("/chat", {
res = await fetch("chat", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
@@ -641,7 +641,7 @@ async function newConversation() {
let res = null;
let body = {};
try {
res = await fetch("/chat", {
res = await fetch("chat", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ reset: true, conversation: askConversation() }),
@@ -674,7 +674,7 @@ async function decideChat(re, decision, text) {
let ok = false;
let body = {};
try {
const res = await fetch("/chat/decision", {
const res = await fetch("chat/decision", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ re, decision, text: text.trim() || undefined, conversation: askConversation() }),
@@ -1176,7 +1176,7 @@ export async function saveSubagents() {
};
save.disabled = true;
status.textContent = "";
const res = await postJson("/subagents", body);
const res = await postJson("subagents", body);
save.disabled = false;
// The next state frame redraws the button.
if (res.status === 200) {
+2 -2
View File
@@ -141,7 +141,7 @@ async function scanCleanup() {
$("cleanup-scan").disabled = true;
$("cleanup-delete").disabled = true;
setCleanupStatus("Looking…", false);
const { status, body } = await postJson("/cleanup", { scan: true });
const { status, body } = await postJson("cleanup", { scan: true });
if (gen !== cleanupGen) return;
$("cleanup-scan").disabled = false;
$("cleanup-delete").disabled = false;
@@ -169,7 +169,7 @@ async function deleteCleanup() {
$("cleanup-scan").disabled = true;
setCleanupStatus("Deleting…", false);
cleanupBusy = true;
const { status, body } = await postJson("/cleanup", { delete: ids }).finally(() => {
const { status, body } = await postJson("cleanup", { delete: ids }).finally(() => {
cleanupBusy = false;
});
if (gen !== cleanupGen) return;
+12 -12
View File
@@ -234,7 +234,7 @@ function fillNoteBox() {
async function seedNoteBox(item, ns) {
const tab = encodeURIComponent(ns.tab);
try {
const res = await fetch("/notepad?tab=" + tab, { cache: "no-store" });
const res = await fetch("notepad?tab=" + tab, { cache: "no-store" });
if (res.status === 404) {
banner("That Notebook tab is gone; the box starts empty.", "warn");
return;
@@ -251,7 +251,7 @@ async function seedNoteBox(item, ns) {
const files = await Promise.all(
(ns.pictures || []).map(async (id) => {
try {
const r = await fetch("/notepad/images/" + tab + "/" + encodeURIComponent(id) + ".jpg", { cache: "no-store" });
const r = await fetch("notepad/images/" + tab + "/" + encodeURIComponent(id) + ".jpg", { cache: "no-store" });
return r.ok ? new File([await r.blob()], id + ".jpg", { type: "image/jpeg" }) : null;
} catch {
return null;
@@ -264,7 +264,7 @@ async function seedNoteBox(item, ns) {
async function pushDraft() {
try {
await fetch("/draft", {
await fetch("draft", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ staged: page.local.staged, drafts: page.local.drafts, images: page.local.images, seeded: page.local.seeded }),
@@ -284,7 +284,7 @@ function agentStale() {
export async function loadState() {
try {
const res = await fetch("/state", { cache: "no-store" });
const res = await fetch("state", { cache: "no-store" });
if (!res.ok) throw new Error(String(res.status));
const body = await res.json();
// The same rev is the same state: adopting it again would redraw the page
@@ -759,7 +759,7 @@ function markGone() {
export function connect() {
esErrors = 0;
try {
es = new EventSource(lastHave ? "/events?have=" + encodeURIComponent(lastHave) : "/events");
es = new EventSource(lastHave ? "events?have=" + encodeURIComponent(lastHave) : "events");
} catch {
es = null;
return startPolling();
@@ -846,7 +846,7 @@ function retryStream() {
// whether the agent is, whether a state frame went missing, and whether a
// send is still waiting to be picked up.
export function checkIn() {
fetch("/ping", { method: "POST" })
fetch("ping", { method: "POST" })
.then((r) => (r.ok ? r.json() : null))
.then((body) => {
if (!body) return;
@@ -2194,7 +2194,7 @@ export function markSent({ sentIds, sentNotes = {}, summaries, values }) {
const ns = page.local.noteSent;
if (ns && sentIds.has(ns.item)) {
page.local.noteSent = null;
fetch("/notepad/tab/sent", {
fetch("notepad/tab/sent", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ id: ns.tab, workflow: ns.workflow, ...(ns.spec ? { spec: ns.spec } : {}) }),
@@ -2223,7 +2223,7 @@ export async function askSuggestions(itemId) {
const text = note ? note.text : "";
const images = note ? note.images : [];
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
@@ -2275,7 +2275,7 @@ export async function send() {
$("send-nudge").hidden = true;
btn.textContent = "Sending…";
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ actions, reply: replyLines.join("\n") }),
@@ -2327,7 +2327,7 @@ export async function send() {
// server is the lost-contact state now, with its reconnect help; a server
// still there was a blip, and Send is the whole fix.
async function sendLost() {
const up = await fetch("/state", { cache: "no-store" })
const up = await fetch("state", { cache: "no-store" })
.then((res) => res.ok)
.catch(() => false);
if (up) {
@@ -2489,7 +2489,7 @@ let whereResizeTimer = null;
// A link the console could not hand to a browser is shown, with a Copy
// button, for the person to paste into one.
async function openOutside(href) {
const ok = await fetch("/open-link", {
const ok = await fetch("open-link", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ url: href }),
@@ -2507,7 +2507,7 @@ export function wireChrome() {
// with `referrer-policy: no-referrer` with `Origin: null`, which /bye's
// origin check refuses.
try {
fetch("/bye", { method: "POST", keepalive: true }).catch(() => {});
fetch("bye", { method: "POST", keepalive: true }).catch(() => {});
} catch {}
// A page that goes away leaves no dot on the app's taskbar behind it.
tellAttention("plain");
+10 -10
View File
@@ -387,7 +387,7 @@ function maybeWake() {
page.wake = { cards: false, entered: false, typed: 0, timers: [], abort: new AbortController() };
wakeHoldsChime = !matchMedia("(prefers-reduced-motion: reduce)").matches;
if (wakeHoldsChime && soundOn("snore")) {
snore = new Audio("/sleeping.mp3");
snore = new Audio("sleeping.mp3");
snore.loop = true;
snore.play().catch(() => {});
}
@@ -709,7 +709,7 @@ async function pickUpHandoff(h) {
page.launchScoping = true;
await hooks.syncWorkspaceScope(h.spec || "");
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ actions: [pickupAction(h)], reply: pickupReply(h) }),
@@ -741,7 +741,7 @@ async function readHandoff(h) {
body.replaceChildren(el("p", "md-p", "Reading…"));
$("handoff-modal").showModal();
try {
const res = await fetch("/handoff?id=" + encodeURIComponent(h.id), { cache: "no-store" });
const res = await fetch("handoff?id=" + encodeURIComponent(h.id), { cache: "no-store" });
if (res.status !== 200) throw new Error(String(res.status));
mdInto(body, await res.text());
} catch {
@@ -836,14 +836,14 @@ export function pendingNotePick(entry) {
// grayed, so each must be read). Read only: GET /notepad never writes.
async function readNoteTabs(state) {
try {
const res = await fetch("/notepad", { cache: "no-store" });
const res = await fetch("notepad", { cache: "no-store" });
if (!res.ok) throw new Error(String(res.status));
const body = await res.json();
const tabs = Array.isArray(body.tabs) ? body.tabs : [];
const read = await Promise.all(
tabs.map(async (t) => {
try {
const r = await fetch("/notepad?tab=" + encodeURIComponent(t.id), { cache: "no-store" });
const r = await fetch("notepad?tab=" + encodeURIComponent(t.id), { cache: "no-store" });
if (!r.ok) return null;
const b = await r.json();
return b && b.tab ? { text: typeof b.tab.text === "string" ? b.tab.text : "", images: Array.isArray(b.tab.images) ? b.tab.images : [] } : null;
@@ -1243,7 +1243,7 @@ export async function launchSkill(entry) {
page.launchScoping = true;
await hooks.syncWorkspaceScope(target ? target.dir : "");
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
@@ -1390,7 +1390,7 @@ async function sendDeleteHandoff(h) {
const go = $("delete-go");
go.disabled = true;
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ actions: [deleteHandoffAction(h)], reply: deleteHandoffReply(h) }),
@@ -1422,7 +1422,7 @@ async function sendDelete(spec) {
const go = $("delete-go");
go.disabled = true;
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ actions: [deleteAction(spec)], reply: deleteReply(spec) }),
@@ -1512,7 +1512,7 @@ function learningBanner(sc) {
// quiet: the nudge simply stays, as it did before.
async function quietTidyNudge() {
try {
await postJson("/learning/tidy-quiet", {});
await postJson("learning/tidy-quiet", {});
} catch {}
redraw();
}
@@ -1582,7 +1582,7 @@ export async function sendLearning(what) {
if (what === "review" || what === "tidy") watchLearningBusy(busy);
}
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ actions: [learningAction(what)], reply: learningReply(what) }),
+2 -2
View File
@@ -82,7 +82,7 @@ export async function sendBrief() {
go.disabled = true;
go.textContent = "Asking…";
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
@@ -322,7 +322,7 @@ export function renderAgentsDoc(main) {
// default browser (the app's webview opens no windows, and a page served over
// http cannot open a file:// link). A failure says so on the banner.
async function openPrototypePage(spec, name) {
const ok = await fetch("/open-prototype", {
const ok = await fetch("open-prototype", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ spec, name }),
+4 -4
View File
@@ -195,7 +195,7 @@ let loopLessons = { key: null, line: "" };
function loopLessonsFor(key) {
if (loopLessons.key === key) return loopLessons.line;
loopLessons = { key, line: "" };
fetch("/learning/state", { cache: "no-store" })
fetch("learning/state", { cache: "no-store" })
.then((res) => (res.ok ? res.json() : null))
.then((learning) => {
const line = loopLessonsLine(learning);
@@ -907,7 +907,7 @@ const AFTER_FINISH_REPLIES = { review: REVIEW_REPLY, done: DONE_REPLY, dashboard
async function sendAfterBuild(kind, launch = null) {
if (page.gone || page.pendingResult || page.local.afterBuild) return;
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
@@ -1100,7 +1100,7 @@ async function goHome() {
const payload = hooks.stagedPayload();
payload.actions.push({ i: "__dashboard", type: "dashboard" });
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ actions: payload.actions, reply: [...payload.replyLines, HOME_REPLY].join("\n") }),
@@ -1180,7 +1180,7 @@ async function stopSession(handoff = false) {
const payload = hooks.stagedPayload();
payload.actions.push(stopAction({ handoff }));
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ actions: payload.actions, reply: [...payload.replyLines, handoff ? STOP_HANDOFF_REPLY : STOP_REPLY].join("\n") }),
+2 -2
View File
@@ -144,7 +144,7 @@ async function sendGit(op, fields = {}, wording = {}) {
return;
}
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
@@ -281,7 +281,7 @@ function gitTabKeys(e) {
// the action that follows has the agent re-read, which rebuilds the link.
async function pickPrHost(host, kind) {
if (gitLocked()) return;
const res = await postJson("/pr-host", { host, kind });
const res = await postJson("pr-host", { host, kind });
if (res.status !== 200) {
hooks.banner("That could not be saved. Try again in a moment.", "warn");
return;
@@ -209,7 +209,7 @@ let helpTabs = null;
async function renderHelpVersion() {
const slot = $("help-version");
try {
const res = await fetch("/version", { cache: "no-store" });
const res = await fetch("version", { cache: "no-store" });
const { version } = res.ok ? await res.json() : {};
slot.replaceChildren(...(version ? [releasesLink("Plan2Code v" + version)] : []));
slot.hidden = !version;
@@ -86,7 +86,7 @@ function pauseSwitch(paused) {
if (pausing) return;
pausing = true;
redraw();
const { status } = await postJson("/learning/pause", { paused: !paused });
const { status } = await postJson("learning/pause", { paused: !paused });
pausing = false;
if (status !== 200) {
hooks.banner(
@@ -567,7 +567,7 @@ async function openLessons() {
body.replaceChildren(el("p", "md-p", "Reading…"));
dlg.showModal();
try {
const res = await fetch("/learning/lessons", { cache: "no-store" });
const res = await fetch("learning/lessons", { cache: "no-store" });
if (res.status !== 200) throw new Error(String(res.status));
const { files, follows } = await res.json();
body.replaceChildren();
+5 -5
View File
@@ -61,7 +61,7 @@ export async function openLoopSetup(spec) {
const mine = page.loopSetup;
let res;
try {
res = await fetch("/loop-setup?spec=" + encodeURIComponent(dir), { cache: "no-store" });
res = await fetch("loop-setup?spec=" + encodeURIComponent(dir), { cache: "no-store" });
} catch {
res = null;
}
@@ -129,7 +129,7 @@ function ensureResolved(s) {
s.facts.resolved = null;
return;
}
fetch("/loop-setup?spec=" + encodeURIComponent(s.spec) + "&agent=" + encodeURIComponent(agent), { cache: "no-store" })
fetch("loop-setup?spec=" + encodeURIComponent(s.spec) + "&agent=" + encodeURIComponent(agent), { cache: "no-store" })
.then((res) => (res.ok ? res.json() : null))
.catch(() => null)
.then((answer) => {
@@ -371,7 +371,7 @@ async function askForSuggestion(s, words) {
strengths: words,
};
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ actions: [action], reply: `Suggest a strength for each phase left in ${s.spec}.` }),
@@ -741,7 +741,7 @@ async function sendTest(s) {
s.problems = [];
page.loopNotifyTest = { waiting: true };
redraw();
const { status, body: answer } = await postJson("/loop-setup", setupBody(f, s));
const { status, body: answer } = await postJson("loop-setup", setupBody(f, s));
if (page.loopSetup !== s) return;
if (status !== 200 || !answer || answer.ok !== true) {
page.loopNotifyTest = null;
@@ -759,7 +759,7 @@ async function startLoop(s) {
page.loopStart = null;
s.starting = true;
redraw();
const { status, body: answer } = await postJson("/loop-setup", setupBody(f, s));
const { status, body: answer } = await postJson("loop-setup", setupBody(f, s));
if (page.loopSetup !== s) return;
if (status !== 200 || !answer || answer.ok !== true) {
s.starting = false;
+10 -10
View File
@@ -160,7 +160,7 @@ async function send() {
sending = true;
const sent = rev;
const tab = saveTab;
const res = await postJson("/notepad/text?tab=" + tab, { text: editor.getValue() });
const res = await postJson("notepad/text?tab=" + tab, { text: editor.getValue() });
sending = false;
// The tab was deleted or left behind while this was out: nothing in the
// answer applies to what is on screen now.
@@ -231,7 +231,7 @@ async function makeEditor() {
// be reached or answered oddly.
async function readNote(tab) {
try {
const res = await fetch("/notepad" + (tab ? "?tab=" + encodeURIComponent(tab) : ""), { cache: "no-store" });
const res = await fetch("notepad" + (tab ? "?tab=" + encodeURIComponent(tab) : ""), { cache: "no-store" });
let body = null;
try {
body = await res.json();
@@ -323,7 +323,7 @@ async function showTab(id, remember = true) {
return false;
}
show(res.body);
if (remember && activeId) postJson("/notepad/tab/last", { id: activeId });
if (remember && activeId) postJson("notepad/tab/last", { id: activeId });
return true;
}
@@ -349,7 +349,7 @@ async function reorder(order, focus) {
tabBar.focusTab(focus);
const at = order.indexOf(focus);
if (at >= 0) inform(`Moved ${nameOf(focus)} to position ${at + 1} of ${order.length}`);
const res = await postJson("/notepad/tab/order", { order });
const res = await postJson("notepad/tab/order", { order });
if (res.status === 200) return;
// Refused: draw what the server has, and say why.
tabs = before;
@@ -438,7 +438,7 @@ function closeNameForm(toFocus = true) {
async function createNamed(name) {
// The tab on screen is saved first, then the new one is made and shown.
if (!(await settled())) return nameError(STAY);
const res = await postJson("/notepad/tab", { name });
const res = await postJson("notepad/tab", { name });
const id = res.body && res.body.id;
if (res.status !== 200 || !TAB_ID_RE.test(String(id))) {
return nameError(errorSentence(res.status === 0 ? null : res.body && res.body.error));
@@ -456,7 +456,7 @@ async function createNamed(name) {
async function renameTo(name) {
const id = activeId;
const res = await postJson("/notepad/tab/rename", { id, name });
const res = await postJson("notepad/tab/rename", { id, name });
if (res.status !== 200) {
const code = res.status === 0 ? null : res.body && res.body.error;
if (code !== "no-such-tab") return nameError(errorSentence(code));
@@ -530,7 +530,7 @@ async function confirmDelete() {
busy = true;
drawTabs();
paintDelete();
const res = await postJson("/notepad/tab/delete", { id });
const res = await postJson("notepad/tab/delete", { id });
const code = res.status === 0 ? null : res.body && res.body.error;
busy = false;
stage = "none";
@@ -592,14 +592,14 @@ async function upload(entry) {
entry.status = "uploading";
if (live(entry)) drawStrip();
if (!entry.id) {
const res = await postJpeg("/notepad/image?tab=" + entry.tab, encoded.blob);
const res = await postJpeg("notepad/image?tab=" + entry.tab, encoded.blob);
const id = res.body && res.body.id;
if (res.status !== 200 || !IMAGE_ID_RE.test(String(id))) return failed(entry, res);
entry.id = id;
// The server names the URL (it carries the tab).
entry.url = res.body.url;
}
const res = await postJpeg("/notepad/thumb?id=" + entry.id + "&tab=" + entry.tab, encoded.thumbBlob);
const res = await postJpeg("notepad/thumb?id=" + entry.id + "&tab=" + entry.tab, encoded.thumbBlob);
if (res.status !== 200) return failed(entry, res);
pending.delete(entry.key);
entry.status = "ready";
@@ -756,7 +756,7 @@ async function remove(entry) {
if (entry.id) {
entry.deleting = true;
drawStrip();
const res = await postJson("/notepad/image/delete?tab=" + entry.tab, { id: entry.id });
const res = await postJson("notepad/image/delete?tab=" + entry.tab, { id: entry.id });
entry.deleting = false;
// The tab was left (or deleted) while this was out: nothing here to update.
if (!live(entry)) return;
@@ -42,7 +42,7 @@ export async function openReviewLoopSetup(spec) {
const mine = page.reviewLoopSetup;
let res;
try {
res = await fetch("/review-loop-setup?facts=1" + (dir ? "&spec=" + encodeURIComponent(dir) : ""), { cache: "no-store" });
res = await fetch("review-loop-setup?facts=1" + (dir ? "&spec=" + encodeURIComponent(dir) : ""), { cache: "no-store" });
} catch {
res = null;
}
@@ -97,7 +97,7 @@ function ensureResolved(s) {
s.facts.resolved = null;
return;
}
fetch("/review-loop-setup?agent=" + encodeURIComponent(agent), { cache: "no-store" })
fetch("review-loop-setup?agent=" + encodeURIComponent(agent), { cache: "no-store" })
.then((res) => (res.ok ? res.json() : null))
.catch(() => null)
.then((answer) => {
@@ -371,7 +371,7 @@ async function saveNotify(s) {
if (url === (facts.notifyUrl || "") && f.notifyKind === (facts.notifyKind || "query") && param === (facts.notifyParam || "message")) return "";
let current = null;
try {
const res = await fetch("/loop-setup", { cache: "no-store" });
const res = await fetch("loop-setup", { cache: "no-store" });
current = res.ok ? await res.json() : null;
} catch {
current = null;
@@ -379,7 +379,7 @@ async function saveNotify(s) {
if (!current) return "The notification address could not be saved. Try again.";
// The loop's own screen drops these two before it saves; the store rejects them as unknown fields.
const { remembered, saved, ...entry } = current;
const { status, body } = await postJson("/loop-setup", { ...entry, notifyKind: f.notifyKind, notifyUrl: url, notifyParam: param });
const { status, body } = await postJson("loop-setup", { ...entry, notifyKind: f.notifyKind, notifyUrl: url, notifyParam: param });
if (status !== 200 || !body || body.ok !== true) {
return Array.isArray(body && body.problems) && body.problems.length ? body.problems.join(" ") : "The notification address could not be saved. Try again.";
}
@@ -420,7 +420,7 @@ async function startReviewLoop(s) {
redraw();
return;
}
const { status, body } = await postJson("/review-loop-setup", reviewSetupBody(f));
const { status, body } = await postJson("review-loop-setup", reviewSetupBody(f));
if (page.reviewLoopSetup !== s) return;
if (status !== 200 || !body || body.ok !== true) {
s.starting = false;
+1 -1
View File
@@ -54,7 +54,7 @@ async function onStart(entry) {
page.local.setupStart = { id: entry.id, label, at: Date.now() };
saveNow();
try {
const res = await fetch("/submit", {
const res = await fetch("submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ actions: [{ i: "__start", type: "start", agent: entry.id }], reply: "Start with " + label }),
+6 -6
View File
@@ -54,7 +54,7 @@ export async function syncWorkspaceScope(spec) {
page.scopeMine = want;
if ((page.wsFrame.scope || "") === want || scopeAsked === want) return;
scopeAsked = want;
const { status, body } = await postJson("/workspace/scope", { spec: want });
const { status, body } = await postJson("workspace/scope", { spec: want });
if (status === 200 && body && Array.isArray(body.folders)) page.wsFrame = { ...page.wsFrame, ...body };
scopeAsked = null;
if ($("workspace-modal").open) renderWorkspace();
@@ -83,7 +83,7 @@ let wsBusy = false;
export async function openWorkspace() {
const dlg = $("workspace-modal");
try {
const res = await fetch("/workspace?check=1", { cache: "no-store" });
const res = await fetch("workspace?check=1", { cache: "no-store" });
if (res.ok) page.wsFrame = await res.json();
} catch {}
wsConfirm = null;
@@ -203,7 +203,7 @@ function workspaceField(f, field, labelText) {
input.value = saved();
return showError("");
}
const { status, body } = await postJson("/workspace/edit", { id: f.id, [field]: value });
const { status, body } = await postJson("workspace/edit", { id: f.id, [field]: value });
// An earlier "Added as @x" is out of date once the list moves on.
if (status === 200) {
setAddMsg("");
@@ -271,7 +271,7 @@ function paintWorkspaceRow(li, f) {
go.type = "button";
go.addEventListener("click", async () => {
go.disabled = true;
const { status } = await postJson("/workspace/remove", { id: f.id });
const { status } = await postJson("workspace/remove", { id: f.id });
wsConfirm = null;
if (status === 200) setAddMsg("");
if (status !== 200) setAddMsg(`@${f.name} could not be removed. Try again.`, "error");
@@ -290,7 +290,7 @@ async function addWorkspaceFolder(path, name) {
if (!trimmed || wsBusy || loopDriving()) return;
wsBusy = true;
$("workspace-add").disabled = true;
const { status, body } = await postJson("/workspace/add", name ? { path: trimmed, name } : { path: trimmed });
const { status, body } = await postJson("workspace/add", name ? { path: trimmed, name } : { path: trimmed });
wsBusy = false;
$("workspace-add").disabled = false;
if (status === 200) {
@@ -327,7 +327,7 @@ async function browseWorkspace() {
if (b.disabled || loopDriving()) return;
b.disabled = true;
setAddMsg("Waiting for the folder picker…");
const { status, body } = await postJson("/workspace/browse", {});
const { status, body } = await postJson("workspace/browse", {});
b.disabled = false;
if (status === 200 && body.path) {
setAddMsg("");
+5 -5
View File
@@ -342,7 +342,7 @@ export function specFileTabs() {
async function fetchSpecFile(spec, kind) {
try {
const res = await fetch("/overview?spec=" + encodeURIComponent(spec) + "&file=" + kind, { cache: "no-store" });
const res = await fetch("overview?spec=" + encodeURIComponent(spec) + "&file=" + kind, { cache: "no-store" });
if (res.status !== 200) return null;
const file = decodeURIComponent(res.headers.get("x-spec-file") || "") || kind;
return { file, text: await res.text() };
@@ -382,7 +382,7 @@ export const prototypesTabShown = () => page.prototypes.key === overviewSpec() &
async function fetchPrototypeList(spec) {
try {
const res = await fetch("/prototypes?spec=" + encodeURIComponent(spec), { cache: "no-store" });
const res = await fetch("prototypes?spec=" + encodeURIComponent(spec), { cache: "no-store" });
if (res.status !== 200) return [];
const body = await res.json();
return Array.isArray(body.files) ? body.files : [];
@@ -393,7 +393,7 @@ async function fetchPrototypeList(spec) {
async function fetchPrototypeDoc(spec, name) {
try {
const res = await fetch("/prototype?spec=" + encodeURIComponent(spec) + "&name=" + encodeURIComponent(name), { cache: "no-store" });
const res = await fetch("prototype?spec=" + encodeURIComponent(spec) + "&name=" + encodeURIComponent(name), { cache: "no-store" });
return res.status === 200 ? await res.text() : null;
} catch {
return null;
@@ -437,7 +437,7 @@ export async function loadSpecCarry() {
if (specCarryAsked || !isDashboard() || !scan() || page.local.specSel !== undefined) return;
specCarryAsked = true;
try {
const res = await fetch("/spec-carry", { method: "POST", cache: "no-store" });
const res = await fetch("spec-carry", { method: "POST", cache: "no-store" });
const { spec } = res.status === 200 ? await res.json() : {};
if (!spec || page.local.specSel !== undefined || !specList().some((s) => s.dir === spec)) return;
page.local.specSel = spec;
@@ -458,7 +458,7 @@ export const agentsTabShown = () => isDashboard() && typeof page.agentsDoc.texts
// keep its text; null when it is not there. Off the dashboard nothing is read.
async function fetchAgentsDoc(rel) {
try {
const res = await fetch("/agents-doc?file=" + encodeURIComponent(rel), { cache: "no-store" });
const res = await fetch("agents-doc?file=" + encodeURIComponent(rel), { cache: "no-store" });
return res.status === 200 ? await res.text() : null;
} catch {
return null;
+1 -1
View File
@@ -39,7 +39,7 @@ export const soundOn = (event) => looks.sound && looks[soundKey(event)];
const soundPath = (event) =>
PICKABLE_SOUNDS.includes(event) && looks[soundFileKey(event)] ? `sounds/${looks[soundFileKey(event)]}` : SOUND_EVENTS[event].file;
const audioFor = (path) => (SOUNDS[path] ||= new Audio(`/${path}.mp3`));
const audioFor = (path) => (SOUNDS[path] ||= new Audio(`${path}.mp3`));
// The Audio a cue last played, so a pick changed mid-sound still stops the right one.
const soundAudio = (event) => SOUNDS[playingPath[event] || soundPath(event)];
+4 -4
View File
@@ -26,8 +26,8 @@ import { step } from "./notepad.js";
export const CHAT_IMAGES = "__chat";
// An upload's server path is `<session>/uploads/<uuid>.<ext>`; the page serves
// it at /uploads/<uuid>.<ext>.
export const uploadUrl = (img) => img.url || "/uploads/" + String(img.path || "").split(/[\\/]/).pop();
// it at uploads/<uuid>.<ext>, relative to itself.
export const uploadUrl = (img) => img.url || "uploads/" + String(img.path || "").split(/[\\/]/).pop();
// A page with its corner folded, drawn inline: the CSP allows no icon font.
function pageIcon() {
@@ -236,7 +236,7 @@ function setNoteImages(itemId, list) {
// Where an attachment is deleted from. Documents have no `url`, so their
// route is built from the path, as uploadUrl does.
export const deleteUrl = (entry) => entry.url || "/uploads/" + String(entry.path || "").split(/[\\/]/).pop();
export const deleteUrl = (entry) => entry.url || "uploads/" + String(entry.path || "").split(/[\\/]/).pop();
// The files in a paste worth attaching: images and allowed documents. A paste
// with none of them is left to paste as text.
@@ -258,7 +258,7 @@ async function uploadBlob(itemId, key, blob) {
let body = null;
let status = 0;
try {
const res = await fetch("/upload", {
const res = await fetch("upload", {
method: "POST",
headers: {
"content-type": isFile ? "application/octet-stream" : "image/jpeg",
+2 -1
View File
@@ -1430,7 +1430,8 @@ function upload(req, res, ctx) {
id,
kind: "image",
path: file,
url: "/uploads/" + id + ".jpg",
// Page-relative, for the macOS app's frame prefix (takeFramePrefix).
url: "uploads/" + id + ".jpg",
name: uploadLabel(req, "image.jpg"),
size: buf.length,
});