~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/hud

A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts

0
0

Names and identifiers are kept from a browser's translation

Merged chadtmiller.com asked to merge into main from chadtmiller.com/hud:web/no-translate
.changeset/names_and_identifiers_are_not_translated.mdnew+7−0
@@ -0,0 +1,7 @@
---
default: patch
---
# Names and identifiers are kept from a browser's translation
A page translated by the browser (Chrome's, Safari's, Google Translate) no longer translates a picture's ALT badge (German's "alt" made it "OLD"), its ⓘ lines, short times like "3h", accounts' names, @handles and DIDs, mentions, or the app's wordmark: the renderer and the shell mark them `translate="no"`. Captions, titles, comments and the app's own words are translated as before. `translateOf` says whether a text is an @handle or a DID, for a host's own drawing, and `LinkButton` takes `translate`.
docs/internals.md+2−0
@@ -149,3 +149,5 @@ The runner (runner.knotless.dev) runs the same checks on every push to main and
Each one is a self-contained HTML file built from `web/` (Svelte 5, Vite) as `web/dist/index.html` and `web/dist/workspace.html`, and embedded in the binary. Both draw with `@hud/renderer` (`web/renderer`), which knows nothing of MCP.
The renderer draws on a server too, so an app can send its pages as HTML and hydrate them. `Tree` takes `now`, the time the page is drawn at, and `hrefOf`, which gives the address of the page a call draws. The app passes both the same on the server and in the browser. Each call the tree opens is then a link (`<a href>`) that works before the page's code arrives and opens in a new tab with a modifier key. A plain click still goes to `oncall`. Until the page is mounted, dates and counts are written in `en-US` and UTC and times are read against `now`, so the browser's first drawing matches the server's. After that they're in the browser's own locale, time zone and clock. What a person did (a like, a text opened in full) is kept in the browser alone, so a server holds nothing of one request in the next.
A browser that translates the page (Chrome's, Safari's, Google Translate) leaves alone what the renderer and the shell mark `translate="no"`: names and identifiers, never words. That's a picture's ALT badge and its ⓘ lines (camera, lens, settings), a short time ("3h"), accounts' names, @handles and DIDs (a `Link` with `style: "name"`, a `Text`, title or label that is an @handle or a DID whole, a mention in text, a profile's names, a face's or an account's row) and the app's wordmark. Captions, titles, comments and the app's own words ("Show more") are translated with the page. `translateOf` (`web/renderer/src/translate.ts`) says whether a text is an identifier.
web/renderer/src/embed/QuoteView.svelte+1−1
@@ -37,7 +37,7 @@
<div class="quote" class:openable={open !== null}>
{#if open}<svelte:element this={tagOf(open)} {...opens(open)} class="open" aria-label="Open the quoted post by {name}"></svelte:element>{/if}
<div class="content">
<p class="byline">
<p class="byline" translate="no">
<span class="who">
<span class="avatar"><Picture src={avatar} alt="" placeholder={[...name][0]?.toUpperCase() ?? '·'} /></span>
<span class="name">{name}</span>
web/renderer/src/tree/compose/TextField.svelte+1−1
@@ -138,7 +138,7 @@
}}
>
<span class="avatar"><Picture src={account.avatar} alt="" placeholder="·" /></span>
<span class="who">
<span class="who" translate="no">
{#if account.name}<span class="name">{account.name}</span>{/if}
<span class="handle">@{account.handle}</span>
</span>
web/renderer/src/tree/Accounts.svelte+1−1
@@ -40,7 +40,7 @@
title={current ? undefined : 'Switch to this account'}
>
<span class="face"><Picture src={account.picture} alt="" person /></span>
<span class="who">
<span class="who" translate="no">
<span class="name">{account.name || account.handle || account.did}</span>
{#if account.handle}<span class="handle">@{account.handle}</span>{/if}
</span>
web/renderer/src/tree/Action.svelte+1−1
@@ -247,7 +247,7 @@
<p id="{id}-ask">{p.confirm}</p>
{#if p.handle}
<label class="typed">
<span>To confirm, type your handle, @{p.handle}.</span>
<span>To confirm, type your handle, <span translate="no">@{p.handle}</span>.</span>
<input type="text" bind:value={typed} placeholder="@{p.handle}" autocomplete="off" autocapitalize="none" spellcheck="false" />
</label>
{/if}
web/renderer/src/tree/Bar.svelte+2−1
@@ -1,4 +1,5 @@
<script lang="ts">
import { translateOf } from '../translate';
import { getTreeContext, setInBar } from './context';
import Node from './Node.svelte';
import type { UiBarProps, UiNode } from './types';
@@ -28,7 +29,7 @@
{#if node.k?.length}<div class="bar">{@render buttons()}</div>{/if}
{:else if place === 'here'}
<div class="bar here">
{#if p.title}<h2 class="title">{p.title}</h2>{/if}
{#if p.title}<h2 class="title" translate={translateOf(p.title)}>{p.title}</h2>{/if}
{@render buttons()}
</div>
{/if}
web/renderer/src/tree/Faces.svelte+1−1
@@ -60,7 +60,7 @@
{@const go = faceOpener(face)}
<svelte:element this={go ? tagOf(go) : 'button'} {...go ? opens(go) : { type: 'button', disabled: true }} class="person">
<span class="big"><Picture src={face.src} alt="" person /></span>
<span class="who">
<span class="who" translate="no">
{#if face.name}<span class="name">{face.name}</span>{/if}
{#if face.handle}<span class="handle">@{face.handle}</span>{/if}
</span>
web/renderer/src/tree/Link.svelte+8−4
@@ -2,6 +2,7 @@
import Glyph from '../Glyph.svelte';
import LinkButton from '../LinkButton.svelte';
import { opens, tagOf } from '../open';
import { translateOf } from '../translate';
import { getTreeContext, inBar, menuClose, opener, unhosted } from './context';
import type { UiLinkProps, UiNode } from './types';
@@ -17,6 +18,8 @@
// Message on Germ) is that pill; `style: muted` is muted text on one
// line (a gallery's location), the accent where a pointer is. One that
// asks what the host alone does (Sign out) is not drawn where it does not.
// An account's name (`style: name`), or a label that is an @handle or a
// DID, is kept from a page's translation (../translate.ts).
let { node }: { node: UiNode } = $props();
const tree = getTreeContext();
@@ -25,6 +28,7 @@
const p = $derived(node.p as UiLinkProps);
const page = $derived(p.open && 'url' in p.open ? p.open.url : null);
const open = $derived(page === null ? opener(tree, p.open) : null);
const translate = $derived(p.style === 'name' ? 'no' : translateOf(p.label));
/** What its words say a moment after sharing or copying: copied, or not allowed to copy. */
let said: string | null = $state(null);
@@ -80,15 +84,15 @@
{:else if open && p.style === 'button'}
<svelte:element this={tagOf(open)} {...opens(open)} class="button" title={open.label}>{p.label}</svelte:element>
{:else if open && p.style === 'muted'}
<svelte:element this={tagOf(open)} {...opens(open)} class="muted" title={p.label}>{p.label}</svelte:element>
<svelte:element this={tagOf(open)} {...opens(open)} class="muted" title={p.label} {translate}>{p.label}</svelte:element>
{:else if open && p.style === 'name'}
<svelte:element this={tagOf(open)} {...opens(open)} class="name whole" title={open.label}>{p.label}</svelte:element>
<svelte:element this={tagOf(open)} {...opens(open)} class="name whole" title={open.label} {translate}>{p.label}</svelte:element>
{:else if open}
<LinkButton strong onclick={open.run} href={open.href} title={open.label}
<LinkButton strong onclick={open.run} href={open.href} title={open.label} {translate}
>{#if p.icon}<svg class="lead" viewBox="0 0 24 24" aria-hidden="true"><Glyph name={p.icon} /></svg>{/if}{p.label}</LinkButton
>
{:else}
<span class:muted={p.style === 'muted'}>{p.label}</span>
<span class:muted={p.style === 'muted'} {translate}>{p.label}</span>
{/if}
<style>
web/renderer/src/tree/Text.svelte+5−2
@@ -5,6 +5,7 @@
<script lang="ts">
import RichRuns from '../RichRuns.svelte';
import { translateOf } from '../translate';
import { remembered } from '../view/remember.svelte';
import { getTreeContext, runsOf } from './context';
import type { UiNode, UiTextProps } from './types';
@@ -15,7 +16,8 @@
// line cut with an ellipsis). With `clamp`, held to that many lines; one
// longer the server cut (`shownRuns`, an ellipsis after them), drawn so
// with a "more" that draws the whole, so nothing is measured and the
// server's drawing is the browser's.
// server's drawing is the browser's. One that is an @handle or a DID
// whole (a byline's) is kept from a page's translation (../translate.ts).
let { node }: { node: UiNode } = $props();
const tree = getTreeContext();
@@ -29,9 +31,10 @@
const held = $derived(clamp !== null && !opened.value);
const cut = $derived(held && p.shownRuns !== undefined);
const runs = $derived(runsOf(cut && p.shownRuns ? p.shownRuns : p.runs, tree));
const translate = $derived(translateOf(p.runs.map((run) => run.text).join('')));
</script>
<div class="text {style}">
<div class="text {style}" {translate}>
<span class="plain" class:held style:--lines={held ? clamp : undefined}><RichRuns {runs} onopenlink={tree.onopenlink} /></span>
{#if cut}
<button type="button" class="more" onclick={() => (opened.value = true)}>more</button>
web/renderer/src/tree/Time.svelte+1−1
web/renderer/src/view/HeaderView.svelte+3−2
web/renderer/src/view/ProfileView.svelte+1−1
web/renderer/src/AltBadge.svelte+2−1
web/renderer/src/Gallery.svelte+1−1
web/renderer/src/index.ts+1−0
web/renderer/src/InfoBadge.svelte+2−1
web/renderer/src/LinkButton.svelte+7−4
web/renderer/src/RichRuns.svelte+2−2
web/renderer/src/translate.test.tsnew+23−0
web/renderer/src/translate.tsnew+18−0
web/renderer/test/ssr.mjs+13−1
web/shell/src/Nav.svelte+1−1
web/shell/src/Pager.svelte+1−1
web/shell/src/SearchFlyout.svelte+1−1
web/shell/src/Sheet.svelte+2−1
web/shell/src/Stack.svelte+4−4