@peers-app/peers-ui 0.25.1 → 0.25.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +2 -1
  2. package/dist/components/markdown-editor/mention-node.d.ts +4 -0
  3. package/dist/components/markdown-editor/mention-node.js +4 -1
  4. package/dist/components/responsive-section-nav.d.ts +34 -0
  5. package/dist/components/responsive-section-nav.js +19 -0
  6. package/dist/components/responsive-section-nav.test.d.ts +1 -0
  7. package/dist/components/responsive-section-nav.test.js +45 -0
  8. package/dist/components/router.d.ts +2 -3
  9. package/dist/components/router.js +6 -9
  10. package/dist/globals-hash.test.d.ts +1 -0
  11. package/dist/globals-hash.test.js +16 -0
  12. package/dist/globals.d.ts +19 -0
  13. package/dist/globals.js +51 -12
  14. package/dist/hooks/use-host-contract.d.ts +18 -0
  15. package/dist/hooks/use-host-contract.js +53 -0
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.js +1 -0
  18. package/dist/peers-services-registration.d.ts +1 -5
  19. package/dist/peers-services-registration.js +6 -16
  20. package/dist/root-layout/root-layout-host.js +7 -4
  21. package/dist/root-layout/root-layout-host.test.js +3 -6
  22. package/dist/screens/account/account-screen.d.ts +1 -0
  23. package/dist/screens/account/account-screen.js +29 -53
  24. package/dist/screens/account/account-screen.test.d.ts +1 -0
  25. package/dist/screens/account/account-screen.test.js +47 -0
  26. package/dist/screens/contacts/contact-details.js +2 -23
  27. package/dist/screens/contacts/contact-list.d.ts +24 -1
  28. package/dist/screens/contacts/contact-list.js +128 -143
  29. package/dist/screens/contacts/contact-list.test.d.ts +1 -0
  30. package/dist/screens/contacts/contact-list.test.js +48 -0
  31. package/dist/screens/contacts/index.d.ts +0 -2
  32. package/dist/screens/contacts/index.js +0 -3
  33. package/dist/screens/device-pairing/device-pairing.js +17 -16
  34. package/dist/screens/device-pairing/device-pairing.test.js +4 -9
  35. package/dist/screens/device-pairing/identity-ipc.d.ts +11 -0
  36. package/dist/screens/device-pairing/identity-ipc.js +20 -0
  37. package/dist/screens/device-pairing/use-device-pairing-state.d.ts +2 -2
  38. package/dist/screens/device-pairing/use-device-pairing-state.js +7 -25
  39. package/dist/screens/devices/devices-list.d.ts +18 -0
  40. package/dist/screens/devices/devices-list.js +173 -0
  41. package/dist/screens/devices/devices-list.test.d.ts +1 -0
  42. package/dist/screens/devices/devices-list.test.js +53 -0
  43. package/dist/screens/devices/index.d.ts +1 -0
  44. package/dist/screens/devices/index.js +5 -0
  45. package/dist/screens/groups/group-details.d.ts +1 -0
  46. package/dist/screens/groups/group-details.js +4 -63
  47. package/dist/screens/groups/group-invite-panel.js +2 -2
  48. package/dist/screens/groups/group-list.d.ts +18 -1
  49. package/dist/screens/groups/group-list.js +107 -136
  50. package/dist/screens/groups/group-list.test.d.ts +1 -0
  51. package/dist/screens/groups/group-list.test.js +38 -0
  52. package/dist/screens/groups/group-members.d.ts +1 -0
  53. package/dist/screens/groups/group-members.js +2 -1
  54. package/dist/screens/groups/index.d.ts +0 -3
  55. package/dist/screens/groups/index.js +0 -4
  56. package/dist/screens/identity/identity-routes.d.ts +107 -0
  57. package/dist/screens/identity/identity-routes.js +245 -0
  58. package/dist/screens/identity/identity-routes.test.d.ts +1 -0
  59. package/dist/screens/identity/identity-routes.test.js +51 -0
  60. package/dist/screens/identity/identity-screen.d.ts +9 -0
  61. package/dist/screens/identity/identity-screen.js +143 -0
  62. package/dist/screens/identity/identity-screen.test.d.ts +1 -0
  63. package/dist/screens/identity/identity-screen.test.js +103 -0
  64. package/dist/screens/identity/index.d.ts +2 -0
  65. package/dist/screens/identity/index.js +6 -0
  66. package/dist/screens/identity/invite-contact-panel.d.ts +4 -0
  67. package/dist/screens/identity/invite-contact-panel.js +30 -0
  68. package/dist/screens/identity/profile-invite.d.ts +7 -0
  69. package/dist/screens/identity/profile-invite.js +62 -0
  70. package/dist/screens/invites/accept-invite.js +1 -1
  71. package/dist/screens/invites/activity-view.d.ts +24 -0
  72. package/dist/screens/invites/activity-view.js +64 -0
  73. package/dist/screens/invites/activity-view.test.d.ts +1 -0
  74. package/dist/screens/invites/activity-view.test.js +108 -0
  75. package/dist/screens/invites/index.d.ts +1 -2
  76. package/dist/screens/invites/index.js +1 -3
  77. package/dist/screens/invites/invite-capture.d.ts +0 -2
  78. package/dist/screens/invites/invite-capture.js +1 -3
  79. package/dist/screens/invites/invite-classify.test.d.ts +1 -0
  80. package/dist/screens/invites/invite-classify.test.js +98 -0
  81. package/dist/screens/invites/invites-ipc.d.ts +1 -1
  82. package/dist/screens/invites/invites-ipc.js +5 -45
  83. package/dist/screens/invites/pending-invites-list.d.ts +35 -16
  84. package/dist/screens/invites/pending-invites-list.js +69 -30
  85. package/dist/screens/network-viewer/network-viewer-ipc.js +4 -59
  86. package/dist/screens/search/global-search.d.ts +1 -0
  87. package/dist/screens/search/global-search.js +2 -1
  88. package/dist/screens/settings/settings-page.js +25 -58
  89. package/dist/screens/setup-user.js +5 -5
  90. package/dist/screens/tools/tool-access-ipc.d.ts +2 -0
  91. package/dist/screens/tools/tool-access-ipc.js +8 -55
  92. package/dist/screens/welcome-modal.js +3 -2
  93. package/dist/system-apps/identity.app.d.ts +3 -0
  94. package/dist/system-apps/identity.app.js +10 -0
  95. package/dist/system-apps/index.d.ts +1 -4
  96. package/dist/system-apps/index.js +5 -17
  97. package/dist/tabs-layout/network-status-indicator.js +10 -3
  98. package/dist/tabs-layout/network-status-indicator.test.js +15 -0
  99. package/dist/tabs-layout/tabs-layout.js +3 -1
  100. package/dist/tabs-layout/tabs-state.d.ts +79 -1
  101. package/dist/tabs-layout/tabs-state.js +256 -79
  102. package/dist/tabs-layout/tabs-state.test.d.ts +1 -0
  103. package/dist/tabs-layout/tabs-state.test.js +110 -0
  104. package/package.json +3 -3
  105. package/src/components/markdown-editor/mention-node.ts +5 -1
  106. package/src/components/responsive-section-nav.test.tsx +88 -0
  107. package/src/components/responsive-section-nav.tsx +92 -0
  108. package/src/components/router.tsx +6 -9
  109. package/src/globals-hash.test.ts +19 -0
  110. package/src/globals.tsx +53 -13
  111. package/src/hooks/use-host-contract.ts +75 -0
  112. package/src/index.tsx +1 -0
  113. package/src/peers-services-registration.ts +6 -17
  114. package/src/root-layout/root-layout-host.test.tsx +4 -7
  115. package/src/root-layout/root-layout-host.tsx +9 -11
  116. package/src/screens/account/account-screen.test.tsx +61 -0
  117. package/src/screens/account/account-screen.tsx +116 -95
  118. package/src/screens/contacts/contact-details.tsx +4 -26
  119. package/src/screens/contacts/contact-list.test.tsx +59 -0
  120. package/src/screens/contacts/contact-list.tsx +246 -260
  121. package/src/screens/contacts/index.ts +0 -4
  122. package/src/screens/device-pairing/device-pairing.test.tsx +7 -9
  123. package/src/screens/device-pairing/device-pairing.tsx +19 -23
  124. package/src/screens/device-pairing/identity-ipc.ts +25 -0
  125. package/src/screens/device-pairing/use-device-pairing-state.ts +10 -33
  126. package/src/screens/devices/devices-list.test.tsx +68 -0
  127. package/src/screens/devices/devices-list.tsx +361 -0
  128. package/src/screens/devices/index.ts +1 -0
  129. package/src/screens/groups/group-details.tsx +8 -142
  130. package/src/screens/groups/group-invite-panel.tsx +2 -7
  131. package/src/screens/groups/group-list.test.tsx +44 -0
  132. package/src/screens/groups/group-list.tsx +227 -288
  133. package/src/screens/groups/group-members.tsx +3 -2
  134. package/src/screens/groups/index.ts +0 -5
  135. package/src/screens/identity/identity-routes.test.ts +70 -0
  136. package/src/screens/identity/identity-routes.ts +301 -0
  137. package/src/screens/identity/identity-screen.test.tsx +138 -0
  138. package/src/screens/identity/identity-screen.tsx +282 -0
  139. package/src/screens/identity/index.ts +2 -0
  140. package/src/screens/identity/invite-contact-panel.tsx +45 -0
  141. package/src/screens/identity/profile-invite.tsx +93 -0
  142. package/src/screens/invites/accept-invite.tsx +1 -1
  143. package/src/screens/invites/activity-view.test.tsx +127 -0
  144. package/src/screens/invites/activity-view.tsx +162 -0
  145. package/src/screens/invites/index.ts +1 -4
  146. package/src/screens/invites/invite-capture.ts +0 -3
  147. package/src/screens/invites/invite-classify.test.ts +110 -0
  148. package/src/screens/invites/invites-ipc.ts +6 -55
  149. package/src/screens/invites/pending-invites-list.tsx +85 -61
  150. package/src/screens/network-viewer/network-viewer-ipc.ts +8 -82
  151. package/src/screens/search/global-search.tsx +2 -1
  152. package/src/screens/settings/settings-page.tsx +53 -126
  153. package/src/screens/setup-user.tsx +5 -6
  154. package/src/screens/tools/tool-access-ipc.ts +13 -74
  155. package/src/screens/welcome-modal.tsx +3 -3
  156. package/src/system-apps/identity.app.ts +9 -0
  157. package/src/system-apps/index.ts +3 -12
  158. package/src/tabs-layout/network-status-indicator.test.tsx +22 -0
  159. package/src/tabs-layout/network-status-indicator.tsx +31 -0
  160. package/src/tabs-layout/tabs-layout.tsx +7 -1
  161. package/src/tabs-layout/tabs-state.test.ts +152 -0
  162. package/src/tabs-layout/tabs-state.ts +300 -83
  163. package/dist/screens/invites/invites-screen.d.ts +0 -9
  164. package/dist/screens/invites/invites-screen.js +0 -36
  165. package/dist/system-apps/account.app.d.ts +0 -2
  166. package/dist/system-apps/account.app.js +0 -8
  167. package/dist/system-apps/contacts.app.d.ts +0 -2
  168. package/dist/system-apps/contacts.app.js +0 -9
  169. package/dist/system-apps/groups.app.d.ts +0 -2
  170. package/dist/system-apps/groups.app.js +0 -9
  171. package/dist/system-apps/invites.app.d.ts +0 -2
  172. package/dist/system-apps/invites.app.js +0 -9
  173. package/src/screens/invites/invites-screen.tsx +0 -78
  174. package/src/system-apps/account.app.ts +0 -7
  175. package/src/system-apps/contacts.app.ts +0 -8
  176. package/src/system-apps/groups.app.ts +0 -8
  177. package/src/system-apps/invites.app.ts +0 -8
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProfileInviteSection = ProfileInviteSection;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const loading_indicator_1 = require("../../components/loading-indicator");
7
+ const tooltip_1 = require("../../components/tooltip");
8
+ const invite_share_1 = require("../invites/invite-share");
9
+ const invites_ipc_1 = require("../invites/invites-ipc");
10
+ const PROFILE_QR_INFO = `### Your profile QR
11
+
12
+ Anyone who scans this (or opens the link) can send you a contact request. Requests show up in **Identity → Activity** and nothing happens until you confirm.
13
+
14
+ ### Regenerate
15
+
16
+ Regenerating invalidates this QR **and every other invite link you have issued**. Use it if the QR leaked somewhere you did not intend.`;
17
+ /**
18
+ * Reusable profile invite.
19
+ *
20
+ * Sharing it asks the other person to request a connection. Regenerating bumps
21
+ * the invite epoch and revokes outstanding links.
22
+ */
23
+ function ProfileInviteSection() {
24
+ const [invite, setInvite] = (0, react_1.useState)(undefined);
25
+ const [busy, setBusy] = (0, react_1.useState)(false);
26
+ const [error, setError] = (0, react_1.useState)(null);
27
+ (0, react_1.useEffect)(() => {
28
+ let cancelled = false;
29
+ void (0, invites_ipc_1.inviteTools)()
30
+ .then((tools) => tools.createContactInvite({ profile: true }))
31
+ .then(({ invite: created }) => {
32
+ if (!cancelled)
33
+ setInvite(created);
34
+ })
35
+ .catch((err) => {
36
+ if (!cancelled)
37
+ setError(err.message || "Could not load your profile QR.");
38
+ });
39
+ return () => {
40
+ cancelled = true;
41
+ };
42
+ }, []);
43
+ const regenerate = async () => {
44
+ if (!confirm("Regenerate your profile QR? Every invite link you have issued so far will stop working.")) {
45
+ return;
46
+ }
47
+ setBusy(true);
48
+ setError(null);
49
+ try {
50
+ const tools = await (0, invites_ipc_1.inviteTools)();
51
+ const { invite: created } = await tools.regenerateProfileInvite();
52
+ setInvite(created);
53
+ }
54
+ catch (err) {
55
+ setError(err.message || "Could not regenerate.");
56
+ }
57
+ finally {
58
+ setBusy(false);
59
+ }
60
+ };
61
+ return ((0, jsx_runtime_1.jsx)("div", { className: "card mb-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "card-body", children: [(0, jsx_runtime_1.jsxs)("h5", { className: "card-title d-flex align-items-center gap-2", children: ["Profile QR", (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: PROFILE_QR_INFO })] }), error ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2", children: error }) : null, invite ? ((0, jsx_runtime_1.jsx)(invite_share_1.InviteShare, { invite: invite, description: "Let people connect with you by scanning this or opening the link. You confirm each request.", shareText: "Connect with me on Peers:" })) : !error ? ((0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {})) : null, (0, jsx_runtime_1.jsx)("div", { className: "text-center mt-3", children: (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-danger btn-sm", onClick: () => void regenerate(), disabled: busy || !invite, children: busy ? "Regenerating…" : "Regenerate (revokes all invites)" }) })] }) }));
62
+ }
@@ -28,7 +28,7 @@ function ResultPanel(props) {
28
28
  : preview.type === "group"
29
29
  ? "Join request sent. You will be added once it is approved."
30
30
  : "Request sent. They will see it and confirm.";
31
- return ((0, jsx_runtime_1.jsxs)("div", { className: "text-center", children: [(0, jsx_runtime_1.jsxs)("output", { className: `alert d-block ${accepted ? "alert-success" : "alert-info"}`, children: [message, result.deliveryState === "queued" ? ((0, jsx_runtime_1.jsx)("div", { className: "small mt-1", children: "Queued until the other person is reachable." })) : null] }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2 justify-content-center", children: [accepted && result.groupId ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-primary", onClick: () => (0, globals_1.mainContentPath)(`groups/${result.groupId}`), children: "Open group" })) : null, (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-secondary", onClick: props.onDone, children: "Done" })] })] }));
31
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "text-center", children: [(0, jsx_runtime_1.jsxs)("output", { className: `alert d-block ${accepted ? "alert-success" : "alert-info"}`, children: [message, result.deliveryState === "queued" ? ((0, jsx_runtime_1.jsx)("div", { className: "small mt-1", children: "Queued until the other person is reachable." })) : null] }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2 justify-content-center", children: [accepted && result.groupId ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-primary", onClick: () => (0, globals_1.mainContentPath)(`identity/groups/${result.groupId}`), children: "Open group" })) : null, (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-secondary", onClick: props.onDone, children: "Done" })] })] }));
32
32
  }
33
33
  /**
34
34
  * Paste or scan an invite, review what it grants, then accept it. Also consumes a token
@@ -0,0 +1,24 @@
1
+ import { type IdentityInviteType } from "../identity/identity-routes";
2
+ /** Props for {@link ActivityView}. */
3
+ export interface ActivityViewProps {
4
+ /** Optional type and group limit, taken from the route query. */
5
+ filter?: {
6
+ type?: IdentityInviteType;
7
+ groupId?: string;
8
+ };
9
+ }
10
+ /**
11
+ * Unified invite inbox.
12
+ *
13
+ * Pending rows are split into decisions the user can make and items waiting
14
+ * on someone else. History is a separate view, not a disclosure on each list.
15
+ */
16
+ export declare function ActivityView(props: ActivityViewProps): import("react/jsx-runtime").JSX.Element;
17
+ /**
18
+ * Compact link from a resource screen to the matching Activity filter.
19
+ * Renders nothing when that filter has no pending rows.
20
+ */
21
+ export declare function PendingWorkLink(props: {
22
+ type: IdentityInviteType;
23
+ groupId?: string;
24
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActivityView = ActivityView;
4
+ exports.PendingWorkLink = PendingWorkLink;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const loading_indicator_1 = require("../../components/loading-indicator");
8
+ const identity_routes_1 = require("../identity/identity-routes");
9
+ const pending_invites_list_1 = require("./pending-invites-list");
10
+ /** Statuses shown in Activity's History view. */
11
+ const TERMINAL_STATUSES = ["accepted", "declined", "expired", "revoked"];
12
+ /**
13
+ * Unified invite inbox.
14
+ *
15
+ * Pending rows are split into decisions the user can make and items waiting
16
+ * on someone else. History is a separate view, not a disclosure on each list.
17
+ */
18
+ function ActivityView(props) {
19
+ const [view, setView] = (0, react_1.useState)("pending");
20
+ const filter = props.filter;
21
+ const query = (0, pending_invites_list_1.useInviteRows)({
22
+ type: filter?.type,
23
+ groupId: filter?.groupId,
24
+ statuses: view === "history" ? TERMINAL_STATUSES : ["pending"],
25
+ });
26
+ const rows = query?.rows ?? [];
27
+ const attention = rows.filter((row) => (0, pending_invites_list_1.classifyInvite)(row) === "attention");
28
+ const waiting = rows.filter((row) => (0, pending_invites_list_1.classifyInvite)(row) === "waiting");
29
+ const filtered = Boolean(filter?.type || filter?.groupId);
30
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex justify-content-between align-items-center gap-2 flex-wrap mb-3", children: [(0, jsx_runtime_1.jsxs)("h4", { className: "mb-0", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-inbox me-2" }), "Activity"] }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "btn-group btn-group-sm", role: "group", "aria-label": "Invite view", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: `btn ${view === "pending" ? "btn-primary" : "btn-outline-primary"}`, onClick: () => setView("pending"), children: "Pending" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: `btn ${view === "history" ? "btn-primary" : "btn-outline-primary"}`, onClick: () => setView("history"), children: "History" })] }), (0, jsx_runtime_1.jsxs)("a", { href: `#${identity_routes_1.IDENTITY_ACCEPT_PATH}`, className: "btn btn-outline-primary btn-sm", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-qr-code-scan me-1" }), "Enter or scan an invite"] })] })] }), filtered ? ((0, jsx_runtime_1.jsxs)("div", { className: "alert alert-secondary py-2 d-flex justify-content-between align-items-center", children: [(0, jsx_runtime_1.jsx)("span", { children: filterLabel(filter?.type, filter?.groupId) }), (0, jsx_runtime_1.jsx)("a", { href: "#identity/activity", children: "Show all" })] })) : null, !query ? ((0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {})) : view === "history" ? ((0, jsx_runtime_1.jsx)(InviteBucket, { title: "History", rows: rows, empty: "No invite history." })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(InviteBucket, { title: "Needs your attention", rows: attention, empty: waiting.length === 0 ? "No invites need attention." : "Nothing needs a decision." }), (0, jsx_runtime_1.jsx)(InviteBucket, { title: "Waiting on others", rows: waiting, empty: attention.length === 0 ? "" : "Nothing is waiting on someone else." })] }))] }));
31
+ }
32
+ /**
33
+ * Compact link from a resource screen to the matching Activity filter.
34
+ * Renders nothing when that filter has no pending rows.
35
+ */
36
+ function PendingWorkLink(props) {
37
+ const query = (0, pending_invites_list_1.useInviteRows)({
38
+ type: props.type,
39
+ groupId: props.groupId,
40
+ statuses: ["pending"],
41
+ });
42
+ if (!query || query.rows.length === 0) {
43
+ return null;
44
+ }
45
+ const noun = props.type === "contact" ? "contact" : props.type === "group" ? "group" : "device";
46
+ const count = query.rows.length;
47
+ return ((0, jsx_runtime_1.jsxs)("a", { href: `#${(0, identity_routes_1.identityActivityFilterPath)(props.type, props.groupId)}`, className: "alert alert-info py-2 px-3 d-flex justify-content-between align-items-center text-decoration-none", children: [(0, jsx_runtime_1.jsxs)("span", { children: [count, " pending ", noun, " invite", count === 1 ? "" : "s"] }), (0, jsx_runtime_1.jsx)("span", { children: "View in Activity" })] }));
48
+ }
49
+ function InviteBucket(props) {
50
+ if (props.rows.length === 0 && !props.empty) {
51
+ return null;
52
+ }
53
+ return ((0, jsx_runtime_1.jsxs)("section", { className: "mb-4", children: [(0, jsx_runtime_1.jsx)("h6", { children: props.title }), props.rows.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { className: "text-muted small mb-0", children: props.empty })) : ((0, jsx_runtime_1.jsx)("div", { className: "list-group", children: props.rows.map((row) => ((0, jsx_runtime_1.jsx)(pending_invites_list_1.InviteRow, { row: row }, row.inviteId))) }))] }));
54
+ }
55
+ function filterLabel(type, groupId) {
56
+ const kind = type === "contact" ? "contact" : type === "group" ? "group" : type === "device" ? "device" : "";
57
+ if (groupId) {
58
+ return "Showing invites for this group.";
59
+ }
60
+ if (kind) {
61
+ return `Showing ${kind} invites.`;
62
+ }
63
+ return "Showing a filtered list.";
64
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("@testing-library/react");
8
+ const user_event_1 = __importDefault(require("@testing-library/user-event"));
9
+ const activity_view_1 = require("./activity-view");
10
+ const invites_ipc_1 = require("./invites-ipc");
11
+ const pending_invites_list_1 = require("./pending-invites-list");
12
+ jest.mock("./pending-invites-list", () => {
13
+ const actual = jest.requireActual("./pending-invites-list");
14
+ return {
15
+ ...actual,
16
+ useInviteRows: jest.fn(),
17
+ };
18
+ });
19
+ jest.mock("./invites-ipc", () => ({
20
+ inviteTools: jest.fn(),
21
+ }));
22
+ function invite(partial) {
23
+ return {
24
+ status: "pending",
25
+ epoch: 1,
26
+ createdAt: new Date("2026-01-01T00:00:00Z"),
27
+ expiresAt: new Date("2026-02-01T00:00:00Z"),
28
+ counterpart: { userId: "abcdefghijklmnopqrstuvwxy", displayName: "Ada" },
29
+ ...partial,
30
+ };
31
+ }
32
+ const attention = invite({
33
+ inviteId: "inboundcontact0000000001",
34
+ direction: "in",
35
+ type: "contact",
36
+ mode: "contact",
37
+ });
38
+ const waiting = invite({
39
+ inviteId: "outboundcontact0000000001",
40
+ direction: "out",
41
+ type: "contact",
42
+ mode: "contact",
43
+ });
44
+ const joinRequest = invite({
45
+ inviteId: "groupjoinrequest000000001",
46
+ direction: "in",
47
+ type: "group",
48
+ mode: "approve",
49
+ groupId: "zyxwvutsrqponmlkjihgfedcb",
50
+ groupName: "Neighbors",
51
+ });
52
+ const history = invite({
53
+ inviteId: "oldcontact000000000000001",
54
+ direction: "in",
55
+ type: "contact",
56
+ mode: "contact",
57
+ status: "accepted",
58
+ });
59
+ const mockedRows = pending_invites_list_1.useInviteRows;
60
+ const acceptInvite = jest.fn();
61
+ const approveJoinRequest = jest.fn();
62
+ describe("ActivityView", () => {
63
+ beforeEach(() => {
64
+ acceptInvite.mockReset();
65
+ approveJoinRequest.mockReset();
66
+ invites_ipc_1.inviteTools.mockResolvedValue({
67
+ acceptInvite,
68
+ declineInvite: jest.fn(),
69
+ approveJoinRequest,
70
+ denyJoinRequest: jest.fn(),
71
+ revokeInvite: jest.fn(),
72
+ });
73
+ mockedRows.mockImplementation((filter) => ({
74
+ rows: filter.statuses?.includes("accepted") ? [history] : [attention, joinRequest, waiting],
75
+ hasHistory: true,
76
+ }));
77
+ });
78
+ it("offers approval for a received group join request", async () => {
79
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(activity_view_1.ActivityView, {}));
80
+ expect(react_1.screen.getByText("Ada wants to join Neighbors")).toBeInTheDocument();
81
+ await user_event_1.default.click(react_1.screen.getByRole("button", { name: "Approve" }));
82
+ await (0, react_1.waitFor)(() => expect(approveJoinRequest).toHaveBeenCalledWith({ inviteId: joinRequest.inviteId }));
83
+ });
84
+ it("splits pending invites and accepts a request from the inbox", async () => {
85
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(activity_view_1.ActivityView, {}));
86
+ expect(react_1.screen.getByRole("heading", { name: "Needs your attention" })).toBeInTheDocument();
87
+ expect(react_1.screen.getByRole("heading", { name: "Waiting on others" })).toBeInTheDocument();
88
+ expect(react_1.screen.getByText("Ada wants to connect")).toBeInTheDocument();
89
+ await user_event_1.default.click(react_1.screen.getByRole("button", { name: "Accept" }));
90
+ await (0, react_1.waitFor)(() => expect(acceptInvite).toHaveBeenCalledWith({ inviteId: attention.inviteId }));
91
+ });
92
+ it("switches to history and shows an empty pending inbox", async () => {
93
+ const view = (0, react_1.render)((0, jsx_runtime_1.jsx)(activity_view_1.ActivityView, {}));
94
+ await user_event_1.default.click(react_1.screen.getByRole("button", { name: "History" }));
95
+ expect(react_1.screen.getByRole("heading", { name: "History" })).toBeInTheDocument();
96
+ expect(react_1.screen.getByText(/accepted/i)).toBeInTheDocument();
97
+ expect(react_1.screen.queryByRole("heading", { name: "Needs your attention" })).not.toBeInTheDocument();
98
+ mockedRows.mockReturnValue({ rows: [], hasHistory: false });
99
+ view.rerender((0, jsx_runtime_1.jsx)(activity_view_1.ActivityView, {}));
100
+ await user_event_1.default.click(react_1.screen.getByRole("button", { name: "Pending" }));
101
+ expect(react_1.screen.getByText("No invites need attention.")).toBeInTheDocument();
102
+ });
103
+ it("shows the active filter", () => {
104
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(activity_view_1.ActivityView, { filter: { type: "group", groupId: "zyxwvutsrqponmlkjihgfedcb" } }));
105
+ expect(react_1.screen.getByText("Showing invites for this group.")).toBeInTheDocument();
106
+ expect(react_1.screen.getByRole("link", { name: "Show all" })).toHaveAttribute("href", "#identity/activity");
107
+ });
108
+ });
@@ -1,7 +1,6 @@
1
- import "./invites-screen";
2
1
  export * from "./accept-invite";
2
+ export * from "./activity-view";
3
3
  export * from "./invite-capture";
4
4
  export * from "./invite-share";
5
5
  export * from "./invites-ipc";
6
- export * from "./invites-screen";
7
6
  export * from "./pending-invites-list";
@@ -14,11 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- // Import the screen so it registers its routes.
18
- require("./invites-screen");
19
17
  __exportStar(require("./accept-invite"), exports);
18
+ __exportStar(require("./activity-view"), exports);
20
19
  __exportStar(require("./invite-capture"), exports);
21
20
  __exportStar(require("./invite-share"), exports);
22
21
  __exportStar(require("./invites-ipc"), exports);
23
- __exportStar(require("./invites-screen"), exports);
24
22
  __exportStar(require("./pending-invites-list"), exports);
@@ -7,8 +7,6 @@
7
7
  */
8
8
  /** sessionStorage key for a captured token awaiting the Accept screen. */
9
9
  export declare const PENDING_INVITE_STORAGE_KEY = "peers.pendingInviteToken";
10
- /** Route of the Accept-invite screen. */
11
- export declare const ACCEPT_INVITE_PATH = "invites/accept";
12
10
  /** Fires whenever a new token is captured, so a mounted app can navigate immediately. */
13
11
  export declare const inviteCaptured: import("@peers-app/peers-sdk").Observable<string | undefined>;
