iterate.com / git

git clone https://git.iterate.com/repos/git

A file's Source and Edit are icons on the row of its name, at the right (#7)

Misha, 27 Nov 2026, in Slack: "“Its source” and “Edit” should be inline icon buttons on the same row as the filename, maybe hugging the right though, they’re taking up vertical space pointlessly rn."

- pages.ts: the file page's two actions leave their own rows and stand in the crumbs row, after "main at <commit>": a code icon for a markdown file's source (an eye for "As it reads" on ?plain), and the pencil for a member. Each link keeps its address and its guard, and names itself in title and aria-label.
- page.css: .acts, the icons as quiet buttons with a hover and a focus state.
- Proven: 53 tests, tsc, and the page on tests/serve.mjs at 1280 px and 390 px.

Task: tasks/put-source-and-edit-icons-on-the-git-filename-row.md
Via: /agents/claude/git-file-header-icons-mwz98bts-054ef5
Session: claude 7381b4d3-8505-45dc-a278-a90177c50d9b on beelink
Iterate-Run: /@1240294

jonas, 2026-11-27 17:30 UTC · ae43ae701fe38fe5dae68e474dddb00ebdaff4f0 · parent da61b80

3 files changed

M pages.ts
@@ -122,11 +122,11 @@
   );
   const top = `<a href="${esc(repo)}">${esc(nameOf(repo))}</a>`;
   const at = `<span class="at">main at <a href="${esc(repo)}/commit/${commitOid}"><code>${commitOid.slice(0, 7)}</code></a></span>`;
-  const way = `<p class="crumbs">${[top, ...crumbs].join(" / ")}${at}</p>`;
+  const file = isFile ? await fileContent(view, handle, path, plain) : null;
+  // a file's actions stand on the row of its name, at the right, and take no row of their own
+  const way = `<p class="crumbs">${[top, ...crumbs].join(" / ")}${at}${file?.acts || ""}</p>`;
 
-  const content = isFile
-    ? await fileContent(view, handle, path, plain)
-    : await folderContent(view, handle, under, within);
+  const content = file ? file.body : await folderContent(view, handle, under, within);
   const main = `<div class="code"><nav id="tree" aria-label="Files"></nav><div id="content">${way}${content}</div></div>`;
   const title = path ? `${path} · ${nameOf(repo)}` : nameOf(repo);
   return page(view, 200, "code", title, main, { paths, path });
@@ -157,7 +157,9 @@
   return `<ul class="entries">${entries.join("")}</ul>${shown}`;
 }
 
-/** The file's text. A markdown file is shown as it reads, and `?plain` shows its source. */
+/** The file's text, and its actions for the row of its name: each an icon that is a link, with
+ *  its name for a reader that sees no icon. A markdown file is shown as it reads, and `?plain`
+ *  shows its source. */
 async function fileContent(view: View, handle: Repo, path: string, plain: boolean) {
   let text: string | null;
   try {
@@ -167,18 +169,20 @@
     if (/is not text/.test(error instanceof Error ? error.message : "")) text = null;
     else throw error;
   }
-  if (text === null) return note("This file is not text, so it is not shown. A clone has it.");
+  if (text === null)
+    return { acts: "", body: note("This file is not text, so it is not shown. A clone has it.") };
   const here = treeHref(view.repo, path);
   const other = isMarkdown(path)
     ? plain
-      ? `<p class="note"><a href="${here}">As it reads</a></p>`
-      : `<p class="note"><a href="${here}?plain">Its source</a></p>`
+      ? `<a href="${here}" title="As it reads" aria-label="As it reads">${EYE}</a>`
+      : `<a href="${here}?plain" title="Its source" aria-label="Its source">${CODE}</a>`
     : "";
   // the pencil, for a member: GitHub's address for the page that edits this file
   const pencil = view.me
-    ? `<p class="note"><a class="pencil" href="${editHref(view.repo, path)}" title="Edit this file">${PENCIL} Edit</a></p>`
+    ? `<a class="pencil" href="${editHref(view.repo, path)}" title="Edit this file" aria-label="Edit this file">${PENCIL}</a>`
     : "";
-  return other + pencil + fileText(path, text, plain);
+  const acts = other || pencil ? `<span class="acts">${other}${pencil}</span>` : "";
+  return { acts, body: fileText(path, text, plain) };
 }
 
 /** `/repos/<name>/edit/main/<path>`, for a member: the file's text in a box that the member
@@ -756,8 +760,14 @@
 /** The page that edits a file of main. */
 const editHref = (repo: string, path: string) =>
   esc(`${repo}/edit/main/${path.split("/").map(encodeURIComponent).join("/")}`);
