Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

fix(tui): let picker arrows adjust effort after moving into the list (#2325)

kt0cf1314d196d
diff --git a/packages/coding-agent/.changes/model-picker-effort-arrows.md b/packages/coding-agent/.changes/model-picker-effort-arrows.md
new file mode 100644
index 0000000000..bac758909b
--- /dev/null
+++ b/packages/coding-agent/.changes/model-picker-effort-arrows.md
@@ -0,0 +1 @@
+- Fixed left and right arrows moving the search cursor after a search in the models picker: once up or down moves into the list, they adjust the highlighted model's effort until the query is edited again.
diff --git a/packages/coding-agent/src/modes/interactive/components/model-selector.ts b/packages/coding-agent/src/modes/interactive/components/model-selector.ts
index 3b014929d2..f85ccfa814 100644
--- a/packages/coding-agent/src/modes/interactive/components/model-selector.ts
+++ b/packages/coding-agent/src/modes/interactive/components/model-selector.ts
@@ -172,6 +172,9 @@ export class ModelSelectorComponent extends Container implements Focusable {
private activeModels: ModelItem[] = [];
private filteredModels: ModelItem[] = [];
private selectedIndex: number = 0;
+ // True once the user moves into the list with up or down; left/right then
+ // adjust the highlighted model's effort instead of the search cursor.
+ private navigatedIntoList = false;
private searchQuery = "";
private currentModel?: Model<any>;
private modelRegistry: ModelRegistry;
@@ -700,9 +703,10 @@ export class ModelSelectorComponent extends Container implements Focusable {
}
return;
}
- // Keep arrows available for editing a filter; an empty filter controls effort.
+ // Keep arrows available for editing a filter; an empty filter or an
+ // explicit move into the list controls effort.
if (
- this.searchInput.getValue() === "" &&
+ (this.searchInput.getValue() === "" || this.navigatedIntoList) &&
(kb.matches(keyData, "tui.editor.cursorLeft") || kb.matches(keyData, "tui.editor.cursorRight"))
) {
const direction = kb.matches(keyData, "tui.editor.cursorLeft") ? -1 : 1;
@@ -717,6 +721,7 @@ export class ModelSelectorComponent extends Container implements Focusable {
if (kb.matches(keyData, "tui.select.up")) {
const selectableCount = this.getSelectableCount();
if (selectableCount === 0) return;
+ this.navigatedIntoList = true;
this.selectedIndex = this.selectedIndex === 0 ? selectableCount - 1 : this.selectedIndex - 1;
this.updateList();
}
@@ -724,10 +729,12 @@ export class ModelSelectorComponent extends Container implements Focusable {
else if (kb.matches(keyData, "tui.select.down")) {
const selectableCount = this.getSelectableCount();
if (selectableCount === 0) return;
+ this.navigatedIntoList = true;
this.selectedIndex = this.selectedIndex === selectableCount - 1 ? 0 : this.selectedIndex + 1;
this.updateList();
} else if (kb.matches(keyData, "tui.select.pageUp") || kb.matches(keyData, "tui.select.pageDown")) {
const direction = kb.matches(keyData, "tui.select.pageUp") ? -1 : 1;
+ this.navigatedIntoList = true;
this.selectedIndex = Math.max(
0,
Math.min(this.filteredModels.length - 1, this.selectedIndex + direction * this.listLayout.visibleItems),
@@ -746,7 +753,10 @@ export class ModelSelectorComponent extends Container implements Focusable {
else {
const previousQuery = this.searchInput.getValue();
this.searchInput.handleInput(keyData);
- if (previousQuery !== this.searchInput.getValue()) this.filterModels(this.searchInput.getValue());
+ if (previousQuery !== this.searchInput.getValue()) {
+ this.navigatedIntoList = false;
+ this.filterModels(this.searchInput.getValue());
+ }
}
}
diff --git a/packages/coding-agent/test/model-selector-actions.test.ts b/packages/coding-agent/test/model-selector-actions.test.ts
index 4740faf3db..6dd569e5ef 100644
--- a/packages/coding-agent/test/model-selector-actions.test.ts
+++ b/packages/coding-agent/test/model-selector-actions.test.ts
@@ -809,6 +809,57 @@ describe("ModelSelectorComponent", () => {
expect(/glm-5(?![.\d])/.test(lines[firstRow] ?? "")).toBe(true);
});
+ it("gives left and right to effort once a search moves the selection into the list", async () => {
+ const harness = await createHarness({
+ models: [
+ { id: "alpha", name: "Alpha", reasoning: true },
+ { id: "beta", name: "Beta", reasoning: true },
+ ],
+ });
+ harnesses.push(harness);
+
+ const alpha = harness.getModel("alpha")!;
+ const beta = harness.getModel("beta")!;
+ const selected = vi.fn();
+ const selector = new ModelSelectorComponent(
+ createFakeTui(),
+ undefined,
+ harness.session.modelRegistry,
+ [],
+ selected,
+ () => {},
+ undefined,
+ { availableModels: [alpha, beta], thinkingLevel: "medium", inline: true },
+ );
+
+ await waitForAsyncRender();
+
+ // With an active query but no list navigation, arrows edit the query.
+ selector.handleInput("a");
+ selector.handleInput("\x1b[D");
+ expect(selector.getSearchInput().getCursor()).toBe(0);
+ selector.handleInput("l");
+ expect(selector.getSearchInput().getValue()).toBe("la");
+ selector.handleInput("\x7f");
+ expect(selector.getSearchInput().getValue()).toBe("a");
+
+ // Moving into the list hands left and right to the highlighted model's effort.
+ selector.handleInput("\x1b[B");
+ selector.handleInput("\x1b[C");
+ expect(selector.getSearchInput().getCursor()).toBe(0);
+ expect(selector.getSearchInput().getValue()).toBe("a");
+ selector.handleInput("\r");
+ expect(selected).toHaveBeenLastCalledWith(beta, "high");
+
+ // Editing the query again returns left and right to the search cursor.
+ selector.handleInput("l");
+ expect(selector.getSearchInput().getValue()).toBe("la");
+ selector.handleInput("\x1b[C");
+ expect(selector.getSearchInput().getCursor()).toBe(2);
+ selector.handleInput("\r");
+ expect(selected).toHaveBeenLastCalledWith(alpha, undefined);
+ });
+
it("keeps scoped model help within a short terminal viewport", async () => {
const harness = await createHarness({
models: Array.from({ length: 12 }, (_, index) => ({