Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/features/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,25 @@ key. Under a proposal's text the tab shows the [advice](memory/writing.md#propos
the review shows the same as **Advice**, below the graded runs. The advice decides nothing:
both decisions stay in the review. A server that sends no advice shows none.

The Proposals tab's toolbar counts the list, and says so when the list is cut ("the newest
100 of 140 proposals"). For an administrator of the namespace each row has a checkbox, except
a sensitive row and a row whose key another listed proposal holds, which say why and are
decided from their own review. While rows are selected the toolbar holds **Reject…** and
**Accept…**, and each opens a plan before anything is sent:

- **Reject…** lists every selected row's key, proposer and preview, takes one optional reason
kept on each rejected fact, and rejects the rows as listed. A rejection cannot be undone: a
rejected fact has to be proposed again.
- **Accept…** takes at most 20 rows. Its plan reads each text whole and shows it with format
and bidirectional control characters drawn as code points (`U+202E`), marks a proposal that
lands in Conflicts when accepted, and leaves out, by name, a text it could not read. It
accepts each text under the hash of the read the plan shows.

The plan then shows how many proposals were decided ("Rejected 37 of 40") and one line for
each one left pending, with the reason: its text changed, someone decided it first, the
reviewer proposed it, or an earlier deletion refuses its text. Decided rows leave the
selection and the rows left pending stay selected.

