Skip to content

Commit e5c4e47

Browse files
author
Brain
committed
Merge main into up-arrow edit, preserving edit and deletion admission
Signed-off-by: Brain <1a02c72794dcd0f07058a353bc3a81f4028b8c77c92c87fce6d5c8b85970a20b@buzz.block.builderlab.xyz>
2 parents 4058a78 + 12a957c commit e5c4e47

57 files changed

Lines changed: 2328 additions & 439 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎dev/relay-broker-api.test.mjs‎

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ async function harness(respond, capabilities = {}) {
4848
const auth = authorization
4949
? JSON.parse(Buffer.from(authorization.slice(6), "base64").toString())
5050
: undefined;
51-
if (upstreamUrl !== fixtureRelayUrl) expect(auth).toBeDefined();
51+
if (
52+
upstreamUrl === fixtureRelayUrl ||
53+
upstreamUrl === `${fixtureRelayUrl}/api/join-policy`
54+
)
55+
expect(auth).toBeUndefined();
56+
else expect(auth).toBeDefined();
5257
if (auth) {
5358
expect(verifyEvent(auth)).toBe(true);
5459
expect(auth.created_at).toBe(Math.floor(Date.now() / 1000));
@@ -114,6 +119,36 @@ const success = (call) =>
114119
: [],
115120
);
116121

122+
test("saved icon discovery survives join-policy failure without changing join discovery", async () => {
123+
const icon = "https://images.example/[email protected]";
124+
const h = await harness((call) => {
125+
if (call.url === fixtureRelayUrl) return Response.json({ icon });
126+
if (call.url === `${fixtureRelayUrl}/api/join-policy`)
127+
return new Response("unavailable", { status: 503 });
128+
return new Response(null, { status: 404 });
129+
});
130+
try {
131+
const iconResponse = await h.get("icon-info");
132+
expect(iconResponse.status).toBe(200);
133+
expect(await iconResponse.json()).toEqual({ icon });
134+
expect(h.calls.map(({ url }) => url)).toEqual([fixtureRelayUrl]);
135+
136+
const joinResponse = await h.get("info");
137+
const joinBody = await joinResponse.json();
138+
expect([joinResponse.status, joinBody]).toEqual([
139+
503,
140+
{ error: "Could not load join policy" },
141+
]);
142+
expect(h.calls.map(({ url }) => url)).toEqual([
143+
fixtureRelayUrl,
144+
fixtureRelayUrl,
145+
`${fixtureRelayUrl}/api/join-policy`,
146+
]);
147+
} finally {
148+
await h.close();
149+
}
150+
});
151+
117152
test("GIF capability discovery does not depend on join-policy availability", async () => {
118153
const h = await harness((call) => {
119154
if (call.url === fixtureRelayUrl)
@@ -1234,3 +1269,52 @@ test("edit capability signs and publishes canonical replacements, rejecting malf
12341269
await h.close();
12351270
}
12361271
});
1272+
1273+
test("message/reaction deletions pass real signing and publication without admitting workflow or arbitrary deletion shapes", async () => {
1274+
const h = await harness((call) =>
1275+
Response.json({ accepted: true, event_id: call.body.id }),
1276+
);
1277+
try {
1278+
await h.start();
1279+
const template = {
1280+
kind: 5,
1281+
content: "",
1282+
created_at: h.event.created_at,
1283+
tags: [
1284+
["h", "c"],
1285+
["e", "a".repeat(64)],
1286+
["k", "7"],
1287+
],
1288+
};
1289+
const response = await h.post("sign", template);
1290+
expect(response.status).toBe(200);
1291+
const event = await response.json();
1292+
expect(verifyEvent(event)).toBe(true);
1293+
expect(event.kind).toBe(5);
1294+
expect((await h.post("publish", event)).status).toBe(200);
1295+
for (const route of ["sign", "publish"]) {
1296+
for (const tags of [
1297+
[
1298+
["h", "c"],
1299+
["e", "invalid"],
1300+
["k", "7"],
1301+
],
1302+
[
1303+
["h", "c"],
1304+
["e", "a".repeat(64)],
1305+
["k", "30030"],
1306+
],
1307+
[...template.tags, ["a", `30620:${h.event.pubkey}:workflow`]],
1308+
[...template.tags, ["h", "other"]],
1309+
[
1310+
["h", "c"],
1311+
["k", "7"],
1312+
],
1313+
])
1314+
expect((await h.post(route, { ...event, tags })).status).toBe(400);
1315+
}
1316+
expect(h.publications).toHaveLength(1);
1317+
} finally {
1318+
await h.close();
1319+
}
1320+
});

‎dev/relay-broker.mjs‎

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,41 @@ export function validMessageTemplate(event) {
287287
})()
288288
);
289289
}
290+
/** Channel-local NIP-09 removal; the relay enforces authorship of each target. */
291+
export function validMessageDeletion(event) {
292+
if (
293+
event?.kind !== 5 ||
294+
event.content !== "" ||
295+
!Number.isSafeInteger(event.created_at) ||
296+
event.created_at < 0 ||
297+
!Array.isArray(event.tags) ||
298+
event.tags.length > 106 ||
299+
!event.tags.every(
300+
(tag) =>
301+
Array.isArray(tag) &&
302+
tag.length === 2 &&
303+
tag.every((value) => typeof value === "string") &&
304+
["h", "e", "k", "client-id"].includes(tag[0]),
305+
)
306+
)
307+
return false;
308+
const channels = event.tags.filter(([name]) => name === "h");
309+
const targets = event.tags.filter(([name]) => name === "e");
310+
const kinds = event.tags.filter(([name]) => name === "k");
311+
return (
312+
channels.length === 1 &&
313+
channels[0][1].length > 0 &&
314+
channels[0][1].length <= 256 &&
315+
targets.length > 0 &&
316+
targets.length <= 100 &&
317+
targets.every(([, id]) => /^[0-9a-f]{64}$/.test(id)) &&
318+
new Set(targets.map(([, id]) => id)).size === targets.length &&
319+
kinds.length > 0 &&
320+
kinds.length <= 3 &&
321+
kinds.every(([, kind]) => ["7", "9", "40002"].includes(kind))
322+
);
323+
}
324+
290325
/** Only explicit bot enrollment; never removal, role elevation or arbitrary kind-9000 tags. */
291326
export function validAgentEnrollment(event) {
292327
const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
@@ -519,7 +554,10 @@ export function relayBrokerPlugin({
519554
: {}),
520555
});
521556
}
522-
if (route === "/api/relay/info" && req.method === "GET") {
557+
if (
558+
(route === "/api/relay/info" || route === "/api/relay/icon-info") &&
559+
req.method === "GET"
560+
) {
523561
const response = await fetchUpstream(relay, {
524562
headers: { Accept: "application/nostr+json" },
525563
redirect: "error",
@@ -530,6 +568,9 @@ export function relayBrokerPlugin({
530568
error: "Community discovery failed",
531569
});
532570
const info = await response.json();
571+
// Saved-community icons are public NIP-11 metadata, not join admission.
572+
if (route === "/api/relay/icon-info")
573+
return json(res, 200, { icon: info?.icon });
533574
const gifSearchPath = relayKlipySearchPath(info);
534575
if (gifSearchPath)
535576
gifSearchPaths.set(relay, Promise.resolve(gifSearchPath));
@@ -1291,7 +1332,10 @@ export function relayBrokerPlugin({
12911332
sent: false,
12921333
});
12931334
}
1294-
} else if (![7, 9, 40003].includes(filters?.kind)) {
1335+
} else if (
1336+
![7, 9, 40003].includes(filters?.kind) &&
1337+
!validMessageDeletion(filters)
1338+
) {
12951339
try {
12961340
validateWorkflowEvent(
12971341
{ ...filters, pubkey: signing ? viewer : filters.pubkey },
@@ -1304,7 +1348,10 @@ export function relayBrokerPlugin({
13041348
sent: false,
13051349
});
13061350
}
1307-
} else if (!validMessageTemplate(filters))
1351+
} else if (
1352+
[7, 9, 40003].includes(filters?.kind) &&
1353+
!validMessageTemplate(filters)
1354+
)
13081355
return json(res, 400, { error: "Message rejected" });
13091356
// Never sign or publish after the requesting browser has left.
13101357
cancel.signal.throwIfAborted();

‎docs/browser-testing.md‎

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ verified clean commit or source manifest.
103103
CI stays on `ubuntu-24.04`. `pnpm test:browser:ci` inherits the ordinary config and
104104
excludes only tests tagged `@local-webkit` from `webkit-measurements`. Their Chromium
105105
instances and every untagged WebKit case remain required. Both engines, serial
106-
measurement order, zero retries, all existing assertions and budgets, and the
107-
strict `CI required` aggregate remain in place.
106+
measurement order, zero retries, the documented functional assertions and
107+
measurement ceilings, and the strict `CI required` aggregate remain in place.
108108

109109
CI shards each functional engine across two runners, without waiting for the
110110
separate measurement runner. Each job selects its engine with `--no-deps` and
@@ -124,7 +124,7 @@ The following **three WebKit cases are local-only**, not passing CI coverage:
124124

125125
| Case | Reason and coverage gap |
126126
| --- | --- |
127-
| `channel-opening.spec.mjs`: cold opening / warm switching | Hosted Linux WebKit recorded 104ms against the unchanged <100ms warm budget. The whole case is local-only, including its cold opening under held DM labels and no-new-head-read assertions. This is runner-sensitive evidence, not proof of an app or engine cause. Chromium retains the full case in CI. |
127+
| `channel-opening.spec.mjs`: cold opening / warm switching | Originally excluded after hosted Linux WebKit recorded 104ms against the former <100ms budget. The warm gate now uses the target/ceiling policy below; this change does not revalidate Linux WebKit or restore its CI selection. The whole case remains local-only, including cold opening under held DM labels and no-new-head-read assertions. Chromium retains the full case in CI. |
128128
| `scroll.spec.mjs`: cursor paging / large-history virtualization | Linux WebKit repeatedly stops short of the requested wheel edge. The cause remains unresolved between engine/input handling and the harness. Its 31 unique cursor requests, 640-message traversal, 4px anchors and DOM ceilings remain local-only on WebKit; Chromium retains them in CI. |
129129
| `scroll.spec.mjs`: live edits / reading anchor | Linux WebKit's fetch reader can leave part of an edit undelivered while the SSE stream is open. WebKit growth/shrinkage and reading-anchor checks are local-only; Chromium retains the case in CI. The delivery defect is not fixed by this selection change. |
130130

@@ -143,7 +143,8 @@ bin/pnpm test:browser # complete original suite, including those case
143143
The full suite remains part of `pnpm test` and `just scan` on every local platform;
144144
these cases are not silently skipped on Linux. The local-only command may still
145145
fail there. No macOS CI runner is configured. To restore a case to CI, remove its
146-
tag only after unchanged Linux assertions and budgets pass repeatedly. Live-edit
146+
tag only after the documented Linux functional assertions and measurement
147+
ceilings pass repeatedly. Live-edit
147148
closure also needs complete delivery on the open stream without a later write,
148149
heartbeat or close rescuing it. Do not move ordinary app/test failures out of CI
149150
or grow this exception list merely to get a green run.
@@ -205,10 +206,31 @@ or attended live-account acceptance.
205206
`channel-opening.spec.mjs` uses the actual app/session and production broker with
206207
an offline upstream: 128 DMs and 1,001 uncached participants. Profile responses
207208
stay held while an unprepared channel opens. This checks the **actual sidebar
208-
label caller**, not just the reader's priority flag. Cached returns then require
209-
no new head request and less than **100ms** from a browser-clock button click to
210-
visible correct-channel rows across a paint opportunity. This is a controlled
211-
regression budget, not a universal device/relay SLA or hardware input measurement.
209+
label caller**, not just the reader's priority flag. Cached returns require no
210+
new head request and visible correct-channel rows with the matching composer
211+
across a paint opportunity. The existing **1s completion watchdog** still fails
212+
an unfinished switch.
213+
214+
Warm timing keeps a **<100ms target** and a provisional **<200ms per-switch hard
215+
ceiling**. All four browser-clock samples and the functional checks complete
216+
before the ceiling is enforced; there are no retries or discarded outliers.
217+
Target misses add `performance` annotations to the downloadable Playwright JSON
218+
report (`ci-report.json` in CI), not the GitHub job-summary table. Raw timings,
219+
first-visible times and frame diagnostics remain in `evidence.json`, including on
220+
passing runs. Authors and reviewers should inspect target misses when changing
221+
opening/rendering paths; green CI does not mean the 100ms target was met.
222+
223+
The ceiling is an explicit tolerance policy, not a statistically established
224+
flake-free limit. Hosted Chromium recorded intermittent 111–120.5ms misses across
225+
main and multiple PRs ([main](https://github.com/block/buzz-app/actions/runs/35925546559),
226+
[#182](https://github.com/block/buzz-app/actions/runs/35932973673),
227+
[#185](https://github.com/block/buzz-app/actions/runs/35936296156)). The 200ms ceiling
228+
leaves roughly 80ms above the largest observed miss while retaining an automatic
229+
slowdown alarm. The timer includes browser scheduling and layout observation as
230+
well as application work: those samples do not establish runner contention as the
231+
cause, and severe stalls can still fail. Regressions between 100ms and 200ms now
232+
require performance review rather than automatically failing CI. This is not a
233+
universal device/relay SLA or hardware input measurement.
212234

213235
Run this focused journey when changing startup/sidebar scheduling:
214236

‎docs/communities.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Configure `BUZZ_DEV_VIEWER` with your existing Buzz public key in `.env.local`
1414
development broker runs on macOS and Linux and refuses an OS-store identity
1515
that does not match your explicit public pin.
1616
Click the avatar → **Settings → Profile** to edit and save a local default
17-
directly in the page, then **Switch community → Add a community** and type a **Relay URL**. There
17+
directly in the page, then use **Add a community** in the left rail and type a **Relay URL**. There
1818
is no destination dropdown. Accepts `wss://` or `https://` origins, for example
1919
`wss://relay.example.com` or `wss://other.example.com`, and other
2020
Buzz-compatible community relays. No community is pre-joined.
@@ -42,8 +42,10 @@ completed community setup seeds the local default only when it is still empty.
4242
Picture setup currently accepts HTTPS URLs, not uploads; a protected media URL
4343
from one community is not a portable public avatar for another.
4444

45-
Open **Switch community** at the top left and select a community to switch. Personal space
46-
clears selection without forgetting memberships. Messages shows an intentional
45+
Use the persistent left community rail to select a saved community or Personal
46+
space. Personal space
47+
clears selection without forgetting memberships. The rail’s Add control opens the
48+
existing join dialog; displaying saved communities reads relay metadata but does not open sessions for them. Messages shows an intentional
4749
empty state there. Try drafting in A, switching to B, then returning to A.
4850
Selected channels, drafts and reading offsets are partitioned by the canonical
4951
community origin and viewer; channel IDs alone are not sufficient keys.

‎docs/design-system-adoption.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pill actions, consistent fields and shared states.
1515
| Search | SearchField | Channels, pages, members and GIFs preserve their query, ref and keyboard handlers. |
1616
| Navigation | NavigationItem | Settings, channel rows, shell destinations, Home and community choices. Route destinations remain buttons, not tabs. |
1717
| Tabs | Tabs | Emoji/GIF uses associated panels and Base UI keyboard activation. Workflow mode retains its existing externally owned editor view. |
18-
| Modals | Dialog and AlertDialog | Page search, community chooser/setup and workflow confirmations. Pending work prevents dismissal; focus returns to the opener. |
18+
| Modals | Dialog and AlertDialog | Page search, community setup and workflow confirmations. Pending work prevents dismissal; focus returns to the opener. |
1919
| Panels and headers | Panel and PanelHeader | Settings, channels and companion cards use shared paint. Grids, scrolling, docks and subscriptions stay with the feature. |
2020
| Feedback | Toast | Agent-start, live-update, sidebar preferences and Settings feedback use a source-owned stack. Recovery stays available; form errors, blocked pages and lasting paused-state context remain inline. |
2121
| Hints | Tooltip | Control titles and agent activity use keyboard-accessible, dismissible hints. Accessible names stay on the controls. |

‎docs/shell-design.md‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,17 @@ identity. See [community/profile ownership](communities.md).
8787
`PageSearch.tsx` uses a native modal dialog for focus containment, Escape dismissal,
8888
and searching available page destinations. Projects is a bundled, enabled-by-default
8989
page scaffold with only a centered title; Apps waits for a functional destination.
90-
`CommunitySwitcher.tsx` replaces the full-height rail:
91-
its top-left button opens a native dialog for Personal space, existing communities,
92-
and Add a community. The trigger is focused before opening so Escape restores
93-
keyboard focus in WebKit as well as Chromium.
90+
`CommunityRail.tsx` shows Personal space, saved communities and Add persistently
91+
beside page content; it only delegates selection to the existing membership owner.
92+
The rail's Add control opens the existing join dialog and returns focus to its
93+
trigger. The former header picker is not mounted; the rail is the sole selector.
94+
The rail reads saved-community NIP-11 icons through the same-origin broker with at
95+
most two concurrent optional reads, including inactive communities without
96+
opening sessions; slow icon responses cannot occupy all foreground connections.
97+
Unavailable or unsupported images fall back to a saved icon or name initial.
98+
The rail does not acquire inactive sessions or claim an unread total: the unread
99+
capability provides bounded observed evidence, not exact community totals
100+
([unread ownership](unread.md)).
94101

95102
Visible copy uses Buzz, never “workspace.” The legacy `workspace` layout identifier
96103
and CSS variable are implementation details retained for plugin compatibility.

‎src/app/shell/AppShell.tsx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { HouseIcon } from "../../shared/design-system/icons/index";
44
import { isTauri } from "@tauri-apps/api/core";
55
import type { RegisteredPage } from "../../features/pages/service";
66
import type { Communities } from "../../features/communities/service";
7-
import { CommunitySwitcher } from "../../features/communities/CommunitySwitcher";
7+
import { CommunityRail } from "../../features/communities/CommunityRail";
88
import { ProfileButton } from "./ProfileButton";
99
import { PageSearch, type SearchServices } from "./PageSearch";
1010
import { orderPages, pagePresentation } from "./presentation";
@@ -70,10 +70,6 @@ export function AppShell({
7070
{...titleBarDragProps}
7171
>
7272
{navigationControls}
73-
<CommunitySwitcher
74-
communities={communities}
75-
onSelect={onCommunitySelect}
76-
/>
7773
</div>
7874
<nav aria-label="Pages" className="shell-pages">
7975
<NavigationItem
@@ -120,6 +116,7 @@ export function AppShell({
120116
</div>
121117
</header>
122118
<div className="flex min-h-0 flex-1">
119+
<CommunityRail communities={communities} onSelect={onCommunitySelect} />
123120
<main
124121
id="main-content"
125122
tabIndex={-1}

‎src/bundled/channels/ChannelsPage.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export function ChannelsPage({
135135
{session.status === "connecting"
136136
? "Connecting to your relay…"
137137
: (session.error ??
138-
"Use Switch community at the top left to choose or add a community. Your profile and settings work without a community.")}
138+
"Use the left community rail to choose or add a community. Your profile and settings work without a community.")}
139139
</p>
140140
{session.status === "error" && (
141141
<>

0 commit comments

Comments
 (0)