From 8d491919b2cdac2fe69fd9ec9b62bc3593641d45 Mon Sep 17 00:00:00 2001 From: BeniBenj Date: Wed, 4 Mar 2026 23:26:04 +0100 Subject: [PATCH] don't steal focus for readonly editors --- .../agentFeedbackEditorInputContribution.ts | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/vs/sessions/contrib/agentFeedback/browser/agentFeedbackEditorInputContribution.ts b/src/vs/sessions/contrib/agentFeedback/browser/agentFeedbackEditorInputContribution.ts index 707a1090912..dc2434cfb45 100644 --- a/src/vs/sessions/contrib/agentFeedback/browser/agentFeedbackEditorInputContribution.ts +++ b/src/vs/sessions/contrib/agentFeedback/browser/agentFeedbackEditorInputContribution.ts @@ -342,15 +342,29 @@ export class AgentFeedbackEditorInputContribution extends Disposable implements return; } + // Don't capture Escape at this level - let it fall through to the input handler if focused + if (e.keyCode === KeyCode.Escape) { + this._hide(); + this._editor.focus(); + return; + } + + // Ctrl+I / Cmd+I explicitly focuses the feedback input + if ((e.ctrlKey || e.metaKey) && e.keyCode === KeyCode.KeyI) { + e.preventDefault(); + e.stopPropagation(); + widget.inputElement.focus(); + return; + } + // Don't focus if any modifier is held (keyboard shortcuts) if (e.ctrlKey || e.altKey || e.metaKey) { return; } - // Don't capture Escape at this level - let it fall through to the input handler if focused - if (e.keyCode === KeyCode.Escape) { - this._hide(); - this._editor.focus(); + // Only auto-focus the input on typing when the document is readonly; + // when editable the user must click or use Ctrl+I to focus. + if (!this._editor.getOption(EditorOption.readOnly)) { return; } @@ -413,6 +427,12 @@ export class AgentFeedbackEditorInputContribution extends Disposable implements })); } + focusInput(): void { + if (this._visible && this._widget) { + this._widget.inputElement.focus(); + } + } + private _addFeedback(): boolean { if (!this._widget) { return false;