Skip to content

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

Rust

Fix Option+S in the model selector on macOS terminals that type ß (#2708)

Sebastian Müllercd1f215cffd0
diff --git a/packages/coding-agent/.changes/macos-option-key-bindings.md b/packages/coding-agent/.changes/macos-option-key-bindings.md
new file mode 100644
index 0000000000..64deedf397
--- /dev/null
+++ b/packages/coding-agent/.changes/macos-option-key-bindings.md
@@ -0,0 +1 @@
+- Fixed Option+S not toggling the model selector scope on macOS terminals that type `ß` instead of sending Option as Meta; the character no longer lands in the search field.
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 a794d5e97b..244c0a288c 100644
--- a/packages/coding-agent/src/modes/interactive/components/model-selector.ts
+++ b/packages/coding-agent/src/modes/interactive/components/model-selector.ts
@@ -701,7 +701,7 @@ export class ModelSelectorComponent extends Container implements Focusable {
handleInput(keyData: string): void {
const kb = getKeybindings();
- if (kb.matches(keyData, "app.model.toggleScope")) {
+ if (kb.matches(keyData, "app.model.toggleScope", { optionComposed: true })) {
if (this.scopedModelItems.length > 0) {
const nextScope: ModelScope = this.scope === "all" ? "scoped" : "all";
this.setScope(nextScope);
diff --git a/packages/coding-agent/test/suite/regressions/2182-picker-selection.test.ts b/packages/coding-agent/test/suite/regressions/2182-picker-selection.test.ts
index 3722f939ed..8797f95064 100644
--- a/packages/coding-agent/test/suite/regressions/2182-picker-selection.test.ts
+++ b/packages/coding-agent/test/suite/regressions/2182-picker-selection.test.ts
@@ -22,7 +22,7 @@ function deferred() {
});
return { promise, resolve };
}
-async function fixture() {
+async function fixture(scoped = false) {
const harness = await createHarness({
models: [
{ id: "plain", name: "Plain", reasoning: false },
@@ -51,8 +51,8 @@ async function fixture() {
connectionConfiguredProviders: new Set([model.provider]),
connectionState: { thinkingLevel: "off" },
getCurrentModel: () => plain,
- getScopedModelState: () => [],
- getCachedModelCandidates: () => [model],
+ getScopedModelState: () => (scoped ? [{ model }] : []),
+ getCachedModelCandidates: () => (scoped ? [model, plain] : [model]),
getModelSelectorRefreshPromise: () => undefined,
createAuthFlows: () => ({ getLoginProviderOptions: () => [] }),
ensureModelProviderConfigured: async () => true,
@@ -178,6 +178,15 @@ it.each([false, true])("edits search text with arrows for reasoning=%s", async (
}
});
+it("toggles model scope instead of typing when Option+S arrives as the composed ß (macOS)", async () => {
+ const f = await fixture(true);
+ const done = f.mode.showConfigurationMenu("models");
+ f.menu().handleInput("ß");
+ expect(stripAnsi(f.menu().render(100).join("\n"))).toContain("Plain");
+ f.menu().handleInput("\x1b");
+ await done;
+});
+
it("does not publish the removed configuration tab action", () => {
expect(Object.keys(KEYBINDINGS)).not.toContain("app.configuration.previousTab");
});
diff --git a/packages/tui/.changes/macos-option-key-bindings.md b/packages/tui/.changes/macos-option-key-bindings.md
new file mode 100644
index 0000000000..b5d396032e
--- /dev/null
+++ b/packages/tui/.changes/macos-option-key-bindings.md
@@ -0,0 +1 @@
+- Fixed keybinding matching so a picker can opt in to accept the character macOS types for Option+letter (for example `ß` for Option+S) when the terminal does not send Option as Meta.
diff --git a/packages/tui/src/keybindings.ts b/packages/tui/src/keybindings.ts
index f35de327e9..c2facb34b8 100644
--- a/packages/tui/src/keybindings.ts
+++ b/packages/tui/src/keybindings.ts
@@ -1,4 +1,4 @@
-import { type KeyId, matchesKey } from "./keys.js";
+import { type KeyId, matchesKey, matchesOptionComposedKey } from "./keys.js";
/**
* Global keybinding registry.
@@ -243,10 +243,11 @@ export class KeybindingsManager {
}
}
- matches(data: string, keybinding: Keybinding): boolean {
+ matches(data: string, keybinding: Keybinding, options: { optionComposed?: boolean } = {}): boolean {
const keys = this.keysById.get(keybinding) ?? [];
for (const key of keys) {
if (matchesKey(data, key)) return true;
+ if (options.optionComposed && matchesOptionComposedKey(data, key)) return true;
}
return false;
}
diff --git a/packages/tui/src/keys.ts b/packages/tui/src/keys.ts
index 73b165d167..dc7a9bc761 100644
--- a/packages/tui/src/keys.ts
+++ b/packages/tui/src/keys.ts
@@ -1189,6 +1189,15 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
return false;
}
+// macOS Option+<letter> without option-as-meta types a composed character instead of ESC+<letter>.
+const MACOS_OPTION_COMPOSED: Record<string, string> = { s: "ß" };
+
+export function matchesOptionComposedKey(data: string, keyId: KeyId): boolean {
+ const parsed = parseKeyId(keyId);
+ if (!parsed?.alt || parsed.ctrl || parsed.shift || parsed.super) return false;
+ return MACOS_OPTION_COMPOSED[parsed.key] === data;
+}
+
/**
* Parse input data and return the key identifier if recognized.
*
diff --git a/packages/tui/test/keys.test.ts b/packages/tui/test/keys.test.ts
index 9382d906f0..f8b20a53a4 100644
--- a/packages/tui/test/keys.test.ts
+++ b/packages/tui/test/keys.test.ts
@@ -8,6 +8,7 @@ import {
Key,
type KeyId,
matchesKey,
+ matchesOptionComposedKey,
parseKey,
setKittyProtocolActive,
} from "../src/keys.js";
@@ -402,6 +403,8 @@ describe("matchesKey", () => {
assert.strictEqual(parseKey("\x1by"), "alt+y");
assert.strictEqual(matchesKey("\x1bz", "alt+z"), true);
assert.strictEqual(parseKey("\x1bz"), "alt+z");
+ assert.strictEqual(matchesOptionComposedKey("ß", "alt+s"), true);
+ assert.strictEqual(matchesKey("ß", "alt+s"), false);
setKittyProtocolActive(true);
assert.strictEqual(matchesKey("\x1b ", "alt+space"), false);