Skip to content

fix: address the review of #56 - #65

Closed
uniqueg wants to merge 29 commits into
devfrom
fix/56-review-fixes
Closed

uniqueg wants to merge 29 commits into
devfrom
fix/56-review-fixes

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Fixes for the review of #56

Hi Chitransh! As you asked, here are the fixes for the review of #56. Since #56 landed in staging (now dev) with #61, this PR goes there. Each commit belongs to one point, so you can pick or drop single ones. You already fixed several points on your branch after 4dc60e1, so those are skipped here (see the table).

Review point → commit → status

Point Commit(s) Status
1. User tokens can go to unverified services e627bc5, 715e3ce, af77eec, 18a0225, 1a13dc0 Fixed: the WES list and the service-info route keep only entries verified in GET /verifications (same id, URL and type) with https URLs without user info. A registry without /verifications (404/405) gives no services; other errors give 502 instead of a cached empty list. A selected service that leaves the list is deselected
2. Access token readable by scripts – Already fixed in 960818f (httpOnly + /auth/api/token); 77ee55a adds a test for the httpOnly cookies
3. PR checks are gone – Mostly fixed in b210b21; the rest is in #60 (see below)
4. LICENSE deleted – Fixed in 859d470; abb7f8c makes the README say Apache-2.0 instead of MIT. pull_request_template.md stays deleted (your call)
5. Preview can't be used for testing – Not code: needs OIDC_REDIRECT_URI/APP_ORIGIN on the preview host and a registry with verified services. abb7f8c says in the README which host login works on
6. Hard-coded test TES server 3f464c3 a1e8a2e removed the rewrite; this drops the leftover "TEST SERVER" entry
7. TES unfinished a18fc0d, 715e3ce, 7c3bb6b Verified https TES list; /ga4gh/tes/v1 is no longer doubled. Not fixed: no token for TES, because @elixir-cloud/tes 1.0.1 can't send one yet (elixir-cloud-aai/cloud-components#443); the README says so
8. No renew and retry on 401 a6d1bdb, 4e43d71, aea923f, 0630f18, c3c83f0, 86c939e Fixed: renew once, retry once. If the session can't be renewed, a toast asks to log in again; if the service rejects the renewed token too, the toast says the service doesn't accept the login. The refresh timer and the provider share one refresh request, so a rotating refresh token is used only once
9. No tests 3c5bbe4, 2d6e049, 7cacc34, abd2535 + tests in each commit Vitest unit and integration tests for everything changed here (fixtures and mocks only, no real services)
10. Scope and tracking – Not code
11. Examples known to run – Not code: needs runs against real WES services
12. Open Sourcery thread – Already resolved
Small: health reason twice 609e69c Fixed
Small: join(", v") 1e33086 Fixed: versions are shown as the service lists them
Small: second logout check on refresh 77ee55a, c3c83f0 Removed (it could never differ from the first), with a comment why
Small: README (VITE_HOST_URI, old login URL, logo) abb7f8c Fixed
Small: Bun 1.2.21 vs 1.3.14 – Left to #60, which aligns packageManager and the Dockerfile
Small: shadcn as production dependency f001de1 Moved to devDependencies (it's only needed at build time); bun audit --prod --audit-level=high finds nothing

Update 2026-11-14: merged dev

After the branch rename (staging → dev), I merged dev (044e328: CI from #60, env file checks from #68; one README conflict, resolved by keeping this PR's login-host note and adding where to set the two variables). Your tests from #63 had also come in with the earlier merge of staging, and the two suites didn't fit together yet, so four follow-up commits reconcile them:

  • 4c38fe0 build: regenerate the lockfile after the merge: the earlier merge had joined the two bun.lock files line by line and lost the semver 7 that make-dir needs, so bun run test:coverage crashed. Now dev's lockfile with shadcn moved to the dev dependencies.
  • 9f896a4 test: move the unit tests next to the code: your Vitest config runs src/**/*.test.ts only, so this PR's tests/ no longer ran. They're now next to the code (src/lib/*.test.ts, src/stores/stores.test.ts, fixtures in src/test/registry.ts using the helpers of src/test/routes.ts), plus a few cases for the 100% threshold.
  • c0c0222 test: check verified lists in the route tests: your route tests expected the behaviour before these fixes (no verifications, registry errors passed on as is). They now check the verified lists, and this PR's integration tests are folded into them and removed. The URL checks in the WES list that fetchVerifiedServices() already makes are removed (they were unreachable); the service-info route keeps its checks as a second line of defence, minus an unreachable try/catch. Your test "drops the new tokens after a logout during the refresh" is removed together with the second logout check (77ee55a): cookies() holds this request's cookies, so another request's logout can't change them. Tell me if you'd rather keep the check and the test. The mock registry of the end-to-end tests now serves /verifications and an unverified entry, which the journey test expects to be dropped.
  • 852d184 test: tidy the route tests after the review: shared registry request options in src/test/routes.ts, consistent helper names, comments; the service-info route drops its own https and user-info checks, which fetchVerifiedServices() already makes (it keeps port and path checks).

How it was verified

After merging dev (852d184):

  • bun run test:coverage: 17 files, 170 tests pass, 100% coverage (dev's threshold)
  • bun run test:e2e (Playwright, Chromium and Firefox, includes next build): 22 tests pass
  • bun run lint (Biome), bunx next typegen + bunx tsc --noEmit: clean
  • bun audit --prod --audit-level=high: no vulnerabilities
  • Not run: a real login, real TES/WES requests
  • CI on 852d184: CI passed green (lint, type check, build, audit, image build and scan; push and publish skipped on PRs as intended), Sourcery passes, Vercel preview deployed. Note: the CI workflow on dev has no job for bun run test or the end-to-end tests yet, so the test results above are local only

Before the merge: see the history of this description (51 Vitest tests, build, audit; no CI for PRs to staging then).

Declined review findings

From the reviews of the merge follow-ups (adversarial and quality reviewer subagents, 2 rounds, no high or medium findings left):

  • One shared mock-registry helper for the three route tests: kept a helper per test file, like dev's other route tests; the shared part (request options) is in src/test/routes.ts.

From the reviews before the first push:

From the reviews before pushing (adversarial and quality reviewer subagents):

  • The service-info route allows fewer URLs than the list (no explicit port, path must end in /ga4gh/wes/v1). That's the route's existing stricter check from feat: rewrite workflow execution using Cloud Components (#42)  #56; unifying the two URL policies is a design choice, so I left it for you.
  • Run bun run test in CI: CI files belong to ci: check PRs and publish images #60, see above.
  • Test the toasts of handleUnauthorized: UI copy only; the provider tests cover which outcome is reported.
  • The WES route still checks CLOUD_REGISTRY_URL itself before calling the registry module: harmless duplicate, kept to keep the diff small.
  • A WES service that never accepts Krini's token gets a session renewal before each failing request (round 2, low). Remembering a rejected token per provider would avoid that; I left it out to keep the retry logic simple, but happy to add it if you want.
  • Casts in filterVerifiedServices: registry entries are untyped JSON; the function checks the fields it relies on.

From Sourcery on this PR (fixed: renewal timeout in 86c939e, malformed verification list in 1a13dc0; answered and resolved in the threads):

  • Revoked services stay in the cached list until it expires (WES and TES): caching is by design (feat: browse services from a registry #40); a service that leaves the list is deselected on the next load. Faster revocation is a trade-off for you.
  • Renewals in several tabs at once: this PR coordinates renewals within a tab; cross-tab coordination is a bigger change, better done separately.
  • Non-default ports in the service-info route: same as the first point above.

Open questions

None.

🤖 Generated with Claude Code

https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV

Summary by Sourcery

Secure registry-backed WES and TES access while making session renewal and service discovery resilient.

New Features:

  • Add verified-service filtering for WES and TES registry entries before exposing them to users.
  • Retry WES requests once after renewing the session when services return 401 responses, with user-facing handling for renewal and token rejection failures.
  • Add Vitest unit and integration coverage for registry filtering, authentication renewal, service routes, stores, and TES URL handling.

Bug Fixes:

  • Prevent unverified, insecure, changed, or malformed registry services from receiving user tokens or appearing in service lists.
  • Clear selected WES and TES services when they are no longer present in the verified registry list.
  • Correct TES API URL construction to avoid duplicated paths and remove the leftover test server entry.
  • Remove duplicated health-reason and version formatting output.

Enhancements:

  • Centralize registry service discovery and session/token handling.
  • Coordinate concurrent session renewals so rotating refresh tokens are used only once.
  • Move shadcn to development dependencies and document current authentication, registry, TES, and testing behavior.

Documentation:

  • Update setup and deployment documentation for OIDC host configuration, verified registries, Apache-2.0 licensing, TES token limitations, and WES authentication retry behavior.

Tests:

  • Add automated tests covering verified service discovery, registry failures, token renewal and retry behavior, secure cookies, selection cleanup, and TES URL normalization.

Chores:

  • Update the README logo reference and remove obsolete login and test-server references.

uniqueg and others added 21 commits November 12, 2026 06:54
Adds Vitest with a Node environment and a test script, so that the
fixes for the review of #56 come with tests (review point 9). The
tests use fixtures and mocks only.

The config is a subset of the one on chore/add-tests-and-docs; on a
conflict, that branch's config can win.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, point 1: the WES list filtered only on type.artifact,
so the user's token could go to any registered service. Krini now
reads GET /verifications next to GET /services (without a token) and
keeps entries verified with the same identifier, URL and type, with
an https URL without user info. A registry without /verifications
yields no services. The service-info route uses the same list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, point 8 (#44, step 3): on a 401, the WES provider now
renews the session through the refresh route once and retries the
request once. If that fails too, a toast asks the user to log in
again. Concurrent renewals share one refresh request, so a rotating
refresh token is used only once.

The provider moves to src/lib/token-wes-provider.ts to be testable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Vite's native config loader doesn't support __dirname in .mts files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, point 8: document the renew and retry of WES requests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, point 7 (#41): the TES list now uses the same verified
registry list as WES (verified entries with https URLs only), and
/ga4gh/tes/v1 is added to a service URL only if it's missing, so
registry URLs that include it no longer get it twice.

Not fixed: @elixir-cloud/tes 1.0.1 can't send the user's token yet
(cloud-components#443); the README says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, point 6 (#40, step 5): a1e8a2e removed the /tes-api
rewrite and the default selection, but the selector still offered
"TEST SERVER" at /tes-api, which now leads nowhere.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, small points: the selector rendered the reason of an
unreachable service twice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, small points: join(", v") added a "v" to every version
but the first. The versions are now shown as the service lists them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, small points: cookies() returns the cookies of the
incoming request, so the second read of logout_marker could never
differ from the first. Adds tests for the logout check and the
httpOnly token cookies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, small points: the README still mentioned VITE_HOST_URI,
the old login.elixir-europe.org and a logo this branch deletes. It now
points to the LS Login URL, explains which host login works on, uses
public/logo.svg, and names the Apache License 2.0 that LICENSE holds
(instead of MIT).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, small points: shadcn is the CLI that generates the UI
components and provides a stylesheet imported at build time; the app
doesn't need it at runtime, and it was the path of the bun audit
advisories. bun audit --prod --audit-level=high finds nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, point 8, follow-up: the refresh timer posted to the
refresh route on its own, so it could use a rotating refresh token at
the same time as a renewal after a 401. Both now use renewSession() in
src/lib/session.ts, which runs one request at a time.

If a WES service rejects the renewed token too, Krini now says that
the service doesn't accept the login, instead of asking to log in
again. Adds a test that the form body is sent again on the retry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, points 1 and 7, follow-up: after a refresh of the list,
a service whose verification was removed stayed selected, and requests
with the user's token kept going to it. The WES and TES stores now
clear the selection if the new list doesn't have it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, point 7, follow-up: the TES list route reads the
registry without a token and no longer returns 401, so the "Login to
fetch TES servers" branch can't be reached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, point 8, follow-up: an expired session asks to log in;
a renewed token that is rejected too gets its own message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, point 1, follow-up: any failure of GET /verifications
gave an empty list, which the WES route then cached for a minute. Now
only 404 and 405 (a registry without the endpoint) give no services;
other errors, e.g. timeouts and 5xx, fail the request (502), so a short
registry outage doesn't hide all services.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, point 1, follow-up: tests that the route fetches the
service info of verified services only, and returns 500 like the other
routes if CLOUD_REGISTRY_URL is missing (was 502). The accepted
artifacts are now shared constants of src/lib/registry.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Review of #56, points 8 and small points, follow-up: the retry test now
checks the form fields of both requests and that the call succeeds,
and the refresh route says why one logout check is enough.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
next build type-checks the tests and couldn't call the union of the
two store types.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
krini Ready Ready Preview Nov 14, 2026 6:54pm UTC

@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Clear WES and TES selections when a refreshed service list no longer contains the selected URL.

  • src/stores/tes.ts L19-27
  • src/stores/wes.ts L20-28

API

Use verified registry entries for TES discovery, WES discovery, and WES service-info lookup, with explicit handling for registry configuration and failures.

  • src/app/api/tasks/get-tes-servers/route.ts L2-26
  • src/app/api/workflows/get-service-info/route.ts L4-8, L33-36, L69-75 (+2 small edits)
  • src/app/api/workflows/get-wes-servers/route.ts L4, L30-31, L128-130

Keep refresh-cookie validation tied to the incoming request and remove the redundant second logout-marker check.

  • src/app/auth/api/refresh/route.ts L18-19, L69 (removed lines)

Uses of the API

Use the shared session-renewal flow for WES requests and surface distinct messages when renewal fails or the service rejects the renewed token.

  • src/hooks/use-token-refresh.ts L4, L24-29
  • src/hooks/use-wes-provider.ts L1-28, L44-48

Normalize selected TES service URLs before passing them to the TES client and remove the obsolete hard-coded test-server option.

  • src/app/dashboard/tasks/_components/ecc-tes-create-run-wrapper.tsx L3, L32
  • src/app/dashboard/tasks/_components/ecc-tes-run-wrapper.tsx L3, L32
  • src/app/dashboard/tasks/_components/tes-server-list.tsx L37-39, L103 (removed lines)

Implementation

Centralize registry URL validation, verification matching, artifact filtering, and bounded public registry requests for service discovery.

  • src/lib/registry.ts L1-146

Provide a shared same-origin token lookup and single-flight, time-limited session renewal for the refresh timer and WES requests.

  • src/lib/session.ts L1-51

Implement the WES provider's bearer-token requests, one renewal and retry after 401, and unauthorized outcome reporting.

  • src/lib/token-wes-provider.ts L1-62

Construct a TES API base URL without duplicating its API path.

  • src/lib/tes.ts L1-11

UI

Remove duplicate WES health text and display workflow versions as supplied by the service.

  • src/app/dashboard/workflows/_components/wes-server-list.tsx L193 (removed lines), L242
  • src/app/dashboard/workflows/_components/workflow-validator.tsx L113

Configuration

Move the shadcn CLI from runtime dependencies to development dependencies.

  • package.json L28 (removed lines), L41

Documentation

Update the README for the local logo, OIDC host requirements, registry verification behavior, TES token limitation, testing, and Apache-2.0 license.

  • README.md L38-47 (+6 small edits)

Document the one-time WES session renewal and retry behavior, including the two possible failure outcomes.

  • docs/deployment.md L236

Tests

Cover verified-service filtering, registry errors, TES and WES route behavior, and verified-service probing.

  • src/app/api/tasks/get-tes-servers/route.test.ts L19-34, L57-70, L100-122 (+5 small edits)
  • src/app/api/workflows/get-service-info/route.test.ts L25-34, L101-126, L178-190 (+10 small edits)
  • src/app/api/workflows/get-wes-servers/route.test.ts L24-39, L96-100, L223-254 (+7 small edits)
  • src/lib/registry.test.ts L1-165

Test shared session renewal, WES token retry behavior, TES URL normalization, selection cleanup, and refresh-cookie behavior.

  • src/app/auth/api/refresh/route.test.ts L7 (removed lines), L82-85, L151 (removed lines)
  • src/lib/session.test.ts L1-106
  • src/lib/tes.test.ts L1-19
  • src/lib/token-wes-provider.test.ts L1-131
  • src/stores/stores.test.ts L1-57

Provide shared registry fixtures and request-option helpers for route tests.

  • src/test/registry.ts L1-80
  • src/test/routes.ts L7, L60-66, L120

Exercise the mock registry's verification endpoint and assert that anonymous visitors see only verified secure services.

  • e2e/journey.spec.ts L27-28
  • e2e/mock/server.ts L6-7, L81-98, L216-221

Lock files and vendored code

Regenerate the Bun lockfile to match the dependency changes.

  • bun.lock L19-1112 (7 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@uniqueg
uniqueg marked this pull request as ready for review November 12, 2026 08:27
@uniqueg
uniqueg requested a review from AnonymousXC November 12, 2026 08:27

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 7 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/app/api/workflows/get-wes-servers/route.ts" line_range="145" />
<code_context>
-        );
+        // Only verified services: the selected one gets the user's token
+        const wesServices =
+            await fetchVerifiedServices<WESServer>(WES_ARTIFACTS);

         const results = await probeWithConcurrencyLimit(
</code_context>
<issue_to_address>
**Revoked WES services receive tokens**

When a WES service is revoked while the route's cache is fresh, the cache-hit branch returns the old list without rechecking verification, so the revoked service remains selectable and `TokenWesProvider` keeps sending the user's access token until the cache expires.

Recheck verifications before returning cached WES servers and remove revoked services from the cached result.

Also at `src/stores/wes.ts:21-28`.
</issue_to_address>

### Comment 2
<location path="src/app/api/workflows/get-wes-servers/route.ts" line_range="145" />
<code_context>
-        );
+        // Only verified services: the selected one gets the user's token
+        const wesServices =
+            await fetchVerifiedServices<WESServer>(WES_ARTIFACTS);

         const results = await probeWithConcurrencyLimit(
</code_context>
<issue_to_address>
**Revoked services keep receiving requests**

When a selected WES service is unverified while a dashboard remains open, the browser keeps its loaded list until a manual refresh, and the route can serve its 60-second cached list, so `setServers` does not clear the selection; `TokenWesProvider` continues attaching the user's token to a service whose verification was removed.

Revalidate the WES list periodically or before requests, and ensure revocation invalidates both the server cache and the client selection promptly.

Also at `src/stores/wes.ts:21-28`.
</issue_to_address>

### Comment 3
<location path="src/stores/tes.ts" line_range="19-27" />
<code_context>
     servers: [],
     serversLoaded: false,
-    setServers: (servers) => set({ servers, serversLoaded: true }),
+    // A server that left the verified list must not stay selected
+    setServers: (servers) =>
+        set(({ selectedServer }) => ({
+            servers,
+            serversLoaded: true,
+            selectedServer: servers.some((s) => s.url === selectedServer)
+                ? selectedServer
+                : null,
+        })),
 }));
</code_context>
<issue_to_address>
**Revoked TES services stay selectable**

When a selected TES service is revoked after the list has loaded and the user keeps the app open, `TESServerList` fetches the registry only while `serversLoaded` is false; after that, it returns without refreshing the list. A service revoked during the open app session therefore remains selected in the Zustand store, and the TES components continue sending requests to it.

Refresh the TES list periodically or on relevant navigation, and clear the selection whenever the current list cannot be revalidated.
</issue_to_address>

### Comment 4
<location path="src/lib/session.ts" line_range="29-40" />
<code_context>
+ * a rotating refresh token is used only once.
+ */
+export function renewSession(): Promise<boolean> {
+    pendingRenewal ??= fetch("/auth/api/refresh", {
+        method: "POST",
+        credentials: "same-origin",
+        cache: "no-store",
+    })
+        .then((response) => response.ok)
+        .catch(() => false)
+        .finally(() => {
+            pendingRenewal = null;
+        });
+
+    return pendingRenewal;
+}
</code_context>
<issue_to_address>
**Concurrent tabs invalidate sessions**

When two tabs renew the same rotating refresh token concurrently, `pendingRenewal` is shared only within one module instance, so both tabs submit the token; the identity provider rejects the replay, and the failed refresh route can clear cookies set by the successful response, leaving the user logged out or with an invalid refresh token.

Coordinate refresh-token renewals across tabs so only one request uses a rotating token at a time.

Also at `src/lib/token-wes-provider.ts:49-51`.
</issue_to_address>

### Comment 5
<location path="src/lib/session.ts" line_range="29-39" />
<code_context>
+ * a rotating refresh token is used only once.
+ */
+export function renewSession(): Promise<boolean> {
+    pendingRenewal ??= fetch("/auth/api/refresh", {
+        method: "POST",
+        credentials: "same-origin",
+        cache: "no-store",
+    })
+        .then((response) => response.ok)
+        .catch(() => false)
+        .finally(() => {
+            pendingRenewal = null;
+        });
+
+    return pendingRenewal;
+}
</code_context>
<issue_to_address>
**A stuck refresh blocks future renewals**

When the browser's request to `/auth/api/refresh` remains pending indefinitely, `renewSession` has no timeout or abort path, so a refresh fetch that never settles leaves `pendingRenewal` set indefinitely. The refresh timer and every WES request that receives a 401 then wait on that same promise instead of attempting another renewal or reporting a completed failure.

Bound the refresh fetch with a timeout or abort signal so the shared promise settles and can be cleared.
</issue_to_address>

### Comment 6
<location path="src/lib/registry.ts" line_range="69" />
<code_context>
+    verifications: unknown,
+    artifacts: readonly string[],
+): T[] {
+    if (!Array.isArray(services) || !Array.isArray(verifications)) return [];
+
+    const verified = new Map<string, ServiceVerification>();
</code_context>
<issue_to_address>
**Registry errors look like empty results**

When `GET /verifications` succeeds with a non-array payload, `filterVerifiedServices` returns an empty list, so the routes report success and the WES route caches that result; users see no services instead of a registry error.

Treat a non-array verification payload as an upstream error rather than returning an empty list.
</issue_to_address>

### Comment 7
<location path="src/app/api/workflows/get-service-info/route.ts" line_range="22" />
<code_context>
-                },
-            },
-        );
+        const servers = await fetchVerifiedServices<WESServer>(WES_ARTIFACTS);

         const server = servers.find((item) => item.id === id);
