Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const PromptInput: Component = () => {

const [text, setText] = createSignal("")
const [ghostText, setGhostText] = createSignal("")
const [chatAutocompleteEnabled, setChatAutocompleteEnabled] = createSignal(false)
let textareaRef: HTMLTextAreaElement | undefined
let debounceTimer: ReturnType<typeof setTimeout> | undefined
let requestCounter = 0
Expand All @@ -32,7 +33,7 @@ export const PromptInput: Component = () => {
const isDisabled = () => !server.isConnected()
const canSend = () => text().trim().length > 0 && !isBusy() && !isDisabled()

// Listen for chat completion results from the extension
// Listen for chat completion results and autocomplete settings from the extension
const unsubscribe = vscode.onMessage((message) => {
if (message.type === "chatCompletionResult") {
const result = message as { type: "chatCompletionResult"; text: string; requestId: string }
Expand All @@ -42,8 +43,17 @@ export const PromptInput: Component = () => {
setGhostText(result.text)
}
}
if (message.type === "autocompleteSettingsLoaded") {
const settings = (
message as { type: "autocompleteSettingsLoaded"; settings: { enableChatAutocomplete: boolean } }
).settings
setChatAutocompleteEnabled(settings.enableChatAutocomplete)
}
})

// Request autocomplete settings so we know whether chat autocomplete is enabled
vscode.postMessage({ type: "requestAutocompleteSettings" })

onCleanup(() => {
unsubscribe()
if (debounceTimer) {
Expand All @@ -53,7 +63,7 @@ export const PromptInput: Component = () => {

// Request autocomplete from the extension
const requestAutocomplete = (currentText: string) => {
if (currentText.length < MIN_TEXT_LENGTH || isDisabled()) {
if (!chatAutocompleteEnabled() || currentText.length < MIN_TEXT_LENGTH || isDisabled()) {
setGhostText("")
return
}
Expand Down
Loading