Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support ai 3 way merge #3404

Merged
merged 19 commits into from
Mar 19, 2024
Merged

feat: support ai 3 way merge #3404

merged 19 commits into from
Mar 19, 2024

Conversation

Ricbet
Copy link
Member

@Ricbet Ricbet commented Mar 14, 2024

Types

  • 🎉 New Features

Background or solution

  1. pick chore/ai-native-module 分支提交的 3way 模式下的智能解决冲突等相关内容
  2. 优化代码
  3. 实现 registerResolveConflictFeature API

具体使用方式见:

registerResolveConflictFeature(registry: IResolveConflictRegistry): void {
  registry.registerResolveConflictProvider(MergeConflictEditorMode['3way'], {
    providerRequest: async (contentMetadata, options, token) => {
      const { isRegenerate } = options;
      const cancelController = new AbortController();
      const { signal } = cancelController;

      token.onCancellationRequested(() => {
        cancelController.abort();
      });

      try {
        let prompt = '';

        if (isRegenerate) {
          prompt = mergeConflictPromptManager.convertDefaultThreeWayRegeneratePrompt(contentMetadata);
        } else {
          prompt = mergeConflictPromptManager.convertDefaultThreeWayPrompt(contentMetadata);
        }

        await new Promise((resolve, reject) => {
          const timeout = setTimeout(resolve, 2000);

          signal.addEventListener('abort', () => {
            clearTimeout(timeout);
            reject(new DOMException('Aborted', 'AbortError'));
          });
        });

        return new ReplyResponse('Resolved successfully!');
      } catch (error) {
        if (error.name === 'AbortError') {
          return new CancelResponse();
        }
        throw error;
      }
    },
  });
}
  • providerRequest 主要用于在点击“智能解决冲突”按钮时所触发的请求,要求返回 ChatResponse 类型
  • mergeConflictPromptManager 是智能解决冲突时的 prompt 封装,以及提供默认的 prompt 文本。集成方可自行选择是否调用

该 pr 先实现 3way 模式下的智能解决冲突,传统模式的解决冲突另开 pr 实现

image

Changelog

@Ricbet Ricbet added v3 OpenSumi 3.0 AI labels Mar 14, 2024
@Ricbet Ricbet requested review from erha19 and bytemain March 14, 2024 11:15
@Ricbet Ricbet self-assigned this Mar 14, 2024
@opensumi opensumi bot added the 🎨 feature feature required label Mar 14, 2024
@Ricbet Ricbet force-pushed the feat/support-ai-3-way-merge branch 2 times, most recently from 8ece6d1 to 99bbe50 Compare March 15, 2024 08:59
@Ricbet Ricbet changed the title WIP: feat: support ai 3 way merge feat: support ai 3 way merge Mar 15, 2024
@Ricbet Ricbet force-pushed the feat/support-ai-3-way-merge branch from f91e174 to 7f99be9 Compare March 18, 2024 03:42
Copy link

codecov bot commented Mar 18, 2024

Codecov Report

Attention: Patch coverage is 26.80000% with 366 lines in your changes are missing coverage. Please review.

Project coverage is 57.19%. Comparing base (e750e96) to head (d2fd589).

Files Patch % Lines
...trib/merge-editor/view/editors/resultCodeEditor.ts 33.51% 103 Missing and 16 partials ⚠️
...owser/contrib/merge-editor/merge-editor.service.ts 12.63% 74 Missing and 9 partials ⚠️
...owser/contrib/merge-editor/view/actions-manager.ts 10.52% 44 Missing and 7 partials ⚠️
...c/browser/contrib/merge-editor/model/line-range.ts 22.91% 34 Missing and 3 partials ⚠️
...e-browser/src/ai-native/conflict-report.service.ts 30.55% 21 Missing and 4 partials ⚠️
...native/src/common/prompts/merge-conflict-prompt.ts 0.00% 15 Missing ⚠️
.../merge-conflict/merge-conflict.feature.registry.ts 0.00% 13 Missing and 1 partial ⚠️
packages/core-common/src/types/ai-native/index.ts 41.17% 10 Missing ⚠️
packages/ai-native/src/browser/index.ts 0.00% 3 Missing ⚠️
packages/design/src/browser/index.ts 0.00% 2 Missing ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3404      +/-   ##
==========================================
- Coverage   57.34%   57.19%   -0.15%     
==========================================
  Files        1433     1436       +3     
  Lines       88301    88703     +402     
  Branches    18192    18274      +82     
==========================================
+ Hits        50633    50731      +98     
- Misses      34272    34546     +274     
- Partials     3396     3426      +30     
Flag Coverage Δ
jsdom 52.44% <26.80%> (-0.13%) ⬇️
node 15.97% <2.80%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Ricbet and others added 17 commits March 18, 2024 17:48
* feat: support 3-way stop widget

* feat: support 3-way stop widget
* refactor: ai native back service

* fix: organize import
* feat: support stop all ai resolve & regenerate

* fix: one-click ai resolve
* fix: 3-way format provider

* style: btn id
* fix: 3-way merge-range error for range

* feat: ai merge queue

fix: 3-way widget ui
* fix: widget position

* feat: add merge conflict report

* feat: ai accept report

* chore: update

* chore: add git stage report

* chore: update report

---------

Co-authored-by: John <qingyi.xjh@antgroup.com>

fix: merge editor float components

fix: format
* fix: resolve conflict report

* fix: improve report

fix: add ai output num report

fix: conflict click num report

fix: type
@Ricbet Ricbet force-pushed the feat/support-ai-3-way-merge branch from 7f99be9 to 55361ba Compare March 18, 2024 09:53
@Ricbet Ricbet merged commit 3752ee6 into main Mar 19, 2024
11 checks passed
@Ricbet Ricbet deleted the feat/support-ai-3-way-merge branch March 19, 2024 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI 🎨 feature feature required v3 OpenSumi 3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants