Skip to content

Commit 5d3545c

Browse files
HugoGresseclaude
andcommitted
fix(transcription): allow endpointing 0 + prod webhook logging
Address Copilot review on #275: - endpointing settings field & URL param now accept 0 (disable endpointing); previously the falsy `|| fallback` and the num() `> 0` guard made 0 impossible to set. - move GO-reminder scheduling error from request.log to console.* so it reaches Cloud Logging in production (Fastify logger is disabled outside dev/test). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 8602f88 commit 5d3545c

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

functions/src/api/routes/whatsapp/whatsapp.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ export const whatsappRoutes = (fastify: FastifyInstance, options: any, done: ()
290290
)
291291
)
292292
} catch (err) {
293-
request.log?.error({ err }, 'failed to schedule whatsapp panel reminders')
293+
// console.* (not request.log) so this reaches Cloud Logging in production, where the
294+
// Fastify logger is disabled.
295+
console.error('[whatsapp go] failed to schedule panel reminders', err)
294296
}
295297

296298
reply.status(200).send({ sent: true })

src/public/transcription/TranscriptionSettingsPanel.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,14 @@ export const TranscriptionSettingsPanel = ({ settings, onChange }: Transcription
126126
label="Endpointing (s)"
127127
inputProps={{ step: 0.05, min: 0 }}
128128
value={settings.endpointing}
129-
onChange={(e) => set('endpointing', Number(e.target.value) || settings.endpointing)}
129+
onChange={(e) => {
130+
const parsed = Number(e.target.value)
131+
// Keep 0 (valid = disable endpointing); only fall back on empty/invalid input.
132+
set(
133+
'endpointing',
134+
e.target.value === '' || Number.isNaN(parsed) || parsed < 0 ? settings.endpointing : parsed
135+
)
136+
}}
130137
sx={fieldSx}
131138
/>
132139
<Button variant="contained" size="small" onClick={() => set('hideSettings', true)} sx={{ ml: 'auto' }}>

src/public/transcription/transcriptionSettings.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ export const toHexColor = (value: string): string => (value.startsWith('#') ? va
4444
// Read settings from a URL query string, falling back to defaults for anything missing/invalid.
4545
export const settingsFromQuery = (search: string): TranscriptionSettings => {
4646
const q = new URLSearchParams(search)
47-
const num = (key: string, fallback: number) => {
48-
const parsed = Number(q.get(key))
49-
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback
47+
const num = (key: string, fallback: number, allowZero = false) => {
48+
const raw = q.get(key)
49+
if (raw === null) return fallback
50+
const parsed = Number(raw)
51+
if (!Number.isFinite(parsed)) return fallback
52+
return parsed > 0 || (allowZero && parsed === 0) ? parsed : fallback
5053
}
5154
const csv = (raw: string | null): string[] | null =>
5255
raw
@@ -69,7 +72,7 @@ export const settingsFromQuery = (search: string): TranscriptionSettings => {
6972
alignment: alignment === 'left' || alignment === 'right' ? alignment : DEFAULT_SETTINGS.alignment,
7073
languages: languages?.length ? languages : DEFAULT_SETTINGS.languages,
7174
customVocabulary: csv(q.get('custom_vocabulary')) ?? DEFAULT_SETTINGS.customVocabulary,
72-
endpointing: num('endpointing', DEFAULT_SETTINGS.endpointing),
75+
endpointing: num('endpointing', DEFAULT_SETTINGS.endpointing, true),
7376
hideSettings: q.has('hide_settings') ? q.get('hide_settings') === 'true' : DEFAULT_SETTINGS.hideSettings,
7477
}
7578
}

0 commit comments

Comments
 (0)