@fungi.computer/tourtois 0.17.0 → 0.18.0

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.
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { DataList, DataListHeading, DataRow, } from "@fungi.computer/caps/components/data-list";
3
+ import { channelWhen } from "./channel-time.js";
3
4
  import { KeycapButton } from "@fungi.computer/caps/components/keycap";
4
5
  import { useQuery } from "@tanstack/react-query";
5
6
  import { useState } from "react";
@@ -31,13 +32,13 @@ export function ChannelConversations({ keys, load, read, speaker, empty, label,
31
32
  ? Promise.reject(new Error("No conversation is open"))
32
33
  : read(reading),
33
34
  });
34
- return (_jsxs("section", { className: "grid gap-sm", "aria-label": "Conversations", children: [_jsx(DataListHeading, { level: 3, children: "Conversations" }), shown ? null : (_jsx(KeycapButton, { density: "compact", label: "Show conversations", onClick: () => {
35
+ return (_jsxs("section", { className: "grid gap-sm", "aria-label": "Conversations", children: [_jsx(DataListHeading, { level: 3, className: "tourtois-conversations-heading", children: "Conversations" }), shown ? null : (_jsx(KeycapButton, { density: "compact", label: "Show conversations", onClick: () => {
35
36
  setShown(true);
36
- } })), list.isPending && shown ? _jsx("p", { role: "status", children: "Loading\u2026" }) : null, list.isError ? (_jsx("p", { role: "alert", children: "Conversations could not be loaded." })) : null, list.data?.length === 0 ? _jsx("p", { className: "text-sm", children: empty }) : null, list.data !== undefined && list.data.length > 0 ? (_jsx(DataList, { density: "compact", "aria-label": label, children: list.data.map((conversation) => (_jsx(DataRow, { children: _jsxs("div", { className: "tourtois-conversation", children: [_jsxs("div", { className: "tourtois-conversation-row", children: [_jsx("span", { className: "tourtois-conversation-name text-sm", children: conversation.label }), _jsxs("span", { className: "flex flex-wrap items-center gap-sm", children: [_jsx("span", { className: "text-sm", children: new Date(conversation.lastEventAt).toLocaleString() }), _jsx(KeycapButton, { density: "compact", label: reading === conversation.sessionId
37
+ } })), list.isPending && shown ? _jsx("p", { role: "status", children: "Loading\u2026" }) : null, list.isError ? (_jsx("p", { role: "alert", children: "Conversations could not be loaded." })) : null, list.data?.length === 0 ? _jsx("p", { className: "text-sm", children: empty }) : null, list.data !== undefined && list.data.length > 0 ? (_jsx(DataList, { density: "compact", "aria-label": label, children: list.data.map((conversation) => (_jsx(DataRow, { children: _jsxs("div", { className: "tourtois-conversation", children: [_jsxs("div", { className: "tourtois-conversation-row", children: [_jsx("span", { className: "tourtois-conversation-name text-sm", children: conversation.label }), _jsxs("span", { className: "flex flex-wrap items-center gap-sm", children: [_jsx("span", { className: "text-sm", children: channelWhen(conversation.lastEventAt, Date.now()) }), _jsx(KeycapButton, { density: "compact", label: reading === conversation.sessionId
37
38
  ? "Close transcript"
38
39
  : "Read transcript", "aria-label": `${reading === conversation.sessionId ? "Close" : "Read"} transcript of ${conversation.label}`, onClick: () => {
39
40
  setReading(reading === conversation.sessionId
40
41
  ? null
41
42
  : conversation.sessionId);
42
- } })] })] }), reading === conversation.sessionId ? (_jsxs("div", { className: "tourtois-conversation-transcript", children: [transcript.isPending ? (_jsx("p", { role: "status", children: "Loading\u2026" })) : null, transcript.isError ? (_jsx("p", { role: "alert", children: "This conversation could not be read." })) : null, transcript.data ? (_jsx("ol", { "aria-label": "Transcript", className: "grid gap-xs", children: transcript.data.lines.map((line, index) => (_jsxs("li", { className: "text-sm", children: [_jsxs("strong", { children: [line.role === "visitor" ? speaker : "Agent", ":"] }), " ", line.text] }, `${String(index)}-${line.role}`))) })) : null] })) : null] }) }, conversation.sessionId))) })) : null, undelivered.data !== undefined && undelivered.data.length > 0 ? (_jsxs("section", { className: "grid gap-xs", "aria-label": "Replies not delivered", children: [_jsx(DataListHeading, { level: 3, children: "Not delivered" }), _jsx(DataList, { density: "compact", "aria-label": "Replies not delivered", children: undelivered.data.map((problem) => (_jsx(DataRow, { children: _jsxs("div", { className: "tourtois-conversation", children: [_jsxs("div", { className: "tourtois-conversation-row", children: [_jsx("span", { className: "tourtois-conversation-name text-sm", children: problem.label }), _jsx("span", { className: "text-sm", children: new Date(problem.at).toLocaleString() })] }), _jsx("p", { className: "text-sm", children: problem.reason })] }) }, problem.id))) })] })) : null] }));
43
+ } })] })] }), reading === conversation.sessionId ? (_jsxs("div", { className: "tourtois-conversation-transcript", children: [transcript.isPending ? (_jsx("p", { role: "status", children: "Loading\u2026" })) : null, transcript.isError ? (_jsx("p", { role: "alert", children: "This conversation could not be read." })) : null, transcript.data ? (_jsx("ol", { "aria-label": "Transcript", className: "grid gap-xs", children: transcript.data.lines.map((line, index) => (_jsxs("li", { className: "text-sm", children: [_jsxs("strong", { children: [line.role === "visitor" ? speaker : "Agent", ":"] }), " ", line.text] }, `${String(index)}-${line.role}`))) })) : null] })) : null] }) }, conversation.sessionId))) })) : null, undelivered.data !== undefined && undelivered.data.length > 0 ? (_jsxs("section", { className: "grid gap-xs", "aria-label": "Replies not delivered", children: [_jsx(DataListHeading, { level: 3, className: "tourtois-conversations-heading", children: "Not delivered" }), _jsx(DataList, { density: "compact", "aria-label": "Replies not delivered", children: undelivered.data.map((problem) => (_jsx(DataRow, { children: _jsxs("div", { className: "tourtois-conversation", children: [_jsxs("div", { className: "tourtois-conversation-row", children: [_jsx("span", { className: "tourtois-conversation-name text-sm", children: problem.label }), _jsx("span", { className: "text-sm", children: channelWhen(problem.at, Date.now()) })] }), _jsx("p", { className: "text-sm", children: problem.reason })] }) }, problem.id))) })] })) : null] }));
43
44
  }
@@ -175,9 +175,11 @@ export function DiscordChannels({ port }) {
175
175
  setOpenBinding(bindingId);
176
176
  setCreatedBinding(bindingId);
177
177
  }
178
- } })) : agents.length === 0 ? (_jsx("p", { className: "text-sm", children: "Create an Agent first; Discord needs one to answer members." })) : (_jsx("div", { className: "flex justify-end", children: _jsx(Button, { onClick: () => {
178
+ } })) : agents.length === 0 ? (_jsx("p", { className: "text-sm", children: "Create an Agent first; Discord needs one to answer members." })) : (_jsx("div", { className: "flex justify-end", children: _jsx(Button, { variant: directory.data.bindings.length === 0 ? "primary" : "outline", onClick: () => {
179
179
  setAdding(true);
180
- }, children: "Add Discord" }) }))] })) : null] }));
180
+ }, children: directory.data.bindings.length === 0
181
+ ? "Add Discord"
182
+ : "Add another application" }) }))] })) : null] }));
181
183
  }
182
184
  function AddDiscord({ port, agents, onDone, }) {
183
185
  const cache = useQueryClient();
@@ -0,0 +1,6 @@
1
+ /**
2
+ * When a channel conversation last moved, for the owner: `Today, 7:30 PM`,
3
+ * `Yesterday, 10:05 AM`, `Nov 9, 10:05 AM`, and with the year only when it is
4
+ * not this one. No seconds; the time of day follows the owner's locale.
5
+ */
6
+ export declare function channelWhen(epochMillis: number, now: number): string;
@@ -0,0 +1,33 @@
1
+ const dayStart = (date) => new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
2
+ const clock = new Intl.DateTimeFormat(undefined, {
3
+ hour: "numeric",
4
+ minute: "2-digit",
5
+ });
6
+ const monthDay = new Intl.DateTimeFormat(undefined, {
7
+ month: "short",
8
+ day: "numeric",
9
+ });
10
+ const monthDayYear = new Intl.DateTimeFormat(undefined, {
11
+ month: "short",
12
+ day: "numeric",
13
+ year: "numeric",
14
+ });
15
+ /**
16
+ * When a channel conversation last moved, for the owner: `Today, 7:30 PM`,
17
+ * `Yesterday, 10:05 AM`, `Nov 9, 10:05 AM`, and with the year only when it is
18
+ * not this one. No seconds; the time of day follows the owner's locale.
19
+ */
20
+ export function channelWhen(epochMillis, now) {
21
+ const at = new Date(epochMillis);
22
+ const today = new Date(now);
23
+ const days = Math.round((dayStart(today) - dayStart(at)) / 86_400_000);
24
+ const time = clock.format(at);
25
+ if (days === 0)
26
+ return `Today, ${time}`;
27
+ if (days === 1)
28
+ return `Yesterday, ${time}`;
29
+ const date = at.getFullYear() === today.getFullYear()
30
+ ? monthDay.format(at)
31
+ : monthDayYear.format(at);
32
+ return `${date}, ${time}`;
33
+ }
@@ -138,6 +138,17 @@
138
138
  min-width: 0;
139
139
  }