The **Curator** tab (`?tab=curator`) shows a namespace admin the
[curator's report](../architecture/curator.md#the-dashboard-tab), one card per section:
**Proposals** (how many wait, how long the oldest has waited, how many were filed and
Expand Down
22 changes: 16 additions & 6 deletions docs/features/memory/writing.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,16 @@ proposed again.
A call decides one pending row of a key, and the tab offers no decision for a key
that more than one listed proposal holds. Accepting a proposal that recorded a
contradiction while on trial stores it `conflicted`, and it waits on the **Conflicts** tab.
An administrator can also tick rows and decide them in one call. **Reject…** takes any
number of the listed rows: its plan shows each row's key, proposer and preview, takes one
optional reason for all of them, and sends the hashes the list served. **Accept…** takes
at most 20: its plan reads each text whole, shows it with format and bidirectional
control characters drawn as code points, says which proposals land in Conflicts, leaves
out a text it could not read, and sends the hash of each read. A `high` row and a key
that more than one listed proposal holds have no checkbox and are decided from their own
review. The result counts the proposals decided and gives one line for each one left
pending, worded from its `code`, or with its `reason` sentence when the dashboard does
not know the code or the server sends none.
Learnings have a review of their own:
[learnings review queue](./procedures-and-learnings.md#learnings-review-queue).

Expand All @@ -423,12 +433,12 @@ Learnings have a review of their own:
A decision is three calls: list the proposals, read each chosen text whole, decide with
the hashes of those reads. Every surface reaches the same three operations.

| Step | HTTP | CLI | Python | TypeScript | MCP |
| -------------------------- | --------------------------------- | ------------------------------------ | --------------------------------------- | ------------------------------ | ----------------------------- |
| Select the proposals | `POST /v1/memory.proposals` | `loom call memory.proposals` | `agent.client.memory.proposals()` | `loom.memory.proposals()` | `loom_memory_proposals` |
| Plan: read each text whole | `POST /v1/memory.get_by_id` | `loom call memory.get_by_id` | `agent.memory.get_by_id()` | `loom.memory.getById()` | `loom_memory_get_by_id` |
| Apply the decision | `POST /v1/memory.proposal_decide` | `loom call memory.proposal_decide` | `agent.client.memory.proposal_decide()` | `loom.memory.proposalDecide()` | `loom_memory_proposal_decide` |
| Read each key's outcome | `results[].code` | `results[].code` in the printed JSON | `out["results"]` | `out.results` | `results` in the tool result |
| Step | HTTP | CLI | Python | TypeScript | MCP | Dashboard |
| -------------------------- | --------------------------------- | ------------------------------------ | --------------------------------------- | ------------------------------ | ----------------------------- | ------------------------------------------------ |
| Select the proposals | `POST /v1/memory.proposals` | `loom call memory.proposals` | `agent.client.memory.proposals()` | `loom.memory.proposals()` | `loom_memory_proposals` | The row checkboxes of the **Proposals** tab |
| Plan: read each text whole | `POST /v1/memory.get_by_id` | `loom call memory.get_by_id` | `agent.memory.get_by_id()` | `loom.memory.getById()` | `loom_memory_get_by_id` | **Accept…** reads and shows each text |
| Apply the decision | `POST /v1/memory.proposal_decide` | `loom call memory.proposal_decide` | `agent.client.memory.proposal_decide()` | `loom.memory.proposalDecide()` | `loom_memory_proposal_decide` | The plan's **Accept** or **Reject** button |
| Read each key's outcome | `results[].code` | `results[].code` in the printed JSON | `out["results"]` | `out.results` | `results` in the tool result | The result's line for each proposal left pending |

An acceptance sends the hash of the full read (`memory.get_by_id`), because the reviewer
read the whole text. A rejection sends that hash or the one `memory.proposals` listed
Expand Down
51 changes: 51 additions & 0 deletions frontend/e2e/list-tables.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,57 @@ test("the review queue loads more and counts what it holds of the total", async
await expect(page.getByRole("button", { name: "Load more" })).toHaveCount(0);
});

// Under a finger a proposal's checkbox keeps its 16 px box and takes a 44 px tap, in Click
// UI's cards on a phone and in the table at a tablet's width: a tap 20 px from the box's
// centre on each side ticks or unticks it, and none opens the review.
for (const width of [375, 1024]) {
test.describe(`a touch pointer at ${width} px`, () => {
test.use({ viewport: { width, height: 812 }, hasTouch: true, isMobile: true });
test("a proposal's checkbox is a 44 px target", async ({ page }) => {
await withRows(page);
await open(page, "/admin/review_queue?tab=proposals");
const check = page.getByRole("checkbox", { name: "Select alerts/threshold/lane-1" });
let checked = false;
for (const [dx, dy] of [
[-20, 0],
[20, 0],
[0, -20],
[0, 20],
]) {
const box = await check.boundingBox();
if (!box) throw new Error("the checkbox has no box");
expect(Math.round(box.width)).toBeLessThan(44);
await page.touchscreen.tap(box.x + box.width / 2 + dx, box.y + box.height / 2 + dy);
checked = !checked;
await expect(check, `a tap ${dx}, ${dy} from the centre`).toBeChecked({ checked });
}
await expect(page.getByRole("dialog")).toHaveCount(0);
});
});
}

// The panel that takes the focus as the selection bar leaves is the toolbar and the whole
// table, taller than the window on a long list: focusing it scrolls nothing.
test("clearing a proposal selection leaves the page where it was scrolled", async ({ page }) => {
await withRows(page);
const many = Array.from({ length: 40 }, (_, i) => ({
...proposal(i % 3),
memory_key: `alerts/threshold/lane-${i}`,
memory_id: `proposal-${i}`,
}));
await page.route("**/v1/memory.proposals", (r) => r.fulfill({ json: { proposals: many, total: many.length } }));
await open(page, "/admin/review_queue?tab=proposals");
const main = page.locator("main#main");
expect(await main.evaluate((m) => m.scrollHeight - m.clientHeight)).toBeGreaterThan(0);
await page.getByRole("checkbox", { name: "Select alerts/threshold/lane-1", exact: true }).check();
const before = await main.evaluate((m) => m.scrollTop);
await page.getByRole("button", { name: "Clear selection" }).click();
await expect(page.getByRole("button", { name: "Clear selection" })).toHaveCount(0);
const bar = page.getByRole("group", { name: "Proposal count and selection" });
await expect(bar.locator("xpath=ancestor::div[@tabindex='-1'][1]")).toBeFocused();
expect(await main.evaluate((m) => m.scrollTop)).toBe(before);
});

test("repositories page above 50 and not below", async ({ page }) => {
const one = codeReposFixture(now)[0];
const many = Array.from({ length: 60 }, (_, i) => ({
Expand Down
23 changes: 21 additions & 2 deletions frontend/src/api/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,24 @@ export interface MemoryProposal {
advice?: "" | "accept" | "reject";
/** Why, in the server's order and words; absent from a server a release behind. */
advice_reasons?: ProposalAdviceReason[];
/** The facts it contradicted while on trial: accepted, it waits in Conflicts. */
conflict_with?: string[];
}

/** One key's outcome, the fields of
* `server/memory/api/models_proposals.py::MemoryProposalDecision` the tab reads. */
export interface ProposalDecision {
memory_key: string;
decided: boolean;
/** The row's status after the call. */
status: string;
/** Why the key was left as it is, as the server's sentence; "" when decided. */
reason: string;
/** The same as one word of a closed set; absent from a server a release behind. */
code?: string;
/** The row decided or judged, which for a key with no pending proposal is the key's
* newest row; "" when the key named none, and absent from a server a release behind. */
memory_id?: string;
}

/** How many proposals the Review queue asks for, newest first. */
Expand All @@ -209,14 +227,15 @@ export async function listProposals(
}

/** POST /v1/memory.proposal_decide. `approvedSha256` names, per key, the hash served with
* the text the reviewer read, on either decision; `reason` is kept on a rejected fact. */
* the text the reviewer read, on either decision; `reason` is kept on each rejected fact.
* The answer holds one result per key. */
export async function decideProposals(
id: Scope,
keys: string[],
decision: "accept" | "reject",
approvedSha256: Record<string, string> = {},
reason = "",
): Promise<{ decided: number; results: { memory_key: string; decided: boolean; status: string; reason: string }[] }> {
): Promise<{ decided: number; results: ProposalDecision[] }> {
return post("/v1/memory.proposal_decide", {
org: id.org,
namespace: id.namespace,
Expand Down
15 changes: 12 additions & 3 deletions frontend/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1474,12 +1474,15 @@ textarea[aria-invalid="true"]:focus-visible {
}
/* A row's checkbox under a coarse pointer is a 44 px target (WCAG 2.5.8), so a tap beside
it selects the row instead of opening it. It reaches into Click UI's checkbox markup
(`[role="checkbox"]`): recheck it when Click UI is upgraded. */
(`[role="checkbox"]`): recheck it when Click UI is upgraded. `.row-check-cell` is the
Click UI Table cell that holds a row's checkbox. */
@media (pointer: coarse) {
.list-row-leading [role="checkbox"] {
.list-row-leading [role="checkbox"],
.row-check-cell [role="checkbox"] {
position: relative;
}
.list-row-leading [role="checkbox"]::after {
.list-row-leading [role="checkbox"]::after,
.row-check-cell [role="checkbox"]::after {
content: "";
position: absolute;
top: 50%;
Expand All @@ -1488,6 +1491,12 @@ textarea[aria-invalid="true"]:focus-visible {
height: var(--spacing-hit);
transform: translate(-50%, -50%);
}
/* Click UI's cell clips what leaves it, and under 769 px its card clips the cell: the
cell is as tall as the target, which reaches over the next cell's padding. */
.row-check-cell {
overflow: visible;
padding-block: calc((var(--spacing-hit) - var(--click-checkbox-size-all)) / 2);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Touch target sits under adjacent cells

Medium Severity

The coarse-pointer hit area on a proposal checkbox is a 44px ::after centered on a ~16px control inside a 40px row-check-cell. That box extends into the next cell, which is painted on top and has no z-index on the checkbox. A tap beside the box hits the fact cell instead of toggling the row, and can open the review.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 44277fb. Configure here.

}

/* A record inside a narrow pane (the Explorer inspector's facts and hits): CardHorizontal sm,
Expand Down
17 changes: 10 additions & 7 deletions frontend/src/test/opNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ import { OP_MIN_ROLE } from "../lib/canCall";
// Vite serves a file outside the project's root under `/@fs/`, URL-encoded, which is not a
// path on disk.
const onDisk = (rel: string) => decodeURIComponent(new URL(rel, import.meta.url).pathname).replace(/^\/@fs\//, "/");
const SDK_TREE = onDisk("../../../sdk/typescript");
const GENERATED_OPS = onDisk("../../../sdk/typescript/src/generated/ops.ts");

/** The generated op table's source, or null in a frontend-only checkout. A checkout with the
* SDK tree must have the table: a partial list would pass every check that reads it. */
export async function generatedOpsText(): Promise<string | null> {
/** The text of `file` in `tree`, a directory named from the repository's root, or null in a
* checkout without that tree (a frontend-only one). A checkout with the tree must have the
* file: without it a check passes against a partial list, or against the test's own copy. */
export async function repositoryText(tree: string, file: string): Promise<string | null> {
// vitest runs on node; the frontend tsconfig carries no node types, so the module is
// reached through a computed specifier, and the cast names the two calls used here.
type Fs = { existsSync(p: string): boolean; readFileSync(p: string, enc: "utf8"): string };
const fs = (await import(/* @vite-ignore */ "node:" + "fs")) as Fs;
if (fs.existsSync(GENERATED_OPS)) return fs.readFileSync(GENERATED_OPS, "utf8");
if (fs.existsSync(SDK_TREE)) throw new Error(`sdk/typescript is here but ${GENERATED_OPS} is not`);
const path = onDisk(`../../../${tree}/${file}`);
if (fs.existsSync(path)) return fs.readFileSync(path, "utf8");
if (fs.existsSync(onDisk(`../../../${tree}`))) throw new Error(`${tree} is here but ${path} is not`);
return null;
}

/** The generated op table's source, or null in a frontend-only checkout. */
export const generatedOpsText = () => repositoryText("sdk/typescript", "src/generated/ops.ts");

export async function opNames(): Promise<{ names: Set<string>; fromRegistry: boolean }> {
const names = new Set(Object.keys(OP_MIN_ROLE).filter((op) => op.includes(".")));
const text = await generatedOpsText();
Expand Down
Loading
Loading