@devries-cameron20 / t3code-1 / commits / de2b1d3358
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): keep HTML prototype selection rings visible (#23745)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>

Stevan Borus committed Oct 29, 2026 at 19:01 UTC de2b1d33582edee2604567dc572fde4c3b906450
3 files changed +110 -2
apps/server/src/provider/agentContextBudget.json
+1 -1
@@ -1,5 +1,5 @@
1 {
2 "claudeSystemAppendBytes": 5135,
3 "codexAdditionalContextBytes": 6865,
4 - "mcpToolListJsonBytes": 45907
4 + "mcpToolListJsonBytes": 46007
5 }
apps/web/src/components/files/BrowserDocumentFrame.browser.test.tsx
+107
@@ -1,3 +1,4 @@
1 +import { injectHtmlRenderBootstrap } from "@t3tools/shared/htmlRender";
2 import { describe, expect, it, vi } from "vite-plus/test";
3
4 import "~/index.css";
@@ -34,3 +35,109 @@ describe("HtmlRenderDocument", () => {
35 expect(onContentHeight).toHaveBeenCalledTimes(1);
36 });
37 });
38 +
39 +it("keeps the first and last selected card rings inside the fitted renderer frame", async () => {
40 + const html = injectHtmlRenderBootstrap(`<!doctype html><html><head><style>
41 + main { display: grid; gap: 12px; }
42 + button { box-sizing: border-box; width: 100%; height: 72px; border: 0; }
43 + button[aria-pressed="true"] { outline: 3px solid blue; outline-offset: 2px; }
44 + </style></head><body><main>
45 + <button id="first" aria-pressed="false">Meadow</button>
46 + <button id="middle" aria-pressed="false">Harbor</button>
47 + <button id="last" aria-pressed="false">Orchid</button>
48 + </main><script>
49 + document.querySelectorAll("button").forEach(function(button) {
50 + button.addEventListener("click", function() {
51 + document.querySelectorAll("button").forEach(function(card) {
52 + card.setAttribute("aria-pressed", String(card === button));
53 + });
54 + });
55 + });
56 + window.addEventListener("message", function(event) {
57 + if (event.source !== window.parent || event.data.type !== "select-card") return;
58 + var button = document.getElementById(event.data.id);
59 + button.click();
60 + var rect = button.getBoundingClientRect();
61 + var style = getComputedStyle(button);
62 + var ring = parseFloat(style.outlineWidth) + parseFloat(style.outlineOffset);
63 + window.parent.postMessage({
64 + type: "selected-card-bounds",
65 + id: button.id,
66 + selected: button.getAttribute("aria-pressed") === "true",
67 + ring: ring,
68 + left: rect.left - ring,
69 + right: rect.right + ring,
70 + top: rect.top - ring,
71 + bottom: rect.bottom + ring,
72 + pageHeight: document.documentElement.getBoundingClientRect().height,
73 + viewportHeight: window.innerHeight,
74 + viewportWidth: window.innerWidth,
75 + scrollWidth: document.documentElement.scrollWidth
76 + }, "*");
77 + });
78 + </script></body></html>`);
79 + const src = URL.createObjectURL(new Blob([html], { type: "text/html" }));
80 + using _url = { [Symbol.dispose]: () => URL.revokeObjectURL(src) };
81 + const container = document.createElement("div");
82 + container.style.width = "728px";
83 + const reports = new Map<
84 + string,
85 + {
86 + selected: boolean;
87 + ring: number;
88 + left: number;
89 + right: number;
90 + top: number;
91 + bottom: number;
92 + pageHeight: number;
93 + viewportHeight: number;
94 + viewportWidth: number;
95 + scrollWidth: number;
96 + }
97 + >();
98 + const messages = new AbortController();
99 + using _messages = { [Symbol.dispose]: () => messages.abort() };
100 + window.addEventListener(
101 + "message",
102 + (event) => {
103 + const frame = container.querySelector("iframe");
104 + if (event.source === frame?.contentWindow && event.data?.type === "selected-card-bounds") {
105 + reports.set(event.data.id, event.data);
106 + }
107 + },
108 + { signal: messages.signal },
109 + );
110 + const contentHeight = vi.fn((height: number) => {
111 + container.style.setProperty("--content-height", `${height}px`);
112 + });
113 + await using screen = await render(
114 + <>
115 + <style>{`iframe[title="Edge cards"] {
116 + display: block; width: 100%; height: var(--content-height, 120px); border: 0;
117 + }`}</style>
118 + <HtmlRenderDocument src={src} title="Edge cards" onContentHeight={contentHeight} />
119 + </>,
120 + { container },
121 + );
122 +
123 + await vi.waitFor(() => expect(contentHeight).toHaveBeenCalled());
124 + const frame = screen.getByTitle("Edge cards").element() as HTMLIFrameElement;
125 + await vi.waitFor(() => {
126 + expect(frame.getBoundingClientRect().height).toBe(contentHeight.mock.lastCall?.[0]);
127 + });
128 +
129 + for (const id of ["first", "last"]) {
130 + frame.contentWindow?.postMessage({ type: "select-card", id }, "*");
131 + await vi.waitFor(() => expect(reports.get(id)?.selected).toBe(true));
132 + const bounds = reports.get(id)!;
133 + expect(bounds.ring).toBe(5);
134 + expect(bounds.viewportWidth).toBe(728);
135 + expect(bounds.pageHeight).toBe(contentHeight.mock.lastCall?.[0]);
136 + expect(bounds.viewportHeight).toBe(bounds.pageHeight);
137 + expect(bounds.left).toBeGreaterThanOrEqual(0);
138 + expect(bounds.top).toBeGreaterThanOrEqual(0);
139 + expect(bounds.right).toBeLessThanOrEqual(bounds.viewportWidth);
140 + expect(bounds.bottom).toBeLessThanOrEqual(bounds.viewportHeight);
141 + expect(bounds.scrollWidth).toBeLessThanOrEqual(bounds.viewportWidth);
142 + }
143 +});
packages/shared/src/htmlRender.ts
+2 -1
@@ -232,6 +232,7 @@ export const HTML_RENDER_THEME_GUIDE = [
232 export const HTML_RENDER_LAYOUT_GUIDE = [
233 `Frame width is reply width (${HTML_RENDER_COLUMN_WIDTH}px desktop, about 360px phones), on the thread background.`,
234 "Leave html, body, and the outer element with no background color, no outer card, border, banner title, or side padding. This wins over any rule that sets a page background.",
235 + "T3 adds an overridable 8px html gutter for selection rings and shadows. Use fluid widths within it.",
236 "A box that needs its own background gets 16px padding and var(--radius) corners. Give charts fixed pixel heights.",
237 "Let content set the height. Do not use vh units or height:100% on html or body. Both are rejected or loop.",
238 ].join(" ");
@@ -353,7 +354,7 @@ export function htmlRenderThemeMessage(theme: HtmlRenderTheme) {
354 }
355
356 const BASE_CSS =
356 - "html{background:var(--background);color:var(--foreground);font-family:var(--font-sans);font-size:14px;line-height:1.5;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;scrollbar-width:none}" +
357 + "html{box-sizing:border-box;padding:8px;background:var(--background);color:var(--foreground);font-family:var(--font-sans);font-size:14px;line-height:1.5;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;scrollbar-width:none}" +
358 "html::-webkit-scrollbar{display:none}body{margin:0}code,kbd,pre,samp{font-family:var(--font-mono)}" +
359 // Focus outlines paint inside the element, so the frame edge never clips them.
360 ":where(:focus-visible){outline:2px solid var(--ring)}:focus-visible{outline-width:2px!important;outline-offset:-2px!important}" +