newsroom 5.1: Web UI — inbox layout, list, reader, actions (ICB-143) #264
No reviewers
Labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
prskr/tools!264
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ICB-143-newsroom-5-1-web-ui-inbox-layout-list-reader-actions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Task 5.1 of OpenSpec change
newsroom.What
/,/feed/{route...},/provider/{name},/entry/{id}; filters, cursor and open entry live in query params.sidebar, unread badges, off-canvas at phone width), stickytoolbarwith state + time-range filters as plain GET links, list withrevealedinfinite scroll plus visible Load more.hx-get /ui/entry/{id}+hx-push-url; full load withentry=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.mshortcut: one Alpine@keydown.windowhandler clicking the mark-read button, ignores input/textarea/select/contenteditable; key shown with Goshtosokbd.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) andgithub.com/microcosm-cc/bluemonday(sanitizer; untrusted feed/extractor HTML). Sanitized output is the only thing passed totempl.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.Not done / caveats
reader.css; needs a human or Grace pass.bazel run //:formatcould not run here (gitdubious ownershipinside the bazel sandbox);gofmtis clean.bazel coveragenot measured (no C toolchain).HX-Refresh..nogo.json: contextcheck excluded fornewsroom/internal/web/web.go(it follows templ component constructors into Goshtoso's button and flags handler call sites; generated code was already excluded).🤖 Generated with Claude Code
Verdict: CHANGES REQUESTED (FAIL) — PR #264 at
32d51ff18a43bcd7e93c843c84ba7abb8c3045b9(PR head re-checked just before posting; Forgejo CIValidateis 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, specnewsroom-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
Blocking findings
1. [HIGH] Feed views and Mark-all-read never match a real feed.
query.go:72,web.go:99-100,layout.templ:102config.JoinedRoute, which always starts with/(config/route.gojoinRoute;storage/store.go:97upserts it). Sidebar links become/feed//golem/news. ServeMux 301-redirects to/feed/golem/news, soPathValue("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-alland callsMarkFeedRead("golem/news"), which marks 0 rows.Route: "/golem/news"):web_test.go:171-178andweb_integration_test.go:94-95usegolem/newswithout 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 realJoinedRoutevalues.2. [HIGH, security]
javascript:feed links are rendered unsanitized.layout.templ:281,283templ.SafeURL(d.Article.Link)/OriginalLinkturns off templ's URL sanitizing.feed/feed.go:226-227storesitem.Linkfrom the remote feed with no scheme check. Repro (stub entry,GET /entry/9):target=_blank rel=noopenerlimits 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 sanitizeshrefstrings) or only allow http/https. Add an XSS test case for the links.Non-blocking findings (in rough order)
layout.templ:162useshx-trigger="revealed", but the list scrolls inside.nr-scroll { overflow-y: auto }(reader.css:265). htmx docs say to useintersect oncefor overflow containers. The load-more click still works. Not checked in a browser.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 itsSelectedhighlight and gets aPageURLwithout scope.?entry=that no longer exists 404s the whole page (view.go:90). Expected: the list renders without the reader./ui/endpoints (web.go:58-62). How serious this is depends on the kong/auth setup (task 6.1).http.CrossOriginProtectionwould close it cheaply.view.go:84), whilefirst_seen_atcomes from Postgresnow(). If the clocks drift, entries that arrive just after render get marked read. Small risk on one host.web.go:66-70), so a partial 200 can be swapped in. The old smoke handler returned 500.ListFeedsruns twice per page with?entry=, and once per row action.view.go:94Sanitizeremoved fromrenderer.markdown,TestReadingViewNeutralizesHostileContentstill passes, because goldmark's own escaping covers it. RemovingSanitizefromrenderer.htmldoes 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 onlytempl.Rawcalls are the sanitizedBodyHTMLand the embeddedreader.css. Read and star send the desired state, anddesired()rejects missing or garbled values.Not covered
internal/web: not measured. Untested paths I noticed: render-error branches, the?entry=not-found page, feed routes with a leading slash./code-reviewfindings 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-reviewwhen ICB-143 is done again. Do not merge.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>Verdict: PASS — PR #264 at
e268089eef73127ca57d3fef917f1f48fafaf3a7(re-review). I re-checked the PR head just before posting: unchanged, open, not merged, Forgejo CIValidategreen 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, specnewsroom-ui, task 5.1. In addition: blocker 1 (feed views and read-all work with real/-prefixed routes) and blocker 2 (nojavascript:article/original links) are fixed and covered by tests that fail without the fix.Steps run
Note: mutation A on the checked-in
layout_templ.goproves nothing.//newsroom/internal/web:webcompiles the output of:layout_templ_gen, so the mutation has to go inlayout.templ, and that is where I ran it.Earlier blockers: fixed
/feed/{route...}and read-all now re-add the leading/, andquery.path()builds/feed+ route. Fixtures use real/golem/newsroutes. Integration test passes over Postgres. Mutation B is caught by both test targets.javascript:links.templ.SafeURLis dropped, so templ sanitizes thehref. NewTestReadingViewNeutralizesHostileLinks; mutation A is caught.intersect once, click. Not checked in a browser.Remaining non-blocking findings (ranked)
query{}(web.go:171,web.go:236). "Back to list" goes to/. A row re-rendered after star/read links to/?entry=Nand 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).?entry=404s the whole page instead of rendering the list without the reader (view.go:90). Same follow-up.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.layout.templ:102concatenates"/ui/feed" + d.Feed, whilequery.path()usesurl.URL.EscapedPath(). Only matters for routes with%escapes, whichvalidateRoutePathallows but nobody uses today. AreadAllURL()helper next topath()would keep the two in sync.<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./ui/endpoints (depends on 6.1 auth). The read-all cutoff uses the app clock. Render errors are only logged.about:invalid#TemplFailedSanitizationURL"Open article" button rather than being hidden. The sidebar now shows the leading/in feed names (/golem/news 60). Theroute == "/"guard inreadAllis effectively dead code. The markdown bluemonday layer still has no test that fails without it.I dropped one
/code-reviewclaim: that the unit tests can't catch the leading-slash bug. Mutation B failsweb_testtoo, throughTestMarkFeedReadUsesRenderCutoff.Not covered
intersect once), URL push, back button and the OOB row swap (finding 5) are all unverified.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.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.newsroom-cleanup: track open 5.1 review findings #265