From 3eec9f311c457b0808a3f3042b711980da7de293 Mon Sep 17 00:00:00 2001 From: Sergey <93754860+slaid098@users.noreply.github.com> Date: Thu, 9 Jul 2026 06:37:23 +0300 Subject: [PATCH] fix: spinner clockwise, lock target on start, context-aware shortcut (#18) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Что сделано ### Спиннер крутится по часовой стрелке - Зеркально отражён SVG-arrow (стрелка указывает вправо) - Вращение изменено с counterclockwise (-360deg) на clockwise (360deg) ### Fix: «Could not find input field» в question prompt - **Корень проблемы**: `currentTarget` перезаписывался при каждом вызове `toggleDictation`, включая остановку. Если запись начата с микрофона question prompt (target="question"), а остановлена через Ctrl+Space (target всегда "composer"), target перезаписывался → текст вставлялся не туда. - **Фикс**: `currentTarget` устанавливается только при старте записи (state="idle") - Ctrl+Space теперь контекстно-зависимый: если открыт question prompt — target="question", иначе "composer" - Auto-submit для question prompt уже был отключён — без изменений Co-authored-by: opencode-agent --- src/index.ts | 12 +++++++++--- src/insert.ts | 4 ++++ src/ui.ts | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 548d5f8..9e799c7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,13 @@ import { setConfig, validateApiKey, } from "./config.js"; -import { type InsertTarget, insertText, isOpencodePage, submitPrompt } from "./insert.js"; +import { + type InsertTarget, + insertText, + isOpencodePage, + isQuestionPromptOpen, + submitPrompt, +} from "./insert.js"; import { setupKeyboardShortcut } from "./keyboard.js"; import { transcribe } from "./transcribe.js"; import type { DictationState } from "./types.js"; @@ -35,8 +41,8 @@ function stopTimer(): void { } async function toggleDictation(target: InsertTarget): Promise { - currentTarget = target; if (currentState === "idle") { + currentTarget = target; await startRecording(); } else if (currentState === "recording") { await stopAndTranscribe(); @@ -182,7 +188,7 @@ function init(): void { }); setupKeyboardShortcut(() => { - void toggleDictation("composer"); + void toggleDictation(isQuestionPromptOpen() ? "question" : "composer"); }); registerMenuCommands({ diff --git a/src/insert.ts b/src/insert.ts index e96bb29..03b9b6a 100644 --- a/src/insert.ts +++ b/src/insert.ts @@ -8,6 +8,10 @@ export function isOpencodePage(): boolean { return document.querySelector(PROMPT_INPUT_SELECTOR) !== null; } +export function isQuestionPromptOpen(): boolean { + return document.querySelector(QUESTION_INPUT_SELECTOR) !== null; +} + export function insertText(text: string, target: InsertTarget = "composer"): boolean { if (target === "question") { return insertIntoTextarea(text); diff --git a/src/ui.ts b/src/ui.ts index 39c4b4f..2652c73 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -14,7 +14,7 @@ const QUESTION_INPUT_SELECTOR = '[data-slot="question-custom-input"]'; const ICON_MIC = ``; const ICON_STOP = ``; const ICON_CANCEL = ``; -const ICON_SPINNER = ``; +const ICON_SPINNER = ``; function createButtonStyle(): string { return ` @@ -119,7 +119,7 @@ function createButtonStyle(): string { } @keyframes ocvd-spin { from { transform: rotate(0deg); } - to { transform: rotate(-360deg); } + to { transform: rotate(360deg); } } .ocvd-spin { animation: ocvd-spin 0.8s linear infinite;