Skip to content

feat(import): consented conversation import service, consent card and imported-message rendering - #2229

Draft
jaykurian wants to merge 6 commits into
block:mainfrom
jaykurian:jkurian/conversation-import
Draft

jaykurian wants to merge 6 commits into
block:mainfrom
jaykurian:jkurian/conversation-import

Conversation

@jaykurian

@jaykurian jaykurian commented Nov 3, 2026 •

Copy link
Copy Markdown

Imports a conversation from another workspace into Buzz only after every participant consents. Imported messages and reactions keep their original time and source, and never count as unread, inbox mentions, channel activity or agent triggers.

Relay side: block/buzz#8981. Reference plugin (Import from Slack) in squareup/agents: https://github.com/squareup/agents/pull/8946.

What it does

  • A conversationImport host service, which plugins reach through the context, proposes an import, collects consent through host-owned dialogs, and publishes imported history paced at 8 events per second. It waits for other participants' parents and stops on the first refusal or membership change.
  • Propose needs relay support: the relay must advertise nip-ci in NIP-11 supported_extensions.
  • Publish needs a relay-signed kind 30623 snapshot with status active.
  • Destination members, type and visibility are rechecked after each dialog and before every signed event.
  • Records 42110-42113 carry exactly the NIP-CI tags.
  • attachmentTags({ sha256Hex, name, size, head }) deterministically derives an attachment's url, imeta tags and markdown from the file hash and its first 4096 bytes, sniffed the same way the relay does (relay-media-type.ts mirrors the relay's infer and cfb routing; unknown content becomes .bin, audio is refused). Every participant therefore produces identical event ids. uploadAttachment throws when the server's url or hash differs from the prediction.
  • The consent card reads its own snapshot, so non-participants see how an import ended. Imported rows show a source marker, including a compact one on continuation rows.

Evidence

  • bin/pnpm check passes. An independent review (Opus, three rounds) probed the host for plugin-reachable state, constructor escapes, forged claimants and spoofed clicks; every path is refused except the trust-model limit below. A 1,780-file differential run of relay-media-type.ts against the relay's infer crate found zero divergences.
  • Full vitest: 15324 tests pass across 875 files at the fifth commit; the import, native and mentions set is 146 tests at HEAD.
  • cargo relay tests: 205 pass.
  • New tests cover plugin reachability of host state, listener re-entrancy, expected-member bounds, missing snapshot, visibility flips, abort accounting, and a real session plus outbox mention path.
  • Not yet run: the native Tauri publish path and a live end-to-end import against a relay with NIP-CI.

Risk and trust model

  • Host state is unreachable from plugins, and the outbox's public send and retry refuse import entries. Records 42110-42113 are shape-checked by both the browser broker and the native signer.
  • Trust model: plugins are trusted same-origin code in this architecture, as docs/identity.md states. The host-owned consent dialog, the brand-checked review queue and the isTrusted click check guard against buggy or accidental plugin code, not hostile code. Hostile same-origin script can still reach the dialog's approve closure through React's DOM internals, and for import-tagged kind 9 and kind 7 the signer cannot tell a host request from a plugin request. Closing that boundary needs a native confirmation in the Tauri signer, which is out of scope here. The limit is stated in the NIP-CI Security section.
  • Publishing waits for the relay's accepts_after time and retries import session warming refusals on the same event, so the relay's replica warm-up never skips a message.

Host observations from a live plugin test

Eight plugins from squareup/agents#8946 (the import plugin among them) were installed from local folders into a signed-in Buzz Desktop 0.7.7 and exercised against real connectors. Nothing below blocks this PR, but each is host behaviour the plugins cannot work around:

  • Access review cannot tell processes apart. A plugin that declares several host.processes entries shows one identical row per process ("Start sq: Can start a background process with additional arguments, using your account's full access"); only expanding a row reveals the arguments. The import plugin declares seven, so the review reads as seven copies of the same line. HostProcess has no title or description field (deny_unknown_fields), so the manifest cannot label them.
  • The network proxy sends no User-Agent and follows no redirects. GitHub's API answers 403 to a request with no User-Agent, and moved repositories answer 301 that redirect::Policy::none surfaces to the plugin. Plugins now set their own User-Agent and follow Location within the declared origin, which every network plugin will have to repeat.
  • Every primary page is a sidebar entry. Eight plugins add eight entries above Channels and push Direct messages below the fold on a 977 pt window. A collapsible plugin group, or a per-install prominence choice, would scale better.
  • Plugin message-menu items are appended without icons or a separator, unlike the built-in items.
  • identity-names reports agent-directory as the source for every locally known name, the signed-in owner included. A plugin that read it as "this is an agent" mislabelled the viewer; the positive evidence lives in knownAgentPubkeys. Worth a doc note on NameSource.
  • Memory: the WebContent process grew from about 973 MB with one plugin to about 1214 MB with eight after visiting every page.

Foundation files touched

  • src/app/App.tsx: mounts ConversationImportReview (4 lines).
  • src/app/services.ts: creates the review queue and ConversationImportHost, disposes the queue, and returns both to the host app (11 lines).
  • src/plugins/author.ts: exports the plugin-facing import types, including AttachmentTagsInput.
  • src/features/relay/session.ts: registers the host-only import writer (sendAt, sendRecord, retry, dismiss, local), exposes the conversationImport NIP-11 capability flag, and keeps imported kind 9 out of the starting-message hook.

🤖 Generated with Claude Code

Kinds 42110 to 42113 and the relay-signed 30623 snapshot: record
templates in NIP-CI key and tag order, strict parsers, validation of
prepared imported events, a filter that drops imported history from
live batches, and the plugin-facing service types.

