[Bug]: Clicking a <label> inside an inline html_render page jumps the chat when its input is off-screen
Before submitting
- [x] I searched existing issues and did not find a duplicate.
- [x] I included enough detail to reproduce or investigate the problem.
Area
apps/web
Steps to reproduce
- Have an agent show this self-contained page with
html_render(about 1570px tall):
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Label focus scroll repro</title>
<style>
.r > input { position: absolute; opacity: 0; pointer-events: none; }
.tg { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; }
.tg label { padding: 4px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; }
#opt-a:checked ~ .tg label[for="opt-a"],
#opt-b:checked ~ .tg label[for="opt-b"] { background: var(--primary); color: var(--primary-foreground); }
.fill { height: 1400px; margin: 12px 0; border: 1px dashed var(--border); border-radius: var(--radius);
display: flex; align-items: center; justify-content: center; color: var(--muted-foreground); }
p { margin: 8px 0; color: var(--muted-foreground); }
</style>
</head>
<body>
<div class="r">
<input type="radio" name="opt" id="opt-a" checked>
<input type="radio" name="opt" id="opt-b">
<div class="tg"><label for="opt-a">A</label><label for="opt-b">B</label></div>
<p>Top of the page. The two hidden radio inputs sit here.</p>
<div class="fill">1400px of content</div>
<p>Scroll the chat until the top of this page is off-screen, then click A or B below.</p>
<div class="tg"><label for="opt-a">A</label><label for="opt-b">B</label></div>
</div>
</body>
</html>
- Scroll the chat until the top of the render is above the viewport and the bottom toggle is visible.
- Click
AorBin the bottom toggle.
Expected behavior
The toggle switches and the chat stays where it is.
Actual behavior
The chat jumps in one frame, with no animation. The top of the render, where the hidden radio inputs sit, lands in the vertical center of the viewport, and the toggle I clicked scrolls out of view. I confirmed this with the page above in T3 Code (Beta) 0.1.9.
Cause. Clicking a <label> focuses its control, and Chromium scrolls a focused element into view. For the sandboxed render frame that scroll also moves the parent's scroll container, the timeline. A visually hidden radio or checkbox (position: absolute; opacity: 0) with labels elsewhere on the page is the standard script-free way to build toggles and tabs, and agents emit it often.
The timeline's own scroll logic is not involved. The jump reproduces in plain Chromium 157 with the page above in a sandbox="allow-scripts allow-forms" cross-site iframe inside a <div style="overflow:auto">: with a 700px viewport and the frame starting 1500px into the container, scrollTop goes from 2693 to 1168, which puts the frame's top at 332px.
Possible fix. A capture-phase click handler in the injected bootstrap (BOOTSTRAP_SCRIPT in packages/shared/src/htmlRender.ts) can take over label activation without the scroll. Sketch:
document.addEventListener("click", function (e) {
if (!e.isTrusted) return;
var l = e.composedPath().find(function (t) { return t && t.tagName === "LABEL"; });
var c = l && l.control;
if (!c || c.disabled || c === e.target) return;
e.preventDefault();
c.focus({ preventScroll: true });
c.click();
}, true);
In the same Chromium harness this removes the jump (scrollTop stays at 2693), and the radio still switches and keeps focus. I have not tested it inside T3 Code. It does not cover a page script that calls focus() on an off-screen element.
Hiding the inputs with display: none also avoids the jump, so a line in the html_render guidance would make agents hit this less often, but it does not protect pages that already exist.
Related: #17463 (closed) was also about interacting with a render, but there the chat re-pinned to the end of the thread. #17056 and #17065 cover scrolling over a render.
Impact
Minor bug or occasional failure
Version or commit
T3 Code (Beta) 0.1.9 (v0.1.9, 24e7747)
Environment
macOS 26.6.2, desktop app
Logs or stack traces
No response
Workaround
Ask the agent to hide the inputs with display: none, or to build the toggle from <button> elements.
Screenshots, recordings, or supporting files
I'll add a screen recording from the desktop app in a comment. The render in it is a larger page built on the same hidden radio and label toggles (the labels read "Было" and "Станет"). The jump happens at about 0:06, when I click "Было" in the lower block.
https://github.com/user-attachments/assets/ad56f15b-256e-41d7-b9f6-885535c535a3