Skip to content

chore: add GitLab wiki proxy, improve Codeberg retry logic, and inclu… - #154

Merged
livrasand merged 5 commits into
mainfrom
chore--add-GitLab-wiki-proxy,-improve-Codeberg-retry-logic,-and-include-Material-Icon-Theme-assets
Aug 5, 2026
Merged

chore: add GitLab wiki proxy, improve Codeberg retry logic, and inclu…#154
livrasand merged 5 commits into
mainfrom
chore--add-GitLab-wiki-proxy,-improve-Codeberg-retry-logic,-and-include-Material-Icon-Theme-assets

Conversation

@livrasand

@livrasand livrasand commented Aug 5, 2026

Copy link
Copy Markdown
Owner

…de Material Icon Theme assets

Add GitLabWikiProxyHandler to fetch wiki pages via GitLab API with token support and normalize inaccessible wikis to empty arrays. Implement single retry with 500ms delay for Codeberg proxy timeouts. Support GitHub-style topic: prefix in search queries for cross-provider compatibility. Update .gitignore to exclude PLAN-TAGS.md. Include Material Icon Theme SVG icons and legal.json for file type visualization.

Summary by CodeRabbit

  • New Features
    • Added GitLab wiki browsing, including optional page content.
    • Improved repository pages with mobile-friendly navigation, file metadata, preview/code toggles, copy and download actions, license detection, and themed icons.
    • Added Markdown alerts, language-aware styling, local file links, and improved image handling.
    • Added generated repository and forge icons on mobile cards.
  • Improvements
    • Search results are now ranked by relevance, with improved topic search support.
    • Codeberg requests retry automatically after transient failures.
    • Repository lists on tag pages are randomized for greater variety.
    • Improved messaging when pull requests or releases are unavailable.

…de Material Icon Theme assets

Add GitLabWikiProxyHandler to fetch wiki pages via GitLab API with token support and normalize inaccessible wikis to empty arrays. Implement single retry with 500ms delay for Codeberg proxy timeouts. Support GitHub-style `topic:` prefix in search queries for cross-provider compatibility. Update .gitignore to exclude PLAN-TAGS.md. Include Material Icon Theme SVG icons and legal.json for file type visualization.
@livrasand livrasand self-assigned this Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@livrasand, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 818c97d1-7916-4338-a953-9d461c908214

📥 Commits

Reviewing files that changed from the base of the PR and between c44b705 and 43360c3.

📒 Files selected for processing (4)
  • internal/http/handlers.go
  • web/assets/MaterialIconTheme/LICENSE
  • web/index.html
  • web/repo.html
📝 Walkthrough

Walkthrough

The PR adds GitLab wiki proxying and provider request handling, improves topic search and repository cards, adds responsive repository-page controls, detects licenses and language colors, applies themed icons, and introduces shared file and README rendering behavior.

Changes

Repository provider integration

Layer / File(s) Summary
Provider proxy and request handling
internal/http/handlers.go, internal/http/router.go, web/repo.html
GitLab wiki requests now use an application proxy. Codeberg requests retry once. Topic queries use provider-specific formats. Failed pull-request and release responses show unavailable states.
Repository metadata, icons, and language presentation
web/repo.html, web/assets/MaterialIconTheme/legal.json
Repository pages detect licenses, load language colors, and use Material Icon Theme mappings for files and folders.

Repository browsing interface

Layer / File(s) Summary
Search ranking and repository cards
web/index.html
Search results use relevance scoring and sorting. Cards use identicons, shared forge icons, escaped metadata, language badges, and shuffled tag results.
Responsive repository shell and sidebar
web/repo.html
The repository page adds responsive mobile navigation, sidebar controls, file-toolbar styling, synchronized star controls, and Markdown alert styles.
File panels and README rendering
web/repo.html
File rendering now supports metadata, preview/code toggles, syntax highlighting, copying, downloading, image handling, relative links, file URLs, and failed-image handling.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: gitgost-anonymous

🚥 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 clearly identifies the GitLab wiki proxy and Codeberg retry changes, which are central objectives of the pull request.
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.
✨ 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 chore--add-GitLab-wiki-proxy,-improve-Codeberg-retry-logic,-and-include-Material-Icon-Theme-assets

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Comment thread web/repo.html
Comment thread web/repo.html Fixed
Comment thread web/repo.html Fixed
…te scripting'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
livrasand and others added 2 commits August 5, 2026 14:16
…te scripting'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…te scripting'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

@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: 5

Caution

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

⚠️ Outside diff range comments (1)
web/index.html (1)

1606-1606: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Other (CWE-693)

Reachability: External

Restore the pageview disclosure or remove the pageview tracker.

web/ethicalmetrics.js still sends pageview JSON to /v1/pageviews; removing the notice at web/index.html:1606 leaves mobile users without disclosure when counters still run.

