From 6aaf425419856fe65ec7ea2ac95a832e682e4ef2 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Thu, 2 Jan 2025 17:10:38 -0800 Subject: [PATCH 1/6] Settings update + ctrlK stream runs (but is broken) --- .../platform/void/common/voidSettingsTypes.ts | 8 +++---- .../void/browser/inlineDiffsService.ts | 22 +++++++++---------- .../react/src/void-settings-tsx/Settings.tsx | 15 ++++++------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/vs/platform/void/common/voidSettingsTypes.ts b/src/vs/platform/void/common/voidSettingsTypes.ts index fce75bcd..64c74477 100644 --- a/src/vs/platform/void/common/voidSettingsTypes.ts +++ b/src/vs/platform/void/common/voidSettingsTypes.ts @@ -144,8 +144,8 @@ export const defaultProviderSettings = { export type ProviderName = keyof typeof defaultProviderSettings export const providerNames = Object.keys(defaultProviderSettings) as ProviderName[] -export const localProviderNames: ProviderName[] = ['ollama'] // all local names -export const nonlocalProviderNames = providerNames.filter((name) => !localProviderNames.includes(name)) // all non-local names +export const localProviderNames = ['ollama', 'openAICompatible'] satisfies ProviderName[] // all local names +export const nonlocalProviderNames = providerNames.filter((name) => !(localProviderNames as string[]).includes(name)) // all non-local names type CustomSettingName = UnionOfKeys type CustomProviderSettings = { @@ -379,7 +379,7 @@ export const featureNames = ['Ctrl+L', 'Ctrl+K', 'Autocomplete'] as const // the models of these can be refreshed (in theory all can, but not all should) -export const refreshableProviderNames = ['ollama', 'openAICompatible'] satisfies ProviderName[] +export const refreshableProviderNames = localProviderNames export type RefreshableProviderName = typeof refreshableProviderNames[number] @@ -405,7 +405,7 @@ type FeatureFlagDisplayInfo = { export const displayInfoOfFeatureFlag = (featureFlag: FeatureFlagName): FeatureFlagDisplayInfo => { if (featureFlag === 'autoRefreshModels') { return { - description: `Automatically detect local providers and models (like Ollama).`, // ${`refreshableProviderNames.map(providerName => titleOfProviderName(providerName)).join(', ')`} + description: `Automatically detect local providers and models (${refreshableProviderNames.map(providerName => displayInfoOfProviderName(providerName).title).join(', ')}).`, } } throw new Error(`featureFlagInfo: Unknown feature flag: "${featureFlag}"`) diff --git a/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts b/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts index da288609..a1c7fd65 100644 --- a/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts +++ b/src/vs/workbench/contrib/void/browser/inlineDiffsService.ts @@ -117,7 +117,7 @@ type CtrlKZone = { editorId: string; // the editor the input lives on _mountInfo: null | { - inputBox: InputBox | null; // the input box that lives in the zone + inputBoxRef: { current: InputBox | null }; // the input box that lives in the zone dispose: () => void; refresh: () => void; } @@ -329,7 +329,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { let zoneId: string | null = null let viewZone_: IViewZone | null = null - let inputBox_: InputBox | null = null + const inputBoxRef: { current: InputBox | null } = { current: null } const itemId = this._consistentEditorItemService.addToEditor(editor, () => { const domNode = document.createElement('div'); @@ -352,7 +352,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { mountCtrlK(domNode, accessor, { diffareaid: ctrlKZone.diffareaid, onGetInputBox: (inputBox) => { - inputBox_ = inputBox + inputBoxRef.current = inputBox // if it's mounting for the first time, focus it if (!(ctrlKZone.diffareaid in this.mostRecentTextOfCtrlKZoneId)) { // detect first mount this way (a hack) this.mostRecentTextOfCtrlKZoneId[ctrlKZone.diffareaid] = undefined @@ -381,10 +381,8 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { }) }) - - return { - inputBox: inputBox_, + inputBoxRef, refresh: () => editor.changeViewZones(accessor => { if (zoneId && viewZone_) { viewZone_.afterLineNumber = ctrlKZone.startLine - 1 @@ -394,7 +392,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { dispose: () => { this._consistentEditorItemService.removeFromEditor(itemId) }, - } + } satisfies CtrlKZone['_mountInfo'] } @@ -405,6 +403,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { if (diffArea.type !== 'CtrlKZone') continue if (!diffArea._mountInfo) { diffArea._mountInfo = this._addCtrlKZoneInput(diffArea) + console.log('MOUNTED', diffArea.diffareaid) } else { diffArea._mountInfo.refresh() @@ -887,7 +886,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { if (diffArea.type !== 'CtrlKZone') continue const noOverlap = diffArea.startLine > endLine || diffArea.endLine < startLine if (!noOverlap) { - setTimeout(() => diffArea._mountInfo?.inputBox?.focus(), 0) + setTimeout(() => diffArea._mountInfo?.inputBoxRef.current?.focus(), 0) return } } @@ -943,6 +942,8 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { let uri: URI let userMessage: string + console.log('AA') + if (featureName === 'Ctrl+L') { const uri_ = this._getActiveEditorURI() @@ -983,14 +984,13 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { startLine = startLine_ endLine = endLine_ - if (!_mountInfo?.inputBox) return - userMessage = _mountInfo.inputBox?.value + if (!_mountInfo?.inputBoxRef.current) return + userMessage = _mountInfo.inputBoxRef.current?.value } else { throw new Error(`Void: diff.type not recognized on: ${featureName}`) } - const currentFileStr = this._readURI(uri) if (currentFileStr === null) return const originalCode = currentFileStr.split('\n').slice((startLine - 1), (endLine - 1) + 1).join('\n') diff --git a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx index 62fd2450..cc935cc3 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx @@ -420,13 +420,12 @@ export const Settings = () => {

Local Providers

{/*

{`Keep your data private by hosting AI locally on your computer.`}

*/} {/*

{`Instructions:`}

*/} -

{`Void can access any model that you host locally.`}

-
-

-

-

-

-

+

{`Void can access any model that you host locally. By default, we automatically detect your local models.`}

+
+

+

+

+

{/* TODO we should create UI for downloading models without user going into terminal */}
@@ -435,7 +434,7 @@ export const Settings = () => {

More Providers

-

{`Void can also access models like ChatGPT and Claude. We recommend using Anthropic or OpenAI.`}

+

{`Void can also access models like ChatGPT and Claude. We recommend using Anthropic or OpenAI.`}

{/*

{`Access models like ChatGPT and Claude. We recommend using Anthropic or OpenAI as providers, or Groq as a faster alternative.`}

*/} From b31882565b6ef6c44daae64d1c0b2427b940dc1b Mon Sep 17 00:00:00 2001 From: Mathew Pareles Date: Thu, 2 Jan 2025 17:11:31 -0800 Subject: [PATCH 2/6] fix watchreact --- .../contrib/void/browser/react/build.js | 37 +++++++++++++++++-- .../browser/react/src/markdown/BlockCode.tsx | 1 - .../react/src/markdown/ChatMarkdownRender.tsx | 5 +-- .../react/src/sidebar-tsx/SidebarChat.tsx | 28 ++++++-------- .../void/browser/react/src/util/inputs.tsx | 2 +- 5 files changed, 49 insertions(+), 24 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/react/build.js b/src/vs/workbench/contrib/void/browser/react/build.js index 118e2eaa..1ce5a6ee 100755 --- a/src/vs/workbench/contrib/void/browser/react/build.js +++ b/src/vs/workbench/contrib/void/browser/react/build.js @@ -4,13 +4,42 @@ *--------------------------------------------------------------------------------------------*/ import { spawn, execSync } from 'child_process'; +// Added lines below +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const __void_name = 'void' + +// hack to refresh styles automatically +function saveStylesFile() { + setTimeout(() => { + try { + // Find "void" in __dirname and use that as our base: + const voidIdx = __dirname.indexOf(__void_name); + const baseDir = __dirname.substring(0, voidIdx + __void_name.length); + const target = path.join( + baseDir, + 'src/vs/workbench/contrib/void/browser/react/src2/styles.css' + ); + + // Or re-write with the same content: + const content = fs.readFileSync(target, 'utf8'); + fs.writeFileSync(target, content, 'utf8'); + console.log('[scope-tailwind] Force-saved styles.css'); + } catch (err) { + console.error('[scope-tailwind] Error saving styles.css:', err); + } + }, 3000); +} const args = process.argv.slice(2); const isWatch = args.includes('--watch') || args.includes('-w'); if (isWatch) { // Watch mode - // Create a watcher for scope-tailwind using nodemon const scopeTailwindWatcher = spawn('npx', [ 'nodemon', '--watch', 'src', @@ -19,15 +48,17 @@ if (isWatch) { 'npx scope-tailwind ./src -o src2/ -s void-scope -c styles.css -p "void-"' ]); - // Create a watcher for tsup in watch mode const tsupWatcher = spawn('npx', [ 'tsup', '--watch' ]); - // Handle scope-tailwind watcher output scopeTailwindWatcher.stdout.on('data', (data) => { console.log(`[scope-tailwind] ${data}`); + // If the output mentions "styles.css", trigger the save: + if (data.toString().includes('styles.css')) { + saveStylesFile(); + } }); scopeTailwindWatcher.stderr.on('data', (data) => { diff --git a/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx b/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx index 8ecc9e8f..e64c43c3 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/markdown/BlockCode.tsx @@ -70,7 +70,6 @@ export const BlockCode = ({ text, buttonsOnHover, language }: { text: string, bu return (<>
- {buttonsOnHover === null ? null : (
{buttonsOnHover}
diff --git a/src/vs/workbench/contrib/void/browser/react/src/markdown/ChatMarkdownRender.tsx b/src/vs/workbench/contrib/void/browser/react/src/markdown/ChatMarkdownRender.tsx index 62d24b1c..ef5221f7 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/markdown/ChatMarkdownRender.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/markdown/ChatMarkdownRender.tsx @@ -45,19 +45,18 @@ const CodeButtonsOnHover = ({ text }: { text: string }) => { }) }, [inlineDiffService]) - const isSingleLine = !text.includes('\n') return <>