14
12
  /**
@@ -7,7 +7,7 @@
7
7
  * startup route restoration never persists them.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.inviteCaptured = exports.ACCEPT_INVITE_PATH = exports.PENDING_INVITE_STORAGE_KEY = void 0;
10
+ exports.inviteCaptured = exports.PENDING_INVITE_STORAGE_KEY = void 0;
11
11
  exports.inviteTokenFromUrl = inviteTokenFromUrl;
12
12
  exports.stashPendingInvite = stashPendingInvite;
13
13
  exports.peekPendingInvite = peekPendingInvite;
@@ -17,8 +17,6 @@ exports.listenForOpenUrlInvites = listenForOpenUrlInvites;
17
17
  const peers_sdk_1 = require("@peers-app/peers-sdk");
18
18
  /** sessionStorage key for a captured token awaiting the Accept screen. */
19
19
  exports.PENDING_INVITE_STORAGE_KEY = "peers.pendingInviteToken";
20
- /** Route of the Accept-invite screen. */
21
- exports.ACCEPT_INVITE_PATH = "invites/accept";
22
20
  /** Fires whenever a new token is captured, so a mounted app can navigate immediately. */
23
21
  exports.inviteCaptured = (0, peers_sdk_1.observable)(undefined);
24
22
  /**
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const pending_invites_list_1 = require("./pending-invites-list");
4
+ function invite(partial) {
5
+ return {
6
+ status: "pending",
7
+ epoch: 1,
8
+ createdAt: new Date("2026-01-01T00:00:00Z"),
9
+ expiresAt: new Date("2026-02-01T00:00:00Z"),
10
+ ...partial,
11
+ };
12
+ }
13
+ describe("classifyInvite", () => {
14
+ const counterpart = {
15
+ userId: "abcdefghijklmnopqrstuvwxy",
16
+ publicKey: "pk",
17
+ publicBoxKey: "box",
18
+ };
19
+ it("puts received decisions in attention", () => {
20
+ const profileRequest = invite({
21
+ inviteId: "1",
22
+ direction: "in",
23
+ type: "contact",
24
+ mode: "profile",
25
+ counterpart,
26
+ parentInviteId: "profileinvite0000000000001",
27
+ });
28
+ const directGroupInvite = invite({
29
+ inviteId: "2",
30
+ direction: "in",
31
+ type: "group",
32
+ mode: "direct",
33
+ counterpart,
34
+ });
35
+ const joinRequest = invite({
36
+ inviteId: "3",
37
+ direction: "in",
38
+ type: "group",
39
+ mode: "approve",
40
+ counterpart,
41
+ parentInviteId: "groupinvite00000000000001",
42
+ });
43
+ expect((0, pending_invites_list_1.classifyInvite)(profileRequest)).toBe("attention");
44
+ expect((0, pending_invites_list_1.actionsForInvite)(profileRequest)).toEqual(["accept", "decline"]);
45
+ expect((0, pending_invites_list_1.classifyInvite)(directGroupInvite)).toBe("attention");
46
+ expect((0, pending_invites_list_1.actionsForInvite)(directGroupInvite)).toEqual(["accept", "decline"]);
47
+ expect((0, pending_invites_list_1.classifyInvite)(joinRequest)).toBe("attention");
48
+ expect((0, pending_invites_list_1.actionsForInvite)(joinRequest)).toEqual(["approve", "deny"]);
49
+ });
50
+ it("keeps locally initiated requests and unsupported device rows waiting", () => {
51
+ const contactRequest = invite({
52
+ inviteId: "4",
53
+ direction: "in",
54
+ type: "contact",
55
+ mode: "profile",
56
+ counterpart,
57
+ recipientUserId: counterpart.userId,
58
+ });
59
+ const groupRequest = invite({
60
+ inviteId: "5",
61
+ direction: "in",
62
+ type: "group",
63
+ mode: "approve",
64
+ counterpart,
65
+ recipientUserId: counterpart.userId,
66
+ });
67
+ const outbound = invite({
68
+ inviteId: "6",
69
+ direction: "out",
70
+ type: "group",
71
+ mode: "open",
72
+ });
73
+ const device = invite({
74
+ inviteId: "7",
75
+ direction: "in",
76
+ type: "device",
77
+ mode: "direct",
78
+ counterpart,
79
+ });
80
+ expect((0, pending_invites_list_1.classifyInvite)(contactRequest)).toBe("waiting");
81
+ expect((0, pending_invites_list_1.actionsForInvite)(contactRequest)).toEqual([]);
82
+ expect((0, pending_invites_list_1.classifyInvite)(groupRequest)).toBe("waiting");
83
+ expect((0, pending_invites_list_1.actionsForInvite)(groupRequest)).toEqual([]);
84
+ expect((0, pending_invites_list_1.classifyInvite)(outbound)).toBe("waiting");
85
+ expect((0, pending_invites_list_1.actionsForInvite)(outbound)).toEqual(["revoke"]);
86
+ expect((0, pending_invites_list_1.classifyInvite)(device)).toBe("waiting");
87
+ expect((0, pending_invites_list_1.actionsForInvite)(device)).toEqual([]);
88
+ });
89
+ it("puts terminal rows in history", () => {
90
+ expect((0, pending_invites_list_1.classifyInvite)(invite({
91
+ inviteId: "8",
92
+ direction: "in",
93
+ type: "contact",
94
+ mode: "contact",
95
+ status: "accepted",
96
+ }))).toBe("history");
97
+ });
98
+ });
@@ -3,7 +3,7 @@ import { type IInvitesConsumer } from "@peers-app/peers-sdk";
3
3
  * Return the typed local-host consumer for the System Invites contract.
4
4
  *
5
5
  * The consumer is cached per host transport and rebuilt if the transport is replaced
6
- * (e.g. after a socket reconnect).
6
+ * (for example after a socket reconnect).
7
7
  */
