Public: anyone can read this; the crew can change it.

Home: two or three owner-pinned panels with release annotations #16884

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/16850-home-two-or-three-owner-pinned-panels-wi → main 0 commits fork 2 threads · 2 unresolved

  • Merged. scout/16850-home-two-or-three-owner-pinned-panels-wi was merged into main as 12309f3.

Review

Sign in to review this change.
4 files changed +54 −4
docs/features/home-pins.md added +21
@@ -0,0 +1,21 @@
1 ---
2 topic: Your apps
3 row: Home pins: two or three board panels with release marks
4 ---
5 # Home pins: two or three board panels with release marks
6
7 The owner (a forge admin who is a person) keeps at most **three** board panels on home, under the
8 KPI row. Each draws its chart over its board's range with the release marks every board chart
9 carries (`releaseMarks`, `src/boards/marks.ts`), and **Open board** goes to `/boards/<slug>`, which
10 draws the same panels over the same range.
11
12 - **Web:** on `/boards`, Pin a panel; on home, Up, Down, Unpin and Open board beside it. A fourth
13 pin is refused ("too many"). The choice is per user, in the `board_pin` table under
14 `FORGE_APP_DATA`; the board and panel are checked against the boards registry, and every change is
15 a same-origin form post.
16 - **Terminal:** the Pinned panels screen (`src/tui/screens/home_pins.ts`): `<`/`>` move, `u`
17 unpins, `enter` opens the board. `p` on a panel in the Boards screen pins it.
18 - **API and MCP:** `/api/v1/boards/pins` and the `board_pins` tool, through `actions/board-pins.ts`.
19
20 Pins above three that were made before the limit stay stored. Home shows the first three; the rest
outdated

This sentence contradicts the title and the first paragraph ('at most three'). Once home shows the first three, say where the others are listed and unpinned.