🤖 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 `@web/index.html` at line 1606, Restore the pageview disclosure near the
closing nav in web/index.html, ensuring mobile users are informed while
web/ethicalmetrics.js continues sending pageview data to /v1/pageviews;
alternatively, remove or disable the pageview tracker so no undisclosed counters
run.
🧹 Nitpick comments (4)
web/repo.html (2)

2053-2058: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add an Escape-key handler for the overlay panel.

The panel is a full-screen overlay at z-index: 100. closeMobileSidebar() is reachable only through the close button. Add an Escape-key handler so keyboard users can dismiss the panel from anywhere in it.

♻️ Proposed addition near closeMobileSidebar
 function closeMobileSidebar() {
     const panel = document.getElementById('mobile-sidebar-panel');
     if (!panel) return;
     panel.classList.remove('open');
     const btn = document.getElementById('mobile-sidebar-toggle-btn');
     if (btn) btn.setAttribute('aria-expanded', 'false');
     document.body.classList.remove('panel-open');
 }
+
+document.addEventListener('keydown', (e) => {
+    if (e.key !== 'Escape') return;
+    const panel = document.getElementById('mobile-sidebar-panel');
+    if (panel && panel.classList.contains('open')) closeMobileSidebar();
+});

Also applies to: 2068-2111

🤖 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 `@web/repo.html` around lines 2053 - 2058, Add a document-level Escape-key
handler near the existing closeMobileSidebar function so pressing Escape invokes
closeMobileSidebar and dismisses the mobile sidebar overlay from anywhere within
it. Preserve the current close-button behavior and only handle the Escape key.

4711-4789: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Use a root-relative icon path.

_themeIcon currently builds relative <img> URLs from ICON_BASE, so serving web/repo.html from a nested route would resolve icon URLs under that route and silently break icons when the fallback assets are not present there. Use /assets/MaterialIconTheme/material-icon-theme--.

🤖 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 `@web/repo.html` around lines 4711 - 4789, The _themeIcon function currently
generates a relative asset URL that breaks when repo.html is served from a
nested route. Update ICON_BASE to use the root-relative
/assets/MaterialIconTheme/material-icon-theme-- path, preserving the existing
_themeIcon construction and icon mappings.
internal/http/handlers.go (1)

2973-2979: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Bound the retry and tie the request to the client context.

The retry is safe for the request itself: the method is restricted to GET/HEAD and the body is nil, so reusing req is correct. Two reliability points remain:

  1. The worst-case handler duration is now about 90.5 s (two 45 s attempts plus the sleep).
  2. http.NewRequest at line 2955 does not carry c.Request.Context(). A client disconnect cancels nothing, so the handler holds a goroutine and an upstream connection for the full duration.

Propagate the request context and lower the per-attempt timeout so the total stays close to the previous budget.

♻️ Proposed change
-	req, err := http.NewRequest(c.Request.Method, target, nil)
+	req, err := http.NewRequestWithContext(c.Request.Context(), c.Request.Method, target, nil)
-	client := &http.Client{Timeout: 45 * time.Second}
+	client := &http.Client{Timeout: 20 * time.Second}
 	resp, err := client.Do(req)
 	if err != nil {
 		// Codeberg sufre timeouts puntuales: reintentar una vez antes de devolver 502.
-		time.Sleep(500 * time.Millisecond)
-		resp, err = client.Do(req)
+		if c.Request.Context().Err() == nil {
+			time.Sleep(500 * time.Millisecond)
+			resp, err = client.Do(req)
+		}
 	}
🤖 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 `@internal/http/handlers.go` around lines 2973 - 2979, Update the upstream
request construction around http.NewRequest to use c.Request.Context(), ensuring
client disconnects cancel the operation. In the retry flow using client.Do(req),
reduce the per-attempt http.Client timeout so both attempts plus the 500 ms
delay remain close to the previous single-attempt duration while preserving the
existing one-retry behavior.
internal/http/router.go (1)

293-293: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Consider rate limiting this proxy route.

The route wiring is correct. The :owner/:repo params match the c.Param calls in GitLabWikiProxyHandler.

Each request to this route triggers one outbound gitlab.com API call that carries the shared GITLAB_TOKEN. The route has no limiter, so an unauthenticated caller can consume the server's GitLab API quota. /cb-proxy/*path at line 284 already applies prCheckLimiter() for the same reason. The neighbouring gl-* routes share this gap, so treat this as an existing pattern to tighten rather than a regression.

♻️ Proposed change
-		api.GET("/gl-wiki/:owner/:repo", GitLabWikiProxyHandler)
+		api.GET("/gl-wiki/:owner/:repo", prCheckLimiter(), GitLabWikiProxyHandler)
🤖 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 `@internal/http/router.go` at line 293, Apply the existing prCheckLimiter()
middleware to the GitLabWikiProxyHandler route, matching the protection already
used by /cb-proxy/*path. Extend the same rate-limiting treatment to the
neighbouring gl-* proxy routes that make outbound GitLab API calls, while
preserving their existing handlers and route parameters.
🤖 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 `@internal/http/handlers.go`:
- Around line 3013-3017: Update the topic extraction in the query-handling logic
around topicParam so the value after the topic: prefix is trimmed of surrounding
whitespace and assigned only when non-empty. Preserve the existing fallback
behavior for q=topic: by leaving topicParam empty, while ensuring valid topics
such as q=topic: go are passed to providers without leading whitespace.
- Around line 1928-1933: Update the status handling in the wiki response path
around resp.StatusCode so only GitLab statuses indicating an inaccessible or
unavailable wiki are normalized to HTTP 200 with an empty list. Propagate all
other non-200 responses, including 429 and 5xx upstream failures, instead of
returning a successful empty wiki response.

In `@web/assets/MaterialIconTheme/legal.json`:
- Around line 1-8: Add the upstream MIT LICENSE file alongside the vendored SVG
assets in the MaterialIconTheme asset directory, preserving the existing
legal.json metadata and using the license text and copyright notice from the
recorded upstream commit.

In `@web/index.html`:
- Line 3041: Update the topic normalization near the `repo.topics` mapping to
fall back when `topics` is empty, merging or selecting the available `topics`,
`tags`, and `tag_list` values into one normalized array. Reuse that same array
for both `searchMatchScore` and `#`-tag filtering so provider tag matches are
scored and filtered consistently.

In `@web/repo.html`:
- Around line 4253-4285: Update _detectLicense to distinguish GPL and LGPL
license text by version before returning labels, so GPLv2 and LGPLv2.1 content
are not classified as v3; alternatively, return version-neutral labels when the
version cannot be identified. Preserve the existing specificity order with AGPL
checked before LGPL before GPL, and apply the same correction to the
corresponding duplicate detection logic.

---

Outside diff comments:
In `@web/index.html`:
- Line 1606: Restore the pageview disclosure near the closing nav in
web/index.html, ensuring mobile users are informed while web/ethicalmetrics.js
continues sending pageview data to /v1/pageviews; alternatively, remove or
disable the pageview tracker so no undisclosed counters run.

---

Nitpick comments:
In `@internal/http/handlers.go`:
- Around line 2973-2979: Update the upstream request construction around
http.NewRequest to use c.Request.Context(), ensuring client disconnects cancel
the operation. In the retry flow using client.Do(req), reduce the per-attempt
http.Client timeout so both attempts plus the 500 ms delay remain close to the
previous single-attempt duration while preserving the existing one-retry
behavior.

In `@internal/http/router.go`:
- Line 293: Apply the existing prCheckLimiter() middleware to the
GitLabWikiProxyHandler route, matching the protection already used by
/cb-proxy/*path. Extend the same rate-limiting treatment to the neighbouring
gl-* proxy routes that make outbound GitLab API calls, while preserving their
existing handlers and route parameters.

In `@web/repo.html`:
- Around line 2053-2058: Add a document-level Escape-key handler near the
existing closeMobileSidebar function so pressing Escape invokes
closeMobileSidebar and dismisses the mobile sidebar overlay from anywhere within
it. Preserve the current close-button behavior and only handle the Escape key.
- Around line 4711-4789: The _themeIcon function currently generates a relative
asset URL that breaks when repo.html is served from a nested route. Update
ICON_BASE to use the root-relative
/assets/MaterialIconTheme/material-icon-theme-- path, preserving the existing
_themeIcon construction and icon mappings.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

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

Comment thread internal/http/handlers.go Outdated
Comment thread internal/http/handlers.go
Comment thread web/assets/MaterialIconTheme/legal.json
Comment thread web/index.html Outdated
Comment thread web/repo.html
Improve handling of upstream responses and client-side normalization across multiple areas.

- internal/http/handlers.go: Normalize GitLab wiki 401/403/404 to 200 with an empty list so the frontend doesn't show network errors for inaccessible wikis; propagate other non-200 upstream responses (e.g. 429/5xx) with their original status and body.
- internal/http/handlers.go (SearchHandler): Safely trim and set topic parameter when using GitHub-style "topic:<name>" queries.
- web/index.html: Add repoTagList() to unify topics/tags/tag_list into a single deduplicated lowercase tag array and use it in search scoring and tag filtering.
- web/repo.html: Improve license detection to better distinguish LGPL v2.1/v3 and GPL v2/v3 (and fall back to generic LGPL/GPL when version not detected).
- web/assets/MaterialIconTheme/LICENSE: Add MIT license file for the MaterialIconTheme asset.

These changes reduce false error states, unify tag handling across providers, and improve license identification.
@livrasand
livrasand merged commit 40d7eb5 into main Aug 5, 2026
5 of 6 checks passed
@livrasand
livrasand deleted the chore--add-GitLab-wiki-proxy,-improve-Codeberg-retry-logic,-and-include-Material-Icon-Theme-assets branch August 5, 2026 21:34
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.

3 participants