Files
cinny/scripts/dev-homeserver.sh
T
jaredandClaude Opus 5 22371f8156 fix(composer): no LaTeX conversion inside a typed markdown fence or backtick span (#184 O3)
In markdown mode each paragraph line is serialised before parseBlockMD
joins them, so $x$ inside a ``` fence became data-mx-maths markup
inside the resulting <pre><code> (rendered as math in a code block).
Track fence state across lines and skip math for fenced lines and for
backtick code spans. Unit tests added; verified in the browser.

Also: scripts/dev-homeserver.sh enables MSC4140 delayed events so
scheduled messages work locally.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
2026-09-18 18:26:15 -04:00

80 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Local throwaway Synapse for driving the real UI (Playwright / a browser)
# against a homeserver you control — open registration, no rate limits,
# SQLite, media served. Everything lives in .dev-homeserver/ (gitignored).
#
# scripts/dev-homeserver.sh start # install (first run) + start on :8008
# scripts/dev-homeserver.sh stop
# scripts/dev-homeserver.sh reset # wipe the database and media
# python3 scripts/dev-seed.py 400 # alice/bob + "Busy Room" with images
#
# Then `npm start` and log in at http://127.0.0.1:5173/login/http%3A%2F%2Flocalhost%3A8008/
# as alice / password123.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
DIR="$ROOT/.dev-homeserver"
VENV="$DIR/venv"
CFG="$DIR/homeserver.yaml"
PIDFILE="$DIR/synapse.pid"
install() {
mkdir -p "$DIR"
if [ ! -x "$VENV/bin/python" ]; then
python3 -m venv --without-pip "$VENV"
curl -sS https://bootstrap.pypa.io/get-pip.py -o "$DIR/get-pip.py"
"$VENV/bin/python" "$DIR/get-pip.py" -q
"$VENV/bin/pip" install -q matrix-synapse
fi
if [ ! -f "$CFG" ]; then
(cd "$DIR" && "$VENV/bin/python" -m synapse.app.homeserver \
--server-name localhost --config-path homeserver.yaml --generate-config --report-stats=no >/dev/null)
# the generated listener only serves `client`; add media + open the door
python3 - "$CFG" <<'PY'
import sys, re
p = sys.argv[1]; s = open(p).read()
s = s.replace(" - client\n", " - client\n - media\n", 1)
s += """
enable_registration: true
enable_registration_without_verification: true
rc_message: { per_second: 1000, burst_count: 10000 }
rc_registration: { per_second: 1000, burst_count: 10000 }
rc_login: { address: { per_second: 1000, burst_count: 10000 }, account: { per_second: 1000, burst_count: 10000 }, failed_attempts: { per_second: 1000, burst_count: 10000 } }
rc_joins: { local: { per_second: 1000, burst_count: 10000 }, remote: { per_second: 1000, burst_count: 10000 } }
rc_presence: { per_user: { per_second: 1000, burst_count: 10000 } }
max_upload_size: 50M
suppress_key_server_warning: true
# scheduled messages (MSC4140 delayed events)
max_event_delay_duration: 24h
experimental_features:
msc4140_enabled: true
"""
open(p, "w").write(s)
PY
fi
}
start() {
install
if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
echo "already running (pid $(cat "$PIDFILE"))"; return
fi
(cd "$DIR" && setsid nohup "$VENV/bin/python" -m synapse.app.homeserver --config-path homeserver.yaml \
> synapse.log 2>&1 < /dev/null & echo $! > "$PIDFILE")
for _ in $(seq 1 40); do
sleep 1
curl -sf http://127.0.0.1:8008/_matrix/client/versions >/dev/null && { echo "synapse up on http://localhost:8008"; return; }
done
echo "synapse did not come up — see $DIR/synapse.log" >&2; exit 1
}
stop() {
if [ -f "$PIDFILE" ]; then kill "$(cat "$PIDFILE")" 2>/dev/null || true; rm -f "$PIDFILE"; echo stopped; fi
}
case "${1:-}" in
start) start ;;
stop) stop ;;
reset) stop; rm -f "$DIR"/homeserver.db* ; rm -rf "$DIR/media_store"; echo "database wiped"; ;;
*) echo "usage: $0 start|stop|reset" >&2; exit 2 ;;
esac