mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 03:54:24 +01:00
tweak inline chat hint (#234544)
This commit is contained in:
@@ -27,6 +27,7 @@ import './media/inlineChat.css';
|
||||
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
|
||||
import { ICommandService } from '../../../../platform/commands/common/commands.js';
|
||||
import { InlineCompletionsController } from '../../../../editor/contrib/inlineCompletions/browser/controller/inlineCompletionsController.js';
|
||||
import { ChatAgentLocation, IChatAgentService } from '../../chat/common/chatAgents.js';
|
||||
|
||||
export const CTX_INLINE_CHAT_SHOWING_HINT = new RawContextKey<boolean>('inlineChatShowingHint', false, localize('inlineChatShowingHint', "Whether inline chat shows a contextual hint"));
|
||||
|
||||
@@ -154,6 +155,7 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@ICommandService commandService: ICommandService,
|
||||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@IChatAgentService chatAgentService: IChatAgentService,
|
||||
) {
|
||||
super();
|
||||
this._editor = editor;
|
||||
@@ -179,44 +181,51 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
|
||||
}
|
||||
}));
|
||||
|
||||
const posObs = observableFromEvent(editor.onDidChangeCursorPosition, () => editor.getPosition());
|
||||
|
||||
const decos = this._editor.createDecorationsCollection();
|
||||
|
||||
const modelObs = observableFromEvent(editor.onDidChangeModel, () => editor.getModel());
|
||||
const posObs = observableFromEvent(editor.onDidChangeCursorPosition, () => editor.getPosition());
|
||||
const keyObs = observableFromEvent(keybindingService.onDidUpdateKeybindings, _ => keybindingService.lookupKeybinding(ACTION_START)?.getLabel());
|
||||
|
||||
|
||||
this._store.add(autorun(r => {
|
||||
|
||||
const ghostState = ghostCtrl?.model.read(r)?.state.read(r);
|
||||
const visible = this._visibilityObs.read(r);
|
||||
const kb = keyObs.read(r);
|
||||
const position = posObs.read(r);
|
||||
const model = modelObs.read(r);
|
||||
|
||||
// update context key
|
||||
this._ctxShowingHint.set(visible);
|
||||
|
||||
if (!visible || !kb || !position || ghostState !== undefined) {
|
||||
if (!visible || !kb || !position || ghostState !== undefined || !model) {
|
||||
decos.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
const column = this._editor.getModel()?.getLineMaxColumn(position.lineNumber);
|
||||
if (!column) {
|
||||
return;
|
||||
const isEol = model.getLineMaxColumn(position.lineNumber) === position.column;
|
||||
|
||||
let content: string;
|
||||
let inlineClassName: string;
|
||||
|
||||
if (isEol) {
|
||||
const agentName = chatAgentService.getDefaultAgent(ChatAgentLocation.Editor)?.fullName ?? localize('defaultTitle', "Chat");
|
||||
content = '\u00A0' + localize('title', "{0} to continue with {1}...", kb, agentName);
|
||||
inlineClassName = `inline-chat-hint${decos.length === 0 ? ' first' : ''}`;
|
||||
} else {
|
||||
content = '\u200a' + kb + '\u200a';
|
||||
inlineClassName = 'inline-chat-hint embedded';
|
||||
}
|
||||
|
||||
const range = Range.fromPositions(position);
|
||||
|
||||
decos.set([{
|
||||
range,
|
||||
range: Range.fromPositions(position),
|
||||
options: {
|
||||
description: 'inline-chat-hint-line',
|
||||
showIfCollapsed: true,
|
||||
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
||||
after: {
|
||||
inlineClassName: 'inline-chat-hint',
|
||||
content: '\u00A0' + localize('ddd', "{0} to chat", kb),
|
||||
content,
|
||||
inlineClassName,
|
||||
inlineClassNameAffectsLetterSpacing: true,
|
||||
cursorStops: InjectedTextCursorStops.Both,
|
||||
attachedData: this
|
||||
|
||||
@@ -340,10 +340,37 @@
|
||||
|
||||
/* HINT */
|
||||
|
||||
|
||||
.monaco-workbench .monaco-editor .inline-chat-hint {
|
||||
/* padding: 0 8px; */
|
||||
cursor: pointer;
|
||||
color: var(--vscode-editorGhostText-foreground);
|
||||
border: 1px solid var(--vscode-editorGhostText-border);
|
||||
background-image: linear-gradient(45deg, var(--vscode-editorGhostText-foreground), 95%, transparent);
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.monaco-workbench .monaco-editor .inline-chat-hint.embedded {
|
||||
border: 1px solid var(--vscode-editorSuggestWidget-border);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
@property --inline-chat-hint-progress {
|
||||
syntax: '<percentage>';
|
||||
initial-value: 33%;
|
||||
inherits: false;
|
||||
}
|
||||
|
||||
@keyframes ltr {
|
||||
0% {
|
||||
--inline-chat-hint-progress: 33%;
|
||||
}
|
||||
100% {
|
||||
--inline-chat-hint-progress: 95%;
|
||||
}
|
||||
}
|
||||
|
||||
.monaco-workbench .monaco-editor .inline-chat-hint.first {
|
||||
background-image: linear-gradient(45deg, var(--vscode-editorGhostText-foreground), var(--inline-chat-hint-progress), transparent);
|
||||
animation: 75ms ltr ease-in forwards;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user