From 900420e5d2bea2931a9b943cf38220e5981045c3 Mon Sep 17 00:00:00 2001 From: RooberSmoth <96537304+RooberSmoth@users.noreply.github.com> Date: Mon, 10 Aug 2026 10:58:22 +0900 Subject: [PATCH 1/7] Changed AI enhance reasoning to stick to the chosen language unless stated so. --- agent_core/core/prompts/reasoning.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/agent_core/core/prompts/reasoning.py b/agent_core/core/prompts/reasoning.py index a4ee895ff..1173f9613 100644 --- a/agent_core/core/prompts/reasoning.py +++ b/agent_core/core/prompts/reasoning.py @@ -60,6 +60,11 @@ RULE 7 — ONE ACTION FRAME Do not chain unrelated actions into one prompt. If the user asked for one thing, keep it as one thing. Do not add "and also..." unless the user said so. + +RULE 8 - PRESERVE INITIAL LANGUAGE +If the user wrote their message in another language, only enhance in the detected +language. Never stray or use another language other than what the user has written in +unless the user said so. @@ -70,6 +75,7 @@ 4. simple or complex task? (single-shot vs. multi-step + verify) 5. Any scheduling signal? (one-time vs. recurring) 6. Any pronouns to replace with actual nouns? +7. What is the intended language? @@ -81,6 +87,7 @@ - Do NOT exceed 4 sentences - Do NOT use passive voice — use active imperative verbs - Do NOT leave platform names implicit when a platform is involved +- Do NOT start using another language other than the one written in by the user initially unless asked for by the user From 5e8626ac428de180570080d7ba015f1393051358 Mon Sep 17 00:00:00 2001 From: RooberSmoth <96537304+RooberSmoth@users.noreply.github.com> Date: Mon, 10 Aug 2026 12:29:13 +0900 Subject: [PATCH 2/7] If the input is empty, stop enhancing and reset to false state. --- .../frontend/src/components/Chat/Chat.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx b/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx index 99f584321..418c0a06c 100644 --- a/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx +++ b/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx @@ -780,11 +780,26 @@ export function Chat({ sessionId, placeholder }: ChatProps) { // Consume enhanced prompt from context when WS response arrives useEffect(() => { if (enhancedPrompt === null) return + if (input.trim() === ''){ + //Is the box cleared? Do not repopulate the deleted text box. + setEnhancing(false) + clearEnhancedPrompt() + return + } setInput(enhancedPrompt) setEnhancing(false) clearEnhancedPrompt() inputRef.current?.focus() - }, [enhancedPrompt, clearEnhancedPrompt, setInput]) + }, [enhancedPrompt, clearEnhancedPrompt, setInput, input]) + + // Deleting the draft cancels any in-flight/pending enhance and resets the + //enhance button's display state + useEffect(() => { + if (input.trim() !== '') return + if (enhancing) setEnhancing(false) + if (plusOpen) setPlusOpen (false) + },[input, enhancing, plusOpen] + ) // Reset enhancing spinner if the WebSocket disconnects mid-request useEffect(() => { From ddd9693ed4ec1101925eedc1a28896af15ab27f7 Mon Sep 17 00:00:00 2001 From: RooberSmoth <96537304+RooberSmoth@users.noreply.github.com> Date: Mon, 10 Aug 2026 12:30:34 +0900 Subject: [PATCH 3/7] Updated chat.tsx as i committed the wrong version. --- app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx b/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx index 418c0a06c..f8ea152df 100644 --- a/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx +++ b/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx @@ -796,9 +796,9 @@ export function Chat({ sessionId, placeholder }: ChatProps) { //enhance button's display state useEffect(() => { if (input.trim() !== '') return - if (enhancing) setEnhancing(false) - if (plusOpen) setPlusOpen (false) - },[input, enhancing, plusOpen] + setEnhancing(false) + setPlusOpen (false) + },[input] ) // Reset enhancing spinner if the WebSocket disconnects mid-request From 05849bf2bbd702c4860303e59650765b0f81fac4 Mon Sep 17 00:00:00 2001 From: RooberSmoth <96537304+RooberSmoth@users.noreply.github.com> Date: Mon, 10 Aug 2026 14:48:55 +0900 Subject: [PATCH 4/7] Added loading spinner to + button for visual communication. --- app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx b/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx index f8ea152df..2d1b14fc6 100644 --- a/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx +++ b/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx @@ -1412,7 +1412,9 @@ export function Chat({ sessionId, placeholder }: ChatProps) { aria-label="Attach and tools" aria-expanded={plusOpen} > - + {enhancing + ? + : } {plusOpen && (
From b756d1e413c3691d50c772f9f061db344ff83435 Mon Sep 17 00:00:00 2001 From: RooberSmoth <96537304+RooberSmoth@users.noreply.github.com> Date: Mon, 10 Aug 2026 15:13:53 +0900 Subject: [PATCH 5/7] Disabled send and dictate button, added 'no entry' thing when hovering on dictate. --- .../browser/frontend/src/components/Chat/Chat.module.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/ui_layer/browser/frontend/src/components/Chat/Chat.module.css b/app/ui_layer/browser/frontend/src/components/Chat/Chat.module.css index 5a5e1a094..c33028332 100644 --- a/app/ui_layer/browser/frontend/src/components/Chat/Chat.module.css +++ b/app/ui_layer/browser/frontend/src/components/Chat/Chat.module.css @@ -596,6 +596,11 @@ color: var(--color-error, #ef4444); } +.micCombo:disabled { + color: var(--text-muted); + cursor: not-allowed; +} + .micIconWrap { position: relative; display: flex; From aef2fd72c0a906b97806eaaf21a28d3d923d439f Mon Sep 17 00:00:00 2001 From: RooberSmoth <96537304+RooberSmoth@users.noreply.github.com> Date: Mon, 10 Aug 2026 16:24:18 +0900 Subject: [PATCH 6/7] Added 30s timeout - needs testing? --- .../frontend/src/components/Chat/Chat.tsx | 47 +++++++++++++++---- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx b/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx index 2d1b14fc6..aefcbcd9b 100644 --- a/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx +++ b/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx @@ -84,6 +84,7 @@ interface SuggestedPlaybook { } const SUGGESTED_PLAYBOOK_COUNT = 3 +const ENHANCE_TIMEOUT_MS = 30000 // Chat-delivery actions — the ones whose visible form IS a chat bubble in // this interface. A chunk whose only actions are these renders nothing at @@ -321,6 +322,22 @@ export function Chat({ sessionId, placeholder }: ChatProps) { }, [dispatch, sessionId]) const [enhancing, setEnhancing] = useState(false) + // Guards against the user waiting forever if the enhance WS response + // never comes back. Cleared (never fires) on success, disconnect, or the + // draft being emptied — see the effects/handler below. + const enhanceTimeoutRef = useRef | null>(null) + + // Single choke point for turning enhancing off: always cancels the + // timeout alongside it, so success/disconnect/clear-draft paths can't + // leave a stale timer that fires 30s later on an already-finished request. + const stopEnhancing = useCallback(() => { + if (enhanceTimeoutRef.current !== null) { + clearTimeout(enhanceTimeoutRef.current) + enhanceTimeoutRef.current = null + } + setEnhancing(false) + }, []) + // Reply-to-bubble: set from an agent bubble's hover Reply action. The // next send carries the quoted original so the event stream records // which message the user replied to. No routing — session is explicit. @@ -782,35 +799,46 @@ export function Chat({ sessionId, placeholder }: ChatProps) { if (enhancedPrompt === null) return if (input.trim() === ''){ //Is the box cleared? Do not repopulate the deleted text box. - setEnhancing(false) + stopEnhancing() clearEnhancedPrompt() return } setInput(enhancedPrompt) - setEnhancing(false) + stopEnhancing() clearEnhancedPrompt() inputRef.current?.focus() - }, [enhancedPrompt, clearEnhancedPrompt, setInput, input]) + }, [enhancedPrompt, clearEnhancedPrompt, setInput, input, stopEnhancing]) // Deleting the draft cancels any in-flight/pending enhance and resets the //enhance button's display state useEffect(() => { if (input.trim() !== '') return - setEnhancing(false) + stopEnhancing() setPlusOpen (false) - },[input] + },[input, stopEnhancing] ) // Reset enhancing spinner if the WebSocket disconnects mid-request useEffect(() => { - if (!connected) setEnhancing(false) - }, [connected]) + if (!connected) stopEnhancing() + }, [connected, stopEnhancing]) const handleEnhancePrompt = useCallback(() => { if (!input.trim() || enhancing) return setEnhancing(true) enhancePrompt(input.trim()) - }, [input, enhancing, enhancePrompt]) + enhanceTimeoutRef.current = setTimeout(() => { + enhanceTimeoutRef.current = null + setEnhancing(false) + showToast('error', 'AI enhance timed out — please try again.') + }, ENHANCE_TIMEOUT_MS) + }, [input, enhancing, enhancePrompt, showToast]) + + useEffect(() => { + return () => { + if (enhanceTimeoutRef.current !== null) clearTimeout(enhanceTimeoutRef.current) + } +}, []) const handleOptionClick = useCallback((value: string, messageId: string) => { if (value === 'open_settings_model') { @@ -1446,6 +1474,7 @@ export function Chat({ sessionId, placeholder }: ChatProps) { className={`${styles.micCombo}${isListening ? ` ${styles.micComboActive}` : ''}`} title={isListening ? 'Stop listening' : 'Voice input'} onClick={toggleListening} + disabled = {enhancing} > {isListening ? : } @@ -1493,7 +1522,7 @@ export function Chat({ sessionId, placeholder }: ChatProps) { type="button" className={styles.sendBtn} onClick={handleSend} - disabled={(!input.trim() && pendingAttachments.length === 0) || !attachmentValidation.valid} + disabled={(!input.trim() && pendingAttachments.length === 0) || !attachmentValidation.valid || enhancing} title="Send" aria-label="Send message" > From f292f47fcba681cc2805809f13c4da33d5b06e80 Mon Sep 17 00:00:00 2001 From: CraftBot Date: Mon, 10 Aug 2026 19:51:47 +0900 Subject: [PATCH 7/7] make chat input disabled --- .../browser/frontend/src/components/Chat/Chat.module.css | 6 ++++++ app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/ui_layer/browser/frontend/src/components/Chat/Chat.module.css b/app/ui_layer/browser/frontend/src/components/Chat/Chat.module.css index c33028332..30dbf2d0d 100644 --- a/app/ui_layer/browser/frontend/src/components/Chat/Chat.module.css +++ b/app/ui_layer/browser/frontend/src/components/Chat/Chat.module.css @@ -429,6 +429,12 @@ outline: none; } +.input:disabled { + color: var(--text-muted); + cursor: not-allowed; + opacity: 0.6; +} + .input::placeholder { color: var(--text-muted); } diff --git a/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx b/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx index aefcbcd9b..1eee03078 100644 --- a/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx +++ b/app/ui_layer/browser/frontend/src/components/Chat/Chat.tsx @@ -806,7 +806,10 @@ export function Chat({ sessionId, placeholder }: ChatProps) { setInput(enhancedPrompt) stopEnhancing() clearEnhancedPrompt() - inputRef.current?.focus() + // Defer focus: the textarea is still disabled in the DOM this tick + // (enhancing→false hasn't re-rendered yet), so a synchronous focus() + // would be ignored. + setTimeout(() => inputRef.current?.focus(), 0) }, [enhancedPrompt, clearEnhancedPrompt, setInput, input, stopEnhancing]) // Deleting the draft cancels any in-flight/pending enhance and resets the @@ -1428,6 +1431,7 @@ export function Chat({ sessionId, placeholder }: ChatProps) { rows={1} lang={micLang} inputMode="text" + disabled={enhancing} />