feat(coding-agent): configurable double-escape action (tree vs branch)

Add doubleEscapeAction setting to choose whether double-escape with an
empty editor opens /tree (default) or /branch.

- Add setting to Settings interface and SettingsManager
- Add to /settings UI for easy toggling
- Update interactive-mode to respect the setting
- Document in README.md settings table

fixes #404
This commit is contained in:
Mario Zechner 2026-01-03 01:59:08 +01:00
parent 17b3a14bfa
commit 42b1e06ad1
6 changed files with 34 additions and 6 deletions

View file

@ -33,6 +33,7 @@ export interface SettingsConfig {
availableThemes: string[];
hideThinkingBlock: boolean;
collapseChangelog: boolean;
doubleEscapeAction: "branch" | "tree";
}
export interface SettingsCallbacks {
@ -46,6 +47,7 @@ export interface SettingsCallbacks {
onThemePreview?: (theme: string) => void;
onHideThinkingBlockChange: (hidden: boolean) => void;
onCollapseChangelogChange: (collapsed: boolean) => void;
onDoubleEscapeActionChange: (action: "branch" | "tree") => void;
onCancel: () => void;
}
@ -160,6 +162,13 @@ export class SettingsSelectorComponent extends Container {
currentValue: config.collapseChangelog ? "true" : "false",
values: ["true", "false"],
},
{
id: "double-escape-action",
label: "Double-escape action",
description: "Action when pressing Escape twice with empty editor",
currentValue: config.doubleEscapeAction,
values: ["tree", "branch"],
},
{
id: "thinking",
label: "Thinking level",
@ -264,6 +273,9 @@ export class SettingsSelectorComponent extends Container {
case "collapse-changelog":
callbacks.onCollapseChangelogChange(newValue === "true");
break;
case "double-escape-action":
callbacks.onDoubleEscapeActionChange(newValue as "branch" | "tree");
break;
}
},
callbacks.onCancel,

View file

@ -755,10 +755,14 @@ export class InteractiveMode {
this.isBashMode = false;
this.updateEditorBorderColor();
} else if (!this.editor.getText().trim()) {
// Double-escape with empty editor triggers /branch
// Double-escape with empty editor triggers /tree or /branch based on setting
const now = Date.now();
if (now - this.lastEscapeTime < 500) {
this.showUserMessageSelector();
if (this.settingsManager.getDoubleEscapeAction() === "tree") {
this.showTreeSelector();
} else {
this.showUserMessageSelector();
}
this.lastEscapeTime = 0;
} else {
this.lastEscapeTime = now;
@ -1682,6 +1686,7 @@ export class InteractiveMode {
availableThemes: getAvailableThemes(),
hideThinkingBlock: this.hideThinkingBlock,
collapseChangelog: this.settingsManager.getCollapseChangelog(),
doubleEscapeAction: this.settingsManager.getDoubleEscapeAction(),
},
{
onAutoCompactChange: (enabled) => {
@ -1739,6 +1744,9 @@ export class InteractiveMode {
onCollapseChangelogChange: (collapsed) => {
this.settingsManager.setCollapseChangelog(collapsed);
},
onDoubleEscapeActionChange: (action) => {
this.settingsManager.setDoubleEscapeAction(action);
},
onCancel: () => {
done();
this.ui.requestRender();