phase: 145_git_source_links
**Phase 145 final verification pass — all green, no code changes needed** - **Verified (no defects found):** resolver `origin_for_source` + `_url_basename` (scp/`.git`/trailing-slash, sanitize, ambiguity WARNING); `origin:`/`branch:` lines in all four read shapes via shared `_origin_lines`; HIGH `<tools>` origin rule (verbatim + only-byte-change pins); `DocContent.origin_url/origin_branch` (absent-never-null serializer); `renderDocument` "Original" anchor (copyable verbatim URL, `_blank`/`noopener`, branch in title); mock scripted origin-link flow (disjoint trigger — grep-verified vs all other E2E files) - **Tests:** `uv run pytest --cov=app --cov-report=term-missing` → 3402 passed, `app/` coverage **99%** (>90% gate); `uv run pytest tests/e2e/test_git_source_links.py -v --no-cov` → **4 passed** in isolation; `uv run ruff check .` → clean; `uv run pyright` → 0 errors, 0 warnings - **Completion criteria:** (1) git read results carry origin/branch, local byte-identical — ✅ (unit pins + E2E control); (2) HIGH `<tools>` rule pinned, LOW byte-identical — ✅; (3) modal AND /document.html show Original link, branch in label when pinned, nothing for local — ✅; (4) full suite green + coverage + E2E + lint/types — ✅; (5) no completed-phase behavior change (read header line 1, mock prefix, done frame/SourceRef untouched, LOW sha) — ✅ - **Extra regression check:** re-ran shared-mock E2E suites `test_read_line_ranges.py` (2 passed) and `test_document_viewer.py` (8 passed) — no cross-suite regressions from the `mock_llm.py` addition - **Documentation:** README.md reviewed in full (env table ⊇ `.env.example`, pages/routes, config defaults, scripts, 17-color palette, 300 s guard, 2 s sync poll, phase-145 provenance section matches implementation) and AGENTS.md (72rem container, no-CDN test, smoke test, gitignore, gates) — **verified consistent, no changes needed** - **Notable:** phase-116 screenshot PNG was regenerated during this phase's E2E runs (byte re-encode only, visually identical, correct no-anchor local-source meta row) — left in tree for the harness commit - **Next pending phase:** `146_search_tool_scope` (then 147, 148, 149)
This commit is contained in:
@@ -118,6 +118,22 @@
|
||||
* the row exists but the copy was lost) swaps the block for a small
|
||||
* "Image unavailable" note (role=status): the page still shows the
|
||||
* description. ONE shared core — page + modal both get it.
|
||||
*
|
||||
* Phase 145 (task 03): the meta row's "Original" anchor — when the
|
||||
* content payload carries origin_url (a git-sourced document — the
|
||||
* task-01 resolver's sanitized repository URL; ABSENT on the wire
|
||||
* for non-git documents, whose meta row stays byte-identical to
|
||||
* pre-phase), an <a class="doc-origin"> joins the .doc-meta row
|
||||
* AFTER the path code and BEFORE the Created badge: href + visible
|
||||
* text = the full URL VERBATIM (the copyable-link contract — no
|
||||
* decorative label inside the anchor text; the .doc-origin ellipsis
|
||||
* clips the display), target=_blank + rel=noopener (the modal's
|
||||
* "Full page" escape-hatch idiom), and the title carries the full
|
||||
* URL plus ` — branch: <name>` when the payload pins a branch (the
|
||||
* pathCode ellipsis-precision idiom). ONE shared core — the modal
|
||||
* AND /document.html render it (no per-surface copy); createElement
|
||||
* + properties/textContent only (the never-build-HTML rule — no
|
||||
* innerHTML).
|
||||
*/
|
||||
|
||||
import { bindSharedHeaderControls, fetchIsAdmin, initSharedHeader } from "./header.js";
|
||||
@@ -158,6 +174,32 @@ function metaBadge(cls, text, title) {
|
||||
return el;
|
||||
}
|
||||
|
||||
/* Phase 145 (task 03): the meta row's "Original" anchor — the git
|
||||
* origin as a copyable external link (called only when the payload
|
||||
* carries origin_url — a non-git document never gets one, so its
|
||||
* meta row stays the pre-phase shape). The FULL URL is the anchor's
|
||||
* visible text (the copyable-link contract — no decorative label
|
||||
* inside the anchor text: a " (branch)" suffix would break
|
||||
* copy-paste; the .doc-origin CSS ellipsis clips the display
|
||||
* instead), target=_blank + rel=noopener (the modal's "Full page"
|
||||
* escape-hatch idiom), and the title carries the full URL — plus
|
||||
* ` — branch: <name>` when the payload pins a branch (the pathCode
|
||||
* ellipsis-precision idiom). Properties + textContent only — never
|
||||
* innerHTML (the XSS contract). */
|
||||
function originAnchor(doc) {
|
||||
const a = document.createElement("a");
|
||||
a.className = "doc-origin";
|
||||
a.href = doc.origin_url;
|
||||
a.target = "_blank";
|
||||
a.rel = "noopener";
|
||||
a.textContent = doc.origin_url;
|
||||
a.setAttribute(
|
||||
"title",
|
||||
doc.origin_branch ? doc.origin_url + " — branch: " + doc.origin_branch : doc.origin_url,
|
||||
);
|
||||
return a;
|
||||
}
|
||||
|
||||
/* ---------- shared renderer (phase 26, task 02) ----------
|
||||
* Populates the three elements every render surface provides: a title,
|
||||
* a .doc-meta badge row (source · format · mono path · created ·
|
||||
@@ -178,10 +220,20 @@ export function renderDocument(doc, { titleEl, metaEl, contentEl }) {
|
||||
const pathCode = document.createElement("code");
|
||||
pathCode.className = "doc-path";
|
||||
pathCode.textContent = doc.path;
|
||||
// Phase 145 (task 03): the "Original" anchor — the git origin as a
|
||||
// copyable external link, present ONLY when the content payload
|
||||
// carries origin_url (a git-sourced document's sanitized repository
|
||||
// URL — the task-01 resolver's output; ABSENT on the wire for
|
||||
// non-git documents, so their meta row stays byte-identical to
|
||||
// pre-phase). It lands AFTER the path code and BEFORE the Created
|
||||
// badge — one more inline item in the row (the modal's wrap rule
|
||||
// and the page's clip rule both keep it on their shapes).
|
||||
const originItems = doc.origin_url ? [originAnchor(doc)] : [];
|
||||
metaEl.replaceChildren(
|
||||
metaBadge("doc-source-badge", doc.source),
|
||||
metaBadge("format-badge", doc.format),
|
||||
pathCode,
|
||||
...originItems,
|
||||
// Phase 106 (task 08, D8): the Created badge BEFORE the Indexed
|
||||
// one (the owner's verbatim position — the date at the top of a
|
||||
// clicked document). textContent = the locale date (fmtDate — the
|
||||
|
||||
@@ -4400,6 +4400,28 @@ a.answer-image:hover { text-decoration: underline; } /* flat — the caption und
|
||||
keeps a visible box on narrow screens while the trailing badges clip. */
|
||||
min-width: 6rem;
|
||||
}
|
||||
/* Phase 145 (task 03): the "Original" anchor — the git origin as a
|
||||
copyable external link in the meta row (rendered by the ONE
|
||||
renderDocument core — the modal AND /document.html; a non-git
|
||||
document never gets one). The .doc-path code family (mono, 0.75rem,
|
||||
the SAME 26rem ellipsis budget + 6rem floor — the row clips, the
|
||||
title carries the full URL) with the .doc-link affordance (brand-ink
|
||||
8.7:1 on --surface — the recorded .doc-link pair; underline on
|
||||
hover/focus, the .doc-link idiom). The anchor's visible text IS the
|
||||
full URL (the copyable-link contract — the ellipsis clips the
|
||||
display). */
|
||||
.doc-origin {
|
||||
font-family: var(--mono);
|
||||
font-size: 0.75rem;
|
||||
max-width: 26rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
min-width: 6rem;
|
||||
color: var(--brand-ink); /* 8.7:1 on --surface (the .doc-link pair) */
|
||||
text-decoration: none;
|
||||
}
|
||||
.doc-origin:hover, .doc-origin:focus-visible { text-decoration: underline; }
|
||||
.doc-chunks { font-family: var(--mono); }
|
||||
/* Phase 106 (task 08, D8): the Created badge — the SAME family as the
|
||||
Indexed one (no own look: the meta row's text, var(--ink-soft) on
|
||||
@@ -5447,6 +5469,7 @@ a.answer-image:hover { text-decoration: underline; } /* flat — the caption und
|
||||
.doc-titlebar .container { gap: 0.5rem; } /* phase 34: row 2 squeezes like row 1 at mobile widths */
|
||||
#doc-title { font-size: 1.1rem; }
|
||||
.doc-path { max-width: 16rem; }
|
||||
.doc-origin { max-width: 16rem; } /* phase 145 (task 03): the Original anchor squeezes like the path */
|
||||
.doc-md { padding: 1.1rem 1rem; }
|
||||
.doc-summary { padding: 0.75rem 0.9rem; }
|
||||
.doc-raw { padding: 1rem; font-size: 0.8rem; }
|
||||
|
||||
Reference in New Issue
Block a user