140
140
 
141
+ /* The Conversations and Not delivered labels sit on their rows' left edge. */
142
+ .tourtois-conversations-heading {
143
+ padding-inline: 0;
144
+ }
145
+ /* On a phone the control that reads a transcript is a full touch target. */
146
+ @media (max-width: 40rem) {
147
+ .tourtois-conversation-row button {
148
+ min-height: 44px;
149
+ }
150
+ }
151
+
141
152
  /* A conversation line: its name gets the room, its date and button wrap below
142
153
  when the line is narrow. */
143
154
  .tourtois-conversation-row {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/tourtois",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Tourtois: the trusted desktop shell for Oyster and Fungi, with host-supplied Settings sections",
6
6
  "type": "module",
@@ -77,15 +77,15 @@
77
77
  "LICENSE"
78
78
  ],
79
79
  "dependencies": {
80
- "@fungi.computer/agar": "0.10.1",
80
+ "@fungi.computer/agar": "0.12.0",
81
81
  "@fungi.computer/cairn": "0.1.0",
82
82
  "@fungi.computer/caps": "0.11.3",
83
83
  "@fungi.computer/ear-tag": "0.1.0",
84
84
  "@fungi.computer/gills": "0.3.0",
85
85
  "@fungi.computer/maosaico": "0.1.2",
86
- "@fungi.computer/parakeet": "0.11.22",
87
- "@fungi.computer/puffball": "0.5.5",
88
- "@fungi.computer/shiitake": "0.14.0",
86
+ "@fungi.computer/parakeet": "0.11.24",
87
+ "@fungi.computer/puffball": "0.6.0",
88
+ "@fungi.computer/shiitake": "0.14.2",
89
89
  "@fungi.computer/sigils": "0.3.1",
90
90
  "@fungi.computer/sprite": "0.2.2",
91
91
  "@fungi.computer/sprite-zdog": "0.3.2",
@@ -100,16 +100,16 @@
100
100
  "lucide-react": "0.460.0",
101
101
  "react-dom": "18.3.1",
102
102
  "zod": "4.4.3",
103
- "@fungi.computer/nacre": "0.5.3"
103
+ "@fungi.computer/nacre": "0.5.5"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": "^18.3.1 || ^19.2.0"
107
107
  },
108
108
  "devDependencies": {
109
- "@fungi.computer/oyster": "0.23.0",
109
+ "@fungi.computer/oyster": "0.25.0",
110
110
  "@cloudflare/workers-types": "5.20260828.1",
111
- "@fungi.computer/forage": "0.3.5",
112
- "@fungi.computer/mycelium": "0.3.8",
111
+ "@fungi.computer/forage": "0.3.6",
112
+ "@fungi.computer/mycelium": "0.3.9",
113
113
  "@ladle/react": "5.1.1",
114
114
  "@types/react": "18.3.3",
115
115
  "@vitejs/plugin-react": "6.1.1",