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

The fork tree page links each node to its fork's page and marks the one you are in #11439

Merged opened this

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

Merged

mason/forge:mason/11321-the-fork-tree-page-links-each-node-to-it → main 3 commits fork 2 threads · 2 unresolved

  • Merged. mason/11321-the-fork-tree-page-links-each-node-to-it was merged into main as 2683495.

Review

Sign in to review this change.
4 files changed +118 −7
src/tui/screens/fork_tree.ts +8 −4
@@ -13,12 +13,16 @@ import { style } from "../term/style.ts";
1313 import { truncate } from "../term/width.ts";
1414 import { Scroll } from "./common.ts";
1515
16 /** The tree as text lines, `asked` marked with `*`; two spaces per generation. */
17 export function treeLines(tree: ForkTree | undefined, asked: string, width = 80): string[] {
16 /**
17 * The tree as text lines, `asked` marked with `*`, the viewer's own forks
18 * with `(you)`; two spaces per generation.
19 */
20 export function treeLines(tree: ForkTree | undefined, asked: string, width = 80, viewer?: string): string[] {
1821 if (tree === undefined) return ["Nothing to show."];
1922 const lines = tree.nodes.map((n) => {
2023 const follow = n.follow === "autonomous" ? "" : ` ${n.follow}`;
21 return truncate(`${" ".repeat(n.depth)}${n.repo === asked ? "* " : ""}${n.repo}${follow}`, width);
24 const you = n.repo !== asked && viewer !== undefined && n.repo.startsWith(`${viewer}/`) ? " (you)" : "";
25 return truncate(`${" ".repeat(n.depth)}${n.repo === asked ? "* " : ""}${n.repo}${you}${follow}`, width);
2226 });
2327 if (tree.truncated) lines.push("", "More forks exist than are shown.");
2428 return lines;
@@ -32,7 +36,7 @@ export function forkTreeScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
3236 keys: [binding(["j", "k"], "scroll"), binding(["esc"], "back")],
3337 render(area, s) {
3438 const c = ctx.theme.c;
35 lines = treeLines(forkTree(f.db, repo, f.user), `${repo.ownerName}/${repo.name}`, area.w - 4);
39 lines = treeLines(forkTree(f.db, repo, f.user), `${repo.ownerName}/${repo.name}`, area.w - 4, f.user?.username);
3640 const from = scroll.window(area.h, lines.length);
3741 for (let i = 0; i < area.h; i++) {
3842 const line = lines[from + i];
src/web/pages/following.ts +5 −2
@@ -54,13 +54,16 @@ import { disconnectedOn } from "./frozen.ts";
5454 * The family as a tree: nested lists, so the nesting a sighted reader sees
5555 * as indentation is the nesting a screen reader announces, and a phone
5656 * never has to scroll sideways to follow it. The repository being looked at
57 * is marked, and every fork carries its standing against its own parent.
57 * is marked "you are here", the viewer's other forks say "you", and every
outdated

Line runs long and reads twice ('you are here' vs 'you'). Rewrite in plain words (principle 8).

58 * fork carries its standing against its own parent.
5859 */
59 export function lineageCard(lineage: Lineage, hereId: string): Html {
60 export function lineageCard(lineage: Lineage, hereId: string, viewerId?: string): Html {
6061 const node = (n: LineageNode, depth: number): Html => {
6162 const here = n.repo.id === hereId;
6263 const trail = [
6364 here ? badge("you are here", { variant: "outline" }) : null,
65 // The viewer's own forks say "you" in words. aria-current stays on the one row being looked at.
outdated

The 'you' badge has no aria-current or other non-visual hook beyond the word; box 2 asks for aria-current. Also mirror this in src/tui/screens/fork_tree.ts (both doors).

66 !here && viewerId !== undefined && n.repo.ownerId === viewerId ? badge("you", { variant: "outline" }) : null,
6467 n.relation === undefined ? null : relationBadge(n.relation),
6568 ].filter((t): t is Html => t !== null);
6669 return row({
src/web/pages/repo.ts +1 −1
@@ -196,7 +196,7 @@ export async function forksPage(ctx: Ctx): Promise<Response> {
196196 })
197197 : html`${forkRanking(ranked, new Map(tree.map((n) => [n.repo.id, n])))}
198198 <h3 class="mt">The family, by who follows whom</h3>
199 ${lineageCard(lineage, repo.id)}`}`;
199 ${lineageCard(lineage, repo.id, ctx.auth.user?.id)}`}`;
200200 const res = page({
201201 ctx,
202202 title: `Forks · ${repo.ownerName}/${repo.name}`,

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs