fix(studio): 홈 포커스 편집기가 자기 초기화를 끝없이 반복하지 않는다

Studio 대시보드의 「지금 집중하는 것」(HomeFocusEditor)은 홈 포커스를
읽으면 effect에서 form.reset으로 값을 채운다. effect는 [focus,
form.reset]에 걸려 있다. 그런데 useAppForm의 reset은 defaultValues에
의존하고, 이 편집기는 defaultValues를 렌더마다 새 객체 리터럴로 넘긴다.
그래서 포커스가 한 번 읽히면 reset → 상태 갱신 → 다시 렌더 → 새 reset →
effect가 끝없이 돈다. 운영(HTTP)에서는 포커스가 있으면 대시보드가 계속
다시 그려진다. 시험 환경에서는 act가 끝나지 않아 시험이 멈춘다.

MOCK Studio에서는 지금까지 관리 기능이 HTTP로 나가 실패했기 때문에
포커스가 비어 있었고, 이 경로가 돌지 않았다. 관리 mock(다음 커밋)을 넣자
studio-shell-smoke.test.tsx의 첫 시험이 멈췄다(vitest worker CPU 100%로
19분, FE-GATE-005가 끝나지 않음).

defaultValues를 모듈 상수로 둔다. release-editor.tsx가 같은 이유로
EMPTY_RELEASE_DRAFT를 쓰는 방식과 같다.

검증: 관리 mock을 넣은 상태에서 이 수정 전에는 studio-shell-smoke의 첫
시험이 60초 timeout으로 끝나지 않는다. 수정 후 studio-shell-smoke·
studio-screens-smoke 8건이 5초에 통과한다. check:types, eslint rc=0.
This commit is contained in:
DongHyeonka
2026-11-12 18:38:29 +09:00
parent 032ba31980
commit fcc35c73f4
@@ -39,6 +39,19 @@ const HOME_FOCUS_SCHEMA = z.object({
decisionId: z.string(),
});
/**
* One object for the life of the module. useAppForm's `reset` depends on
* `defaultValues`, and the effect below resets the form when `reset` changes:
* a literal here made a new `reset` every render, so as soon as a home focus
* loaded the editor reset itself, re-rendered and reset again without end.
* release-editor.tsx keeps its defaults the same way (EMPTY_RELEASE_DRAFT).
*/
const EMPTY_HOME_FOCUS = Object.freeze({
projectId: "",
questionId: "",
decisionId: "",
});
export function HomeFocusEditor() {
const copy = useTechLogCopy();
const { setRequestAnnouncement } = useStudio();
@@ -51,11 +64,7 @@ export function HomeFocusEditor() {
const form = useAppForm({
schema: HOME_FOCUS_SCHEMA,
defaultValues: {
projectId: "",
questionId: "",
decisionId: "",
},
defaultValues: EMPTY_HOME_FOCUS,
allowedServerFields: ["projectId", "questionId", "decisionId"] as const,
mapToCommand(values) {
return {