Skip to content

Chat and People with Home: connect, approve contacts and recover (#86) - #123

Closed
irzhywau wants to merge 52 commits into
developfrom
feat/0.7.1-chat-people-on-invite
Closed

irzhywau wants to merge 52 commits into
developfrom
feat/0.7.1-chat-people-on-invite

Conversation

@irzhywau

@irzhywau irzhywau commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

This PR connects Home’s first visit with Community and contacts. Create account is visible when registration is available, and the welcome asks for a first Recovery Kit. A signed-in person creates a Profile, enables Discovery and sends a contact request from a Community Profile card. The recipient accepts or declines in Inbox. Message selects the exact direct conversation in the current Chat window; Inbox Open launches that exact conversation.

Drafts stay with their conversation. Accepted send responses clear only the revision they sent, and uncertain direct sends retain their request identity across navigation. Session loss shows Reconnect with a clear explanation. One explicit click asks Home for fresh launch authority in the same iframe document, then restores the selected conversation and draft. Home owns sign-in. Guards keep old responses from changing renewed authority or the current selection, including Direct list, history and send 401 failures. Shared text and attachment receipts use the same deduplication and forward-only cursor rule.

The integration preserves Profile-card response and focus guards, attachments and object links through Home, the Attach accessible name, reading position, per-account direct unread indicators and notifications, and terminal signing refusal and UTF-8 input. Unused join-by-invite controls are removed; supported gateway access and link creation/revocation remain.

The signed release pins the Community configuration CID and signer set. Setup fetches that exact CID through Runtime and enforces a 3 MiB bound before reading the body. Setup and update verify the pinned configuration through their existing admission paths. Before the first start, --isolated records the choice and removes a release-supplied network file while preserving operator configuration. Undo restores the earlier release and keeps the joined network, accepted revision and later user data. The production configuration uses the approved maintainer signer and its separate profile-signature domain, with signing under the existing offline custody workflow. These changes follow Anders’s network decision.

The approved contact capability remains POST /api/apps/chat-room/contacts/request with only {"participant_ref":"contact:<24 hex>"}. It requires a valid Chat launch token, the sender’s own Profile and a recipient in current Discovery. Runtime signs and queues the request; the recipient owns the Inbox decision. Runtime keeps Profile and device DIDs private. Bounds remain 16 requests per sender, 128 stored records and 512 KiB, with one pending request per person/listing. Relay bounds remain 32 per recipient and 64 total; requests expire after one hour and listings after ten minutes.

#86 and #139 own current acceptance and exact-candidate proof. Verification covers fresh signup, Profile/contact/Inbox paths, initial conversation selection, held responses and drafts, explicit same-document recovery, peer delivery, restart and retained history. Installed journey proof, required reviews and Sasha’s first-visit/Chat acceptance remain merge gates. The approved order is #89 closure, then #123, then #262 integration and bundle rebuild. Delivery/retry, catch-up and Community limits remain in #139/#262; signup capacity/retry acceptance remains in #260; leaving Community remains in #264.

@irzhywau irzhywau added this to the 0.7.1 milestone Sep 29, 2026
@irzhywau
irzhywau added this pull request to stack #124 September 29, 2026 18:39
@andersalm andersalm mentioned this pull request Sep 30, 2026
9 tasks
@irzhywau
irzhywau marked this pull request as ready for review September 30, 2026 14:11
@irzhywau
irzhywau force-pushed the feat/0.7.1-chat-people-on-invite branch 3 times, most recently from 3f4375b to 9e9c016 Compare September 30, 2026 16:31
@andersalm andersalm mentioned this pull request Sep 30, 2026
7 of 12 tasks
@irzhywau
irzhywau removed this pull request from stack #124 September 30, 2026 16:54
@irzhywau
irzhywau changed the base branch from fix/chat-invite-in-home-0.7.1-models to feat/0.7.1-models September 30, 2026 16:55
@andersalm andersalm modified the milestones: 0.8.0, 0.7.2 Sep 30, 2026
@andersalm

Copy link
Copy Markdown
Contributor

AI pre-review of the server part, prepared for Anders's review. This is agent review evidence, not an approval and not the human review. @irzhywau, please check each point; where the AI is wrong, say so and we drop it.

What checks out: sign-up stays gated by the admin flag guest_registration_enabled; the pin check (CID, network ID, signer set, then the startup validator) is sound and writes owner-only files; the new endpoint serves no secrets; Discovery's connecting state, retry cap and outbox changes match #86; invite stages 2 and 3 are not in this PR.

Blocker (verified by hand)

  1. Update breaks once a release pins collaboration_network. The real update fetchers are positional: release_cmd.rs:63-68 serves four files and returns unexpected fetch #4 on the fifth call, before any gateway fallback (the reviewer reports the same pattern in operator_control.rs:534-539). Step 11b (update.rs:856-860) makes that fifth call after the new binary and components.json are already installed, so every elastos update and operator apply fails halfway and each retry fails the same way. The unit tests pass because they inject a CID-keyed mock. Fix: fetch and verify the network file by name with the other downloads before the binary is replaced, then install it after step 11.

Major
2. The isolation hint never works. Setup prints elastos setup --isolated, but choose_isolated refuses whenever collaboration-network-v1.json exists (collaboration_release_network.rs:85-91), and after the next start Runtime refuses to remove the network. #86 agreed that setup shows where to turn it off. Fix: let --isolated remove a config equal to the release copy while no accepted-head marker exists, and word the hint for started Homes truthfully.
3. Setup fails when the release copy was never staged (collaboration_release_network.rs:156-161): a Home updated by an older binary gets the new components.json but not collaboration-network-release-v1.json. Fix: fetch it by the pinned CID or skip with a notice, or ship the pin one release after this code.
4. The unread dot and the DM realtime marker are Home-wide, not per account (notifications.rs:12, gateway_room.rs:81-86,113, gateway_home_system.rs:5204-5214). On a multi-account Home such as the seed, a sender sees their own message as unread and clears the recipient's dot. Fix: key direct-message notifications by account.
5. Scope: the fixed 15 GiB free-space floor (elastos-common/src/lib.rs:47-50) replaces the 10% rule for IPFS, model preparation, Browser image and hosted egress, and changes AGENTS.md policy. It is unrelated to #86 and stricter on every volume under 150 GiB. Fix: move it to its own PR for Anders to decide.

Minor
6. The unauthenticated collaboration-network endpoint (gateway_room.rs:349-358) republishes the bootstrap node ID and ticket from any reachable Home, and nothing reads it yet. Remove it until a consumer exists, or serve only the release-pinned bytes; correct the comment and docs/COLLABORATION_NETWORK_PROFILE.md:118-123.
7. Tests: add an update test with a positional Carrier-style fetcher, handler tests for the contact request (no token, not visible, success), and a test for the stop on an expired advertisement.

CI note: develop now requires the 8 checks on the PR head. The dispatch run 36747808294 passed at 9e9c016c but does not count; your next push starts the PR checks.

@irzhywau
irzhywau force-pushed the feat/0.7.1-chat-people-on-invite branch from 9e9c016 to 1ae2549 Compare October 5, 2026 11:11
@irzhywau
irzhywau changed the base branch from develop to fix/drop-free-space-floor October 5, 2026 11:11
@irzhywau
irzhywau added this pull request to stack #235 October 5, 2026 11:11
@irzhywau
irzhywau force-pushed the feat/0.7.1-chat-people-on-invite branch from 1ae2549 to 43ecf6d Compare October 5, 2026 12:25
@irzhywau
irzhywau force-pushed the feat/0.7.1-chat-people-on-invite branch 2 times, most recently from 15a2759 to 023f8e5 Compare October 5, 2026 19:20
@irzhywau irzhywau self-assigned this Oct 5, 2026
@irzhywau

irzhywau commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@andersalm Thanks. Here's where each point of your 30 September pre-review stands, on head 023f8e55 (rebased on today's develop 4b34967c).