8
8
  export declare function getInvitesConsumer(): Promise<IInvitesConsumer>;
9
9
  /** Shorthand for `(await getInvitesConsumer()).tools`. */
@@ -3,57 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInvitesConsumer = getInvitesConsumer;
4
4
  exports.inviteTools = inviteTools;
5
5
  const peers_sdk_1 = require("@peers-app/peers-sdk");
6
- const HOST_TRANSPORT_TIMEOUT_MS = 10_000;
7
- let cached;
8
- let pending;
9
- (0, peers_sdk_1.subscribeHostContractTransport)((transport) => {
10
- if (cached && cached.transport !== transport) {
11
- cached.consumer.dispose();
12
- cached = undefined;
13
- pending = undefined;
14
- }
15
- }, { emitCurrent: false });
16
- async function load(transport) {
17
- const userContext = await (0, peers_sdk_1.getUserContext)();
18
- const consumer = (0, peers_sdk_1.createContractConsumer)((0, peers_sdk_1.getInvitesContractDefinition)(), transport, {
19
- dataContextId: userContext.userId,
20
- });
21
- try {
22
- await consumer.loadingPromise;
23
- if ((0, peers_sdk_1.getHostContractTransport)() !== transport) {
24
- consumer.dispose();
25
- return getInvitesConsumer();
26
- }
27
- cached = { transport, consumer };
28
- return consumer;
29
- }
30
- catch (error) {
31
- consumer.dispose();
32
- throw error;
33
- }
34
- }
6
+ const invites = (0, peers_sdk_1.hostContractConsumer)((0, peers_sdk_1.getInvitesContractDefinition)(), {
7
+ dataContextId: async () => (await (0, peers_sdk_1.getUserContext)()).userId,
8
+ });
35
9
  /**
36
10
  * Return the typed local-host consumer for the System Invites contract.
37
11
  *
38
12
  * The consumer is cached per host transport and rebuilt if the transport is replaced
39
- * (e.g. after a socket reconnect).
13
+ * (for example after a socket reconnect).
40
14
  */
41
15
  async function getInvitesConsumer() {
42
- const transport = (0, peers_sdk_1.getHostContractTransport)() ??
43
- (await (0, peers_sdk_1.waitForHostContractTransport)({ timeoutMs: HOST_TRANSPORT_TIMEOUT_MS }));
44
- if (cached?.transport === transport) {
45
- return cached.consumer;
46
- }
47
- if (pending) {
48
- return pending;
49
- }
50
- pending = load(transport);
51
- try {
52
- return await pending;
53
- }
54
- finally {
55
- pending = undefined;
56
- }
16
+ return invites.get();
57
17
  }
58
18
  /** Shorthand for `(await getInvitesConsumer()).tools`. */
59
19
  async function inviteTools() {
@@ -1,29 +1,48 @@
1
1
  import { type IInvite, type InviteStatus } from "@peers-app/peers-sdk";
2
- /** Props for {@link PendingInvitesList}. */
3
- export interface PendingInvitesListProps {
4
- /** Only show rows of this type. */
5
- type?: IInvite["type"];
6
- /** Only show rows for this group. */
7
- groupId?: string;
8
- /** Statuses to include; defaults to pending only. */
9
- statuses?: InviteStatus[];
10
- /** Hide the section entirely when there is nothing to show. */
11
- hideWhenEmpty?: boolean;
12
- title?: string;
2
+ /** Filtered invite rows plus whether any non-pending row exists for the same type and group. */
3
+ export interface IInviteRowQuery {
4
+ /** Rows matching the status filter, newest first. */
5
+ rows: IInvite[];
6
+ /** True when at least one matching invite is not pending. */
7
+ hasHistory: boolean;
13
8
  }
14
- /** Subscribe to the personal `Invites` table and return rows matching the filter, newest first. */
9
+ /**
10
+ * Subscribe to the personal `Invites` table.
11
+ *
12
+ * @param filter Type, group, and statuses to include. Statuses default to pending.
13
+ * @returns Matching rows and whether any non-pending row exists, or `undefined` while loading.
14
+ */
15
15
  export declare function useInviteRows(filter: {
16
16
  type?: IInvite["type"];
17
17
  groupId?: string;
18
18
  statuses?: InviteStatus[];
19
- }): IInvite[] | undefined;
19
+ }): IInviteRowQuery | undefined;
20
20
  /** Human summary of what a row is, from the local user's point of view. */