Signed-off-by: jaykurian <49807026+jaykurian@users.noreply.github.com>
The outbox gains sendAt for imported history at its original time with a
deterministic id, and sendRecord for import records carrying exactly the
NIP-CI tags. Both go through a module-private send path; the public send
and retry refuse import entries, so listeners cannot forge them. A
session's import writer serves only the first service that claims it.
Failed import entries do not count toward the pending limit. Relay
refusal text is kept on the journal entry. The native signer checks the
record shape of kinds 42110 to 42113 as the browser broker does, and
hosts report NIP-CI support from the relay's NIP-11 document.

Signed-off-by: jaykurian <49807026+jaykurian@users.noreply.github.com>
Imported messages and reactions never count as unread evidence, inbox
mentions, channel activity or agent triggers.

Signed-off-by: jaykurian <49807026+jaykurian@users.noreply.github.com>
Consent, withdrawal and completion records render as system lines.
Imported messages show their source and original time, an edited marker
when the source recorded an edit, a compact marker on continuation rows,
no manual Retry, and never trigger the new-message divider.

Signed-off-by: jaykurian <49807026+jaykurian@users.noreply.github.com>
The conversationImport service checks verified identities and
membership, shows host-owned confirmation dialogs for proposals,
consents and new destinations, and publishes imported history paced at
8 events per second, waiting for other participants' parents and
stopping on the first refusal or membership change. Host state is
unreachable from plugins, and only the host can construct the service;
dialogs approve only on a trusted click. Proposals and consents need
relay NIP-CI support; publishing needs an active relay snapshot, and the
destination is rechecked after each dialog and before each event.
Attachment tags are derived from the file hash and the type the relay
sniffs from the file's first bytes, so every participant produces the
same event ids. The proposal renders as a consent card that reads its
own snapshot, with a progress banner while active. Types are exported
through the author package; gallery specimens added.

Signed-off-by: jaykurian <49807026+jaykurian@users.noreply.github.com>
The relay refuses imported events for a short time after a session turns
active and states when it will accept them in the snapshot's
accepts_after tag. The snapshot read model carries it as acceptsAfter on
this device's clock, moved earlier when the snapshot shows the relay's
clock running ahead. publish waits until then before signing the first
event, reporting progress phase "starting", and a cancel during the wait
stops the run. A "session warming" refusal backs off to acceptsAfter, or
5 seconds without one, and publishes the same event again. The consent
card counts down to the start while the import is active.

Signed-off-by: jaykurian <49807026+jaykurian@users.noreply.github.com>
matt2e added a commit that referenced this pull request Nov 9, 2026
## What the user saw

When the relay refused a plain-text send, the message row stayed silent
for about ten seconds and only then showed a small Retry. The relay
actually answers in about 50 ms, so the user had no idea the message had
failed until the ten-second delivery grace ran out.

## The fix

`deliveryFeedback` applied the 10 s delivery grace (measured from
`created_at`) to every non-`seen` state, `failed` included. The grace
exists to hide uncertainty, and a `failed` send is not uncertain: every
path to `failed` (relay refusal, rate-limited `PublishNotSent`, HTTP
refusal, pre-publish error) proves the message was not delivered, while
a transport error mid-publish becomes `unknown`.

The grace check now applies only when `delivery !== "failed"`.
`sending`, `accepted` and `unknown` still wait ten seconds from the
message timestamp. A failed send restored after a reload shows Retry at
once. `DeliveryNotice` needs no change: a new row re-renders it, and its
grace timer is harmless for failed rows.

The guard is keyed on the delivery state rather than the outbox item's
`refused` flag, which never reaches `ChannelMessage`, is dropped on
reload, and is not set for rate-limit refusals.

## Before and after

"Lunch at 12?" is sent in #Alpha in both panels at the same moment and
the relay refuses it as rate-limited. The overlay clock counts from
pressing Enter.

| | Relay refused | Retry visible |
|---|---|---|
| Before (main `58116b8`) | 0.06 s | 9.23 s |
| After (fix) | 0.06 s | 0.06 s |


https://github.com/user-attachments/assets/9253a010-28de-4670-80b6-9e28841145a0

![Before pressing Enter: both panels hold "Lunch at 12?" in the
composer](https://github.com/user-attachments/assets/edbf14de-02d5-49f5-945e-9377e754871c)

![Enter + 8.5 s: both relays refused at 0.06 s, but only the right-hand
(fixed) row shows Retry; the left row is still
quiet](https://github.com/user-attachments/assets/63b995f4-3890-4af2-ae48-fb3ab217339b)

## Docs

- `docs/shell-design.md`: the delivery rule now says failed sends show
Retry immediately and only unconfirmed sends wait about ten seconds.
- `docs/buzz-help.md`: same rule in the bundled help.

## Verification

- `src/features/messages/delivery.test.ts`: narrows the ten-second quiet
case to unconfirmed states and adds a failed-inside-the-grace case.
- `src/features/messages/DeliveryNotice.test.tsx`: rerenders a row
inside the grace as `sending`, `failed`, then `unknown` and expects no
status, Retry, then no status.
- Both new tests failed before the fix and pass after it.
- `tsc --noEmit` and Biome are clean.

## Scope

This is PR 1 of three independent changes from the refused-send note
(the other two are the sidebar unsent marker and keeping failed sends
out of previews). #2229 touches `DeliveryNotice.tsx` only in `canRetry`
(an imported-row guard) and leaves the grace alone, so there is no
conflict.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: mtoohey <mtoohey@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant