Skip to content

fix(CL router): cl path dismatch#1905

Merged
benjamin-747 merged 1 commit into
gitmono-dev:mainfrom
ztygod:fix/cl-file-path-mapping
Feb 9, 2026
Merged

fix(CL router): cl path dismatch#1905
benjamin-747 merged 1 commit into
gitmono-dev:mainfrom
ztygod:fix/cl-file-path-mapping

Conversation

@ztygod

@ztygod ztygod commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

问题

code review 进行评论的时候需要获取到 commit sha。目前前端能从接口获取到的是长路径,但是cl目录树这里是短路径
路径匹配不太友好 。

解决方案

cl_files_list router 返回短路径。目前这个接口没有被使用,不用担心代码改动影响其他逻辑

/// Get Change List file list
#[utoipa::path(
    get,
    params(
        ("link", description = "CL link"),
    ),
    path = "/{link}/files-list",
    responses(
        (status = 200, body = CommonResult<Vec<ClFilesRes>>, content_type = "application/json")
    ),
    tag = CL_TAG
)]
async fn cl_files_list(
    Path(link): Path<String>,
    state: State<MonoApiServiceState>,
) -> Result<Json<CommonResult<Vec<ClFilesRes>>>, ApiError> {
    let cl = state
        .cl_stg()
        .get_cl(&link)
        .await?
        .ok_or(MegaError::Other("CL Not Found".to_string()))?;

    let stg = state.monorepo();
    let old_files = stg.get_commit_blobs(&cl.from_hash).await?;
    let new_files = stg.get_commit_blobs(&cl.to_hash).await?;
    let cl_diff_files = stg.cl_files_list(old_files, new_files.clone()).await?; // TODO

    let res = cl_diff_files
        .into_iter()
        .map(|m| {
            let item: ClFilesRes = m.into();
            item
        })
        .collect::<Vec<ClFilesRes>>();
    Ok(Json(CommonResult::success(Some(res))))
}

@genedna

genedna commented Feb 6, 2026

Copy link
Copy Markdown
Collaborator

@codex review

Copilot AI 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.

Pull request overview

This pull request addresses a path mismatch issue in the code review feature where the frontend receives long paths from the API but the CL directory tree uses short paths. The fix modifies the cl_files_list router endpoint to return short paths instead of concatenating the CL base path with file paths.

Changes:

  • Removes unused std::path::PathBuf import
  • Simplifies the path handling in cl_files_list endpoint by returning short paths directly instead of joining with cl.path

.map(|m| {
let mut item: ClFilesRes = m.into();
item.path = cl_base.join(item.path).to_string_lossy().to_string();
let item: ClFilesRes = m.into();

Copilot AI Feb 6, 2026

Copy link

Choose a reason for hiding this comment

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

The PR description states "this interface is not being used" (目前这个接口没有被使用), but the endpoint is actually being used in the frontend code. The useGetClFilesList hook is imported and used in moon/apps/web/components/DiffView/comment/CommentForm.tsx to retrieve commit SHA for code review comments.

Before making this breaking change, verify that returning short paths instead of long paths won't break the path matching logic in CommentForm.tsx line 46: file.path.endsWith(filePath). The frontend may need to be updated to handle this change.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

这部分router在前端中并没有得到使用

.map(|m| {
let mut item: ClFilesRes = m.into();
item.path = cl_base.join(item.path).to_string_lossy().to_string();
let item: ClFilesRes = m.into();

Copilot AI Feb 6, 2026

Copy link

Choose a reason for hiding this comment

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

There's an inconsistency in the codebase: ceres/src/build_trigger/changes_calculator.rs lines 47-56 still joins the CL path with file paths when creating ClFilesRes objects (using cl_base.join(item.path)), while this PR removes the same logic from the API router. This creates an inconsistency where different code paths return different path formats for the same data structure.

Consider whether the build_changes function in changes_calculator.rs should also be updated to match this new behavior, or if there's a reason for the different path handling in different contexts.

Copilot uses AI. Check for mistakes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: afa3201eb1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 324 to 328
let res = cl_diff_files
.into_iter()
.map(|m| {
let mut item: ClFilesRes = m.into();
item.path = cl_base.join(item.path).to_string_lossy().to_string();
let item: ClFilesRes = m.into();
item

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve CL base in files-list paths

The files-list response now returns raw diff paths without prefixing them with the CL base path. Downstream consumers (e.g., scorpio/src/daemon/antares.rs relative_path_for_mount) normalize each entry as an absolute path and require it to start with the mount path; if the CL base prefix is missing, relative_path_for_mount returns None and the file is skipped, which results in missing CL layer contents for non-root mounts. This regression appears when mount_path is anything other than / and the CL is scoped to a subdirectory, because the returned paths no longer include that subdirectory.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

拿到原始差异路径就是本次PR的目的

@benjamin-747 benjamin-747 added this pull request to the merge queue Feb 9, 2026
Merged via the queue into gitmono-dev:main with commit 046d7ec Feb 9, 2026
23 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.

4 participants