Files
ai-app/app/build-icon-font.sh
T
iris-ai b7fd18b195 Let the reader put the session list in its own order
Nothing sorts the sessions tab any more. The order is the server's
`sessions` list, which is the reader's arrangement: holding a row puts the
screen in selection mode -- the same gesture and the same bottom bar as the
import tab -- and each card grows a burger handle at its right edge that
drags the row to a new place, with a tick of haptic feedback for each one it
passes.

The two attempts this replaces, sorting by activity and then by when each
agent was turned on, were both looking for an order a session could not move
itself out of; no rule computed from what a session is doing can be one.
`POST /sessions/order` rewrites the config's order, so it is the same on
every device and survives a backend restart, and `SessionConfig::started`
goes with the sort that needed it.

Rearranging is independent of the selection: the handle moves the row it is
on, picked out or not. The click moved off the card and onto its contents so
that a press landing on the handle cannot also select the row it is about to
move. Selection's one action is Delete, which now takes the whole set.

Two traps in `Reorder.kt`, both measured on the emulator and written down in
`this-machine-android`: a crossing is decided from how far the finger has
travelled, because a lazy list animates an item into its new place and its
`offset` reports the old one for several frames; and the viewport is pinned
with `requestScrollToItem` around each move, because a lazy list keeps its
place by the key of the top item and would otherwise follow the row being
dragged.

Verified on the emulator against the sandbox: the order survives an app
restart and a backend read-back, a two-row drag moves exactly two rows, a
drag to the bottom edge scrolls the list and lands the row last, pressing the
handle without moving changes nothing, and deleting two selected sessions
leaves the rest in place.
2026-09-20 01:06:15 -04:00

85 lines
3.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Rebuilds androidApp/src/main/res/font/nerd_icons.ttf.
#
# The app draws a handful of icons -- a cog, a refresh arrow, send, stop --
# as text in a Nerd Fonts glyph rather than as vector assets or as ordinary
# Unicode. Unicode has no character for most of these, and the ones it does
# have are not reliably in an Android system font, so they land as tofu
# boxes on somebody's phone. Shipping the subset removes the hope: the
# glyph is in the APK.
#
# The whole symbols font is 3 MB for the handful below, so what is
# committed is a subset. Add a codepoint to GLYPHS below and to NerdIcons.kt
# (the two lists have to agree -- a codepoint in the Kotlin but not here is
# a glyph that silently doesn't exist), then run this and commit the result.
#
# Needs python3 and network access; fontTools is fetched into a temporary
# venv, so nothing has to be installed on the machine.
#
# Copied from dev-updater's script of the same name rather than shared
# through wg-app-link, for the reason Theme.kt gives about the palette: the
# link is the tunnel, the pinned CA and enrollment, and an icon set is a
# preference rather than part of that contract.
set -euo pipefail
# Codepoint, then the Nerd Fonts glyph name it came from. Material Design
# Icons bar one, so they read as one family -- and the first two are
# deliberately the same two dev-updater uses, since a cog and a refresh
# arrow mean the same thing in both apps. The exception is noted on its
# own line, as dev-updater's script does with its two.
GLYPHS=(
U+F0493 # md-cog
U+F0450 # md-refresh
U+F048A # md-send
U+F04DB # md-stop
U+F03E4 # md-pause
U+F040A # md-play
U+F1163 # md-send_clock
U+F0156 # md-close
U+F004D # md-arrow_left
U+F009A # md-bell
U+F04C5 # md-speedometer
U+F024B # md-folder -- dev-updater's too; a folder means the same in both
U+F0415 # md-plus -- likewise
U+F03EB # md-pencil
U+F0193 # md-content_save
U+F0224 # md-file_outline
U+F201 # fa-line_chart -- Font Awesome's, asked for by name
U+F035C # md-menu -- the burger, as a row's drag handle
)
url=https://github.com/ryanoasis/nerd-fonts/releases/latest/download/NerdFontsSymbolsOnly.zip
out="$(cd "$(dirname "$0")" && pwd)/androidApp/src/main/res/font/nerd_icons.ttf"
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
echo "Fetching $url"
curl -fsSL -o "$work/nf.zip" "$url"
python3 -c 'import sys,zipfile; zipfile.ZipFile(sys.argv[1]).extractall(sys.argv[2])' "$work/nf.zip" "$work"
python3 -m venv "$work/venv"
"$work/venv/bin/pip" -q install fonttools
unicodes="$(IFS=,; echo "${GLYPHS[*]}")"
mkdir -p "$(dirname "$out")"
# The Mono face rather than the proportional one, which this used until
# 2026-08-30. Every glyph in it is one em wide and one em tall, so two
# icons drawn at the same size are the same size -- which is what makes two
# icon buttons beside each other match without either of them being told a
# width. In the proportional face the advances run from 0.46 em (play) to
# 0.92 em (line chart), so the composer's Send button came out visibly wider
# than the Stop button next to it, and any fix at the call site would have
# been one measurement hardcoded per pair.
#
# The trade is the one the old comment named: an icon inline beside text is
# padded out to a cell. That is worth it, and it is also why GLYPH_SIZE in
# NerdIcons.kt came down when this changed -- a glyph that fills its em
# draws bigger at the same point size than one that does not.
"$work/venv/bin/pyftsubset" "$work/SymbolsNerdFontMono-Regular.ttf" \
--unicodes="$unicodes" \
--layout-features= \
--drop-tables+=DSIG \
--output-file="$out"
echo "Wrote $out ($(stat -c %s "$out") bytes) with ${#GLYPHS[@]} glyphs"