Skip to content

Commit 32a56a0

Browse files
committed
Merge main into am-consolidated-panel
Signed-off-by: Arjun Mahanti <[email protected]>
2 parents cf0ae42 + 6de1ab4 commit 32a56a0

103 files changed

Lines changed: 3281 additions & 714 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.

‎README.md‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ an existing supported credential, live development is unavailable; shell and
120120
fixture tests still work.
121121

122122
Media attachments in live development need `ffmpeg` on the server’s PATH for
123-
video, HEIC/HEIF, and the existing `voice-note-*.wav` exception (macOS:
124-
`brew install ffmpeg`; Linux: your distribution’s ffmpeg package). The broker
123+
video, HEIC/HEIF, and the existing `voice-note-*.wav` exception. Install ffmpeg on the host (macOS: `brew install ffmpeg`; Linux: your
124+
distribution’s ffmpeg package); HEIC tile grids require ffmpeg 8 or newer.
125+
Like `block/buzz`, real conversion tests return early when optional host tools
126+
are missing; tiled-HEIC tests also require ffmpeg 8+ and ffprobe. These tools are
127+
not pinned through Hermit or provisioned by CI. Packaged apps use the host's
128+
installed ffmpeg and reject HEIC preparation if its version is older than 8 or
129+
cannot be determined. The broker
125130
prepares canonical H.264/AAC MP4 or single-frame JPEG before upload hashes/signs
126131
those exact bytes. Missing tools and unsupported codecs fail visibly. No generic
127132
audio conversion or recording UI is added.
@@ -146,8 +151,9 @@ Picker/paste/drop share the same tab-local draft. Files must finish uploading
146151
before Send; navigation pauses unfinished uploads for explicit Retry. Reload loses
147152
unsent files. Background Send, attachment-first new sessions and UX polish are
148153
separate work. Live uploads use the development broker in dev runs and the
149-
native `relay_upload` path in packaged desktop builds. Packaged HEIC and non-MP4
150-
video files are not converted by the broker and may be rejected by the relay.
154+
native `relay_upload` path in packaged desktop builds. The native host prepares
155+
HEIC and supported video/voice-note inputs with fixed demuxers and bounded child
156+
processes before upload; it requires ffmpeg installed on the host.
151157

152158
The broker supports reads, live traffic and basic message sending **as your real
153159
account**. Profile changes and invite admission can also write to real communities.

