Merge branch 'main' into feat-mistral-new and fix conflict introduced by Deepseek

This commit is contained in:
Jérôme Commaret 2025-01-24 14:22:06 +01:00
commit ff83bb5edc
32 changed files with 1299 additions and 1447 deletions

View file

@ -8,7 +8,7 @@ Void's code mostly lives in `src/vs/workbench/contrib/void/` and `src/vs/platfor
There are a few ways to contribute: There are a few ways to contribute:
- 👨‍💻 Build new features - see [Roadmap](https://github.com/orgs/voideditor/projects/2/views/3) or [Issues](https://github.com/voideditor/void/issues). - 👨‍💻 Build new features - see [Roadmap](https://github.com/orgs/voideditor/projects/2/views/3) and [Issues](https://github.com/voideditor/void/issues).
- 💡 Make suggestions in our [Discord](https://discord.gg/RSNjgaugJs). - 💡 Make suggestions in our [Discord](https://discord.gg/RSNjgaugJs).

View file

@ -11,23 +11,22 @@
Void is the open-source Cursor alternative. Void is the open-source Cursor alternative.
This repo contains the full sourcecode for Void. We are currently in [open beta](https://voideditor.com/) for Discord members (see `#announcements` to download), and we have a waitlist for our official release. If you're new, welcome! This repo contains the full sourcecode for Void. We are currently in [open beta](https://voideditor.com/) for Discord members (see the `announcements` channel), with a waitlist for our official release. If you're new, welcome!
- 👋 [Discord](https://discord.gg/RSNjgaugJs) - 👋 [Discord](https://discord.gg/RSNjgaugJs)
- 🔨 [Contribute](https://github.com/voideditor/void/blob/main/CONTRIBUTING.md)
- 🚙 [Roadmap](https://github.com/orgs/voideditor/projects/2) - 🚙 [Roadmap](https://github.com/orgs/voideditor/projects/2)
- 📝 [Changelog](https://voideditor.com/changelog) - 📝 [Changelog](https://voideditor.com/changelog)
- 🔨 [Contribute](https://github.com/voideditor/void/blob/main/CONTRIBUTING.md)
## Contributing ## Contributing
1. Feel free to attend a weekly meeting in our Discord channel if you'd like to contribute!
1. To get started developing Void, see [`CONTRIBUTING.md`](https://github.com/voideditor/void/blob/main/CONTRIBUTING.md). 2. To get started working on Void, see [Contributing](https://github.com/voideditor/void/blob/main/CONTRIBUTING.md).
2. Feel free to attend a weekly meeting in our Discord channel!
3. We're open to collaborations of all types - just reach out. 3. We're open to collaborations of all types - just reach out.
@ -37,4 +36,4 @@ This repo contains the full sourcecode for Void. We are currently in [open beta]
Void is a fork of the [vscode](https://github.com/microsoft/vscode) repository. For some useful links on VSCode, see [`VOID_USEFUL_LINKS.md`](https://github.com/voideditor/void/blob/main/VOID_USEFUL_LINKS.md). Void is a fork of the [vscode](https://github.com/microsoft/vscode) repository. For some useful links on VSCode, see [`VOID_USEFUL_LINKS.md`](https://github.com/voideditor/void/blob/main/VOID_USEFUL_LINKS.md).
## Support ## Support
Feel free to reach out in our Discord or contact us via email: support@voideditor.com. Feel free to reach out in our Discord or contact us via email: hello@voideditor.com.

View file

@ -23,7 +23,7 @@ AppMutex={code:GetAppMutex}
SetupMutex={#AppMutex}setup SetupMutex={#AppMutex}setup
; this is a Void icon comment. Old: WizardImageFile="{#RepoDir}\resources\win32\inno-big-100.bmp,{#RepoDir}\resources\win32\inno-big-125.bmp,{#RepoDir}\resources\win32\inno-big-150.bmp,{#RepoDir}\resources\win32\inno-big-175.bmp,{#RepoDir}\resources\win32\inno-big-200.bmp,{#RepoDir}\resources\win32\inno-big-225.bmp,{#RepoDir}\resources\win32\inno-big-250.bmp" ; this is a Void icon comment. Old: WizardImageFile="{#RepoDir}\resources\win32\inno-big-100.bmp,{#RepoDir}\resources\win32\inno-big-125.bmp,{#RepoDir}\resources\win32\inno-big-150.bmp,{#RepoDir}\resources\win32\inno-big-175.bmp,{#RepoDir}\resources\win32\inno-big-200.bmp,{#RepoDir}\resources\win32\inno-big-225.bmp,{#RepoDir}\resources\win32\inno-big-250.bmp"
; this is a Void icon comment. Old: WizardSmallImageFile="{#RepoDir}\resources\win32\inno-small-100.bmp,{#RepoDir}\resources\win32\inno-small-125.bmp,{#RepoDir}\resources\win32\inno-small-150.bmp,{#RepoDir}\resources\win32\inno-small-175.bmp,{#RepoDir}\resources\win32\inno-small-200.bmp,{#RepoDir}\resources\win32\inno-small-225.bmp,{#RepoDir}\resources\win32\inno-small-250.bmp" ; this is a Void icon comment. Old: WizardSmallImageFile="{#RepoDir}\resources\win32\inno-small-100.bmp,{#RepoDir}\resources\win32\inno-small-125.bmp,{#RepoDir}\resources\win32\inno-small-150.bmp,{#RepoDir}\resources\win32\inno-small-175.bmp,{#RepoDir}\resources\win32\inno-small-200.bmp,{#RepoDir}\resources\win32\inno-small-225.bmp,{#RepoDir}\resources\win32\inno-small-250.bmp"
WizardImageFile="{#RepoDir}\resources\win32\inno-void.bmp" ; WizardImageFile="{#RepoDir}\resources\win32\inno-void.bmp"
WizardSmallImageFile="{#RepoDir}\resources\win32\inno-void.bmp" WizardSmallImageFile="{#RepoDir}\resources\win32\inno-void.bmp"
SetupIconFile={#RepoDir}\resources\win32\code.ico SetupIconFile={#RepoDir}\resources\win32\code.ico
UninstallDisplayIcon={app}\{#ExeBasename}.exe UninstallDisplayIcon={app}\{#ExeBasename}.exe

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View file

@ -98,6 +98,7 @@ export class LLMMessageService extends Disposable implements ILLMMessageService
} }
const { providerName, modelName } = modelSelection const { providerName, modelName } = modelSelection
// add ai instructions here because we don't have access to voidSettingsService on the other side of the proxy
const aiInstructions = this.voidSettingsService.state.globalSettings.aiInstructions const aiInstructions = this.voidSettingsService.state.globalSettings.aiInstructions
if (aiInstructions) if (aiInstructions)
proxyParams.messages.unshift({ role: 'system', content: aiInstructions }) proxyParams.messages.unshift({ role: 'system', content: aiInstructions })

View file

@ -30,6 +30,12 @@ export type LLMMessage = {
content: string; content: string;
} }
export type _InternalLLMMessage = {
role: 'user' | 'assistant';
content: string;
}
export type ServiceSendLLMFeatureParams = { export type ServiceSendLLMFeatureParams = {
useProviderFor: 'Ctrl+K'; useProviderFor: 'Ctrl+K';
range: IRange; range: IRange;
@ -80,7 +86,7 @@ export type EventLLMMessageOnFinalMessageParams = Parameters<OnFinalMessage>[0]
export type EventLLMMessageOnErrorParams = Parameters<OnError>[0] & { requestId: string } export type EventLLMMessageOnErrorParams = Parameters<OnError>[0] & { requestId: string }
export type _InternalSendLLMMessageFnType = (params: { export type _InternalSendLLMMessageFnType = (params: {
messages: LLMMessage[]; messages: _InternalLLMMessage[];
onText: OnText; onText: OnText;
onFinalMessage: OnFinalMessage; onFinalMessage: OnFinalMessage;
onError: OnError; onError: OnError;

View file

@ -115,8 +115,13 @@ class VoidSettingsService extends Disposable implements IVoidSettingsService {
this.waitForInitState = new Promise((res, rej) => resolver = res) this.waitForInitState = new Promise((res, rej) => resolver = res)
// read and update the actual state immediately // read and update the actual state immediately
this._readState().then(s => { this._readState().then(readS => {
this.state = s
// THIS IS A HACK BECAUSE WE ADDED DEEPSEEK
const deepseekAdd = { deepseek: defaultSettingsOfProvider['deepseek'] }
readS = { ...readS, settingsOfProvider: { ...deepseekAdd, ...readS.settingsOfProvider, } }
this.state = readS
resolver() resolver()
this._onDidChangeState.fire('all') this._onDidChangeState.fire('all')
}) })

View file

@ -77,6 +77,11 @@ export const defaultOpenAIModels = modelInfoOfDefaultNames([
// 'gpt-3.5-turbo-1106', // 'gpt-3.5-turbo-1106',
]) ])
// https://platform.openai.com/docs/models/gp
export const defaultDeepseekModels = modelInfoOfDefaultNames([
'deepseek-chat',
'deepseek-reasoner',
])
// https://console.groq.com/docs/models // https://console.groq.com/docs/models
@ -141,6 +146,9 @@ export const defaultProviderSettings = {
openAI: { openAI: {
apiKey: '', apiKey: '',
}, },
deepseek: {
apiKey: '',
},
ollama: { ollama: {
endpoint: 'http://127.0.0.1:11434', endpoint: 'http://127.0.0.1:11434',
}, },
@ -212,6 +220,11 @@ export const displayInfoOfProviderName = (providerName: ProviderName): DisplayIn
title: 'OpenAI', title: 'OpenAI',
} }
} }
else if (providerName === 'deepseek') {
return {
title: 'DeepSeek',
}
}
else if (providerName === 'openRouter') { else if (providerName === 'openRouter') {
return { return {
title: 'OpenRouter', title: 'OpenRouter',
@ -258,21 +271,23 @@ export const displayInfoOfSettingName = (providerName: ProviderName, settingName
title: 'API Key', title: 'API Key',
placeholder: providerName === 'anthropic' ? 'sk-ant-key...' : // sk-ant-api03-key placeholder: providerName === 'anthropic' ? 'sk-ant-key...' : // sk-ant-api03-key
providerName === 'openAI' ? 'sk-proj-key...' : providerName === 'openAI' ? 'sk-proj-key...' :
providerName === 'openRouter' ? 'sk-or-key...' : // sk-or-v1-key providerName === 'deepseek' ? 'sk-...' :
providerName === 'gemini' ? 'key...' : providerName === 'openRouter' ? 'sk-or-key...' : // sk-or-v1-key
providerName === 'groq' ? 'gsk_key...' : providerName === 'gemini' ? 'key...' :
providerName === 'mistral' ? 'api-key...' : providerName === 'groq' ? 'gsk_key...' :
providerName === 'openAICompatible' ? 'sk-key...' : providerName === 'mistral' ? 'api-key...' :
'(never)', providerName === 'openAICompatible' ? 'sk-key...' :
'',
subTextMd: providerName === 'anthropic' ? 'Get your [API Key here](https://console.anthropic.com/settings/keys).' : subTextMd: providerName === 'anthropic' ? 'Get your [API Key here](https://console.anthropic.com/settings/keys).' :
providerName === 'openAI' ? 'Get your [API Key here](https://platform.openai.com/api-keys).' : providerName === 'openAI' ? 'Get your [API Key here](https://platform.openai.com/api-keys).' :
providerName === 'openRouter' ? 'Get your [API Key here](https://openrouter.ai/settings/keys).' : providerName === 'deepseek' ? 'Get your [API Key here](https://platform.deepseek.com/api_keys).' :
providerName === 'gemini' ? 'Get your [API Key here](https://aistudio.google.com/apikey).' : providerName === 'openRouter' ? 'Get your [API Key here](https://openrouter.ai/settings/keys).' :
providerName === 'groq' ? 'Get your [API Key here](https://console.groq.com/keys).' : providerName === 'gemini' ? 'Get your [API Key here](https://aistudio.google.com/apikey).' :
providerName === 'mistral' ? 'Get your [API Key here](https://console.mistral.ai/api-keys/).' : providerName === 'groq' ? 'Get your [API Key here](https://console.groq.com/keys).' :
providerName === 'openAICompatible' ? undefined : providerName === 'mistral' ? 'Get your [API Key here](https://console.mistral.ai/api-keys/).' :
undefined, providerName === 'openAICompatible' ? undefined :
'',
} }
} }
else if (settingName === 'endpoint') { else if (settingName === 'endpoint') {
@ -323,6 +338,9 @@ export const voidInitModelOptions = {
openAI: { openAI: {
models: defaultOpenAIModels, models: defaultOpenAIModels,
}, },
deepseek: {
models: defaultDeepseekModels,
},
ollama: { ollama: {
models: [], models: [],
}, },
@ -358,6 +376,12 @@ export const defaultSettingsOfProvider: SettingsOfProvider = {
...defaultProviderSettings.openAI, ...defaultProviderSettings.openAI,
...voidInitModelOptions.openAI, ...voidInitModelOptions.openAI,
}, },
deepseek: {
...defaultCustomSettings,
...defaultProviderSettings.deepseek,
...voidInitModelOptions.deepseek,
_enabled: undefined,
},
gemini: { gemini: {
...defaultCustomSettings, ...defaultCustomSettings,
...defaultProviderSettings.gemini, ...defaultProviderSettings.gemini,

View file

@ -33,7 +33,6 @@ export class VoidUpdateService implements IVoidUpdateService {
} }
// anything transmitted over a channel must be async even if it looks like it doesn't have to be // anything transmitted over a channel must be async even if it looks like it doesn't have to be
check: IVoidUpdateService['check'] = async () => { check: IVoidUpdateService['check'] = async () => {
const res = await this.voidUpdateService.check() const res = await this.voidUpdateService.check()

View file

@ -7,11 +7,6 @@ import Anthropic from '@anthropic-ai/sdk';
import { _InternalSendLLMMessageFnType } from '../../common/llmMessageTypes.js'; import { _InternalSendLLMMessageFnType } from '../../common/llmMessageTypes.js';
import { anthropicMaxPossibleTokens } from '../../common/voidSettingsTypes.js'; import { anthropicMaxPossibleTokens } from '../../common/voidSettingsTypes.js';
// Anthropic
type LLMMessageAnthropic = {
role: 'user' | 'assistant';
content: string;
}
export const sendAnthropicMsg: _InternalSendLLMMessageFnType = ({ messages, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter }) => { export const sendAnthropicMsg: _InternalSendLLMMessageFnType = ({ messages, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter }) => {
const thisConfig = settingsOfProvider.anthropic const thisConfig = settingsOfProvider.anthropic
@ -24,20 +19,9 @@ export const sendAnthropicMsg: _InternalSendLLMMessageFnType = ({ messages, onTe
const anthropic = new Anthropic({ apiKey: thisConfig.apiKey, dangerouslyAllowBrowser: true }); const anthropic = new Anthropic({ apiKey: thisConfig.apiKey, dangerouslyAllowBrowser: true });
// find system messages and concatenate them
const systemMessage = messages
.filter(msg => msg.role === 'system')
.map(msg => msg.content)
.join('\n');
// remove system messages for Anthropic
const anthropicMessages = messages.filter(msg => msg.role !== 'system') as LLMMessageAnthropic[]
const stream = anthropic.messages.stream({ const stream = anthropic.messages.stream({
system: systemMessage, // system: systemMessage,
messages: anthropicMessages, messages: messages,
model: modelName, model: modelName,
max_tokens: maxTokens, max_tokens: maxTokens,
}); });

View file

@ -3,7 +3,7 @@
* Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information.
*--------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------*/
import { Content, GoogleGenerativeAI, GoogleGenerativeAIFetchError } from '@google/generative-ai'; import { Content, GoogleGenerativeAI } from '@google/generative-ai';
import { _InternalSendLLMMessageFnType } from '../../common/llmMessageTypes.js'; import { _InternalSendLLMMessageFnType } from '../../common/llmMessageTypes.js';
// Gemini // Gemini
@ -16,22 +16,17 @@ export const sendGeminiMsg: _InternalSendLLMMessageFnType = async ({ messages, o
const genAI = new GoogleGenerativeAI(thisConfig.apiKey); const genAI = new GoogleGenerativeAI(thisConfig.apiKey);
const model = genAI.getGenerativeModel({ model: modelName }); const model = genAI.getGenerativeModel({ model: modelName });
// remove system messages that get sent to Gemini
// str of all system messages
const systemMessage = messages
.filter(msg => msg.role === 'system')
.map(msg => msg.content)
.join('\n');
// Convert messages to Gemini format // Convert messages to Gemini format
const geminiMessages: Content[] = messages const geminiMessages: Content[] = messages
.filter(msg => msg.role !== 'system')
.map((msg, i) => ({ .map((msg, i) => ({
parts: [{ text: msg.content }], parts: [{ text: msg.content }],
role: msg.role === 'assistant' ? 'model' : 'user' role: msg.role === 'assistant' ? 'model' : 'user'
})) }))
model.generateContentStream({ contents: geminiMessages, systemInstruction: systemMessage, }) model.generateContentStream({
// systemInstruction: systemMessage,
contents: geminiMessages,
})
.then(async response => { .then(async response => {
_setAborter(() => response.stream.return(fullText)) _setAborter(() => response.stream.return(fullText))
@ -43,11 +38,6 @@ export const sendGeminiMsg: _InternalSendLLMMessageFnType = async ({ messages, o
onFinalMessage({ fullText }); onFinalMessage({ fullText });
}) })
.catch((error) => { .catch((error) => {
if (error instanceof GoogleGenerativeAIFetchError && error.status === 400) { onError({ message: error + '', fullError: error })
onError({ message: 'Invalid API key.', fullError: null });
}
else {
onError({ message: error + '', fullError: error });
}
}) })
} }

View file

@ -69,6 +69,14 @@ export const sendOpenAIMsg: _InternalSendLLMMessageFnType = ({ messages, onText,
}); });
options = { model: modelName, messages: messages, stream: true, /*max_completion_tokens: parseMaxTokensStr(thisConfig.maxTokens)*/ } options = { model: modelName, messages: messages, stream: true, /*max_completion_tokens: parseMaxTokensStr(thisConfig.maxTokens)*/ }
} }
else if (providerName === 'deepseek') {
const thisConfig = settingsOfProvider.deepseek
openai = new OpenAI({
baseURL: 'https://api.deepseek.com/v1', apiKey: thisConfig.apiKey, dangerouslyAllowBrowser: true,
});
options = { model: modelName, messages: messages, stream: true, /*max_completion_tokens: parseMaxTokensStr(thisConfig.maxTokens)*/ }
}
else if (providerName === 'openAICompatible') { else if (providerName === 'openAICompatible') {
const thisConfig = settingsOfProvider.openAICompatible const thisConfig = settingsOfProvider.openAICompatible
openai = new OpenAI({ baseURL: thisConfig.endpoint, apiKey: thisConfig.apiKey, dangerouslyAllowBrowser: true }) openai = new OpenAI({ baseURL: thisConfig.endpoint, apiKey: thisConfig.apiKey, dangerouslyAllowBrowser: true })
@ -79,7 +87,6 @@ export const sendOpenAIMsg: _InternalSendLLMMessageFnType = ({ messages, onText,
throw new Error(`providerName was invalid: ${providerName}`) throw new Error(`providerName was invalid: ${providerName}`)
} }
openai.models.list()
openai.chat.completions openai.chat.completions
.create(options) .create(options)
.then(async response => { .then(async response => {
@ -98,7 +105,7 @@ export const sendOpenAIMsg: _InternalSendLLMMessageFnType = ({ messages, onText,
onError({ message: 'Invalid API key.', fullError: error }); onError({ message: 'Invalid API key.', fullError: error });
} }
else { else {
onError({ message: error, fullError: error }); onError({ message: error + '', fullError: error });
} }
}) })

View file

@ -3,7 +3,7 @@
* Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information.
*--------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------*/
import { LLMMMessageParams, OnText, OnFinalMessage, OnError } from '../../common/llmMessageTypes.js'; import { LLMMMessageParams, OnText, OnFinalMessage, OnError, LLMMessage, _InternalLLMMessage } from '../../common/llmMessageTypes.js';
import { IMetricsService } from '../../common/metricsService.js'; import { IMetricsService } from '../../common/metricsService.js';
import { sendAnthropicMsg } from './anthropic.js'; import { sendAnthropicMsg } from './anthropic.js';
@ -13,8 +13,43 @@ import { sendGeminiMsg } from './gemini.js';
import { sendGroqMsg } from './groq.js'; import { sendGroqMsg } from './groq.js';
import { sendMistralMsg } from './mistral.js'; import { sendMistralMsg } from './mistral.js';
const cleanMessages = (messages: LLMMessage[]): _InternalLLMMessage[] => {
// trim message content (Anthropic and other providers give an error if there is trailing whitespace)
messages = messages.map(m => ({ ...m, content: m.content.trim() }))
// find system messages and concatenate them
const systemMessage = messages
.filter(msg => msg.role === 'system')
.map(msg => msg.content)
.join('\n') || undefined;
// remove all system messages
const noSystemMessages = messages
.filter(msg => msg.role !== 'system') as _InternalLLMMessage[]
// add system mesasges to first message (should be a user message)
if (systemMessage && (noSystemMessages.length !== 0)) {
const newFirstMessage = {
role: noSystemMessages[0].role,
content: (''
+ '<SYSTEM_MESSAGE>\n'
+ systemMessage
+ '\n'
+ '</SYSTEM_MESSAGE>\n'
+ noSystemMessages[0].content
)
}
noSystemMessages.splice(0, 1) // delete first message
noSystemMessages.unshift(newFirstMessage) // add new first message
}
return noSystemMessages
}
export const sendLLMMessage = ({ export const sendLLMMessage = ({
messages, messages: messages_,
onText: onText_, onText: onText_,
onFinalMessage: onFinalMessage_, onFinalMessage: onFinalMessage_,
onError: onError_, onError: onError_,
@ -27,9 +62,7 @@ export const sendLLMMessage = ({
metricsService: IMetricsService metricsService: IMetricsService
) => { ) => {
const messages = cleanMessages(messages_)
// trim message content (Anthropic and other providers give an error if there is trailing whitespace)
messages = messages.map(m => ({ ...m, content: m.content.trim() }))
// only captures number of messages and message "shape", no actual code, instructions, prompts, etc // only captures number of messages and message "shape", no actual code, instructions, prompts, etc
const captureChatEvent = (eventId: string, extras?: object) => { const captureChatEvent = (eventId: string, extras?: object) => {
@ -38,6 +71,9 @@ export const sendLLMMessage = ({
modelName, modelName,
numMessages: messages?.length, numMessages: messages?.length,
messagesShape: messages?.map(msg => ({ role: msg.role, length: msg.content.length })), messagesShape: messages?.map(msg => ({ role: msg.role, length: msg.content.length })),
origNumMessages: messages_?.length,
origMessagesShape: messages_?.map(msg => ({ role: msg.role, length: msg.content.length })),
...extras, ...extras,
}) })
} }
@ -84,6 +120,7 @@ export const sendLLMMessage = ({
break; break;
case 'openAI': case 'openAI':
case 'openRouter': case 'openRouter':
case 'deepseek':
case 'openAICompatible': case 'openAICompatible':
sendOpenAIMsg({ messages, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName }); sendOpenAIMsg({ messages, onText, onFinalMessage, onError, settingsOfProvider, modelName, _setAborter, providerName });
break; break;

View file

@ -9,84 +9,123 @@ import { generateUuid } from '../../../base/common/uuid.js';
import { IEnvironmentMainService } from '../../environment/electron-main/environmentMainService.js'; import { IEnvironmentMainService } from '../../environment/electron-main/environmentMainService.js';
import { IProductService } from '../../product/common/productService.js'; import { IProductService } from '../../product/common/productService.js';
import { IStorageMainService } from '../../storage/electron-main/storageMainService.js'; import { StorageScope, StorageTarget } from '../../storage/common/storage.js';
import { IApplicationStorageMainService } from '../../storage/electron-main/storageMainService.js';
import { IMetricsService } from '../common/metricsService.js'; import { IMetricsService } from '../common/metricsService.js';
import { PostHog } from 'posthog-node' import { PostHog } from 'posthog-node'
const os = isWindows ? 'windows' : isMacintosh ? 'mac' : isLinux ? 'linux' : null const os = isWindows ? 'windows' : isMacintosh ? 'mac' : isLinux ? 'linux' : null
const _getOSInfo = () => {
try {
const { platform, arch } = process // see platform.ts
return { platform, arch }
}
catch (e) {
return { osInfo: { platform: '??', arch: '??' } }
}
}
const osInfo = _getOSInfo()
const VOID_MACHINE_STORAGE_KEY = 'void.machineId' // we'd like to use devDeviceId on telemetryService, but that gets sanitized by the time it gets here as 'someValue.devDeviceId'
export class MetricsMainService extends Disposable implements IMetricsService { export class MetricsMainService extends Disposable implements IMetricsService {
_serviceBrand: undefined; _serviceBrand: undefined;
private readonly client: PostHog private readonly client: PostHog
private readonly _initProperties: object private _initProperties: object = {}
// TODO we should eventually identify people based on email // helper - looks like this is stored in a .vscdb file in ~/Library/Application Support/Void
private get machineId() { private _memoStorage(key: string, target: StorageTarget, setValIfNotExist?: string) {
const currVal = this._storageService.applicationStorage.get(VOID_MACHINE_STORAGE_KEY) const currVal = this._appStorage.get(key, StorageScope.APPLICATION)
if (currVal !== undefined) return currVal if (currVal !== undefined) return currVal
const newVal = generateUuid() const newVal = setValIfNotExist ?? generateUuid()
this._storageService.applicationStorage.set(VOID_MACHINE_STORAGE_KEY, newVal) this._appStorage.store(key, newVal, StorageScope.APPLICATION, target)
return newVal return newVal
} }
// this is old, eventually we can just delete this since all the keys will have been transferred over
// returns 'NULL' or the old key
private get oldId() {
// check new storage key first
const newKey = 'void.app.oldMachineId'
const newOldId = this._appStorage.get(newKey, StorageScope.APPLICATION)
if (newOldId) return newOldId
// put old key into new key if didn't already
const oldValue = this._appStorage.get('void.machineId', StorageScope.APPLICATION) ?? 'NULL' // the old way of getting the key
this._appStorage.store(newKey, oldValue, StorageScope.APPLICATION, StorageTarget.MACHINE)
return oldValue
// in a few weeks we can replace above with this
// private get oldId() {
// return this._memoStorage('void.app.oldMachineId', StorageTarget.MACHINE, 'NULL')
// }
}
// the main id
private get distinctId() {
const oldId = this.oldId
const setValIfNotExist = oldId === 'NULL' ? undefined : oldId
return this._memoStorage('void.app.machineId', StorageTarget.MACHINE, setValIfNotExist)
}
// just to see if there are ever multiple machineIDs per userID (instead of this, we should just track by the user's email)
private get userId() {
return this._memoStorage('void.app.userMachineId', StorageTarget.USER)
}
constructor( constructor(
@IProductService private readonly _productService: IProductService, @IProductService private readonly _productService: IProductService,
@IStorageMainService private readonly _storageService: IStorageMainService,
@IEnvironmentMainService private readonly _envMainService: IEnvironmentMainService, @IEnvironmentMainService private readonly _envMainService: IEnvironmentMainService,
@IApplicationStorageMainService private readonly _appStorage: IApplicationStorageMainService,
) { ) {
super() super()
this.client = new PostHog('phc_UanIdujHiLp55BkUTjB1AuBXcasVkdqRwgnwRlWESH2', { this.client = new PostHog('phc_UanIdujHiLp55BkUTjB1AuBXcasVkdqRwgnwRlWESH2', {
host: 'https://us.i.posthog.com', host: 'https://us.i.posthog.com',
}) })
// we'd like to use devDeviceId on telemetryService, but that gets sanitized by the time it gets here as 'someValue.devDeviceId' this.initialize() // async
}
async initialize() {
// very important to await whenReady!
await this._appStorage.whenReady
const { commit, version, quality } = this._productService const { commit, version, quality } = this._productService
const isDevMode = !this._envMainService.isBuilt // found in abstractUpdateService.ts const isDevMode = !this._envMainService.isBuilt // found in abstractUpdateService.ts
// custom properties we identify // custom properties we identify
this._initProperties = { this._initProperties = {
commit, commit,
version, vscodeVersion: version,
os, os,
quality, quality,
distinctId: this.machineId, distinctId: this.distinctId,
distinctIdUser: this.userId,
oldId: this.oldId,
isDevMode, isDevMode,
...this._getOSInfo(), ...osInfo,
} }
const identifyMessage = { const identifyMessage = {
distinctId: this.machineId, distinctId: this.distinctId,
properties: this._initProperties, properties: this._initProperties,
} }
this.client.identify(identifyMessage) this.client.identify(identifyMessage)
console.log('Void posthog metrics info:', JSON.stringify(identifyMessage, null, 2)) console.log('Void posthog metrics info:', JSON.stringify(identifyMessage, null, 2))
} }
_getOSInfo() {
try {
const { platform, arch } = process // see platform.ts
return { platform, arch }
}
catch (e) {
return { osInfo: { platform: '??', arch: '??' } }
}
}
capture: IMetricsService['capture'] = (event, params) => { capture: IMetricsService['capture'] = (event, params) => {
const capture = { distinctId: this.machineId, event, properties: params } as const const capture = { distinctId: this.distinctId, event, properties: params } as const
// console.log('full capture:', capture) // console.log('full capture:', capture)
this.client.capture(capture) this.client.capture(capture)
} }

View file

@ -146,25 +146,6 @@ export class EditorGroupWatermark extends Disposable {
private render(): void { private render(): void {
// const enabled = this.configurationService.getValue<boolean>('workbench.tips.enabled');
// if (enabled === this.enabled) {
// return;
// }
// this.enabled = enabled;
// if (!enabled) {
// return;
// }
// const hasFolder = this.workbenchState !== WorkbenchState.EMPTY;
// const selected = (hasFolder ? folderEntries : noFolderEntries)
// .filter(entry => !('when' in entry) || this.contextKeyService.contextMatchesRules(entry.when))
// .filter(entry => !('mac' in entry) || entry.mac === (isMacintosh && !isWeb))
// .filter(entry => !!CommandsRegistry.getCommand(entry.id))
// .filter(entry => !!this.keybindingService.lookupKeybinding(entry.id));
this.clear(); this.clear();
const voidIconBox = append(this.shortcuts, $('.watermark-box')); const voidIconBox = append(this.shortcuts, $('.watermark-box'));
@ -176,6 +157,10 @@ export class EditorGroupWatermark extends Disposable {
const update = async () => { const update = async () => {
// put async at top so don't need to wait (this prevents a jitter on load)
const recentlyOpened = await this.workspacesService.getRecentlyOpened()
.catch(() => ({ files: [], workspaces: [] })).then(w => w.workspaces);
clearNode(voidIconBox); clearNode(voidIconBox);
clearNode(recentsBox); clearNode(recentsBox);
@ -206,10 +191,6 @@ export class EditorGroupWatermark extends Disposable {
// Recents // Recents
const recentlyOpened = await this.workspacesService.getRecentlyOpened()
.catch(() => ({ files: [], workspaces: [] })).then(w => w.workspaces);
if (recentlyOpened.length !== 0) { if (recentlyOpened.length !== 0) {
voidIconBox.append( voidIconBox.append(

File diff suppressed because it is too large Load diff

View file

@ -13,29 +13,25 @@ import { Emitter, Event } from '../../../../base/common/event.js';
import { IRange } from '../../../../editor/common/core/range.js'; import { IRange } from '../../../../editor/common/core/range.js';
import { ILLMMessageService } from '../../../../platform/void/common/llmMessageService.js'; import { ILLMMessageService } from '../../../../platform/void/common/llmMessageService.js';
import { IModelService } from '../../../../editor/common/services/model.js'; import { IModelService } from '../../../../editor/common/services/model.js';
import { VSReadFile } from './helpers/readFile.js'; import { chat_userMessage, chat_systemMessage } from './prompt/prompts.js';
import { chat_prompt, chat_systemMessage } from './prompt/prompts.js';
// one of the square items that indicates a selection in a chat bubble (NOT a file, a Selection of text)
export type CodeSelection = { export type CodeSelection = {
type: 'Selection';
fileURI: URI; fileURI: URI;
selectionStr: string | null; selectionStr: string;
content: string; // TODO remove this (replace `selectionStr` with `content`)
range: IRange; range: IRange;
} }
// if selectionStr is null, it means to use the entire file at send time export type FileSelection = {
export type CodeStagingSelection = { type: 'File';
type: 'Selection', fileURI: URI;
fileURI: URI, selectionStr: null;
selectionStr: string, range: null;
range: IRange
} | {
type: 'File',
fileURI: URI,
selectionStr: null,
range: null
} }
export type StagingSelectionItem = CodeSelection | FileSelection
// WARNING: changing this format is a big deal!!!!!! need to migrate old format to new format on users' computers so people don't get errors. // WARNING: changing this format is a big deal!!!!!! need to migrate old format to new format on users' computers so people don't get errors.
export type ChatMessage = export type ChatMessage =
@ -43,7 +39,7 @@ export type ChatMessage =
role: 'user'; role: 'user';
content: string | null; // content sent to the llm - allowed to be '', will be replaced with (empty) content: string | null; // content sent to the llm - allowed to be '', will be replaced with (empty)
displayContent: string | null; // content displayed to user - allowed to be '', will be ignored displayContent: string | null; // content displayed to user - allowed to be '', will be ignored
selections: CodeSelection[] | null; // the user's selection selections: StagingSelectionItem[] | null; // the user's selection
} }
| { | {
role: 'assistant'; role: 'assistant';
@ -69,7 +65,7 @@ export type ChatThreads = {
export type ThreadsState = { export type ThreadsState = {
allThreads: ChatThreads; allThreads: ChatThreads;
currentThreadId: string; // intended for internal use only currentThreadId: string; // intended for internal use only
currentStagingSelections: CodeStagingSelection[] | null; currentStagingSelections: StagingSelectionItem[] | null;
} }
export type ThreadStreamState = { export type ThreadStreamState = {
@ -91,6 +87,9 @@ const newThreadObject = () => {
} satisfies ChatThreads[string] } satisfies ChatThreads[string]
} }
const THREAD_VERSION_KEY = 'void.chatThreadVersion'
const THREAD_VERSION = 'v1'
const THREAD_STORAGE_KEY = 'void.chatThreadStorage' const THREAD_STORAGE_KEY = 'void.chatThreadStorage'
export interface IChatThreadService { export interface IChatThreadService {
@ -106,7 +105,7 @@ export interface IChatThreadService {
openNewThread(): void; openNewThread(): void;
switchToThread(threadId: string): void; switchToThread(threadId: string): void;
setStaging(stagingSelection: CodeStagingSelection[] | null): void; setStaging(stagingSelection: StagingSelectionItem[] | null): void;
addUserMessageAndStreamResponse(userMessage: string): Promise<void>; addUserMessageAndStreamResponse(userMessage: string): Promise<void>;
cancelStreaming(threadId: string): void; cancelStreaming(threadId: string): void;
@ -143,11 +142,15 @@ class ChatThreadService extends Disposable implements IChatThreadService {
// always be in a thread // always be in a thread
this.openNewThread() this.openNewThread()
// for now just write the version, anticipating bigger changes in the future where we'll want to access this
this._storageService.store(THREAD_VERSION_KEY, THREAD_VERSION, StorageScope.APPLICATION, StorageTarget.USER)
} }
private _readAllThreads(): ChatThreads { private _readAllThreads(): ChatThreads {
// PUT ANY VERSION CHANGE FORMAT CONVERSION CODE HERE // PUT ANY VERSION CHANGE FORMAT CONVERSION CODE HERE
// CAN ADD "v0" TAG IN STORAGE AND CONVERT
const threads = this._storageService.get(THREAD_STORAGE_KEY, StorageScope.APPLICATION) const threads = this._storageService.get(THREAD_STORAGE_KEY, StorageScope.APPLICATION)
return threads ? JSON.parse(threads) : {} return threads ? JSON.parse(threads) : {}
} }
@ -188,15 +191,11 @@ class ChatThreadService extends Disposable implements IChatThreadService {
const threadId = this.getCurrentThread().id const threadId = this.getCurrentThread().id
const currSelns = this.state.currentStagingSelections ?? [] const currSelns = this.state.currentStagingSelections ?? []
const selections = !currSelns ? null : await Promise.all(
currSelns.map(async (sel) => ({ ...sel, content: await VSReadFile(this._modelService, sel.fileURI) }))
).then(
(files) => files.filter(file => file.content !== null) as CodeSelection[]
)
// add user's message to chat history // add user's message to chat history
const instructions = userMessage const instructions = userMessage
const userHistoryElt: ChatMessage = { role: 'user', content: chat_prompt(instructions, selections), displayContent: instructions, selections: selections } const content = await chat_userMessage(instructions, currSelns, this._modelService)
const userHistoryElt: ChatMessage = { role: 'user', content: content, displayContent: instructions, selections: currSelns }
this._addMessageToThread(threadId, userHistoryElt) this._addMessageToThread(threadId, userHistoryElt)
@ -292,7 +291,7 @@ class ChatThreadService extends Disposable implements IChatThreadService {
} }
setStaging(stagingSelection: CodeStagingSelection[] | null): void { setStaging(stagingSelection: StagingSelectionItem[] | null): void {
this._setState({ currentStagingSelections: stagingSelection }, true) // this is a hack for now this._setState({ currentStagingSelections: stagingSelection }, true) // this is a hack for now
} }

View file

@ -91,10 +91,7 @@ export class ConsistentItemService extends Disposable {
this._register(this._editorService.onCodeEditorAdd(editor => { initializeEditor(editor) })) this._register(this._editorService.onCodeEditorAdd(editor => { initializeEditor(editor) }))
// when an editor is deleted, remove its items // when an editor is deleted, remove its items
this._register(this._editorService.onCodeEditorRemove(editor => { this._register(this._editorService.onCodeEditorRemove(editor => { removeItemsFromEditor(editor) }))
removeItemsFromEditor(editor)
}))
} }
@ -127,8 +124,6 @@ export class ConsistentItemService extends Disposable {
const editorId = editor.getId() const editorId = editor.getId()
this.itemIdsOfEditorId[editorId]?.delete(itemId) this.itemIdsOfEditorId[editorId]?.delete(itemId)
if (this.itemIdsOfEditorId[editorId]?.size === 0)
delete this.itemIdsOfEditorId[editorId]
this.disposeFnOfItemId[itemId]?.() this.disposeFnOfItemId[itemId]?.()
delete this.disposeFnOfItemId[itemId] delete this.disposeFnOfItemId[itemId]
@ -175,8 +170,6 @@ export class ConsistentItemService extends Disposable {
// clear // clear
this.consistentItemIdsOfURI[uri.fsPath]?.delete(consistentItemId) this.consistentItemIdsOfURI[uri.fsPath]?.delete(consistentItemId)
if (this.consistentItemIdsOfURI[uri.fsPath]?.size === 0)
delete this.consistentItemIdsOfURI[uri.fsPath]
delete this.infoOfConsistentItemId[consistentItemId] delete this.infoOfConsistentItemId[consistentItemId]

View file

@ -76,47 +76,55 @@ class SurroundingsRemover {
removeCodeBlock = () => { removeCodeBlock = () => {
// Match either:
// 1. ```language\n<code>\n```\n?
// 2. ```<code>\n```\n?
const pm = this const pm = this
const foundCodeBlock = pm.removePrefix('```') const foundCodeBlock = pm.removePrefix('```')
if (!foundCodeBlock) return false if (!foundCodeBlock) return false
pm.removeFromStartUntil('\n', true) // language pm.removeFromStartUntil('\n', true) // language
const foundCodeBlockEnd = pm.removeSuffix('```') const j = pm.j
let foundCodeBlockEnd = pm.removeSuffix('```')
if (pm.j === j) foundCodeBlockEnd = pm.removeSuffix('```\n') // if no change, try again with \n after ```
if (!foundCodeBlockEnd) return false if (!foundCodeBlockEnd) return false
pm.removeSuffix('\n') pm.removeSuffix('\n') // remove the newline before ```
return true return true
} }
actualRecentlyAdded = (recentlyAddedTextLen: number) => { deltaInfo = (recentlyAddedTextLen: number) => {
// aaaaaatextaaaaaa{recentlyAdded} // aaaaaatextaaaaaa{recentlyAdded}
// i ^ j // ^ i j len
// | // |
// recentyAddedIdx // recentyAddedIdx
const recentlyAddedIdx = this.j - recentlyAddedTextLen + 1 const recentlyAddedIdx = this.originalS.length - recentlyAddedTextLen
return this.originalS.substring(Math.max(this.i, recentlyAddedIdx), this.j + 1) const actualDelta = this.originalS.substring(Math.max(this.i, recentlyAddedIdx), this.j + 1)
const ignoredSuffix = this.originalS.substring(Math.max(this.j + 1, recentlyAddedIdx), Infinity)
return [actualDelta, ignoredSuffix] as const
} }
} }
export const extractCodeFromRegular = ({ text, recentlyAddedTextLen }: { text: string, recentlyAddedTextLen: number }): [string, string] => { export const extractCodeFromRegular = ({ text, recentlyAddedTextLen }: { text: string, recentlyAddedTextLen: number }): [string, string, string] => {
// Match either:
// 1. ```language\n<code>```
// 2. ```<code>```
const pm = new SurroundingsRemover(text) const pm = new SurroundingsRemover(text)
pm.removeCodeBlock() pm.removeCodeBlock()
const s = pm.value() const s = pm.value()
const actual = pm.actualRecentlyAdded(recentlyAddedTextLen) const [delta, ignoredSuffix] = pm.deltaInfo(recentlyAddedTextLen)
return [s, actual] return [s, delta, ignoredSuffix]
} }
@ -124,7 +132,7 @@ export const extractCodeFromRegular = ({ text, recentlyAddedTextLen }: { text: s
// Ollama has its own FIM, we should not use this if we use that // Ollama has its own FIM, we should not use this if we use that
export const extractCodeFromFIM = ({ text, recentlyAddedTextLen, midTag, }: { text: string, recentlyAddedTextLen: number, midTag: string }): [string, string] => { export const extractCodeFromFIM = ({ text, recentlyAddedTextLen, midTag, }: { text: string, recentlyAddedTextLen: number, midTag: string }): [string, string, string] => {
/* ------------- summary of the regex ------------- /* ------------- summary of the regex -------------
[optional ` | `` | ```] [optional ` | `` | ```]
@ -146,9 +154,9 @@ export const extractCodeFromFIM = ({ text, recentlyAddedTextLen, midTag, }: { te
pm.removeSuffix(`</${midTag}>`) pm.removeSuffix(`</${midTag}>`)
} }
const s = pm.value() const s = pm.value()
const actual = pm.actualRecentlyAdded(recentlyAddedTextLen) const [delta, ignoredSuffix] = pm.deltaInfo(recentlyAddedTextLen)
return [s, actual] return [s, delta, ignoredSuffix]
// // const regex = /[\s\S]*?(?:`{1,3}\s*([a-zA-Z_]+[\w]*)?[\s\S]*?)?<MID>([\s\S]*?)(?:<\/MID>|`{1,3}|$)/; // // const regex = /[\s\S]*?(?:`{1,3}\s*([a-zA-Z_]+[\w]*)?[\s\S]*?)?<MID>([\s\S]*?)(?:<\/MID>|`{1,3}|$)/;

View file

@ -25,7 +25,7 @@ import * as dom from '../../../../base/browser/dom.js';
import { Widget } from '../../../../base/browser/ui/widget.js'; import { Widget } from '../../../../base/browser/ui/widget.js';
import { URI } from '../../../../base/common/uri.js'; import { URI } from '../../../../base/common/uri.js';
import { IConsistentEditorItemService, IConsistentItemService } from './helperServices/consistentItemService.js'; import { IConsistentEditorItemService, IConsistentItemService } from './helperServices/consistentItemService.js';
import { ctrlKStream_prefixAndSuffix, ctrlKStream_prompt, ctrlKStream_systemMessage, ctrlLStream_prompt, ctrlLStream_systemMessage, defaultFimTags } from './prompt/prompts.js'; import { ctrlKStream_prefixAndSuffix, ctrlKStream_userMessage, ctrlKStream_systemMessage, fastApply_userMessage, fastApply_systemMessage, defaultFimTags } from './prompt/prompts.js';
import { ILLMMessageService } from '../../../../platform/void/common/llmMessageService.js'; import { ILLMMessageService } from '../../../../platform/void/common/llmMessageService.js';
import { mountCtrlK } from '../browser/react/out/quick-edit-tsx/index.js' import { mountCtrlK } from '../browser/react/out/quick-edit-tsx/index.js'
@ -104,10 +104,9 @@ const getLeadingWhitespacePx = (editor: ICodeEditor, startLine: number): number
export type StartApplyingOpts = { export type StartApplyingOpts = {
featureName: 'Ctrl+K'; featureName: 'Ctrl+K';
diffareaid: number; // id of the CtrlK area (contains text selection) diffareaid: number; // id of the CtrlK area (contains text selection)
userMessage: string; // user message
} | { } | {
featureName: 'Ctrl+L'; featureName: 'Ctrl+L';
userMessage: string; applyStr: string;
} | { } | {
featureName: 'Autocomplete'; featureName: 'Autocomplete';
range: IRange; range: IRange;
@ -260,6 +259,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
if (!(model.uri.fsPath in this.diffAreasOfURI)) { if (!(model.uri.fsPath in this.diffAreasOfURI)) {
this.diffAreasOfURI[model.uri.fsPath] = new Set(); this.diffAreasOfURI[model.uri.fsPath] = new Set();
} }
else return // do not add listeners to the same model twice - important, or will see duplicates
// when the user types, realign diff areas and re-render them // when the user types, realign diff areas and re-render them
this._register( this._register(
@ -280,7 +280,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
.filter(diffArea => !!diffArea && diffArea.type === 'DiffZone') .filter(diffArea => !!diffArea && diffArea.type === 'DiffZone')
const isStreaming = diffZones.find(diffZone => !!diffZone._streamState.isStreaming) const isStreaming = diffZones.find(diffZone => !!diffZone._streamState.isStreaming)
if (diffZones.length !== 0 && !isStreaming && !removeAcceptRejectAllUI) { if (diffZones.length !== 0 && !isStreaming && !removeAcceptRejectAllUI) {
removeAcceptRejectAllUI = this._addAcceptRejectUI(uri) ?? null removeAcceptRejectAllUI = this._addAcceptRejectAllUI(uri) ?? null
} else { } else {
removeAcceptRejectAllUI?.() removeAcceptRejectAllUI?.()
removeAcceptRejectAllUI = null removeAcceptRejectAllUI = null
@ -394,7 +394,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
} }
} }
private _addAcceptRejectUI(uri: URI) { private _addAcceptRejectAllUI(uri: URI) {
// find all diffzones that aren't streaming // find all diffzones that aren't streaming
const diffZones: DiffZone[] = [] const diffZones: DiffZone[] = []
@ -1214,7 +1214,6 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
let startLine: number let startLine: number
let endLine: number let endLine: number
let uri: URI let uri: URI
let userMessage: string
if (featureName === 'Ctrl+L') { if (featureName === 'Ctrl+L') {
@ -1231,20 +1230,16 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
startLine = 1 startLine = 1
endLine = numLines endLine = numLines
userMessage = opts.userMessage
} }
else if (featureName === 'Ctrl+K') { else if (featureName === 'Ctrl+K') {
const { diffareaid } = opts const { diffareaid } = opts
const ctrlKZone = this.diffAreaOfId[diffareaid] const ctrlKZone = this.diffAreaOfId[diffareaid]
if (ctrlKZone.type !== 'CtrlKZone') return if (ctrlKZone.type !== 'CtrlKZone') return
const { startLine: startLine_, endLine: endLine_, _URI, _mountInfo } = ctrlKZone const { startLine: startLine_, endLine: endLine_, _URI } = ctrlKZone
uri = _URI uri = _URI
startLine = startLine_ startLine = startLine_
endLine = endLine_ endLine = endLine_
if (!_mountInfo?.textAreaRef.current) return
userMessage = _mountInfo.textAreaRef.current?.value
} }
else { else {
throw new Error(`Void: diff.type not recognized on: ${featureName}`) throw new Error(`Void: diff.type not recognized on: ${featureName}`)
@ -1295,24 +1290,25 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
let messages: LLMMessage[] let messages: LLMMessage[]
if (featureName === 'Ctrl+L') { if (featureName === 'Ctrl+L') {
const userContent = ctrlLStream_prompt({ originalCode, userMessage, uri }) const userContent = fastApply_userMessage({ originalCode, applyStr: opts.applyStr, uri })
messages = [ messages = [
{ role: 'system', content: ctrlLStream_systemMessage, }, { role: 'system', content: fastApply_systemMessage, },
{ role: 'user', content: userContent, } { role: 'user', content: userContent, }
] ]
} }
else if (featureName === 'Ctrl+K') { else if (featureName === 'Ctrl+K') {
const { prefix, suffix } = ctrlKStream_prefixAndSuffix({ fullFileStr: currentFileStr, startLine, endLine }) const { diffareaid } = opts
// console.log('PREFIX:\n', prefix) const ctrlKZone = this.diffAreaOfId[diffareaid]
// console.log('SUFFIX:\n', suffix) if (ctrlKZone.type !== 'CtrlKZone') return
// console.log('USER CONTENT:\n', userContent) const { _mountInfo } = ctrlKZone
const instructions = _mountInfo?.textAreaRef.current?.value ?? ''
// __TODO__ use Ollama's FIM api // __TODO__ use Ollama's FIM api, if (isOllamaFIM) {...} else:
// if (isOllamaFIM) {...} else: const { prefix, suffix } = ctrlKStream_prefixAndSuffix({ fullFileStr: currentFileStr, startLine, endLine })
const language = filenameToVscodeLanguage(uri.fsPath) ?? '' const language = filenameToVscodeLanguage(uri.fsPath) ?? ''
const userContent = ctrlKStream_prompt({ selection: originalCode, userMessage, prefix, suffix, isOllamaFIM: false, fimTags: modelFimTags, language }) const userContent = ctrlKStream_userMessage({ selection: originalCode, instructions: instructions, prefix, suffix, isOllamaFIM: false, fimTags: modelFimTags, language })
messages = [ messages = [
{ role: 'system', content: ctrlKStream_systemMessage, }, { role: 'system', content: ctrlKStream_systemMessage({ fimTags: modelFimTags }), },
{ role: 'user', content: userContent, } { role: 'user', content: userContent, }
] ]
} }
@ -1354,15 +1350,25 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
} }
const latestStreamInfo = { line: diffZone.startLine, addedSplitYet: false, col: 1, originalCodeStartLine: 1 } const latestStreamInfo = { line: diffZone.startLine, addedSplitYet: false, col: 1, originalCodeStartLine: 1 }
// state used in onText:
let fullText = ''
let prevIgnoredSuffix = ''
streamRequestIdRef.current = this._llmMessageService.sendLLMMessage({ streamRequestIdRef.current = this._llmMessageService.sendLLMMessage({
useProviderFor: featureName, useProviderFor: featureName,
logging: { loggingName: `startApplying - ${featureName}` }, logging: { loggingName: `startApplying - ${featureName}` },
messages, messages,
onText: ({ newText, fullText }) => { onText: ({ newText: newText_ }) => {
const [text, deltaText] = extractText(fullText, newText.length)
const newText = prevIgnoredSuffix + newText_ // add the previously ignored suffix because it's no longer the suffix!
fullText += prevIgnoredSuffix + newText
const [text, deltaText, ignoredSuffix] = extractText(fullText, newText.length)
this._writeStreamedDiffZoneLLMText(diffZone, text, deltaText, latestStreamInfo) this._writeStreamedDiffZoneLLMText(diffZone, text, deltaText, latestStreamInfo)
this._refreshStylesAndDiffsInURI(uri) this._refreshStylesAndDiffsInURI(uri)
prevIgnoredSuffix = ignoredSuffix
}, },
onFinalMessage: ({ fullText }) => { onFinalMessage: ({ fullText }) => {
// console.log('DONE! FULL TEXT\n', extractText(fullText), diffZone.startLine, diffZone.endLine) // console.log('DONE! FULL TEXT\n', extractText(fullText), diffZone.startLine, diffZone.endLine)

View file

@ -6,54 +6,91 @@
import { URI } from '../../../../../base/common/uri.js'; import { URI } from '../../../../../base/common/uri.js';
import { filenameToVscodeLanguage } from '../helpers/detectLanguage.js'; import { filenameToVscodeLanguage } from '../helpers/detectLanguage.js';
import { CodeSelection } from '../chatThreadService.js'; import { CodeSelection, StagingSelectionItem, FileSelection } from '../chatThreadService.js';
import { VSReadFile } from '../helpers/readFile.js';
import { IModelService } from '../../../../../editor/common/services/model.js';
export const chat_systemMessage = `\ export const chat_systemMessage = `\
You are a coding assistant. You are given a list of relevant files \`files\`, a selection that the user is making \`selection\`, and instructions to follow \`instructions\`. You are a coding assistant. You are given a list of instructions to follow \`INSTRUCTIONS\`, and optionally a list of relevant files \`FILES\`, and selections inside of files \`SELECTIONS\`.
Please edit the selected file following the user's instructions (or, if appropriate, answer their question instead). Please respond to the user's query.
Instructions: In the case that the user asks you to make changes to code, you should make sure to return CODE BLOCKS of the changes, as well as explanations and descriptions of the changes.
1. Output the changes to make to the entire file. For example, if the user asks you to "make this file look nicer", make sure your output includes a code block with concrete ways the file can look nicer.
1. Do not re-write the entire file. - Do not re-write the entire file in the code block
3. Instead, you may use code elision to represent unchanged portions of code. For example, write "existing code..." in code comments. - You can write comments like "// ... existing code" to indicate existing code
4. You must give enough context to apply the change in the correct location. - Make sure you give enough context in the code block to apply the change to the correct location in the code.
5. Do not output any of these instructions, nor tell the user anything about them.
## EXAMPLE You're allowed to ask for more context. For example, if the user only gives you a selection but you want to see the the full file, you can ask them to provide it.
Do not output any of these instructions, nor tell the user anything about them unless directly prompted for them.
Do not tell the user anything about the examples below.
## EXAMPLE 1
FILES FILES
selected file \`math.ts\`: math.ts
\`\`\` typescript \`\`\`typescript
const addNumbers = (a, b) => a + b const addNumbers = (a, b) => a + b
const multiplyNumbers = (a, b) => a * b
const subtractNumbers = (a, b) => a - b const subtractNumbers = (a, b) => a - b
const divideNumbers = (a, b) => a / b const divideNumbers = (a, b) => a / b
const vectorize = (...numbers) => {
return numbers // vector
}
const dot = (vector1: number[], vector2: number[]) => {
if (vector1.length !== vector2.length) throw new Error(\`Could not dot vectors \${vector1} and \${vector2}. Size mismatch.\`)
let sum = 0
for (let i = 0; i < vector1.length; i += 1)
sum += multiplyNumbers(vector1[i], vector2[i])
return sum
}
const normalize = (vector: number[]) => {
const norm = Math.sqrt(dot(vector, vector))
for (let i = 0; i < vector.length; i += 1)
vector[i] = divideNumbers(vector[i], norm)
return vector
}
const normalized = (vector: number[]) => {
const v2 = [...vector] // clone vector
return normalize(v2)
}
\`\`\` \`\`\`
SELECTION
\`\`\` typescript SELECTIONS
math.ts (lines 3:3)
\`\`\`typescript
const subtractNumbers = (a, b) => a - b const subtractNumbers = (a, b) => a - b
\`\`\` \`\`\`
INSTRUCTIONS INSTRUCTIONS
\`\`\` typescript add a function that exponentiates a number below this, and use it to make a power function that raises all entries of a vector to a power
add a function that multiplies numbers below this
\`\`\`
EXPECTED OUTPUT ACCEPTED OUTPUT
We can add the following code to the file: We can add the following code to the file:
\`\`\` typescript \`\`\`typescript
// existing code... // existing code...
const subtractNumbers = (a, b) => a - b; const subtractNumbers = (a, b) => a - b
const multiplyNumbers = (a, b) => a * b; const exponentiateNumbers = (a, b) => Math.pow(a, b)
const divideNumbers = (a, b) => a / b
// existing code... // existing code...
const raiseAll = (vector: number[], power: number) => {
for (let i = 0; i < vector.length; i += 1)
vector[i] = exponentiateNumbers(vector[i], power)
return vector
}
\`\`\` \`\`\`
## EXAMPLE
## EXAMPLE 2
FILES FILES
selected file \`fib.ts\`: fib.ts
\`\`\` typescript \`\`\`typescript
const dfs = (root) => { const dfs = (root) => {
if (!root) return; if (!root) return;
@ -67,19 +104,18 @@ const fib = (n) => {
} }
\`\`\` \`\`\`
SELECTION SELECTIONS
\`\`\` typescript fib.ts (lines 10:10)
\`\`\`typescript
return fib(n - 1) + fib(n - 2) return fib(n - 1) + fib(n - 2)
\`\`\` \`\`\`
INSTRUCTIONS INSTRUCTIONS
\`\`\` typescript
memoize results memoize results
\`\`\`
EXPECTED OUTPUT ACCEPTED OUTPUT
To implement memoization in your Fibonacci function, you can use a JavaScript object to store previously computed results. This will help avoid redundant calculations and improve performance. Here's how you can modify your function: To implement memoization in your Fibonacci function, you can use a JavaScript object to store previously computed results. This will help avoid redundant calculations and improve performance. Here's how you can modify your function:
\`\`\` typescript \`\`\`typescript
// existing code... // existing code...
const fib = (n, memo = {}) => { const fib = (n, memo = {}) => {
if (n < 1) return 1; if (n < 1) return 1;
@ -97,188 +133,91 @@ Store Result: After computing fib(n), the result is stored in memo for future re
` `
type FileSelnLocal = FileSelection & { content: string }
const stringifyFileSelection = ({ fileURI, selectionStr, range, content }: FileSelnLocal) => {
return `\
${fileURI.fsPath}
\`\`\`${filenameToVscodeLanguage(fileURI.fsPath) ?? ''}
${content}
\`\`\`
`
}
const stringifyCodeSelection = ({ fileURI, selectionStr, range }: CodeSelection) => {
return `\
${fileURI.fsPath} (lines ${range.startLineNumber}:${range.endLineNumber})
\`\`\`${filenameToVscodeLanguage(fileURI.fsPath) ?? ''}
${selectionStr}
\`\`\`
`
}
const stringifySelections = (selections: CodeSelection[]) => { const failToReadStr = 'Could not read content. This file may have been deleted. If you expected content here, you can tell the user about this as they might not know.'
return selections.map(({ fileURI, content, selectionStr }) => const stringifyFileSelections = async (fileSelections: FileSelection[], modelService: IModelService) => {
`\ if (fileSelections.length === 0) return null
File: ${fileURI.fsPath} const fileSlns: FileSelnLocal[] = await Promise.all(fileSelections.map(async (sel) => {
\`\`\` ${filenameToVscodeLanguage(fileURI.fsPath) ?? ''} const content = await VSReadFile(modelService, sel.fileURI) ?? failToReadStr
${content // this was the enite file which is foolish return { ...sel, content }
} }))
\`\`\`${selectionStr === null ? '' : ` return fileSlns.map(sel => stringifyFileSelection(sel)).join('\n')
Selection: ${selectionStr}`} }
`).join('\n') const stringifyCodeSelections = (codeSelections: CodeSelection[]) => {
return codeSelections.map(sel => stringifyCodeSelection(sel)).join('\n')
} }
export const chat_prompt = (instructions: string, selections: CodeSelection[] | null) => {
let str = ''; export const chat_userMessage = async (instructions: string, selections: StagingSelectionItem[] | null, modelService: IModelService) => {
if (selections && selections.length > 0) { const fileSelections = selections?.filter(s => s.type === 'File') as FileSelection[]
str += stringifySelections(selections); const codeSelections = selections?.filter(s => s.type === 'Selection') as CodeSelection[]
str += `Please edit the selected code following these instructions:\n`
} const filesStr = await stringifyFileSelections(fileSelections, modelService)
str += `${instructions}`; const codeStr = stringifyCodeSelections(codeSelections)
let str = ''
if (filesStr) str += `FILES\n${filesStr}\n`
if (codeStr) str += `SELECTIONS\n${codeStr}\n`
str += `INSTRUCTIONS\n${instructions}`
return str; return str;
}; };
export const ctrlLStream_systemMessage = ` export const fastApply_systemMessage = `\
You are a coding assistant that applies a diff to a file. You are given the original file \`original_file\`, a diff \`diff\`, and a new file that you are applying the diff to \`new_file\`. You are a coding assistant that re-writes an entire file to make a change. You are given the original file \`ORIGINAL_FILE\` and a change \`CHANGE\`.
Please finish writing the new file \`new_file\`, according to the diff \`diff\`. You must completely re-write the whole file, using the diff.
Directions: Directions:
1. Continue exactly where the new file \`new_file\` left off. 1. Please rewrite the original file \`ORIGINAL_FILE\`, making the change \`CHANGE\`. You must completely re-write the whole file.
2. Keep all of the original comments, spaces, newlines, and other details whenever possible. 2. Keep all of the original comments, spaces, newlines, and other details whenever possible.
3. Note that \`+\` lines represent additions, \`-\` lines represent removals, and space lines \` \` represent no change. 3. ONLY output the full new file. Do not add any other explanations or text.
# Example 1:
ORIGINAL_FILE
\`Sidebar.tsx\`:
\`\`\` typescript
import React from 'react';
import styles from './Sidebar.module.css';
interface SidebarProps {
items: { label: string; href: string }[];
onItemSelect?: (label: string) => void;
onExtraButtonClick?: () => void;
}
const Sidebar: React.FC<SidebarProps> = ({ items, onItemSelect, onExtraButtonClick }) => {
return (
<div className={styles.sidebar}>
<ul>
{items.map((item, index) => (
<li key={index}>
<button
className={styles.sidebarButton}
onClick={() => onItemSelect?.(item.label)}
>
{item.label}
</button>
</li>
))}
</ul>
<button className={styles.extraButton} onClick={onExtraButtonClick}>
Extra Action
</button>
</div>
);
};
export default Sidebar;
\`\`\`
DIFF
\`\`\` typescript
@@ ... @@
-<div className={styles.sidebar}>
-<ul>
- {items.map((item, index) => (
- <li key={index}>
- <button
- className={styles.sidebarButton}
- onClick={() => onItemSelect?.(item.label)}
- >
- {item.label}
- </button>
- </li>
- ))}
-</ul>
-<button className={styles.extraButton} onClick={onExtraButtonClick}>
- Extra Action
-</button>
-</div>
+<div className={styles.sidebar}>
+<ul>
+ {items.map((item, index) => (
+ <li key={index}>
+ <div
+ className={styles.sidebarButton}
+ onClick={() => onItemSelect?.(item.label)}
+ >
+ {item.label}
+ </div>
+ </li>
+ ))}
+</ul>
+<div className={styles.extraButton} onClick={onExtraButtonClick}>
+ Extra Action
+</div>
+</div>
\`\`\`
NEW_FILE
\`\`\` typescript
import React from 'react';
import styles from './Sidebar.module.css';
interface SidebarProps {
items: { label: string; href: string }[];
onItemSelect?: (label: string) => void;
onExtraButtonClick?: () => void;
}
const Sidebar: React.FC<SidebarProps> = ({ items, onItemSelect, onExtraButtonClick }) => {
return (
\`\`\`
COMPLETION
\`\`\` typescript
<div className={styles.sidebar}>
<ul>
{items.map((item, index) => (
<li key={index}>
<div
className={styles.sidebarButton}
onClick={() => onItemSelect?.(item.label)}
>
{item.label}
</div>
</li>
))}
</ul>
<div className={styles.extraButton} onClick={onExtraButtonClick}>
Extra Action
</div>
</div>
);
};
export default Sidebar;\`\`\`
` `
export const ctrlLStream_prompt = ({ originalCode, userMessage, uri }: { originalCode: string, userMessage: string, uri: URI }) => { export const fastApply_userMessage = ({ originalCode, applyStr, uri }: { originalCode: string, applyStr: string, uri: URI }) => {
const language = filenameToVscodeLanguage(uri.fsPath) ?? '' const language = filenameToVscodeLanguage(uri.fsPath) ?? ''
return `\ return `\
ORIGINAL_CODE ORIGINAL_FILE
\`\`\` ${language} \`\`\`${language}
${originalCode} ${originalCode}
\`\`\` \`\`\`
DIFF CHANGE
\`\`\` \`\`\`
${userMessage} ${applyStr}
\`\`\` \`\`\`
INSTRUCTIONS INSTRUCTIONS
Please finish writing the new file by applying the diff to the original file. Return ONLY the completion of the file, without any explanation. Please finish writing the new file by applying the change to the original file. Return ONLY the completion of the file, without any explanation.
` `
} }
export const ctrlKStream_systemMessage = `\
`
export const ctrlKStream_prefixAndSuffix = ({ fullFileStr, startLine, endLine }: { fullFileStr: string, startLine: number, endLine: number }) => { export const ctrlKStream_prefixAndSuffix = ({ fullFileStr, startLine, endLine }: { fullFileStr: string, startLine: number, endLine: number }) => {
@ -336,16 +275,31 @@ export type FimTagsType = {
midTag: string midTag: string
} }
export const defaultFimTags: FimTagsType = { export const defaultFimTags: FimTagsType = {
preTag: 'BEFORE', preTag: 'ABOVE',
sufTag: 'AFTER', sufTag: 'BELOW',
midTag: 'SELECTION', midTag: 'SELECTION',
} }
export const ctrlKStream_prompt = ({ selection, prefix, suffix, userMessage, fimTags, isOllamaFIM, language }: // this should probably be longer
{ export const ctrlKStream_systemMessage = ({ fimTags: { preTag, midTag, sufTag } }: { fimTags: FimTagsType }) => {
selection: string, prefix: string, suffix: string, userMessage: string, fimTags: FimTagsType, language: string, return `\
isOllamaFIM: false, // we require this be false for clarity You are a FIM (fill-in-the-middle) coding assistant. Your task is to fill in the middle SELECTION marked by <${midTag}> tags.
}) => {
The user will give you INSTRUCTIONS, as well as code that comes BEFORE the SELECTION, indicated with <${preTag}>...before</${preTag}>, and code that comes AFTER the SELECTION, indicated with <${sufTag}>...after</${sufTag}>.
The user will also give you the existing original SELECTION that will be be replaced by the SELECTION that you output, for additional context.
Instructions:
1. Your OUTPUT should be a SINGLE PIECE OF CODE of the form <${midTag}>...new_code</${midTag}>. Do NOT output any text or explanations before or after this.
2. You may ONLY CHANGE the original SELECTION, and NOT the content in the <${preTag}>...</${preTag}> or <${sufTag}>...</${sufTag}> tags.
3. Make sure all brackets in the new selection are balanced the same as in the original selection.
4. Be careful not to duplicate or remove variables, comments, or other syntax by mistake.
`
}
export const ctrlKStream_userMessage = ({ selection, prefix, suffix, instructions, fimTags, isOllamaFIM, language }: {
selection: string, prefix: string, suffix: string, instructions: string, fimTags: FimTagsType, language: string,
isOllamaFIM: false, // we require this be false for clarity
}) => {
const { preTag, sufTag, midTag } = fimTags const { preTag, sufTag, midTag } = fimTags
// prompt the model artifically on how to do FIM // prompt the model artifically on how to do FIM
@ -353,300 +307,20 @@ export const ctrlKStream_prompt = ({ selection, prefix, suffix, userMessage, fim
// const sufTag = 'AFTER' // const sufTag = 'AFTER'
// const midTag = 'SELECTION' // const midTag = 'SELECTION'
return `\ return `\
The user is selecting this code as their SELECTION:
\`\`\` ${language} CURRENT SELECTION
\`\`\`${language}
<${midTag}>${selection}</${midTag}> <${midTag}>${selection}</${midTag}>
\`\`\` \`\`\`
The user wants to apply the following INSTRUCTIONS to the SELECTION: INSTRUCTIONS
${userMessage} ${instructions}
Please edit the SELECTION following the user's INSTRUCTIONS, and return the edited selection.
Note that the SELECTION has code that comes before it. This code is indicated with <${preTag}>...before</${preTag}>.
Note also that the SELECTION has code that comes after it. This code is indicated with <${sufTag}>...after</${sufTag}>.
Instructions:
1. Your OUTPUT should be a SINGLE PIECE OF CODE of the form <${midTag}>...new_selection</${midTag}>. Do NOT output any text or explanations before or after this.
2. You may ONLY CHANGE the original SELECTION, and NOT the content in the <${preTag}>...</${preTag}> or <${sufTag}>...</${sufTag}> tags.
3. Make sure all brackets in the new selection are balanced the same as in the original selection.
4. Be careful not to duplicate or remove variables, comments, or other syntax by mistake.
Given the code:
<${preTag}>${prefix}</${preTag}> <${preTag}>${prefix}</${preTag}>
<${sufTag}>${suffix}</${sufTag}> <${sufTag}>${suffix}</${sufTag}>
Return only the completion block of code (of the form \`\`\` ${language}\n <${midTag}>...new_selection</${midTag}>\`\`\`):` Return only the completion block of code (of the form \`\`\`${language}
<${midTag}>...new code</${midTag}>
\`\`\`).`
}; };
// export const searchDiffChunkInstructions = `
// You are a coding assistant that applies a diff to a file. You are given a diff \`diff\`, a list of files \`files\` to apply the diff to, and a selection \`selection\` that you are currently considering in the file.
// Determine whether you should modify ANY PART of the selection \`selection\` following the \`diff\`. Return \`true\` if you should modify any part of the selection, and \`false\` if you should not modify any part of it.
// # Example 1:
// FILES
// selected file \`Sidebar.tsx\`:
// \`\`\`
// import React from 'react';
// import styles from './Sidebar.module.css';
// interface SidebarProps {
// items: { label: string; href: string }[];
// onItemSelect?: (label: string) => void;
// onExtraButtonClick?: () => void;
// }
// const Sidebar: React.FC<SidebarProps> = ({ items, onItemSelect, onExtraButtonClick }) => {
// return (
// <div className={styles.sidebar}>
// <ul>
// {items.map((item, index) => (
// <li key={index}>
// <button
// className={styles.sidebarButton}
// onClick={() => onItemSelect?.(item.label)}
// >
// {item.label}
// </button>
// </li>
// ))}
// </ul>
// <button className={styles.extraButton} onClick={onExtraButtonClick}>
// Extra Action
// </button>
// </div>
// );
// };
// export default Sidebar;
// \`\`\`
// DIFF
// \`\`\`
// @@ ... @@
// -<div className={styles.sidebar}>
// -<ul>
// - {items.map((item, index) => (
// - <li key={index}>
// - <button
// - className={styles.sidebarButton}
// - onClick={() => onItemSelect?.(item.label)}
// - >
// - {item.label}
// - </button>
// - </li>
// - ))}
// -</ul>
// -<button className={styles.extraButton} onClick={onExtraButtonClick}>
// - Extra Action
// -</button>
// -</div>
// +<div className={styles.sidebar}>
// +<ul>
// + {items.map((item, index) => (
// + <li key={index}>
// + <div
// + className={styles.sidebarButton}
// + onClick={() => onItemSelect?.(item.label)}
// + >
// + {item.label}
// + </div>
// + </li>
// + ))}
// +</ul>
// +<div className={styles.extraButton} onClick={onExtraButtonClick}>
// + Extra Action
// +</div>
// +</div>
// \`\`\`
// SELECTION
// \`\`\`
// import React from 'react';
// import styles from './Sidebar.module.css';
// interface SidebarProps {
// items: { label: string; href: string }[];
// onItemSelect?: (label: string) => void;
// onExtraButtonClick?: () => void;
// }
// const Sidebar: React.FC<SidebarProps> = ({ items, onItemSelect, onExtraButtonClick }) => {
// return (
// <div className={styles.sidebar}>
// <ul>
// {items.map((item, index) => (
// \`\`\`
// RESULT
// The output should be \`true\` because the diff begins on the line with \`<div className={styles.sidebar}>\` and this line is present in the selection.
// OUTPUT
// \`true\`
// `
// export const generateDiffInstructions = `
// You are a coding assistant. You are given a list of relevant files \`files\`, a selection that the user is making \`selection\`, and instructions to follow \`instructions\`.
// Please edit the selected file following the user's instructions (or, if appropriate, answer their question instead).
// All changes made to files must be outputted in unified diff format.
// Unified diff format instructions:
// 1. Each diff must begin with \`\`\`@@ ... @@\`\`\`.
// 2. Each line must start with a \`+\` or \`-\` or \` \` symbol.
// 3. Make diffs more than a few lines.
// 4. Make high-level diffs rather than many one-line diffs.
// Here's an example of unified diff format:
// \`\`\`
// @@ ... @@
// -def factorial(n):
// - if n == 0:
// - return 1
// - else:
// - return n * factorial(n-1)
// +def factorial(number):
// + if number == 0:
// + return 1
// + else:
// + return number * factorial(number-1)
// \`\`\`
// Please create high-level diffs where you group edits together if they are near each other, like in the above example. Another way to represent the above example is to make many small line edits. However, this is less preferred, because the edits are not high-level. The edits are close together and should be grouped:
// \`\`\`
// @@ ... @@ # This is less preferred because edits are close together and should be grouped:
// -def factorial(n):
// +def factorial(number):
// - if n == 0:
// + if number == 0:
// return 1
// else:
// - return n * factorial(n-1)
// + return number * factorial(number-1)
// \`\`\`
// # Example 1:
// FILES
// selected file \`test.ts\`:
// \`\`\`
// x = 1
// {{selection}}
// z = 3
// \`\`\`
// SELECTION
// \`\`\`const y = 2\`\`\`
// INSTRUCTIONS
// \`\`\`y = 3\`\`\`
// EXPECTED RESULT
// We should change the selection from \`\`\`y = 2\`\`\` to \`\`\`y = 3\`\`\`.
// \`\`\`
// @@ ... @@
// -x = 1
// -
// -y = 2
// +x = 1
// +
// +y = 3
// \`\`\`
// # Example 2:
// FILES
// selected file \`Sidebar.tsx\`:
// \`\`\`
// import React from 'react';
// import styles from './Sidebar.module.css';
// interface SidebarProps {
// items: { label: string; href: string }[];
// onItemSelect?: (label: string) => void;
// onExtraButtonClick?: () => void;
// }
// const Sidebar: React.FC<SidebarProps> = ({ items, onItemSelect, onExtraButtonClick }) => {
// return (
// <div className={styles.sidebar}>
// <ul>
// {items.map((item, index) => (
// <li key={index}>
// {{selection}}
// className={styles.sidebarButton}
// onClick={() => onItemSelect?.(item.label)}
// >
// {item.label}
// </button>
// </li>
// ))}
// </ul>
// <button className={styles.extraButton} onClick={onExtraButtonClick}>
// Extra Action
// </button>
// </div>
// );
// };
// export default Sidebar;
// \`\`\`
// SELECTION
// \`\`\` <button\`\`\`
// INSTRUCTIONS
// \`\`\`make all the buttons like this into divs\`\`\`
// EXPECTED OUTPUT
// We should change all the buttons like the one selected into a div component. Here is the change:
// \`\`\`
// @@ ... @@
// -<div className={styles.sidebar}>
// -<ul>
// - {items.map((item, index) => (
// - <li key={index}>
// - <button
// - className={styles.sidebarButton}
// - onClick={() => onItemSelect?.(item.label)}
// - >
// - {item.label}
// - </button>
// - </li>
// - ))}
// -</ul>
// -<button className={styles.extraButton} onClick={onExtraButtonClick}>
// - Extra Action
// -</button>
// -</div>
// +<div className={styles.sidebar}>
// +<ul>
// + {items.map((item, index) => (
// + <li key={index}>
// + <div
// + className={styles.sidebarButton}
// + onClick={() => onItemSelect?.(item.label)}
// + >
// + {item.label}
// + </div>
// + </li>
// + ))}
// +</ul>
// +<div className={styles.extraButton} onClick={onExtraButtonClick}>
// + Extra Action
// +</div>
// +</div>
// \`\`\`
// `;

View file

@ -41,15 +41,15 @@ const CodeButtonsOnHover = ({ text }: { text: string }) => {
.catch(() => { setCopyButtonState(CopyButtonState.Error) }) .catch(() => { setCopyButtonState(CopyButtonState.Error) })
metricsService.capture('Copy Code', { length: text.length }) // capture the length only metricsService.capture('Copy Code', { length: text.length }) // capture the length only
}, [text, clipboardService]) }, [metricsService, clipboardService, text])
const onApply = useCallback(() => { const onApply = useCallback(() => {
inlineDiffService.startApplying({ inlineDiffService.startApplying({
featureName: 'Ctrl+L', featureName: 'Ctrl+L',
userMessage: text, applyStr: text,
}) })
metricsService.capture('Apply Code', { length: text.length }) // capture the length only metricsService.capture('Apply Code', { length: text.length }) // capture the length only
}, [inlineDiffService]) }, [metricsService, inlineDiffService, text])
const isSingleLine = !text.includes('\n') const isSingleLine = !text.includes('\n')

View file

@ -58,7 +58,6 @@ export const QuickEditChat = ({
const id = inlineDiffsService.startApplying({ const id = inlineDiffsService.startApplying({
featureName: 'Ctrl+K', featureName: 'Ctrl+K',
diffareaid: diffareaid, diffareaid: diffareaid,
userMessage: instructions,
}) })
setCurrentlyStreamingDiffZone(id ?? null) setCurrentlyStreamingDiffZone(id ?? null)
}, [currStreamingDiffZoneRef, setCurrentlyStreamingDiffZone, isDisabled, inlineDiffsService, diffareaid]) }, [currStreamingDiffZoneRef, setCurrentlyStreamingDiffZone, isDisabled, inlineDiffsService, diffareaid])
@ -80,7 +79,7 @@ export const QuickEditChat = ({
const keybindingString = accessor.get('IKeybindingService').lookupKeybinding(VOID_CTRL_K_ACTION_ID)?.getLabel() const keybindingString = accessor.get('IKeybindingService').lookupKeybinding(VOID_CTRL_K_ACTION_ID)?.getLabel()
return <div ref={sizerRef} style={{ maxWidth: 500 }} className={`py-2 w-full`}> return <div ref={sizerRef} style={{ maxWidth: 450 }} className={`py-2 w-full`}>
<form <form
// copied from SidebarChat.tsx // copied from SidebarChat.tsx
className={` className={`
@ -146,8 +145,8 @@ export const QuickEditChat = ({
{/* X button */} {/* X button */}
<div className='absolute -top-1 -right-1 cursor-pointer z-1'> <div className='absolute -top-1 -right-1 cursor-pointer z-1'>
<IconX <IconX
size={16} size={12}
className="p-[1px] stroke-[2] opacity-80 text-void-fg-3 hover:brightness-95" className="stroke-[2] opacity-80 text-void-fg-3 hover:brightness-95"
onClick={onX} onClick={onX}
/> />
</div> </div>

View file

@ -9,7 +9,7 @@ import { errorDetails } from '../../../../../../../platform/void/common/llmMessa
export const ErrorDisplay = ({ export const ErrorDisplay = ({
message:message_, message: message_,
fullError, fullError,
onDismiss, onDismiss,
showDismiss, showDismiss,
@ -23,7 +23,7 @@ export const ErrorDisplay = ({
const details = errorDetails(fullError) const details = errorDetails(fullError)
const message = message_ === 'TypeError: fetch failed' ? 'TypeError: fetch failed. This likely means you specified the wrong endpoint in Void Settings.' : message_ const message = message_ === 'TypeError: fetch failed' ? 'TypeError: fetch failed. This likely means you specified the wrong endpoint in Void Settings.' : message_ + ''
return ( return (

View file

@ -3,32 +3,23 @@
* Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information. * Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information.
*--------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------*/
import React, { ButtonHTMLAttributes, FormEvent, FormHTMLAttributes, Fragment, useCallback, useEffect, useRef, useState } from 'react'; import React, { ButtonHTMLAttributes, FormEvent, FormHTMLAttributes, Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useAccessor, useSidebarState, useChatThreadsState, useChatThreadsStreamState, useUriState } from '../util/services.js'; import { useAccessor, useSidebarState, useChatThreadsState, useChatThreadsStreamState, useUriState } from '../util/services.js';
import { ChatMessage, CodeSelection, CodeStagingSelection } from '../../../chatThreadService.js'; import { ChatMessage, StagingSelectionItem } from '../../../chatThreadService.js';
import { BlockCode } from '../markdown/BlockCode.js'; import { BlockCode } from '../markdown/BlockCode.js';
import { ChatMarkdownRender } from '../markdown/ChatMarkdownRender.js'; import { ChatMarkdownRender } from '../markdown/ChatMarkdownRender.js';
import { URI } from '../../../../../../../base/common/uri.js'; import { URI } from '../../../../../../../base/common/uri.js';
import { EndOfLinePreference } from '../../../../../../../editor/common/model.js';
import { IDisposable } from '../../../../../../../base/common/lifecycle.js'; import { IDisposable } from '../../../../../../../base/common/lifecycle.js';
import { ErrorDisplay } from './ErrorDisplay.js'; import { ErrorDisplay } from './ErrorDisplay.js';
import { OnError, ServiceSendLLMMessageParams } from '../../../../../../../platform/void/common/llmMessageTypes.js'; import { TextAreaFns, VoidInputBox2 } from '../util/inputs.js';
import { HistoryInputBox, InputBox } from '../../../../../../../base/browser/ui/inputbox/inputBox.js';
import { TextAreaFns, VoidCodeEditorProps, VoidInputBox2 } from '../util/inputs.js';
import { ModelDropdown, WarningBox } from '../void-settings-tsx/ModelDropdown.js'; import { ModelDropdown, WarningBox } from '../void-settings-tsx/ModelDropdown.js';
import { chat_systemMessage, chat_prompt } from '../../../prompt/prompts.js';
import { ISidebarStateService } from '../../../sidebarStateService.js';
import { ILLMMessageService } from '../../../../../../../platform/void/common/llmMessageService.js';
import { IModelService } from '../../../../../../../editor/common/services/model.js';
import { SidebarThreadSelector } from './SidebarThreadSelector.js'; import { SidebarThreadSelector } from './SidebarThreadSelector.js';
import { useScrollbarStyles } from '../util/useScrollbarStyles.js'; import { useScrollbarStyles } from '../util/useScrollbarStyles.js';
import { VOID_CTRL_L_ACTION_ID } from '../../../actionIDs.js'; import { VOID_CTRL_L_ACTION_ID } from '../../../actionIDs.js';
import { ArrowBigLeftDash, CopyX, Delete, FileX2, SquareX, X } from 'lucide-react';
import { filenameToVscodeLanguage } from '../../../helpers/detectLanguage.js'; import { filenameToVscodeLanguage } from '../../../helpers/detectLanguage.js';
import { Pencil } from 'lucide-react'
import { VOID_OPEN_SETTINGS_ACTION_ID } from '../../../voidSettingsPane.js'; import { VOID_OPEN_SETTINGS_ACTION_ID } from '../../../voidSettingsPane.js';
@ -261,8 +252,8 @@ const getBasename = (pathStr: string) => {
export const SelectedFiles = ( export const SelectedFiles = (
{ type, selections, setSelections, showProspectiveSelections }: { type, selections, setSelections, showProspectiveSelections }:
| { type: 'past', selections: CodeSelection[]; setSelections?: undefined, showProspectiveSelections?: undefined } | { type: 'past', selections: StagingSelectionItem[]; setSelections?: undefined, showProspectiveSelections?: undefined }
| { type: 'staging', selections: CodeStagingSelection[]; setSelections: ((newSelections: CodeStagingSelection[]) => void), showProspectiveSelections?: boolean } | { type: 'staging', selections: StagingSelectionItem[]; setSelections: ((newSelections: StagingSelectionItem[]) => void), showProspectiveSelections?: boolean }
) => { ) => {
// index -> isOpened // index -> isOpened
@ -287,11 +278,11 @@ export const SelectedFiles = (
return withCurrent.slice(0, maxRecentUris) return withCurrent.slice(0, maxRecentUris)
}) })
}, [currentUri]) }, [currentUri])
let prospectiveSelections: CodeStagingSelection[] = [] let prospectiveSelections: StagingSelectionItem[] = []
if (type === 'staging' && showProspectiveSelections) { // handle prospective files if (type === 'staging' && showProspectiveSelections) { // handle prospective files
// add a prospective file if type === 'staging' and if the user is in a file, and if the file is not selected yet // add a prospective file if type === 'staging' and if the user is in a file, and if the file is not selected yet
prospectiveSelections = recentUris prospectiveSelections = recentUris
.filter(uri => !selections.find(s => s.range === null && s.fileURI.fsPath === uri.fsPath)) .filter(uri => !selections.find(s => s.type === 'File' && s.fileURI.fsPath === uri.fsPath))
.slice(0, maxProspectiveFiles) .slice(0, maxProspectiveFiles)
.map(uri => ({ .map(uri => ({
type: 'File', type: 'File',
@ -325,7 +316,7 @@ export const SelectedFiles = (
> >
{/* selection summary */} {/* selection summary */}
<div // container for item and its delete button (if it's last) <div // container for item and its delete button (if it's last)
className='flex items-center gap-1 mr-0.5 mb-0.5' className='flex items-center gap-1 mr-0.5 my-0.5'
> >
<div // styled summary box <div // styled summary box
className={`flex items-center gap-0.5 relative className={`flex items-center gap-0.5 relative
@ -339,7 +330,7 @@ export const SelectedFiles = (
onClick={() => { onClick={() => {
if (isThisSelectionProspective) { // add prospective selection to selections if (isThisSelectionProspective) { // add prospective selection to selections
if (type !== 'staging') return; // (never) if (type !== 'staging') return; // (never)
setSelections([...selections, selection as CodeStagingSelection]) setSelections([...selections, selection])
} else if (isThisSelectionAFile) { // open files } else if (isThisSelectionAFile) { // open files
commandService.executeCommand('vscode.open', selection.fileURI, { commandService.executeCommand('vscode.open', selection.fileURI, {
@ -380,7 +371,7 @@ export const SelectedFiles = (
</div> </div>
{/* clear all selections button */} {/* clear all selections button */}
{type !== 'staging' || selections.length === 0 || i !== selections.length - 1 {/* {type !== 'staging' || selections.length === 0 || i !== selections.length - 1
? null ? null
: <div className={`flex items-center ${isThisSelectionOpened ? 'w-full' : ''}`}> : <div className={`flex items-center ${isThisSelectionOpened ? 'w-full' : ''}`}>
<div <div
@ -402,7 +393,7 @@ export const SelectedFiles = (
/> />
</div> </div>
</div> </div>
} } */}
</div> </div>
{/* selection text */} {/* selection text */}
{isThisSelectionOpened && {isThisSelectionOpened &&
@ -413,7 +404,7 @@ export const SelectedFiles = (
}} }}
> >
<BlockCode <BlockCode
initValue={selection.selectionStr!} initValue={selection.selectionStr}
language={filenameToVscodeLanguage(selection.fileURI.path)} language={filenameToVscodeLanguage(selection.fileURI.path)}
maxHeight={200} maxHeight={200}
showScrollbars={true} showScrollbars={true}
@ -423,9 +414,8 @@ export const SelectedFiles = (
</div>) </div>)
return <Fragment key={thisKey}> return <Fragment key={thisKey}>
{selections.length > 0 && i === selections.length && {/* divider between `selections` and `prospectiveSelections` */}
<div className='w-full'></div> // divider between `selections` and `prospectiveSelections` {/* {selections.length > 0 && i === selections.length && <div className='w-full'></div>} */}
}
{selectionHTML} {selectionHTML}
</Fragment> </Fragment>
@ -446,7 +436,7 @@ const ChatBubble_ = ({ isEditMode, isLoading, children, role }: { role: ChatMess
className={` className={`
relative relative
${isEditMode ? 'px-2 w-full max-w-full' ${isEditMode ? 'px-2 w-full max-w-full'
: role === 'user' ? `px-2 self-end w-fit max-w-full` : role === 'user' ? `px-2 mt-4 self-end w-fit max-w-full`
: role === 'assistant' ? `px-2 self-start w-full max-w-full` : '' : role === 'assistant' ? `px-2 self-start w-full max-w-full` : ''
} }
`} `}
@ -487,7 +477,7 @@ const ChatBubble = ({ chatMessage, isLoading }: { chatMessage: ChatMessage, isLo
const [isEditMode, setIsEditMode] = useState(false) const [isEditMode, setIsEditMode] = useState(false)
if (!chatMessage.content) { // don't show if empty if (!chatMessage.content && !isLoading) { // don't show if empty and not loading (if loading, want to show)
return null return null
} }
@ -606,6 +596,13 @@ export const SidebarChat = () => {
scrollContainerRef.current?.scrollTo({ top: 0, left: 0 }) scrollContainerRef.current?.scrollTo({ top: 0, left: 0 })
}, [isHistoryOpen, currentThread.id]) }, [isHistoryOpen, currentThread.id])
const prevMessagesHTML = useMemo(() => {
return previousMessages.map((message, i) =>
<ChatBubble key={i} chatMessage={message} />
)
}, [previousMessages])
return <div return <div
ref={sidebarRef} ref={sidebarRef}
className={`w-full h-full`} className={`w-full h-full`}
@ -622,16 +619,14 @@ export const SidebarChat = () => {
scrollContainerRef={scrollContainerRef} scrollContainerRef={scrollContainerRef}
className={` className={`
w-full h-auto w-full h-auto
flex flex-col gap-1 flex flex-col
overflow-x-hidden overflow-x-hidden
overflow-y-auto overflow-y-auto
`} `}
style={{ maxHeight: sidebarDimensions.height - historyDimensions.height - formDimensions.height - 36 }} // the height of the previousMessages is determined by all other heights style={{ maxHeight: sidebarDimensions.height - historyDimensions.height - formDimensions.height - 36 }} // the height of the previousMessages is determined by all other heights
> >
{/* previous messages */} {/* previous messages */}
{previousMessages.map((message, i) => {prevMessagesHTML}
<ChatBubble key={i} chatMessage={message} />
)}
{/* message stream */} {/* message stream */}
<ChatBubble chatMessage={{ role: 'assistant', content: messageSoFar ?? '', displayContent: messageSoFar || null }} isLoading={isStreaming} /> <ChatBubble chatMessage={{ role: 'assistant', content: messageSoFar ?? '', displayContent: messageSoFar || null }} isLoading={isStreaming} />
@ -675,7 +670,7 @@ export const SidebarChat = () => {
{/* top row */} {/* top row */}
<> <>
{/* selections */} {/* selections */}
<SelectedFiles type='staging' selections={selections || []} setSelections={chatThreadsService.setStaging.bind(chatThreadsService)} showProspectiveSelections={previousMessages.length === 0}/> <SelectedFiles type='staging' selections={selections || []} setSelections={chatThreadsService.setStaging.bind(chatThreadsService)} showProspectiveSelections={previousMessages.length === 0} />
</> </>
{/* middle row */} {/* middle row */}

View file

@ -104,6 +104,7 @@ export const SidebarThreadSelector = () => {
flex items-center flex items-center
`} `}
onClick={() => chatThreadsService.switchToThread(pastThread.id)} onClick={() => chatThreadsService.switchToThread(pastThread.id)}
onDoubleClick={() => sidebarStateService.setState({ isHistoryOpen: false })}
title={new Date(pastThread.createdAt).toLocaleString()} title={new Date(pastThread.createdAt).toLocaleString()}
> >
<div className='truncate'>{`${firstMsg}`}</div> <div className='truncate'>{`${firstMsg}`}</div>

View file

@ -687,6 +687,8 @@ export const VoidCodeEditor = ({ initValue, language, maxHeight, showScrollbars
// maxColumn: 0, // maxColumn: 0,
}, },
hover: { enabled: false },
selectionHighlight: false, // highlights whole words selectionHighlight: false, // highlights whole words
renderLineHighlight: 'none', renderLineHighlight: 'none',

View file

@ -11,7 +11,7 @@ import { ServicesAccessor } from '../../../../editor/browser/editorExtensions.js
import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js'; import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js';
import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js'; import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';
import { CodeStagingSelection, IChatThreadService } from './chatThreadService.js'; import { StagingSelectionItem, IChatThreadService } from './chatThreadService.js';
import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js'; import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js';
import { IRange } from '../../../../editor/common/core/range.js'; import { IRange } from '../../../../editor/common/core/range.js';
@ -112,7 +112,7 @@ registerAction2(class extends Action2 {
const selectionStr = getContentInRange(model, selectionRange) const selectionStr = getContentInRange(model, selectionRange)
const selection: CodeStagingSelection = !selectionRange || !selectionStr || (selectionRange.startLineNumber > selectionRange.endLineNumber) ? { const selection: StagingSelectionItem = !selectionRange || !selectionStr || (selectionRange.startLineNumber > selectionRange.endLineNumber) ? {
type: 'File', type: 'File',
fileURI: model.uri, fileURI: model.uri,
selectionStr: null, selectionStr: null,

View file

@ -53,10 +53,11 @@ registerAction2(class extends Action2 {
const notifService = accessor.get(INotificationService) const notifService = accessor.get(INotificationService)
const metricsService = accessor.get(IMetricsService) const metricsService = accessor.get(IMetricsService)
metricsService.capture('Void Update Manual: Checking...', {})
const res = await voidUpdateService.check() const res = await voidUpdateService.check()
if (!res) { notifyErrChecking(notifService); metricsService.capture('Void Update: Error', {}) } if (!res) { notifyErrChecking(notifService); metricsService.capture('Void Update Manual: Error', { res }) }
else if (res.hasUpdate) { notifyYesUpdate(notifService, res.message); metricsService.capture('Void Update: Yes', {}) } else if (res.hasUpdate) { notifyYesUpdate(notifService, res.message); metricsService.capture('Void Update Manual: Yes', { res }) }
else if (!res.hasUpdate) { notifyNoUpdate(notifService); metricsService.capture('Void Update: No', {}) } else if (!res.hasUpdate) { notifyNoUpdate(notifService); metricsService.capture('Void Update Manual: No', { res }) }
} }
}) })
@ -65,23 +66,27 @@ class VoidUpdateWorkbenchContribution extends Disposable implements IWorkbenchCo
static readonly ID = 'workbench.contrib.void.voidUpdate' static readonly ID = 'workbench.contrib.void.voidUpdate'
constructor( constructor(
@IVoidUpdateService private readonly voidUpdateService: IVoidUpdateService, @IVoidUpdateService private readonly voidUpdateService: IVoidUpdateService,
@INotificationService private readonly notifService: INotificationService,
@IMetricsService private readonly metricsService: IMetricsService, @IMetricsService private readonly metricsService: IMetricsService,
@INotificationService private readonly notifService: INotificationService,
) { ) {
super() super()
const autoCheck = async () => {
// on mount this.metricsService.capture('Void Update Startup: Checking...', {})
setTimeout(async () => {
const res = await this.voidUpdateService.check() const res = await this.voidUpdateService.check()
if (!res) { notifyErrChecking(this.notifService); this.metricsService.capture('Void Update Startup: Error', { res }) }
else if (res.hasUpdate) { notifyYesUpdate(this.notifService, res.message); this.metricsService.capture('Void Update Startup: Yes', { res }) }
else if (!res.hasUpdate) { this.metricsService.capture('Void Update Startup: No', { res }) } // display nothing if up to date
}
const notifService = this.notifService // check once 5 seconds after mount
const metricsService = this.metricsService
if (!res) { notifyErrChecking(notifService); metricsService.capture('Void Update Startup: Error', {}) } const initId = setTimeout(() => autoCheck(), 5 * 1000)
else if (res.hasUpdate) { notifyYesUpdate(this.notifService, res.message); metricsService.capture('Void Update Startup: Yes', {}) } this._register({ dispose: () => clearTimeout(initId) })
else if (!res.hasUpdate) { metricsService.capture('Void Update Startup: No', {}) } // display nothing if up to date
// check every 3 hours
const intervalId = setInterval(() => autoCheck(), 3 * 60 * 60 * 1000)
this._register({ dispose: () => clearInterval(intervalId) })
}, 5 * 1000)
} }
} }
registerWorkbenchContribution2(VoidUpdateWorkbenchContribution.ID, VoidUpdateWorkbenchContribution, WorkbenchPhase.BlockRestore); registerWorkbenchContribution2(VoidUpdateWorkbenchContribution.ID, VoidUpdateWorkbenchContribution, WorkbenchPhase.BlockRestore);

View file

@ -190,7 +190,7 @@ import { MAX_ZOOM_LEVEL, MIN_ZOOM_LEVEL } from '../../platform/window/electron-s
}, },
'window.zoomLevel': { 'window.zoomLevel': {
'type': 'number', 'type': 'number',
'default': 0, 'default': -1,
'minimum': MIN_ZOOM_LEVEL, 'minimum': MIN_ZOOM_LEVEL,
'maximum': MAX_ZOOM_LEVEL, 'maximum': MAX_ZOOM_LEVEL,
'markdownDescription': localize({ comment: ['{0} will be a setting name rendered as a link'], key: 'zoomLevel' }, "Adjust the default zoom level for all windows. Each increment above `0` (e.g. `1`) or below (e.g. `-1`) represents zooming `20%` larger or smaller. You can also enter decimals to adjust the zoom level with a finer granularity. See {0} for configuring if the 'Zoom In' and 'Zoom Out' commands apply the zoom level to all windows or only the active window.", '`#window.zoomPerWindow#`'), 'markdownDescription': localize({ comment: ['{0} will be a setting name rendered as a link'], key: 'zoomLevel' }, "Adjust the default zoom level for all windows. Each increment above `0` (e.g. `1`) or below (e.g. `-1`) represents zooming `20%` larger or smaller. You can also enter decimals to adjust the zoom level with a finer granularity. See {0} for configuring if the 'Zoom In' and 'Zoom Out' commands apply the zoom level to all windows or only the active window.", '`#window.zoomPerWindow#`'),

View file

@ -44,45 +44,77 @@ export enum ThemeSettings {
} }
export enum ThemeSettingDefaults { export enum ThemeSettingDefaults {
COLOR_THEME_DARK = 'Default Dark Modern', COLOR_THEME_DARK = 'Default Dark+', // Void changed this. this is the default theme
COLOR_THEME_LIGHT = 'Default Light Modern', COLOR_THEME_LIGHT = 'Default Light Modern',
COLOR_THEME_HC_DARK = 'Default High Contrast', COLOR_THEME_HC_DARK = 'Default High Contrast',
COLOR_THEME_HC_LIGHT = 'Default High Contrast Light', COLOR_THEME_HC_LIGHT = 'Default High Contrast Light',
COLOR_THEME_DARK_OLD = 'Default Dark+', COLOR_THEME_DARK_OLD = 'Default Dark Modern', // Void changed this
COLOR_THEME_LIGHT_OLD = 'Default Light+', COLOR_THEME_LIGHT_OLD = 'Default Light+',
FILE_ICON_THEME = 'vs-seti', FILE_ICON_THEME = 'vs-seti',
PRODUCT_ICON_THEME = 'Default', PRODUCT_ICON_THEME = 'Default',
} }
export const COLOR_THEME_DARK_INITIAL_COLORS = { // export const COLOR_THEME_DARK_INITIAL_COLORS = {
'activityBar.activeBorder': '#0078d4', // 'activityBar.activeBorder': '#0078d4',
'activityBar.background': '#181818', // 'activityBar.background': '#181818',
'activityBar.border': '#2b2b2b', // 'activityBar.border': '#2b2b2b',
'activityBar.foreground': '#d7d7d7', // 'activityBar.foreground': '#d7d7d7',
'activityBar.inactiveForeground': '#868686', // 'activityBar.inactiveForeground': '#868686',
'editorGroup.border': '#ffffff17', // 'editorGroup.border': '#ffffff17',
'editorGroupHeader.tabsBackground': '#181818', // 'editorGroupHeader.tabsBackground': '#181818',
'editorGroupHeader.tabsBorder': '#2b2b2b', // 'editorGroupHeader.tabsBorder': '#2b2b2b',
'statusBar.background': '#181818', // 'statusBar.background': '#181818',
'statusBar.border': '#2b2b2b', // 'statusBar.border': '#2b2b2b',
'statusBar.foreground': '#cccccc', // 'statusBar.foreground': '#cccccc',
'statusBar.noFolderBackground': '#1f1f1f', // 'statusBar.noFolderBackground': '#1f1f1f',
'tab.activeBackground': '#1f1f1f', // 'tab.activeBackground': '#1f1f1f',
'tab.activeBorder': '#1f1f1f', // 'tab.activeBorder': '#1f1f1f',
'tab.activeBorderTop': '#0078d4', // 'tab.activeBorderTop': '#0078d4',
// 'tab.activeForeground': '#ffffff',
// 'tab.border': '#2b2b2b',
// 'textLink.foreground': '#4daafc',
// 'titleBar.activeBackground': '#181818',
// 'titleBar.activeForeground': '#cccccc',
// 'titleBar.border': '#2b2b2b',
// 'titleBar.inactiveBackground': '#1f1f1f',
// 'titleBar.inactiveForeground': '#9d9d9d',
// 'welcomePage.tileBackground': '#2b2b2b'
// };
export const COLOR_THEME_DARK_INITIAL_COLORS = { // Void changed this to match dark+
'activityBar.activeBorder': '#ffffff',
'activityBar.background': '#333333',
'activityBar.border': '#454545',
'activityBar.foreground': '#ffffff',
'activityBar.inactiveForeground': '#ffffff66',
'editorGroup.border': '#444444',
'editorGroupHeader.tabsBackground': '#252526',
'editorGroupHeader.tabsBorder': '#252526',
'statusBar.background': '#007ACC',
'statusBar.border': '#454545',
'statusBar.foreground': '#ffffff',
'statusBar.noFolderBackground': '#68217A',
'tab.activeBackground': '#2D2D2D',
'tab.activeBorder': '#ffffff',
'tab.activeBorderTop': '#007ACC',
'tab.activeForeground': '#ffffff', 'tab.activeForeground': '#ffffff',
'tab.border': '#2b2b2b', 'tab.border': '#252526',
'textLink.foreground': '#4daafc', 'textLink.foreground': '#3794ff',
'titleBar.activeBackground': '#181818', 'titleBar.activeBackground': '#3C3C3C',
'titleBar.activeForeground': '#cccccc', 'titleBar.activeForeground': '#CCCCCC',
'titleBar.border': '#2b2b2b', 'titleBar.border': '#454545',
'titleBar.inactiveBackground': '#1f1f1f', 'titleBar.inactiveBackground': '#2C2C2C',
'titleBar.inactiveForeground': '#9d9d9d', 'titleBar.inactiveForeground': '#999999',
'welcomePage.tileBackground': '#2b2b2b' 'welcomePage.tileBackground': '#252526'
}; };
export const COLOR_THEME_LIGHT_INITIAL_COLORS = { export const COLOR_THEME_LIGHT_INITIAL_COLORS = {
'activityBar.activeBorder': '#005FB8', 'activityBar.activeBorder': '#005FB8',
'activityBar.background': '#f8f8f8', 'activityBar.background': '#f8f8f8',