Skip to content

Commit 9cb41c0

Browse files
committed
feat: support ai lint and always show inline completions
1 parent 461d510 commit 9cb41c0

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/ai/browser/ai-native.contribution.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import {
66
IChatContent,
77
IChatProgress,
88
IAIBackService,
9+
CancellationToken,
10+
ChatResponse,
911
} from '@opensumi/ide-core-common';
1012
import { ClientAppContribution, Domain, getIcon } from '@opensumi/ide-core-browser';
1113
import { ComponentContribution, ComponentRegistry } from '@opensumi/ide-core-browser/lib/layout';
12-
import { AINativeCoreContribution, ERunStrategy, IChatFeatureRegistry, IInlineChatFeatureRegistry, IRenameCandidatesProviderRegistry, ITerminalProviderRegistry, TChatSlashCommandSend, TerminalSuggestionReadableStream } from '@opensumi/ide-ai-native/lib/browser/types';
14+
import { AINativeCoreContribution, ERunStrategy, IChatFeatureRegistry, IInlineChatFeatureRegistry, IProblemFixContext, IProblemFixProviderRegistry, IRenameCandidatesProviderRegistry, ITerminalProviderRegistry, TChatSlashCommandSend, TerminalSuggestionReadableStream } from '@opensumi/ide-ai-native/lib/browser/types';
1315
import { ICodeEditor, MarkdownString, NewSymbolNameTag } from '@opensumi/ide-monaco';
1416
import { MessageService } from '@opensumi/ide-overlay/lib/browser/message.service';
1517
import { BaseTerminalDetectionLineMatcher, JavaMatcher, MatcherType, NodeMatcher, NPMMatcher, ShellMatcher, TSCMatcher } from '@opensumi/ide-ai-native/lib/browser/contrib/terminal/matcher';
@@ -518,4 +520,35 @@ export class AINativeContribution implements ComponentContribution, AINativeCore
518520
return stream;
519521
});
520522
}
523+
524+
525+
registerProblemFixFeature(registry: IProblemFixProviderRegistry): void {
526+
registry.registerHoverFixProvider({
527+
provideFix: async (
528+
editor: ICodeEditor,
529+
context: IProblemFixContext,
530+
token: CancellationToken,
531+
): Promise<ChatResponse | InlineChatController> => {
532+
const { marker, editRange } = context;
533+
534+
const prompt = `原始代码内容:
535+
\`\`\`
536+
${editor.getModel()!.getValueInRange(editRange)}
537+
\`\`\`
538+
539+
lint error 信息:
540+
541+
${marker.message}.
542+
543+
请根据 lint error 信息修复代码!
544+
不需要任何解释,只要返回修复后的代码块内容`;
545+
546+
const controller = new InlineChatController({ enableCodeblockRender: true });
547+
const stream = await this.aiBackService.requestStream(prompt, {}, token);
548+
controller.mountReadable(stream);
549+
550+
return controller;
551+
},
552+
});
553+
}
521554
}

src/bootstrap/browser/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ async function renderApp() {
170170
extensionStorageDirName: electronEnv.metadata.environment.dataFolderName,
171171
extWorkerHost: electronEnv.metadata.workerHostEntry ? URI.file(electronEnv.metadata.workerHostEntry).toString() : undefined,
172172
defaultPreferences: {
173-
[AINativeSettingSectionsId.InlineCompletionsPromptEngineeringEnabled]: false,
174173
'settings.userBeforeWorkspace': true,
175174
'general.icon': 'vs-seti',
175+
[AINativeSettingSectionsId.IntelligentCompletionsPromptEngineeringEnabled]: false,
176+
// 总是显示智能提示
177+
[AINativeSettingSectionsId.IntelligentCompletionsAlwaysVisible]: true,
176178
},
177179
onigWasmUri: URI.file(electronEnv.onigWasmPath).toString(true),
178180
treeSitterWasmDirectoryUri: URI.file(electronEnv.treeSitterWasmDirectoryPath).toString(true),

0 commit comments

Comments
 (0)