Files
luxe/crates/luxe-remote/app/comments.js
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

66 lines
3.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// @ts-check
// Comments on the open review from the phone: where a new one goes, and the `edit_review` edit each
// action sends. The review desk answers every edit with the whole session, so nothing here keeps
// comments of its own.
/** @import { LinePick } from "./lines.js" */
/**
* Where a comment on `pick` goes: a line for one picked line, its hunk for a run inside one hunk,
* and the chapter for anything wider or for no pick at all. A line is the new side's, the only
* side a pick can name.
* @param {any} review @param {string} chapterId @param {LinePick | null} pick
*/
export function anchorFor(review, chapterId, pick) {
const chapter = { kind: "chapter", chapter_id: chapterId };
const file = pick && review.files.find((/** @type {any} */ it) => it.new_path === pick.path);
const holds = (/** @type {any} */ hunk, /** @type {number} */ line) => hunk.lines.some((/** @type {any} */ it) => it.new_line === line);
const hunk = pick && file?.hunks.find((/** @type {any} */ it) => holds(it, pick.first));
if (!pick || !hunk) return chapter;
if (pick.first === pick.last) return { kind: "line", file_id: file.id, hunk_id: hunk.id, side: "new", line: pick.first };
return holds(hunk, pick.last) ? { kind: "hunk", file_id: file.id, hunk_id: hunk.id } : chapter;
}
/** The composer's heading for a comment at `anchor`. @param {any} anchor @param {LinePick | null} pick */
export function anchorWords(anchor, pick) {
if (anchor.kind === "line") return `Comment on line ${anchor.line}`;
if (anchor.kind === "hunk" && pick) return `Comment on lines ${pick.first}–${pick.last}`;
return "Comment on this chapter";
}
/**
* A new comment, unsent unless `send`. A question asks for an answer; anything else is an issue,
* the review desk's default for a comment.
* @param {any} anchor @param {string} body @param {boolean} question @param {boolean} send
*/
export function commentEdit(anchor, body, question, send) {
return { edit: "comment", anchor, body, severity: question ? "question" : "issue", send };
}
/**
* The edit a card's button asks for. A reply goes to the agent at once, as a thread reply does in
* the TUI.
* @param {string} act @param {string} findingId @param {string} [body]
*/
export function actEdit(act, findingId, body = "") {
switch (act) {
case "send": return { edit: "send", finding_ids: [findingId] };
case "delete": return { edit: "delete_comment", finding_id: findingId };
case "resolve": return { edit: "resolve", finding_id: findingId };
case "reopen": return { edit: "reopen", finding_id: findingId };
case "reply": return { edit: "reply", finding_id: findingId, body, send: true };
default: return null;
}
}
/** The comments not sent yet, which Send all sends. A posted one is GitHub's. @param {any} session @returns {string[]} */
export function unsent(session) {
const drafts = (session?.findings ?? []).filter((/** @type {any} */ it) => it.state === "draft" && !it.posted);
return drafts.map((/** @type {any} */ it) => it.id);
}
/** A card's label, for the reply composer's heading. @param {any} session @param {string} findingId */
export function labelOf(session, findingId) {
return session?.findings?.find((/** @type {any} */ it) => it.id === findingId)?.label ?? "";
}