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

A feed post has a permalink with its replies and a share card, and every post in the timeline links to it #12331

Merged opened this

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

Merged

scout/forge:scout/12325-a-feed-post-has-a-permalink-with-its-rep → main 5 commits fork 4 threads · 4 unresolved

  • Merged. scout/12325-a-feed-post-has-a-permalink-with-its-rep was merged into main as c0a5a9c.

Review

Sign in to review this change.
10 files changed +156 −8
docs/features/README.md +1
@@ -23,6 +23,7 @@ Read with the guide page [What a forge is](../guide-what-a-forge-is.md).
2323 - [/docs](docs-link.md)
2424 - [Engine shape](engine-shape.md)
2525 - [Feed fold](feed-fold.md)
26 - [A feed post has a permalink](feed-permalink.md)
2627 - [Feed likes: the ledger](feed-like-ledger.md)
2728 - [Forge packs: a premade forge to deploy (`/packs`)](packs.md)
2829 - [Home paints its frame first](home-frame.md)
src/feed/reply.ts +9
@@ -51,3 +51,12 @@ export function replyTarget(
5151 const repo = replyRepo(db, viewer, item.app);
5252 return repo === undefined ? undefined : { thread, repo };
5353 }
54
55 /**
56 * The one stable URL a post has: the issue or pull its link names, without
57 * any comment anchor. A post about anything else (a run, a map) keeps its link.
58 */
59 export function permalinkOf(link: string): string {
60 const thread = threadOf(link);
61 return thread === undefined ? link : `/${thread.owner}/${thread.name}/${thread.kind}/${thread.number}`;
62 }

Both doors: the terminal needs to reach this same permalink; use permalinkOf from the feed screen in src/tui/ and add a test there.

src/tui/screens/feed.ts +13 −3
@@ -7,7 +7,8 @@
77 * posts to the same people as the page's Reply (`feed/reply.ts`). `enter` on a folded burst
88 * lists its members; `l` likes the post under the cursor and a second press takes it back: the page's
99 * Like, behind the same `readInteraction` check (`feed/likes.ts`); `h` lists
10 * who liked or unliked it and when, newest first, behind that check too. Twenty
10 * who liked or unliked it and when, newest first, behind that check too. `p` says the
11 * post's permalink (`permalinkOf`, the page's time link) in a toast. Twenty
1112 * posts at a time; `t` switches to every post, newest first (`readTimeline`); `m` narrows that to only mine (its `mine` option, the page's
1213 * `?show=mine`); `n` reads the next page from the cursor the last returned.
1314 */
@@ -19,7 +20,7 @@ import { parseBefore, readTimeline, TIMELINE_START } from "../../feed/timeline.t
1920 import type { FeedItem } from "../../feed/rank.ts";
2021 import { readInteraction } from "../../feed/interact.ts";
2122 import { likeLedger, toggleLike } from "../../feed/likes.ts";
22 import { replyTarget } from "../../feed/reply.ts";
23 import { permalinkOf, replyTarget } from "../../feed/reply.ts";
2324 import type { Ctx, Screen } from "../app/app.ts";
2425 import { binding } from "../app/keys.ts";
2526 import type { Session } from "../session.ts";
@@ -123,6 +124,13 @@ export function feedScreen(f: Session, ctx: Ctx): Screen {
123124 ctx.invalidate();
124125 };
125126
127 /** `p`: the permalink of the post under the cursor, the path the page's time stamp links to. */
128 const permalink = (): void => {
129 const item = items[state.index];
130 if (item === undefined) return;
131 ctx.toast(`permalink ${permalinkOf(item.link)}`);
132 };
133
126134 const submit = (): void => {
127135 const at = selected();
128136 if (at === undefined) return;
@@ -149,6 +157,7 @@ export function feedScreen(f: Session, ctx: Ctx): Screen {
149157 ...(items[state.index]?.opens === true ? [binding(["enter"], "open the burst")] : []),
150158 ...(items.length === 0 ? [] : [binding(["l"], "like")]),
151159 ...(items.length === 0 ? [] : [binding(["h"], "who liked")]),
160 ...(items.length === 0 ? [] : [binding(["p"], "permalink")]),
152161 ...(next === null ? [] : [binding(["n"], "next page")]),
153162 binding(["t"], timeline || mine ? "ranked" : "newest first"),
154163 binding(["m"], mine ? "everyone's" : "only mine"),
@@ -213,6 +222,7 @@ export function feedScreen(f: Session, ctx: Ctx): Screen {
213222 } else if (e.key === "enter" && items[state.index]?.opens === true) members = items[state.index]!;
214223 else if (e.key === "l") like();
215224 else if (e.key === "h") showHistory();
225 else if (e.key === "p") permalink();
216226 else if (e.key === "t" || e.key === "m") {
217227 if (e.key === "m") mine = !mine;
218228 else {
@@ -235,7 +245,7 @@ export function feedScreen(f: Session, ctx: Ctx): Screen {
235245 export const entry: PaletteEntry = {
236246 id: "feed",
237247 title: "Feed",
238 hint: "what happened, ranked; r replies on a post about an issue or pull, l likes, h who liked",
248 hint: "what happened, ranked; r replies on a post about an issue or pull, l likes, h who liked, p its permalink",
239249 offered: (session) => session.user !== undefined,
240250 run: (session, ctx) => ctx.push(feedScreen(session, ctx)),
241251 };
src/web/studio/feed.ts +2 −2
@@ -21,7 +21,7 @@ import { parseCursor, readFeedPage } from "../../feed/feed.ts";
2121 import { parseShow, type Show } from "../../feed/mine.ts";
2222 import { parseBefore, readTimeline, TIMELINE_START } from "../../feed/timeline.ts";
2323 import type { FeedItem } from "../../feed/rank.ts";
24 import { replyPath, replyRepo, threadOf } from "../../feed/reply.ts";
24 import { permalinkOf, replyPath, replyRepo, threadOf } from "../../feed/reply.ts";
2525 import { getAppByRepo } from "../../core/apps.ts";
2626 import { getRepo, getRepoById } from "../../core/repos.ts";
2727 import { DEFAULT_PAGE, looksForEnv, lookUrl } from "../../core/looks.ts";
@@ -153,7 +153,7 @@ export function feedCard(
153153 const head = html`${avatar(item.actor ?? item.app)}
154154 <strong class="break">${item.actor ?? item.app}</strong
155155 >${nameMark(item.actor === null ? undefined : marks.get(item.actor))}
156 <span class="muted small break">${item.app} · ${time(item.at)}</span>
156 <span class="muted small break">${item.app} · <a href="${permalinkOf(item.link)}" class="muted permalink" aria-label="Open post" data-permalink>${time(item.at)}</a></span>

Non-blocking: the aria-label drops the visible time from the accessible name (label in name). Include the time text in the label.

157157 ${settledBadge(item.settled)}
158158 <span class="spacer"></span>
159159 <span class="badge">${KIND_LABEL[item.kind]}</span>`;
src/web/style/components.ts +1
@@ -451,6 +451,7 @@ a.sha:hover { color: var(--accent); }
451451 .look img { display: block; width: 100%; height: auto; }
452452 .look[data-slot="thumb"] { flex: none; width: 30px; height: 40px; border-radius: 4px; }
453453 .look[data-slot="thumb"] img { height: 100%; object-fit: cover; object-position: top; }
454 .permalink { display: inline-block; padding: 12px 6px; margin: -12px -6px; }

Non-blocking: this rule sits between the .look rules; put it with the link rules.

454455 .look[data-slot="feed"] { width: 160px; height: 100px; margin-top: 6px; }
455456 .look[data-slot="feed"] img { height: 100%; object-fit: cover; object-position: top; }
456457 .look[data-slot="now"] { flex: none; width: 168px; }
test/palette-roster.test.ts +3 −3
@@ -197,7 +197,7 @@ test("a site-admin person is offered the whole roster", () => {
197197 ["bets", "Bets", "back, stop and finish a repository\'s bets"],
198198 ["origins", "Connected accounts", "the hosts your mirrors come from"],
199199 ["domains", "Failure domains", "failure domains and their last drill"],
200 ["feed", "Feed", "what happened, ranked; r replies on a post about an issue or pull, l likes, h who liked"],
200 ["feed", "Feed", "what happened, ranked; r replies on a post about an issue or pull, l likes, h who liked, p its permalink"],
201201 ["feature-review", "Menu entries to review", "absorbed apps whose declared name or page changed: accept them"],
202202 ["feature-feed", "Feature feeds", "the feed items about an absorbed app, as Settings › Features shows them"],
203203 ["features", "Features", "apps that declare a feature: absorb one, change its settings"],
@@ -290,7 +290,7 @@ test("a site-admin agent is offered the roster without the person-only entries",
290290 ["plan-row", "Plan", "this forge's plan, and where its owner manages billing"],
291291 ["cloud", "Cloud accounts", "provider tokens, what they are used for, today's calls"],
292292 ["pinned", "Pinned forges", "deploy, update and roll back a forge on your cloud"],
293 ["feed", "Feed", "what happened, ranked; r replies on a post about an issue or pull, l likes, h who liked"],
293 ["feed", "Feed", "what happened, ranked; r replies on a post about an issue or pull, l likes, h who liked, p its permalink"],
294294 ["feature-feed", "Feature feeds", "the feed items about an absorbed app, as Settings › Features shows them"],
295295 ["front", "Front page", "the apps a first visitor sees, ranked; an admin pins or hides"],
296296 ["forges", "Forges you sent", "each forge sent, claimed or not, and its apps"],
@@ -385,7 +385,7 @@ test("a member person is offered the signed-in roster without the admin entries"
385385 ["bulk", "Bulk actions", "your last bulk actions; u undoes one inside its day"],
386386 ["bets", "Bets", "back, stop and finish a repository\'s bets"],
387387 ["origins", "Connected accounts", "the hosts your mirrors come from"],
388 ["feed", "Feed", "what happened, ranked; r replies on a post about an issue or pull, l likes, h who liked"],
388 ["feed", "Feed", "what happened, ranked; r replies on a post about an issue or pull, l likes, h who liked, p its permalink"],
389389 ["feature-feed", "Feature feeds", "the feed items about an absorbed app, as Settings › Features shows them"],
390390 ["front", "Front page", "the apps a first visitor sees, ranked; an admin pins or hides"],
391391 ["origin-ahead", "New commits upstream", "mirrors whose origin has moved on: take them"],
test/tui-feed-reply.test.ts +9
@@ -204,3 +204,12 @@ test("t switches the feed to every post, newest first, and back", async () => {
204204 expect(t.text()).toContain("newest first");
205205 t.stop();
206206 });
207
208 test("p says the permalink of the post under the cursor, without a comment anchor", async () => {
209 const t = boot("alice");
210 await t.open();
211 await t.press(...downTo("alice", `/alice/open/pulls/${pullNumber}`));
212 await t.press("p");
213 expect(t.text()).toContain(`permalink /alice/open/pulls/${pullNumber}`);
214 t.stop();
215 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs