Skip to content

Commit 0a437bf

Browse files
committed
Merge plugin sidebar and community cleanup into Inbox
Signed-off-by: tulsi <[email protected]>
2 parents ed69074 + 1b30cb3 commit 0a437bf

93 files changed

Lines changed: 4542 additions & 561 deletions

File tree

Some content is hidden

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

‎.github/workflows/ci.yml‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,23 @@ jobs:
122122
env:
123123
PLAYWRIGHT_JSON_OUTPUT_FILE: test-results/browser/ci-report.json
124124
run: node scripts/ci-test-report.mjs kind=playwright report=test-results/browser/ci-report.json evidence=test-results/browser/ci-timing.json title="Browser measurements" -- pnpm test:browser:ci --project '*-measurements' --workers=1 --reporter=list,json
125+
# Cases tagged @classic-scrollbars need Chromium's platform scrollbars,
126+
# which Linux always draws as classic ones. One file cannot join the
127+
# six-way engine matrix (empty shards are errors), so it runs here, and
128+
# CI required already blocks on this job. The project writes to its own
129+
# outputDir so this run does not clear the measurement evidence above.
130+
- name: Chromium classic-scrollbar layout
131+
env:
132+
PLAYWRIGHT_JSON_OUTPUT_FILE: test-results/browser-classic-scrollbars/ci-report.json
133+
run: node scripts/ci-test-report.mjs kind=playwright report=test-results/browser-classic-scrollbars/ci-report.json evidence=test-results/browser-classic-scrollbars/ci-timing.json title="Browser classic scrollbars" -- pnpm test:browser:ci --project chromium-classic-scrollbars --no-deps --reporter=list,json
125134
- name: Measurement evidence
126135
if: always()
127136
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
128137
with:
129138
name: browser-measurements
130-
path: test-results/browser
139+
path: |
140+
test-results/browser
141+
test-results/browser-classic-scrollbars
131142
retention-days: 7
132143

133144
browser:

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Messages, choose a channel, and click a GitHub reference. See
160160
[the channel extension contract and data budgets](docs/channels.md) for ownership,
161161
performance, validation, and limitations.
162162

163-
Messages is the landing page. Channels is required and cannot be disabled; optional plugins such as GitHub can be toggled in Settings.
163+
Messages opens by default. Channels is required and cannot be disabled; optional plugins such as GitHub can be toggled in Settings.
164164

165165
See [client and community ownership](docs/communities.md) for the minimal join/profile flow, session scopes, and switching checks.
166166

@@ -222,7 +222,8 @@ to exercise component reuse and contribution lifecycle.
222222
`apply(ctx)`. `ctx` is a Cordis context. External JSX plugins export
223223
`inject = ["react", "pages"]` and obtain `const React = ctx.react` inside `apply`, then call
224224
`ctx.pages.register({ id, title, component })` to contribute a page. A plugin may register
225-
several pages or none. Page IDs are unique within their plugin. Buzz supplies React
225+
several pages or none. Page IDs are unique within their plugin. Add `primary: true` for a
226+
row in the sidebar's page navigation; every active page is listed in search. Buzz supplies React
226227
and owns the Cordis runtime (`@deepseek-ai/cordis` 4.0.2). Import their types only
227228
in external plugins; runtime imports are rejected by the scaffold's builder.
228229

