feat(coding-agent): add composable editor factory access

closes #3935
This commit is contained in:
Mario Zechner
2026-04-29 23:26:25 +02:00
parent c1dd6082ee
commit d698647b12
7 changed files with 36 additions and 7 deletions

View File

@@ -20,7 +20,6 @@ import type {
AutocompleteItem,
AutocompleteProvider,
EditorComponent,
EditorTheme,
Keybinding,
KeyId,
MarkdownTheme,
@@ -60,6 +59,7 @@ import { type AgentSession, type AgentSessionEvent, parseSkillBlock } from "../.
import { type AgentSessionRuntime, SessionImportFileNotFoundError } from "../../core/agent-session-runtime.js";
import type {
AutocompleteProviderFactory,
EditorFactory,
ExtensionCommandContext,
ExtensionContext,
ExtensionRunner,
@@ -251,6 +251,7 @@ export class InteractiveMode {
private statusContainer: Container;
private defaultEditor: CustomEditor;
private editor: EditorComponent;
private editorComponentFactory: EditorFactory | undefined;
private autocompleteProvider: AutocompleteProvider | undefined;
private autocompleteProviderWrappers: AutocompleteProviderFactory[] = [];
private fdPath: string | undefined;
@@ -1985,6 +1986,7 @@ export class InteractiveMode {
this.setupAutocompleteProvider();
},
setEditorComponent: (factory) => this.setCustomEditorComponent(factory),
getEditorComponent: () => this.editorComponentFactory,
get theme() {
return theme;
},
@@ -2182,9 +2184,9 @@ export class InteractiveMode {
* Set a custom editor component from an extension.
* Pass undefined to restore the default editor.
*/
private setCustomEditorComponent(
factory: ((tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) => EditorComponent) | undefined,
): void {
private setCustomEditorComponent(factory: EditorFactory | undefined): void {
this.editorComponentFactory = factory;
// Save text from current editor before switching
const currentText = this.editor.getText();