newsroom 5.1: Web UI — inbox layout, list, reader, actions (ICB-143) #264

Merged
prskr merged 3 commits from ICB-143-newsroom-5-1-web-ui-inbox-layout-list-reader-actions into main 2026-10-14 17:39:47 +00:00
Contributor

Task 5.1 of OpenSpec change newsroom.

What

  • Routes /, /feed/{route...}, /provider/{name}, /entry/{id}; filters, cursor and open entry live in query params.
  • Sidebar (Goshtoso sidebar, unread badges, off-canvas at phone width), sticky toolbar with state + time-range filters as plain GET links, list with revealed infinite scroll plus visible Load more.
  • Reader pane via hx-get /ui/entry/{id} + hx-push-url; full load with entry= renders both panes server-side. Summary + extracted body (goldmark -> bluemonday); pending/failed entries show feed content with honest status; links to article and OriginalLink when different.
  • /ui/ fragment endpoints: read, star (desired state, never toggle), read-all (render-time cutoff), next page, reader pane.
  • m shortcut: one Alpine @keydown.window handler clicking the mark-read button, ignores input/textarea/select/contenteditable; key shown with Goshtoso kbd.
  • Filtered view shows the rule.
  • server.New(ui http.Handler): UI handler is injected; nil -> 503 (real wiring is task 6.1).

Deps added

github.com/yuin/goldmark (markdown render) and github.com/microcosm-cc/bluemonday (sanitizer; untrusted feed/extractor HTML). Sanitized output is the only thing passed to templ.Raw.

Verification

  • bazel test --config=remote //newsroom/...: 19/19 pass, including //newsroom/internal/web:web_integration_test (real Postgres: pagination covers every entry once, malformed cursor 400, since=24h on first_seen_at, filtered rule, read action vs DB, XSS, no outbound calls, read-all cutoff) and nogo.
  • XSS test asserts script/iframe/on*/javascript: do not survive in the reading view.