‎crates/plugin-manager/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ pub fn valid_id(id: &str) -> Result<()> {
9999
}
100100
pub fn bundled_manifests() -> Vec<Manifest> {
101101
vec![
102-
serde_json::from_str(include_str!("../../../src/bundled/inbox/manifest.json"))
103-
.expect("inbox manifest"),
104102
serde_json::from_str(include_str!("../../../src/bundled/todos/manifest.json"))
105103
.expect("todos manifest"),
106104
serde_json::from_str(include_str!("../../../src/bundled/diffs/manifest.json"))
@@ -131,6 +129,8 @@ pub fn bundled_manifests() -> Vec<Manifest> {
131129
.expect("channels manifest"),
132130
serde_json::from_str(include_str!("../../../src/bundled/github/manifest.json"))
133131
.expect("github manifest"),
132+
serde_json::from_str(include_str!("../../../src/bundled/inbox/manifest.json"))
133+
.expect("valid Inbox manifest"),
134134
serde_json::from_str(include_str!("../../../src/bundled/bestie/manifest.json"))
135135
.expect("bestie manifest"),
136136
serde_json::from_str(include_str!("../../../src/bundled/projects/manifest.json"))

‎crates/plugin-manager/src/main.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ export function apply(ctx: Context) {
164164
const React = ctx.react;
165165
// Plugin resources belong in ctx.effect(() => cleanup).
166166
// React effects belong to the visible page and stop when navigating away.
167-
ctx.pages.register({ id: "main", title: "My page", component: function Page() {
167+
// primary gives the page a sidebar row; every active page is still listed in search.
168+
ctx.pages.register({ id: "main", title: "My page", primary: true, component: function Page() {
168169
const [count, setCount] = React.useState(0);
169170
return <section>
170171
<h1>My page</h1>

‎crates/plugin-manager/tests/management.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ fn bundled_plugins_have_independent_flags_and_all_ids_are_reserved() {
468468
"buzz.identity-naming",
469469
"buzz.terminal",
470470
"buzz.sessions",
471+
"buzz.inbox",
471472
"buzz.bestie",
472473
"buzz.projects",
473474
"buzz.agents",

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

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,6 +2114,112 @@ test("member change receipts must match the signed command", async () => {
21142114
}
21152115
});
21162116

2117+
test("leave requests sign the exact NIP-43 shape for the selected community only", async () => {
2118+
const { h, post } = await communityAdmin((call) =>
2119+
Response.json({ accepted: true, event_id: call.body.id, message: "" }),
2120+
);
2121+
try {
2122+
const response = await post("leave", {});
2123+
expect(response.status).toBe(200);
2124+
const sent = h.calls.at(-1);
2125+
expect(sent.url).toBe(`${fixtureRelayUrl}/events`);
2126+
expect(verifyEvent(sent.body)).toBe(true);
2127+
expect(sent.body).toMatchObject({
2128+
kind: 28936,
2129+
tags: [["-"]],
2130+
content: "",
2131+
pubkey: h.event.pubkey,
2132+
created_at: Math.floor(Date.now() / 1000),
2133+
});
2134+
expect(await response.json()).toMatchObject({
2135+
accepted: true,
2136+
event_id: sent.body.id,
2137+
});
2138+
// The request body carries nothing: a client cannot smuggle another kind
2139+
// or extra tags into the signed event.
2140+
const shaped = await post("leave", {
2141+
kind: 9031,
2142+
tags: [["p", "a".repeat(64)]],
2143+
content: "bye",
2144+
});
2145+
expect(shaped.status).toBe(200);
2146+
expect(h.calls.at(-1).body).toMatchObject({
2147+
kind: 28936,
2148+
tags: [["-"]],
2149+
content: "",
2150+
});
2151+
// Unscoped requests name no community to leave.
2152+
expect((await h.post("leave", {})).status).toBe(400);
2153+
expect(h.calls).toHaveLength(2);
2154+
} finally {
2155+
await h.close();
2156+
}
2157+
});
2158+
2159+
test("leave receipts must match the signed request", async () => {
2160+
const { h, post } = await communityAdmin(() =>
2161+
Response.json({ accepted: true, event_id: "wrong" }),
2162+
);
2163+
try {
2164+
const response = await post("leave", {});
2165+
expect(response.status).toBe(502);
2166+
expect(await response.json()).toEqual({
2167+
error: "Leave request could not be confirmed",
2168+
});
2169+
} finally {
2170+
await h.close();
2171+
}
2172+
});
2173+
2174+
test.each([
2175+
[
2176+
400,
2177+
"invalid: you are not a relay member",
2178+
"invalid: you are not a relay member",
2179+
],
2180+
[
2181+
400,
2182+
"invalid: relay membership is not enabled",
2183+
"invalid: relay membership is not enabled",
2184+
],
2185+
[
2186+
400,
2187+
"invalid: relay owner cannot leave",
2188+
"invalid: relay owner cannot leave",
2189+
],
2190+
[
2191+
403,
2192+
"blocked: you are banned from this community",
2193+
"blocked: you are banned from this community",
2194+
],
2195+
[
2196+
503,
2197+
"community writes are temporarily unavailable",
2198+
"community writes are temporarily unavailable",
2199+
],
2200+
// Admin refusals are not leave refusals.
2201+
[400, "invalid: cannot remove yourself", "Relay request failed (400)"],
2202+
[
2203+
400,
2204+
"invalid: database error: connection reset <script>",
2205+
"Relay request failed (400)",
2206+
],
2207+
])(
2208+
"leave refusal %i %j is surfaced only when whitelisted",
2209+
async (status, error, shown) => {
2210+
const { h, post } = await communityAdmin(() =>
2211+
Response.json({ error }, { status }),
2212+
);
2213+
try {
2214+
const response = await post("leave", {});
2215+
expect(response.status).toBe(status);
2216+
expect((await response.json()).error).toBe(shown);
2217+
} finally {
2218+
await h.close();
2219+
}
2220+
},
2221+
);
2222+
21172223
test.each([
21182224
[400, "invalid: cannot remove yourself", "invalid: cannot remove yourself"],
21192225
[

‎dev/relay-broker.mjs‎

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ import {
3131
inviteRequest,
3232
memberCommand,
3333
} from "./community-admin.mjs";
34+
import {
35+
leaveRefusal,
36+
leaveRequestTemplate,
37+
} from "../src/features/communities/leave-protocol.ts";
3438
import {
3539
directMessageEvent,
3640
directMessageReceipt,
@@ -1951,6 +1955,7 @@ export function relayBrokerPlugin({
19511955
"/api/relay/accept-policy",
19521956
"/api/relay/invite",
19531957
"/api/relay/member",
1958+
"/api/relay/leave",
19541959
"/api/relay/gifs",
19551960
"/api/relay/workflow-runs",
19561961
"/api/relay/project-git",
@@ -2157,18 +2162,29 @@ export function relayBrokerPlugin({
21572162
const policy = route === "/api/relay/accept-policy";
21582163
const invite = route === "/api/relay/invite";
21592164
const member = route === "/api/relay/member";
2165+
const leave = route === "/api/relay/leave";
21602166
const gifs = route === "/api/relay/gifs";
21612167
// Only these routes may surface an exact, allowed relay refusal.
21622168
const refusal =
2163-
invite || member ? adminReason : claim ? claimReason : undefined;
2164-
if (invite || member) {
2169+
invite || member
2170+
? adminReason
2171+
: claim
2172+
? claimReason
2173+
: leave
2174+
? leaveRefusal
2175+
: undefined;
2176+
if (invite || member || leave) {
21652177
// Community-bound only; the relay remains the authority for roles.
21662178
if (!scoped)
21672179
return json(res, 400, { error: "Select a community first" });
21682180
try {
2181+
// The viewer's own leave request has one shape; the body carries nothing.
21692182
filters = invite
21702183
? inviteRequest(filters)
2171-
: finalizeEvent(memberCommand(filters), key);
2184+
: finalizeEvent(
2185+
leave ? leaveRequestTemplate() : memberCommand(filters),
2186+
key,
2187+
);
21722188
} catch (error) {
21732189
return json(res, 400, { error: error.message, sent: false });
21742190
}
@@ -2435,6 +2451,7 @@ export function relayBrokerPlugin({
24352451
!policy &&
24362452
!invite &&
24372453
!member &&
2454+
!leave &&
24382455
!gifs &&
24392456
!workflowPath &&
24402457
!readPublishing &&
@@ -2499,7 +2516,7 @@ export function relayBrokerPlugin({
24992516
workflowPath ??
25002517
(gifs
25012518
? gifSearchPath
2502-
: profile || directMessage || member
2519+
: profile || directMessage || member || leave
25032520
? "/events"
25042521
: claim
25052522
? "/api/invites/claim"
@@ -2663,16 +2680,18 @@ export function relayBrokerPlugin({
26632680
});
26642681
}
26652682
}
2666-
if (profile || member) {
2683+
if (profile || member || leave) {
26672684
const receipt = JSON.parse(text);
26682685
if (
26692686
receipt.event_id !== filters.id ||
26702687
typeof receipt.accepted !== "boolean"
26712688
)
26722689
return json(res, 502, {
2673-
error: member
2674-
? "Member change could not be confirmed"
2675-
: "Profile publication could not be confirmed",
2690+
error: leave
2691+
? "Leave request could not be confirmed"
2692+
: member
2693+
? "Member change could not be confirmed"
2694+
: "Profile publication could not be confirmed",
26762695
});
26772696
}
26782697
res.writeHead(200, {

‎docs/browser-testing.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ Results go to ignored `test-results/browser/`: each built-app test writes `evide
9595
with runtime versions, HEAD/dirty status, request ledger, runtime errors and
9696
measurements. Failure screenshots and traces are retained too. The next invocation
9797
replaces that output; copy artifacts before a rerun if you need to compare them.
98+
The one exception is the `chromium-classic-scrollbars` project, whose `evidence.json`,
99+
failure screenshots and traces land in `test-results/browser-classic-scrollbars/`
100+
so that its separate invocation cannot clear the measurement evidence.
98101
A dirty-status listing is not a content hash; tie release claims to a separately
99102
verified clean commit or source manifest.
100103

@@ -120,6 +123,20 @@ check's shell against failed, skipped, cancelled and missing lane results.
120123
These safeguards must change with the matrix; do not maintain feature allowlists
121124
or move existing required cases out of CI to reduce its duration.
122125

126+
Cases tagged `@classic-scrollbars` need a scrollbar that takes space. They run
127+
only in the `chromium-classic-scrollbars` project, which keeps Chromium's
128+
platform scrollbars visible, and the engine projects exclude them. CI runs that
129+
project as a second step of the measurements job, so `CI required` blocks on it;
130+
the integration gate checks that the step exists and that the tagged cases are
131+
selected there and nowhere else. Linux always draws classic scrollbars, so the
132+
cases fail there if the scrollbar takes no space. On macOS Chromium follows the
133+
system "Show scroll bars" setting, so they skip unless `BUZZ_CLASSIC_SCROLLBARS=1`
134+
is set on a Mac whose scrollbars take space:
135+
136+
```sh
137+
BUZZ_CLASSIC_SCROLLBARS=1 bin/pnpm test:browser --project chromium-classic-scrollbars --no-deps
138+
```
139+
123140
The following **three WebKit cases are local-only**, not passing CI coverage:
124141

125142
| Case | Reason and coverage gap |

‎docs/communities.md‎

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,42 @@ reporting success. This confirmation is not a transaction against other clients.
6868
Use the persistent left community rail to select a saved community or Personal
6969
space. Personal space
7070
clears selection without forgetting memberships. The rail’s Add control opens the
71-
existing join dialog; displaying saved communities reads relay metadata but does not open sessions for them. Messages shows an intentional
71+
existing join dialog; displaying saved communities reads relay metadata but does not open sessions for them.
72+
Right-click a saved community (or press the ContextMenu key or Shift+F10 on it)
73+
for Mark all as read, Copy community URL, Invite to community, Community
74+
settings and, last, Leave community. Only the selected community can be marked
75+
read, and only while its read state syncs; Invite shows only where the viewer
76+
owns or administers the selected community and this build can mint invites,
77+
with the role read from the relay-signed roster through the selected
78+
community's existing session rather than a further session request. The
79+
Membership settings card applies the same gate: it stays registered in native
80+
builds so owners and admins can still read the relay-signed member list, but
81+
its Invite members button and per-member actions are absent there, with a
82+
note that this build can't create invites or change members, since `invite` and
83+
`member` are broker routes the packaged adapter does not carry. Copy,
84+
Community settings and Leave work on inactive communities without opening their
85+
sessions. Leave asks for confirmation, then sends a signed NIP-43 leave request
86+
(kind 28936) to that community's relay before the device forgets it. Three
87+
answers end the membership here. The relay accepting, or answering that the
88+
viewer is not a member, removes the community and clears its drafts, reading
89+
positions and other device state, since the relay holds nothing to go back to.
90+
The relay answering that the viewer is banned also removes the community and
91+
disposes its session, but keeps that device state: the relay still holds the
92+
membership while a ban lasts (bans can be timed or lifted), and the data is
93+
keyed by origin and viewer, so adding the community again by its URL finds it.
94+
That notice says the viewer is currently banned, so the leave was refused, and
95+
promises nothing about how long; it never calls access revoked for good. Any
96+
other refusal or an unreachable relay keeps the membership and reports the
97+
failure so Leave can be tried again. Once the relay has answered, only this
98+
device can still fail: a device record that will not save keeps the community
99+
in the rail and says so, naming the storage error so a store that never saves
100+
is not the same promise every attempt, and leaving it again finishes through
101+
the not-a-member answer; a store that will not clear is logged by name and the
102+
success notice says some saved data remains. A left community that was selected
103+
lands on Personal space through the host's selection path, exactly as clicking
104+
Personal space would; a host callback that fails there is logged as the host's
105+
own error, and the leave still reports success because the device did finish.
106+
Messages shows an intentional
72107
empty state there. Try drafting in A, switching to B, then returning to A.
73108
Selected channels, drafts and reading offsets are partitioned by the canonical
74109
community origin and viewer; channel IDs alone are not sufficient keys.
@@ -97,9 +132,9 @@ not a plugin key service.
97132

98133
Packaged builds do not include the broker. Native macOS, Windows and Linux
99134
[identity import/create](identity.md) and the shared native relay adapter provide
100-
discovery, admission, profile publication, authenticated reads and supported event
101-
writes. Windows/Linux installed-app acceptance remains unverified. Community
102-
creation/removal and background connection eviction are not implemented. Native
135+
discovery, admission, leave requests, profile publication, authenticated reads and
136+
supported event writes. Windows/Linux installed-app acceptance remains unverified.
137+
Community creation and background connection eviction are not implemented. Native
103138
agent enrollment has its own [local control contract](agent-control.md). Avatar
104139
uploads still require the development media host. Agents have local
105140
configuration plus separately scoped participation; selecting a community must
@@ -184,7 +219,21 @@ backup; same-origin plugin JavaScript is trusted and can invoke that IPC too.
184219
## Verification
185220

186221
`src/features/communities/service.test.ts` covers no-community initialization,
187-
local profiles, scoped view intent, session retention and selective restoration.
222+
local profiles, scoped view intent, session retention, selective restoration and
223+
leaving (membership removal, Personal space fallback, session disposal, purged
224+
device state, a leave that keeps device state for the banned answer, the last
225+
community, a purge that leaves named failures, and a native device record that
226+
will not save, which throws before the snapshot, session, record or device state
227+
change). `CommunityRail.test.tsx` covers the leave flow end to end against the
228+
broker route: confirm, publish, then remove; cancel; refusals and timeouts that
229+
keep the membership; the not-a-member answers (purging) and the banned answer
230+
(keeping device state); a device record that will not save after the relay
231+
answered, naming the storage error; a host selection callback that throws after
232+
a completed leave; residual saved data; the host selection of Personal space for
233+
a left selection; focus placement; the in-flight state; and that no inactive
234+
session is acquired. `device-state.test.ts` covers the per-origin purge and its
235+
per-store failure report. The broker and native adapter tests sign the exact
236+
leave shape and pass through only the relay's known refusals.
188237
`broker.test.ts` runs real localhost HTTP with signed fixture events to verify
189238
multi-community routing, profile publication, invite claims, and a captured send
190239
after opening another community. `destination.test.ts` checks normalization and

0 commit comments

Comments
 (0)