-/** A pencil (lucide's), drawn in the text's colour. */
-const PENCIL = `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/></svg>`;
+/** An icon (lucide's), drawn in the text's colour. */
+const icon = (paths: string) =>
+  `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${paths}</svg>`;
+const PENCIL = icon(`<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>`);
+const CODE = icon(`<path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/>`);
+const EYE = icon(
+  `<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/>`,
+);
 /** A moment as `2026-11-24 15:39 UTC`: the same for every reader. */
 const utcStamp = (timestamp: number) =>
   `${new Date(timestamp).toISOString().slice(0, 16).replace("T", " ")} UTC`;
M public/page.css
@@ -27,6 +27,11 @@
 .crumbs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem;
   margin-bottom: 0.75rem; }
 .crumbs .at { margin-left: auto; font-size: 0.75rem; }
+/* a file's actions: icons at the right of the row of its name */
+.crumbs .acts { display: inline-flex; align-self: center; gap: 0.125rem; margin-left: 0.25rem; }
+.acts a { display: inline-flex; padding: 0.25rem; border-radius: 0.375rem;
+  color: var(--muted-foreground); }
+.acts a:hover, .acts a:focus-visible { background: var(--accent); color: var(--foreground); }
 .entries { border: 1px solid var(--border); border-radius: 0.5rem; overflow: hidden; }
 .entries li + li { border-top: 1px solid var(--border); }
 .entries a { display: block; padding: 0.3rem 0.75rem; text-decoration: none;
@@ -133,7 +138,6 @@
 /* ── the page that edits a file ── */
 .edit { margin: 1rem 1rem 3rem; }
 .edit > .crumbs { margin-bottom: 0.75rem; }
-.pencil { display: inline-flex; align-items: center; gap: 0.3rem; }
 #edit-text { display: block; width: 100%; min-height: 60vh; padding: 0.75rem;
   border: 1px solid var(--input); border-radius: 0.5rem; background: var(--background);
   font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.8125rem; line-height: 1.5;
M tests/pages.test.mjs
@@ -94,10 +94,15 @@
 
   const shown = await read("/repos/task-board/tree/main/todo/first.md");
   assert.ok(shown.includes(`<pre data-markdown data-dir="todo"># First\n</pre>`));
-  assert.ok(shown.includes(`<a href="/repos/task-board/tree/main/todo/first.md?plain">Its source</a>`));
+  // the action is an icon on the row of the file's name, and its name is there for a reader
+  assert.ok(
+    /<p class="crumbs">.*<span class="acts"><a href="\/repos\/task-board\/tree\/main\/todo\/first\.md\?plain" title="Its source" aria-label="Its source"><svg [^>]*aria-hidden="true">.*<\/svg><\/a><\/span><\/p>/.test(shown),
+  );
+  assert.ok(!shown.includes(`<p class="note">`));
 
   const source = await read("/repos/task-board/tree/main/todo/first.md?plain");
   assert.ok(source.includes(`<pre data-file="todo/first.md"># First\n</pre>`));
+  assert.ok(source.includes(`<a href="/repos/task-board/tree/main/todo/first.md" title="As it reads" aria-label="As it reads"><svg `));
 });
 
 test("the commits are listed newest first, each with its oid, the first line of its message, who and when, and no address", async () => {
@@ -284,7 +289,11 @@
   const read = async (member) =>
     (await git.fetch(new Request("https://git.example.com/repos/kernel/tree/main/core/my%20sdk.ts"), localMind({ folders, member }))).text();
 
-  assert.ok((await read("ada@example.com")).includes(`<a class="pencil" href="/repos/kernel/edit/main/core/my%20sdk.ts" title="Edit this file">`));
+  const members = await read("ada@example.com");
+  assert.ok(members.includes(`<a class="pencil" href="/repos/kernel/edit/main/core/my%20sdk.ts" title="Edit this file" aria-label="Edit this file"><svg `));
+  // on the row of the file's name, with no row of its own
+  assert.ok(/<p class="crumbs">.*<span class="acts"><a class="pencil" [^>]*>.*<\/a><\/span><\/p>/.test(members));
+  assert.ok(!(await read(null)).includes(`class="acts"`));
   assert.ok(!(await read(null)).includes("/edit/main/"));
 });