Skip to content

Fix/readme images and hydration#3

Merged
ziguifrido merged 9 commits into
mainfrom
fix/readme-images-and-hydration
Jun 21, 2026
Merged

Fix/readme images and hydration#3
ziguifrido merged 9 commits into
mainfrom
fix/readme-images-and-hydration

Conversation

@ziguifrido

@ziguifrido ziguifrido commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Fixes two issues: README images not rendering on the repository dashboard, and React hydration mismatches causing console errors.

Changes

README image rendering

  • Added default_branch to the GitHubRepository interface (src/lib/github.ts)
  • Registered raw.githubusercontent.com in images.remotePatterns (next.config.ts)
  • Installed rehype-raw to allow react-markdown to parse raw HTML in READMEs (many repos use tags instead of markdown image syntax)
  • Added a custom img component override that resolves relative image src paths to absolute raw.githubusercontent.com URLs (e.g. assets/logo.png → https://raw.githubusercontent.com/owner/repo/main/assets/logo.png)

Hydration error fixes

  • Replaced toLocaleDateString(undefined, …) with toLocaleDateString('en-US', …) in ViewRepo, ViewUser, and ViewSearch to ensure server and client produce identical date strings regardless of locale
  • Replaced the Base UI Button component with a native for the search submit — Base UI strips the native disabled attribute during SSR, causing a hydration attribute mismatch

Documentation

  • Updated README.md version badge, stack listing (added rehype-raw), and fixed the GitHub token env var name
  • Added version bump instructions to AGENTS.md

Summary by CodeRabbit

  • New Features
    • Improved README rendering to support raw HTML
    • Enabled safer README image loading from GitHub repository files
  • Improvements
    • Standardized date formatting across repository, user, and recent search displays (using en-US)
    • Updated the search submit control behavior (spinner/loading and disabled states)
  • Documentation
    • Updated version badge to v0.3.2 and refreshed prerequisites (added rehype-raw, raised Node to >=22.0.0)
    • Renamed the optional GitHub token variable to GITHUB_TOKEN
  • Chores
    • Bumped project version to 0.3.2 and added version-bump guidance to AGENTS.md

- Add default_branch field to GitHubRepository interface
- Register raw.githubusercontent.com in images.remotePatterns
rehype-raw allows react-markdown to parse and render raw HTML tags
found in GitHub READMEs (e.g. <img>, <p align="center">).
Add rehype-raw plugin to parse raw HTML in markdown and a custom img
component override that resolves relative image src paths to absolute
raw.githubusercontent.com URLs using the repo's default branch.
Replace undefined locale with 'en-US' in toLocaleDateString calls
across ViewRepo, ViewUser, and ViewSearch to ensure server and
client render identical date strings.
…match

Base UI's ButtonPrimitive strips the native disabled attribute during SSR
but adds it on the client, causing a hydration mismatch. Using a native
<button> element renders disabled consistently across server and client.
Missed in the previous hydration fix pass — the commit timeline date
also needs an explicit locale to avoid SSR/CSR mismatch.
- Bump version badge to v0.3.2 in README
- Add rehype-raw to the markdown stack entry
- Fix env var name from NEXT_PUBLIC_GITHUB_TOKEN to GITHUB_TOKEN
- Add version bump instructions to AGENTS.md
@ziguifrido ziguifrido self-assigned this Jun 21, 2026
@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
github-explorer-dashboard Ready Ready Preview, Comment Jun 21, 2026 5:38am

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4805c931-59fc-4bb0-af29-a55b6ff4fdc3

📥 Commits

Reviewing files that changed from the base of the PR and between e157df5 and 462cf19.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • package.json
  • src/components/ViewRepo.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • package.json
  • src/components/ViewRepo.tsx

📝 Walkthrough

Walkthrough

Adds rehype-raw (v7) to enable raw HTML in ReactMarkdown, extends GitHubRepository with default_branch, allows raw.githubusercontent.com in Next.js image patterns, and implements relative-image URL resolution in ViewRepo. Standardizes date formatting to 'en-US' across three components, replaces a shared Button with a native <button> in ViewSearch, and bumps the project to v0.3.2.

Changes

README Image Rendering, Locale Fixes, and v0.3.2 Release

Layer / File(s) Summary
GitHubRepository interface, rehype-raw dep, and Next.js image pattern
src/lib/github.ts, package.json, next.config.ts
Adds default_branch: string to GitHubRepository, registers rehype-raw ^7.0.0 as a dependency, and permits HTTPS image loads from raw.githubusercontent.com via images.remotePatterns.
ViewRepo: rehype-raw plugin and relative image URL resolution
src/components/ViewRepo.tsx
Imports rehype-raw and rehype-sanitize, adds them to ReactMarkdown's rehype plugins, and introduces a custom img renderer that validates src, detects absolute vs relative URLs, and resolves relative paths to raw.githubusercontent.com using activeRepo.default_branch. Also fixes repo metadata and commit timestamp date formatting to 'en-US'.
ViewSearch native button and locale fixes
src/components/ViewSearch.tsx, src/components/ViewUser.tsx
Replaces the shared Button submit control in ViewSearch with a native <button> (same disabled/spinner logic), and standardizes toLocaleDateString calls in ViewSearch and ViewUser to 'en-US'.
Version bump and docs
package.json, README.md, AGENTS.md
Bumps version to 0.3.2, updates the README badge and prerequisites (adds rehype-raw, renames NEXT_PUBLIC_GITHUB_TOKENGITHUB_TOKEN), and documents version-bump file requirements in AGENTS.md.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • ziguifrido/github-explorer#2: Both PRs modify the src/components/ViewSearch.tsx search UI with changes to the submit control and timestamp formatting, and extend src/lib/github.ts with data types, creating a code-level connection.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objectives: fixing README image rendering and hydration mismatches, which align with the significant changes across multiple components and configuration files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/readme-images-and-hydration

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/ViewRepo.tsx (1)

74-86: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Pin the timezone too, not just the locale.

These still use the server/client default timezone, so SSR in UTC and hydration in a user timezone can produce different dates/times. Add a fixed timeZone to each formatter used during render.

🐛 Proposed fix
 const createdDate = new Date(activeRepo.created_at).toLocaleDateString('en-US', {
   year: 'numeric',
   month: 'short',
-  day: 'numeric'
+  day: 'numeric',
+  timeZone: 'UTC'
 });
 
 const pushedDate = new Date(activeRepo.pushed_at).toLocaleDateString('en-US', {
   year: 'numeric',
   month: 'short',
   day: 'numeric',
   hour: '2-digit',
-  minute: '2-digit'
+  minute: '2-digit',
+  timeZone: 'UTC'
 });
 const commitDate = new Date(item.commit.author.date).toLocaleDateString('en-US', {
   month: 'short',
   day: 'numeric',
   hour: '2-digit',
-  minute: '2-digit'
+  minute: '2-digit',
+  timeZone: 'UTC'
 });

Also applies to: 272-277

🤖 Prompt for 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.

In `@src/components/ViewRepo.tsx` around lines 74 - 86, The toLocaleDateString()
calls for createdDate and pushedDate formatting are missing a fixed timeZone
option, which can cause date/time mismatches between server-side rendering and
client-side hydration. Add a timeZone property (such as 'UTC') to the options
object in both the createdDate and pushedDate formatters, and also apply the
same fix to the similar date formatting code mentioned at lines 272-277 to
ensure consistent timezone handling across all renders.
🤖 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 `@README.md`:
- Line 35: Update the Node.js version requirement in README.md at line 35 from
"Node.js 20+" to "Node.js >=22.0.0" to align with the actual minimum version
requirement that is documented in AGENTS.md (line 50) and enforced via the
engines field in package.json. This will eliminate the cross-file inconsistency
and ensure users understand the correct minimum Node.js version needed.

In `@src/components/ViewRepo.tsx`:
- Line 21: Add the `rehype-sanitize` plugin to protect against XSS
vulnerabilities when rendering untrusted user content like activeRepoReadme.
Import rehype-sanitize at the top of the ViewRepo.tsx file alongside the
existing rehypeRaw import, then add rehype-sanitize to the rehypePlugins array
in the markdown rendering configuration (around lines 240-243) to sanitize any
HTML produced by rehypeRaw before it reaches the DOM. Finally, run npm install
rehype-sanitize to add the dependency to your project.

In `@src/components/ViewSearch.tsx`:
- Around line 109-119: The submit button in ViewSearch.tsx that displays only an
icon (either the Send icon or loading spinner) lacks accessible labeling for
screen readers. Add an aria-label attribute with a descriptive action name (such
as "Search") to the button element, and optionally add aria-busy={loading} to
indicate the loading state to assistive technologies. These attributes should be
added directly to the button element alongside the existing type, disabled, and
className attributes.

---

Outside diff comments:
In `@src/components/ViewRepo.tsx`:
- Around line 74-86: The toLocaleDateString() calls for createdDate and
pushedDate formatting are missing a fixed timeZone option, which can cause
date/time mismatches between server-side rendering and client-side hydration.
Add a timeZone property (such as 'UTC') to the options object in both the
createdDate and pushedDate formatters, and also apply the same fix to the
similar date formatting code mentioned at lines 272-277 to ensure consistent
timezone handling across all renders.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 80ee9010-7776-4c69-bbc0-6cc8993c5055

📥 Commits

Reviewing files that changed from the base of the PR and between 6e818b1 and 9e9ff81.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • AGENTS.md
  • README.md
  • next.config.ts
  • package.json
  • src/components/ViewRepo.tsx
  • src/components/ViewSearch.tsx
  • src/components/ViewUser.tsx
  • src/lib/github.ts

Comment thread README.md Outdated
Comment thread src/components/ViewRepo.tsx
Comment thread src/components/ViewSearch.tsx
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

⚠️ Branch updated during autofix.

The branch was updated while autofix was in progress. Please try again.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 3 file(s) based on 1 unresolved review comment.

Files modified:

  • package-lock.json
  • package.json
  • src/components/ViewRepo.tsx

Commit: 462cf19ab3e062e00e992c8611dd61854794cb24

The changes have been pushed to the fix/readme-images-and-hydration branch.

Time taken: 2m 6s

Fixed 3 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@ziguifrido ziguifrido closed this Jun 21, 2026
@ziguifrido ziguifrido deleted the fix/readme-images-and-hydration branch June 21, 2026 06:22
@ziguifrido ziguifrido restored the fix/readme-images-and-hydration branch June 21, 2026 06:35
@ziguifrido ziguifrido reopened this Jun 21, 2026
@ziguifrido ziguifrido merged commit 7df0dde into main Jun 21, 2026
5 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