From 8fcc705e2c5dc8ce342e30cfc80a1a899bc6cf72 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Sat, 13 Jun 2026 14:49:15 +0700 Subject: [PATCH] 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 --- app/actions/generate-key.js | 6 ++++-- app/globals.css | 6 ++++++ app/layout.js | 2 +- components/site-header.js | 2 +- lib/supabase/server-client.js | 4 ++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/actions/generate-key.js b/app/actions/generate-key.js index b17c8af..b9d871b 100644 --- a/app/actions/generate-key.js +++ b/app/actions/generate-key.js @@ -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." }, diff --git a/app/globals.css b/app/globals.css index 5003ea3..d1c898b 100644 --- a/app/globals.css +++ b/app/globals.css @@ -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); diff --git a/app/layout.js b/app/layout.js index b030363..5263ffa 100644 --- a/app/layout.js +++ b/app/layout.js @@ -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 */ diff --git a/components/site-header.js b/components/site-header.js index 4d8783a..3f5d023 100644 --- a/components/site-header.js +++ b/components/site-header.js @@ -23,7 +23,7 @@ export async function SiteHeader() { llmapikey -