luxe 0.1.4: remembered models, wheel-driven lists, and a steadier phone app
- luxe starts on the model you last chose in this project, then the last one anywhere. Signing in opens the model picker instead of choosing for you. - Every list in a modal takes the mouse wheel and a draggable scrollbar. - The phone app shows reasoning in full, stays put while you read back through a long session, and shows a question's answer on its card. - On Windows, luxe update replaces the running luxe, and a signed-in install no longer sees setup again. - The file tree no longer shows "engine busy" in a large project, loop output is easier to follow, and the name is written lowercase. The CHANGELOG has the full list.
This commit is contained in:
@@ -3,7 +3,7 @@ name = "luxe-remote"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
description = "The bridge that lets your own phone or tablet drive Luxe sessions running on this machine"
|
||||
description = "The bridge that lets your own phone or tablet drive luxe sessions running on this machine"
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
# The app's checks run from the repository, with npm; nothing in them builds the crate
|
||||
@@ -18,7 +18,7 @@ exclude = ["app-tests/"]
|
||||
# reqwest and the workspace's rustls.
|
||||
|
||||
[dependencies]
|
||||
luxe-core = { path = "../luxe-core", version = "0.1.3" }
|
||||
luxe-core = { path = "../luxe-core", version = "0.1.4" }
|
||||
thiserror = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
|
||||
43
crates/luxe-remote/app-tests/answers.test.mjs
Normal file
43
crates/luxe-remote/app-tests/answers.test.mjs
Normal file
@@ -0,0 +1,43 @@
|
||||
// A question card's answers, read back out of the call's result. Each result text is a literal
|
||||
// copied from a saved session or from `luxe_core::question`'s own tests, so a reworded ending on
|
||||
// the host fails here rather than leaving the phone's card quietly blank.
|
||||
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { questionOutcome } from "../app/answers.js";
|
||||
|
||||
// The break this catches: a single answer, the usual case, left off the card
|
||||
test("one answer reads back as that answer", () => {
|
||||
assert.deepEqual(questionOutcome("The user answered: Now, with my phone"), { answers: ["Now, with my phone"], note: "" });
|
||||
});
|
||||
|
||||
// The break this catches: several answers run together as one, or a comma inside an answer
|
||||
// splitting it in two
|
||||
test("several answers read back one per line, commas and all", () => {
|
||||
const result = "The user answered:\n- Dark mode\n- also, vim keys";
|
||||
assert.deepEqual(questionOutcome(result), { answers: ["Dark mode", "also, vim keys"], note: "" });
|
||||
});
|
||||
|
||||
// The break this catches: a dismissal drawn as though the reader chose something
|
||||
test("a dismissal says so and credits no answer", () => {
|
||||
const outcome = questionOutcome("The user dismissed the question without answering.");
|
||||
assert.deepEqual(outcome, { answers: [], note: "dismissed without answering" });
|
||||
});
|
||||
|
||||
// The break this catches: an empty submission mistaken for a dismissal, or for text the card can't read
|
||||
test("an empty submission says it had no answer", () => {
|
||||
const outcome = questionOutcome("The user submitted the question with no selection.");
|
||||
assert.deepEqual(outcome, { answers: [], note: "submitted with no answer" });
|
||||
});
|
||||
|
||||
// The break this catches: a default the call fell back to credited to a reader who was never asked
|
||||
test("an answer nobody gave says it came from the default", () => {
|
||||
const outcome = questionOutcome("[Auto-answered, no interactive session] Which runtime?\nAnswer: tokio");
|
||||
assert.deepEqual(outcome, { answers: ["tokio"], note: "nobody to ask · answered from the default" });
|
||||
});
|
||||
|
||||
// The break this catches: the card inventing an answer from text that isn't one of the host's endings
|
||||
test("text that isn't a question's ending reads as nothing", () => {
|
||||
assert.equal(questionOutcome("Error: question needs a prompt"), null);
|
||||
assert.equal(questionOutcome("[Auto-answered, no interactive session] Which runtime?"), null);
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
// A Luxe of the test's own: a session in a fresh git project, driven by the mock model, and a
|
||||
// A luxe of the test's own: a session in a fresh git project, driven by the mock model, and a
|
||||
// bridge serving it, all under one temporary directory, so nothing touches the real config.
|
||||
|
||||
import { spawn, execFileSync } from "node:child_process";
|
||||
@@ -17,11 +17,11 @@ export const LOGIN = "e2e@luxe.test";
|
||||
/** The `luxe` to test: `LUXE_BIN`, or the debug build. */
|
||||
const LUXE = process.env.LUXE_BIN ?? join(REPO, "target/debug/luxe");
|
||||
|
||||
/** Starts a session and a bridge for the mock model on `modelPort`. */
|
||||
export async function startHost(modelPort) {
|
||||
/** Starts a session and a bridge for the mock model on `modelPort`, in a project named `name`. */
|
||||
export async function startHost(modelPort, name = "project") {
|
||||
const root = mkdtempSync(join(tmpdir(), "luxe-e2e-"));
|
||||
const env = isolatedEnv(root);
|
||||
const project = gitProject(root);
|
||||
const project = gitProject(root, name);
|
||||
writeConfig(env.LUXE_CONFIG_DIR, modelPort);
|
||||
const children = [];
|
||||
const host = { root, project, children, stop: () => stop(host) };
|
||||
@@ -39,11 +39,11 @@ function isolatedEnv(root) {
|
||||
return env;
|
||||
}
|
||||
|
||||
function gitProject(root) {
|
||||
const project = join(root, "project");
|
||||
function gitProject(root, name) {
|
||||
const project = join(root, name);
|
||||
mkdirSync(project);
|
||||
const git = (...args) => execFileSync("git", ["-c", "user.name=e2e", "-c", "user.email=e2e@luxe.test", ...args], { cwd: project });
|
||||
git("init", "-q");
|
||||
git("init", "-q", "-b", "main");
|
||||
// a few lines, so a phone can pick a range of them and select part of one
|
||||
writeFileSync(join(project, "README.md"), "# e2e\n\nThe port is 4519.\nThe host is luxe.local.\n");
|
||||
git("add", ".");
|
||||
|
||||
127
crates/luxe-remote/app-tests/e2e/screenshots.mjs
Normal file
127
crates/luxe-remote/app-tests/e2e/screenshots.mjs
Normal file
@@ -0,0 +1,127 @@
|
||||
// The phone app's screenshots for the guide's "Luxe on your phone" page, taken of the real app: a
|
||||
// session in a scratch project, a bridge, and a scripted model that reads a file, edits it (which
|
||||
// asks permission), runs it, and says what it did. Nothing here is drawn by hand.
|
||||
//
|
||||
// Needs a built `luxe` (`LUXE_BIN`, or target/debug/luxe) and Playwright's WebKit or Chromium.
|
||||
// Run from app-tests: node e2e/screenshots.mjs [out-dir], by default docs/guide/phone/
|
||||
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { mkdirSync, writeFileSync } from "node:fs";
|
||||
import { createServer } from "node:http";
|
||||
import { createRequire } from "node:module";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { LOGIN, startHost } from "./host.mjs";
|
||||
|
||||
const playwright = createRequire(import.meta.url)("playwright");
|
||||
const REPO = resolve(dirname(fileURLToPath(import.meta.url)), "../../../..");
|
||||
const OUT = resolve(process.argv[2] ?? join(REPO, "docs/guide/phone"));
|
||||
|
||||
const APP = `import argparse
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Count the words in a file.")
|
||||
parser.add_argument("path")
|
||||
args = parser.parse_args()
|
||||
with open(args.path) as file:
|
||||
print(len(file.read().split()))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
`;
|
||||
|
||||
const OLD = ` parser.add_argument("path")\n args = parser.parse_args()\n with open(args.path) as file:\n print(len(file.read().split()))`;
|
||||
const NEW = ` parser.add_argument("path")\n parser.add_argument("--top", type=int, help="also list the most common words")\n args = parser.parse_args()\n with open(args.path) as file:\n words = file.read().lower().split()\n print(len(words))\n for word, count in Counter(words).most_common(args.top or 0):\n print(f"{count:>5} {word}")`;
|
||||
|
||||
/** Each step of the script, picked by how many tool results the request carries. */
|
||||
const STEPS = [
|
||||
{ say: "I'll read the script first.", tool: "read", args: { path: "wc.py" } },
|
||||
{ say: "It counts but doesn't rank. Adding `--top`:", tool: "edit", args: { path: "wc.py", edits: [{ oldText: OLD, newText: NEW }, { oldText: "import argparse\n", newText: "import argparse\nfrom collections import Counter\n" }] } },
|
||||
{ say: null, tool: "bash", args: { command: "python3 wc.py README.md --top 3", description: "Try the new flag" } },
|
||||
{ done: "Added **`--top N`** to `wc.py`. It still prints the total first, then the `N` most common words with their counts:\n\n```text\n12\n 2 the\n 1 port\n 1 is\n```\n\nWords are lowercased before counting, so `The` and `the` are one word. Without `--top` the output is unchanged." },
|
||||
];
|
||||
|
||||
const chunk = (delta, finish = null) => ({ id: "shot", object: "chat.completion.chunk", created: 0, model: "scripted", choices: [{ index: 0, delta, finish_reason: finish }] });
|
||||
const usage = { id: "shot", object: "chat.completion.chunk", created: 0, model: "scripted", choices: [], usage: { prompt_tokens: 18400, completion_tokens: 240, total_tokens: 18640 } };
|
||||
|
||||
function reply(body) {
|
||||
if (!body.tools?.length) return [chunk({ role: "assistant", content: "Rank words" }), chunk({}, "stop"), usage];
|
||||
const step = STEPS[Math.min(body.messages.filter((m) => m.role === "tool").length, STEPS.length - 1)];
|
||||
if (step.done) return [chunk({ role: "assistant", content: step.done }), chunk({}, "stop"), usage];
|
||||
const call = { index: 0, id: `call_${step.tool}`, type: "function", function: { name: step.tool, arguments: JSON.stringify(step.args) } };
|
||||
return [chunk({ role: "assistant", content: step.say, tool_calls: [call] }), chunk({}, "tool_calls"), usage];
|
||||
}
|
||||
|
||||
async function startModel() {
|
||||
const server = createServer(async (request, response) => {
|
||||
let text = "";
|
||||
for await (const part of request) text += part;
|
||||
response.writeHead(200, { "content-type": "text/event-stream" });
|
||||
for (const piece of reply(JSON.parse(text))) response.write(`data: ${JSON.stringify(piece)}\n\n`);
|
||||
response.end("data: [DONE]\n\n");
|
||||
});
|
||||
await new Promise((done) => server.listen(0, "127.0.0.1", () => done(undefined)));
|
||||
return { port: /** @type {import("node:net").AddressInfo} */ (server.address()).port, close: () => server.close() };
|
||||
}
|
||||
|
||||
// As flow.mjs pairs: paste the link, carry the Secure cookie over plain HTTP by hand
|
||||
async function pair(page, host) {
|
||||
await page.goto(host.url);
|
||||
await page.locator(".pair-link input").fill(`https://desk.example.ts.net/pair#${host.invitation}`);
|
||||
await page.locator(".pair-link button").click();
|
||||
const answered = page.waitForResponse("**/api/pair");
|
||||
await page.locator("#pair button").click();
|
||||
const cookie = (await (await answered).headerValue("set-cookie"))?.split(";")[0] ?? "";
|
||||
await page.waitForURL((url) => url.pathname === "/", { waitUntil: "networkidle" });
|
||||
const at = cookie.indexOf("=");
|
||||
await page.context().addCookies([{ name: cookie.slice(0, at), value: cookie.slice(at + 1), url: host.url }]);
|
||||
await page.goto(host.url);
|
||||
}
|
||||
|
||||
async function launch() {
|
||||
try {
|
||||
return await playwright.webkit.launch();
|
||||
} catch (error) {
|
||||
console.warn(`WebKit wouldn't start, using Chromium: ${String(error).split("\n")[0]}`);
|
||||
return playwright.chromium.launch();
|
||||
}
|
||||
}
|
||||
|
||||
async function shoot(page, name) {
|
||||
await page.waitForTimeout(400);
|
||||
await page.screenshot({ path: join(OUT, `${name}.png`) });
|
||||
console.log(`wrote ${join(OUT, `${name}.png`)}`);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
mkdirSync(OUT, { recursive: true });
|
||||
const model = await startModel();
|
||||
const host = await startHost(model.port, "wordcount");
|
||||
writeFileSync(join(host.project, "wc.py"), APP);
|
||||
const git = (...args) => execFileSync("git", ["-c", "user.name=e2e", "-c", "user.email=e2e@luxe.test", ...args], { cwd: host.project });
|
||||
git("add", "wc.py");
|
||||
git("commit", "-qm", "wc");
|
||||
const browser = await launch();
|
||||
const { defaultBrowserType: _, ...phone } = playwright.devices["iPhone 15 Pro"];
|
||||
const context = await browser.newContext({ ...phone, deviceScaleFactor: 2, extraHTTPHeaders: { "Tailscale-User-Login": LOGIN } });
|
||||
const page = await context.newPage();
|
||||
try {
|
||||
await pair(page, host);
|
||||
await page.locator("a.session").click();
|
||||
await page.locator(".composer textarea").fill("Add a --top flag to wc.py that lists the most common words");
|
||||
await page.locator(".send").click();
|
||||
await page.locator(".prompt .choice.once").waitFor();
|
||||
await shoot(page, "remote-permission");
|
||||
await page.locator(".prompt .choice.once").click();
|
||||
await page.locator(".item.reply", { hasText: "Without --top" }).waitFor({ timeout: 20000 });
|
||||
await shoot(page, "remote-turn");
|
||||
} finally {
|
||||
await browser.close();
|
||||
await host.stop();
|
||||
model.close();
|
||||
}
|
||||
}
|
||||
|
||||
await main();
|
||||
@@ -43,8 +43,8 @@ test("an answer to an earlier question is ignored", () => {
|
||||
assert.equal(models.listing.value.state, "asking");
|
||||
});
|
||||
|
||||
// The break this catches: an older Luxe's refusal ignored, so the sheet says it's listing forever
|
||||
test("a Luxe that doesn't know the question is told apart", () => {
|
||||
// The break this catches: an older luxe's refusal ignored, so the sheet says it's listing forever
|
||||
test("a luxe that doesn't know the question is told apart", () => {
|
||||
const { models } = asked();
|
||||
models.apply({ kind: "action_rejected", content: { kind: "list_models", reason: "unknown kind" } });
|
||||
assert.equal(models.listing.value.state, "unsupported");
|
||||
|
||||
@@ -43,7 +43,7 @@ test("a push it can't read still shows a notification", async () => {
|
||||
const { fire, shown } = worker();
|
||||
await fire("push", push("not json"));
|
||||
await fire("push", { data: null });
|
||||
assert.deepEqual(shown.map((notice) => notice.title), ["Luxe", "Luxe"]);
|
||||
assert.deepEqual(shown.map((notice) => notice.title), ["luxe", "luxe"]);
|
||||
});
|
||||
|
||||
const click = (session) => {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { test } from "node:test";
|
||||
import { WINDOW, elapsed, windowOf } from "../app/items.js";
|
||||
import { WINDOW, elapsed, windowOf, windowStart } from "../app/items.js";
|
||||
import { createTranscript, formatTokens } from "../app/transcript.js";
|
||||
|
||||
/** A session joined through the bridge: the snapshot, then a live turn with two tool calls. */
|
||||
@@ -214,7 +214,42 @@ test("a transcript that fits is drawn whole", () => {
|
||||
assert.deepEqual(windowOf(items, 3), { hidden: 0, drawn: items });
|
||||
});
|
||||
|
||||
// The break this catches: a reader at the bottom left with an ever-growing page, or a first draw
|
||||
// that doesn't start from the latest items
|
||||
test("the window slides to the latest items while the reader follows the bottom", () => {
|
||||
assert.equal(windowStart(null, WINDOW + 5, WINDOW, false), 5);
|
||||
assert.equal(windowStart(5, WINDOW + 6, WINDOW, true), 6);
|
||||
});
|
||||
|
||||
// The break this catches: each new item taking the oldest from the top while the reader is scrolled
|
||||
// up, which in WebKit moves everything they were reading up the screen
|
||||
test("the window holds its start while the reader reads above the bottom", () => {
|
||||
assert.equal(windowStart(5, WINDOW + 6, WINDOW, false), 5);
|
||||
assert.equal(windowStart(5, WINDOW + 40, WINDOW, false), 5);
|
||||
});
|
||||
|
||||
// The break this catches: "Show earlier" doing nothing while the reader is scrolled up to tap it
|
||||
test("asking for earlier items moves the start back while reading above the bottom", () => {
|
||||
assert.equal(windowStart(500, 900, 900 - 200, false), 200);
|
||||
});
|
||||
|
||||
// The break this catches: a reader back at the bottom keeping every item that came while they read
|
||||
test("back at the bottom, the window trims to the latest items again", () => {
|
||||
assert.equal(windowStart(5, WINDOW + 40, WINDOW, true), 40);
|
||||
});
|
||||
|
||||
// The break this catches: a duration written differently from the TUI's card beside it.
|
||||
test("durations read as the TUI writes them", () => {
|
||||
assert.deepEqual([0.4, 19, 1500, 63000].map(elapsed), ["<1ms", "19ms", "1.5s", "1m 3s"]);
|
||||
});
|
||||
|
||||
// The break this catches: reasoning clipped to a few rows with nothing to say there's more, which
|
||||
// reads as the agent's thought cut off mid-sentence where the TUI shows all of it
|
||||
test("reasoning is drawn whole, never clipped", () => {
|
||||
const css = readFileSync(new URL("../app/style.css", import.meta.url), "utf8");
|
||||
const rules = [...css.matchAll(/([^{}]*\.thinking[^{}]*)\{([^}]*)\}/g)];
|
||||
assert.ok(rules.length > 0, "the reasoning rule is where this test looks");
|
||||
for (const [, selector, body] of rules) {
|
||||
assert.doesNotMatch(body, /max-height|overflow\s*:\s*hidden|line-clamp/, `${selector.trim()} clips`);
|
||||
}
|
||||
});
|
||||
|
||||
54
crates/luxe-remote/app/answers.js
Normal file
54
crates/luxe-remote/app/answers.js
Normal file
@@ -0,0 +1,54 @@
|
||||
// @ts-check
|
||||
// A question card's answers, read back out of the call's result the way the TUI's card reads them
|
||||
// (`luxe_core::question::QuestionOutcome`). The prompt above the composer is gone once answered, so
|
||||
// without these rows the card is the question alone and the decision leaves no trace.
|
||||
|
||||
import { html } from "./html.js";
|
||||
|
||||
// The four endings as the host writes them, copied from `QuestionOutcome::result_text`
|
||||
const ANSWERED = "The user answered:";
|
||||
const EMPTY = "The user submitted the question with no selection.";
|
||||
const DISMISSED = "The user dismissed the question without answering.";
|
||||
const UNATTENDED = "[Auto-answered, no interactive session]";
|
||||
|
||||
/**
|
||||
* @typedef {{ answers: string[], note: string }} Outcome
|
||||
*/
|
||||
|
||||
/**
|
||||
* What a question's result says was decided, or null when the text isn't one of the host's: a card
|
||||
* that shows its raw output beats one inventing an answer nobody gave.
|
||||
* @param {string} result @returns {Outcome | null}
|
||||
*/
|
||||
export function questionOutcome(result) {
|
||||
const [first = "", ...rest] = result.split("\n");
|
||||
const head = first.trimEnd();
|
||||
if (head.startsWith(ANSWERED)) return answered(head.slice(ANSWERED.length).trim(), rest);
|
||||
if (head.startsWith(UNATTENDED)) return unattended(rest);
|
||||
if (head === EMPTY) return { answers: [], note: "submitted with no answer" };
|
||||
if (head === DISMISSED) return { answers: [], note: "dismissed without answering" };
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @param {string} inline @param {string[]} lines @returns {Outcome} */
|
||||
function answered(inline, lines) {
|
||||
if (inline) return { answers: [inline], note: "" };
|
||||
const listed = lines.map((line) => line.trim()).filter((line) => line.startsWith("- ")).map((line) => line.slice(2));
|
||||
const answers = listed.filter(Boolean);
|
||||
return { answers, note: answers.length ? "" : "submitted with no answer" };
|
||||
}
|
||||
|
||||
/** Nobody was there to ask, so the card mustn't credit the reader. @param {string[]} lines */
|
||||
function unattended(lines) {
|
||||
const answer = lines.map((line) => line.trim()).find((line) => line.startsWith("Answer:"));
|
||||
if (answer === undefined) return null;
|
||||
return { answers: [answer.slice("Answer:".length).trim()], note: "nobody to ask · answered from the default" };
|
||||
}
|
||||
|
||||
/** The decision under its question, labeled so it doesn't read as the options offered. @param {{ outcome: Outcome }} props */
|
||||
export function Answers({ outcome }) {
|
||||
return html`<div class="answers">
|
||||
${outcome.note ? html`<p class="answer-note">${outcome.note}</p>` : null}
|
||||
${outcome.answers.map((answer) => html`<p class="answer"><span class="answer-label">answer</span>${answer}</p>`)}
|
||||
</div>`;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ function ModelPicker({ listing, current, pick }) {
|
||||
|
||||
/** What the model list is waiting on, when it's not just a list. @param {{ state: string, empty: boolean }} props */
|
||||
function ListingNote({ state, empty }) {
|
||||
if (state === "unsupported") return html`<p class="dim">Update Luxe on your computer to switch models from here.</p>`;
|
||||
if (state === "unsupported") return html`<p class="dim">Update luxe on your computer to switch models from here.</p>`;
|
||||
if (state === "lost") return html`<p class="dim">Not connected.</p>`;
|
||||
if (state === "asking" && empty) return html`<p class="dim">Loading models…</p>`;
|
||||
if (state === "listed" && empty) return html`<p class="dim">No other models configured.</p>`;
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
width: calc(24rem + env(safe-area-inset-left));
|
||||
box-sizing: border-box;
|
||||
overflow-y: auto;
|
||||
padding: env(safe-area-inset-top) 1.5ch calc(env(safe-area-inset-bottom) + 1lh)
|
||||
padding: var(--top-inset) 1.5ch calc(env(safe-area-inset-bottom) + 1lh)
|
||||
calc(1.5ch + env(safe-area-inset-left));
|
||||
border-right: 1px solid var(--luxe-border-muted, #2e2b27);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ subset keeps come from Material Design Icons (Apache-2.0), Font Awesome (OFL-1.1
|
||||
Extra (MIT) and [Codicons](https://github.com/microsoft/vscode-codicons) (© Microsoft Corporation,
|
||||
CC BY 4.0).
|
||||
|
||||
Subset to Latin, Greek, Cyrillic, punctuation, arrows, maths and box drawing, plus every glyph Luxe
|
||||
Subset to Latin, Greek, Cyrillic, punctuation, arrows, maths and box drawing, plus every glyph luxe
|
||||
draws. Regular (400), Bold (700) and Italic.
|
||||
|
||||
## Adwaita Mono Nerd Font Mono
|
||||
@@ -26,4 +26,4 @@ Invis) · Copyright (c) 2025, Jamie Gravendeel · Copyright (c) 2025, Florian M
|
||||
<https://gitlab.gnome.org/GNOME/adwaita-fonts> · SIL Open Font License 1.1 · full text in
|
||||
`OFL-AdwaitaMono.txt`. Patched with Nerd Fonts, as above.
|
||||
|
||||
Subset to only the marks Luxe draws that JetBrains Mono lacks, on the same 0.6em cell.
|
||||
Subset to only the marks luxe draws that JetBrains Mono lacks, on the same 0.6em cell.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 440 154" width="440" height="154" data-cell="10 22" data-drift-depth="0.55" role="img" aria-label="Luxe">
|
||||
<title>Luxe</title>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 440 154" width="440" height="154" data-cell="10 22" data-drift-depth="0.55" role="img" aria-label="luxe">
|
||||
<title>luxe</title>
|
||||
<path fill="var(--luxe-wordmark-1, currentColor)" d="M10 11h10v11h-10z M20 11h10v11h-10z M30 11h10v11h-10z M40 11h10v11h-10z M10 22h10v11h-10z M20 22h10v11h-10z M30 22h20v22h-20z M30 44h20v22h-20z M30 66h20v22h-20z M30 88h20v22h-20z M30 110h20v22h-20z M50 121h10v11h-10z M60 121h10v11h-10z M70 121h10v11h-10z M40 132h10v11h-10z M50 132h10v11h-10z M60 132h10v11h-10z M70 132h10v11h-10z"/>
|
||||
<path fill="var(--luxe-wordmark-2, currentColor)" d="M110 44h20v22h-20z M170 44h20v22h-20z M110 66h20v22h-20z M170 66h20v22h-20z M110 88h20v22h-20z M170 88h20v22h-20z M110 110h20v22h-20z M130 121h10v11h-10z M140 121h10v11h-10z M150 121h10v11h-10z M160 110h30v22h-30z M120 132h10v11h-10z M130 132h10v11h-10z M140 132h10v11h-10z M150 132h10v11h-10z M170 132h10v11h-10z M180 132h10v11h-10z"/>
|
||||
<path fill="var(--luxe-wordmark-3, currentColor)" d="M210 44h10v11h-10z M220 44h20v22h-20z M260 44h20v22h-20z M280 44h10v11h-10z M230 66h40v22h-40z M230 99h10v11h-10z M240 88h20v22h-20z M260 99h10v11h-10z M220 121h10v11h-10z M230 110h10v22h-10z M240 110h10v11h-10z M250 110h10v11h-10z M260 110h10v22h-10z M270 121h10v11h-10z M210 132h10v11h-10z M220 132h10v11h-10z M230 132h10v11h-10z M260 132h10v11h-10z M270 132h10v11h-10z M280 132h10v11h-10z"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
@@ -3,10 +3,10 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<title>Luxe</title>
|
||||
<title>luxe</title>
|
||||
<link rel="manifest" href="/manifest.webmanifest">
|
||||
<link rel="apple-touch-icon" href="/icons/180.png">
|
||||
<meta name="apple-mobile-web-app-title" content="Luxe">
|
||||
<meta name="apple-mobile-web-app-title" content="luxe">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<link rel="stylesheet" href="/theme.css">
|
||||
<link rel="stylesheet" href="/app/style.css">
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// so nothing waits on the round trip to be readable.
|
||||
|
||||
import { useLayoutEffect, useRef, useState } from "preact/hooks";
|
||||
import { Answers, questionOutcome } from "./answers.js";
|
||||
import { html, landedIn } from "./html.js";
|
||||
import { useRendered } from "./render.js";
|
||||
|
||||
@@ -31,13 +32,28 @@ export function windowOf(items, shown) {
|
||||
return { hidden, drawn: hidden ? items.slice(hidden) : items };
|
||||
}
|
||||
|
||||
/** @param {{ items: TranscriptItem[] }} props */
|
||||
export function Transcript({ items }) {
|
||||
/**
|
||||
* Where the drawn items start, of `length`, when at least the latest `shown` are wanted. A reader
|
||||
* following the bottom gets the latest `shown`. One reading above it keeps the start where it was,
|
||||
* so new items grow the list below them rather than taking items from over them: WebKit doesn't
|
||||
* anchor the scroll, and every item dropped from the top moved what they were reading.
|
||||
* @param {number | null} start where the drawn items started last time, if they have
|
||||
* @param {number} length @param {number} shown @param {boolean} following
|
||||
*/
|
||||
export function windowStart(start, length, shown, following) {
|
||||
const latest = Math.max(0, length - shown);
|
||||
return following || start === null ? latest : Math.min(start, latest);
|
||||
}
|
||||
|
||||
/** @param {{ items: TranscriptItem[], following: boolean }} props */
|
||||
export function Transcript({ items, following }) {
|
||||
const [shown, setShown] = useState(WINDOW);
|
||||
const list = useRef(/** @type {HTMLDivElement | null} */ (null));
|
||||
const start = useRef(/** @type {number | null} */ (null));
|
||||
const keepPlace = useKeptPlace(list);
|
||||
const { hidden, drawn } = windowOf(items, shown);
|
||||
const more = () => keepPlace(() => setShown(shown + WINDOW));
|
||||
start.current = windowStart(start.current, items.length, shown, following);
|
||||
const { hidden, drawn } = windowOf(items, items.length - start.current);
|
||||
const more = () => keepPlace(() => setShown(items.length - Math.max(0, hidden - WINDOW)));
|
||||
const count = html`<span class="dim">${hidden.toLocaleString()} more</span>`;
|
||||
return html`<div class="transcript" ref=${list} onClick=${copyCode}>
|
||||
${hidden ? html`<button type="button" class="earlier" onClick=${more}>Show earlier ${count}</button>` : null}
|
||||
@@ -118,15 +134,10 @@ function Reply({ item }) {
|
||||
return html`<${Rendered} className="item reply md" rendered=${rendered} text=${item.text.value} />`;
|
||||
}
|
||||
|
||||
/** @param {{ item: TextItem }} props */
|
||||
/** Reasoning in full, as the TUI shows it by default. @param {{ item: TextItem }} props */
|
||||
function Thinking({ item }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const rendered = useRendered({ kind: "reasoning", text: item.text.value }, !!item.provisional);
|
||||
const toggle = () => setOpen(!open);
|
||||
/** @param {KeyboardEvent} event */
|
||||
const onKey = (event) => (event.key === "Enter" || event.key === " ") && toggle();
|
||||
return html`<div class=${`item thinking ${open ? "open" : ""}`} role="button" tabindex="0"
|
||||
aria-expanded=${open} onClick=${toggle} onKeyDown=${onKey}>
|
||||
return html`<div class="item thinking">
|
||||
<${Rendered} className="md reasoning" rendered=${rendered} text=${item.text.value} />
|
||||
</div>`;
|
||||
}
|
||||
@@ -140,6 +151,8 @@ function ToolCard({ card }) {
|
||||
<span class="tool-label">${call.label}</span>
|
||||
<span class="tool-time">${standing(call)}</span>
|
||||
${body(call)}`;
|
||||
const outcome = call.name === "question" && output ? questionOutcome(output) : null;
|
||||
if (outcome) return html`<div class=${`item tool ${call.state}`}><div class="tool-head">${head}</div><${Answers} outcome=${outcome} /></div>`;
|
||||
if (!output) return html`<div class=${`item tool ${call.state}`}><div class="tool-head">${head}</div></div>`;
|
||||
return html`<details class=${`item tool ${call.state}`}>
|
||||
<summary class="tool-head">${head}</summary>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @ts-check
|
||||
// The models a session can switch to, asked for each time the details sheet opens and answered to
|
||||
// this device alone. An older Luxe doesn't know the question and refuses it, so the sheet says so
|
||||
// this device alone. An older luxe doesn't know the question and refuses it, so the sheet says so
|
||||
// rather than waiting for an answer that won't come.
|
||||
|
||||
import { signal } from "@preact/signals";
|
||||
|
||||
@@ -120,8 +120,8 @@ export function NotificationSwitch() {
|
||||
function Choice({ state }) {
|
||||
switch (state) {
|
||||
case "unsupported": return html`<p class="dim">Notifications aren't supported in this browser.</p>`;
|
||||
case "home-screen": return html`<p class="dim">Add Luxe to your Home Screen to enable notifications.</p>`;
|
||||
case "blocked": return html`<p class="dim">Allow notifications for Luxe in this device's settings.</p>`;
|
||||
case "home-screen": return html`<p class="dim">Add luxe to your Home Screen to enable notifications.</p>`;
|
||||
case "blocked": return html`<p class="dim">Allow notifications for luxe in this device's settings.</p>`;
|
||||
case "on": return html`<p class="dim">Notifications are on for this device.</p>
|
||||
<button type="button" class="quiet" onClick=${() => flip(turnOff)}>Turn off</button>`;
|
||||
default: return html`<p class="dim">Get notified when a session needs an answer or finishes a long turn.</p>
|
||||
|
||||
@@ -28,18 +28,20 @@ import { createWorkspace, diffRequest } from "./workspace.js";
|
||||
const PROTOCOL_VERSION = 2;
|
||||
|
||||
/** @import { Frame, Status } from "./connection.js" */
|
||||
/** @import { Signal } from "@preact/signals" */
|
||||
/** @typedef {ReturnType<typeof createView>} View */
|
||||
|
||||
/** @param {{ sessionId: string }} props */
|
||||
export function SessionView({ sessionId }) {
|
||||
const view = useMemo(createView, [sessionId]);
|
||||
const transcriptRef = useRef(/** @type {HTMLElement | null} */ (null));
|
||||
const following = useMemo(() => signal(true), [sessionId]);
|
||||
useLink(sessionId, view);
|
||||
usePinnedScroll(transcriptRef);
|
||||
usePinnedScroll(transcriptRef, following);
|
||||
return html`
|
||||
<${Header} view=${view} sessionId=${sessionId} />
|
||||
<main ref=${transcriptRef}>
|
||||
<${Transcript} items=${view.transcript.items.value} />
|
||||
<${Transcript} items=${view.transcript.items.value} following=${following.value} />
|
||||
<${Ending} status=${view.status.value} problem=${view.problem.value} />
|
||||
</main>
|
||||
<${Footer} view=${view} />
|
||||
@@ -203,7 +205,7 @@ function applyFrame(view, frame) {
|
||||
if (frame.kind !== "ready") return view.transcript.apply(frame);
|
||||
view.title.value = folderName(frame.content.cwd);
|
||||
if (frame.content.protocol_version !== PROTOCOL_VERSION) {
|
||||
view.problem.value = `Protocol mismatch: Luxe uses ${frame.content.protocol_version}, this app ${PROTOCOL_VERSION}.`;
|
||||
view.problem.value = `Protocol mismatch: luxe uses ${frame.content.protocol_version}, this app ${PROTOCOL_VERSION}.`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,24 +227,27 @@ function Ending({ status, problem }) {
|
||||
/**
|
||||
* Follow new output while the reader is at the bottom; leave them be once they scroll up. Only
|
||||
* scrolling up lets go: items drawn late grow the page under a scroll to the bottom, which would
|
||||
* otherwise read as the reader having left it.
|
||||
* @param {{ current: HTMLElement | null }} ref
|
||||
* otherwise read as the reader having left it. `following` says which, for the transcript's window.
|
||||
* @param {{ current: HTMLElement | null }} ref @param {Signal<boolean>} following
|
||||
*/
|
||||
function usePinnedScroll(ref) {
|
||||
useEffect(() => (ref.current ? followGrowth(ref.current) : undefined), []);
|
||||
function usePinnedScroll(ref, following) {
|
||||
useEffect(() => (ref.current ? followGrowth(ref.current, following) : undefined), [following]);
|
||||
}
|
||||
|
||||
/** Keeps the page at the bottom as `transcript` grows, until stopped. @param {HTMLElement} transcript */
|
||||
function followGrowth(transcript) {
|
||||
let pinned = true;
|
||||
/**
|
||||
* Keeps the page at the bottom as `transcript` grows, until stopped.
|
||||
* @param {HTMLElement} transcript @param {Signal<boolean>} following
|
||||
*/
|
||||
function followGrowth(transcript, following) {
|
||||
following.value = true;
|
||||
let lastY = scrollY;
|
||||
const page = document.documentElement;
|
||||
const onScroll = () => {
|
||||
if (innerHeight + scrollY >= page.scrollHeight - 48) pinned = true;
|
||||
else if (scrollY < lastY) pinned = false;
|
||||
if (innerHeight + scrollY >= page.scrollHeight - 48) following.value = true;
|
||||
else if (scrollY < lastY) following.value = false;
|
||||
lastY = scrollY;
|
||||
};
|
||||
const follow = new ResizeObserver(() => pinned && scrollTo(0, page.scrollHeight));
|
||||
const follow = new ResizeObserver(() => following.value && scrollTo(0, page.scrollHeight));
|
||||
addEventListener("scroll", onScroll, { passive: true });
|
||||
follow.observe(transcript);
|
||||
return () => {
|
||||
|
||||
@@ -88,7 +88,7 @@ function Row({ session }) {
|
||||
return html`<a class="session" href=${`#/session/${encodeURIComponent(session.session_id)}`}>
|
||||
<span class="name">${folderName(session.cwd)}</span>
|
||||
<span class="dim path">${session.cwd}</span>
|
||||
<span class="dim">${session.session_id.slice(0, 8)} · Luxe ${session.luxe_version}</span>
|
||||
<span class="dim">${session.session_id.slice(0, 8)} · luxe ${session.luxe_version}</span>
|
||||
</a>`;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
/* The app is set like the terminal: one monospace face, one line height, widths in `ch`. Colors
|
||||
come from `/theme.css`, the active theme; each fallback is Luxe's own, for a theme whose token
|
||||
come from `/theme.css`, the active theme; each fallback is luxe's own, for a theme whose token
|
||||
is the terminal's default color, which a page can't know. Rendered text is `markdown.css`. */
|
||||
|
||||
@font-face {
|
||||
font-family: "Luxe Mono";
|
||||
font-family: "luxe Mono";
|
||||
src: url("fonts/jetbrains-mono-regular.woff2") format("woff2");
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Luxe Mono";
|
||||
font-family: "luxe Mono";
|
||||
src: url("fonts/jetbrains-mono-bold.woff2") format("woff2");
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Luxe Mono";
|
||||
font-family: "luxe Mono";
|
||||
src: url("fonts/jetbrains-mono-italic.woff2") format("woff2");
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@@ -25,14 +25,14 @@
|
||||
|
||||
/* A separate family, so the browser takes from it only what the first face lacks */
|
||||
@font-face {
|
||||
font-family: "Luxe Mono Marks";
|
||||
font-family: "luxe Mono Marks";
|
||||
src: url("fonts/adwaita-mono-regular.woff2") format("woff2");
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Luxe Mono Marks";
|
||||
font-family: "luxe Mono Marks";
|
||||
src: url("fonts/adwaita-mono-bold.woff2") format("woff2");
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
@@ -44,6 +44,17 @@
|
||||
--corner: 0.5ch;
|
||||
/* the least a finger is given to hit, Apple's 44 points */
|
||||
--tap: 2.4lh;
|
||||
/* where a top edge's content starts: under the status bar */
|
||||
--top-inset: env(safe-area-inset-top);
|
||||
}
|
||||
|
||||
/* From the Home Screen, iOS 26 blurs a strip of the page just under the status bar, and a page has
|
||||
no way to turn that off (only a native app's web view does). So the top bar's words start below
|
||||
it, and only its background sits in the blur. A Safari tab has its own toolbar up there. */
|
||||
@media (display-mode: standalone) {
|
||||
:root {
|
||||
--top-inset: calc(env(safe-area-inset-top) + 0.75lh);
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
@@ -51,7 +62,7 @@ body {
|
||||
padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
|
||||
background: var(--luxe-background, #12100e);
|
||||
color: var(--luxe-text, #e4dfd6);
|
||||
font: 13px / var(--cell) "Luxe Mono", "Luxe Mono Marks", ui-monospace, monospace;
|
||||
font: 13px / var(--cell) "luxe Mono", "luxe Mono Marks", ui-monospace, monospace;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
@@ -64,7 +75,7 @@ button {
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
/* Buttons keep Luxe's square shape: no browser's rounded tap blob or focus ring, which hug a lone
|
||||
/* Buttons keep luxe's square shape: no browser's rounded tap blob or focus ring, which hug a lone
|
||||
icon into a circle. A press or a keyboard's focus marks the button's own box instead */
|
||||
button,
|
||||
a {
|
||||
@@ -125,7 +136,7 @@ main {
|
||||
display: flex;
|
||||
gap: 1ch;
|
||||
align-items: baseline;
|
||||
padding: calc(env(safe-area-inset-top) + 0.5lh) 1ch 0.5lh;
|
||||
padding: calc(var(--top-inset) + 0.5lh) 1ch 0.5lh;
|
||||
background: var(--luxe-background, #12100e);
|
||||
border-bottom: 1px solid var(--luxe-border-muted, #2e2b27);
|
||||
}
|
||||
@@ -370,7 +381,7 @@ h2 {
|
||||
padding-inline: 1ch;
|
||||
}
|
||||
|
||||
/* Your words on a band; a brief Luxe wrote to the agent, as one muted line */
|
||||
/* Your words on a band; a brief luxe wrote to the agent, as one muted line */
|
||||
.user-message .words,
|
||||
.user-message.plain {
|
||||
display: block;
|
||||
@@ -399,18 +410,11 @@ h2 {
|
||||
padding-inline: 1ch;
|
||||
}
|
||||
|
||||
/* Reasoning stays three rows until it's tapped open */
|
||||
/* Reasoning in full, as the TUI shows it: a clipped block reads as text that never arrived */
|
||||
.thinking {
|
||||
padding-inline: 1ch;
|
||||
font-style: italic;
|
||||
color: var(--luxe-thinking-text, #97938c);
|
||||
max-height: 3lh;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.thinking.open {
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
.tool {
|
||||
@@ -452,6 +456,29 @@ h2 {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
/* A question's answers sit under the question, in the voice of the reader's own messages */
|
||||
.answers {
|
||||
padding-inline-start: 3ch;
|
||||
}
|
||||
|
||||
.answers p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.answer {
|
||||
color: var(--luxe-accent, #ddc084);
|
||||
}
|
||||
|
||||
.answer-label {
|
||||
margin-inline-end: 1ch;
|
||||
font-weight: bold;
|
||||
color: var(--luxe-success, #81caa0);
|
||||
}
|
||||
|
||||
.answer-note {
|
||||
color: var(--luxe-muted, #97938c);
|
||||
}
|
||||
|
||||
.tool-output {
|
||||
margin-block-start: 0.5lh;
|
||||
padding-block-start: 0.5lh;
|
||||
|
||||
@@ -44,7 +44,7 @@ export function createTranscript() {
|
||||
}
|
||||
|
||||
// The engine says a turn started with turn_started; the message that opened it, or anything it
|
||||
// streams, stands in for that from a session whose Luxe predates the event
|
||||
// streams, stands in for that from a session whose luxe predates the event
|
||||
const TURN_SIGNS = new Set(["turn_started", "token_delta", "thinking_delta", "tool_call_composing"]);
|
||||
|
||||
/** @param {State} state @param {Frame} frame */
|
||||
|
||||
@@ -42,9 +42,9 @@ export async function loadWordmark(get = fetch) {
|
||||
|
||||
export function Wordmark() {
|
||||
const art = drawing.value;
|
||||
if (!art) return html`<span class="title">Luxe</span>`;
|
||||
if (!art) return html`<span class="title">luxe</span>`;
|
||||
// a custom property set through the DOM, which the page's style-src allows
|
||||
return html`<svg class="wordmark" viewBox=${art.viewBox} role="img" aria-label="Luxe"
|
||||
return html`<svg class="wordmark" viewBox=${art.viewBox} role="img" aria-label="luxe"
|
||||
style=${{ "--drift-depth": art.depth }}>
|
||||
${art.paths.map((d, index) => html`<path d=${d} style=${{ "--phase": driftPhase(index, art.paths.length) }} />`)}
|
||||
</svg>`;
|
||||
|
||||
@@ -33,7 +33,7 @@ function read(data) {
|
||||
/** @param {Notice | null} notice */
|
||||
function show(notice) {
|
||||
if (!notice?.title) {
|
||||
return worker.registration.showNotification("Luxe", { body: "A session wants you", icon: ICON });
|
||||
return worker.registration.showNotification("luxe", { body: "A session wants you", icon: ICON });
|
||||
}
|
||||
const { title, body, session } = notice;
|
||||
return worker.registration.showNotification(title, { body, icon: ICON, data: { session } });
|
||||
|
||||
@@ -33,8 +33,8 @@ const HTML_TAG: &str = "<html lang=\"en\">";
|
||||
|
||||
/// The page's title as written, and the home screen name iOS suggests; a named bridge puts the
|
||||
/// computer in both.
|
||||
const PAGE_TITLE: &str = "<title>Luxe</title>";
|
||||
const HOME_SCREEN_TITLE: &str = "name=\"apple-mobile-web-app-title\" content=\"Luxe\"";
|
||||
const PAGE_TITLE: &str = "<title>luxe</title>";
|
||||
const HOME_SCREEN_TITLE: &str = "name=\"apple-mobile-web-app-title\" content=\"luxe\"";
|
||||
|
||||
/// What the page takes from your own config: a project's can't reach here.
|
||||
#[derive(Default)]
|
||||
@@ -80,7 +80,7 @@ fn themed_page(page: &str, look: &PageLook) -> String {
|
||||
|
||||
/// The page named for the computer `machine`: its title, the name iOS suggests when it's added to
|
||||
/// the home screen, and a `luxe-machine` meta the app reads to say which computer it reaches.
|
||||
/// Unnamed, it stays plain Luxe.
|
||||
/// Unnamed, it stays plain luxe.
|
||||
fn named_page(page: &str, machine: Option<&str>) -> String {
|
||||
let Some(machine) = machine else {
|
||||
return page.to_owned();
|
||||
|
||||
@@ -139,13 +139,13 @@ fn the_page_says_how_headings_are_cut() {
|
||||
/// screen, and the meta the app reads; an unnamed one is the page as written.
|
||||
///
|
||||
/// The break this catches: the page's title or home screen meta reworded so the swap finds
|
||||
/// nothing, leaving two computers' apps both "Luxe", or a name put in unescaped.
|
||||
/// nothing, leaving two computers' apps both "luxe", or a name put in unescaped.
|
||||
#[test]
|
||||
fn the_page_is_named_for_its_computer() {
|
||||
let page = AppFiles::get("index.html").expect("the page");
|
||||
let page = String::from_utf8_lossy(&page.data);
|
||||
let named = named_page(&page, Some("desk"));
|
||||
assert!(named.contains("<title>Luxe \u{00b7} desk</title>"), "{named}");
|
||||
assert!(named.contains("<title>luxe \u{00b7} desk</title>"), "{named}");
|
||||
assert!(named.contains(r#"name="apple-mobile-web-app-title" content="desk""#));
|
||||
assert!(named.contains(r#"<meta name="luxe-machine" content="desk">"#));
|
||||
assert!(named_page(&page, Some("a\"b")).contains(r#"content="a"b""#));
|
||||
|
||||
@@ -121,7 +121,7 @@ impl DeviceBook {
|
||||
Self { file: JsonFile::new(path, FileMode::OwnerOnly) }
|
||||
}
|
||||
|
||||
/// Where it lives unless told otherwise: `remote.json` beside Luxe's other settings.
|
||||
/// Where it lives unless told otherwise: `remote.json` beside luxe's other settings.
|
||||
pub fn default_path() -> PathBuf {
|
||||
luxe_core::user_dirs::luxe_config_dir().join("remote.json")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Folders — where a device can start a session.
|
||||
//!
|
||||
//! The folders Luxe is running in now, the ones herdr's panes are in, and the ones the bridge has
|
||||
//! seen Luxe running in before, remembered in a small file. Never a scan of the home folder: the
|
||||
//! The folders luxe is running in now, the ones herdr's panes are in, and the ones the bridge has
|
||||
//! seen luxe running in before, remembered in a small file. Never a scan of the home folder: the
|
||||
//! list is where you've already worked.
|
||||
|
||||
use std::collections::HashMap;
|
||||
@@ -40,7 +40,7 @@ struct Sighting {
|
||||
last_seen: u64,
|
||||
}
|
||||
|
||||
/// The folders the bridge has seen Luxe running in.
|
||||
/// The folders the bridge has seen luxe running in.
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct FolderBook {
|
||||
file: JsonFile,
|
||||
@@ -52,12 +52,12 @@ impl FolderBook {
|
||||
Self { file: JsonFile::new(path, FileMode::OwnerOnly) }
|
||||
}
|
||||
|
||||
/// Where it lives unless told otherwise: Luxe's state folder, since it's a record of use.
|
||||
/// Where it lives unless told otherwise: luxe's state folder, since it's a record of use.
|
||||
pub(crate) fn default_path() -> PathBuf {
|
||||
luxe_core::user_dirs::luxe_state_dir().join("remote-folders.json")
|
||||
}
|
||||
|
||||
/// Notes that Luxe is running in each of `running` now.
|
||||
/// Notes that luxe is running in each of `running` now.
|
||||
pub(crate) fn saw(&self, running: &[String]) -> Result<(), FileError> {
|
||||
let now = now();
|
||||
let since = now.saturating_sub(RESIGHTING_SECS);
|
||||
|
||||
@@ -55,7 +55,7 @@ fn icon_side(file: &str) -> Option<u32> {
|
||||
}
|
||||
|
||||
/// The manifest for a theme whose background is `background`, for the computer `machine`. The
|
||||
/// icon already says Luxe, so a named one's home screen label is the computer: an app for each of
|
||||
/// icon already says luxe, so a named one's home screen label is the computer: an app for each of
|
||||
/// two computers tells itself apart.
|
||||
fn manifest_json(background: &str, machine: Option<&str>) -> serde_json::Value {
|
||||
let icon = |side: u32| {
|
||||
@@ -65,7 +65,7 @@ fn manifest_json(background: &str, machine: Option<&str>) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"id": "/",
|
||||
"name": app_name(machine),
|
||||
"short_name": machine.unwrap_or("Luxe"),
|
||||
"short_name": machine.unwrap_or("luxe"),
|
||||
"start_url": "/",
|
||||
"scope": "/",
|
||||
"display": "standalone",
|
||||
@@ -75,9 +75,9 @@ fn manifest_json(background: &str, machine: Option<&str>) -> serde_json::Value {
|
||||
})
|
||||
}
|
||||
|
||||
/// The app's name: `Luxe · desk` for the computer `desk`, or plain Luxe unnamed.
|
||||
/// The app's name: `luxe · desk` for the computer `desk`, or plain luxe unnamed.
|
||||
pub(crate) fn app_name(machine: Option<&str>) -> String {
|
||||
machine.map_or_else(|| "Luxe".to_owned(), |machine| format!("Luxe \u{00b7} {machine}"))
|
||||
machine.map_or_else(|| "luxe".to_owned(), |machine| format!("luxe \u{00b7} {machine}"))
|
||||
}
|
||||
|
||||
/// The active theme's tile colors, read off the async threads like the stylesheet.
|
||||
|
||||
@@ -10,8 +10,8 @@ fn theme(pairs: &[(&str, ColorValue)]) -> HashMap<String, ColorValue> {
|
||||
fn the_manifest_is_pinned() {
|
||||
let expected = serde_json::json!({
|
||||
"id": "/",
|
||||
"name": "Luxe",
|
||||
"short_name": "Luxe",
|
||||
"name": "luxe",
|
||||
"short_name": "luxe",
|
||||
"start_url": "/",
|
||||
"scope": "/",
|
||||
"display": "standalone",
|
||||
@@ -26,16 +26,16 @@ fn the_manifest_is_pinned() {
|
||||
}
|
||||
|
||||
/// A named bridge's app is named for its computer, and the home screen label is the computer
|
||||
/// alone, since the icon already says Luxe.
|
||||
/// alone, since the icon already says luxe.
|
||||
///
|
||||
/// The break this catches: two computers' apps both suggested as "Luxe", so the phone shows two
|
||||
/// The break this catches: two computers' apps both suggested as "luxe", so the phone shows two
|
||||
/// identical icons, or the full name crowding the home screen's short label.
|
||||
#[test]
|
||||
fn a_named_bridge_names_its_app_for_the_computer() {
|
||||
let named = manifest_json("#12100e", Some("desk"));
|
||||
assert_eq!(
|
||||
(named["name"].as_str(), named["short_name"].as_str()),
|
||||
(Some("Luxe \u{00b7} desk"), Some("desk"))
|
||||
(Some("luxe \u{00b7} desk"), Some("desk"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Launch — starting a session for a device: in a herdr pane when herdr is running, otherwise as a
|
||||
//! `luxe --rpc` child of the bridge.
|
||||
//!
|
||||
//! Either way the new Luxe shares its session like any other, so a device joins it through the
|
||||
//! Either way the new luxe shares its session like any other, so a device joins it through the
|
||||
//! same route as one started at the desk. The bridge learns which session is the new one by
|
||||
//! watching for its record in the runtime folder.
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::folders::{self, Folder, FolderBook};
|
||||
|
||||
pub(crate) use herdr::Herdr;
|
||||
|
||||
/// How long a new Luxe gets to share its session. It takes about a second.
|
||||
/// How long a new luxe gets to share its session. It takes about a second.
|
||||
const APPEAR_TIMEOUT: Duration = Duration::from_secs(20);
|
||||
/// How often the runtime folder is reread while waiting.
|
||||
const APPEAR_POLL: Duration = Duration::from_millis(250);
|
||||
@@ -47,7 +47,7 @@ pub(crate) enum LaunchError {
|
||||
/// The child couldn't be started
|
||||
#[error("couldn't start luxe: {0}")]
|
||||
Spawn(#[source] std::io::Error),
|
||||
/// Luxe started but no session showed up in time
|
||||
/// luxe started but no session showed up in time
|
||||
#[error("luxe started in {0} but didn't share a session within 20 seconds")]
|
||||
NeverAppeared(String),
|
||||
}
|
||||
@@ -87,16 +87,16 @@ impl Launcher {
|
||||
(listed.await.unwrap_or_default(), in_herdr)
|
||||
}
|
||||
|
||||
/// Notes the folders Luxe is running in, for the list a device starts sessions from.
|
||||
/// Notes the folders luxe is running in, for the list a device starts sessions from.
|
||||
pub(crate) async fn saw(&self, running: Vec<String>) {
|
||||
let book = self.folders.clone();
|
||||
let noted = tokio::task::spawn_blocking(move || book.saw(&running)).await;
|
||||
if let Ok(Err(error)) = noted {
|
||||
tracing::warn!(%error, "could not note the folders Luxe is running in");
|
||||
tracing::warn!(%error, "could not note the folders luxe is running in");
|
||||
}
|
||||
}
|
||||
|
||||
/// Starts Luxe in `folder` and waits for the session it shares.
|
||||
/// Starts luxe in `folder` and waits for the session it shares.
|
||||
pub(crate) async fn start(
|
||||
&self,
|
||||
folder: &Path,
|
||||
@@ -210,7 +210,7 @@ async fn appeared(
|
||||
|
||||
/// The session in `running` that wasn't there `before` and works on `folder`.
|
||||
///
|
||||
/// "Works on" rather than "is in": a Luxe started in a subfolder of a repository shares the
|
||||
/// "Works on" rather than "is in": a luxe started in a subfolder of a repository shares the
|
||||
/// repository's root as its folder.
|
||||
fn newcomer(running: &[LiveSession], before: &HashSet<u32>, folder: &Path) -> Option<LiveSession> {
|
||||
let folder = folder.canonicalize().ok()?;
|
||||
|
||||
@@ -24,7 +24,7 @@ fn a_tilde_is_the_home_folder() {
|
||||
|
||||
/// A relative path is refused rather than resolved against wherever the bridge happens to run.
|
||||
///
|
||||
/// The break this catches: dropping the full-path check, so `app` starts Luxe in the service's
|
||||
/// The break this catches: dropping the full-path check, so `app` starts luxe in the service's
|
||||
/// working folder, which nobody chose.
|
||||
#[test]
|
||||
fn a_relative_path_is_refused() {
|
||||
@@ -52,7 +52,7 @@ fn only_a_folder_that_exists_is_accepted() {
|
||||
///
|
||||
/// The break this catches, one per session in the list: answering with a session that was already
|
||||
/// running there (1), or one that started elsewhere at the same moment (2). The last one is found
|
||||
/// because a Luxe started in a repository's subfolder shares the repository's root.
|
||||
/// because a luxe started in a repository's subfolder shares the repository's root.
|
||||
#[test]
|
||||
fn the_new_session_is_the_one_that_appeared_where_it_was_asked_for() {
|
||||
let root = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Luxe remote — the bridge between your own devices and the sessions running on this machine.
|
||||
//! luxe remote — the bridge between your own devices and the sessions running on this machine.
|
||||
//!
|
||||
//! Each running Luxe shares its session on a local endpoint only this user can open
|
||||
//! Each running luxe shares its session on a local endpoint only this user can open
|
||||
//! (`luxe_core::local_endpoint`). The bridge is the one thing that puts those sessions on a
|
||||
//! network, and only on the loopback interface: Tailscale Serve carries it to your tailnet and does
|
||||
//! the HTTPS. A phone lists the sessions over HTTP and joins one over a WebSocket, which the bridge
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Pair with Luxe</title>
|
||||
<title>Pair with luxe</title>
|
||||
<style>
|
||||
body { background: #161616; color: #d8d8d8; font: 15px/1.5 ui-monospace, monospace; margin: 2rem; }
|
||||
h1 { font-size: 1rem; color: #e0b46c; }
|
||||
@@ -12,7 +12,7 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Pair this device with Luxe</h1>
|
||||
<h1>Pair this device with luxe</h1>
|
||||
<form id="pair">
|
||||
<label>Device name <input id="name" autocomplete="off"></label>
|
||||
<button>Pair</button>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! Web Push, as iOS has offered it to home-screen web apps since 16.4: a device that opted in
|
||||
//! gives the bridge a subscription, and the bridge posts each notification, sealed so only that
|
||||
//! device can read it, straight to the push service the subscription names (Apple's, for an
|
||||
//! iPhone). There is no Luxe server in between, and the push service sees when, not what.
|
||||
//! iPhone). There is no luxe server in between, and the push service sees when, not what.
|
||||
//!
|
||||
//! [`watch`] hears what the sessions are waiting for, and [`notify`] takes each notice to every
|
||||
//! subscribed device that doesn't have that session open in front of it.
|
||||
|
||||
@@ -77,7 +77,10 @@ impl Reading {
|
||||
fn prompt(&self, event: &Event) -> Option<Heard> {
|
||||
let (id, body) = match event {
|
||||
Event::PermissionRequested { id, tool, .. } => (id.as_str(), format!("Approve {tool}")),
|
||||
Event::QuestionAsked { id, .. } => (id.as_str(), "Luxe has a question".to_string()),
|
||||
// The agent asks, not the app: luxe is the title the notification already carries
|
||||
Event::QuestionAsked { id, .. } => {
|
||||
(id.as_str(), "The agent has a question for you".to_string())
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
Some(Heard::Prompt(id.to_string(), self.notice(body, true)))
|
||||
@@ -102,7 +105,7 @@ impl Reading {
|
||||
|
||||
/// Whether `event` shows a turn running. The engine says so with `TurnStarted`, which comes
|
||||
/// first; the message that opened the turn, or anything it streams, stands in for it from a
|
||||
/// session whose Luxe predates that event.
|
||||
/// session whose luxe predates that event.
|
||||
fn is_turn_sign(event: &Event) -> bool {
|
||||
match event {
|
||||
Event::TurnStarted
|
||||
|
||||
@@ -38,7 +38,7 @@ fn a_prompt_says_what_waits_and_never_the_detail() {
|
||||
let asked = reading().read(&event(PERMISSION), now);
|
||||
assert_eq!(asked, Some(Heard::Prompt("perm:1".into(), notice("Approve bash", true))));
|
||||
let asked = reading().read(&event(QUESTION), now);
|
||||
let expected = Heard::Prompt("ask:1".into(), notice("Luxe has a question", true));
|
||||
let expected = Heard::Prompt("ask:1".into(), notice("The agent has a question for you", true));
|
||||
assert_eq!(asked, Some(expected));
|
||||
assert_eq!(reading().read(&event(CLOSED), now), Some(Heard::Closed("perm:1".into())));
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ async fn a_prompt_answered_in_time_is_never_sent() {
|
||||
let (mut heard, mut joined, _watcher) = watched(&mut session).await;
|
||||
say(&mut joined, &[PERMISSION, QUESTION, CLOSED]).await;
|
||||
let notice = heard.recv().await.expect("a notice");
|
||||
assert_eq!(notice.body, "Luxe has a question");
|
||||
assert_eq!(notice.body, "The agent has a question for you");
|
||||
tokio::time::sleep(PROMPT_GRACE * 2).await;
|
||||
assert!(heard.try_recv().is_err(), "the answered prompt was sent");
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ async fn line_to_device(
|
||||
}
|
||||
|
||||
/// Whether `line` is the session refusing the bridge's `introduce`. Only a session started before
|
||||
/// its Luxe knew the action does, and it carries on without the device's name; the refusal is of a
|
||||
/// its luxe knew the action does, and it carries on without the device's name; the refusal is of a
|
||||
/// frame the device never sent, so showing it there reads as a fault. Decoded only when it could
|
||||
/// be one, so every other line still passes untouched.
|
||||
fn refuses_introduction(line: &str) -> bool {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! Markdown, highlighted code, tool glyphs and the status line's wording are the TUI's, and the
|
||||
//! bridge doesn't depend on the TUI, so `luxe-cli` hands one in as a [`Renderer`]. What a user
|
||||
//! message shows (the reader's own words, and a brief Luxe wrote to the agent as one line saying
|
||||
//! message shows (the reader's own words, and a brief luxe wrote to the agent as one line saying
|
||||
//! so) is core's call (`luxe_core::briefs`), so that is made here. The bridge keeps no session
|
||||
//! state, so the app asks: once for a finished message, and a few times a second for one still
|
||||
//! growing or a status that changed.
|
||||
@@ -283,7 +283,7 @@ pub(crate) struct Rendered {
|
||||
/// `piece` as the app's HTML.
|
||||
pub(crate) fn render(renderer: &dyn Renderer, piece: &Piece) -> String {
|
||||
match piece {
|
||||
// what the agent wrote for Luxe to read (a remediation report, a draft) isn't the reader's
|
||||
// what the agent wrote for luxe to read (a remediation report, a draft) isn't the reader's
|
||||
Piece::Answer { text } => renderer.markdown(&briefs::for_the_reader(text), Voice::Answer),
|
||||
Piece::Reasoning { text } => renderer.markdown(text, Voice::Reasoning),
|
||||
Piece::User { content } => user_message(content) + &images_attached(renderer, content),
|
||||
|
||||
@@ -135,7 +135,7 @@ fn words_alone_say_nothing_is_attached() {
|
||||
assert_eq!(html, "<p class=\"words\">hi</p>");
|
||||
}
|
||||
|
||||
/// The break this catches: a brief Luxe wrote shown whole, as a page of instructions in the
|
||||
/// The break this catches: a brief luxe wrote shown whole, as a page of instructions in the
|
||||
/// reader's colors.
|
||||
#[test]
|
||||
fn a_brief_shows_as_one_line() {
|
||||
|
||||
@@ -46,7 +46,7 @@ pub enum ServiceError {
|
||||
detail: String,
|
||||
},
|
||||
/// Nowhere to put a service: no home folder, or a platform without a per-user service manager
|
||||
#[error("this system has no per-user service manager Luxe knows how to use")]
|
||||
#[error("this system has no per-user service manager luxe knows how to use")]
|
||||
Unsupported,
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
use super::Launch;
|
||||
|
||||
const TEMPLATE: &str = "[Unit]
|
||||
Description=Luxe remote: your sessions on your own devices
|
||||
Description=luxe remote: your sessions on your own devices
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
|
||||
@@ -22,7 +22,7 @@ type DeviceSocket =
|
||||
const SESSION: &str = "5898d57b-0000-4000-8000-000000000001";
|
||||
const OWNER: &str = "alex@github";
|
||||
|
||||
/// A session as a running Luxe shares it: an endpoint, and its record beside it.
|
||||
/// A session as a running luxe shares it: an endpoint, and its record beside it.
|
||||
struct FakeSession {
|
||||
listener: EndpointListener,
|
||||
_record: Publication,
|
||||
@@ -170,7 +170,7 @@ async fn the_bridge_listens_on_loopback_only() {
|
||||
|
||||
/// The list names running sessions and keeps their local address on this machine.
|
||||
///
|
||||
/// The break this catches: listing a record whose Luxe has died, which the app shows as a session
|
||||
/// The break this catches: listing a record whose luxe has died, which the app shows as a session
|
||||
/// that fails to open; or sending the endpoint's path, which means nothing off this machine.
|
||||
#[tokio::test]
|
||||
async fn the_list_shows_running_sessions_without_their_address() {
|
||||
@@ -286,7 +286,7 @@ async fn starting_in_a_folder_that_isnt_there_is_refused() {
|
||||
assert!(refused.text().await.unwrap().contains("isn't a folder"));
|
||||
}
|
||||
|
||||
/// The folders a device can start in include the ones Luxe is running in, counted.
|
||||
/// The folders a device can start in include the ones luxe is running in, counted.
|
||||
///
|
||||
/// The break this catches: listing only remembered folders, so a project open at the desk right
|
||||
/// now is missing from the phone's list until it's been seen once before.
|
||||
|
||||
@@ -30,7 +30,7 @@ impl Renderer for Sketch {
|
||||
/// paired with two computers keeps two apps it can tell apart.
|
||||
///
|
||||
/// The break this catches: the name set on the bridge but never reaching the routes that read it,
|
||||
/// so both computers' apps are added as "Luxe".
|
||||
/// so both computers' apps are added as "luxe".
|
||||
#[tokio::test]
|
||||
async fn a_named_bridge_serves_an_app_named_for_its_computer() {
|
||||
let bridge = harness_with(|bridge| bridge.named("desk")).await;
|
||||
|
||||
Reference in New Issue
Block a user