Repository navigation
feat(web): identity-safe caches, relay and asset fixes, notifications, moderation, repository activity, workflow runs - #14
Open
anasfik wants to merge 15 commits into
Conversation
Scope Git clone/fetch storage and query keys to the signed-in viewer and configured Relay, bind NIP-98 authorization to the captured viewer namespace, and fail closed on any non-transport failure. Denied views now surface a localized alert and suppress private tree, log, README, blob, HTML and action surfaces. Add unit coverage for DB naming, signer binding and failure classification, a synthetic smart-HTTP browser fixture for real clone/fetch denial journeys, and pin the Inbox test clock to remove the demo fixture second-boundary race. Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
The /app/assets/* immutable Cache-Control header was matched by path alone and the catch-all try_files fallback rewrote a missing asset to /app/index.html, so a stale asset URL could be cached for a year as the SPA shell. Serve assets through an existence-checked file_server with a 404 fallback and add the check:caddy container-backed regression proof. Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the cache-isolation and missing-asset routing changes.
No open issues 🎉
What changed in this PR
This PR addresses two Web-client cache issues: repository data shared across identities and missing assets receiving an immutable-cached SPA shell. Relay and protocol behavior remain unchanged.
Changes:
- Scope repository caches by viewer and relay, bind Git authorization to the captured viewer, and clear query caches on sign-out.
- Hide cached repository content after access failures and display localized, accessible error messages.
- Return 404 for missing assets and add regression coverage for cache isolation, identity-switch races, denial handling, and Caddy routing.
| File | Description |
|---|---|
web/tests/e2e/smoke.spec.ts |
Fixes the clock for the Inbox test. |
web/tests/e2e/p0.spec.ts |
Tests cache isolation, denial handling, and localized error UI. |
web/tests/e2e/git-fixture.ts |
Adds a synthetic Git transport backed by real fixture repositories. |
web/src/shared/i18n/index.ts |
Adds English and Chinese repository-access errors. |
web/src/features/repos/use-repos.ts |
Scopes repository queries by viewer and requires a signer. |
web/src/features/repos/use-repo-refs.ts |
Scopes refs queries by viewer and requires a signer. |
web/src/features/repos/use-git-browse.ts |
Scopes browse queries and masks cached results after clone errors. |
web/src/features/repos/ui/ReposPanel.tsx |
Makes repository error banners accessible. |
web/src/features/repos/ui/RepoDetailPage.tsx |
Adds accessible alert semantics to detail-page errors. |
web/src/features/repos/ui/RepoBlobViewer.tsx |
Adds an accessible, styled file-error alert. |
web/src/features/repos/git-client.ts |
Isolates clone databases, validates signer identity, and restricts offline fallback. |
web/src/features/repos/git-client.test.ts |
Tests cache namespaces, authorization, and failure classification. |
web/src/features/repos/git-client.nip07-race.test.ts |
Tests identity changes during signing and rejection before transport. |
web/src/features/chat/ui/IdentityGate.tsx |
Clears the query cache before clearing the signer. |
web/scripts/check-caddy.mjs |
Adds container-based routing and cache-header checks. |
web/package.json |
Exposes the check:caddy command. |
web/Caddyfile |
Separates asset serving from SPA fallback and returns 404 for missing assets. |
Review effort: Balanced
…meout Bodyless NIP-98 requests skipped the nonce tag, so two identical signed GETs (for example the same Git ref advertisement) produced byte-identical events and the relay replay guard rejected the second one. Emit a fresh nonce for every signed request regardless of whether a payload is present. The agent-control start call aborted after 20s, but the control service can legitimately spend 25s on is-active, start, and is-active before it answers. Raise the client timeout to 35s to cover that worst case plus headroom for an operator proxy in front of the service. Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Only visible tabs used to raise a notification, and nothing suppressed a notification for activity the reader was already looking at. A hidden tab now raises at most one notification per channel for mentions, direct messages, thread replies, and needs-action items, and the service worker serializes the check-and-show so staggered tabs cannot both display the same event. Each notification carries a scope tag derived from the current identity and Relay, so a notification raised under one session is never reused after an identity or Relay change, and the copy stays generic: no sender, channel name, message text, Relay host, or count reaches the notification store. Cleanup runs when the scope, the read state, or the inbox contents change. Click routing validates the pushed target against the current identity before it opens anything, refuses channels this session did not load, and falls back to the Inbox rather than guessing a destination. Closed-tab delivery is still unsupported: there is no push subscription, no server-side sender, and no Relay-side endpoint, so a notification appears only while at least one tab is open. The Roadmap records that gap. Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Add a community moderation view that reads the Relay's moderator endpoints directly. The web client performs no moderation actions: reports, the audit log, and restricted-member rows are display-only. Access is gated by the Relay. The navigation entry appears for community owners and admins, and the Relay independently decides which rows are returned for the signed viewer. Every request is scoped to the viewer and the configured Relay URL, so responses for one identity or Relay are never reused for another. Nothing is persisted locally: the queue is fetched on demand and held in memory for the duration of the view. Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Render repository issues and pull requests from the real Relay event kinds: kind 1621 (issue root), kind 1618 (pull-request root), and kinds 1630-1633 as the status events that close, merge, apply, or draft them. The Relay does not index `#a`, so these events are joined in the browser to the repository announcements that are already loaded. The query is a bounded newest window of 200 events instead of a full history scan, and the UI states that window explicitly rather than presenting it as the complete record. Counts and empty states only claim absence when the join is complete: a saturated window, or a root naming a repository with no loaded announcement, yields an unknown count and an incomplete-state message instead of zero. Issue and pull-request text is Relay-wide, so this feature does not imply that repository Git access control applies to it; the copy says so directly. Status events are trusted only when published by the root author or the repository owner, because any Relay member with write access can publish an issue or a pull request. Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Enabling notifications during an inbox reload folded the newly arriving events into the seen set and silently suppressed them, because the enable paths seeded the arming from the in-flight item list instead of arming at once. Both the settings enable click and the cross-tab storage re-arm now use createEnabledArming, which starts already armed at the current one-second watermark so a load in flight cannot consume fresh events. A structural test pins both call sites, since the hook has no DOM harness in this suite. Limits: the watermark is whole seconds, so eligibility stays strictly newer than the enable second; events with future timestamps beyond it still depend on the relay clock matching the browser. Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Workflow definitions arrive from kind 30620 events with no write path, and run history is fetched on demand through the existing relay route for a single workflow. Approvals and authoring stay unshipped on purpose: the approval reference is a bearer capability and no producer exists for it yet. Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Parse the first usable kind-0 name instead of letting a blank display_name mask a valid name, and treat malformed or non-object metadata as empty. Keep known and configured names when newer metadata has no name, hydrate channel and message authors before history becomes visible, and use one localized Member/Agent fallback across chat, inbox, repos, and agent activity surfaces. Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Render cached messages before profile hydration, detach startup presence from the channel gate, bound HTTP queries, reject malformed relay events, and reuse agent metadata names. Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com>
Signed-off-by: Gwhyyy <anasfik@users.noreply.github.com> (cherry picked from commit 045e54c)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fifteen commits on top of upstream
main(9718473): two security and asset fixes, five earlier reliability fixes, seven features that fill in missing read-only surfaces, and one follow-up that hardens the workflow run-history gate. The browser stays a client of the existing Relay; this PR adds no server, schema, deployment, or credential changes.What ships
Cache isolation and asset fallback
/app/assets/*was matched by path alone and the catch-alltry_filesrewrote a missing asset to/app/index.html, so a stale asset URL could be cached for a year as the SPA shell. Assets now go through an existence-checkedfile_serverwith a 404 fallback, andnpm run check:caddyproves the contract against the container config.connect-srcnow allowsblob:so client-generated download URLs are not blocked.Requests and resilience
is-active+start+is-activeplus proxy headroom.canCreateChannelnow tracks the connection state, community-wide management is a separatecanManageCommunityrole check, and the channel browser, new-DM view, inbox, search, and settings surfaces receive the connection state instead of offering writes that cannot land. The mobile navigation close control takes focus when the drawer opens.display_namemask a valid name, malformed or non-object metadata is treated as empty, known and configured names survive newer nameless metadata, channel and message authors hydrate before history becomes visible, and one localized Member/Agent fallback is used across chat, inbox, repos, and agent activity.Notifications
Read-only surfaces
#a. The query is a bounded newest window of 200 events and says so; counts and empty states claim absence only when the join is complete, otherwise they report unknown/incomplete. Status events are trusted only from the root author or the repository owner, and the copy states that issue text is Relay-wide rather than governed by repository Git access.Workflow run-history cleanup
BuzzWebAppinto auseWorkflowGatehook. It still re-probes on every (re)connect, so a probe that answered on a stale socket recovers on the client's own reconnect instead of hiding the tool for the rest of the session. While the gate is unresolved and the session is connected, one one-shot kind 30620 subscription watches the definition stream and reveals the row on the first definition published mid-session, then tears itself down — no timers, no re-probe loop, nothing left running once the gate ispresent.aria-live="polite"androle="status"but moves off the destructive surface to the muted, ringed surface with an info icon, because the rows that could be read are still shown above it. Browser tests measure ink and icon contrast against the painted background at AA.All new user-facing copy has English and Simplified Chinese values, and the new surfaces were built against the existing navigation, panel, and i18n patterns.
Excluded on purpose
Verification
Run from
web/on this head (7906f59) with Node 24.14.0 and npm 11.9.0, no retries, no skipped tests, no relaxed assertions:npm run typechecktsc --noEmit, exit 0, no diagnosticsnpm testnpm run checknpm run buildtsc+vite buildsucceeded (1.69s)npx playwright test --project=workflowsgit diff --checknpm ciwas not rerun for the final commit:node_modulesis present andpackage-lock.jsonis unchanged by it, which touches onlyweb/srcandweb/tests.npm run check:caddyand the fullnpm run test:e2esuite were not rerun on this head — the Caddy config is untouched by this commit. The full suite passed 71 tests on the previous head (3a286c4), one commit behind this tree; that commit changes only the workflow feature and its spec, which the project run above covers.The unit-test count drops by one (210 → 209) because this cycle deletes the superseded gate-refinement unit test; the behaviour it covered is now asserted in the workflows browser project.
E2E covers the cache-isolation denial journeys, the asset-404 contract, notification dedupe and identity scoping across two tabs, moderation empty/denied/timeout/identity-switch states, repository activity joins and Chinese copy, and workflow definition/run states at 390px and desktop widths. The workflow project additionally covers reconnect recovery, mid-session reveal, and the dropped-rows notice contrast.
npm cireports 9 dependency advisories (4 moderate, 4 high, 1 critical) in the existing lockfile (vite,vitest,zod,nanoid,seroval,postcss-selector-parser,source-map-js,@tailwindcss/typography). They predate this PR and are untouched here; upgrading them is a separate change.Limits
30618) remain spoofable exactly as before, and Relay ACL gaps are unchanged; this PR does not add trust in announcements or tighten Relay authorization.