Skip to content

Commit

Permalink
Merge branch 'main' into feat/support-autoClosingPairs
Browse files Browse the repository at this point in the history
  • Loading branch information
hacke2 authored Oct 25, 2024
2 parents 5c631ac + d7d8a1d commit 8fb29fa
Show file tree
Hide file tree
Showing 34 changed files with 410 additions and 200 deletions.
12 changes: 6 additions & 6 deletions packages/ai-native/src/browser/chat/chat.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getIcon, useInjectable, useUpdateOnEvent } from '@opensumi/ide-core-bro
import { Popover, PopoverPosition } from '@opensumi/ide-core-browser/lib/components';
import { EnhanceIcon } from '@opensumi/ide-core-browser/lib/components/ai-native';
import {
AISerivceType,
AIServiceType,
ActionSourceEnum,
ActionTypeEnum,
CancellationToken,
Expand Down Expand Up @@ -198,7 +198,7 @@ export const AIChatView = observer(() => {
disposer.addDispose(
chatApiService.onChatReplyMessageLaunch((data) => {
if (data.kind === 'content') {
const relationId = aiReporter.start(AISerivceType.CustomReplay, {
const relationId = aiReporter.start(AIServiceType.CustomReplay, {
message: data.content,
});
msgHistoryManager.addAssistantMessage({
Expand All @@ -207,7 +207,7 @@ export const AIChatView = observer(() => {
});
renderSimpleMarkdownReply({ chunk: data.content, relationId });
} else {
const relationId = aiReporter.start(AISerivceType.CustomReplay, {
const relationId = aiReporter.start(AIServiceType.CustomReplay, {
message: 'component#' + data.component,
});
msgHistoryManager.addAssistantMessage({
Expand All @@ -228,7 +228,7 @@ export const AIChatView = observer(() => {
list.forEach((item) => {
const { role } = item;

const relationId = aiReporter.start(AISerivceType.Chat, {
const relationId = aiReporter.start(AIServiceType.Chat, {
message: '',
});

Expand Down Expand Up @@ -290,7 +290,7 @@ export const AIChatView = observer(() => {
disposer.addDispose(
chatAgentService.onDidSendMessage((chunk) => {
const newChunk = chunk as IChatComponent | IChatContent;
const relationId = aiReporter.start(AISerivceType.Agent, {
const relationId = aiReporter.start(AIServiceType.Agent, {
message: '',
});

Expand Down Expand Up @@ -495,7 +495,7 @@ export const AIChatView = observer(() => {
aiChatService.setLatestRequestId(request.requestId);

const startTime = Date.now();
const reportType = ChatProxyService.AGENT_ID === agentId ? AISerivceType.Chat : AISerivceType.Agent;
const reportType = ChatProxyService.AGENT_ID === agentId ? AIServiceType.Chat : AIServiceType.Agent;
const relationId = aiReporter.start(command || reportType, {
message,
agentId,
Expand Down
5 changes: 0 additions & 5 deletions packages/ai-native/src/browser/components/ChatMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ export const ChatMarkdown = (props: MarkdownProps) => {
typeof props.markdown === 'string' ? new MarkdownString(props.markdown) : props.markdown;

const renderer: MarkdownReactRenderer = new MarkdownReactRenderer();
renderer.link = (href: string, text: ReactNode): React.ReactElement => (
<a rel='noopener' target='_blank' href={href} title={href}>
{text}
</a>
);
renderer.code = (code, lang) => {
const language = postProcessCodeBlockLanguageId(lang);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { empty } from '@opensumi/ide-utils/lib/strings';
import { InlineCompletionContextKeys } from '@opensumi/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/inlineCompletionContextKeys';

import { IAIInlineCompletionsProvider } from '../../../common';
import { AINativeContextKey } from '../../contextkey/ai-native.contextkey.service';
import { AINativeContextKey } from '../../ai-core.contextkeys';
import { BaseAIMonacoEditorController } from '../base';
import { IIntelligentCompletionsResult } from '../intelligent-completions';
import { IntelligentCompletionsRegistry } from '../intelligent-completions/intelligent-completions.feature.registry';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
URI,
uuid,
} from '@opensumi/ide-core-common';
import { AISerivceType, IAIReporter } from '@opensumi/ide-core-common/lib/types/ai-native/reporter';
import { AIServiceType, IAIReporter } from '@opensumi/ide-core-common/lib/types/ai-native/reporter';
import { WorkbenchEditorService } from '@opensumi/ide-editor';
import { WorkbenchEditorServiceImpl } from '@opensumi/ide-editor/lib/browser/workbench-editor.service';
import * as monaco from '@opensumi/ide-monaco';
Expand Down Expand Up @@ -165,7 +165,7 @@ export class InlineCompletionRequestTask extends Disposable {
let completeResult: IIntelligentCompletionsResult | undefined;
const cacheData = this.promptCache.getCache(requestBean);
const relationId =
cacheData?.relationId || this.aiReporter.start(AISerivceType.Completion, { message: AISerivceType.Completion });
cacheData?.relationId || this.aiReporter.start(AIServiceType.Completion, { message: AIServiceType.Completion });

this.aiCompletionsService.setLastRelationId(relationId);
// 如果存在缓存
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Disposable } from '@opensumi/ide-core-common';
import { IRange, InlineCompletion } from '@opensumi/ide-monaco';
import { Disposable, ECodeEditsSourceTyping } from '@opensumi/ide-core-common';
import { IPosition, IRange, InlineCompletion } from '@opensumi/ide-monaco';

import type { ILineChangeData } from './source/line-change.source';
import type { ILinterErrorData } from './source/lint-error.source';
Expand All @@ -12,14 +12,9 @@ export interface IIntelligentCompletionsResult<T = any> {
extra?: T;
}

export enum ECodeEditsSource {
LinterErrors = 'lint_errors',
LineChange = 'line_change',
}

export type ICodeEditsContextBean =
| { typing: ECodeEditsSource.LinterErrors; data: ILinterErrorData }
| { typing: ECodeEditsSource.LineChange; data: ILineChangeData };
| { typing: ECodeEditsSourceTyping.LinterErrors; position: IPosition; data: ILinterErrorData }
| { typing: ECodeEditsSourceTyping.LineChange; position: IPosition; data: ILineChangeData };

export interface ICodeEdit {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@opensumi/ide-core-browser';
import {
AI_MULTI_LINE_COMPLETION_ACCEPT,
AI_MULTI_LINE_COMPLETION_HIDE,
AI_MULTI_LINE_COMPLETION_DISCARD,
} from '@opensumi/ide-core-browser/lib/ai-native/command';
import { MultiLineEditsIsVisible } from '@opensumi/ide-core-browser/lib/contextkey/ai-native';
import { CommandContribution, CommandRegistry, Domain } from '@opensumi/ide-core-common';
Expand All @@ -23,11 +23,11 @@ export class IntelligentCompletionsContribution implements KeybindingContributio
private readonly workbenchEditorService: WorkbenchEditorServiceImpl;

registerCommands(commands: CommandRegistry): void {
commands.registerCommand(AI_MULTI_LINE_COMPLETION_HIDE, {
commands.registerCommand(AI_MULTI_LINE_COMPLETION_DISCARD, {
execute: () => {
const editor = this.workbenchEditorService.currentCodeEditor;
if (editor) {
IntelligentCompletionsController.get(editor.monacoEditor)?.hide();
IntelligentCompletionsController.get(editor.monacoEditor)?.discard.get();
}
},
});
Expand All @@ -36,15 +36,15 @@ export class IntelligentCompletionsContribution implements KeybindingContributio
execute: () => {
const editor = this.workbenchEditorService.currentCodeEditor;
if (editor) {
IntelligentCompletionsController.get(editor.monacoEditor)?.accept();
IntelligentCompletionsController.get(editor.monacoEditor)?.accept.get();
}
},
});
}

registerKeybindings(keybindings: KeybindingRegistry): void {
keybindings.registerKeybinding({
command: AI_MULTI_LINE_COMPLETION_HIDE.id,
command: AI_MULTI_LINE_COMPLETION_DISCARD.id,
keybinding: Key.ESCAPE.code,
when: MultiLineEditsIsVisible.raw,
priority: 100,
Expand Down
Loading

0 comments on commit 8fb29fa

Please sign in to comment.