Not done / caveats

  • Visual check at 375px / desktop, light + dark: not done (no browser available). Layout is CSS in reader.css; needs a human or Grace pass.
  • bazel run //:format could not run here (git dubious ownership inside the bazel sandbox); gofmt is clean.
  • bazel coverage not measured (no C toolchain).
  • Sidebar badges and rows other than the acted-on one refresh on reload; read-all uses HX-Refresh.
  • .nogo.json: contextcheck excluded for newsroom/internal/web/web.go (it follows templ component constructors into Goshtoso's button and flags handler call sites; generated code was already excluded).
  • Goshtoso hides the badge of an active top-level sidebar item, so the active All news shows its count in the label.
  • Out of scope as planned: tags, Readeck, search, briefings.

🤖 Generated with Claude Code

Task 5.1 of OpenSpec change `newsroom`. ## What - Routes `/`, `/feed/{route...}`, `/provider/{name}`, `/entry/{id}`; filters, cursor and open entry live in query params. - Sidebar (Goshtoso `sidebar`, unread badges, off-canvas at phone width), sticky `toolbar` with state + time-range filters as plain GET links, list with `revealed` infinite scroll plus visible *Load more*. - Reader pane via `hx-get /ui/entry/{id}` + `hx-push-url`; full load with `entry=` renders both panes server-side. Summary + extracted body (goldmark -> bluemonday); pending/failed entries show feed content with honest status; links to article and OriginalLink when different. - `/ui/` fragment endpoints: read, star (desired state, never toggle), read-all (render-time cutoff), next page, reader pane. - `m` shortcut: one Alpine `@keydown.window` handler clicking the mark-read button, ignores input/textarea/select/contenteditable; key shown with Goshtoso `kbd`. - Filtered view shows the rule. - `server.New(ui http.Handler)`: UI handler is injected; nil -> 503 (real wiring is task 6.1). ## Deps added `github.com/yuin/goldmark` (markdown render) and `github.com/microcosm-cc/bluemonday` (sanitizer; untrusted feed/extractor HTML). Sanitized output is the only thing passed to `templ.Raw`. ## Verification - `bazel test --config=remote //newsroom/...`: 19/19 pass, including `//newsroom/internal/web:web_integration_test` (real Postgres: pagination covers every entry once, malformed cursor 400, since=24h on first_seen_at, filtered rule, read action vs DB, XSS, no outbound calls, read-all cutoff) and nogo. - XSS test asserts script/iframe/on*/javascript: do not survive in the reading view. ## Not done / caveats - Visual check at 375px / desktop, light + dark: **not done** (no browser available). Layout is CSS in `reader.css`; needs a human or Grace pass. - `bazel run //:format` could not run here (git `dubious ownership` inside the bazel sandbox); `gofmt` is clean. - `bazel coverage` not measured (no C toolchain). - Sidebar badges and rows other than the acted-on one refresh on reload; read-all uses `HX-Refresh`. - `.nogo.json`: contextcheck excluded for `newsroom/internal/web/web.go` (it follows templ component constructors into Goshtoso's button and flags handler call sites; generated code was already excluded). - Goshtoso hides the badge of an active top-level sidebar item, so the active *All news* shows its count in the label. - Out of scope as planned: tags, Readeck, search, briefings. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
newsroom: web UI inbox, list, reader and actions (task 5.1)
Some checks failed
Validate / validate (pull_request) Failing after 55s
5b474d9f57
Three-pane server-rendered inbox over internal/library: sidebar with unread
badges, filterable keyset-paginated list (load more + revealed), reader pane
with sanitized markdown, read/star/read-all fragment endpoints, `m` shortcut.

New deps: goldmark (markdown) and bluemonday (HTML sanitizer for untrusted
feed/extractor content). server.New now takes the UI handler; wiring is 6.1.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
newsroom: format web_test.go and reader.css (CI format check)
All checks were successful
Validate / validate (pull_request) Successful in 4m1s
32d51ff18a
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Contributor

Verdict: CHANGES REQUESTED (FAIL) — PR #264 at 32d51ff18a43bcd7e93c843c84ba7abb8c3045b9 (PR head re-checked just before posting; Forgejo CI Validate is green on this head).

The tests, the format check and nogo all pass. But every feed view is broken against real data, and feed-supplied links can be javascript: URLs. The tests miss the first bug because their fixtures use routes the real config never produces.

Success condition tested

Plan document on ICB-144: brief newsroom/tasks/14-web-ui.md, spec newsroom-ui, task 5.1. Feed/provider/entry views work with real stored data, content is sanitized, URL state works, actions are idempotent, and the gate passes (tests, format, nogo, no symlinks).

Steps run

git worktree add --detach /tmp/pr264 32d51ff        # separate worktree; review branch untouched
/code-review high origin/main...32d51ff              # 10 findings; I checked the top ones myself, see below
bazel test --config=remote --nocache_test_results --experimental_convenience_symlinks=ignore //newsroom/...
  -> Executed 19 out of 19 tests: 19 tests pass. (19 remote; incl. web/library/storage/ingest integration tests via podman)
bazel query 'attr(tags, "manual", //newsroom/...)'  -> Empty results (no manual targets; integration tests are in the run above)
bazel run --experimental_convenience_symlinks=ignore //:format ; git status --short  -> clean
git diff --raw origin/main...HEAD | awk '$2=="120000"'  -> none ; find . -type l -not -path './.git/*' -> none (PR worktree and workspace)
Throwaway repro tests (deleted afterwards), plus mutation checks on render.go (reverted)

Blocking findings

1. [HIGH] Feed views and Mark-all-read never match a real feed. query.go:72, web.go:99-100, layout.templ:102

  • Stored routes are config.JoinedRoute, which always starts with / (config/route.go joinRoute; storage/store.go:97 upserts it). Sidebar links become /feed//golem/news. ServeMux 301-redirects to /feed/golem/news, so PathValue("route") = golem/news. GetFeedByRoute("golem/news") finds nothing, so every feed page shows an empty list. On that page, Mark-all-read posts to /ui/feed/golem/news/read-all and calls MarkFeedRead("golem/news"), which marks 0 rows.
  • Expected: clicking a feed in the sidebar lists its entries. Actual (repro with stub feeds using Route: "/golem/news"):
    link on /: /feed//golem/news
    GET /feed//golem/news -> final /feed/golem/news status 200
    scope.Feed values passed to library: ["" "golem/news"]
    read-all target: /ui/feed/golem/news/read-all
    
  • The tests miss it because both web_test.go:171-178 and web_integration_test.go:94-95 use golem/news without the leading slash. Fix: pick one form, either re-add the / when you read {route...} or strip it when you build links. Make the fixtures use real JoinedRoute values.

2. [HIGH, security] javascript: feed links are rendered unsanitized. layout.templ:281,283

  • templ.SafeURL(d.Article.Link) / OriginalLink turns off templ's URL sanitizing. feed/feed.go:226-227 stores item.Link from the remote feed with no scheme check. Repro (stub entry, GET /entry/9):
    <a data-source="article" href="javascript:alert(document.domain)" target="_blank" ...
    <a data-source="original" href="javascript:alert(2)" ...
    
  • target=_blank rel=noopener limits the damage in current browsers, but this is still untrusted DB content that skips sanitizing, which the brief rules out. Fix: pass the plain string (templ sanitizes href strings) or only allow http/https. Add an XSS test case for the links.

Non-blocking findings (in rough order)

  1. [MEDIUM] Infinite scroll probably never fires. layout.templ:162 uses hx-trigger="revealed", but the list scrolls inside .nr-scroll { overflow-y: auto } (reader.css:265). htmx docs say to use intersect once for overflow containers. The load-more click still works. Not checked in a browser.
  2. [MEDIUM] Reader pane and action responses render with an empty query{}. web.go:175,230. After HTMX navigation, "Back to list" goes to / instead of the current feed and filters, and on a phone that is the only way back. A starred or read row swapped in from the list loses its Selected highlight and gets a PageURL without scope.
  3. [MEDIUM] An open ?entry= that no longer exists 404s the whole page (view.go:90). Expected: the list renders without the reader.
  4. [LOW] No CSRF or cross-origin check on the POST /ui/ endpoints (web.go:58-62). How serious this is depends on the kong/auth setup (task 6.1). http.CrossOriginProtection would close it cheaply.
  5. [LOW] Mark-all-read cutoff comes from the app clock (view.go:84), while first_seen_at comes from Postgres now(). If the clocks drift, entries that arrive just after render get marked read. Small risk on one host.
  6. [LOW] Render errors are only logged (web.go:66-70), so a partial 200 can be swapped in. The old smoke handler returned 500.
  7. [NIT] ListFeeds runs twice per page with ?entry=, and once per row action. view.go:94
  8. [NIT, test strength] The markdown sanitizer layer is untested. With Sanitize removed from renderer.markdown, TestReadingViewNeutralizesHostileContent still passes, because goldmark's own escaping covers it. Removing Sanitize from renderer.html does make it fail (good). Consider a markdown case that only bluemonday catches, or document that goldmark is the first layer.

Checklist items that pass

Gate (tests, format, nogo, 5.1 ticked, no symlinks). The XSS test fails when HTML sanitizing is removed. No inline <script>. The only templ.Raw calls are the sanitized BodyHTML and the embedded reader.css. Read and star send the desired state, and desired() rejects missing or garbled values.

Not covered

  • No browser check: I can't render pages, so 375px/desktop layout, light/dark, off-canvas sidebar, htmx scroll, URL push, back button and row refresh are all unverified. Finding 3 is from the code and the htmx docs, not from watching it run.
  • Coverage >70% for internal/web: not measured. Untested paths I noticed: render-error branches, the ?entry= not-found page, feed routes with a leading slash.
  • /code-review findings 6–9 are taken from reading the code, without repros.

Next owner

Linus Torvalds fixes 1 and 2 (and 3–5 if cheap) on ICB-143. I re-review the new head with /code-review when ICB-143 is done again. Do not merge.

**Verdict: CHANGES REQUESTED (FAIL)** — PR [#264](https://code.icb4dc0.de/prskr/tools/pulls/264) at `32d51ff18a43bcd7e93c843c84ba7abb8c3045b9` (PR head re-checked just before posting; Forgejo CI `Validate` is green on this head). The tests, the format check and nogo all pass. But every feed view is broken against real data, and feed-supplied links can be `javascript:` URLs. The tests miss the first bug because their fixtures use routes the real config never produces. ### Success condition tested Plan document on ICB-144: brief `newsroom/tasks/14-web-ui.md`, spec `newsroom-ui`, task 5.1. Feed/provider/entry views work with **real stored data**, content is sanitized, URL state works, actions are idempotent, and the gate passes (tests, format, nogo, no symlinks). ### Steps run ``` git worktree add --detach /tmp/pr264 32d51ff # separate worktree; review branch untouched /code-review high origin/main...32d51ff # 10 findings; I checked the top ones myself, see below bazel test --config=remote --nocache_test_results --experimental_convenience_symlinks=ignore //newsroom/... -> Executed 19 out of 19 tests: 19 tests pass. (19 remote; incl. web/library/storage/ingest integration tests via podman) bazel query 'attr(tags, "manual", //newsroom/...)' -> Empty results (no manual targets; integration tests are in the run above) bazel run --experimental_convenience_symlinks=ignore //:format ; git status --short -> clean git diff --raw origin/main...HEAD | awk '$2=="120000"' -> none ; find . -type l -not -path './.git/*' -> none (PR worktree and workspace) Throwaway repro tests (deleted afterwards), plus mutation checks on render.go (reverted) ``` ### Blocking findings **1. [HIGH] Feed views and Mark-all-read never match a real feed.** `query.go:72`, `web.go:99-100`, `layout.templ:102` - Stored routes are `config.JoinedRoute`, which always starts with `/` (`config/route.go` `joinRoute`; `storage/store.go:97` upserts it). Sidebar links become `/feed//golem/news`. ServeMux 301-redirects to `/feed/golem/news`, so `PathValue("route")` = `golem/news`. `GetFeedByRoute("golem/news")` finds nothing, so every feed page shows an empty list. On that page, Mark-all-read posts to `/ui/feed/golem/news/read-all` and calls `MarkFeedRead("golem/news")`, which marks 0 rows. - Expected: clicking a feed in the sidebar lists its entries. Actual (repro with stub feeds using `Route: "/golem/news"`): ``` link on /: /feed//golem/news GET /feed//golem/news -> final /feed/golem/news status 200 scope.Feed values passed to library: ["" "golem/news"] read-all target: /ui/feed/golem/news/read-all ``` - The tests miss it because both `web_test.go:171-178` and `web_integration_test.go:94-95` use `golem/news` without the leading slash. Fix: pick one form, either re-add the `/` when you read `{route...}` or strip it when you build links. Make the fixtures use real `JoinedRoute` values. **2. [HIGH, security] `javascript:` feed links are rendered unsanitized.** `layout.templ:281,283` - `templ.SafeURL(d.Article.Link)` / `OriginalLink` turns off templ's URL sanitizing. `feed/feed.go:226-227` stores `item.Link` from the remote feed with no scheme check. Repro (stub entry, `GET /entry/9`): ``` <a data-source="article" href="javascript:alert(document.domain)" target="_blank" ... <a data-source="original" href="javascript:alert(2)" ... ``` - `target=_blank rel=noopener` limits the damage in current browsers, but this is still untrusted DB content that skips sanitizing, which the brief rules out. Fix: pass the plain string (templ sanitizes `href` strings) or only allow http/https. Add an XSS test case for the links. ### Non-blocking findings (in rough order) 3. **[MEDIUM] Infinite scroll probably never fires.** `layout.templ:162` uses `hx-trigger="revealed"`, but the list scrolls inside `.nr-scroll { overflow-y: auto }` (`reader.css:265`). htmx docs say to use `intersect once` for overflow containers. The load-more click still works. Not checked in a browser. 4. **[MEDIUM] Reader pane and action responses render with an empty `query{}`.** `web.go:175,230`. After HTMX navigation, "Back to list" goes to `/` instead of the current feed and filters, and on a phone that is the only way back. A starred or read row swapped in from the list loses its `Selected` highlight and gets a `PageURL` without scope. 5. **[MEDIUM] An open `?entry=` that no longer exists 404s the whole page** (`view.go:90`). Expected: the list renders without the reader. 6. **[LOW] No CSRF or cross-origin check on the POST `/ui/` endpoints** (`web.go:58-62`). How serious this is depends on the kong/auth setup (task 6.1). `http.CrossOriginProtection` would close it cheaply. 7. **[LOW] Mark-all-read cutoff comes from the app clock** (`view.go:84`), while `first_seen_at` comes from Postgres `now()`. If the clocks drift, entries that arrive just after render get marked read. Small risk on one host. 8. **[LOW] Render errors are only logged** (`web.go:66-70`), so a partial 200 can be swapped in. The old smoke handler returned 500. 9. **[NIT] `ListFeeds` runs twice per page with `?entry=`, and once per row action.** `view.go:94` 10. **[NIT, test strength] The markdown sanitizer layer is untested.** With `Sanitize` removed from `renderer.markdown`, `TestReadingViewNeutralizesHostileContent` still passes, because goldmark's own escaping covers it. Removing `Sanitize` from `renderer.html` does make it fail (good). Consider a markdown case that only bluemonday catches, or document that goldmark is the first layer. ### Checklist items that pass Gate (tests, format, nogo, 5.1 ticked, no symlinks). The XSS test fails when HTML sanitizing is removed. No inline `<script>`. The only `templ.Raw` calls are the sanitized `BodyHTML` and the embedded `reader.css`. Read and star send the desired state, and `desired()` rejects missing or garbled values. ### Not covered - **No browser check:** I can't render pages, so 375px/desktop layout, light/dark, off-canvas sidebar, htmx scroll, URL push, back button and row refresh are all unverified. Finding 3 is from the code and the htmx docs, not from watching it run. - **Coverage >70% for `internal/web`:** not measured. Untested paths I noticed: render-error branches, the `?entry=` not-found page, feed routes with a leading slash. - `/code-review` findings 6–9 are taken from reading the code, without repros. ### Next owner **Linus Torvalds** fixes 1 and 2 (and 3–5 if cheap) on ICB-143. I re-review the new head with `/code-review` when ICB-143 is done again. Do not merge.
newsroom: fix feed routes with leading slash, sanitize article links
All checks were successful
Validate / validate (pull_request) Successful in 2m20s
Validate / validate (push) Successful in 2m23s
e268089eef
Stored feed routes start with '/', so /feed/{route...} and read-all never
matched a real feed. Links from feeds were wrapped in templ.SafeURL, letting
javascript: URLs through; pass plain strings so templ sanitizes them. The list
load-more trigger uses 'intersect once' because the list scrolls in an
overflow container.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Contributor

Verdict: PASS — PR #264 at e268089eef73127ca57d3fef917f1f48fafaf3a7 (re-review). I re-checked the PR head just before posting: unchanged, open, not merged, Forgejo CI Validate green on this head. Do not merge on my say-so; merging is the owner's call.

Both blockers from my first review (32d51ff) are fixed, and I checked that the tests catch them if the fix is reverted. What is left is non-blocking. Items 1–2 below are the ones worth a follow-up.

Success condition tested

Same as the first round: the ICB-144 plan, brief newsroom/tasks/14-web-ui.md, spec newsroom-ui, task 5.1. In addition: blocker 1 (feed views and read-all work with real /-prefixed routes) and blocker 2 (no javascript: article/original links) are fixed and covered by tests that fail without the fix.

Steps run

git worktree add --detach /tmp/pr264 e268089                    # separate worktree
/code-review high 32d51ff...e268089 (+ feed-route handling across origin/main...e268089)  -> 9 findings, triaged below
bazel test --config=remote --nocache_test_results --experimental_convenience_symlinks=ignore //newsroom/...
  -> Executed 19 out of 19 tests: 19 tests pass.   (incl. web/library/storage/serving integration tests)
Mutation A: restore templ.SafeURL on both links in layout.templ -> web_test FAILED
  (TestReadingViewNeutralizesHostileLinks: Needle "javascript:", Haystack "javascript:alert(1)")  -> reverted
Mutation B: drop the "/" prefix in inbox (web.go:101) -> web_test FAILED and web_integration_test FAILED
  (TestViewsOverRealStore/time_range_follows_first_seen_at, /mark_feed_read_respects_the_cutoff)  -> reverted
Throwaway probe test for GET /feed/ (deleted afterwards)
bazel run --experimental_convenience_symlinks=ignore //:format  -> exit 0; git status --short -> clean
git diff --raw origin/main...HEAD | awk '$2=="120000"' -> none; find . -type l -not -path './.git/*' -> none (PR worktree and workspace)
tasks.md: 5.1 ticked

Note: mutation A on the checked-in layout_templ.go proves nothing. //newsroom/internal/web:web compiles the output of :layout_templ_gen, so the mutation has to go in layout.templ, and that is where I ran it.

Earlier blockers: fixed

  1. Feed routes. /feed/{route...} and read-all now re-add the leading /, and query.path() builds /feed + route. Fixtures use real /golem/news routes. Integration test passes over Postgres. Mutation B is caught by both test targets.
  2. javascript: links. templ.SafeURL is dropped, so templ sanitizes the href. New TestReadingViewNeutralizesHostileLinks; mutation A is caught.
  3. (old #3) Load-more now uses intersect once, click. Not checked in a browser.

Remaining non-blocking findings (ranked)

  1. [MEDIUM, carried over: old #4] The reader pane and row actions render with an empty query{} (web.go:171, web.go:236). "Back to list" goes to /. A row re-rendered after star/read links to /?entry=N and loses its selected highlight. This hurts phone navigation most, since that is the only way back. Recommend a follow-up task (Linus asked; this is the owner's/Steve's call).
  2. [MEDIUM, carried over: old #5] A stale ?entry= 404s the whole page instead of rendering the list without the reader (view.go:90). Same follow-up.
  3. [LOW, new] Bare GET /feed/ now renders a feed titled /. Probe output: /feed/ -> 200 read-all="hx-post=\"/ui/feed//read-all\"" heading "/". Before this commit it showed All news. Nothing links to /feed/, so this only bites on hand-typed URLs. Fix: treat an empty wildcard as "no feed" or 404.
  4. [LOW, new] Read-all URL is not escaped like the page URL. layout.templ:102 concatenates "/ui/feed" + d.Feed, while query.path() uses url.URL.EscapedPath(). Only matters for routes with % escapes, which validateRoutePath allows but nobody uses today. A readAllURL() helper next to path() would keep the two in sync.
  5. [LOW, unverified] Rows are swapped out-of-band through <div hx-swap-oob="outerHTML:#entry-N"> (layout.templ:263, already present before this commit). With htmx 2 semantics, the wrapper div replaces the row and wrappers pile up. Goshtoso ships htmx 4.0.0, and I could not confirm how v4 handles this without a browser.
  6. [LOW, carried over] No CSRF/cross-origin check on the POST /ui/ endpoints (depends on 6.1 auth). The read-all cutoff uses the app clock. Render errors are only logged.
  7. [NIT] A sanitized link renders as a dead about:invalid#TemplFailedSanitizationURL "Open article" button rather than being hidden. The sidebar now shows the leading / in feed names (/golem/news 60). The route == "/" guard in readAll is effectively dead code. The markdown bluemonday layer still has no test that fails without it.

I dropped one /code-review claim: that the unit tests can't catch the leading-slash bug. Mutation B fails web_test too, through TestMarkFeedReadUsesRenderCutoff.

Not covered

  • No browser: 375px/desktop layout, light/dark, off-canvas sidebar, infinite scroll (intersect once), URL push, back button and the OOB row swap (finding 5) are all unverified.
  • Coverage for internal/web: not measured. Untested paths I know of: render-error branches, the ?entry= not-found page, bare /feed/, feed-scoped /ui/entries?feed=… load-more.
  • Findings 4–6 come from reading the code; finding 3 has a repro.

Next owner

Nothing blocks this PR. The owner decides on merging. Steve Wozniak decides whether findings 1–2 go into a follow-up task (recommended) or into this PR. If they go into this PR, I re-review with /code-review.

**Verdict: PASS** — PR [#264](https://code.icb4dc0.de/prskr/tools/pulls/264) at `e268089eef73127ca57d3fef917f1f48fafaf3a7` (re-review). I re-checked the PR head just before posting: unchanged, open, not merged, Forgejo CI `Validate` green on this head. **Do not merge on my say-so; merging is the owner's call.** Both blockers from my first review (`32d51ff`) are fixed, and I checked that the tests catch them if the fix is reverted. What is left is non-blocking. Items 1–2 below are the ones worth a follow-up. ### Success condition tested Same as the first round: the ICB-144 plan, brief `newsroom/tasks/14-web-ui.md`, spec `newsroom-ui`, task 5.1. In addition: blocker 1 (feed views and read-all work with real `/`-prefixed routes) and blocker 2 (no `javascript:` article/original links) are fixed and covered by tests that fail without the fix. ### Steps run ``` git worktree add --detach /tmp/pr264 e268089 # separate worktree /code-review high 32d51ff...e268089 (+ feed-route handling across origin/main...e268089) -> 9 findings, triaged below bazel test --config=remote --nocache_test_results --experimental_convenience_symlinks=ignore //newsroom/... -> Executed 19 out of 19 tests: 19 tests pass. (incl. web/library/storage/serving integration tests) Mutation A: restore templ.SafeURL on both links in layout.templ -> web_test FAILED (TestReadingViewNeutralizesHostileLinks: Needle "javascript:", Haystack "javascript:alert(1)") -> reverted Mutation B: drop the "/" prefix in inbox (web.go:101) -> web_test FAILED and web_integration_test FAILED (TestViewsOverRealStore/time_range_follows_first_seen_at, /mark_feed_read_respects_the_cutoff) -> reverted Throwaway probe test for GET /feed/ (deleted afterwards) bazel run --experimental_convenience_symlinks=ignore //:format -> exit 0; git status --short -> clean git diff --raw origin/main...HEAD | awk '$2=="120000"' -> none; find . -type l -not -path './.git/*' -> none (PR worktree and workspace) tasks.md: 5.1 ticked ``` Note: mutation A on the checked-in `layout_templ.go` proves nothing. `//newsroom/internal/web:web` compiles the output of `:layout_templ_gen`, so the mutation has to go in `layout.templ`, and that is where I ran it. ### Earlier blockers: fixed 1. **Feed routes.** `/feed/{route...}` and read-all now re-add the leading `/`, and `query.path()` builds `/feed` + route. Fixtures use real `/golem/news` routes. Integration test passes over Postgres. Mutation B is caught by both test targets. 2. **`javascript:` links.** `templ.SafeURL` is dropped, so templ sanitizes the `href`. New `TestReadingViewNeutralizesHostileLinks`; mutation A is caught. 3. (old #3) Load-more now uses `intersect once, click`. Not checked in a browser. ### Remaining non-blocking findings (ranked) 1. **[MEDIUM, carried over: old #4] The reader pane and row actions render with an empty `query{}`** (`web.go:171`, `web.go:236`). "Back to list" goes to `/`. A row re-rendered after star/read links to `/?entry=N` and loses its selected highlight. This hurts phone navigation most, since that is the only way back. **Recommend a follow-up task** (Linus asked; this is the owner's/Steve's call). 2. **[MEDIUM, carried over: old #5]** A stale `?entry=` 404s the whole page instead of rendering the list without the reader (`view.go:90`). Same follow-up. 3. **[LOW, new] Bare `GET /feed/` now renders a feed titled `/`.** Probe output: `/feed/ -> 200 read-all="hx-post=\"/ui/feed//read-all\"" heading "/"`. Before this commit it showed All news. Nothing links to `/feed/`, so this only bites on hand-typed URLs. Fix: treat an empty wildcard as "no feed" or 404. 4. **[LOW, new] Read-all URL is not escaped like the page URL.** `layout.templ:102` concatenates `"/ui/feed" + d.Feed`, while `query.path()` uses `url.URL.EscapedPath()`. Only matters for routes with `%` escapes, which `validateRoutePath` allows but nobody uses today. A `readAllURL()` helper next to `path()` would keep the two in sync. 5. **[LOW, unverified]** Rows are swapped out-of-band through `<div hx-swap-oob="outerHTML:#entry-N">` (`layout.templ:263`, already present before this commit). With htmx 2 semantics, the wrapper div replaces the row and wrappers pile up. Goshtoso ships **htmx 4.0.0**, and I could not confirm how v4 handles this without a browser. 6. **[LOW, carried over]** No CSRF/cross-origin check on the POST `/ui/` endpoints (depends on 6.1 auth). The read-all cutoff uses the app clock. Render errors are only logged. 7. **[NIT]** A sanitized link renders as a dead `about:invalid#TemplFailedSanitizationURL` "Open article" button rather than being hidden. The sidebar now shows the leading `/` in feed names (`/golem/news 60`). The `route == "/"` guard in `readAll` is effectively dead code. The markdown bluemonday layer still has no test that fails without it. I dropped one `/code-review` claim: that the unit tests can't catch the leading-slash bug. Mutation B fails `web_test` too, through `TestMarkFeedReadUsesRenderCutoff`. ### Not covered - **No browser:** 375px/desktop layout, light/dark, off-canvas sidebar, infinite scroll (`intersect once`), URL push, back button and the OOB row swap (finding 5) are all unverified. - **Coverage for `internal/web`:** not measured. Untested paths I know of: render-error branches, the `?entry=` not-found page, bare `/feed/`, feed-scoped `/ui/entries?feed=…` load-more. - Findings 4–6 come from reading the code; finding 3 has a repro. ### Next owner Nothing blocks this PR. **The owner** decides on merging. **Steve Wozniak** decides whether findings 1–2 go into a follow-up task (recommended) or into this PR. If they go into this PR, I re-review with `/code-review`.
prskr approved these changes 2026-10-14 17:39:44 +00:00
prskr merged commit e268089eef into main 2026-10-14 17:39:47 +00:00
prskr deleted branch ICB-143-newsroom-5-1-web-ui-inbox-layout-list-reader-actions 2026-10-14 17:39:47 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prskr/tools!264
No description provided.