From 6f1d87c8784e37705a2c09f8c85f951db9cd2ebc Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sat, 2 May 2026 15:59:07 -0400 Subject: [PATCH] refactor(web): simplify interview-dock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop a resync useEffect that healed activeIndex back to safeIndex — safeIndex already clamped reads, so the effect only triggered an extra render. Reuse the shared ErrorMessage from ui.tsx instead of the inline copy. Drop a useMemo over a tiny per-render array. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../app/components/interview-dock.tsx | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/apps/fabro-web/app/components/interview-dock.tsx b/apps/fabro-web/app/components/interview-dock.tsx index 4407207e1..beafcf118 100644 --- a/apps/fabro-web/app/components/interview-dock.tsx +++ b/apps/fabro-web/app/components/interview-dock.tsx @@ -1,7 +1,6 @@ import { useCallback, useEffect, - useMemo, useRef, useState, type FormEvent, @@ -23,6 +22,7 @@ import { useSubmitInterviewAnswer, type SubmitInterviewAnswerArg, } from "../lib/mutations"; +import { ErrorMessage } from "./ui"; const PRIMARY_BUTTON = "inline-flex items-center justify-center gap-1.5 rounded-lg bg-teal-500 px-3.5 py-2 text-sm font-medium text-on-primary transition-colors hover:bg-teal-300 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-500 disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:bg-teal-500"; @@ -51,12 +51,6 @@ export function InterviewDock({ runId, questions }: InterviewDockProps) { submitMutation.reset(); }, [question?.id, submitMutation.reset]); - useEffect(() => { - if (safeIndex !== activeIndex) { - setActiveIndex(safeIndex); - } - }, [activeIndex, safeIndex]); - const submit = useCallback( async (arg: Omit) => { if (!question) return; @@ -113,14 +107,7 @@ export function InterviewDock({ runId, questions }: InterviewDockProps) { onSubmit={submit} /> - {error && ( -

- {error} -

- )} + {error && } @@ -351,10 +338,7 @@ function MultiSelectBody({ }); } - const selectedKeys = useMemo( - () => options.map((o) => o.key).filter((key) => selected.has(key)), - [options, selected], - ); + const selectedKeys = options.map((o) => o.key).filter((key) => selected.has(key)); return (