21 are listed, and can be unpinned, on `/boards` and in the terminal's Pinned panels screen.
src/boards/pins.ts +2 −1
@@ -8,7 +8,8 @@ import type { Database } from "bun:sqlite";
88 import { isSlug, MAX_TITLE } from "./store.ts";
99
1010 export type Pin = { slug: string; title: string };
11 export const MAX_PINS = 24;
11 /** Home keeps a few panels, not a wall: two or three the owner chose (#16850). */
12 export const MAX_PINS = 3;
1213
1314 /** A pin as a form says it, judged: the plain value or undefined. */
1415 export function pinOf(slug: unknown, title: unknown): Pin | undefined {
src/web/studio/pinned.ts +5 −3
@@ -1,12 +1,12 @@
11 /**
22 * The panels a person pinned from /boards, drawn under home's KPI row in
3 * their order (#2741), each with Up, Down and Unpin beside it. Only the
3 * their order (#2741), at most MAX_PINS of them, each with Up, Down and Unpin beside it. Only the
44 * viewer's own pins are read. A pin whose board or panel is gone is skipped.
55 */
66 import type { App } from "../../app.ts";
77 import { listPinned, PINS_EVENT } from "../../actions/board-pins.ts";
88 import type { Board, Panel } from "../../boards/store.ts";
9 import type { Pin } from "../../boards/pins.ts";
9 import { MAX_PINS, type Pin } from "../../boards/pins.ts";
1010 import type { User } from "../../core/users.ts";
1111 import { html, type Html } from "../html.ts";
1212 import { btn } from "../ui.ts";
@@ -17,6 +17,7 @@ import { drawPanel } from "../pages/boards-view.ts";
1717 function controls(p: Pin): Html {
1818 const hidden = html`<input type="hidden" name="slug" value="${p.slug}" /><input type="hidden" name="title" value="${p.title}" /><input type="hidden" name="back" value="/" />`;
1919 return html`<div class="row-actions">
20 ${btn("Open board", { href: `/boards/${p.slug}`, size: "sm", label: `Open the ${p.title} board` })}

Principle 1/7: fine as a link. But home draws listed.value in full below; slice it to MAX_PINS so 'at most three' holds for pins stored before the cap, and test it.

2021 <form method="post" action="/boards/move-pin" class="row-actions">${hidden}
2122 ${btn("Up", { size: "sm", name: "by", value: "-1", label: `Move ${p.title} up` })}
2223 ${btn("Down", { size: "sm", name: "by", value: "1", label: `Move ${p.title} down` })}
@@ -32,7 +33,8 @@ const cached = (p: Pin & { board: Board; panel: Panel }): typeof runFor => (db,
3233 export async function pinnedPanels(app: App, user: User): Promise<Html | null> {
3334 const listed = await listPinned(app, user);
3435 if (!listed.ok) return null;
35 const shown = listed.value.length === 0 ? null : html`<section class="bgrid" aria-label="Pinned panels">${listed.value.map((p) => drawPanel(app, p.board, p.panel, { slug: p.slug, index: p.board.panels.indexOf(p.panel) }, controls(p), cached(p)))}</section>`;
36 const first = listed.value.slice(0, MAX_PINS); // pins stored before the cap stay listed elsewhere; home draws three
37 const shown = first.length === 0 ? null : html`<section class="bgrid" aria-label="Pinned panels">${first.map((p) => drawPanel(app, p.board, p.panel, { slug: p.slug, index: p.board.panels.indexOf(p.panel) }, controls(p), cached(p)))}</section>`;
3638 return pinsRegion(shown);
3739 }
3840
test/board-pins.test.ts +26
@@ -99,6 +99,13 @@ describe("pinned panels", () => {
9999 expect(pinOf("mine", "a\u0000b")).toBeUndefined();
100100 });
101101
102 test("home keeps at most three pins and each links to its board", async () => {
103 expect(MAX_PINS).toBe(3);
104 const html = await home("alice");
105 expect(html).toContain('href="/boards/mine"');
106 expect(html).toContain("Open the Pin A board");
107 });
108
102109 test("a pin whose panel has gone is skipped, not an error", async () => {
103110 app.db.run("INSERT INTO board_pin (user_id, slug, title, pos) VALUES (?, 'gone', 'x', 9)", [alice.id]);
104111 expect(titles(await home("alice"))).toEqual(["Pin A", "Pin B"]);
@@ -140,3 +147,22 @@ describe("pinned panels", () => {
140147 expect(await titlesOf("carol")).toEqual([]); // her "Pin C" was renamed away: not shown
141148 });
142149 });
150
151 describe("the cap of three", () => {
152 test("home draws only the first three of four stored pins; a fourth through pinPanel is refused", async () => {
153 const dave = { ...carol, isAdmin: true }; // the stale object predates the promotion
154 app.db.run("DELETE FROM board_pin WHERE user_id = ?", [dave.id]);
155 const names = ["Cap 1", "Cap 2", "Cap 3", "Cap 4"];
156 const w = await writeBoard(app, alice, "cap", { title: "Cap", range: "all", refresh: "off", panels: names.map(panel) });
157 expect(w.ok).toBe(true);
158 names.forEach((t, i) => app.db.run("INSERT INTO board_pin (user_id, slug, title, pos) VALUES (?, 'cap', ?, ?)", [dave.id, t, i]));
159 expect(listPins(app.db, dave.id)).toHaveLength(4);
160 const h = await home("carol");
161 expect([...h.matchAll(/<h2>(Cap \d)<\/h2>/g)].map((m) => m[1])).toEqual(["Cap 1", "Cap 2", "Cap 3"]);
162 const w2 = await writeBoard(app, alice, "cap", { title: "Cap", range: "all", refresh: "off", panels: [...names, "Cap 5"].map(panel) });
163 expect(w2.ok).toBe(true);
164 const refused = await pinPanel(app, dave, "cap", "Cap 5");
165 expect(refused.ok).toBe(false);
166 if (!refused.ok) expect(refused.error).toBe("too_many");
167 });
168 });

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs