Skip to content

Conversation

davemarco
Copy link
Contributor

@davemarco davemarco commented May 30, 2025

Description

Host old log viewer status page, so link to log viewer actually work. Also passes in the neccesary arguments.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Tested with another instance of the package, and links opened correctly

Had to modify this script to actually host the new app.

import {StrictMode} from "react";
import {createRoot} from "react-dom/client";

import AntdApp from "./AntdApp";

import "./index.css";


const rootElement = document.getElementById("root");
if (null === rootElement) {
    throw new Error("Root element not found");
}

const root = createRoot(rootElement);
root.render(
    <StrictMode>
        <AntdApp/>
    </StrictMode>
);

Summary by CodeRabbit

  • New Features

    • Added internal navigation to a new "/streamFile" page for viewing log streams directly within the app.
    • Introduced support for a new storage engine configuration option.
    • Enhanced search results with additional metadata for improved stream identification.
  • Bug Fixes

    • Improved static file serving behaviour for specific routes to ensure correct loading of the new page.

@davemarco davemarco requested a review from a team as a code owner May 30, 2025 19:19
Copy link
Contributor

coderabbitai bot commented May 30, 2025

Warning

Rate limit exceeded

@davemarco has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 42f4df8 and e1d42eb.

📒 Files selected for processing (4)
  • components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Message/LogViewerLink.tsx (1 hunks)
  • components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Message/index.tsx (2 hunks)
  • components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx (2 hunks)
  • components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/utils.ts (1 hunks)

Walkthrough

This change updates the log viewer web UI to support internal navigation for viewing log streams. It introduces new route handling for /streamFile, updates components and props to pass stream identifiers and event indices, and adds utility logic to select stream IDs based on the configured storage engine. Static file serving is also adjusted for the new route.

Changes

File(s) Change Summary
client/settings.json Added "ClpStorageEngine": "clp" config entry; ensured valid JSON syntax.
.../SearchResultsTable/Message/LogViewerLink.tsx Changed from static external anchor to internal react-router Link with new props; updated interface and usage.
.../SearchResultsTable/Message/index.tsx Extended MessageProps and Message to accept and pass streamId and logEventIdx props to LogViewerLink.
.../SearchResultsTable/typings.tsx Added archive_id to SearchResult interface; updated columns to pass streamId and logEventIdx to Message.
.../SearchResultsTable/utils.ts New utility: exports STREAM_TYPE and getStreamId() based on storage engine config.
client/src/router.tsx Added /streamFile route rendering QueryStatus; imported QueryStatus.
server/src/routes/static.ts Disabled wildcard on root static route; added /streamFile GET handler to serve index.html.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SearchResultsTable
    participant Message
    participant LogViewerLink
    participant Router
    participant QueryStatus

    User->>SearchResultsTable: Clicks log message link
    SearchResultsTable->>Message: Render with streamId, logEventIdx, filePath
    Message->>LogViewerLink: Render with streamId, logEventIdx, filePath
    LogViewerLink->>Router: Navigate to /streamFile?type=...&streamId=...&logEventIdx=...
    Router->>QueryStatus: Render QueryStatus component for /streamFile route
Loading

Possibly related PRs

Suggested reviewers

  • junhaoliao
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@davemarco davemarco requested a review from junhaoliao May 30, 2025 21:02
Copy link
Member

@junhaoliao junhaoliao left a comment

Choose a reason for hiding this comment

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

for the PR title, how about

feat(new-webui): Add log viewer links to search results for viewing context.

@davemarco davemarco requested a review from junhaoliao June 2, 2025 14:15
@junhaoliao
Copy link
Member

discussed offline - since the UIs (links) are already there, for the PR title, how about:

feat(new-webui): Add backend support for log viewer links in search results.

@davemarco davemarco changed the title feat(new-webui): Add support for opening files in log viewer. feat(new-webui): Add backend support for log viewer links in search results. Jun 2, 2025
@davemarco
Copy link
Contributor Author

@junhaoliao - i still need approval

@davemarco davemarco merged commit cc9c89e into y-scope:main Jun 2, 2025
6 checks passed
Comment on lines +55 to 57
fastify.get("/streamFile", (_, reply) => {
reply.sendFile("index.html", clientDir);
});
Copy link
Member

Choose a reason for hiding this comment

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

to get the other React-Router defined routes in the SPA working, i believe we also need to let Fastify serve those routes with the index.html

@coderabbitai please create an issue to track this

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

@junhaoliao I'll create an issue to track the SPA routing problem you've identified.


🏁 Script executed:

#!/bin/bash
# Create a GitHub issue to track the SPA routing problem
gh issue create \
  --title "SPA routing: Fastify needs to serve index.html for all React Router routes" \
  --body "## Problem

Currently, only the \`/streamFile\` route is configured to serve \`index.html\` in the Fastify server. Other React Router defined routes in the SPA will return 404 errors when accessed directly via URL or when users refresh the page.

## Current Implementation

In \`components/log-viewer-webui/server/src/routes/static.ts\`, we have:
- Static file serving with \`wildcard: false\`
- Specific route handler for \`/streamFile\` that serves \`index.html\`

## Expected Behavior

All React Router defined routes should be served with \`index.html\` so that the React application can handle client-side routing properly.

## Related

- PR: https://github.com/y-scope/clp/pull/950
- Comment: https://github.com/y-scope/clp/pull/950#discussion_r2148823183
- Requested by: @junhaoliao" \
  --assignee junhaoliao

Length of output: 952


@junhaoliao I've successfully created issue #1011 to track the SPA routing problem: #1011

The issue documents the current implementation where only /streamFile serves index.html, and explains that other React Router routes will need similar handling to prevent 404 errors when accessed directly or on page refresh. The issue has been assigned to you as requested.

🐰📝
Taking notes for future improvements


🧬 Code Graph Analysis Results

Relevant snippet from components/log-viewer-webui/server/src/routes/static.ts (lines 1-56)

import path from "node:path";
import process from "node:process";
import {fileURLToPath} from "node:url";

import {fastifyStatic} from "@fastify/static";
import {FastifyPluginAsync} from "fastify";

import settings from "../../settings.json" with {type: "json"};


/**
 * Creates static files serving routes.
 *
 * @param fastify
 */
const routes: FastifyPluginAsync = async (fastify) => {
    const filename = fileURLToPath(import.meta.url);
    const dirname = path.dirname(filename);
    const rootDirname = path.resolve(dirname, "../..");

    let streamFilesDir = settings.StreamFilesDir;
    if (false === path.isAbsolute(streamFilesDir)) {
        streamFilesDir = path.resolve(rootDirname, streamFilesDir);
    }
    await fastify.register(fastifyStatic, {
        prefix: "/streams",
        root: streamFilesDir,
    });

    let logViewerDir = settings.LogViewerDir;
    if (false === path.isAbsolute(logViewerDir)) {
        logViewerDir = path.resolve(rootDirname, logViewerDir);
    }
    await fastify.register(fastifyStatic, {
        prefix: "/log-viewer",
        root: logViewerDir,
        decorateReply: false,
    });

    if ("production" === process.env.NODE_ENV) {
        // In the development environment, we expect the client to use a separate webserver that
        // supports live reloading.
        let clientDir = settings.ClientDir;
        if (false === path.isAbsolute(clientDir)) {
            clientDir = path.resolve(rootDirname, settings.ClientDir);
        }

        await fastify.register(fastifyStatic, {
            prefix: "/",
            root: clientDir,
            decorateReply: false,
            wildcard: false,
        });

        fastify.get("/streamFile", (_, reply) => {
            reply.sendFile("index.html", clientDir);
        });
    }
};

export default routes;

Summary of possibly relevant snippet from components/webui/server/main.js (lines 30-33)

const {
        CLP_DB_USER,
        CLP_DB_PASS,
    } = process.env;
  • This snippet extracts environment variables related to database credentials from process.env.
  • It is a small part of the server main file, likely related to configuration.
  • No direct relation to static file serving or React Router routes handling.

No other snippets provided appear relevant to the static file serving or SPA route handling discussed in the user comment.

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.

2 participants