1. Updates break once a release pins the network: fixed.
The network file now travels with the signed release like the other release files: it is signed, published, and checked against the pin. During elastos update it is downloaded and checked before the new Runtime replaces the old one; if anything fails, the update rolls back and the Home keeps its previous release. The new tests use a download source that only serves what the signed release really contains, so this cannot hide behind a mock again.
One question: update downloads the file by its pinned content ID, not by file name, because that is the only way the update downloader on develop fetches files. Setup downloads it by name. Is that OK?

2. The --isolated hint doesn't work: still open, I'd like your decision.
Today --isolated refuses as soon as the Home has a network file, so the hint printed by setup is misleading. Two options:

  • (a) let --isolated remove the release network file, as long as the Home has not started with it yet;
  • (b) keep that behaviour and correct the hint: isolation is only possible before the first start.

I'd go with (a). Also: should a Home that has already joined Community be able to leave?

3. Setup fails if the network file was never copied: fixed.
Homes installed with install.sh now download the network file during setup and check it before writing anything. A source setup with a missing file stops with a clear error that names the file and points to --isolated.

4. Unread dots are shared by everyone on the same Home: still open.
On a Home with several accounts, one person's messages can show as unread for, or be cleared by, another person. I can fix it here by tracking unread per account, or we move it to #139. It only affects Homes with several accounts. Which do you prefer?

5. The free-space change doesn't belong here: done.
It is out of this PR and lives in #234, for you to decide.

6. The public network-file endpoint: removed.
Nothing used it, and #173 allows no new public route without approval.

7. Missing tests: partly done.
Done: the update tests from point 1, plus setup and release tests for the network file.
Still to add: contact-request tests (refused when not signed in, refused when the person is not visible, success) and a test that a request stops being resent once the other person's Discovery listing expires.

Next: I'll describe the contact-request capability on #86 for your approval, and run the installed Home journey on this exact commit.

@irzhywau
irzhywau force-pushed the feat/0.7.1-chat-people-on-invite branch from 023f8e5 to a2d3e86 Compare October 5, 2026 22:11
@irzhywau
irzhywau force-pushed the feat/0.7.1-chat-people-on-invite branch from a2d3e86 to c731827 Compare October 6, 2026 09:26
irzhywau and others added 10 commits October 8, 2026 19:41
…s belong to their card

Inside Home a lost conversation session only changed a status row that Home
never shows, so Chat sat on 'Opening conversation' with a dark composer. The
reason now shows as a lasting message with one Reconnect action. It starts a
new session with Chat's Home launch token without reloading the page, so
unsent drafts stay, and nothing signs in on its own; when Home no longer
admits the launch, Chat says to open it again from Home.

An Add contact reply arriving after the card was closed or reopened for
someone else wrote into that other card. Replies now update only the
opening that sent them. Closing the card with its button or Escape returns
keyboard focus to the exact name that opened it: a message sender is found
again by its message seq, so focus does not jump to an earlier message by
the same person. When that name is gone, focus goes to the composer.
…ing keeps its place

Open in Documents and elastos:// links posted to the parent frame at Chat's
own origin. Home loads Chat in an opaque frame, so that origin is "null" and
the request never arrived; Documents' reply, which Home relays, was also
refused because it did not come from Chat's origin. Both requests now use
the admitted Home path the Library picker uses (Home's top window at the
?home_origin= origin), and the reply is accepted from Home.

The shared room removed the Attach button's title and aria-label, leaving an
icon-only button with no accessible name. It now keeps 'Attach'.

Every new message forced the view to the bottom, pulling a person reading
older history away. Only a new session now opens at the newest message;
later messages follow a reader already at the bottom. A person's own
Community send still scrolls down, but only while Community is open, so a
late response does not move them inside a direct conversation.
…8 typing

When signing failed, terminal Chat still broadcast the line without a
signature and printed it as sent, although every receiver drops an unsigned
line. The signer now treats an HTTP refusal or an empty signature as no
signature, and the line is refused before broadcast with a clear reason.

The terminal read one byte at a time and pushed each byte as a char, so 'é'
became 'é' in the echo and the sent text. Bytes of one UTF-8 character are
now collected and pushed as that character; an invalid sequence is dropped.
The Join a Conversation form and the ?invite= / ?join= launch path posted
to /invites/join, which Runtime always refuses (409, gateway_room.rs), and
outside Home the form refused before posting. Chat drops that form, its
launch path, its styles and the compact-rail rule that waited on it, and
the smokes stop expecting it.

Creating and revoking join links stays: those routes still work for an
unconfigured Runtime, and browser-guest (gateway) mode is unchanged until
the people who open Chat outside Home are listed on #86.
Installed setup asked the trusted source for the network file by its release
name, which could serve newer bytes than the signed pin; they were refused
only after the download. Setup now fetches it by the pinned CID, as the CLI
and System updates do, with the 3 MiB startup-configuration bound applied
from the length header. The setup test serves the network only by CID and
fails on a by-name request.
Undo installs an older release through the same path as an update. A Home
that joined the release Community network keeps it: a release without a pin
leaves it alone, and an older pin never replaces the newer accepted chain,
because Runtime never drops an accepted network. 'Undo an update' now says
so, and a test updates to a release that joins the network, then undoes to
an unpinned release and to an older pin and checks the network stays.
…iner key

The provisioning contract required a dedicated configuration key that is
never the release publisher. The production Community network instead uses
the release maintainer DID: profile signatures have their own domain and the
signed release pins the file's CID and signer set, so one key is safe.
Production profiles are signed by the offline release custodian; the
create-authority-key flow stays for disposable test and fixture networks.
Rebuilt with scripts/build-chat-room-ui.sh (now path-independent on
develop, so the wasm embeds no builder paths) from the drafts, Reconnect,
Profile card, attachment, Attach, scroll and invite-control changes. The
asset cache version moves to chat-room-ui-20261008a so browsers load the
new bundle.
@irzhywau

irzhywau commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 460a38ff (fast-forward from cdf62ca7, normal merge of develop d430a133) with your 8 Oct answers: (1) Reconnect is one person-chosen action that restarts the session with Chat's Home launch token in place, since Home's policy lets chat-room open only Library and a reload would lose drafts; no automatic sign-in, drafts kept. (2) Bundle rebuilt with the new script (0 builder paths, cache chat-room-ui-20261008a). (3) Dead join-by-invite controls removed; gateway mode and link create/revoke unchanged. Setup fetches the network by its pinned CID (3 MiB bound); docs/INSTALL.md "Undo an update" states that Undo keeps a joined network and undo_to_an_older_release_keeps_the_joined_network proves it; the profile docs name the maintainer DID and offline custodian as the production signer.
Also the #86 audit repairs: drafts per conversation with send revisions and held request IDs, Profile card replies and focus, attachments and elastos:// links through Home, Attach's name, reading place kept, terminal Chat refuses unsigned lines and keeps UTF-8. just test-elastos 4141/0. Independent adversarial review (Codex) of feat/0.7.1-chat-people-on-invite @ 460a38f VERDICT: PASS
Open: the list of who opens Chat outside Home for #86, Sasha's Chat check, merge after #89.

…puts

Preserve the owner draft, attachment, terminal and profile repairs. Keep fresh Home authority, Direct 401 recovery, exact launch intent and guarded two-Home acceptance together. Independent source review passed on UI/Home, network/Undo and harness resolutions.
Native Chat UI tests and Clippy pass before the release WASM build. Generated assets retain path-independent compiler inputs.
A poll can receive the accepted message before its held send response. Reuse canonical deduplication and preserve the newer sequence cursor. The regression covers repeated receipts after later peer traffic and preserves draft revisions.
Use the tested shared-object completion helper for attachments too. Native UI tests, Clippy and release WASM build pass; independent source review confirms the picker guards and error paths stay intact.
@andersalm andersalm changed the title Chat and People with Home: sign-up, welcome text, Discovery (#86) Chat and People with Home: connect, approve contacts and recover (#86) Oct 8, 2026
@andersalm
andersalm requested a review from SashaMIT October 8, 2026 18:23
@andersalm

Copy link
Copy Markdown
Contributor

Independent development review — VERDICT: PASS.
Reviewed Home authority, drafts and receipt handling, pinned setup/Undo, and the strict two-Home harness.
Source and refusal checks pass; installed proof and human acceptance are recorded in #139.

@andersalm

Copy link
Copy Markdown
Contributor

Independent adversarial review (Claude Opus via elastos-pr-review) — VERDICT: PASS.
Blocking findings: none; contact authority, network pin, Reconnect and account alert scope were reviewed.
Source review only; installed journey and human acceptance remain in #139.

@andersalm

Copy link
Copy Markdown
Contributor

Today I pushed de5a986 and then ea9bee4 to feat/0.7.1-chat-people-on-invite; the second push completed at19:48:37UTC before the pause request.
67c0cf5 is included in published ea9bee4; the Wallet-provider fixture fixes remain local in the isolated fixture. wt-chat-connect is preserved for Irzhy to select the changes.
Chat lane is paused. The Chat build/install finished before stop, both test Homes are stopped, the review process was stopped, and the shared heavy-build lock is free; I will make no further pushes to this branch or fix/139-spam-limits.

@andersalm

Copy link
Copy Markdown
Contributor

This PR is superseded by #140 / #309.
Please close it when convenient; its retained work continues there.

@andersalm

Copy link
Copy Markdown
Contributor

Closing as superseded: every commit of this PR is contained in #309 (git rev-list origin/fix/139-chat-stability..<this branch> is empty). #309 carries it to develop.

@andersalm andersalm closed this Oct 11, 2026
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.

G3 Community chat: Chat and People with Home

2 participants