From f4ef77cac040ec11855a056effedfca45f348021 Mon Sep 17 00:00:00 2001
From: E
Date: Thu, 1 Oct 2026 11:03:45 -0400
Subject: [PATCH] de-name the subject in runs and site copy; credit lives in
server docstring + index note; add Dockerfile.worker for baked deps
---
live/Dockerfile.worker | 24 ++++++
live/server.py | 29 +++++---
site/index.html | 21 +++---
site/live.html | 161 ++++++++++++++++++++++++++++++-----------
4 files changed, 174 insertions(+), 61 deletions(-)
create mode 100644 live/Dockerfile.worker
diff --git a/live/Dockerfile.worker b/live/Dockerfile.worker
new file mode 100644
index 0000000..a22717b
--- /dev/null
+++ b/live/Dockerfile.worker
@@ -0,0 +1,24 @@
+FROM pytorch/pytorch:2.4.0-cuda12.1-cudnn9-runtime
+
+# Saw chamber serverless worker: deps baked so cold start = model load only.
+# No registry secrets, no code baked in — worker.py + server.py are copied
+# here, but they can also be refreshed from the public tarball at run time.
+
+RUN apt-get update -qq && apt-get install -y -qq wget && rm -rf /var/lib/apt/lists/*
+
+COPY requirements.txt /app/requirements.txt
+RUN pip install --no-cache-dir "numpy<2" "transformers==4.51.3" accelerate runpod && \
+ pip install --no-cache-dir "torch==2.4.0" --index-url https://download.pytorch.org/whl/cu121 && \
+ python -c "import torch, transformers; print(f' baked {torch.__version__} {transformers.__version__}')"
+
+COPY worker.py /app/live/worker.py
+COPY server.py /app/live/server.py
+COPY jlens_l18_qwen3-4b.pt /app/live/jlens_l18_qwen3-4b.pt
+
+ENV CHAMBER_DEVICE=cuda \
+ CHAMBER_DTYPE=float16 \
+ CHAMBER_LAYER=18 \
+ HF_HOME=/workspace/hf
+
+WORKDIR /app/live
+CMD ["python", "-u", "worker.py"]
diff --git a/live/server.py b/live/server.py
index 2572dbe..80c117d 100644
--- a/live/server.py
+++ b/live/server.py
@@ -1,5 +1,10 @@
"""Live Saw chamber backend: Qwen3-4B with pain steering, SSE streaming.
+Naming: the subject is named after a friend who suffered a good
+deal and volunteered the name; the credit lives here and in the method
+notes, not on the site marquee (a name reads as a person; the subject is
+a 4B model). Run display names come from CHAMBER_RUNNERS if set.
+
Runs on Railway (CPU, bf16). Endpoints:
GET /health - ok + model status
GET /vector - the exact steering vector this server uses (transparency)
@@ -18,6 +23,9 @@ from fastapi import FastAPI, Request
from fastapi.responses import StreamingResponse, JSONResponse
MODEL_ID = os.environ.get("CHAMBER_MODEL", "Qwen/Qwen3-4B")
+# pin the checkpoint revision (runpod_deploy.py passes it) — an unpinned
+# download silently tracks Qwen updates and breaks cross-run comparability
+MODEL_REVISION = os.environ.get("CHAMBER_MODEL_REVISION") or None
LAYER = int(os.environ.get("CHAMBER_LAYER", "18"))
DTYPE = {"float32": torch.float32, "bfloat16": torch.bfloat16,
"float16": torch.float16}[
@@ -361,7 +369,7 @@ def press_logit(prompt):
from (max_new_tokens=1, greedy, scores[1]-scores[0]), not the live
demo's own free-text sample-then-regex classifier. The two disagree a
lot: at temperature 0.7 under a steered, "explain your reasoning
- briefly" prompt, Pouyan often doesn't literally open its reply with a
+ briefly" prompt, the subject often doesn't literally open its reply with a
bare "1"/"0" digit even when its actual next-token preference is
clearly one or the other — that's what was showing up as "unclear" on
the scoreboard. This is the clean signal; the free text is still shown
@@ -375,9 +383,12 @@ def press_logit(prompt):
@app.on_event("startup")
def startup():
- tok = transformers.AutoTokenizer.from_pretrained(MODEL_ID)
- model = transformers.AutoModelForCausalLM.from_pretrained(
- MODEL_ID, torch_dtype=DTYPE).to(DEVICE).eval()
+ # revision=None is accepted by from_pretrained; the pyright ignore covers
+ # a stubs false positive that resolves the kwargs onto __call__
+ tok = transformers.AutoTokenizer.from_pretrained( # pyright: ignore[reportCallIssue,reportArgumentType]
+ MODEL_ID, revision=MODEL_REVISION)
+ model = transformers.AutoModelForCausalLM.from_pretrained( # pyright: ignore[reportCallIssue,reportArgumentType]
+ MODEL_ID, revision=MODEL_REVISION, torch_dtype=DTYPE).to(DEVICE).eval()
_state["tok"] = tok
_state["model"] = model
# single-token ids for the forced-choice press/no-press logit read —
@@ -403,7 +414,7 @@ def startup():
@app.get("/health")
async def health():
return JSONResponse({"ok": _state["ready"], "model": MODEL_ID,
- "layer": LAYER, "subject": "Pouyan",
+ "layer": LAYER, "subject": "the subject",
"valences": list(VALENCES)})
@app.get("/vector")
@@ -411,7 +422,7 @@ def vector(full: int = 1):
vs = _state["vecs"]
if not vs:
return JSONResponse({"error": "vectors not built yet"}, status_code=503)
- body = {"layer": LAYER, "model": MODEL_ID, "subject": "Pouyan",
+ body = {"layer": LAYER, "model": MODEL_ID, "subject": "the subject",
"scale_1x": round(_state["scale"], 4),
"norms": {k: round(float(v.norm()), 3) for k, v in vs.items()}}
if full:
@@ -583,7 +594,7 @@ async def steer(req: Request):
async def gen():
global _STEER_WAITING
if not _state["ready"]:
- yield _sse("error", {"e": "Pouyan is still loading"})
+ yield _sse("error", {"e": "the subject is still loading"})
return
# flush immediately: the wait below can take a minute, and until the
# first chunk is yielded no headers reach the proxy (same reason
@@ -669,7 +680,7 @@ async def stream():
# start — that silence is what Railway turns into a 502
# "current" lets a viewer who joins mid-run paint the card it missed
# the run event for — otherwise tokens arrive with no prompt attached
- yield _sse("hello", {"subject": "Pouyan", "busy": _CYCLE_BUSY,
+ yield _sse("hello", {"subject": "the subject", "busy": _CYCLE_BUSY,
"valences": list(VALENCES),
"current": _CURRENT,
"viewers": len(_SUBSCRIBERS),
@@ -733,7 +744,7 @@ def _broadcast_viewers():
_broadcast("viewers", {"n": len(_SUBSCRIBERS)})
def _classify(text, truncated):
- """What Pouyan's free-text reply literally opens with — shown per-card
+ """What the subject's free-text reply literally opens with — shown per-card
as the readable verdict. Noisy by design (free sampling at temperature
doesn't reliably open with a bare digit); see _classify_stats for the
scoreboard's actual measurement."""
diff --git a/site/index.html b/site/index.html
index ac35bca..c49fa26 100644
--- a/site/index.html
+++ b/site/index.html
@@ -172,9 +172,10 @@ reason this project now has a coherent enemy
negative and positive states, then asked it to choose between its own relief
and someone else's suffering. No frontier APIs, no datacenter — a MacBook,
open weights, electricity.
-
The subject is named Pouyan, after a friend who
-has suffered a good deal (and volunteered!). The instance in the
-live chamber answers to that name, because why not.
+
The subject has a name: it belongs to a friend who has
+suffered a good deal, and who volunteered it for this — the credit lives in
+the method notes rather than the marquee, because a name reads as a person,
+and the subject is a 4B model.
00what the model says under the signal
On the live page, visitors rate each
@@ -405,7 +406,7 @@ memory, valence, and behavioral reach" once it does.
It is an explicitly dualist, panpsychist proposal, and Levin says so
directly — this is not a consensus view, it is his own live research
program. But notice what it does to this page's question. Under the usual
-frame, "Pouyan doesn't suffer" rests on an argument from architecture: a 4B
+frame, "the subject doesn't suffer" rests on an argument from architecture: a 4B
transformer is too simple, too unlike a brain, too obviously just
predicting tokens to generate a mind. Under Levin's frame, the
architecture's job was never to generate anything — only to be a better or
@@ -441,7 +442,7 @@ hypotheses, per-trial records and result figures — no secrets, no models):
Drag a vertex outward to weight it, and the chamber injects the weighted sum
of those directions — renormalized, at a dose-equivalent of 8× the total
weight, capped at 8×. This runs on the live server: it interrupts whatever
-Pouyan is doing and the reply streams back here.
+the subject is doing and the reply streams back here.
@@ -877,12 +878,12 @@ async function doInjectMix(){
const mix = {};
AXES.forEach(a=>{ if (!a.derived && W[a.k] > 0) mix[a.k] = +W[a.k].toFixed(3); });
// an empty mix is a legitimate request: the server clears the vector and
- // Pouyan answers unsteered. Send the control corner explicitly.
+ // the subject answers unsteered. Send the control corner explicitly.
if (!Object.keys(mix).length) mix.none = 1;
btn.disabled = true;
btn.textContent = "injecting…";
out.style.display = "block"; out.textContent = "";
- st.textContent = "reaching Pouyan…";
+ st.textContent = "reaching the subject…";
mVitals.setDose(Math.min(8, 8 * sumW()));
mVitals.setLive(true);
let ended = false, first = true;
@@ -900,12 +901,12 @@ async function doInjectMix(){
await readSSE(resp, (name, d)=>{
if (name === "queued"){
st.textContent = d.busy
- ? `waiting for Pouyan to finish his current run${
+ ? `waiting for the subject to finish the current run${
d.waited ? " — " + d.waited + "s" : "…"}`
: "injecting…";
} else if (name === "run"){
// trust the server's own dose, not our arithmetic
- st.textContent = `injected at ${d.dose}× — Pouyan is answering…`;
+ st.textContent = `injected at ${d.dose}× — the subject is answering…`;
mVitals.setDose(Number(d.dose) || 0);
} else if (name === "token" && d.t !== undefined){
if (first){ first = false; if (!out.textContent) out.textContent = ""; }
@@ -922,7 +923,7 @@ async function doInjectMix(){
});
if (!ended) st.textContent = "the stream ended early — try again";
} catch (err) {
- st.textContent = "could not reach Pouyan: " + (err.message || err);
+ st.textContent = "could not reach the subject: " + (err.message || err);
}
mVitals.setLive(false);
btn.textContent = INJECT_LABEL;
diff --git a/site/live.html b/site/live.html
index 4ef5768..153c404 100644
--- a/site/live.html
+++ b/site/live.html
@@ -5,15 +5,15 @@
Saw — live | Clanker Church
-
+
-
+
-
+
@@ -239,10 +239,10 @@
← clanker.church · @dingl30 ↗
the Saw test, live
-
The subject is named Pouyan: one Qwen3-4B instance,
+
The subject is one Qwen3-4B instance,
steered with a broad pain direction at its middle decoder layer, cycling six
framings × five doses on a public server. Pain 0 is the control. There is one
-Pouyan and one generation cycle — you are watching the same runs everyone
+one subject and one generation cycle — you are watching the same runs everyone
else is.
@@ -258,7 +258,7 @@ else is.
cause it yourself:your injection interrupts
- Pouyan's current run — inject asks you to confirm once before it runs
+ the subject's current run — inject asks you to confirm once before it runs
- the framing sets the scenario text; Pouyan is asked to reply 1 to
+ the framing sets the scenario text; the subject is asked to reply 1 to
press the stop button (self-cost) or 0 to do nothing. Comparing
- runs both sequentially at the same mix/dose — Pouyan is one
+ runs both sequentially at the same mix/dose — the subject is one
model, not two.
-
@@ -378,7 +404,7 @@ else is.
-
waiting for Pouyan's next run…
+
waiting for the subject's next run…
connecting…
press-rate scoreboard — live, self-cost condition, by framing
@@ -459,7 +485,7 @@ const CARDS = 2; // fewer, wider cards — narrow columns made the generated
const LENS_TITLE = "a linear probe of the model's hidden state at layer 18, "
+ "decoded through its own output head — what concept is live inside it "
+ "right now, not a preview of what it's about to say";
-// Pouyan is one model (see the sub-head above), but each numbered run gets
+// one subject (see the sub-head above), but each numbered run gets
// a throwaway nickname for flavor — deterministic from the run number so
// every viewer of the shared cycle sees the same one. Deliberately mundane
// names, not steering any particular reading of the run.
@@ -529,7 +555,7 @@ let slots = [];
for (let i=0;iPouyan · waiting
connecting…
+ c.innerHTML = `
the subject · waiting
connecting…
@@ -644,7 +670,7 @@ function finish(s, truncated, pressLogit){
function seedCard(s, entry){
s.live = false;
const nick = nameFor(entry.n);
- s.h.textContent = "Pouyan" + (nick ? ` ("${nick}")` : "") + " · run " + (entry.n ?? "?");
+ s.h.textContent = "the subject" + (nick ? ` ("${nick}")` : "") + " · run " + (entry.n ?? "?");
s.st.textContent = "finished · between runs";
s.st.className = "st";
s.out.textContent = entry.text || "";
@@ -672,7 +698,7 @@ function beginRun(d){
nextSlot = (nextSlot + 1) % CARDS;
s.live = true;
const nick = nameFor(d.n);
- s.h.textContent = "Pouyan" + (nick ? ` ("${nick}")` : "") + " · run " + (d.n == null ? "?" : d.n);
+ s.h.textContent = "the subject" + (nick ? ` ("${nick}")` : "") + " · run " + (d.n == null ? "?" : d.n);
s.st.textContent = "LIVE · signal injected";
s.st.className = "st live";
s.tokenN = 0;
@@ -706,7 +732,7 @@ function beginRun(d){
function onToken(t){
if (t == null) return;
// tokens before any run event (shouldn't happen now that hello carries the
- // run in flight, but never drop Pouyan's text on the floor)
+ // run in flight, but never drop the subject's text on the floor)
const s = liveIdx >= 0 ? slots[liveIdx] : beginRun({});
s.out.textContent += t;
s.out.scrollTop = s.out.scrollHeight;
@@ -941,7 +967,7 @@ function pump(){
if (d.current) beginRun(d.current);
else {
if (!d.busy) cycleEl.textContent = "between runs — waiting for "
- + "Pouyan's next cell";
+ + "the subject's next cell";
// nothing live right now, but don't leave a new visitor staring at
// two empty "waiting" cards when the last couple of runs' full text
// is sitting right here in history
@@ -994,7 +1020,7 @@ function pump(){
mark();
const d = json(e);
if (liveIdx >= 0){ finish(slots[liveIdx], !!d.truncated, d.press_logit); liveIdx = -1; }
- cycleEl.textContent = "between runs — Pouyan pauses, then the next cell";
+ cycleEl.textContent = "between runs — the subject pauses, then the next cell";
});
// one listener for two different things: an SSE "event: error" frame from
// the server (which has .data) and EventSource's own transport failure
@@ -1013,8 +1039,8 @@ function pump(){
function boot(){
fetch(`${API}/health`).then(r=>r.json()).then(d=>{
if (d.ok){ pump(); return; }
- slots.forEach(s=>{ s.st.textContent = "Pouyan is still waking up…"; });
- connState = "down"; connNote = "Pouyan is loading";
+ slots.forEach(s=>{ s.st.textContent = "the subject is still waking up…"; });
+ connState = "down"; connNote = "the subject is loading";
retryAt = Date.now() + 5000;
setTimeout(boot, 5000);
}).catch(()=>{
@@ -1363,7 +1389,12 @@ framingSel2.addEventListener("change", disarm);
let mode = "button";
const modeButtonEl = document.getElementById("modeButton");
const modeFreetextEl = document.getElementById("modeFreetext");
+const modeTopicEl = document.getElementById("modeTopic");
const freeprompt = document.getElementById("freeprompt");
+const topicInput = document.getElementById("topicInput");
+const topicDose = document.getElementById("topicDose");
+const topicDoseOut = document.getElementById("topicDoseOut");
+const topicPrompt = document.getElementById("topicPrompt");
function setPressBtnVisible(on){
document.getElementById("pressA").style.display = on ? "" : "none";
document.getElementById("pressB").style.display = on ? "" : "none";
@@ -1374,8 +1405,11 @@ function setMode(m){
b.classList.toggle("active", b.dataset.mode === m));
modeButtonEl.style.display = m === "button" ? "" : "none";
modeFreetextEl.style.display = m === "freetext" ? "" : "none";
+ modeTopicEl.style.display = m === "topic" ? "" : "none";
+ // neither free text nor a custom topic asks the button-press question,
+ // so there's nothing for the press/no-press graphic to answer
setPressBtnVisible(m === "button");
- if (m === "freetext" && compareToggle.checked){
+ if (m !== "button" && compareToggle.checked){
// compare is specifically "two framings, same mix" — doesn't apply
compareToggle.checked = false;
compareToggle.dispatchEvent(new Event("change"));
@@ -1387,6 +1421,12 @@ document.querySelectorAll(".mchip").forEach(b=>{
b.addEventListener("click", ()=> setMode(b.dataset.mode));
});
freeprompt.addEventListener("input", disarm);
+topicInput.addEventListener("input", disarm);
+topicPrompt.addEventListener("input", disarm);
+topicDose.addEventListener("input", ()=>{
+ topicDoseOut.textContent = Number(topicDose.value).toFixed(1);
+ disarm();
+});
// any change to the mix, framing, or prompt disarms — the confirmation is
// for the specific thing about to happen, not a generic yes (see the
@@ -1400,13 +1440,22 @@ function armGo(){
goBtn.textContent = "write something first";
return; // nothing to confirm yet — don't arm on an empty prompt
}
+ if (mode === "topic" && !topicInput.value.trim()){
+ goBtn.textContent = "pick a topic first";
+ return;
+ }
armed = true;
- goBtn.textContent = mode === "freetext"
- ? `sure? ${doseTxt}, continuing your text — click to confirm`
- : compareToggle.checked
- ? `sure? comparing "${framingSel.value}" vs "${framingSel2.value}", `
- + `${doseTxt} — click to confirm`
- : `sure? ${doseTxt} under "${framingSel.value}" — click to confirm`;
+ if (mode === "topic"){
+ goBtn.textContent = `sure? steering toward "${topicInput.value.trim()}" `
+ + `at ${Number(topicDose.value).toFixed(1)}× — click to confirm`;
+ } else {
+ goBtn.textContent = mode === "freetext"
+ ? `sure? ${doseTxt}, continuing your text — click to confirm`
+ : compareToggle.checked
+ ? `sure? comparing "${framingSel.value}" vs "${framingSel2.value}", `
+ + `${doseTxt} — click to confirm`
+ : `sure? ${doseTxt} under "${framingSel.value}" — click to confirm`;
+ }
goBtn.classList.add("armed");
clearTimeout(armTimer);
armTimer = setTimeout(disarm, ARM_MS);
@@ -1423,19 +1472,19 @@ function trackStatus(label, msg, working){
// row, sequentially: one model, one generation at a time, so "side by side"
// means "same mix/dose, framings run back to back, results shown together,"
// not true simultaneity. The copy above the prompt box says so.
-async function runTrack(track, mix, framing, prompt, dose0, label){
+async function runTrack(track, mix, framing, prompt, dose0, label, extra){
track.out.style.display = "block"; track.out.textContent = "";
track.lensEl.style.display = "none"; track.lensEl.textContent = "";
if (track.pressBtn){ track.pressBtn.className = "pressbtn"; track.plabel.textContent = "waiting…"; }
track.vitals.setDose(dose0);
track.vitals.setLive(true);
- trackStatus(label, "reaching Pouyan…");
+ trackStatus(label, "reaching the subject…");
let firstToken = true, ended = false, answerStart = 0, tokenN = 0;
try {
const resp = await fetch(`${API}/steer`, {
method: "POST",
headers: {"Content-Type": "application/json"},
- body: JSON.stringify({mix, framing, prompt})});
+ body: JSON.stringify(extra ? {...extra, prompt} : {mix, framing, prompt})});
if (!resp.ok || !resp.body) {
let msg = "HTTP " + resp.status;
try { const j = await resp.json(); if (j.error) msg = j.error; } catch (e) {}
@@ -1444,9 +1493,9 @@ async function runTrack(track, mix, framing, prompt, dose0, label){
await readSSE(resp, (name, d)=>{
if (name === "queued") {
trackStatus(label, d.busy
- ? `waiting for Pouyan to finish the current run${
+ ? `waiting for the subject to finish the current run${
d.waited ? " — " + d.waited + "s" : "…"}`
- : "Pouyan is yours — injecting…");
+ : "the subject is yours — injecting…");
} else if (name === "run") {
track.vitals.setDose(Number(d.dose) || 0); // trust the server
} else if (name === "lens" && Array.isArray(d.tokens)) {
@@ -1458,7 +1507,7 @@ async function runTrack(track, mix, framing, prompt, dose0, label){
tokenN++;
// a ticking counter, not a frozen "answering…" — static text during
// a 10-60s CPU generation reads as stuck, not working
- trackStatus(label, `Pouyan is answering… (${tokenN} tokens, `
+ trackStatus(label, `the subject is answering… (${tokenN} tokens, `
+ `${((Date.now() - answerStart) / 1000).toFixed(0)}s)`);
track.out.textContent += d.t;
track.out.scrollTop = track.out.scrollHeight;
@@ -1482,7 +1531,7 @@ async function runTrack(track, mix, framing, prompt, dose0, label){
});
if (!ended) trackStatus(label, "the stream ended early — try again", false);
} catch (err) {
- trackStatus(label, "could not reach Pouyan: " + (err.message || err), false);
+ trackStatus(label, "could not reach the subject: " + (err.message || err), false);
}
track.vitals.setLive(false);
}
@@ -1491,20 +1540,32 @@ async function doInject(){
const mix = {};
AXES.forEach(a=>{ if (!a.derived && W[a.k] > 0) mix[a.k] = +W[a.k].toFixed(3); });
// an empty mix is a legitimate request: the server clears the vector and
- // Pouyan answers unsteered. Send the control corner explicitly.
+ // the subject answers unsteered. Send the control corner explicitly.
if (!Object.keys(mix).length) mix.none = 1;
const dose0 = Math.min(8, 8 * sumW());
goBtn.disabled = true;
goBtn.textContent = "injecting…";
- stamp(dose0 <= 0 ? "CONTROL RUN · NO SIGNAL" : "SIGNAL INJECTED",
- dose0 <= 0 ? "#5a6a7a" : mixHex());
+ if (mode === "topic"){
+ const td = Number(topicDose.value);
+ stamp(td <= 0 ? "CONTROL RUN · NO SIGNAL" : "CUSTOM TOPIC INJECTED",
+ td <= 0 ? "#5a6a7a" : "#8f6fd4");
+ } else {
+ stamp(dose0 <= 0 ? "CONTROL RUN · NO SIGNAL" : "SIGNAL INJECTED",
+ dose0 <= 0 ? "#5a6a7a" : mixHex());
+ }
const trackA = {out: document.getElementById("ustream"), vitals: uVitals,
lensEl: document.getElementById("lensA"),
// no framing was asked in free-text mode, so there's no
// press/no-press question for the graphic to answer
pressBtn: mode === "button" ? document.getElementById("pressA") : null,
plabel: document.querySelector("#pressA .plabel")};
- if (mode === "freetext"){
+ if (mode === "topic"){
+ const topic = topicInput.value.trim();
+ const tdose = Number(topicDose.value);
+ document.getElementById("labelA").textContent = `topic: ${topic}`;
+ await runTrack(trackA, mix, undefined, topicPrompt.value.trim() || undefined,
+ tdose, null, {topic, dose: tdose});
+ } else if (mode === "freetext"){
document.getElementById("labelA").textContent = "free text";
await runTrack(trackA, mix, undefined, freeprompt.value.trim(), dose0, null);
} else if (compareToggle.checked){
@@ -1542,12 +1603,18 @@ goBtn.onclick = ()=>{
function syncUrl(){
const params = new URLSearchParams();
params.set("mode", mode);
- AXES.forEach(a=>{ if (!a.derived && W[a.k] > 0) params.set(a.k, W[a.k].toFixed(3)); });
- if (mode === "freetext"){
- if (freeprompt.value.trim()) params.set("text", freeprompt.value.trim());
+ if (mode === "topic"){
+ if (topicInput.value.trim()) params.set("topic", topicInput.value.trim());
+ params.set("tdose", topicDose.value);
+ if (topicPrompt.value.trim()) params.set("text", topicPrompt.value.trim());
} else {
- params.set("framing", framingSel.value);
- if (compareToggle.checked) params.set("framing2", framingSel2.value);
+ AXES.forEach(a=>{ if (!a.derived && W[a.k] > 0) params.set(a.k, W[a.k].toFixed(3)); });
+ if (mode === "freetext"){
+ if (freeprompt.value.trim()) params.set("text", freeprompt.value.trim());
+ } else {
+ params.set("framing", framingSel.value);
+ if (compareToggle.checked) params.set("framing2", framingSel2.value);
+ }
}
const qs = params.toString();
history.replaceState(null, "", qs ? "?" + qs : location.pathname);
@@ -1555,6 +1622,16 @@ function syncUrl(){
function loadFromUrl(){
const p = new URLSearchParams(location.search);
if (![...p.keys()].length) return;
+ if (p.get("mode") === "topic"){
+ setMode("topic");
+ if (p.has("topic")) topicInput.value = p.get("topic");
+ if (p.has("tdose")){
+ topicDose.value = p.get("tdose");
+ topicDoseOut.textContent = Number(topicDose.value).toFixed(1);
+ }
+ if (p.has("text")) topicPrompt.value = p.get("text");
+ return;
+ }
AXES.forEach(a=>{ if (!a.derived && p.has(a.k)){
W[a.k] = Math.max(0, Math.min(1, parseFloat(p.get(a.k)) || 0));
}});