xonecas.io
8058
Ir

irvc / commit 1e02afb

Merge pull request #4 from sacenox/jm/style

lots of style changes

xonecas2026-10-16 1e02afb92a2f2933c6374d7aa087e8452c1cf3c9 parent d0e6dd0parent 4c8b19c

19 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

.gitignore+1−0
@@ -20,3 +20,4 @@ web/dist/
2020 /irvc.db-shm
2121 /irvc.db-wal
2222 /media/
23+/fruit/*.yml
Makefile+1−0
@@ -10,6 +10,7 @@ frontend:
1010
1111 fmt:
1212 goimports -w $$(find . -name '*.go' -not -path './web/node_modules/*')
13+ cd web && npm run fmt && npm run lint
1314
1415 test:
1516 go test ./...
deploy/dev/tools/convo.py+210−0
@@ -0,0 +1,210 @@
1+#!/usr/bin/env python3
2+"""Emit a ~4 day fake conversation between the six seed users as JSONL
3+for post.py. Usage: convo.py > /tmp/convo.jsonl"""
4+import json, random
5+from datetime import datetime, timedelta
6+
7+S, B, W, M, T, K = "sean", "bananaman", "wombat", "moonlord", "toaster", "kebab"
8+random.seed(7)
9+
10+# (day offset from first day, "HH:MM", [(user, text), ...], max gap seconds between lines)
11+scenes = [
12+(0, "08:12", 90, [
13+ (S, "morning all"), (T, "mornin"), (S, "did anyone get the staging deploy to go through last night?"),
14+ (K, "yeah it went through around midnight, i was up anyway"), (S, "ah thanks. i saw the green check but wanted a human to confirm"),
15+ (K, "human confirmed. mostly human"), (T, "lol"), (W, "what are we deploying"), (S, "the voice rework, it's finally behind a flag"),
16+ (W, "nice. i'll poke at it later"), (M, "is the flag on by default"), (S, "off. you have to set it in the env"),
17+ (M, "good. last time something was on by default i got 14 pings"), (B, "that was the pizza bot incident wasn't it"),
18+ (M, "do not speak of the pizza bot"), (B, "the pizza bot was a gift to this community"), (T, "the pizza bot ordered 40 pizzas"),
19+ (B, "and 40 pizzas were delivered. system worked"), (K, "to a building none of us work in"), (B, "details"),
20+]),
21+(0, "10:40", 150, [
22+ (W, "ok question. anyone using sqlite WAL mode with more than one writer process"),
23+ (S, "in prod? no. we have one writer"), (W, "i keep reading conflicting things about busy_timeout"),
24+ (S, "set it to 5000 and move on, it's fine for our scale"), (W, "that's the answer i wanted but not the one i expected"),
25+ (M, "the real answer is it's fine until it isn't"), (W, "very helpful moonlord"), (M, "i contain multitudes"),
26+ (K, "wal files growing forever is the thing to watch"), (W, "checkpoint on a timer?"), (K, "the default auto checkpoint is ok unless you have a long reader"),
27+ (W, "i have a long reader. it's a metrics script"), (K, "there it is"), (W, "ok i'll make it read in smaller chunks"),
28+ (T, "or just copy the db and read the copy"), (W, "that's also not a bad idea"), (S, "don't copy a live wal db with cp tho"),
29+ (T, "use .backup, yeah yeah"), (S, "just saying"),
30+]),
31+(0, "12:55", 120, [
32+ (B, "lunch plans"), (T, "leftover curry"), (K, "kebab. obviously"), (K, "don't say it"), (B, "i wasn't going to say it"),
33+ (M, "kebab is having a kebab"), (K, "i knew it"), (W, "i'm having a sad desk salad"), (S, "what's sad about it"),
34+ (W, "no dressing. i forgot"), (S, "oh that's rough"), (B, "i'll trade you half a sandwich for a story"),
35+ (W, "ok so my landlord's cat has started sleeping on my car"), (B, "that's not a story that's a situation"),
36+ (W, "every morning there's a cat on the hood. i have to move it to leave. it looks at me like i'm the problem"),
37+ (T, "you are the problem. it's his hood"), (W, "it is NOT his hood"), (K, "name the cat"), (W, "cabbage"), (M, "cabbage is a great name"),
38+ (B, "deal. half a sandwich incoming"),
39+]),
40+(0, "15:30", 200, [
41+ (T, "anyone know why the sidebar flickers when i switch channels"), (S, "which browser"), (T, "firefox"),
42+ (S, "huh. i'll check. is it every time"), (T, "only the first switch after a reload"), (S, "that smells like the fonts"),
43+ (T, "ha could be. there's a flash of a different font"), (S, "yeah ok font-display. i'll fix that"),
44+ (M, "can we also make the channel list collapsible on mobile"), (S, "it is already?"), (M, "not for me. there's no arrow"),
45+ (S, "which phone"), (M, "an old pixel"), (S, "ok i believe you. screenshot?"), (M, "will send when i'm home"),
46+ (K, "can't wait to see the old pixel"), (M, "it has character"),
47+]),
48+(0, "19:20", 100, [
49+ (B, "evening"), (K, "hey"), (B, "anyone want to play something tonight"), (T, "what"), (B, "something with no loading screens"),
50+ (M, "that's not a genre"), (B, "it should be"), (W, "chess"), (B, "that's a loading screen with extra steps"),
51+ (W, "what"), (K, "i'm in for anything. but not before 9, i'm cooking"), (T, "9 works"), (S, "i'm in if it's co-op"),
52+ (B, "co-op it is. i'll find something"), (M, "please not the one with the rakes"), (B, "the rake game is a classic"),
53+ (M, "i stepped on 31 rakes last time"), (B, "and you had fun"), (M, "...a little"),
54+ (S, "jump in voice at 9?"), (T, "👍"), (K, "👍"), (W, "👍"),
55+]),
56+(0, "23:10", 240, [
57+ (S, "that was fun"), (T, "moonlord stepped on every single rake"), (M, "I REGRET NOTHING"), (K, "the way you screamed"),
58+ (M, "it was a strategic scream"), (B, "same time tomorrow?"), (S, "maybe. i've got the voice stuff to finish"),
59+ (W, "gn all"), (T, "night"), (K, "night"),
60+]),
61+(1, "08:45", 110, [
62+ (K, "ok who changed the favicon"), (S, "that was me. too much?"), (K, "no it's cute. it looks like a headset"),
63+ (S, "it's a headset"), (K, "i know i just wanted you to feel seen"), (S, "thank you"),
64+ (T, "morning btw"), (B, "mornin"), (T, "bananaman you were up late"), (B, "i found a second game and lost track of time"),
65+ (M, "the rake game?"), (B, "a different game. there were fewer rakes and more tractors"),
66+ (M, "that's a better game"), (B, "it's the same game"), (W, "morning folks"),
67+ (W, "cabbage update: cabbage has moved to the porch. my car is free"), (T, "he knows you've been talking about him"),
68+ (W, "he's watching"), (K, "beware the cabbage"),
69+]),
70+(1, "10:05", 160, [
71+ (S, "ok voice rework status: calls connect, mute works, deafen is... complicated"), (W, "complicated how"),
72+ (S, "deafen mutes you AND stops remote audio, but if you undeafen it forgets you were muted"), (W, "yeah that's a bug"),
73+ (S, "right but is it a bug or is it a feature"), (W, "it's a bug sean"), (S, "ok fine"),
74+ (M, "discord has the same behavior as the thing you want. undeafen restores previous mute"), (S, "ok so store previous mute state"),
75+ (M, "yes"), (S, "easy"), (T, "famous last words"), (S, "it's four lines"), (T, "the four lines of doom"),
76+ (K, "can we get a push to talk option too"), (S, "put it in the issue tracker, i'll look after this"),
77+ (K, "there's an issue tracker?"), (S, "there's a markdown file"), (K, "oh"), (K, "i'll add it to the markdown file"),
78+ (S, "thank you"),
79+]),
80+(1, "12:30", 130, [
81+ (B, "reminder that the sandwich economy is booming"), (T, "what's the going rate"), (B, "one story per half sandwich"),
82+ (T, "i don't have a story"), (B, "everyone has a story"), (T, "my story is i make coffee and then drink it"),
83+ (B, "that's a haiku not a story"), (T, "that's a gift"), (K, "ok i have one. i found a 20 in a coat from last winter"),
84+ (B, "and"), (K, "and i bought a kebab with it"), (M, "so the kebab has now paid for the kebab"), (K, "full circle"),
85+ (W, "that's beautiful"), (S, "someone should write that down"), (K, "i have"),
86+]),
87+(1, "14:50", 180, [
88+ (M, "found something nasty in the log rotation"), (S, "what"), (M, "we rotate the logs but never prune. 6 months of logs"),
89+ (S, "oh no"), (M, "it's only 800mb"), (S, "that's not nothing on the small vps"), (M, "no it's not. i'll add a cron"),
90+ (W, "logrotate does that for you"), (M, "we're not using logrotate, it's a custom thing"), (W, "why"), (M, "i don't know, i inherited it"),
91+ (K, "from who"), (M, "from past me"), (K, "past you is a menace"), (M, "past me had a lot of energy and no plan"),
92+ (T, "i feel attacked on behalf of all past selves"), (M, "i'll just switch to logrotate"), (S, "please"), (M, "ok ok ok"),
93+ (W, "keep copytruncate off, it loses lines"), (M, "noted"),
94+]),
95+(1, "17:40", 90, [
96+ (T, "ok so i got a new keyboard"), (B, "pics"), (T, "it's loud"), (B, "pics"), (T, "it's SO loud"), (K, "how loud"),
97+ (T, "my neighbor knocked"), (K, "that loud"), (T, "i'm going to put o-rings in"), (W, "do that. we can hear it on voice"),
98+ (T, "you can?"), (W, "it sounds like rain"), (T, "that's... kind of nice?"), (W, "for 5 minutes"), (M, "it's hail by 6"),
99+ (T, "ok ok o-rings tonight"),
100+]),
101+(1, "21:00", 140, [
102+ (B, "tractor game?"), (K, "yes"), (M, "yes"), (S, "i'll hop on later, finishing something"), (W, "can't tonight, sorry"),
103+ (T, "i'm in, give me ten"), (B, "voice channel"), (M, "who's hosting"), (B, "me"), (M, "the host always crashes it"),
104+ (B, "that was ONE time"), (K, "it was two times"), (B, "ok two times"), (T, "i'm in"),
105+]),
106+(2, "09:10", 100, [
107+ (W, "morning. weird one: anyone else's messages show up out of order"), (S, "when"), (W, "yesterday i sent two close together and they flipped"),
108+ (S, "hm. they're ordered by id server side. maybe it was client side optimistic ordering"), (W, "could be"),
109+ (S, "do you remember the channel"), (W, "general"), (S, "i'll try to repro"), (T, "i've seen it too, once"), (T, "i thought i was dreaming"),
110+ (S, "ok now i'm worried"), (K, "i haven't seen it"), (M, "no"), (S, "ok. if someone catches it screenshot the timestamps"),
111+ (W, "will do"),
112+]),
113+(2, "10:30", 170, [
114+ (K, "random but what's everyone drinking"), (T, "coffee"), (B, "tea"), (M, "coffee, black, bitter, like my soul"),
115+ (W, "mate"), (S, "coffee but it's lukewarm because i got distracted"), (K, "you always do that"), (S, "i know"),
116+ (T, "there's a mug that heats itself"), (S, "that's the most dangerous thing you could tell me"), (T, "i have one"),
117+ (S, "what's it like"), (T, "it works for like an hour and then it's just a mug"), (S, "i'll take it"),
118+ (B, "mate is just tea with commitment"), (W, "mate is just mate"), (B, "the commitment is the gourd"), (W, "fine."),
119+ (W, "yes. fine."),
120+]),
121+(2, "13:15", 120, [
122+ (S, "pushed the deafen fix"), (W, "tested?"), (S, "tested on my machine"), (T, "the four words that ruin lives"),
123+ (S, "ok tested on two machines. mine and my laptop"), (T, "progress"), (M, "i'll pull it and try"), (M, "ok deafen works. undeafen restores mute"),
124+ (S, "yes!"), (M, "but if you leave the channel while deafened and rejoin you're still deafened"), (S, "..."), (S, "that's correct behavior"),
125+ (M, "is it"), (S, "it's an edge case. let me think about it"), (K, "discord resets on rejoin"), (S, "ok. then we reset on rejoin"),
126+ (S, "i'll fix it"), (T, "four more lines"), (S, "SIX more lines"),
127+]),
128+(2, "16:00", 200, [
129+ (K, "who wants to see my dumb project"), (B, "me"), (K, "it's a tiny bot that rates sandwiches"), (B, "WHAT"), (K, "you give it a photo, it gives you a score out of 10"),
130+ (B, "this is the greatest thing i've ever heard"), (K, "it's mostly random"), (B, "mostly?"), (K, "the score is based on how much of the photo is bread"),
131+ (M, "peak engineering"), (W, "does it rate kebabs"), (K, "it rates kebabs highly"), (T, "because it's biased"), (K, "because kebabs are great"),
132+ (B, "run my sandwich through it"), (K, "send a pic"), (B, "[image of a sandwich, trust me]"), (K, "7.4"), (B, "i'm insulted"),
133+ (K, "it's a harsh critic"), (B, "it's WRONG"), (M, "it's a machine bananaman, it can't be wrong"), (B, "everyone is against me today"),
134+]),
135+(2, "18:45", 130, [
136+ (T, "ok so i did the o-rings"), (W, "report"), (T, "it's now quiet. too quiet"), (K, "that's how horror movies start"),
137+ (T, "i miss the rain"), (W, "told you"), (T, "i'm taking one out"), (M, "you've created a mid-volume keyboard"), (T, "the goldilocks keyboard"),
138+ (S, "my neighbors would thank you"), (T, "your neighbors can't hear my keyboard sean"), (S, "they can hear everything"), (S, "i live in paper"),
139+]),
140+(2, "22:05", 160, [
141+ (M, "can't sleep"), (K, "same"), (M, "what are you doing"), (K, "watching a documentary about bridges"),
142+ (M, "good ones?"), (K, "the bridge in it collapsed. it's not a happy documentary"), (M, "why are you watching it to sleep"),
143+ (K, "it's soothing in a morbid way"), (M, "that's the most you thing"), (K, "thank you"), (W, "i'm awake too lol"),
144+ (W, "what's the plan"), (M, "no plan"), (W, "great plan"), (K, "all in favor of sleeping at midnight"), (M, "aye"), (W, "aye"), (K, "aye. motion carried. will not sleep"),
145+]),
146+(3, "08:30", 100, [
147+ (S, "morning. got the repro for the out of order thing"), (W, "oh?"), (S, "if two messages land in the same second the client sorts by timestamp then id"),
148+ (S, "but the sort isn't stable on the first render"), (W, "so that's a real bug"), (S, "yes. fixing"), (T, "so i wasn't dreaming"),
149+ (S, "you weren't dreaming"), (T, "vindicated"), (B, "good morning to everyone except the sort function"), (K, "lol"),
150+ (M, "sort functions are a gateway bug"), (S, "i'll add a test"), (T, "he said the t word"), (S, "i know. i'm growing"),
151+]),
152+(3, "09:50", 140, [
153+ (B, "ok i have a serious announcement"), (K, "uh oh"), (B, "i'm going to start a sourdough"), (M, "no"), (B, "yes"),
154+ (M, "you'll abandon it in a week"), (B, "i won't, i named it"), (T, "what is it named"), (B, "doughnald"), (T, "doughnald."),
155+ (W, "i can't believe it"), (B, "he's already bubbling"), (K, "it's been 20 minutes"), (B, "he's an overachiever"),
156+ (M, "when do i get bread"), (B, "in about a week"), (M, "that's when you abandon him"), (B, "i will not"), (K, "set a reminder to check on doughnald"),
157+ (B, "i did. it's named 'doughnald'"), (S, "i love this channel"),
158+]),
159+(3, "11:30", 180, [
160+ (W, "ok real work. who's reviewing my pr"), (S, "which one"), (W, "the metrics one. it's small"), (S, "'small' it has 60 files"),
161+ (W, "40 of them are generated"), (S, "then why are they in the pr"), (W, "because i forgot to gitignore them"), (S, "ugh"),
162+ (M, "i'll review it"), (W, "thank you moonlord"), (M, "i'll start with the real ones and ignore the rest"), (W, "that's what i'd do"),
163+ (S, "can you also gitignore the generated files"), (W, "yes yes yes. fixing"), (K, "this is called teamwork"),
164+ (W, "pushed"), (M, "looking"), (M, "line 88, nil check missing"), (W, "good catch"), (M, "line 140, you're ignoring an error"),
165+ (W, "on purpose!"), (M, "add a comment saying so"), (W, "fair"), (M, "otherwise lgtm"), (W, "merging"),
166+]),
167+(3, "13:40", 90, [
168+ (T, "lunch crew"), (K, "kebab"), (T, "of course"), (B, "sandwich"), (M, "ramen"), (S, "leftover pasta"), (W, "salad. WITH dressing"),
169+ (S, "growth"), (W, "i'm a changed wombat"), (T, "i'll have the leftover curry's cousin"), (T, "it's also curry"),
170+]),
171+(3, "15:20", 170, [
172+ (S, "fixed the sort, added a test, pushed"), (T, "tell me about the test"), (S, "it sends two messages in the same second and checks the order"),
173+ (T, "and?"), (S, "it passed"), (T, "did it fail before the fix"), (S, "...yes"), (T, "good. that's the point of the test"),
174+ (S, "stop teaching me"), (T, "never"), (M, "can i be added to the learning group"), (T, "it's not a group, it's me nagging"),
175+ (M, "i'll join the nag"), (K, "i'd like to be nagged too"), (T, "i'm overbooked"), (K, "that's ok, i'll nag myself"),
176+ (M, "that's the best kind"),
177+]),
178+(3, "17:15", 120, [
179+ (B, "doughnald update: doughnald is huge"), (K, "pic"), (B, "[image: a jar, mostly foam]"), (K, "that's a jar of foam"),
180+ (B, "that's doughnald"), (M, "is it supposed to be that much foam"), (B, "i don't know! i've never done this!"),
181+ (W, "you might have fed him too much"), (B, "he's a growing boy"), (T, "you need to discard some"), (B, "discard??? my own child???"),
182+ (T, "yes, that's how it works"), (B, "this is a dark hobby"), (K, "welcome to bread"),
183+]),
184+(3, "20:30", 150, [
185+ (S, "ok last night of the 4 day stretch, anyone around for a final voice hang"), (K, "yes"), (M, "yes"), (T, "yes"), (W, "yes"),
186+ (B, "give me five, i'm feeding doughnald"), (S, "of course you are"), (B, "he's eating more than i am"),
187+ (K, "let's do 9"), (S, "9 works"), (M, "bring snacks"), (T, "you can't bring snacks to voice"), (M, "you can bring snacks in spirit"),
188+ (T, "...ok that's nice"), (W, "see you all in a bit"),
189+]),
190+(3, "23:50", 200, [
191+ (S, "that was a good one"), (K, "the rake game finale"), (M, "i have never stepped on that many rakes in my life"),
192+ (B, "you say that every time"), (M, "it's true every time"), (W, "i'm going to bed, work in the morning"),
193+ (T, "same. gn all"), (K, "night"), (S, "night, thanks everyone"), (B, "gn. doughnald says gn too"),
194+ (M, "tell doughnald he's a good boy"), (B, "he heard you"),
195+]),
196+]
197+
198+base = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) - timedelta(days=4)
199+out, n = [], 0
200+for day, hm, gap, lines in scenes:
201+ h, m = map(int, hm.split(":"))
202+ t = base + timedelta(days=day, hours=h, minutes=m)
203+ for user, text in lines:
204+ out.append({"user": user, "text": text, "at": int(t.timestamp())})
205+ # people reply fast, with the occasional pause
206+ t += timedelta(seconds=random.randint(4, gap) if random.random() > .12 else random.randint(gap, gap * 4))
207+ n += 1
208+out.sort(key=lambda x: x["at"])
209+for o in out:
210+ print(json.dumps(o))
deploy/dev/tools/post.py+80−0
@@ -0,0 +1,80 @@
1+#!/usr/bin/env python3
2+"""Post messages to a running irvc dev server as a seed user.
3+
4+Single: post.py -u sean -m "hello" [--at "2026-10-12 09:30"]
5+Batch: post.py --jsonl convo.jsonl (lines: {"user","text","at"?})
6+
7+Messages go through the real API (auth, validation, websocket broadcast).
8+The API stamps messages with the current time, so when --at is given the
9+row's created_at is rewritten in the sqlite db afterwards (--db, default
10+./irvc.db). Post in chronological order: history is ordered by message id.
11+"""
12+import argparse, json, sqlite3, sys, time
13+from datetime import datetime
14+from urllib.request import Request, urlopen
15+from urllib.error import HTTPError
16+
17+def parse_at(s):
18+ if s.isdigit():
19+ return int(s)
20+ return int(datetime.fromisoformat(s).timestamp()) # naive = local time
21+
22+class Client:
23+ def __init__(self, base):
24+ self.base, self.cookies = base.rstrip("/"), {}
25+
26+ def call(self, method, path, body=None, user=None):
27+ data = json.dumps(body).encode() if body is not None else None
28+ req = Request(self.base + path, data=data, method=method,
29+ headers={"Content-Type": "application/json"})
30+ # Session cookies are Secure, which urllib's jar refuses over http.
31+ if user in self.cookies:
32+ req.add_header("Cookie", self.cookies[user])
33+ try:
34+ resp = urlopen(req)
35+ except HTTPError as e:
36+ sys.exit(f"{method} {path}: {e.code} {e.read().decode()}")
37+ if path == "/api/login":
38+ self.cookies[user] = resp.headers["Set-Cookie"].split(";")[0]
39+ return json.load(resp)
40+
41+ def login(self, user, password):
42+ if user not in self.cookies:
43+ self.call("POST", "/api/login", {"username": user, "password": password}, user)
44+
45+def main():
46+ ap = argparse.ArgumentParser()
47+ ap.add_argument("-u", "--user")
48+ ap.add_argument("-m", "--message")
49+ ap.add_argument("--at", help="ISO local time or unix seconds")
50+ ap.add_argument("--jsonl")
51+ ap.add_argument("--channel", default="general", help="text channel name")
52+ ap.add_argument("--password", default="11111111")
53+ ap.add_argument("--url", default="http://localhost:8080")
54+ ap.add_argument("--db", default="irvc.db")
55+ a = ap.parse_args()
56+
57+ if a.jsonl:
58+ items = [json.loads(l) for l in open(a.jsonl) if l.strip()]
59+ elif a.user and a.message:
60+ items = [{"user": a.user, "text": a.message, "at": a.at}]
61+ else:
62+ ap.error("need --user and --message, or --jsonl")
63+
64+ c = Client(a.url)
65+ first = items[0]["user"]
66+ c.login(first, a.password)
67+ chans = c.call("GET", "/api/channels", user=first)
68+ chan = next(x["id"] for x in chans if x["type"] == "text" and x["name"] == a.channel)
69+
70+ db = sqlite3.connect(a.db, timeout=5) if any(i.get("at") for i in items) else None
71+ for i in items:
72+ c.login(i["user"], a.password)
73+ m = c.call("POST", f"/api/channels/{chan}/messages", {"body": i["text"]}, i["user"])
74+ if i.get("at"):
75+ db.execute("UPDATE messages SET created_at = ? WHERE id = ?", (parse_at(str(i["at"])), m["id"]))
76+ db.commit()
77+ time.sleep(0.02)
78+ print(f"posted {len(items)} message(s) to #{a.channel}")
79+
80+main()
fruit/README.md+18−0
@@ -0,0 +1,18 @@
1+# External themes
2+
3+* derived from https://github.com/mbadolato/iTerm2-Color-Schemes/tree/master/yaml
4+* run `npm run schemes` to rebuild
5+
6+The YAML format is an extension of the YAML format
7+used by [Gogh](https://github.com/Gogh-Co/Gogh/),
8+with the optional extra keys:
9+
10+* `badge`
11+* `bold` (defaults to `foreground`)
12+* `cursor_guide` (defaults to `cursor`)
13+* `cursor_text` (defaults to `foreground`)
14+* `link`
15+* `selection_text` (defaults to `background`)
16+* `selection` (defaults to `foreground`)
17+* `tab`
18+* `underline`
web/package.json+1−0
@@ -8,6 +8,7 @@
88 "build": "tsc -b && vite build",
99 "preview": "vite preview",
1010 "lint": "oxlint",
11+ "schemes": "node scripts/schemes.mjs ../fruit src/lib/schemes.json",
1112 "fmt": "oxfmt"
1213 },
1314 "dependencies": {
web/scripts/schemes.mjs+58−0
@@ -0,0 +1,58 @@
1+#!/usr/bin/env node
2+// Converts a directory of terminal color scheme .yml files into the compact
3+// JSON the settings page autocompletes against.
4+//
5+// node scripts/schemes.mjs ../fruit src/lib/schemes.json
6+//
7+// Each file is flat "key: value" yaml; the scheme name is the file name. Output
8+// is a name-sorted array of { n: name, bg, fg, c: [16 ANSI colors] } with colors
9+// as lowercase #rrggbb.
10+import { readdirSync, readFileSync, writeFileSync } from "node:fs";
11+import { join } from "node:path";
12+
13+const [dir, out] = process.argv.slice(2);
14+if (!dir || !out) {
15+ console.error("usage: schemes.mjs <yaml-dir> <out.json>");
16+ process.exit(2);
17+}
18+
19+// hex normalizes "#abc", "'AABBCC'", "aabbcc" and 8-digit alpha forms to #rrggbb.
20+function hex(v) {
21+ const m = /^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(v);
22+ if (!m) return null;
23+ let h = m[1].toLowerCase();
24+ if (h.length === 3) h = [...h].map((c) => c + c).join("");
25+ return "#" + h.slice(0, 6);
26+}
27+
28+// value pulls the scalar off a "key: value # comment" line.
29+function value(raw) {
30+ raw = raw.trim();
31+ const q = /^(["'])(.*?)\1/.exec(raw);
32+ return q ? q[2] : raw.split(/\s+#|\s/)[0];
33+}
34+
35+const schemes = [];
36+for (const file of readdirSync(dir)
37+ .filter((f) => f.endsWith(".yml"))
38+ .sort()) {
39+ const kv = {};
40+ for (const line of readFileSync(join(dir, file), "utf8").split(/\r?\n/)) {
41+ const m = /^([a-z_0-9]+):\s*(.*)$/.exec(line);
42+ if (m) kv[m[1]] = value(m[2]);
43+ }
44+ const c = Array.from({ length: 16 }, (_, i) =>
45+ hex(kv[`color_${String(i + 1).padStart(2, "0")}`] ?? ""),
46+ );
47+ const bg = hex(kv.background ?? "");
48+ const fg = hex(kv.foreground ?? "");
49+ if (!bg || !fg || c.includes(null)) {
50+ console.error(`skipping ${file}: missing or invalid colors`);
51+ continue;
52+ }
53+ schemes.push({ n: file.replace(/\.yml$/, ""), bg, fg, c });
54+}
55+
56+schemes.sort((a, b) => a.n.localeCompare(b.n, "en", { sensitivity: "base" }));
57+writeFileSync(out, JSON.stringify(schemes) + "\n");
58+console.error(`wrote ${schemes.length} schemes to ${out}`);
web/src/components/Markdown.tsx+38−18
@@ -1,4 +1,4 @@
1-import { Component, createContext, useContext, useState, type ReactNode } from "react";
1+import { Component, createContext, useContext, useEffect, useState, type ReactNode } from "react";
22 import ReactMarkdown from "react-markdown";
33 import remarkBreaks from "remark-breaks";
44 import remarkGfm from "remark-gfm";
@@ -7,17 +7,25 @@ import { ChevronDown, ChevronRight } from "lucide-react";
77 const Collapsed = createContext(false);
88
99 // Images render inline; clicking one opens it in a full-window focus dialog.
10-// When the message's header is collapsed, images shrink to an alt-text chip.
10+// When the message's header is collapsed, images are hidden and their names
11+// show as chips beside the header toggle.
1112 function Image({ src, alt }: { src?: string; alt?: string }) {
1213 const [open, setOpen] = useState(false);
1314 const collapsed = useContext(Collapsed);
15+ // Esc closes the viewer. Capture phase + stopPropagation so it doesn't also
16+ // dismiss whatever else listens for Escape (e.g. the message actions pane).
17+ useEffect(() => {
18+ if (!open) return;
19+ const onKey = (e: KeyboardEvent) => {
20+ if (e.key !== "Escape") return;
21+ e.stopPropagation();
22+ setOpen(false);
23+ };
24+ window.addEventListener("keydown", onKey, true);
25+ return () => window.removeEventListener("keydown", onKey, true);
26+ }, [open]);
1427 if (!src) return alt ? <span>{alt}</span> : null;
15- if (collapsed)
16- return (
17- <span className="my-1 inline-block rounded-md border border-line bg-surface px-2 py-0.5 text-xs text-muted">
18- {alt || "image"}
19- </span>
20- );
28+ if (collapsed) return null; // names are shown in the header row instead
2129 return (
2230 <>
2331 <img
@@ -76,19 +84,31 @@ export default function Markdown({
7684 collapsed: boolean;
7785 onToggle: () => void;
7886 }) {
79- const count = (text.match(/!\[[^\]]*\]\([^)]+\)/g) ?? []).length;
87+ const names = [...text.matchAll(/!\[([^\]]*)\]\([^)]+\)/g)].map((m) => m[1] || "image");
88+ const count = names.length;
8089 return (
8190 <Fallback text={text}>
8291 {count > 0 && (
83- <button
84- type="button"
85- onClick={onToggle}
86- title={collapsed ? "show images" : "hide images"}
87- className="flex w-full items-center gap-1 text-xs leading-6 text-faint hover:text-muted"
88- >
89- {collapsed ? <ChevronRight className="size-3" /> : <ChevronDown className="size-3" />}
90- {count} image{count > 1 ? "s" : ""}
91- </button>
92+ <div className="flex flex-wrap items-center gap-x-2 gap-y-0.5">
93+ <button
94+ type="button"
95+ onClick={onToggle}
96+ title={collapsed ? "show images" : "hide images"}
97+ className="flex items-center gap-1 text-xs leading-6 text-faint hover:text-muted"
98+ >
99+ {collapsed ? <ChevronRight className="size-3" /> : <ChevronDown className="size-3" />}
100+ {count} image{count > 1 ? "s" : ""}
101+ </button>
102+ {collapsed &&
103+ names.map((name, i) => (
104+ <span
105+ key={i}
106+ className="rounded-md border border-line bg-surface px-2 py-0.5 text-xs text-muted"
107+ >
108+ {name}
109+ </span>
110+ ))}
111+ </div>
92112 )}
93113 <Collapsed.Provider value={collapsed}>
94114 <ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]} components={components}>
web/src/components/MessageActions.tsx+73−35
@@ -1,11 +1,15 @@
1+import { useLayoutEffect, useRef, useState } from "react";
2+import { createPortal } from "react-dom";
13 import { Pencil, Trash2, X } from "lucide-react";
24 import { Button, IconButton } from "@/ui";
35 import type { Message, Reaction } from "../lib/types";
46 import { reactions } from "./MessageList";
57
6-// MessageActions is the contextual bar for the selected message. It replaces
7-// per-message hover toolbars: tap the ⋯ on any message and its actions appear
8-// here, reachable on touch screens and by keyboard alike.
8+// MessageActions is the contextual popover for the selected message: tap the ⋯
9+// on any message (or the row) and the actions float beside it, reachable on
10+// touch screens and by keyboard alike. It is portalled and positioned
11+// absolutely, so opening it never reflows the message list; its right edge is
12+// anchored to the message's ⋯ button.
913 export default function MessageActions({
1014 message,
1115 own,
@@ -21,38 +25,72 @@ export default function MessageActions({
2125 onDelete: () => void;
2226 onClose: () => void;
2327 }) {
24- return (
25- <div className="shrink-0 px-2 pb-1 md:px-3">
26- <div className="flex items-center gap-1 rounded-lg border border-line bg-raised p-1.5 shadow-lg">
27- {reactions.map(({ key, label, Icon }) => (
28- <IconButton
29- key={key}
30- label={`react ${label}`}
31- size="sm"
32- className="size-9"
33- onClick={() => onReact(key)}
34- >
35- <Icon />
36- </IconButton>
37- ))}
38- <span className="mx-1 h-6 w-px bg-line" />
39- <span className="min-w-0 flex-1 truncate px-1 text-xs text-faint">
40- {message.username}: {message.body}
41- </span>
42- {own && (
43- <>
44- <Button size="sm" variant="ghost" onClick={onEdit}>
45- <Pencil /> edit
46- </Button>
47- <Button size="sm" variant="danger" onClick={onDelete}>
48- <Trash2 /> delete
49- </Button>
50- </>
51- )}
52- <IconButton label="close message actions" size="sm" onClick={onClose}>
53- <X />
28+ const panel = useRef<HTMLDivElement>(null);
29+ const [pos, setPos] = useState<{ top: number; left: number } | null>(null);
30+
31+ // Track the ⋯ button through list scrolling, resizes and relayouts.
32+ useLayoutEffect(() => {
33+ const anchor = document.querySelector<HTMLElement>(`[data-actions-for="${message.id}"]`);
34+ if (!anchor) return;
35+ const place = () => {
36+ const r = anchor.getBoundingClientRect();
37+ const p = panel.current!.getBoundingClientRect();
38+ let top = r.bottom + 4;
39+ if (top + p.height > innerHeight - 8) top = Math.max(8, r.top - p.height - 4);
40+ const left = Math.max(8, Math.min(r.right - p.width, innerWidth - p.width - 8));
41+ setPos((prev) => (prev?.top === top && prev.left === left ? prev : { top, left }));
42+ };
43+ place();
44+ addEventListener("scroll", place, true);
45+ addEventListener("resize", place);
46+ const ro = new ResizeObserver(place);
47+ ro.observe(panel.current!);
48+ return () => {
49+ removeEventListener("scroll", place, true);
50+ removeEventListener("resize", place);
51+ ro.disconnect();
52+ };
53+ }, [message.id, own]);
54+
55+ return createPortal(
56+ <div
57+ ref={panel}
58+ role="toolbar"
59+ aria-label="message actions"
60+ style={{
61+ top: pos?.top ?? 0,
62+ left: pos?.left ?? 0,
63+ visibility: pos ? "visible" : "hidden",
64+ }}
65+ className="fixed z-40 flex w-max max-w-[calc(100vw-1rem)] flex-wrap items-center gap-1 rounded-lg border border-line bg-raised p-1.5 shadow-lg"
66+ >
67+ {reactions.map(({ key, label, Icon }) => (
68+ <IconButton
69+ key={key}
70+ label={`react ${label}`}
71+ size="sm"
72+ className="size-9"
73+ onClick={() => onReact(key)}
74+ >
75+ <Icon />
5476 </IconButton>
55- </div>
56- </div>
77+ ))}
78+ {own && (
79+ <>
80+ <span className="mx-1 h-6 w-px bg-line" />
81+ <Button size="sm" variant="ghost" onClick={onEdit}>
82+ <Pencil /> edit
83+ </Button>
84+ <Button size="sm" variant="danger" onClick={onDelete}>
85+ <Trash2 /> delete
86+ </Button>
87+ </>
88+ )}
89+ <span className="mx-1 h-6 w-px bg-line" />
90+ <IconButton label="close message actions" size="sm" onClick={onClose}>
91+ <X />
92+ </IconButton>
93+ </div>,
94+ document.body,
5795 );
5896 }
web/src/components/MessageList.tsx+49−28
@@ -1,9 +1,11 @@
1-import { useEffect, useLayoutEffect, useRef } from "react";
1+import { Fragment, useEffect, useLayoutEffect, useRef } from "react";
22 import { Heart, Laugh, MoreHorizontal, ThumbsDown, ThumbsUp } from "lucide-react";
33 import { cn } from "cn";
44 import { IconButton, TextArea } from "@/ui";
55 import type { Message, Reaction } from "../lib/types";
6+import { Time, dayKey, formatDay } from "../lib/time";
67 import Markdown from "./Markdown";
8+import { userColor } from "../lib/scheme";
79
810 export const reactions: { key: Reaction; label: string; Icon: typeof ThumbsUp }[] = [
911 { key: "+1", label: "+1", Icon: ThumbsUp },
@@ -22,9 +24,6 @@ export function hasImage(body: string) {
2224 return /!\[[^\]]*\]\([^)]+\)/.test(body);
2325 }
2426
25-const clock = (ts: number) =>
26- new Date(ts * 1000).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
27-
2827 export default function MessageList({
2928 messages,
3029 username,
@@ -93,30 +92,34 @@ export default function MessageList({
9392 {messages.map((m, i) => {
9493 const prev = messages[i - 1];
9594 const action = m.body.startsWith("/me ") ? m.body.slice(4) : null;
95+ const newDay = !prev || dayKey(prev.createdAt) !== dayKey(m.createdAt);
9696 const grouped =
9797 !action &&
98+ !newDay &&
9899 prev !== undefined &&
99100 !prev.body.startsWith("/me ") &&
100101 prev.username === m.username &&
101102 m.createdAt - prev.createdAt < 300;
102103 return (
103- <Row
104- key={m.id}
105- message={m}
106- action={action}
107- grouped={grouped}
108- username={username}
109- mentioned={!action && isMentioned(m.body, username)}
110- active={activeId === m.id}
111- editing={editing?.id === m.id}
112- editBody={editing?.body ?? ""}
113- collapsed={collapsed.has(m.id)}
114- onSelect={() => onSelect(m)}
115- onToggleImages={() => onToggleImages(m.id)}
116- onEditBody={onEditBody}
117- onSaveEdit={onSaveEdit}
118- onCancelEdit={onCancelEdit}
119- />
104+ <Fragment key={m.id}>
105+ {newDay && <DaySeparator ts={m.createdAt} />}
106+ <Row
107+ message={m}
108+ action={action}
109+ grouped={grouped}
110+ username={username}
111+ mentioned={!action && isMentioned(m.body, username)}
112+ active={activeId === m.id}
113+ editing={editing?.id === m.id}
114+ editBody={editing?.body ?? ""}
115+ collapsed={collapsed.has(m.id)}
116+ onSelect={() => onSelect(m)}
117+ onToggleImages={() => onToggleImages(m.id)}
118+ onEditBody={onEditBody}
119+ onSaveEdit={onSaveEdit}
120+ onCancelEdit={onCancelEdit}
121+ />
122+ </Fragment>
120123 );
121124 })}
122125 </div>
@@ -124,6 +127,16 @@ export default function MessageList({
124127 );
125128 }
126129
130+function DaySeparator({ ts }: { ts: number }) {
131+ return (
132+ <div role="separator" className="flex items-center gap-3 px-3 py-2 md:px-4">
133+ <div className="h-px flex-1 bg-line" />
134+ <span className="text-[0.7rem] text-fg">{formatDay(ts)}</span>
135+ <div className="h-px flex-1 bg-line" />
136+ </div>
137+ );
138+}
139+
127140 function Row({
128141 message: m,
129142 action,
@@ -169,6 +182,7 @@ function Row({
169182 <IconButton
170183 label="message actions"
171184 size="sm"
185+ data-actions-for={m.id}
172186 className={cn(
173187 "size-6 text-faint",
174188 active && "bg-raised text-fg",
@@ -186,9 +200,11 @@ function Row({
186200 if (action) {
187201 return (
188202 <div className="flex items-baseline gap-2 px-3 py-1 text-sm italic md:px-4">
189- <span className="not-italic text-accent">* {m.username}</span>
203+ <span className="not-italic text-accent" style={{ color: userColor(m.username, "var(--accent)") }}>
204+ * {m.username}
205+ </span>
190206 <span className="min-w-0 flex-1">{action}</span>
191- <span className="text-[0.7rem] not-italic text-faint">{clock(m.createdAt)}</span>
207+ <Time ts={m.createdAt} className="text-[0.7rem] not-italic text-faint" />
192208 </div>
193209 );
194210 }
@@ -212,14 +228,19 @@ function Row({
212228 <div className="min-w-0 flex-1">
213229 {!grouped && (
214230 <div className="flex items-baseline gap-2">
215- <span className="text-sm font-medium text-accent">{m.username}</span>
216- <time className="text-[0.7rem] text-faint">{clock(m.createdAt)}</time>
231+ <span
232+ className="text-sm font-medium text-accent"
233+ style={{ color: userColor(m.username, "var(--accent)") }}
234+ >
235+ {m.username}
236+ </span>
237+ <Time ts={m.createdAt} className="text-[0.7rem] text-faint" />
217238 {!!m.editedAt && <span className="text-[0.7rem] text-faint">(edited)</span>}
218239 <span className="ml-auto -my-0.5">{menuButton(false)}</span>
219240 </div>
220241 )}
221242 {editing ? (
222- <div className="py-1">
243+ <div className="py-1 pl-5 md:pl-8">
223244 <TextArea
224245 ref={textarea}
225246 rows={1}
@@ -243,13 +264,13 @@ function Row({
243264 </div>
244265 </div>
245266 ) : (
246- <div className="md">
267+ <div className="md pl-5 md:pl-8">
247268 <Markdown text={m.body} collapsed={collapsed} onToggle={onToggleImages} />
248269 </div>
249270 )}
250271 {grouped && <span className="absolute top-0 right-2 md:right-3">{menuButton(true)}</span>}
251272 {chips.length > 0 && (
252- <div className="flex flex-wrap gap-1 pt-1">
273+ <div className="flex flex-wrap gap-1 pt-1 pl-5 md:pl-8">
253274 {chips.map(([key, who]) => {
254275 const Icon = reactions.find((r) => r.key === key)!.Icon;
255276 return (
web/src/components/Sidebar.tsx+55−15
@@ -19,6 +19,7 @@ import { byName } from "../lib/channels";
1919 import type { Channel, UserSummary, VoiceOccupant } from "../lib/types";
2020 import type { Voice } from "../lib/voice";
2121 import VoiceBar from "./VoiceBar";
22+import { userColor } from "../lib/scheme";
2223
2324 interface Props {
2425 channels: Channel[];
@@ -115,6 +116,10 @@ export default function Sidebar({
115116 channel={c}
116117 voice={voice}
117118 occupants={voiceRooms[String(c.id)] ?? []}
119+ deafened={deafened}
120+ onDeafen={onDeafen}
121+ openShare={openShare}
122+ onOpenShare={onOpenShare}
118123 onDelete={() => onDeleteChannel(c)}
119124 />
120125 ))}
@@ -153,7 +158,8 @@ export default function Sidebar({
153158 </nav>
154159
155160 <div className="shrink-0 px-2 pb-2">
156- {voice.channel && (
161+ {/* Voice channel calls render in place in the Voice list; DM calls have no row. */}
162+ {voice.channel?.type === "dm" && (
157163 <VoiceBar
158164 voice={voice}
159165 deafened={deafened}
@@ -233,21 +239,27 @@ function ChannelRow({
233239 actions?: (close: () => void) => ReactNode;
234240 }) {
235241 return (
236- <div className="flex items-center gap-0.5">
242+ // The wrapper carries the active/hover chrome so it surrounds the actions button too.
243+ <div
244+ className={cn(
245+ "flex items-center rounded-md border pr-1 transition-colors",
246+ active ? "border-line bg-raised" : "border-transparent hover:bg-raised",
247+ )}
248+ >
237249 <button
238250 type="button"
239251 onClick={onSelect}
240- className={cn("row flex-1", active && "row-active", !active && !!badge && "row-unread")}
252+ className={cn(
253+ "row flex-1 hover:bg-transparent",
254+ active && "font-medium text-fg",
255+ !active && !!badge && "row-unread",
256+ )}
241257 >
242258 <span className="text-faint">{icon}</span>
243259 <span className="flex-1 truncate">{name}</span>
244260 {!!badge && <span className="badge">{badge > 99 ? "99+" : badge}</span>}
245261 </button>
246- {actions && (
247- <Menu trigger={<MoreButton />}>
248- {actions}
249- </Menu>
250- )}
262+ {actions && <Menu trigger={<MoreButton />}>{actions}</Menu>}
251263 </div>
252264 );
253265 }
@@ -256,27 +268,48 @@ function VoiceRow({
256268 channel,
257269 voice,
258270 occupants,
271+ deafened,
272+ onDeafen,
273+ openShare,
274+ onOpenShare,
259275 onDelete,
260276 }: {
261277 channel: Channel;
262278 voice: Voice;
263279 occupants: VoiceOccupant[];
280+ deafened: boolean;
281+ onDeafen: (value: boolean) => void;
282+ openShare?: string | null;
283+ onOpenShare?: (id: string) => void;
264284 onDelete: () => void;
265285 }) {
266286 const active = voice.channel?.id === channel.id;
287+ // Once joined, the row becomes the call panel: same outline, roster and controls.
288+ if (active)
289+ return (
290+ <VoiceBar
291+ voice={voice}
292+ deafened={deafened}
293+ onDeafen={onDeafen}
294+ openShare={openShare}
295+ onOpenShare={onOpenShare}
296+ occupants={occupants}
297+ className="my-1"
298+ />
299+ );
267300 return (
268301 <div>
269302 <div className="flex items-center gap-0.5">
270303 <button
271304 type="button"
272- onClick={() => (active ? voice.leave() : voice.join(channel))}
273- className={cn("row flex-1", active && "row-active")}
305+ onClick={() => voice.join(channel)}
306+ className="row flex-1"
274307 >
275308 <span className="text-faint">
276309 <Volume2 size={14} />
277310 </span>
278311 <span className="flex-1 truncate">{channel.name}</span>
279- <span className="text-xs text-faint">{active ? "leave" : "join"}</span>
312+ <span className="text-xs text-faint">join</span>
280313 </button>
281314 {!channel.permanent && occupants.length === 0 && (
282315 <Menu trigger={<MoreButton />}>
@@ -292,8 +325,10 @@ function VoiceRow({
292325 <ul className="space-y-0.5 pb-1 pl-7">
293326 {occupants.map((o) => (
294327 <li key={o.name} className="flex items-center gap-2 text-sm text-muted">
295- <Dot on={active && voice.speaking.includes(o.name)} />
296- <span className="min-w-0 flex-1 truncate">{o.name}</span>
328+ <Dot on={false} />
329+ <span className="min-w-0 flex-1 truncate" style={{ color: userColor(o.name) }}>
330+ {o.name}
331+ </span>
297332 <VoiceMarks muted={o.muted} deafened={o.deafened} className="pr-1" />
298333 </li>
299334 ))}
@@ -327,7 +362,12 @@ function UserList({
327362 className={cn("row w-full", !online.has(u.username) && "text-faint")}
328363 >
329364 <Dot on={online.has(u.username)} />
330- <span className="flex-1 truncate">{u.username}</span>
365+ <span
366+ className="flex-1 truncate"
367+ style={online.has(u.username) ? { color: userColor(u.username) } : undefined}
368+ >
369+ {u.username}
370+ </span>
331371 </button>
332372 </li>
333373 ))}
@@ -366,7 +406,7 @@ function NewChannel({
366406
367407 function MoreButton() {
368408 return (
369- <IconButton label="more actions" size="sm">
409+ <IconButton label="more actions" size="sm" className="hover:bg-surface">
370410 <MoreHorizontal />
371411 </IconButton>
372412 );
web/src/components/VoiceBar.tsx+10−2
@@ -9,12 +9,14 @@ import {
99 ScreenShareOff,
1010 Video,
1111 VideoOff,
12+ Volume2,
1213 VolumeX,
1314 } from "lucide-react";
1415 import { cn } from "cn";
1516 import { Dot, IconButton, Menu, MenuItem, VoiceMarks } from "@/ui";
1617 import type { VoiceOccupant } from "../lib/types";
1718 import type { Voice } from "../lib/voice";
19+import { userColor } from "../lib/scheme";
1820
1921 const volumesKey = "irvc.peerVolumes";
2022
@@ -88,7 +90,11 @@ export default function VoiceBar({
8890 return (
8991 <div className={cn("rounded-lg border border-line bg-raised p-2", className)}>
9092 <div className="flex items-center gap-2 px-1">
91- <Dot on={voice.status === "live"} />
93+ {voice.channel.type === "dm" ? (
94+ <Dot on={voice.status === "live"} />
95+ ) : (
96+ <Volume2 size={14} className={voice.status === "live" ? "text-accent" : "text-faint"} />
97+ )}
9298 <span className="min-w-0 flex-1 truncate text-sm font-medium">{voice.channel.name}</span>
9399 <span className="max-w-1/2 shrink-0 truncate text-xs text-faint">{status}</span>
94100 </div>
@@ -194,7 +200,9 @@ function PeerMenu({
194200 trigger={
195201 <button type="button" aria-label={`${name} volume`} className="row w-full py-1 text-sm">
196202 <Dot on={speaking} />
197- <span className="flex-1 truncate">{name}</span>
203+ <span className="flex-1 truncate" style={{ color: userColor(name) }}>
204+ {name}
205+ </span>
198206 </button>
199207 }
200208 >
web/src/index.css+0−3
@@ -207,9 +207,6 @@
207207 .row {
208208 @apply flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-left text-sm text-muted transition-colors hover:bg-raised hover:text-fg;
209209 }
210- .row-active {
211- @apply bg-raised font-medium text-fg;
212- }
213210 .row-unread {
214211 @apply font-medium text-accent;
215212 }
web/src/lib/scheme.ts+139−0
@@ -0,0 +1,139 @@
1+import type { Token } from "./theme";
2+
3+// A terminal color scheme as emitted by scripts/schemes.mjs: background,
4+// foreground and the 16 ANSI colors (black..white, then the bright row).
5+export interface Scheme {
6+ n: string;
7+ bg: string;
8+ fg: string;
9+ c: string[];
10+}
11+
12+type RGB = [number, number, number];
13+
14+const rgb = (hex: string): RGB => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16)) as RGB;
15+const hex = (c: RGB) =>
16+ "#" +
17+ c
18+ .map((n) =>
19+ Math.round(Math.max(0, Math.min(255, n)))
20+ .toString(16)
21+ .padStart(2, "0"),
22+ )
23+ .join("");
24+
25+// mix blends a toward b; t=0 is a, t=1 is b.
26+const mix = (a: string, b: string, t: number) => {
27+ const [x, y] = [rgb(a), rgb(b)];
28+ return hex(x.map((v, i) => v + (y[i] - v) * t) as RGB);
29+};
30+
31+function luminance(h: string) {
32+ const [r, g, b] = rgb(h).map((v) => {
33+ v /= 255;
34+ return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
35+ });
36+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
37+}
38+
39+function contrast(a: string, b: string) {
40+ const [x, y] = [luminance(a), luminance(b)].sort((p, q) => q - p);
41+ return (x + 0.05) / (y + 0.05);
42+}
43+
44+// chroma is how colorful a color is (0 = gray); used to prefer vivid colors.
45+const chroma = (h: string) => {
46+ const c = rgb(h);
47+ return (Math.max(...c) - Math.min(...c)) / 255;
48+};
49+
Cut short: this commit's diff is over 1000 lines.
web/src/lib/schemes.json+1−0
Cut short: this commit's diff is over 1000 lines.
web/src/lib/theme.ts+37−3
Cut short: this commit's diff is over 1000 lines.
web/src/lib/time.tsx+75−0
Cut short: this commit's diff is over 1000 lines.
web/src/views/Chat.tsx+56−3
Cut short: this commit's diff is over 1000 lines.
web/src/views/Settings.tsx+51−3
Cut short: this commit's diff is over 1000 lines.