add void settings in lower left

This commit is contained in:
Andrew Pareles 2024-12-15 21:10:15 -08:00
parent f6924df09b
commit 718b8cc61b
3 changed files with 22 additions and 13 deletions

View file

@ -29,7 +29,7 @@ type SetModelSelectionOfFeature = <K extends FeatureName>(
type ModelOption = { text: string, value: ModelSelection }
export type ModelOption = { text: string, value: ModelSelection }

View file

@ -17,13 +17,13 @@ export const ModelSelectionOfFeature = ({ featureName }: { featureName: FeatureN
let weChangedText = false
return <>
<h2>{featureName}</h2>
{
<VoidSelectBox
{settingsState._modelsList.length === 0 ?
'Please add a provider!'
: <VoidSelectBox
options={settingsState._modelsList}
onChangeSelection={useCallback((newVal: ModelSelection) => {
if (weChangedText) return
voidSettingsService.setModelSelectionOfFeature(featureName, newVal)
}, [voidSettingsService, featureName])}
// we are responsible for setting the initial state here. always sync instance when state changes.
@ -32,18 +32,15 @@ export const ModelSelectionOfFeature = ({ featureName }: { featureName: FeatureN
const modelsListRef = voidSettingsService.state._modelsList // as a ref
const settingsAtProvider = voidSettingsService.state.modelSelectionOfFeature[featureName]
const selectionIdx = settingsAtProvider === null ? -1 : modelsListRef.findIndex(v => modelSelectionsEqual(v.value, settingsAtProvider))
if (selectionIdx !== -1) {
weChangedText = true
instance.select(selectionIdx)
weChangedText = false
}
weChangedText = true
instance.select(selectionIdx === -1 ? 0 : selectionIdx)
weChangedText = false
}
syncInstance()
const disposable = voidSettingsService.onDidChangeState(syncInstance)
return [disposable]
}, [voidSettingsService, featureName])}
/>}
</>
}

View file

@ -15,7 +15,7 @@ import { IStorageService } from '../../../../platform/storage/common/storage.js'
import { Dimension } from '../../../../base/browser/dom.js';
import { EditorPaneDescriptor, IEditorPaneRegistry } from '../../../browser/editor.js';
import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js';
import { Action2, MenuId, registerAction2 } from '../../../../platform/actions/common/actions.js';
import { Action2, MenuId, MenuRegistry, registerAction2 } from '../../../../platform/actions/common/actions.js';
import { Registry } from '../../../../platform/registry/common/platform.js';
import { ServicesAccessor } from '../../../../editor/browser/editorExtensions.js';
import { IEditorService } from '../../../services/editor/common/editorService.js';
@ -92,11 +92,12 @@ Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane
);
const OPEN_VOID_SETTINGS_ID = 'workbench.action.openVoidSettings'
// Register the gear
registerAction2(class extends Action2 {
constructor() {
super({
id: 'workbench.action.openVoidSettings',
id: OPEN_VOID_SETTINGS_ID,
title: nls.localize2('voidSettings', "Void: Settings"),
f1: true,
icon: Codicon.gear,
@ -120,3 +121,14 @@ registerAction2(class extends Action2 {
await editorService.openEditor(input);
}
})
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
group: '0_command',
command: {
id: OPEN_VOID_SETTINGS_ID,
title: nls.localize('voidSettings', "Void Settings")
},
order: 1
});