fix(coding-agent): fix IME candidate window positioning in menu selectors

Components with search inputs now implement Focusable interface and
propagate focus state to their child Input components. This allows
the hardware cursor to be positioned correctly for IME candidate
window placement.

Affected components:
- ModelSelectorComponent
- ScopedModelsSelectorComponent
- SessionSelectorComponent (and SessionList)
- ExtensionInputComponent
- LoginDialogComponent
- TreeSelectorComponent (and LabelInput)

fixes #827
This commit is contained in:
Mario Zechner 2026-01-18 17:22:40 +01:00
parent 8b23c0a45e
commit b4f833c259
7 changed files with 113 additions and 11 deletions

View file

@ -1,6 +1,7 @@
import {
type Component,
Container,
type Focusable,
getEditorKeybindings,
Input,
matchesKey,
@ -889,12 +890,22 @@ class SearchLine implements Component {
}
/** Label input component shown when editing a label */
class LabelInput implements Component {
class LabelInput implements Component, Focusable {
private input: Input;
private entryId: string;
public onSubmit?: (entryId: string, label: string | undefined) => void;
public onCancel?: () => void;
// Focusable implementation - propagate to input for IME cursor positioning
private _focused = false;
get focused(): boolean {
return this._focused;
}
set focused(value: boolean) {
this._focused = value;
this.input.focused = value;
}
constructor(entryId: string, currentLabel: string | undefined) {
this.entryId = entryId;
this.input = new Input();
@ -933,13 +944,26 @@ class LabelInput implements Component {
/**
* Component that renders a session tree selector for navigation
*/
export class TreeSelectorComponent extends Container {
export class TreeSelectorComponent extends Container implements Focusable {
private treeList: TreeList;
private labelInput: LabelInput | null = null;
private labelInputContainer: Container;
private treeContainer: Container;
private onLabelChangeCallback?: (entryId: string, label: string | undefined) => void;
// Focusable implementation - propagate to labelInput when active for IME cursor positioning
private _focused = false;
get focused(): boolean {
return this._focused;
}
set focused(value: boolean) {
this._focused = value;
// Propagate to labelInput when it's active
if (this.labelInput) {
this.labelInput.focused = value;
}
}
constructor(
tree: SessionTreeNode[],
currentLeafId: string | null,
@ -997,6 +1021,9 @@ export class TreeSelectorComponent extends Container {
};
this.labelInput.onCancel = () => this.hideLabelInput();
// Propagate current focused state to the new labelInput
this.labelInput.focused = this._focused;
this.treeContainer.clear();
this.labelInputContainer.clear();
this.labelInputContainer.addChild(this.labelInput);