Skip to content

支持编辑文件后自动创建 CL 并触发构建流程#1877

Closed
Chen-Rong-Zi wants to merge 3732 commits into
gitmono-dev:mainfrom
Chen-Rong-Zi:issue-1872
Closed

支持编辑文件后自动创建 CL 并触发构建流程#1877
Chen-Rong-Zi wants to merge 3732 commits into
gitmono-dev:mainfrom
Chen-Rong-Zi:issue-1872

Conversation

@Chen-Rong-Zi

@Chen-Rong-Zi Chen-Rong-Zi commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 编辑文件后不再直接生成 Commit
    当用户在 UI / API 中编辑文件并保存时:

    • 改为进入 CL 流程 (通过cl与构建系统的BuildContext类型转换中实现)
    • 禁止直接创建 Git commit (mega_cl::model 定义存在from_hash以及to_hash字段, 可能需要修改该结构体)
  • 自动或显式新建 CL
    编辑文件后:

    • 若当前无 open CL → 自动创建一个新的 CL (会在force_create设置为否时尝试获取当前的cl)
    • 若已有 open CL → 可选地将变更追加到该 CL (新增force_create参数)
    • CL 需包含:修改的文件列表 (由from_hash以及to_hash对应的commit动态计算)
    • CL 需包含:基于当前基线(base branch)的 diff (由from_hash以及to_hash对应的commit动态计算)
  • 基于 CL 触发构建
    CL 创建或更新后:

    • 按新的构建触发模型触发构建
    • 构建状态与结果绑定到 CL (cl -> task -> {builds})
    • 构建不再与“孤立 commit”绑定 (cl -> task -> {builds})
    • UI 可在 CL 维度展示构建状态 (cl -> task -> {builds})
      新增:
    • 新增skip_build参数, 抑制构建可选
      - [x] 构建前MonoApiService::should_trigger_build可根据changed_files动态判断是否构建, 目前总是返回字面常量true 相关代码已删除, 对应功能应该在新构建系统内实现
      feat: implement build trigger system #1880

related issue

#1872

231220075 and others added 30 commits October 21, 2025 10:56
Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

fix problems
…o-dev#1457) (gitmono-dev#1567)

* feat: remove unnecessary mr components and rename enum mr_sync to cl_sync(gitmono-dev#1457)

* feat: remove unnecessary mr components and rename enum mr_sync to cl_sync(gitmono-dev#1457)

---------

Co-authored-by: s_yangjunke <s_yangjunke@wps.com>
Co-authored-by: Quanyi Ma <eli@patch.sh>
Signed-off-by: acfboy <acfboyu@outlook.com>
…itmono-dev#1574)

* refactor: Change tags/refs from query parameters to path parameters

- Components now uniformly read the version from router.query.version
- Routes changed to: /tree/[version]/[...path] and /blob/[version]/[...path]
- URL example: /mega/code/tree/1.0.0/doc (formerly /tree/doc?refs=1.0.0)
- Fixed user display error on the Tag page

* refactor: Change tags/refs from query parameters to path parameters

- Components now uniformly read the version from router.query.version
- Routes changed to: /tree/[version]/[...path] and /blob/[version]/[...path]
- URL example: /mega/code/tree/1.0.0/doc (formerly /tree/doc?refs=1.0.0)
- Fixed user display error on the Tag page
…dev#1575)

- Show "New File" and "New Folder" buttons only on main branch
 - Display SyncRepoButton for repository synchronization only on main branch under third-party path
* refactor

* restore UI edits

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

* accept code review comments

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

---------

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>
Signed-off-by: allure <1550220889@qq.com>
Signed-off-by: allure <1550220889@qq.com>
…er information (gitmono-dev#1581)

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>
* fix: Add  committer parameter to the create_entry API and bind committer information

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

* fix: Support finding the latest commit for a file

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

fix reviews

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

---------

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>
Signed-off-by: allure <1550220889@qq.com>
* Add copilot-instructions.md for GitHub copilot

Signed-off-by: Eli Ma <eli@patch.sh>

* Update .github/copilot-instructions.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Quanyi Ma <eli@patch.sh>

---------

Signed-off-by: Eli Ma <eli@patch.sh>
Signed-off-by: Quanyi Ma <eli@patch.sh>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…itmono-dev#1586)

- Remove edit option under Tags
- Fix path duplication bug to prevent version tags from appearing twice
- Fetch latest commit data and improve date display
- Add avatar info when creating new files/folders
…no-dev#1594)

* refactor: rm user table && fix tag pointing to wrong tree hash

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

cargo fmt

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

* accept reviews

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>

---------

Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>
* [saturn]FEAT: Midware Guard in Mono

Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com>

* UPDATE: cargo fmt

Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com>

* [mono]ADD: add entitystore to mono api state

Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com>

* UPDATE:fmt

Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com>

---------

Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com>
* [mono]FIX: Change Resolve Auth to Reviewer

Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com>

* UPDATE: user username from campsiteAPI

Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com>

---------

Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com>
…tmono-dev#1598)

* feat: Implement online file editor and Diff preview functionality
 - Provide editing and Diff preview modes
 - Support file renaming feature
 - Fix blame timeline
 - Fix lastCommit avatar display

* Update moon/apps/web/components/CodeView/BlobView/BlobEditor.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: 卷娄 <zhaokang.r2cn@isrc.iscas.ac.cn>

* Update moon/apps/web/components/CodeView/CommitHistory.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: 卷娄 <zhaokang.r2cn@isrc.iscas.ac.cn>

---------

Signed-off-by: 卷娄 <zhaokang.r2cn@isrc.iscas.ac.cn>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ono-dev#1599)

* fix: Add CL filter box echo functionality and multiple UI fixes

 - Add filter condition echo functionality to CL list
 - Fix tag editor scroll synchronization issue
 - Fix double line break issue when creating files with Enter key
 - Fix clone path display issue showing "main"
 - Fix UI misalignment in tag dropdown list

* fix: Add CL filter box echo functionality and multiple UI fixes

 - Add filter condition echo functionality to CL list
 - Fix tag editor scroll synchronization issue
 - Fix double line break issue when creating files with Enter key
 - Fix clone path display issue showing "main"
 - Fix UI misalignment in tag dropdown list
…e for Issue and CL (gitmono-dev#1601)

- Leverage additional object with filter state as single source of truth
- Fix null value issue when selecting labels in Issue
- Fix bug where labels are cleared after selecting assignee in Issue/CL
- Comment out Search component in Issue, replace with read-only filter display
- Simplify dropdown configs to directly update state
@genedna genedna requested a review from Copilot February 3, 2026 05:58
@genedna

genedna commented Feb 3, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@genedna

genedna commented Feb 3, 2026

Copy link
Copy Markdown
Collaborator

@claude

@github-actions

github-actions Bot commented Feb 3, 2026

Copy link
Copy Markdown

Claude finished @genedna's task in 1m 35s —— View job


Code Review Complete ✓

I've completed a comprehensive review of PR #1877. Here are my findings:


Overview

This PR successfully implements automatic CL (Change List) creation and build triggering after file edits, replacing the previous direct commit approach. The implementation is generally well-structured with good separation of concerns.


Strengths

  1. Architecture: Clean separation between the web edit handler, CL management, and build triggering
  2. Comments: All code comments are properly in English (previous review concern addressed ✓)
  3. Code Quality: The refactor from sort_by to sort_by_key in commit_ops.rs:457 is a good improvement
  4. Extensibility: The new EditCLMode enum provides flexibility for CL reuse strategies

Issues & Recommendations

🔴 Critical Issues

  1. Error Handling - Silent Failure in Background Task (mono_api_service.rs:1174-1180)

    tokio::spawn(async move {
        let _ = BuildTriggerService::build_by_context(
            storage,
            git_cache,
            bellatrix.into(),
            cl.into(),
        )
        .await;
    });

    Issue: The let _ = pattern silently discards build errors. Users won't know if their build failed to trigger.

    Recommendation: Add error logging at minimum:

    tokio::spawn(async move {
        if let Err(e) = BuildTriggerService::build_by_context(...).await {
            tracing::error!("Failed to trigger build for CL {}: {}", cl_link, e);
        }
    });

    Fix this →

  2. Breaking API Change (model/git.rs:200)

    pub struct EditFilePayload {
        // ...
        pub mode: EditCLMode,  // ← Not optional!
    }

    Issue: Adding a required field breaks backward compatibility with existing API clients.

    Recommendation: Make it optional with a sensible default:

    #[serde(default = "default_edit_mode")]
    pub mode: EditCLMode,
    
    fn default_edit_mode() -> EditCLMode {
        EditCLMode::TryReuse(None)
    }

    Fix this →

🟡 Important Issues

  1. Incomplete Error Context (mono_api_service.rs:1085-1090)

    let from_hash = self
        .storage
        .mono_storage()
        .get_main_ref(repo_path)
        .await?
        .ok_or_else(|| MegaError::Other("Main ref not found".to_string()))?

    Issue: Error message doesn't include which repo path failed, making debugging difficult.

    Recommendation:

    .ok_or_else(|| MegaError::Other(format!("Main ref not found for repo: {}", repo_path)))?

    Fix this →

  2. Potential Path Parsing Issue (mono_api_service.rs:1139-1142)

    let repo_path = path
        .parent()
        .map(|p| p.to_string_lossy().to_string())
        .unwrap_or_else(|| "/".to_string());

    Issue: If file_path is just a filename (no path separators), parent() returns Some(""), not None. This could create an empty string repo path instead of "/".

    Recommendation: Add explicit empty string handling:

    let repo_path = path
        .parent()
        .and_then(|p| {
            let s = p.to_string_lossy().to_string();
            if s.is_empty() { None } else { Some(s) }
        })
        .unwrap_or_else(|| "/".to_string());
  3. CL Update Race Condition (mono_api_service.rs:1155-1161)

    if let Some(existing_cl) = storage.get_open_cl_by_path(&repo_path, username).await... {
        storage.update_cl_to_hash(existing_cl.clone(), to_hash).await?;
        Ok(existing_cl)
    }

    Issue: Between fetching and updating, another request could modify the same CL, leading to inconsistent state.

    Recommendation: Implement optimistic locking or a transaction to ensure atomicity.

🟢 Minor Issues

  1. Missing field documentation (model/git.rs:201)
    The mode field lacks a doc comment explaining when to use ForceCreate vs TryReuse.

  2. Inconsistent naming (web_edit_handler.rs:32)
    The fallback CL link format "webedit-{timestamp}-{hash}" doesn't match other CL link generation patterns. Should use generate_link() consistently.

  3. Test Coverage: No tests included for the new CL workflow. Consider adding:

    • Unit tests for find_or_create_cl_for_edit logic
    • Integration tests for the build trigger flow
    • Edge case tests (empty paths, concurrent edits, etc.)

Security Considerations

Good: No SQL injection risks (using ORM)
Good: No obvious authentication bypasses
⚠️ Consider: Add rate limiting for CL creation to prevent abuse


Performance Considerations

Good: Background task spawning prevents blocking the edit response
⚠️ Consider: The get_builds_for_commit call in web_edit_handler.rs:34 could be expensive for large changes. Consider adding caching or limits.


Documentation

  • Missing field documentation for new EditFilePayload.mode and EditFilePayload.skip_build
  • The PR description checkboxes are well-maintained ✓
  • Consider adding inline examples in the doc comments

Summary

The PR implements the required functionality correctly, but has 2 critical issues that should be addressed before merging:

  1. Silent error handling in background build tasks
  2. Breaking API change with required mode field

The code is otherwise well-structured with good English documentation. After addressing these issues, this will be a solid implementation of the CL workflow.


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

ℹ️ 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 thread ceres/src/model/git.rs
Comment on lines +1109 to +1113
let path = PathBuf::from(file_path);
let repo_path = path
.parent()
.map(|p| p.to_string_lossy().to_string())
.unwrap_or_else(|| "/".to_string());

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 Resolve repo root before looking up main ref

Here repo_path is derived from the immediate parent directory of the edited file. For edits under nested subdirectories (e.g., /repo/src/file.rs), this becomes /repo/src, but get_main_ref is keyed by the repository root path (e.g., /repo). That makes create_new_cl fail with “Main ref not found” for typical edits and blocks CL creation/builds. The repo root should be resolved before calling get_main_ref rather than using the file’s parent directory.

Useful? React with 👍 / 👎.

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread ceres/src/api_service/mono_api_service.rs Outdated
Comment on lines +1101 to +1108
async fn find_or_create_cl_for_edit(
&self,
mode: EditCLMode,
to_hash: &str,
commit_message: &str,
file_path: &str,
username: &str,
) -> Result<mega_cl::Model, GitError> {

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

The new CL creation/reuse flow for web edits (find_or_create_cl_for_edit, create_new_cl) and build triggering via trigger_build_for_cl introduce non-trivial behavior (different EditCLMode paths, skip_build flag, background build trigger) but there are no targeted tests covering these code paths, even though MonoApiService already has a test module. Please add tests that exercise at least ForceCreate, TryReuse (with/without link), and skip_build behavior to guard against regressions in the CL/build workflow.

Copilot generated this review using guidance from repository custom instructions.
Comment thread ceres/src/model/git.rs
Comment thread ceres/src/api_service/mono_api_service.rs Outdated
@Chen-Rong-Zi Chen-Rong-Zi force-pushed the issue-1872 branch 2 times, most recently from 89426b5 to b5bef43 Compare February 3, 2026 07:01
Signed-off-by: miliu2cc <miliu2cc@gmail.com>
@Chen-Rong-Zi Chen-Rong-Zi force-pushed the issue-1872 branch 8 times, most recently from 48cc3da to 0adcfd4 Compare February 3, 2026 08:08
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
---
修改github GPG验证配置

Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
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.