Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Coach: the message box grows with the text, and opens into a tall editor

Duarte Santos45e6204573d3
diff --git a/frontend/src/coach.css b/frontend/src/coach.css
index a8dc90370..a2c2fdc39 100644
--- a/frontend/src/coach.css
+++ b/frontend/src/coach.css
@@ -75,7 +75,7 @@
.ob-hint{text-align:center;font-size:13px;color:var(--label-3);margin-top:8px}
/* ---------- chat ---------- */
-.chat{padding-bottom:40px}
+.chat{padding-bottom:calc(40px + var(--composer-extra,0px))}
.chat-hdr{
display:flex;align-items:center;gap:10px;
/* Pinned like a messenger's title bar: it eats the app shell's top padding so the blur
@@ -173,13 +173,25 @@
background:color-mix(in srgb,var(--bg) 88%,transparent);
-webkit-backdrop-filter:saturate(180%) blur(12px);backdrop-filter:saturate(180%) blur(12px)
}
-.composer-in{max-width:560px;margin:0 auto;display:flex;gap:8px;align-items:flex-end}
+/* The Android app reports the keyboard instead of shrinking the page (lib/native-keyboard.js):
+ the composer rides on top of it. */
+:root[data-native-kb] .composer{bottom:var(--native-kb);padding-bottom:10px}
+.composer-in{max-width:560px;margin:0 auto;display:flex;gap:8px;align-items:flex-end;position:relative}
+/* The height is set by components/ChatInput.jsx: as tall as the text, up to 40% of the screen
+ above the keyboard, or 70% opened into the tall editor. */
.composer textarea{
- flex:1;min-height:44px;max-height:120px;resize:none;border-radius:22px;padding:11px 16px;
+ flex:1;min-height:44px;resize:none;border-radius:22px;padding:11px 16px;overflow-y:auto;
font-size:16px;line-height:1.35;background:var(--surface);color:var(--label);border:none;outline:none;
font-family:inherit;letter-spacing:-.008em
}
.composer textarea:focus{box-shadow:inset 0 0 0 1.5px var(--acc)}
+.composer-in.tall textarea{border-radius:18px}
+/* The toggle between the growing box and the tall editor, on the box's top corner. */
+.composer-grow{
+ position:absolute;top:-30px;left:4px;width:28px;height:28px;border-radius:99px;
+ display:flex;align-items:center;justify-content:center;font-size:15px;
+ background:var(--surface);color:var(--label-2);box-shadow:0 1px 3px rgba(0,0,0,.18)
+}
.composer textarea::placeholder{color:var(--label-3)}
.send{
width:44px;height:44px;border-radius:99px;background:var(--acc);color:var(--on-acc);flex:none;
diff --git a/frontend/src/components/ChatInput.jsx b/frontend/src/components/ChatInput.jsx
new file mode 100644
index 000000000..1dd421353
--- /dev/null
+++ b/frontend/src/components/ChatInput.jsx
@@ -0,0 +1,62 @@
+// The Coach's message box (views/CoachChat.jsx): it grows with what is typed, up to about 40% of
+// what the keyboard leaves of the screen, and scrolls inside after that. A toggle opens it into a
+// tall editor for a long message and back. The height is worked out from the space above the
+// keyboard (lib/native-keyboard.js visibleBottom: the visual viewport on iOS, the layout viewport
+// less the keyboard the Android app reports), so it never grows under the keyboard.
+import { useEffect, useLayoutEffect, useRef, useState } from 'react'
+import { t } from '../lib/i18n.js'
+import { visibleBottom, NATIVE_KEYBOARD_EVENT } from '../lib/native-keyboard.js'
+import Icon from './Icon.jsx'
+
+export const MIN_HEIGHT = 44
+export const GROW_SHARE = 0.4
+export const TALL_SHARE = 0.7
+// The toggle shows once the text no longer fits in about three lines, or while expanded.
+export const TOGGLE_FROM = 3 * 21 + 22
+
+/**
+ * The box's height in px: what the text needs, between one line and 40% of the free screen; or
+ * 70% of it when expanded. `visible` is the height left above the keyboard.
+ */
+export function composerHeight({ scrollHeight = 0, visible = 0, expanded = false }) {
+ const room = Math.max(MIN_HEIGHT, Math.round(visible || 0))
+ if (expanded) return Math.max(MIN_HEIGHT, Math.round(room * TALL_SHARE))
+ return Math.max(MIN_HEIGHT, Math.min(Math.ceil(scrollHeight || 0), Math.round(room * GROW_SHARE)))
+}
+
+export default function ChatInput({ value, onChange, onSend, placeholder, disabled, maxLength, expanded, setExpanded }) {
+ const ref = useRef(null)
+ const [tall, setTall] = useState(false) // whether the text needs more than a few lines
+ // The keyboard coming up or going down changes the room: measured again then.
+ const [room, setRoom] = useState(0)
+ useEffect(() => {
+ const again = () => setRoom(r => r + 1)
+ const vv = window.visualViewport
+ vv?.addEventListener?.('resize', again)
+ window.addEventListener(NATIVE_KEYBOARD_EVENT, again)
+ return () => { vv?.removeEventListener?.('resize', again); window.removeEventListener(NATIVE_KEYBOARD_EVENT, again) }
+ }, [])
+ useLayoutEffect(() => {
+ const el = ref.current
+ if (!el) return
+ // Measured from its natural height: shrink first, so deleting text shrinks the box too.
+ el.style.height = 'auto'
+ const need = el.scrollHeight
+ const h = composerHeight({ scrollHeight: need, visible: visibleBottom(), expanded })
+ el.style.height = h + 'px'
+ // The chat leaves room for what the box grew by, so the last message is never under it.
+ el.closest('.chat')?.style.setProperty('--composer-extra', Math.max(0, h - MIN_HEIGHT) + 'px')
+ setTall(need > TOGGLE_FROM)
+ }, [value, expanded, room])
+ return <>
+ {(tall || expanded) && <button type="button" className="composer-grow" onClick={() => setExpanded(!expanded)}
+ aria-label={expanded ? t('Make the box smaller') : t('Make the box bigger')} aria-pressed={expanded}>
+ <Icon name={expanded ? 'minimize' : 'expand'} />
+ </button>}
+ <textarea ref={ref} rows={1} value={value} maxLength={maxLength} placeholder={placeholder} disabled={disabled}
+ onChange={e => onChange(e.target.value)}
+ // Enter sends; Shift+Enter makes a new line. In the tall editor Enter is a new line too:
+ // that is what it is opened for.
+ onKeyDown={e => { if (e.key === 'Enter' && !e.shiftKey && !expanded) { e.preventDefault(); onSend() } }} />
+ </>
+}
diff --git a/frontend/src/components/ChatInput.test.jsx b/frontend/src/components/ChatInput.test.jsx
new file mode 100644
index 000000000..eec4c505c
--- /dev/null
+++ b/frontend/src/components/ChatInput.test.jsx
@@ -0,0 +1,75 @@
+// @vitest-environment happy-dom
+import React, { act, useState } from 'react'
+import { createRoot } from 'react-dom/client'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import ChatInput, { composerHeight, MIN_HEIGHT } from './ChatInput.jsx'
+
+globalThis.IS_REACT_ACT_ENVIRONMENT = true
+
+/* The Coach's message box grows with the text up to 40% of the room above the keyboard, and opens
+ into a tall editor and back. happy-dom lays nothing out, so scrollHeight is stubbed. */
+describe('composerHeight', () => {
+ it('as tall as the text, from one line up to 40% of the room', () => {
+ expect(composerHeight({ scrollHeight: 20, visible: 800 })).toBe(MIN_HEIGHT)
+ expect(composerHeight({ scrollHeight: 150, visible: 800 })).toBe(150)
+ expect(composerHeight({ scrollHeight: 900, visible: 800 })).toBe(320)
+ })
+ it('follows the room the keyboard leaves', () => {
+ expect(composerHeight({ scrollHeight: 900, visible: 400 })).toBe(160)
+ })
+ it('the tall editor takes 70% of the room, however short the text', () => {
+ expect(composerHeight({ scrollHeight: 10, visible: 800, expanded: true })).toBe(560)
+ })
+ it('never below one line, whatever it is told', () => {
+ expect(composerHeight({})).toBe(MIN_HEIGHT)
+ expect(composerHeight({ scrollHeight: 300, visible: 50 })).toBe(MIN_HEIGHT)
+ })
+})
+
+describe('ChatInput', () => {
+ let host, root, scroll
+ beforeEach(() => {
+ scroll = 30
+ vi.spyOn(HTMLTextAreaElement.prototype, 'scrollHeight', 'get').mockImplementation(() => scroll)
+ Object.defineProperty(window, 'innerHeight', { configurable: true, value: 800 })
+ host = document.createElement('div'); host.className = 'chat'
+ document.body.appendChild(host)
+ root = createRoot(host)
+ })
+ afterEach(() => { act(() => root.unmount()); host.remove(); vi.restoreAllMocks() })
+
+ function Harness({ onSend }) {
+ const [v, setV] = useState('')
+ const [x, setX] = useState(false)
+ return <ChatInput value={v} onChange={setV} onSend={onSend} expanded={x} setExpanded={setX} />
+ }
+ const type = (el, value) => act(() => {
+ Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value').set.call(el, value)
+ el.dispatchEvent(new Event('input', { bubbles: true }))
+ })
+ const key = (el, k, shift = false) => act(() => { el.dispatchEvent(new KeyboardEvent('keydown', { key: k, shiftKey: shift, bubbles: true, cancelable: true })) })
+
+ it('grows with a long message, offers the tall editor, and Enter sends only from the small box', () => {
+ const onSend = vi.fn()
+ act(() => root.render(<Harness onSend={onSend} />))
+ const ta = host.querySelector('textarea')
+ expect(ta.style.height).toBe('44px')
+ expect(host.querySelector('.composer-grow')).toBeNull()
+ scroll = 200
+ type(ta, 'a long message\n'.repeat(8))
+ expect(ta.style.height).toBe('200px')
+ expect(host.style.getPropertyValue('--composer-extra')).toBe('156px')
+ const grow = host.querySelector('.composer-grow')
+ expect(grow.getAttribute('aria-label')).toBe('Make the box bigger')
+ act(() => grow.click())
+ expect(ta.style.height).toBe('560px')
+ key(ta, 'Enter')
+ expect(onSend).not.toHaveBeenCalled()
+ act(() => host.querySelector('.composer-grow').click())
+ expect(ta.style.height).toBe('200px')
+ key(ta, 'Enter', true)
+ expect(onSend).not.toHaveBeenCalled()
+ key(ta, 'Enter')
+ expect(onSend).toHaveBeenCalledTimes(1)
+ })
+})
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index 5d5994fb3..8af967646 100644
--- a/frontend/src/lib/pt-br-locale.test.js
+++ b/frontend/src/lib/pt-br-locale.test.js
@@ -41,7 +41,7 @@ describe('Brazilian Portuguese locale', () => {
// has to be taught is a number nobody reads. What the numbers stood for is asserted above.
// If the hash fails, review the changed keys and wording before accepting a new one. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('216032f046ce2c36098a4a434d117bb1c33737f96c5a4eb7e377de0cfdcabb1d')
+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('c4fc6feddca3a51396ace0845e66bac3c623c922b477e0adb823a90436c77e03')
})
// pt-PT labelled Unpair 'Desfazer': Undo, in Portuguese (it is pt-BR's Undo), on the button that
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.js
index 7cbcf80ae..726e6bb36 100644
--- a/frontend/src/locales/ar.js
+++ b/frontend/src/locales/ar.js
@@ -2348,4 +2348,7 @@ export default {
'Training reminders, only if you switch them on': 'تذكيرات التمرين، فقط إذا فعّلتها',
'You can change it anytime in your phone’s settings.': 'يمكنك تغيير ذلك في أي وقت من إعدادات هاتفك.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'يمكن لـ openGym أن ينقر على كتفك عند انتهاء الراحة، حتى والهاتف مقفل في جيبك.',
+ // --- Coach message box ---
+ 'Make the box bigger': 'تكبير مربع الكتابة',
+ 'Make the box smaller': 'تصغير مربع الكتابة',
}
diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.js
index 12435b6f3..c5c506639 100644
--- a/frontend/src/locales/bn.js
+++ b/frontend/src/locales/bn.js
@@ -2372,4 +2372,7 @@ export default {
'Training reminders, only if you switch them on': 'ট্রেনিংয়ের রিমাইন্ডার, শুধু আপনি চালু করলে',
'You can change it anytime in your phone’s settings.': 'ফোনের সেটিংসে যেকোনো সময় এটি বদলাতে পারেন।',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'ফোন লক করে পকেটে রাখলেও, বিশ্রাম শেষ হলে openGym আপনার কাঁধে টোকা দিতে পারে।',
+ // --- Coach message box ---
+ 'Make the box bigger': 'লেখার বাক্স বড় করুন',
+ 'Make the box smaller': 'লেখার বাক্স ছোট করুন',
}
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index ca7d511a4..b2b91befd 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -2313,4 +2313,7 @@ export default {
'Training reminders, only if you switch them on': 'Trainingserinnerungen, nur wenn du sie einschaltest',
'You can change it anytime in your phone’s settings.': 'Du kannst das jederzeit in den Einstellungen deines Handys ändern.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'openGym tippt dir auf die Schulter, wenn eine Pause vorbei ist, auch wenn das Handy gesperrt in der Tasche steckt.',
+ // --- Coach message box ---
+ 'Make the box bigger': 'Feld vergrößern',
+ 'Make the box smaller': 'Feld verkleinern',
}
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index 8a83983ce..a99ce1cfd 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -2293,4 +2293,7 @@ export default {
'Training reminders, only if you switch them on': 'Recordatorios de entreno, solo si los activas',
'You can change it anytime in your phone’s settings.': 'Puedes cambiarlo cuando quieras en los ajustes del móvil.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'openGym puede darte un toque en el hombro cuando acaba un descanso, aunque el móvil esté bloqueado en tu bolsillo.',
+ // --- Coach message box ---
+ 'Make the box bigger': 'Agrandar el cuadro',
+ 'Make the box smaller': 'Achicar el cuadro',
}
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 5f1ff3aec..9a13b26e1 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -2293,4 +2293,7 @@ export default {
'Training reminders, only if you switch them on': 'Des rappels d’entraînement, seulement si tu les actives',
'You can change it anytime in your phone’s settings.': 'Tu peux changer ça à tout moment dans les réglages de ton téléphone.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'openGym peut te taper sur l’épaule quand un repos est fini, même avec le téléphone verrouillé dans ta poche.',
+ // --- Coach message box ---
+ 'Make the box bigger': 'Agrandir la zone',
+ 'Make the box smaller': 'Réduire la zone',
}
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 3c5fc9699..2432a3272 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -2293,4 +2293,7 @@ export default {
'Training reminders, only if you switch them on': 'ट्रेनिंग रिमाइंडर, सिर्फ़ अगर आप चालू करें',
'You can change it anytime in your phone’s settings.': 'आप इसे कभी भी अपने फ़ोन की सेटिंग्स में बदल सकते हैं।',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'फ़ोन लॉक होकर जेब में हो तब भी, रेस्ट खत्म होने पर openGym आपके कंधे पर थपकी दे सकता है।',
+ // --- Coach message box ---
+ 'Make the box bigger': 'बॉक्स बड़ा करें',
+ 'Make the box smaller': 'बॉक्स छोटा करें',
}
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index 5592c3f68..afa8c354c 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -2296,4 +2296,7 @@ export default {
'Training reminders, only if you switch them on': 'Edzésemlékeztetők, csak ha bekapcsolod',
'You can change it anytime in your phone’s settings.': 'Ezt bármikor megváltoztathatod a telefonod beállításaiban.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'Az openGym megkoppintja a vállad, amikor letelt a pihenő, akkor is, ha a lezárt telefon a zsebedben van.',
+ // --- Coach message box ---
+ 'Make the box bigger': 'Nagyobb mező',
+ 'Make the box smaller': 'Kisebb mező',
}
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 1fa77b68f..15a51bae3 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -2293,4 +2293,7 @@ export default {
'Training reminders, only if you switch them on': 'Promemoria di allenamento, solo se li attivi',
'You can change it anytime in your phone’s settings.': 'Puoi cambiarlo quando vuoi nelle impostazioni del telefono.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'openGym può darti un colpetto sulla spalla quando un recupero è finito, anche con il telefono bloccato in tasca.',
+ // --- Coach message box ---
+ 'Make the box bigger': 'Ingrandisci il riquadro',
+ 'Make the box smaller': 'Rimpicciolisci il riquadro',
}
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index 8d107cb57..23f8d08d5 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -2293,4 +2293,7 @@ export default {
'Training reminders, only if you switch them on': '운동 알림은 켰을 때만',
'You can change it anytime in your phone’s settings.': '언제든 휴대폰 설정에서 바꿀 수 있어요.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': '휴대폰이 잠긴 채 주머니에 있어도 휴식이 끝나면 openGym이 어깨를 톡 쳐 드려요.',
+ // --- Coach message box ---
+ 'Make the box bigger': '입력창 크게',
+ 'Make the box smaller': '입력창 작게',
}
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index fd2f4c48e..8f9a300ee 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -2293,4 +2293,7 @@ export default {
'Training reminders, only if you switch them on': 'Przypomnienia o treningu, tylko jeśli je włączysz',
'You can change it anytime in your phone’s settings.': 'Możesz to zmienić w każdej chwili w ustawieniach telefonu.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'openGym może klepnąć cię w ramię, gdy przerwa się skończy, nawet gdy zablokowany telefon leży w kieszeni.',
+ // --- Coach message box ---
+ 'Make the box bigger': 'Powiększ pole',
+ 'Make the box smaller': 'Zmniejsz pole',
}
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 287839d07..bb0df4ddd 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -1454,6 +1454,7 @@ export const PT_BR_OVERRIDES = {
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'O openGym pode te dar um toque no ombro quando um descanso acaba, mesmo com o celular bloqueado no bolso.',
// --- background check before the nudge ---
'Logged a workout on another device? Before the nudge goes out, the phone checks with your server whenever it lets the app run in the background. Opening the app always catches up.': 'Registrou um treino em outro dispositivo? Antes do aviso, o celular confirma com o seu servidor, sempre que deixar o aplicativo rodar em segundo plano. Abrir o aplicativo sempre deixa tudo em dia.',
+ // --- Coach message box ---
}
export default { ...pt, ...PT_BR_OVERRIDES }
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index e4125edef..4e3fec87c 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -2293,4 +2293,7 @@ export default {
'Training reminders, only if you switch them on': 'Lembretes de treino, só se os ligares',
'You can change it anytime in your phone’s settings.': 'Podes mudar isto quando quiseres nas definições do teu telemóvel.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'O openGym pode dar-te um toque no ombro quando um descanso acaba, mesmo com o telemóvel bloqueado no bolso.',
+ // --- Coach message box ---
+ 'Make the box bigger': 'Aumentar a caixa',
+ 'Make the box smaller': 'Diminuir a caixa',
}
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index f956abcaf..d6bf69692 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -2297,4 +2297,7 @@ export default {
'Training reminders, only if you switch them on': 'Напоминания о тренировках, только если вы их включите',
'You can change it anytime in your phone’s settings.': 'Это можно изменить в любой момент в настройках телефона.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'openGym может похлопать вас по плечу, когда отдых закончится, даже если телефон заблокирован и лежит в кармане.',
+ // --- Coach message box ---
+ 'Make the box bigger': 'Увеличить поле',
+ 'Make the box smaller': 'Уменьшить поле',
}
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index 5e1f5050b..f37fb55ea 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -2304,4 +2304,7 @@ export default {
'Training reminders, only if you switch them on': 'การแจ้งเตือนการฝึก เฉพาะเมื่อคุณเปิดใช้',
'You can change it anytime in your phone’s settings.': 'เปลี่ยนได้ทุกเมื่อในการตั้งค่าของโทรศัพท์',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'openGym สะกิดไหล่คุณได้เมื่อหมดเวลาพัก แม้โทรศัพท์จะล็อกอยู่ในกระเป๋า',
+ // --- Coach message box ---
+ 'Make the box bigger': 'ขยายช่องพิมพ์',
+ 'Make the box smaller': 'ย่อช่องพิมพ์',
}
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index 9abe57a64..c3b9147cc 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -2293,4 +2293,7 @@ export default {
'Training reminders, only if you switch them on': 'Antrenman hatırlatıcıları, sadece açarsan',
'You can change it anytime in your phone’s settings.': 'Bunu istediğin zaman telefonunun ayarlarından değiştirebilirsin.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'Telefon kilitli halde cebinde olsa bile, dinlenme bitince openGym omzuna dokunabilir.',
+ // --- Coach message box ---
+ 'Make the box bigger': 'Kutuyu büyüt',
+ 'Make the box smaller': 'Kutuyu küçült',
}
diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.js
index a3503154f..2530f2760 100644
--- a/frontend/src/locales/uk.js
+++ b/frontend/src/locales/uk.js
@@ -2290,4 +2290,7 @@ export default {
'Training reminders, only if you switch them on': 'Нагадування про тренування, лише якщо ти їх увімкнеш',
'You can change it anytime in your phone’s settings.': 'Це можна змінити будь-коли в налаштуваннях телефона.',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': 'openGym може поплескати тебе по плечу, коли відпочинок скінчиться, навіть якщо телефон заблокований і лежить у кишені.',
+ // --- Coach message box ---
+ 'Make the box bigger': 'Збільшити поле',
+ 'Make the box smaller': 'Зменшити поле',
}
diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.js
index 241f0206e..34f57662f 100644
--- a/frontend/src/locales/zh-TW.js
+++ b/frontend/src/locales/zh-TW.js
@@ -2286,4 +2286,7 @@ export default {
'Training reminders, only if you switch them on': '訓練提醒,只在你開啟時',
'You can change it anytime in your phone’s settings.': '你隨時可以在手機設定裡更改。',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': '就算手機鎖著放在口袋裡,休息結束時 openGym 也能拍拍你的肩膀。',
+ // --- Coach message box ---
+ 'Make the box bigger': '放大輸入框',
+ 'Make the box smaller': '縮小輸入框',
}
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index f6414b7a2..633b4c9cd 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -2293,4 +2293,7 @@ export default {
'Training reminders, only if you switch them on': '训练提醒,只在你开启时',
'You can change it anytime in your phone’s settings.': '你随时可以在手机设置里更改。',
'openGym can tap you on the shoulder when a rest is over, even with the phone locked in your pocket.': '即使手机锁屏放在口袋里,休息结束时 openGym 也能拍拍你的肩膀。',
+ // --- Coach message box ---
+ 'Make the box bigger': '放大输入框',
+ 'Make the box smaller': '缩小输入框',
}
diff --git a/frontend/src/views/CoachChat.jsx b/frontend/src/views/CoachChat.jsx
index a41694a9b..05952205a 100644
--- a/frontend/src/views/CoachChat.jsx
+++ b/frontend/src/views/CoachChat.jsx
@@ -23,6 +23,7 @@ import { exLine } from '../lib/history.js'
import { speedUnitOf } from '../lib/speed.js'
import { DEMO } from '../lib/demo.js'
import { MOBILE } from '../lib/mobile.js'
+import ChatInput from '../components/ChatInput.jsx'
import {
coachAvailable, hasConsent, emptyCoach, appendChat, recordTiming, estimateMs, profileLines,
markStale, applicable, applyChangeSet, applyCreatedPlan, recordDismissal, recordDebrief, logEntry,
@@ -50,6 +51,8 @@ export default function CoachChat() {
const openSheet = useUI(s => s.openSheet)
const { job, pending, cap, loading, lastError, last, refresh, maxMessageLen } = useCoachStatus(true)
const [text, setText] = useState('')
+ // The message box opened into a tall editor (components/ChatInput.jsx); closed again on send.
+ const [expanded, setExpanded] = useState(false)
const [busy, setBusy] = useState(false)
const endRef = useRef(null)
const prevJob = useRef(null)
@@ -113,6 +116,7 @@ export default function CoachChat() {
else await requestReview(msg)
update(s => appendChat(s, { role: 'user', kind: 'text', text: msg }))
setText('')
+ setExpanded(false)
refresh()
} catch (e) {
// A server that refuses the job says so in English, with its class beside it: the class
@@ -222,10 +226,9 @@ export default function CoachChat() {
{!!(S.routines || []).length && <button className="qchip" onClick={pickRoutine}><Icon name="wrench" />{t('Improve a routine')}</button>}
{community && <button className="qchip" onClick={showCohort}><Icon name="person" />{t('Compare')}</button>}
</div>}
- <div className="composer-in">
- <textarea rows={1} value={text} maxLength={maxMessageLen || 1000} placeholder={placeholder} disabled={!!job}
- onChange={e => setText(e.target.value)}
- onKeyDown={e => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); send() } }} />
+ <div className={'composer-in' + (expanded ? ' tall' : '')}>
+ <ChatInput value={text} onChange={setText} onSend={send} placeholder={placeholder} disabled={!!job}
+ maxLength={maxMessageLen || 1000} expanded={expanded} setExpanded={setExpanded} />
<button className="send" onClick={send} disabled={!text.trim() || busy || !!job} aria-label={t('Send')}><Icon name="arrowUp" /></button>
</div>
{cap?.limit > 0 && <div className="composer-cap">{t('{0} of {1} Coach runs used today', cap.used, cap.limit)}</div>}