</code_context>
<issue_to_address>
**Non-default ports break service info**

When a verified WES service uses an HTTPS URL with a non-default port, `isAllowedServiceUrl` accepts the URL and the WES list route can probe it, but the service-info route rejects it because `parsedUrl.port` is nonempty, so the info link returns 400.

Allow the service-info route to accept verified HTTPS URLs with non-default ports.

Also at `src/lib/registry.ts:43`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 7 findings to address first, and after a WES service returns 401, Krini now refreshes the session and resends the request with the renewed bearer token to that same service. If the service-selection or retry trust is wrong, the remote service can retain the token and request data; reverting cannot retrieve them.

Blocking findings: src/app/api/workflows/get-wes-servers/route.ts:145, src/app/api/workflows/get-wes-servers/route.ts:145, src/stores/tes.ts:27, src/lib/session.ts:40, src/lib/session.ts:39, and 2 more


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/stores/tes.ts Resolved
Comment thread src/lib/session.ts Resolved
Comment thread src/lib/session.ts Resolved
Comment thread src/lib/registry.ts Resolved
uniqueg and others added 2 commits November 12, 2026 09:40
Sourcery on #65: a refresh request that never settled would keep the
shared renewal pending, so the refresh timer and every WES request
after a 401 would wait on it forever.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Sourcery on #65: a GET /verifications response that isn't a list gave
an empty, cached service list instead of a registry error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
@vercel
vercel Bot temporarily deployed to Preview – krini November 12, 2026 08:40 Inactive
uniqueg and others added 5 commits November 14, 2026 18:09
Brings in the CI workflow (#60) and the env file checks (#68). The
README note on the login host keeps the wording of this PR and adds
where to set the two variables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The merge of staging had joined the two lockfiles line by line and
dropped the semver 7 that make-dir needs, so the coverage report
crashed. This is dev's lockfile with shadcn moved to the dev
dependencies, as package.json has it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Vitest on dev runs only src/**/*.test.ts, so the tests of this PR in
tests/ no longer ran. They now sit next to the modules they test, the
fixtures in src/test/registry.ts share the registry URL and errors of
src/test/routes.ts, and new cases cover the branches that the 100%
threshold of dev requires.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The route tests from #63 expected the lists before the review fixes
(no verifications, errors passed on). They now cover the verified
lists and fold in the integration tests of this PR, which are
removed. The checks that the registry module already makes are gone
from the WES list and kept as a second line of defence in the
service-info route. The test of a logout during a refresh is gone
with the second check (77ee55a): cookies() returns the cookies of
the request, so a logout can't change them. The mock registry of the
end-to-end tests serves verifications and an unverified entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Share the registry request options in src/test/routes.ts, name the
helper parameters alike, document the fixtures and the call counts,
and say in the README that all Vitest tests are unit tests. The
service-info route drops its https and user-info checks: the
registry module makes them, and no request could reach them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – krini November 14, 2026 18:54 Inactive
@uniqueg

uniqueg commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

@AnonymousXC this is ready for your review: dev is merged in, CI is green, and the tests are reconciled with #63 (170 Vitest tests at 100% coverage, 22 Playwright e2e tests). Details are in the PR body. It's in the v0.1.0 milestone (due 2026-11-18), so a review early next week would be great. Thanks!

@AnonymousXC

Copy link
Copy Markdown
Contributor

Closing this PR since the code has evolved significantly since these changes were originally made, and the current implementation has diverged. There are also substantial merge conflicts, and resolving them would require reworking much of the existing code.

We can track any remaining review comments as separate issues and revisit them after the release, addressing them against the current codebase.

Thanks for work!

This branch was previously deployed

1 inactive deployment
Preview – krini — 852d1843 Deployed Nov 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants