Skip to content

Clarify Pagefind dev-mode search message#401

Closed
zz-plant wants to merge 1 commit into
mainfrom
codex/fix-pagefind-search-availability-in-builds
Closed

Clarify Pagefind dev-mode search message#401
zz-plant wants to merge 1 commit into
mainfrom
codex/fix-pagefind-search-availability-in-builds

Conversation

@zz-plant

Copy link
Copy Markdown
Owner

Motivation

  • Make the search fallback clearer when Pagefind is unavailable in development by showing a dev-only guidance message that explains how to test search locally and a production-friendly message for non-dev environments.

Description

  • Update src/components/Search.astro to read import.meta.env.DEV into isDev and render a conditional empty-state: in dev show a message with bun run build / bun run preview instructions, otherwise show a generic retry message.

Testing

  • Ran bun run typecheck, which failed due to unrelated errors in src/actions/index.ts (missing astro:actions export z and an implicit any).
  • Ran bun run astro:check, which failed for the same src/actions/index.ts errors reported by Astro.
  • Ran the repo check with bun run check, which reported failing checks (lint, typecheck, and astro:check) and passing JSON/glossary/unit tests.
  • Attempted to run the dev server and a Playwright script to capture the UI, but the site failed to load due to an ActionsCantBeLoaded error from src/actions/index.ts, preventing the automated UI screenshot.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jan 15, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
et3 88cf59f Jan 15 2026, 04:46 AM

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @zz-plant, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the user experience for the search functionality by providing more informative messages when the Pagefind search index is not available. It differentiates between development and production environments, offering clear instructions for developers on how to enable local search testing and a general 'temporarily unavailable' message for live users. This change improves clarity and guidance without affecting core search functionality.

Highlights

  • Improved Search Fallback Message: The pull request clarifies the search fallback message when Pagefind is unavailable, providing different guidance based on the environment.
  • Development Mode Guidance: In development mode, users will now see a specific message explaining how to test search locally by running bun run build and bun run preview.
  • Production-Friendly Message: For non-development environments, a generic 'Search is temporarily unavailable' message is displayed, ensuring a consistent user experience.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request clarifies the search fallback message by providing different messages for development and production environments. The implementation correctly uses import.meta.env.DEV to detect the environment. My feedback focuses on improving code readability by refactoring a complex ternary operator into a more explicit if/else block. This also serves as an opportunity to highlight a potential security risk with innerHTML usage elsewhere in the component, recommending a safer approach for future improvements.

Comment on lines 473 to +476
resultsContainer.innerHTML =
'<p class="search-empty">Search is only available in production builds.</p>';
isDev
? '<p class="search-empty">Search is only available in production builds. Run <code>bun run build</code> and <code>bun run preview</code> to test it locally.</p>'
: '<p class="search-empty">Search is temporarily unavailable. Please try again later.</p>';

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.

medium

This multi-line ternary operator for constructing the message can be difficult to read and maintain. Refactoring it to use a standard if/else block to define the message string before assigning it to innerHTML would improve code clarity.

On a related note, please be cautious with innerHTML assignments. While the content here is static, another part of this function uses it with the user-provided query, creating a potential Cross-Site Scripting (XSS) vulnerability. A future refactor to use safer DOM manipulation APIs (like textContent or createElement) across the component would be a good security enhancement.

        let message;
        if (isDev) {
          message =
            '<p class="search-empty">Search is only available in production builds. Run <code>bun run build</code> and <code>bun run preview</code> to test it locally.</p>';
        } else {
          message =
            '<p class="search-empty">Search is temporarily unavailable. Please try again later.</p>';
        }
        resultsContainer.innerHTML = message;

@zz-plant zz-plant closed this Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant