Merge PR #2950: feat(coding-agent): add copy affordance to completed /btw answers (@wolfiesch)

Adds 'c copy' to the completed /btw panel footer (alongside b branch / Esc
dismiss), copying the sanitized visible answer to the clipboard. The copy
shortcut is guarded by canCopyBtw + main-editor focus + empty editor.
This commit is contained in:
can1357
2026-06-20 23:56:24 +02:00
8 changed files with 240 additions and 13 deletions
@@ -99,6 +99,7 @@ export class InputController {
#enhancedPaste?: EnhancedPasteController;
#focusedLeftTapListenerInstalled = false;
#btwBranchListenerInstalled = false;
#btwCopyListenerInstalled = false;
// Tap counter for the double-← gesture; reset whenever a quiet gap
// (>= LEFT_DOUBLE_TAP_MAX_GAP_MS) starts a fresh sequence. See
// #detectLeftDoubleTap.
@@ -174,6 +175,17 @@ export class InputController {
return { consume: true };
});
}
if (!this.#btwCopyListenerInstalled) {
this.#btwCopyListenerInstalled = true;
this.ctx.ui.addInputListener(data => {
if (!matchesKey(data, "c")) return undefined;
if (!this.ctx.canCopyBtw()) return undefined;
if (this.ctx.ui.getFocused() !== this.ctx.editor) return undefined;
if (this.ctx.editor.getText().trim()) return undefined;
void this.ctx.handleBtwCopyKey();
return { consume: true };
});
}
this.ctx.editor.onEscape = () => {
// Active context maintenance owns Esc: auto/manual compaction,
// handoff generation, and auto-retry backoff all advertise