fix: 홈 초점의 질문·결정을 고른 프로젝트 것으로 좁힌다

「지금 집중하는 것」은 프로젝트·질문·결정 셋을 각각 고르는 구조였고, 고르는
목록이 전체였다. 그래서 프로젝트만 바꾸면 질문·결정은 이전 프로젝트 것이
그대로 남았다 — 홈에 프로젝트는 Liner 인데 결정은 Keycloak 것이 나왔다.

프로젝트를 고르면 그 프로젝트의 질문·결정만 목록에 온다. 질문은 항목이
`primaryProject` 를 들고 오므로 그것으로 거르고(계약의 ProjectSummary 에는
id 가 없어 공개 경로에서 뽑은 slug 로 맞춘다), 결정은 경로 자체가 프로젝트를
요구하므로 고른 프로젝트의 것만 온다. 프로젝트를 바꾸면 이전 선택은 함께
비운다 — 남겨 두면 같은 어긋남이 다시 난다.

listStudioQuestions·listStudioProjectDecisions 는 계약에 있었지만 기여 목록에
등록되지 않아 부를 수 없었다. 오늘 같은 누락을 세 번째 만난다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011nAjrqNHGPNngN4aUbcyvJ
This commit is contained in:
DongHyeonka
2026-09-01 15:02:06 +09:00
co-authored by Claude Opus 5
parent d835276296
commit 2b042829cf
5 changed files with 119 additions and 10 deletions
@@ -9,7 +9,6 @@ import { managementFailureMessage } from "../../../application/ports/management-
import { GuardedStudioLink } from "./guarded-studio-link.tsx";
import { useStudio } from "../use-studio.ts";
type CatalogEntry = components["schemas"]["CatalogEntry"];
/**
* 공개 홈의 "지금 집중하는 것" 을 정하는 화면.
@@ -29,10 +28,11 @@ export function HomeFocusEditor() {
const { gateway, managementGateway, setRequestAnnouncement } = useStudio();
const [focus, setFocus] = useState<HomeFocusResponse | null>(null);
const [projects, setProjects] = useState<ProjectIndexItem[]>([]);
const [relations, setRelations] = useState<CatalogEntry[]>([]);
const [projectId, setProjectId] = useState("");
const [questionId, setQuestionId] = useState("");
const [decisionId, setDecisionId] = useState("");
const [projectQuestions, setProjectQuestions] = useState<{ id: string; label: string }[]>([]);
const [projectDecisions, setProjectDecisions] = useState<{ id: string; label: string }[]>([]);
const [pending, setPending] = useState(false);
const [error, setError] = useState("");
const [generation, setGeneration] = useState(0);
@@ -49,15 +49,13 @@ export function HomeFocusEditor() {
*/
void (async () => {
try {
const [current, projectPage, catalog] = await Promise.all([
const [current, projectPage] = await Promise.all([
managementGateway.getHomeFocus(),
managementGateway.listProjects(0, 50),
gateway.getCatalog({ type: "RELATION", limit: 100 }),
]);
if (cancelled) return;
setFocus(current);
setProjects(projectPage.items ?? []);
setRelations(catalog.items ?? []);
setProjectId(current.currentProjectId ?? "");
setQuestionId(current.openQuestionId ?? "");
setDecisionId(current.recentDecisionId ?? "");
@@ -71,8 +69,65 @@ export function HomeFocusEditor() {
};
}, [gateway, managementGateway, generation]);
const questions = relations.filter((entry) => entry.kind === "QUESTION");
const decisions = relations.filter((entry) => entry.kind === "PROJECT_DECISION");
/*
고른 프로젝트의 질문·결정만 불러온다. 프로젝트를 바꾸면 이전 프로젝트의 선택은 목록에
없으므로 함께 비운다 — 남겨 두면 홈에서 다른 프로젝트의 결정이 나온다.
*/
useEffect(() => {
let cancelled = false;
if (!projectId) {
setProjectQuestions([]);
setProjectDecisions([]);
return () => {
cancelled = true;
};
}
void (async () => {
try {
const [questionPage, decisionList] = await Promise.all([
managementGateway.listQuestions(0, 100),
managementGateway.listProjectDecisions(projectId),
]);
if (cancelled) return;
/*
질문 항목은 프로젝트를 slug 로 알려 준다(계약의 `ProjectSummary` 에는 id 가 없다).
그래서 고른 프로젝트의 slug 와 맞춘다.
*/
const chosenSlug = projects
.find((project) => project.id === projectId)
?.publication.canonicalPath?.split("/")
.filter(Boolean)
.pop();
setProjectQuestions(
(questionPage.items ?? [])
.filter((item) => !chosenSlug || item.primaryProject?.slug === chosenSlug)
.map((item) => ({ id: item.id, label: item.question })),
);
setProjectDecisions(
decisionList.map((item) => ({ id: item.id, label: item.statement })),
);
} catch {
if (!cancelled) {
setProjectQuestions([]);
setProjectDecisions([]);
}
}
})();
return () => {
cancelled = true;
};
}, [managementGateway, projectId, projects, generation]);
/*
이 화면은 「지금 집중하는 것」 하나를 고르는 자리다. 셋(프로젝트·질문·결정)이 서로 다른
프로젝트를 가리키면 홈에서 프로젝트는 A 인데 결정은 B 의 것이 나온다 — 실제로 그렇게 나왔다.
그래서 프로젝트를 고르면 그 프로젝트의 질문·결정만 고르게 한다.
질문 항목은 `primaryProject` 를 들고 오므로 그것으로 거르고, 결정은 경로 자체가 프로젝트를
요구하므로 고른 프로젝트의 것만 온다.
*/
const questions = projectQuestions;
const decisions = projectDecisions;
const save = async (event: FormEvent) => {
event.preventDefault();
@@ -127,7 +182,18 @@ export function HomeFocusEditor() {
<div className="studio-field-grid">
<label className="studio-field studio-field--wide">
<span>현재 작업 (프로젝트)</span>
<select value={projectId} onChange={(event) => setProjectId(event.currentTarget.value)}>
<select
value={projectId}
onChange={(event) => {
/*
프로젝트를 바꾸면 질문·결정 선택을 비운다. 남겨 두면 홈에서 프로젝트는 A 인데
결정은 B 의 것이 나온다 — 실제로 그렇게 나왔다.
*/
setProjectId(event.currentTarget.value);
setQuestionId("");
setDecisionId("");
}}
>
<option value="">고르지 않음</option>
{projects.map((project) => (
<option key={project.id} value={project.id}>
@@ -159,7 +225,13 @@ export function HomeFocusEditor() {
</option>
))}
</select>
{questions.length === 0 ? <small>아직 Question 문서가 없습니다.</small> : null}
{questions.length === 0 ? (
<small>
{projectId
? "이 프로젝트에 열린 질문이 없습니다."
: "프로젝트를 먼저 고르세요."}
</small>
) : null}
</label>
<label className="studio-field">
@@ -176,7 +248,13 @@ export function HomeFocusEditor() {
</option>
))}
</select>
{decisions.length === 0 ? <small>아직 Decision 문서가 없습니다.</small> : null}
{decisions.length === 0 ? (
<small>
{projectId
? "이 프로젝트에 결정이 없습니다."
: "프로젝트를 먼저 고르세요."}
</small>
) : null}
</label>
</div>