Skip to content

[luv-337] fix: route Gemini sessions by full UUID, not 8-char filename prefix#336

Merged
NiveditJain merged 2 commits into
mainfrom
luv-337
May 10, 2026
Merged

[luv-337] fix: route Gemini sessions by full UUID, not 8-char filename prefix#336
NiveditJain merged 2 commits into
mainfrom
luv-337

Conversation

@NiveditJain
Copy link
Copy Markdown
Member

@NiveditJain NiveditJain commented May 9, 2026

Summary

  • Gemini sessions linked from the dashboard project page were 404ing because SessionFile.sessionId carried only the 8-hex prefix from the filename, but the session detail route at app/project/[name]/session/[sessionId]/page.tsx:42 rejects non-UUIDs and calls notFound(). Hooks-section links worked because hook stdin carries the full UUID.
  • lib/gemini-projects.ts scanGeminiSessions() now reads each JSONL's metadata header (line 1, ~1 KB) via a new async readFirstLine helper — same pattern as lib/codex-projects.ts:46-62 — parses meta.sessionId, validates against a local UUID_RE, and plumbs the full UUID through GeminiSessionMeta.sessionId into both getGeminiSessionsForCwd and getGeminiSessionsByEncodedName.
  • When the header is missing, malformed, or carries a non-UUID sessionId, the field stays undefined so the row renders un-linked (SessionsList already handles this) rather than producing a clickable 404.

Test plan

  • bun run test:run __tests__/lib/gemini-projects.test.ts — 4 new cases pass (full-UUID propagation, malformed JSON, missing field, non-UUID value)
  • bun run test:run — full unit suite (1577 tests) passes
  • bun run test:e2e __tests__/e2e/hooks/gemini-integration.e2e.test.ts — 18 e2e tests pass
  • bunx tsc --noEmit clean
  • bun run lint clean (only pre-existing <img> warning)
  • Manual UI: bun run dev/projects → click a Gemini-only project → click a session row → entries view loads (URL contains the full UUID, not the 8-char prefix)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Resolved session routing failures that returned 404s when opening session details.
    • Session links now use complete session identifiers so detail pages resolve correctly.
  • Tests

    • Added tests covering extraction and validation of session identifiers from session metadata.

Review Change Stack

…e prefix

Gemini sessions linked from the dashboard project page were 404ing because
`SessionFile.sessionId` was pulled from the filename regex match group
(8-hex prefix), but the session detail route at
`app/project/[name]/session/[sessionId]/page.tsx:42` rejects non-UUIDs and
calls `notFound()`. The same sessions loaded fine from the hooks/activity
table because hook stdin carries the full UUID directly.

Fix: in `lib/gemini-projects.ts` `scanGeminiSessions()`, read the JSONL
metadata header (line 1, ~1 KB) via a new async `readFirstLine` helper —
mirrors the pattern in `lib/codex-projects.ts:46-62`. Parse `meta.sessionId`
and validate against a local `UUID_RE`, then plumb the full UUID through
`GeminiSessionMeta.sessionId` to both `getGeminiSessionsForCwd` and
`getGeminiSessionsByEncodedName`. When the header is missing, malformed,
or carries a non-UUID value, leave `sessionId` undefined so the row
renders un-linked (`SessionsList` already handles this) rather than
producing a clickable 404 link.

New unit suite `__tests__/lib/gemini-projects.test.ts` pins all four
behaviors (full-UUID propagation, malformed JSON, missing field,
non-UUID value).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 49bbb110-239d-4e5e-ac59-dd8c6001efff

📥 Commits

Reviewing files that changed from the base of the PR and between b987db0 and 4ede867.

📒 Files selected for processing (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

📝 Walkthrough

Walkthrough

Reads full UUID sessionId from each Gemini JSONL file’s first-line metadata header, validates it, populates GeminiSessionMeta.sessionId during scan, uses that value in session listing APIs, adds helpers for bounded-first-line reads and parsing, includes Vitest coverage for valid and edge cases, and updates CHANGELOG.md.

Changes

Gemini Session UUID Extraction

Layer / File(s) Summary
Type Schema
lib/gemini-projects.ts
GeminiSessionMeta extended with optional sessionId field from JSONL metadata header.
Constants & Imports
lib/gemini-projects.ts
Add fs usage, full-UUID regex pattern, and capped byte limit for reading the first JSONL line.
Extraction Helpers
lib/gemini-projects.ts
readFirstLine() reads a bounded first line; extractFullSessionId() parses metadata JSON and validates sessionId as a full UUID.
Session Scanning
lib/gemini-projects.ts
Directory traversal invokes helpers to compute and attach sessionId to each GeminiSessionMeta.
API Integration
lib/gemini-projects.ts
getGeminiSessionsForCwd() and getGeminiSessionsByEncodedName() populate returned SessionFile.sessionId from parsed metadata instead of filename prefix.
Test Harness
__tests__/lib/gemini-projects.test.ts
Temporary GEMINI_SESSIONS_DIR setup, metadata header builder, and lifecycle management for tests.
Test Cases
__tests__/lib/gemini-projects.test.ts
Tests verify full UUID extraction, malformed JSON => undefined, missing sessionId => undefined, and non-UUID sessionId => undefined.
Documentation
CHANGELOG.md
Added 0.0.10-beta.10 Fixes entry documenting JSONL metadata header UUID extraction for session routing.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 In the first line the true ID hides,
Not the short name where confusion resides.
I hop through JSONL, nibble the key,
Full UUID found — routes now agree,
No more 404s, rejoice — hop, hop, we’re free! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main fix: routing Gemini sessions by full UUID instead of filename prefix.
Description check ✅ Passed The description comprehensively explains the problem, solution, and testing, though the manual UI verification checklist item remains incomplete.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Line 6: The changelog entry in CHANGELOG.md incorrectly references PR number
(`#337`); update that entry so the trailing PR suffix matches this PR (`#336`).
Locate the line that reads "Read full session UUID... (`#337`)" and replace the PR
number with (`#336`) to comply with the one-line entry format used throughout the
changelog.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fdaa9d9f-24e0-47ba-ac9b-f9c8a35f5b84

📥 Commits

Reviewing files that changed from the base of the PR and between 3703ff0 and b987db0.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • __tests__/lib/gemini-projects.test.ts
  • lib/gemini-projects.ts

Comment thread CHANGELOG.md Outdated
CodeRabbit caught the mismatch on PR #336.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@NiveditJain NiveditJain merged commit 9f0b14b into main May 10, 2026
9 checks passed
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.

1 participant