‎crates/agent-controller/src/runtime.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,9 @@ impl Controller {
546546
self.store.use_here(id, resolution)?;
547547
self.snapshot()
548548
}
549+
pub fn local_clone_settings(&self, id: &str) -> Result<crate::CloneSettings> {
550+
self.store.local_clone_settings(id)
551+
}
549552
pub fn prepare_import(
550553
&self,
551554
imports: &mut crate::Imports,

‎crates/agent-controller/src/runtime/tests.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,6 +2468,10 @@ fn use_here_rejects_configured_other_community_without_writes() {
24682468
.unwrap_err();
24692469
assert!(error.contains("Clone"));
24702470
assert_eq!(fs::read(&path).unwrap(), before);
2471+
assert_eq!(
2472+
store.local_clone_settings(&id).unwrap().system_prompt,
2473+
"test prompt"
2474+
);
24712475
}
24722476

24732477
#[test]

‎crates/agent-controller/src/store.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,17 @@ impl Store {
339339
}
340340
self.write(&doc)
341341
}
342+
pub fn local_clone_settings(&self, id: &str) -> Result<crate::CloneSettings> {
343+
let agent = self
344+
.agents()?
345+
.into_iter()
346+
.find(|agent| agent.id == id)
347+
.ok_or("Local identity no longer exists")?;
348+
Ok(crate::CloneSettings {
349+
name: agent.name,
350+
system_prompt: agent.system_prompt,
351+
})
352+
}
342353
pub fn save(&mut self, id: &str, revision: u64, edit: AgentEdit) -> Result<()> {
343354
let mut doc = self.read()?;
344355
let agent = doc
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { execFileSync } from "node:child_process";
2+
import { readFile } from "node:fs/promises";
3+
import { Readable } from "node:stream";
4+
import { expect, test } from "vitest";
5+
import { prepareMedia } from "./media-preparation.mjs";
6+
7+
// Match block/buzz: real conversion tests return early when optional host tools
8+
// are absent. Installed tools must still succeed; conversion failures are not skipped.
9+
function mediaToolVersion(name) {
10+
try {
11+
return execFileSync(name, ["-version"], { encoding: "utf8" });
12+
} catch (error) {
13+
if (error.code !== "ENOENT") throw error;
14+
console.warn(`skipping real conversion: ${name} not found`);
15+
return null;
16+
}
17+
}
18+
19+
test("tiled HEIC preparation preserves the full image dimensions", async () => {
20+
const version = mediaToolVersion("ffmpeg");
21+
if (version === null) return;
22+
// This fixture requires grid support; older host versions remain optional.
23+
const major = /^ffmpeg version n?(\d+)\./.exec(version)?.[1];
24+
if (!major || Number(major) < 8) {
25+
console.warn("skipping tiled HEIC conversion: ffmpeg 8+ required");
26+
return;
27+
}
28+
if (mediaToolVersion("ffprobe") === null) return;
29+
const bytes = await readFile(
30+
new URL("../tests/fixtures/media/tiled.heic", import.meta.url),
31+
);
32+
const req = Readable.from([bytes]);
33+
req.headers = { "x-attachment-name": "tiled.heic" };
34+
await prepareMedia(
35+
req,
36+
new AbortController().signal,
37+
async (path, type, size) => {
38+
expect(type).toBe("image/jpeg");
39+
expect(size).toBeGreaterThan(0);
40+
const dimensions = execFileSync(
41+
"ffprobe",
42+
[
43+
"-v",
44+
"error",
45+
"-show_entries",
46+
"stream=width,height",
47+
"-of",
48+
"csv=p=0",
49+
path,
50+
],
51+
{ encoding: "utf8" },
52+
);
53+
expect(dimensions.trim()).toBe("1536,1024");
54+
},
55+
);
56+
}, 30_000);

‎dev/media-preparation.mjs‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { UploadError, UPLOAD_MAX_BYTES } from "./attachment-upload.mjs";
1616
function run(args, signal, timeout = VIDEO_PREPARATION_MS) {
1717
return new Promise((resolve, reject) => {
1818
let failure;
19+
let stdout;
1920
const child = execFile(
2021
"ffmpeg",
2122
args,
@@ -33,7 +34,8 @@ function run(args, signal, timeout = VIDEO_PREPARATION_MS) {
3334
: {}),
3435
},
3536
},
36-
(error) => {
37+
(error, output) => {
38+
stdout = output;
3739
failure ??= error;
3840
},
3941
);
@@ -44,7 +46,7 @@ function run(args, signal, timeout = VIDEO_PREPARATION_MS) {
4446
if (signal.aborted) reject(signal.reason);
4547
else if (failure || code !== 0)
4648
reject(failure ?? new Error("Conversion failed"));
47-
else resolve();
49+
else resolve(stdout);
4850
});
4951
});
5052
}
@@ -104,6 +106,11 @@ export async function prepareMedia(req, callerSignal, deliver) {
104106
.catch(() => {}); // Output need not exist yet; process completion is authoritative.
105107
}, 250);
106108
try {
109+
if (heic) {
110+
const version = await run(["-version"], bounded, 5_000);
111+
const major = /^ffmpeg version n?(\d+)\./.exec(version ?? "")?.[1];
112+
if (!major || Number(major) < 8) throw new UploadError("ffmpeg", 503);
113+
}
107114
await run(
108115
[
109116
"-y",
@@ -120,8 +127,7 @@ export async function prepareMedia(req, callerSignal, deliver) {
120127
source,
121128
...(heic
122129
? [
123-
"-map",
124-
"0:v:0",
130+
// Automatic selection assembles HEIC grids, not the first tile.
125131
"-map_metadata",
126132
"-1",
127133
"-frames:v",
@@ -178,6 +184,7 @@ export async function prepareMedia(req, callerSignal, deliver) {
178184
} catch (error) {
179185
signal.throwIfAborted();
180186
if (outputLimitExceeded) throw new UploadError("size", 413);
187+
if (error instanceof UploadError) throw error;
181188
throw new UploadError(
182189
error.code === "ENOENT" ? "ffmpeg" : heic ? "image" : "video",
183190
error.code === "ENOENT" ? 503 : 400,

‎dev/media-preparation.test.mjs‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,48 @@ test("the production broker deadline destroys an undrained response, cleans its
227227
});
228228
}
229229
});
230+
231+
test("old ffmpeg fails closed before HEIC conversion or delivery", async () => {
232+
const launches = [];
233+
processFixture.launch = (_command, args, _options, callback) => {
234+
launches.push(args);
235+
const child = new EventEmitter();
236+
queueMicrotask(() => {
237+
callback(null, "ffmpeg version 7.1.4 Copyright");
238+
child.emit("close", 0);
239+
});
240+
return child;
241+
};
242+
const deliver = vi.fn();
243+
await expect(
244+
prepareMedia(request("photo.heic"), new AbortController().signal, deliver),
245+
).rejects.toMatchObject({ code: "ffmpeg", status: 503 });
246+
expect(launches).toEqual([["-version"]]);
247+
expect(deliver).not.toHaveBeenCalled();
248+
});
249+
250+
test("release n-prefix versions permit HEIC conversion", async () => {
251+
processFixture.launch = (_command, args, _options, callback) => {
252+
const child = new EventEmitter();
253+
void (async () => {
254+
await Promise.resolve(); // execFile cannot close before its listeners exist.
255+
if (args[0] === "-version")
256+
callback(null, "ffmpeg version n9.0.2 Copyright");
257+
else {
258+
const file = await open(args.at(-1), "w");
259+
await file.write("jpeg");
260+
await file.close();
261+
callback(null);
262+
}
263+
child.emit("close", 0);
264+
})();
265+
return child;
266+
};
267+
const deliver = vi.fn();
268+
await prepareMedia(
269+
request("photo.heic"),
270+
new AbortController().signal,
271+
deliver,
272+
);
273+
expect(deliver).toHaveBeenCalledOnce();
274+
});

‎dev/relay-broker.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import {
7777
SIDEBAR_UPLOAD_SLOTS,
7878
} from "./sidebar-preferences.mjs";
7979
import { createHostAdmission } from "../src/features/relay/host-admission.ts";
80-
import { relayKlipySearchPath } from "../src/features/relay/gifs.ts";
80+
import { relayKlipySearchPath } from "../src/features/relay/gif-capability.ts";
8181
import {
8282
validEmojiSetTemplate,
8383
validReactionContent,

‎docs/communities.md‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,10 @@ read, and only while its read state syncs; Invite shows only where the viewer
7676
owns or administers the selected community and this build can mint invites,
7777
with the role read from the relay-signed roster through the selected
7878
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,
79+
Membership settings card applies the same role gate in both development and
80+
native builds. Native owners and admins can read the relay-signed member list
81+
and mint invite links, but direct additions and per-member actions remain absent:
82+
the packaged adapter does not carry the broker's `member` route. Copy,
8483
Community settings and Leave work on inactive communities without opening their
8584
sessions. Leave asks for confirmation, then sends a signed NIP-43 leave request
8685
(kind 28936) to that community's relay before the device forgets it. Three
@@ -133,10 +132,12 @@ not a plugin key service.
133132
Packaged builds do not include the broker. Native macOS, Windows and Linux
134133
[identity import/create](identity.md) and the shared native relay adapter provide
135134
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
138-
agent enrollment has its own [local control contract](agent-control.md). Avatar
139-
uploads still require the development media host. Agents have local
135+
supported event writes. Native invite minting and relay-advertised KLIPY GIF search
136+
use the same captured HTTPS community; neither requires the development broker.
137+
Windows/Linux installed-app acceptance remains unverified. Community creation and
138+
background connection eviction are not implemented. Native agent enrollment has
139+
its own [local control contract](agent-control.md). Avatar uploads still require
140+
the development media host. Agents have local
140141
configuration plus separately scoped participation; selecting a community must
141142
not become a deployment or enrollment command.
142143

‎docs/deep-links.md‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,23 @@ The OS ingress accepts the Buzz link forms and nothing else:
2525
Entity sections are `files`, `commits`, `issues`, `prs`, `contributors`, and
2626
`channels`; omitting the section opens the overview. Repository commit links add
2727
`&tab=commits&commit=<40- or 64-hex hash>`. Identifiers use 1-64 ASCII letters,
28-
digits, `_`, `-`, or `.`, without a leading dot or `..`. Unknown or duplicate
29-
parameters are rejected. The same forms work in message content.
28+
digits, `_`, `-`, or `.`, without a leading dot or `..`. Query parameters outside
29+
a form's grammar are ignored, with their values and any repeats, so a link that
30+
another client decorated still opens; a duplicated known parameter is rejected as
31+
ambiguous. The `channel` forms carry everything in the path and ignore any query.
32+
The same forms work in message content.
3033

3134
None carries a community, so each binds to the currently selected community and
3235
viewer, and fail `unavailable` when no community is selected or no identity is
33-
known. Every other link, including `buzz://open?target=…`, `buzz://join`,
34-
incomplete entity links, unknown hosts and oversize links, fails as
35-
`invalid-target` and shows "This destination couldn't open" with
36-
**Open Settings**. Unsupported links have no Retry action. Nothing is
37-
auto-joined. A valid address is never authorization: bound targets pass the same
38-
viewer, membership and channel checks as in-app navigation, so a link into a channel
39-
you cannot read still fails `denied`. The frontend expects the canonical lowercase
40-
`buzz:` scheme; the native URL parser can normalize scheme case before delivery,
41-
so uppercase OS input is not guaranteed to be rejected.
36+
known. Every other link, including `buzz://join`, incomplete entity links,
37+
unknown hosts and oversize links, fails as `invalid-target` and shows "This
38+
destination couldn't open" with **Open Settings**. Unsupported links have no
39+
Retry action. Nothing is auto-joined. A valid address is never authorization:
40+
bound targets pass the same viewer, membership and channel checks as in-app
41+
navigation, so a link into a channel you cannot read still fails `denied`. The
42+
frontend expects the canonical lowercase `buzz:` scheme; the native URL parser
43+
can normalize scheme case before delivery, so uppercase OS input is not
44+
guaranteed to be rejected.
4245

4346
The latest arriving link wins. Before readiness, one pending intent is retained;
4447
if identity or community is missing, select a community and use **Retry navigation**.
@@ -61,8 +64,9 @@ explicit Git sections report navigation failure, not an empty successful page.
6164
This deliberately omits the sender's community and identity: recipients must select
6265
the correct community before opening it. Original mobile Buzz requires a UUID
6366
channel identifier; named development channels are supported here but do not imply
64-
mobile compatibility. Existing `buzz://open` locators still preserve community
65-
context for in-app use and remain unsupported at the OS boundary.
67+
mobile compatibility. The app has no link form of its own beyond the Buzz ones:
68+
unknown `buzz://` hosts are rejected everywhere, staying plain text in message
69+
content and failing `invalid-target` at the OS boundary.
6670

6771
## Testing locally
6872

0 commit comments

Comments
 (0)