refactor: simplify comments, styling, and conflict-resolution control flow

- replace stale plan-reference comments with intent-describing ones
- move inline nav style to a .site-nav CSS class
- drop dummy placeholder return in generate-key resolveConflict
This commit is contained in:
2026-06-13 14:49:15 +07:00
parent 02fa52ccf9
commit 8fcc705e2c
5 changed files with 14 additions and 6 deletions
+4 -2
View File
@@ -76,8 +76,10 @@ export async function generateKey() {
* Resolve a reserve() conflict: existing active key, reclaimable stale pending,
* or an in-progress request.
*
* Returns either a fresh reservation id to mint against, or a terminal result.
*
* @param {{ githubUserId: string, githubUsername: string }} identity
* @returns {Promise<{ reclaimedId?: string, result: GenerateKeyResult }>}
* @returns {Promise<{ reclaimedId?: string, result?: GenerateKeyResult }>}
*/
async function resolveConflict(identity) {
const row = await repo.findByGithubUserId(identity.githubUserId);
@@ -88,7 +90,7 @@ async function resolveConflict(identity) {
if (row && isStale(row.created_at, STALE_PENDING_MS)) {
await repo.deletePending(row.id);
const retryId = await repo.reserve(identity.githubUserId, identity.githubUsername);
if (retryId) return { reclaimedId: retryId, result: { status: "error" } };
if (retryId) return { reclaimedId: retryId };
}
return {
result: { status: "error", message: "A key request is already in progress. Try again shortly." },
+6
View File
@@ -52,6 +52,12 @@ header.site-header {
color: var(--text);
}
.site-nav {
display: flex;
align-items: center;
gap: 1rem;
}
.panel {
background: var(--panel);
border: 1px solid var(--border);
+1 -1
View File
@@ -9,7 +9,7 @@ export const metadata = {
};
/**
* Root layout. The session-aware header is added in Phase 3.
* Root layout wrapping every page with the session-aware site header.
*
* @param {{ children: React.ReactNode }} props
*/
+1 -1
View File
@@ -23,7 +23,7 @@ export async function SiteHeader() {
<Link href="/" className="brand">
llmapikey
</Link>
<nav style={{ display: "flex", gap: "1rem", alignItems: "center" }}>
<nav className="site-nav">
<Link href="/docs">Docs</Link>
{username ? (
<>
+2 -2
View File
@@ -5,8 +5,8 @@ import { cookies } from "next/headers";
/**
* Cookie-based Supabase client (anon key) for reading/refreshing the auth
* session on the server. Use this to know WHO the request is (Phase 3 identity),
* never to touch `api_keys` — that table lives in the unexposed `llmapikey`
* session on the server. Use this to know WHO the request is, never to touch
* `api_keys` — that table lives in the unexposed `llmapikey`
* schema and is reached only via the direct Postgres client (lib/db).
*
* In Server Components cookie writes throw; we swallow that — session refresh