xonecas.io
8058
Ir

irvc / commit 0802cbe

feat: polish UI pass, enable basic mobile UI

xonecas2026-10-12 0802cbeb616843d31525aa96772d38c490e64aff parent b05994d

6 files changed

AGENTS.md+67−0
@@ -8,8 +8,75 @@ the need is rising for a private self hosted instance of this.
88
99 This is ours.
1010
11+## This box is production
12+
13+**This checkout is the live instance at https://irvc.xonecas.io. It is not a
14+sandbox.** The `irvc` systemd service runs from this directory
15+(`WorkingDirectory` = this repo). Treat everything here as live.
16+
17+- `web/dist` is served live from disk per request. `cd web && npm run build`
18+ **deploys the frontend immediately** — no separate deploy step.
19+- `irvc.db` (WAL) is the live database: all users, invites, sessions, channels,
20+ messages. It is the only state.
21+- `./irvc` is the live binary; `go build -o irvc .` replaces it on disk (the
22+ service picks it up on restart).
23+- Host config (DNS, Caddy, firewall, Caddyfile) lives in `../vps/README.md`.
24+- Deployment runbook: `DEPLOY.md`.
25+
26+### SQLite: be very, very careful
27+
28+The DB holds real users and messages. Losing or corrupting it loses everything.
29+
30+- **Never start a second server process against `irvc.db`.** One process owns it.
31+- **Never run schema migrations, manual writes, or `sqlite3` mutations by hand.**
32+ Read-only inspection is fine; anything that writes is not.
33+- Don't copy, move, truncate, or delete the DB, `-wal`, or `-shm` files.
34+- Don't create accounts or invites in it without Sean's explicit approval.
35+
36+When verifying changes, use the live site directly (`agent-browser` against
37+https://irvc.xonecas.io) — never spin up a local instance.
38+
1139 ## Docs
1240
1341 - `README.md` — build, configuration, invites, run.
1442 - `irvc.md` — design.
1543 - `DEPLOY.md` — runbook for the VPS deployment.
44+
45+## Agent test account
46+
47+This is the shared test account for agents. Use it for any live UI checks.
48+
49+- URL: https://irvc.xonecas.io
50+- Username: `deepseek`
51+- Password: `deepseek`
52+
53+Rules:
54+
55+- Use only this account. It is the only account agents may use.
56+- Never create new accounts or invites without explicit approval from Sean.
57+
58+### Seeing the UI
59+
60+Use `agent-browser`:
61+
62+```bash
63+agent-browser open https://irvc.xonecas.io
64+agent-browser snapshot -i # find the username/password fields
65+agent-browser fill @e<user> deepseek
66+agent-browser fill @e<pass> deepseek
67+agent-browser click @e<join>
68+agent-browser screenshot /tmp/irvc.png
69+```
70+
71+If already logged in, just open and snapshot.
72+
73+Note: this React app does not respond to `agent-browser click`/`press` for some
74+controls (e.g. `send`, Enter-to-send). Native clicks work but React handlers may
75+not fire. Fall back to dispatching the real DOM event via `agent-browser eval`:
76+
77+```bash
78+# submit the message form
79+agent-browser eval "document.querySelector('form').requestSubmit()"
80+# click a button by title
81+agent-browser eval "[...document.querySelectorAll('button')].find(b=>b.title==='dark mode').click()"
82+```
web/src/components/ChatPane.tsx+47−29
@@ -1,4 +1,5 @@
11 import {
2+ useCallback,
23 useEffect,
34 useLayoutEffect,
45 useRef,
@@ -33,23 +34,38 @@ export default function ChatPane({
3334 }) {
3435 const [body, setBody] = useState("");
3536 const listRef = useRef<HTMLDivElement>(null);
37+ const contentRef = useRef<HTMLDivElement>(null);
3638 const stickRef = useRef(true);
3739 const textareaRef = useRef<HTMLTextAreaElement>(null);
3840 const fileRef = useRef<HTMLInputElement>(null);
3941
40- // Jump to the bottom on channel switch, regardless of prior position.
41- useLayoutEffect(() => {
42- stickRef.current = true;
42+ const scrollToBottom = useCallback(() => {
4343 const el = listRef.current;
4444 if (el) el.scrollTop = el.scrollHeight;
45- }, [channel]);
45+ }, []);
4646
47- // Follow new messages only while the user is pinned to the bottom. Layout
48- // effect so the initial history scrolls before the browser can unpin us.
47+ // Jump to the latest messages on channel switch, regardless of prior position.
4948 useLayoutEffect(() => {
50- const el = listRef.current;
51- if (el && stickRef.current) el.scrollTop = el.scrollHeight;
52- }, [messages]);
49+ stickRef.current = true;
50+ scrollToBottom();
51+ }, [channel?.id, scrollToBottom]);
52+
53+ // Follow appended messages only while the user is pinned to the bottom.
54+ useLayoutEffect(() => {
55+ if (stickRef.current) scrollToBottom();
56+ }, [messages, scrollToBottom]);
57+
58+ // Images and markdown grow after the effects above run, so stay pinned while
59+ // the content resizes — unless the user has scrolled up.
60+ useEffect(() => {
61+ const content = contentRef.current;
62+ if (!content) return;
63+ const ro = new ResizeObserver(() => {
64+ if (stickRef.current) scrollToBottom();
65+ });
66+ ro.observe(content);
67+ return () => ro.disconnect();
68+ }, [channel?.id, scrollToBottom]);
5369
5470 function onScroll() {
5571 const el = listRef.current;
@@ -126,26 +142,28 @@ export default function ChatPane({
126142 return (
127143 <>
128144 <div ref={listRef} onScroll={onScroll} className="min-h-0 flex-1 overflow-y-auto px-4 py-3">
129- {messages.map((m) => {
130- const action = m.body.startsWith("/me ") ? m.body.slice(4) : null;
131- return (
132- <div key={m.id} className="flex gap-1.5 py-0.5 text-sm leading-6">
133- <span className="shrink-0">
134- <span className="text-sepia/40">{clock(m.createdAt)}</span>{" "}
135- {!action && <span className="text-gold/90">{m.username}</span>}
136- </span>
137- {action ? (
138- <div className="min-w-0 flex-1 break-words italic text-gold/90">
139- * {m.username} {action}
140- </div>
141- ) : (
142- <div className={bodyClass}>
143- <Markdown text={m.body} />
144- </div>
145- )}
146- </div>
147- );
148- })}
145+ <div ref={contentRef}>
146+ {messages.map((m) => {
147+ const action = m.body.startsWith("/me ") ? m.body.slice(4) : null;
148+ return (
149+ <div key={m.id} className="flex gap-1.5 py-0.5 text-sm leading-6">
150+ <span className="shrink-0">
151+ <span className="text-sepia/40">{clock(m.createdAt)}</span>{" "}
152+ {!action && <span className="text-gold/90">{m.username}</span>}
153+ </span>
154+ {action ? (
155+ <div className="min-w-0 flex-1 break-words italic text-gold/90">
156+ * {m.username} {action}
157+ </div>
158+ ) : (
159+ <div className={bodyClass}>
160+ <Markdown text={m.body} />
161+ </div>
162+ )}
163+ </div>
164+ );
165+ })}
166+ </div>
149167 </div>
150168 <form onSubmit={submit} className="flex items-end gap-2 border-t border-sepia/15 p-3">
151169 <input
web/src/components/SettingsPanel.tsx+3−4
@@ -62,9 +62,8 @@ export default function SettingsPanel({
6262 const meter = voice.status === "live" ? voice.micLevel : preview;
6363
6464 return (
65- <aside className="w-64 shrink-0 overflow-y-auto border-l border-sepia/15">
66- <div className="px-4 py-3 text-[10px] uppercase tracking-widest text-sepia/40">Settings</div>
67- <div className="space-y-4 px-3 pb-4">
65+ <div className="flex-1 overflow-y-auto">
66+ <div className="mx-auto max-w-2xl space-y-4 p-6">
6867 <Group label="Voice">
6968 <Button
7069 variant={settings.deafened ? "secondary" : "ghost"}
@@ -147,7 +146,7 @@ export default function SettingsPanel({
147146 />
148147 </Group>
149148 </div>
150- </aside>
149+ </div>
151150 );
152151 }
153152
web/src/components/Sidebar.tsx+66−4
@@ -1,9 +1,24 @@
11 import { useState, type ReactNode } from "react";
2-import { Hash, Mic, MicOff, PhoneOff, UserPlus, Volume2 } from "lucide-react";
2+import {
3+ ChevronDown,
4+ ChevronRight,
5+ Hash,
6+ LogOut,
7+ Mic,
8+ MicOff,
9+ Moon,
10+ PhoneOff,
11+ Settings,
12+ Sun,
13+ UserPlus,
14+ Volume2,
15+} from "lucide-react";
316 import { Button } from "@/components/ui/button";
417 import { api } from "../lib/api";
5-import type { Channel } from "../lib/types";
18+import type { Channel, UserSummary } from "../lib/types";
19+import type { Theme } from "../lib/theme";
620 import type { Voice } from "../lib/voice";
21+import UserList from "./UserList";
722 import VoicePeers from "./VoicePeers";
823
924 interface Invite {
@@ -17,14 +32,29 @@ export default function Sidebar({
1732 onSelect,
1833 voice,
1934 username,
35+ users,
36+ online,
37+ theme,
38+ onToggleTheme,
39+ settingsOpen,
40+ onToggleSettings,
41+ onLogout,
2042 }: {
2143 channels: Channel[];
2244 selected: Channel | null;
2345 onSelect: (c: Channel) => void;
2446 voice: Voice;
2547 username: string;
48+ users: UserSummary[];
49+ online: Set<string>;
50+ theme: Theme;
51+ onToggleTheme: () => void;
52+ settingsOpen: boolean;
53+ onToggleSettings: () => void;
54+ onLogout: () => void;
2655 }) {
2756 const [label, setLabel] = useState("create invite");
57+ const [showUsers, setShowUsers] = useState(true);
2858
2959 async function invite() {
3060 try {
@@ -38,7 +68,7 @@ export default function Sidebar({
3868 }
3969
4070 return (
41- <aside className="flex w-56 shrink-0 flex-col border-r border-sepia/15">
71+ <aside className="flex w-56 shrink-0 flex-col border-r border-sepia/15 bg-bg max-md:absolute max-md:inset-y-0 max-md:left-0 max-md:z-20">
4272 <div className="px-4 py-3 text-sm font-semibold text-gold">irvc</div>
4373 <nav className="flex-1 space-y-4 overflow-y-auto px-2 pb-3">
4474 <Group
@@ -56,8 +86,19 @@ export default function Sidebar({
5686 <VoiceChannel key={c.id} channel={c} voice={voice} username={username} />
5787 ))}
5888 </div>
89+ <div>
90+ <button
91+ type="button"
92+ onClick={() => setShowUsers((v) => !v)}
93+ className="flex w-full items-center gap-1 px-2 py-1 text-[10px] uppercase tracking-widest text-sepia/40 hover:text-sepia/70"
94+ >
95+ {showUsers ? <ChevronDown size={12} /> : <ChevronRight size={12} />}
96+ Users
97+ </button>
98+ {showUsers && <UserList users={users} online={online} />}
99+ </div>
59100 </nav>
60- <div className="p-2">
101+ <div className="space-y-2 p-2">
61102 <Button
62103 variant="ghost"
63104 size="sm"
@@ -67,6 +108,27 @@ export default function Sidebar({
67108 <UserPlus size={14} />
68109 {label}
69110 </Button>
111+ <div className="flex items-center gap-1">
112+ <Button
113+ variant="ghost"
114+ size="icon-sm"
115+ onClick={onToggleTheme}
116+ title={theme === "dark" ? "light mode" : "dark mode"}
117+ >
118+ {theme === "dark" ? <Sun /> : <Moon />}
119+ </Button>
120+ <Button
121+ variant={settingsOpen ? "secondary" : "ghost"}
122+ size="icon-sm"
123+ onClick={onToggleSettings}
124+ title="settings"
125+ >
126+ <Settings />
127+ </Button>
128+ <Button variant="ghost" size="icon-sm" onClick={onLogout} title="log out">
129+ <LogOut />
130+ </Button>
131+ </div>
70132 </div>
71133 </aside>
72134 );
web/src/components/UserList.tsx+16−19
@@ -8,24 +8,21 @@ export default function UserList({ users, online }: { users: UserSummary[]; onli
88 );
99
1010 return (
11- <aside className="w-56 shrink-0 overflow-y-auto border-l border-sepia/15">
12- <div className="px-4 py-3 text-[10px] uppercase tracking-widest text-sepia/40">Users</div>
13- <ul className="space-y-0.5 px-2">
14- {sorted.map((u) => {
15- const isOnline = online.has(u.username);
16- return (
17- <li
18- key={u.id}
19- className={`flex items-center gap-2 rounded px-2 py-1 text-sm ${
20- isOnline ? "text-sepia" : "text-sepia/35"
21- }`}
22- >
23- <span className={`h-2 w-2 rounded-full ${isOnline ? "bg-gold" : "bg-sepia/25"}`} />
24- {u.username}
25- </li>
26- );
27- })}
28- </ul>
29- </aside>
11+ <ul className="space-y-0.5 px-2">
12+ {sorted.map((u) => {
13+ const isOnline = online.has(u.username);
14+ return (
15+ <li
16+ key={u.id}
17+ className={`flex items-center gap-2 rounded px-2 py-1 text-sm ${
18+ isOnline ? "text-sepia" : "text-sepia/35"
19+ }`}
20+ >
21+ <span className={`h-2 w-2 rounded-full ${isOnline ? "bg-gold" : "bg-sepia/25"}`} />
22+ {u.username}
23+ </li>
24+ );
25+ })}
26+ </ul>
3027 );
3128 }
web/src/views/Chat.tsx+63−48
@@ -1,5 +1,5 @@
11 import { useEffect, useRef, useState } from "react";
2-import { Hash, LogOut, Moon, Settings, Sun, Users } from "lucide-react";
2+import { Hash, Menu, Settings } from "lucide-react";
33 import { Button } from "@/components/ui/button";
44 import { api } from "../lib/api";
55 import { useSettings } from "../lib/settings";
@@ -9,9 +9,6 @@ import type { Channel, Message, User, UserSummary, WSEvent } from "../lib/types"
99 import ChatPane from "../components/ChatPane";
1010 import SettingsPanel from "../components/SettingsPanel";
1111 import Sidebar from "../components/Sidebar";
12-import UserList from "../components/UserList";
13-
14-type Panel = "users" | "settings" | null;
1512
1613 export default function Chat({ user, onLogout }: { user: User; onLogout: () => void }) {
1714 const [channels, setChannels] = useState<Channel[]>([]);
@@ -19,7 +16,9 @@ export default function Chat({ user, onLogout }: { user: User; onLogout: () => v
1916 const [users, setUsers] = useState<UserSummary[]>([]);
2017 const [online, setOnline] = useState<Set<string>>(new Set());
2118 const [messages, setMessages] = useState<Message[]>([]);
22- const [panel, setPanel] = useState<Panel>("users");
19+ const [settingsOpen, setSettingsOpen] = useState(false);
20+ const desktop = useRef(window.matchMedia("(min-width: 768px)").matches);
21+ const [sidebarOpen, setSidebarOpen] = useState(desktop.current);
2322 const selectedId = useRef<number | null>(null);
2423 const { settings, update } = useSettings();
2524 const voice = useVoice(settings);
@@ -66,60 +65,76 @@ export default function Chat({ user, onLogout }: { user: User; onLogout: () => v
6665 .catch(() => {});
6766 }, [selected]);
6867
68+ function selectChannel(c: Channel) {
69+ setSelected(c);
70+ setSettingsOpen(false);
71+ if (!desktop.current) setSidebarOpen(false);
72+ }
73+
74+ function toggleSettings() {
75+ setSettingsOpen((v) => !v);
76+ if (!desktop.current) setSidebarOpen(false);
77+ }
78+
6979 async function logout() {
7080 await api("/logout", { method: "POST" }).catch(() => {});
7181 onLogout();
7282 }
7383
7484 return (
75- <div className="flex h-full">
76- <Sidebar
77- channels={channels}
78- selected={selected}
79- onSelect={setSelected}
80- voice={voice}
81- username={user.username}
82- />
85+ <div className="relative flex h-full">
86+ {sidebarOpen && (
87+ <div
88+ className="fixed inset-0 z-10 bg-black/30 md:hidden"
89+ onClick={() => setSidebarOpen(false)}
90+ />
91+ )}
92+ {sidebarOpen && (
93+ <Sidebar
94+ channels={channels}
95+ selected={selected}
96+ onSelect={selectChannel}
97+ voice={voice}
98+ username={user.username}
99+ users={users}
100+ online={online}
101+ theme={theme}
102+ onToggleTheme={toggle}
103+ settingsOpen={settingsOpen}
104+ onToggleSettings={toggleSettings}
105+ onLogout={logout}
106+ />
107+ )}
83108 <main className="flex min-w-0 flex-1 flex-col">
84- <header className="flex items-center justify-between border-b border-sepia/15 px-4 py-2">
109+ <header className="flex items-center gap-1 border-b border-sepia/15 px-2 py-2">
110+ <Button
111+ variant="ghost"
112+ size="icon-sm"
113+ onClick={() => setSidebarOpen((v) => !v)}
114+ title="toggle sidebar"
115+ >
116+ <Menu />
117+ </Button>
85118 <span className="flex items-center gap-1.5 text-sm text-sepia/70">
86- {selected && <Hash size={14} />}
87- {selected?.name}
119+ {settingsOpen ? (
120+ <>
121+ <Settings size={14} />
122+ Settings
123+ </>
124+ ) : (
125+ <>
126+ {selected && <Hash size={14} />}
127+ {selected?.name}
128+ </>
129+ )}
88130 </span>
89- <div className="flex items-center gap-1">
90- <Button
91- variant="ghost"
92- size="icon-sm"
93- onClick={toggle}
94- title={theme === "dark" ? "light mode" : "dark mode"}
95- >
96- {theme === "dark" ? <Sun /> : <Moon />}
97- </Button>
98- <Button
99- variant="ghost"
100- size="icon-sm"
101- onClick={() => setPanel((p) => (p === "settings" ? null : "settings"))}
102- title="settings"
103- >
104- <Settings />
105- </Button>
106- <Button
107- variant="ghost"
108- size="icon-sm"
109- onClick={() => setPanel((p) => (p === "users" ? null : "users"))}
110- title="toggle users"
111- >
112- <Users />
113- </Button>
114- <Button variant="ghost" size="icon-sm" onClick={logout} title="log out">
115- <LogOut />
116- </Button>
117- </div>
118131 </header>
119- <ChatPane channel={selected} messages={messages} />
132+ {settingsOpen ? (
133+ <SettingsPanel settings={settings} update={update} voice={voice} />
134+ ) : (
135+ <ChatPane channel={selected} messages={messages} />
136+ )}
120137 </main>
121- {panel === "settings" && <SettingsPanel settings={settings} update={update} voice={voice} />}
122- {panel === "users" && <UserList users={users} online={online} />}
123138 </div>
124139 );
125140 }