From fac078dea1c770c2ecc1ab4190cab8cc82872a46 Mon Sep 17 00:00:00 2001 From: Emir Karabeg Date: Wed, 15 Jan 2025 14:28:58 -0800 Subject: [PATCH] Fixed code editing bug and shortened agent input --- .../sub-block/components/code.tsx | 17 +++++++++++++++++ blocks/configs/agent.ts | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/w/components/workflow-block/sub-block/components/code.tsx b/app/w/components/workflow-block/sub-block/components/code.tsx index f490e5655b..8dfada74c1 100644 --- a/app/w/components/workflow-block/sub-block/components/code.tsx +++ b/app/w/components/workflow-block/sub-block/components/code.tsx @@ -124,6 +124,23 @@ export function Code() { const handleAutoClose = useCallback( (e: React.KeyboardEvent) => { + // If we're typing a closing character (not an opening one) + if (Object.values(MATCHING_PAIRS).includes(e.key)) { + const textarea = e.currentTarget + const start = textarea.selectionStart + const currentContent = lines[currentLine].content + + // If cursor is before the same closing character, just move cursor + if (currentContent[start] === e.key) { + e.preventDefault() + setTimeout(() => { + textarea.selectionStart = textarea.selectionEnd = start + 1 + }, 0) + return true + } + } + + // Handle opening characters const closingChar = MATCHING_PAIRS[e.key] if (!closingChar) return false diff --git a/blocks/configs/agent.ts b/blocks/configs/agent.ts index f14ebe8a65..2f95fd568e 100644 --- a/blocks/configs/agent.ts +++ b/blocks/configs/agent.ts @@ -27,7 +27,7 @@ export const AgentBlock: BlockConfig = { }, { title: 'Context', - type: 'long-input', + type: 'short-input', layout: 'full', }, {