21
21
  export declare function describeInviteRow(row: IInvite): {
22
22
  title: string;
23
23
  detail: string;
24
24
  };
25
+ /** Which Activity bucket a row belongs in. */
26
+ export type InviteBucket = "attention" | "waiting" | "history";
27
+ /**
28
+ * Group an invite by what the signed-in user can do with it.
29
+ *
30
+ * Pending rows that need a decision are `attention`. Pending rows waiting on
31
+ * someone else, including links the user issued, are `waiting`.
32
+ *
33
+ * @param row - Invite row from the personal Invites table.
34
+ */
35
+ export declare function classifyInvite(row: IInvite): InviteBucket;
36
+ /** Action that the local user can take on an Activity row. */
37
+ export type InviteRowAction = "accept" | "decline" | "approve" | "deny" | "revoke";
25
38
  /**
26
- * Live list of invite rows with the actions each one supports. Subscribes to the `Invites`
27
- * table directly, so it updates when replies arrive on any of the user's devices.
39
+ * Return actions that are valid from the local user's perspective.
40
+ *
41
+ * Inbound rows with `recipientUserId` were initiated locally and are waiting
42
+ * for that recipient. Actionable profile requests and join requests omit it.
28
43
  */
29
- export declare function PendingInvitesList(props: PendingInvitesListProps): import("react/jsx-runtime").JSX.Element | null;
44
+ export declare function actionsForInvite(row: IInvite): InviteRowAction[];
45
+ /** One invite row and the actions its direction and status allow. */
46
+ export declare function InviteRow({ row }: {
47
+ row: IInvite;
48
+ }): import("react/jsx-runtime").JSX.Element;