xonecas.io
8058
Ir

irvc / commit a494d37

feat: 1:1 video/voice calls in dms

xonecas2026-10-16 a494d3769c2f3b6feeee9858a978cdfc1bb74291 parent 9e4affd

11 files changed

channels.go+45−0
@@ -26,6 +26,18 @@ func parseDM(name string) (int64, int64, bool) {
2626 return u1, u2, true
2727 }
2828
29+// dmPeer returns the other participant of a DM named name, if userID is one.
30+func dmPeer(name string, userID int64) (int64, bool) {
31+ u1, u2, ok := parseDM(name)
32+ if !ok || (u1 != userID && u2 != userID) {
33+ return 0, false
34+ }
35+ if u1 == userID {
36+ return u2, true
37+ }
38+ return u1, true
39+}
40+
2941 func (s *Server) notifyChannel(channelType, channelName string, ev event) {
3042 if channelType == "dm" {
3143 if u1, u2, ok := parseDM(channelName); ok {
@@ -241,6 +253,39 @@ func (s *Server) handleOpenDM(c *gin.Context) {
241253 c.JSON(http.StatusOK, ch)
242254 }
243255
256+// handleRing propagates a DM call ring, or its end, to the other participant
257+// so their client can sound the incoming-call tone.
258+func (s *Server) handleRing(ringing bool) gin.HandlerFunc {
259+ return func(c *gin.Context) {
260+ channelID, err := strconv.ParseInt(c.Param("id"), 10, 64)
261+ if err != nil {
262+ c.JSON(http.StatusBadRequest, gin.H{"error": "bad channel"})
263+ return
264+ }
265+ user := c.MustGet("user").(User)
266+ var chType, chName string
267+ if err := s.db.QueryRow(`SELECT type, name FROM channels WHERE id = ?`, channelID).Scan(&chType, &chName); err != nil {
268+ c.JSON(http.StatusNotFound, gin.H{"error": "channel not found"})
269+ return
270+ }
271+ if chType != "dm" {
272+ c.JSON(http.StatusBadRequest, gin.H{"error": "not a dm"})
273+ return
274+ }
275+ peerID, ok := dmPeer(chName, user.ID)
276+ if !ok {
277+ c.JSON(http.StatusForbidden, gin.H{"error": "forbidden"})
278+ return
279+ }
280+ if ringing {
281+ s.hub.sendTo(event{Type: "ring", ChannelID: channelID}, peerID)
282+ } else {
283+ s.hub.sendTo(event{Type: "ring_end", ChannelID: channelID}, peerID)
284+ }
285+ c.Status(http.StatusNoContent)
286+ }
287+}
288+
244289 func (s *Server) checkTextOrDM(c *gin.Context, channelID, userID int64) (string, string, bool) {
245290 var chType, chName string
246291 if err := s.db.QueryRow(`SELECT type, name FROM channels WHERE id = ?`, channelID).Scan(&chType, &chName); err != nil {
feat-video-calls-in-dms.md+19−0
@@ -0,0 +1,19 @@
1+# Inside the Direct Message context we want the user to be able to intiate a video and voice call.
2+
3+- Add a new button to the DM pane (top next to title of pane) This starts a video call.
4+- Ringing is a slow repeating, `beep()`, and can be turned off in the settings (next to join/leave sounds toggle).
5+- DM pane gets an horizontal split, with the top 3/4ths being the video call UI and the text gets shrunk to the bottom 1/4th left.
6+- A video/voice call is just another livekit track, so most of the changes are going to be on the frontend, camera support, new setting, changes to the DM pane.
7+- The ringing needs backend changes so we can propagate a ring event.
8+
9+## Some edge cases
10+
11+- Starting a DM video call while the audio is being used in a voice channel exits the voice channel. (only on audio/video track at a time).
12+
13+Follow the golden rule, re-use the existing style system/components.
14+
15+## Verify your changes
16+
17+- Use `agent-browser` and the local dev container.
18+
19+Go!
main.go+2−0
@@ -142,6 +142,8 @@ func runServer(cfg *Config, db *sql.DB) {
142142 authed.DELETE("/messages/:id", s.handleDeleteMessage)
143143 authed.POST("/messages/:id/reactions", s.handleToggleReaction)
144144 authed.POST("/channels/:id/voice", s.handleVoiceToken)
145+ authed.POST("/channels/:id/ring", s.handleRing(true))
146+ authed.DELETE("/channels/:id/ring", s.handleRing(false))
145147 authed.POST("/invites", s.handleCreateInvite)
146148 authed.GET("/gifs", s.handleGifs)
147149 authed.POST("/upload", s.handleUpload)
voice.go+11−4
@@ -62,12 +62,20 @@ func (s *Server) handleVoiceToken(c *gin.Context) {
6262 c.JSON(http.StatusBadRequest, gin.H{"error": "bad channel"})
6363 return
6464 }
65- var channelType string
66- if err := s.db.QueryRow(`SELECT type FROM channels WHERE id = ?`, channelID).Scan(&channelType); err != nil {
65+ var channelType, channelName string
66+ if err := s.db.QueryRow(`SELECT type, name FROM channels WHERE id = ?`, channelID).Scan(&channelType, &channelName); err != nil {
6767 c.JSON(http.StatusNotFound, gin.H{"error": "channel not found"})
6868 return
6969 }
70- if channelType != "voice" {
70+ user := c.MustGet("user").(User)
71+ // A DM call is a call in the DM, so it mints the same kind of token; only
72+ // voice channels and the caller's own DMs may be joined.
73+ if channelType == "dm" {
74+ if _, ok := dmPeer(channelName, user.ID); !ok {
75+ c.JSON(http.StatusForbidden, gin.H{"error": "forbidden"})
76+ return
77+ }
78+ } else if channelType != "voice" {
7179 c.JSON(http.StatusBadRequest, gin.H{"error": "not a voice channel"})
7280 return
7381 }
@@ -75,7 +83,6 @@ func (s *Server) handleVoiceToken(c *gin.Context) {
7583 c.JSON(http.StatusServiceUnavailable, gin.H{"error": "voice not configured"})
7684 return
7785 }
78- user := c.MustGet("user").(User)
7986 room := fmt.Sprintf("voice-%d", channelID)
8087 token := livekitToken(s.cfg.LiveKitKey, s.cfg.LiveKitSecret, strconv.FormatInt(user.ID, 10), user.Username, room)
8188 c.JSON(http.StatusOK, gin.H{"url": s.cfg.LiveKitURL, "token": token, "room": room})
web/src/components/CallView.tsx+64−0
@@ -0,0 +1,64 @@
1+import { useEffect, useRef } from "react";
2+import { cn } from "cn";
3+import type { Camera, Voice } from "../lib/voice";
4+
5+// Tile shows one camera publication. Our own preview is muted (it would feed
6+// back) and mirrored so it reads like a mirror, matching every video app.
7+function Tile({ cam, className }: { cam: Camera; className?: string }) {
8+ const ref = useRef<HTMLVideoElement>(null);
9+
10+ useEffect(() => {
11+ const el = ref.current;
12+ if (!el) return;
13+ cam.track.attach(el);
14+ return () => {
15+ cam.track.detach(el);
16+ };
17+ }, [cam.track]);
18+
19+ return (
20+ <div className={cn("relative min-h-0 overflow-hidden rounded-md border border-line bg-black", className)}>
21+ <video
22+ ref={ref}
23+ autoPlay
24+ playsInline
25+ muted={cam.self}
26+ className={cn("absolute inset-0 h-full w-full object-cover", cam.self && "-scale-x-100")}
27+ />
28+ <span className="absolute bottom-1 left-1 rounded bg-scrim px-1.5 py-0.5 text-xs text-fg">
29+ {cam.self ? "you" : cam.name}
30+ </span>
31+ </div>
32+ );
33+}
34+
35+// CallView fills the call pane of a DM: peers fill the pane, our own camera
36+// sits as a small picture-in-picture in the corner so we can see what we send.
37+export default function CallView({ voice, className }: { voice: Voice; className?: string }) {
38+ const { cameras } = voice;
39+ const self = cameras.find((c) => c.self) ?? null;
40+ const remotes = cameras.filter((c) => !c.self);
41+ return (
42+ <div className={cn("relative min-h-0 bg-surface", className)}>
43+ <div
44+ className={cn(
45+ "grid h-full min-h-0 auto-rows-fr gap-1 p-1",
46+ remotes.length > 1 ? "grid-cols-2" : "grid-cols-1",
47+ )}
48+ >
49+ {remotes.length > 0 ? (
50+ remotes.map((c) => <Tile key={c.id} cam={c} />)
51+ ) : (
52+ <div className="grid place-items-center text-sm text-faint">
53+ {voice.status === "live" ? "waiting for video…" : voice.error || voice.status}
54+ </div>
55+ )}
56+ </div>
57+ {self && (
58+ <div className="absolute right-2 bottom-2 aspect-video w-28 overflow-hidden rounded-md border border-line shadow-lg md:w-40">
59+ <Tile cam={self} className="h-full" />
60+ </div>
61+ )}
62+ </div>
63+ );
64+}
web/src/components/VoiceBar.tsx+11−0
@@ -7,6 +7,8 @@ import {
77 PhoneOff,
88 ScreenShare,
99 ScreenShareOff,
10+ Video,
11+ VideoOff,
1012 VolumeX,
1113 } from "lucide-react";
1214 import { cn } from "cn";
@@ -145,6 +147,15 @@ export default function VoiceBar({
145147 >
146148 {deafened ? <HeadphoneOff /> : <Headphones />}
147149 </IconButton>
150+ {voice.channel.type === "dm" && (
151+ <IconButton
152+ label={voice.cameraOn ? "turn camera off" : "turn camera on"}
153+ variant={voice.cameraOn ? "secondary" : "ghost"}
154+ onClick={voice.toggleCamera}
155+ >
156+ {voice.cameraOn ? <Video /> : <VideoOff />}
157+ </IconButton>
158+ )}
148159 <IconButton
149160 label={!canShare ? "screen share needs https" : voice.sharing ? "stop sharing" : "share screen"}
150161 variant={voice.sharing ? "secondary" : "ghost"}
web/src/lib/settings.ts+2−0
@@ -26,6 +26,7 @@ export interface Settings {
2626 deafened: boolean;
2727 gateThreshold: number;
2828 joinSound: boolean;
29+ ringSound: boolean;
2930 screenShareQuality: ScreenShareQuality;
3031 fontSize: FontSize;
3132 }
@@ -41,6 +42,7 @@ export const defaultSettings: Settings = {
4142 deafened: false,
4243 gateThreshold: -60,
4344 joinSound: true,
45+ ringSound: true,
4446 screenShareQuality: "720p",
4547 fontSize: "normal",
4648 };
web/src/lib/types.ts+3−1
@@ -51,7 +51,9 @@ export interface WSEvent {
5151 | "presence"
5252 | "pong"
5353 | "channel"
54- | "channel_delete";
54+ | "channel_delete"
55+ | "ring"
56+ | "ring_end";
5557 message?: Message;
5658 users?: string[];
5759 roster?: UserSummary[];
web/src/lib/voice.ts+67−3
@@ -26,10 +26,11 @@ interface VoiceToken {
2626 }
2727
2828 // beep plays a short tone for call roster changes (someone joined or left the
29-// call you are in). Web Audio needs no asset; it unlocks on the click that
30-// joined the call.
31-function beep(freq: number) {
29+// call you are in) and for an incoming DM ring. Web Audio needs no asset; it
30+// unlocks on the click that joined the call.
31+export function beep(freq: number) {
3232 const ctx = new AudioContext();
33+ ctx.resume().catch(() => {});
3334 const osc = ctx.createOscillator();
3435 const gain = ctx.createGain();
3536 gain.gain.value = 0.1;
@@ -223,6 +224,37 @@ function sharesOf(room: Room): Share[] {
223224 return shares;
224225 }
225226
227+// A camera publication, ours or a peer's, in a DM video call.
228+export interface Camera {
229+ id: string;
230+ name: string;
231+ self: boolean;
232+ track: Track;
233+}
234+
235+function camerasOf(room: Room): Camera[] {
236+ const cameras: Camera[] = [];
237+ const collect = (p: Participant, self: boolean) => {
238+ for (const pub of p.trackPublications.values()) {
239+ if (
240+ pub.source === Track.Source.Camera &&
241+ pub.track?.kind === Track.Kind.Video &&
242+ !pub.isMuted
243+ ) {
244+ cameras.push({
245+ id: `${p.identity}:${pub.trackSid}`,
246+ name: p.name || p.identity,
247+ self,
248+ track: pub.track,
249+ });
250+ }
251+ }
252+ };
253+ collect(room.localParticipant, true);
254+ for (const p of room.remoteParticipants.values()) collect(p, false);
255+ return cameras;
256+}
257+
226258 // micSignature identifies the applied capture + encoding config, so live
227259 // changes can be detected without republishing on every render.
228260 function micSignature(s: Settings): string {
@@ -254,11 +286,14 @@ export interface Voice {
254286 peers: string[];
255287 speaking: string[];
256288 shares: Share[];
289+ cameras: Camera[];
257290 sharing: boolean;
291+ cameraOn: boolean;
258292 muted: boolean;
259293 join: (c: Channel) => void;
260294 leave: () => void;
261295 toggleMute: () => void;
296+ toggleCamera: () => void;
262297 toggleShare: () => void;
263298 setPeerVolume: (name: string, volume: number) => void;
264299 micLevel: () => number;
@@ -275,6 +310,8 @@ export function useVoice(settings: Settings, onVoice?: (state: VoiceState) => vo
275310 const [peers, setPeers] = useState<string[]>([]);
276311 const [speaking, setSpeaking] = useState<string[]>([]);
277312 const [shares, setShares] = useState<Share[]>([]);
313+ const [cameras, setCameras] = useState<Camera[]>([]);
314+ const [cameraOn, setCameraOn] = useState(false);
278315 const [muted, setMuted] = useState(false);
279316 const roomRef = useRef<Room | null>(null);
280317 const audioRef = useRef<HTMLAudioElement[]>([]);
@@ -309,6 +346,8 @@ export function useVoice(settings: Settings, onVoice?: (state: VoiceState) => vo
309346 setPeers([]);
310347 setSpeaking([]);
311348 setShares([]);
349+ setCameras([]);
350+ setCameraOn(false);
312351 setMuted(false);
313352 }, []);
314353
@@ -330,6 +369,7 @@ export function useVoice(settings: Settings, onVoice?: (state: VoiceState) => vo
330369 const sync = () => {
331370 setPeers([...room.remoteParticipants.values()].map((p) => p.name || p.identity));
332371 setShares(sharesOf(room));
372+ setCameras(camerasOf(room));
333373 };
334374 room.on(RoomEvent.ParticipantConnected, () => {
335375 if (readyRef.current && settingsRef.current.joinSound) beep(440);
@@ -355,6 +395,8 @@ export function useVoice(settings: Settings, onVoice?: (state: VoiceState) => vo
355395 RoomEvent.TrackUnpublished,
356396 RoomEvent.TrackSubscribed,
357397 RoomEvent.TrackUnsubscribed,
398+ RoomEvent.TrackMuted,
399+ RoomEvent.TrackUnmuted,
358400 RoomEvent.LocalTrackPublished,
359401 RoomEvent.LocalTrackUnpublished,
360402 ]) {
@@ -377,6 +419,14 @@ export function useVoice(settings: Settings, onVoice?: (state: VoiceState) => vo
377419 readyRef.current = true;
378420 const mic = await room.localParticipant.setMicrophoneEnabled(true, capture(s), publish(s));
379421 if (mic?.audioTrack) await mic.audioTrack.setProcessor(gate.processor);
422+ // A DM call is a video call: publish the camera too, falling back to
423+ // audio only if the camera is unavailable or denied.
424+ if (c.type === "dm") {
425+ await room.localParticipant
426+ .setCameraEnabled(true)
427+ .then(() => setCameraOn(true))
428+ .catch(() => {});
429+ }
380430 if (s.speakerDeviceId) {
381431 await room.switchActiveDevice("audiooutput", s.speakerDeviceId).catch(() => {});
382432 }
@@ -445,6 +495,17 @@ export function useVoice(settings: Settings, onVoice?: (state: VoiceState) => vo
445495 setMuted(next);
446496 }, [muted]);
447497
498+ const toggleCamera = useCallback(async () => {
499+ const room = roomRef.current;
500+ if (!room) return;
501+ const next = !cameraOn;
502+ // A denied camera stays off; do not claim it is on.
503+ await room.localParticipant.setCameraEnabled(next).then(
504+ () => setCameraOn(next),
505+ () => setCameraOn(false),
506+ );
507+ }, [cameraOn]);
508+
448509 const toggleShare = useCallback(async () => {
449510 const room = roomRef.current;
450511 if (!room) return;
@@ -481,11 +542,14 @@ export function useVoice(settings: Settings, onVoice?: (state: VoiceState) => vo
481542 peers,
482543 speaking,
483544 shares,
545+ cameras,
484546 sharing: shares.some((s) => s.self),
547+ cameraOn,
485548 muted,
486549 join,
487550 leave,
488551 toggleMute,
552+ toggleCamera,
489553 toggleShare,
490554 setPeerVolume,
491555 micLevel,
web/src/views/Chat.tsx+100−32
@@ -1,13 +1,14 @@
11 import { useCallback, useEffect, useRef, useState } from "react";
2-import { AtSign, Hash, Menu, MoreHorizontal, ScreenShare, Settings as SettingsIcon } from "lucide-react";
2+import { AtSign, Hash, Menu, MoreHorizontal, PhoneOff, ScreenShare, Settings as SettingsIcon, Video } from "lucide-react";
33 import { cn } from "cn";
44 import { Button, Centered, IconButton, Menu as MenuPrimitive, MenuItem } from "@/ui";
55 import { api } from "../lib/api";
66 import { usePresence } from "../lib/presence";
77 import { useSettings } from "../lib/settings";
88 import { useTheme } from "../lib/theme";
9-import { useVoice, type VoiceState } from "../lib/voice";
9+import { beep, useVoice, type VoiceState } from "../lib/voice";
1010 import type { Channel, Message, Reaction, User, UserSummary, VoiceOccupant } from "../lib/types";
11+import CallView from "../components/CallView";
1112 import Composer from "../components/Composer";
1213 import MessageActions from "../components/MessageActions";
1314 import MessageList, { hasImage } from "../components/MessageList";
@@ -41,9 +42,12 @@ export default function Chat({ user, onLogout }: { user: User; onLogout: () => v
4142 const [voiceRooms, setVoiceRooms] = useState<Record<string, VoiceOccupant[]>>({});
4243 const [view, setView] = useState<"channel" | "settings">("channel");
4344 const [openShare, setOpenShare] = useState<string | null>(null);
45+ const [ringing, setRinging] = useState<number | null>(null);
4446 const desktop = useRef(matchMedia("(min-width: 768px)").matches);
4547 const [sidebarOpen, setSidebarOpen] = useState(desktop.current);
4648 const selectedId = useRef<number | null>(null);
49+ // The channel of the DM call we started, so we can tell the peer when it ends.
50+ const rangRef = useRef<number | null>(null);
4751 // The server drops our voice state when the socket dies, so keep the last
4852 // thing we told it and replay that on every (re)connect.
4953 const voiceState = useRef<VoiceState>({ channelId: 0, muted: false, deafened: false });
@@ -72,6 +76,23 @@ export default function Chat({ user, onLogout }: { user: User; onLogout: () => v
7276 setChannels((cs) => (cs.some((c) => c.id === ev.channel!.id) ? cs : [...cs, ev.channel!]));
7377 } else if (ev.type === "channel_delete" && ev.channelId) {
7478 setChannels((cs) => cs.filter((c) => c.id !== ev.channelId));
79+ } else if (ev.type === "ring" && ev.channelId) {
80+ // Answering sends its own ring; ignore it when already in that call.
81+ if (voice.channel?.id === ev.channelId) return;
82+ setRinging(ev.channelId);
83+ // Answering means opening the DM, so surface it for the callee.
84+ const dm = channels.find((c) => c.id === ev.channelId);
85+ if (dm) open(dm);
86+ else
87+ api<Channel[]>("/channels")
88+ .then((cs) => {
89+ setChannels(cs);
90+ const c = cs.find((x) => x.id === ev.channelId);
91+ if (c) open(c);
92+ })
93+ .catch(() => {});
94+ } else if (ev.type === "ring_end" && ev.channelId) {
95+ setRinging((r) => (r === ev.channelId ? null : r));
7596 } else if (ev.message) {
7697 if (ev.type === "message") {
7798 setChannels((cs) => {
@@ -107,6 +128,31 @@ export default function Chat({ user, onLogout }: { user: User; onLogout: () => v
107128 });
108129 const theme = useTheme();
109130
131+ // Ring while a peer calls us. The slow beep repeats (when enabled) until we
132+ // answer, they hang up, or the call times out as missed.
133+ useEffect(() => {
134+ if (ringing === null) return;
135+ const timeout = setTimeout(() => setRinging(null), 30_000);
136+ const sound = settings.ringSound ? (beep(880), setInterval(() => beep(880), 2000)) : 0;
137+ return () => {
138+ clearTimeout(timeout);
139+ clearInterval(sound);
140+ };
141+ }, [ringing, settings.ringSound]);
142+
143+ // Joining the call answers the ring.
144+ useEffect(() => {
145+ if (ringing !== null && voice.channel?.id === ringing) setRinging(null);
146+ }, [ringing, voice.channel]);
147+
148+ // Tell the peer when a DM call we started is over.
149+ useEffect(() => {
150+ const started = rangRef.current;
151+ if (started === null || voice.channel?.id === started) return;
152+ rangRef.current = null;
153+ api(`/channels/${started}/ring`, { method: "DELETE" }).catch(() => {});
154+ }, [voice.channel]);
155+
110156 // The watched share lives in the LiveKit room, so it vanishes when the sharer
111157 // stops; the pane then falls back to the selected channel.
112158 const share = voice.shares.find((s) => s.id === openShare) ?? null;
@@ -177,6 +223,14 @@ export default function Chat({ user, onLogout }: { user: User; onLogout: () => v
177223 if (!desktop.current) setSidebarOpen(false);
178224 }
179225
226+ // startCall opens a DM video call and rings the peer. Joining leaves any
227+ // voice channel first, since only one call can use the mic and camera.
228+ function startCall(c: Channel) {
229+ rangRef.current = c.id;
230+ voice.join(c);
231+ api(`/channels/${c.id}/ring`, { method: "POST" }).catch(() => {});
232+ }
233+
180234 async function selectUser(u: UserSummary) {
181235 try {
182236 const dm = await api<Channel>(`/dms/${u.id}`, { method: "POST" });
@@ -254,6 +308,7 @@ export default function Chat({ user, onLogout }: { user: User; onLogout: () => v
254308
255309 const chat = selected?.type === "text" || selected?.type === "dm";
256310 const showingShare = view === "channel" && share !== null;
311+ const inCall = selected?.type === "dm" && voice.channel?.id === selected.id;
257312
258313 return (
259314 <div className="flex h-dvh overflow-hidden">
@@ -339,6 +394,16 @@ export default function Chat({ user, onLogout }: { user: User; onLogout: () => v
339394 <Hash size={16} className="text-faint" />
340395 ))}
341396 <span className="truncate text-sm font-medium">{selected?.name}</span>
397+ {selected?.type === "dm" && (
398+ <IconButton
399+ label={inCall ? "leave call" : ringing === selected.id ? "answer call" : "start video call"}
400+ variant={inCall ? "danger" : ringing === selected.id ? "primary" : "ghost"}
401+ size="sm"
402+ onClick={() => (inCall ? voice.leave() : startCall(selected))}
403+ >
404+ {inCall ? <PhoneOff /> : <Video />}
405+ </IconButton>
406+ )}
342407 {selected?.type === "text" && !selected.permanent && (
343408 <MenuPrimitive
344409 className="ml-auto"
@@ -368,37 +433,40 @@ export default function Chat({ user, onLogout }: { user: User; onLogout: () => v
368433 <ScreenShareView track={share.track} />
369434 ) : chat && selected ? (
370435 <>
371- <MessageList
372- channelId={selected.id}
373- messages={messages}
374- username={user.username}
375- collapsed={collapsed}
376- editing={editing}
377- activeId={active?.id ?? null}
378- onSelect={(m) => setActive((a) => (a?.id === m.id ? null : m))}
379- onToggleImages={toggleImages}
380- onEditBody={(body) => setEditing((e) => (e ? { ...e, body } : e))}
381- onCancelEdit={() => setEditing(null)}
382- onSaveEdit={saveEdit}
383- />
384- {active && !editing && (
385- <MessageActions
386- message={active}
387- own={active.username === user.username}
388- onReact={(r) => react(active, r)}
389- onEdit={() => startEdit(active)}
390- onDelete={() => deleteMessage(active)}
391- onClose={() => setActive(null)}
436+ {inCall && <CallView voice={voice} className="flex-[3]" />}
437+ <div className={cn("flex min-h-0 flex-1 flex-col", inCall && "flex-[1] border-t border-line")}>
438+ <MessageList
439+ channelId={selected.id}
440+ messages={messages}
441+ username={user.username}
442+ collapsed={collapsed}
443+ editing={editing}
444+ activeId={active?.id ?? null}
445+ onSelect={(m) => setActive((a) => (a?.id === m.id ? null : m))}
446+ onToggleImages={toggleImages}
447+ onEditBody={(body) => setEditing((e) => (e ? { ...e, body } : e))}
448+ onCancelEdit={() => setEditing(null)}
449+ onSaveEdit={saveEdit}
392450 />
393- )}
394- <Composer
395- channel={selected}
396- users={users}
397- onEditLast={startEditLast}
398- onCollapseImages={() =>
399- setCollapsed(new Set(messages.filter((m) => hasImage(m.body)).map((m) => m.id)))
400- }
401- />
451+ {active && !editing && (
452+ <MessageActions
453+ message={active}
454+ own={active.username === user.username}
455+ onReact={(r) => react(active, r)}
456+ onEdit={() => startEdit(active)}
457+ onDelete={() => deleteMessage(active)}
458+ onClose={() => setActive(null)}
459+ />
460+ )}
461+ <Composer
462+ channel={selected}
463+ users={users}
464+ onEditLast={startEditLast}
465+ onCollapseImages={() =>
466+ setCollapsed(new Set(messages.filter((m) => hasImage(m.body)).map((m) => m.id)))
467+ }
468+ />
469+ </div>
402470 </>
403471 ) : (
404472 <Centered>select a channel</Centered>
web/src/views/Settings.tsx+5−0
@@ -135,6 +135,11 @@ export default function SettingsView({
135135 checked={settings.joinSound}
136136 onChange={(v) => update({ joinSound: v })}
137137 />
138+ <Toggle
139+ label="ringing"
140+ checked={settings.ringSound}
141+ onChange={(v) => update({ ringSound: v })}
142+ />
138143 </Section>
139144
140145 <Section label="Voice activation">