Skip to content

Commit

Permalink
Merge branch 'main' into feat/move-terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricbet authored Feb 10, 2025
2 parents f84098b + bfefebb commit e76df6c
Show file tree
Hide file tree
Showing 23 changed files with 275 additions and 112 deletions.
4 changes: 2 additions & 2 deletions packages/ai-native/src/browser/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
MaybePromise,
MergeConflictEditorMode,
} from '@opensumi/ide-core-common';
import { ICodeEditor, IRange, ITextModel, NewSymbolNamesProvider, Position } from '@opensumi/ide-monaco';
import { ICodeEditor, IRange, ISelection, ITextModel, NewSymbolNamesProvider, Position } from '@opensumi/ide-monaco';
import { SumiReadableStream } from '@opensumi/ide-utils/lib/stream';
import { IMarker } from '@opensumi/monaco-editor-core/esm/vs/platform/markers/common/markers';

Expand Down Expand Up @@ -44,7 +44,7 @@ interface IBaseInlineChatHandler<T extends any[]> {

export type IEditorInlineChatHandler = IBaseInlineChatHandler<[editor: ICodeEditor, token: CancellationToken]>;
export type IInteractiveInputHandler = IBaseInlineChatHandler<
[editor: ICodeEditor, value: string, token: CancellationToken]
[editor: ICodeEditor, selection: ISelection, value: string, token: CancellationToken]
>;

export enum ERunStrategy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,6 @@ export class AIInlineContentWidget extends ReactInlineContentWidget {
super(editor);

this.aiNativeContextKey = this.injector.get(AINativeContextKey, [this.editor.contextKeyService]);
this.addDispose(
this.editor.onDidLayoutChange(() => {
if (this.isOutOfArea()) {
this.dispose();
}
}),
);
}

public launchChatStatus(status: EInlineChatStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,14 @@ export class LiveInlineDiffPreviewer extends BaseInlineDiffPreviewer<InlineStrea
const firstRemovedWidgetLineNumber = firstRemovedWidget.getLastPosition()?.lineNumber;
if (firstRemovedWidgetLineNumber <= lineNumber) {
const lineHeight = this.inlineContentWidget.getLineHeight();
const len = firstRemovedWidget.height;
const len = firstRemovedWidget.height + 1;
this.inlineContentWidget.setOffsetTop(-lineHeight * len - 4);
} else {
this.inlineContentWidget.setOffsetTop(0);
}
}
} else {
this.inlineContentWidget.setOffsetTop(0);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ interface IInlineInputWidgetRenderProps {
onInteractiveInputSend?: (value: string) => void;
onChatStatus: Event<EInlineChatStatus>;
onResultClick: (k: EResultKind) => void;
onValueChange?: (value: string) => void;
}

const InlineInputWidgetRender = (props: IInlineInputWidgetRenderProps) => {
const { defaultValue, onClose, onInteractiveInputSend, onLayoutChange, onChatStatus, onResultClick } = props;
const { defaultValue, onClose, onInteractiveInputSend, onLayoutChange, onChatStatus, onResultClick, onValueChange } =
props;
const [status, setStatus] = useState<EInlineChatStatus>(EInlineChatStatus.READY);
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);

Expand Down Expand Up @@ -69,6 +71,7 @@ const InlineInputWidgetRender = (props: IInlineInputWidgetRenderProps) => {
<InteractiveInput
autoFocus
defaultValue={defaultValue}
onValueChange={onValueChange}
onHeightChange={(height) => onLayoutChange(height)}
size='small'
placeholder={localize('aiNative.inline.chat.input.placeholder.default')}
Expand All @@ -82,16 +85,19 @@ const InlineInputWidgetRender = (props: IInlineInputWidgetRenderProps) => {
};

@Injectable({ multiple: true })
export class InlineInputChatWidget extends AIInlineContentWidget {
export class InlineInputWidget extends AIInlineContentWidget {
allowEditorOverflow = true;
positionPreference = [ContentWidgetPositionPreference.ABOVE];

protected readonly _onInteractiveInputValue = new Emitter<string>();
public readonly onInteractiveInputValue = this._onInteractiveInputValue.event;
protected readonly _onSend = new Emitter<string>();
public readonly onSend = this._onSend.event;

protected readonly _onClose = new Emitter<void>();
public readonly onClose = this._onClose.event;

protected readonly _onValueChange = new Emitter<string>();
public readonly onValueChange = this._onValueChange.event;

constructor(protected readonly editor: IMonacoCodeEditor, protected readonly defaultValue?: string) {
super(editor);
}
Expand All @@ -115,9 +121,12 @@ export class InlineInputChatWidget extends AIInlineContentWidget {
onLayoutChange={() => {
this.editor.layoutContentWidget(this);
}}
onValueChange={(value) => {
this._onValueChange.fire(value);
}}
onInteractiveInputSend={(value) => {
this.launchChatStatus(EInlineChatStatus.THINKING);
this._onInteractiveInputValue.fire(value);
this._onSend.fire(value);
}}
onResultClick={(k: EResultKind) => {
this._onResultClick.fire(k);
Expand Down
Loading

0 comments on commit e76df6c

Please sign in to comment.