Files
luxe/crates/luxe-remote/app-tests/photos.test.mjs
Evan Whittaker d2129a886f Luxe 0.1.3: your sessions on your phone, joinable sessions, and nested AGENTS.md
- luxe remote puts the sessions on your computer in reach of your own phone or tablet over
  Tailscale: write, steer, answer prompts, send photos, browse files, diffs and GitHub, with a
  paired device and your own Tailscale login.
- luxe join lets another program on the same machine join a running session over the RPC protocol.
- An AGENTS.md in a subfolder reaches the model the first time it works there.
- Long sessions stay fast: no stall before each model call, lighter memory, cheaper drawing.
- A session is open in one Luxe at a time, web_search shares results across its phrasings, and a
  grep glob starting with ! excludes.

The CHANGELOG has the full list.
2026-10-20 02:40:13 -05:00

41 lines
2.2 KiB
JavaScript

// Photos in the composer: their size, the frame that carries them, and the button's word.
import assert from "node:assert/strict";
import { test } from "node:test";
import { sendLabel } from "../app/composer.js";
import { messageFrame } from "../app/pending.js";
import { LONGEST_EDGE, dataOf, fitWithin, forTheWire } from "../app/photos.js";
// The break this catches: a photo sent at full size (12 megapixels, megabytes over the phone's
// network), squashed out of shape, or a small screenshot blown up past its own pixels
test("a photo fits the longest edge, keeps its shape, and is never enlarged", () => {
assert.deepEqual(fitWithin(4032, 3024), { width: LONGEST_EDGE, height: 1176 });
assert.deepEqual(fitWithin(3024, 4032), { width: 1176, height: LONGEST_EDGE });
assert.deepEqual(fitWithin(800, 600), { width: 800, height: 600 });
});
// The break this catches: the preview sent along, doubling every photo's size, or the data URL's
// header sent as part of the base64, which no provider can decode
test("on the wire a photo is its base64, its type and its name", () => {
const preview = "data:image/jpeg;base64,QUJD";
assert.equal(dataOf(preview), "QUJD");
const photo = { data: "QUJD", mime: "image/jpeg", name: "IMG_1.HEIC", preview };
assert.deepEqual(forTheWire([photo]), [{ data: "QUJD", mime: "image/jpeg", name: "IMG_1.HEIC" }]);
});
// The break this catches: photos sent as steering, which carries only words, so they're dropped;
// a message with photos starts a turn, waiting for a running one to end
test("a message with photos is always a new turn", () => {
const images = [{ data: "QUJD", mime: "image/jpeg", name: null }];
const frame = { kind: "submit_user_message", content: { text: "what's this?", images } };
assert.deepEqual(messageFrame("what's this?", true, images), frame);
assert.deepEqual(messageFrame("what's this?", false, images), frame);
});
// The break this catches: the button saying Steer for a message that will wait for the next turn
test("the send button says what will happen", () => {
assert.equal(sendLabel(false, true), "Send");
assert.equal(sendLabel(true, false), "Steer");
assert.equal(sendLabel(true, true), "Queue");
});