fix: 관계 하나가 미리보기 전체를 버리지 않게 한다

편집기 오른쪽이 통째로 「초안을 미리 볼 수 없습니다」가 되고 이유로 UUID 하나만
보여 줬다. 본문을 쓰는 동안 본문을 볼 수 없었다.

원인은 관계 후보 목록의 개수 상한이다. 계약이 limit 을 100 으로 못박고 있고,
기록이 그 수를 넘자 목록 밖의 기록을 가리킨 문서는 전부 이 상태가 됐다.

관계가 실제로 끊겼는지는 검증이 판정한다(RELATION_TARGET_NOT_FOUND). 서버가 자기
저장소를 직접 보므로 목록 상한과 무관하다. 미리보기가 할 일은 지금 쓰고 있는 글을
보여 주는 것이고, 이름을 모르는 관계 한 줄은 그렇다고 적으면 된다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PTnWufiY9ATv57egkKKVAV
This commit is contained in:
DongHyeonka
2026-09-09 17:50:52 +09:00
co-authored by Claude Opus 5
parent 7bcbaefc47
commit 304893dfde
2 changed files with 32 additions and 8 deletions
@@ -99,6 +99,8 @@ function catalogEntry(
id: string | null,
type: CatalogEntry["type"],
required: boolean,
/** 목록에 없을 때 미리보기를 통째로 버릴 것인가. 관계만 예외다 — 목록에 상한이 있기 때문이다. */
failWhenMissing = true,
): CatalogEntry | null {
if (!id) {
if (required) fail(`${type} catalog entry is required`);
@@ -107,9 +109,10 @@ function catalogEntry(
const entry = catalog.find((candidate) => candidate.id === id);
if (!entry || entry.type !== type) {
if (!failWhenMissing) return null;
fail(`${type} catalog entry not found: ${id}`);
}
return entry;
return entry ?? null;
}
function displayTarget(
@@ -182,13 +185,29 @@ function resolvedRelations(
.sort((left, right) => left.order - right.order)
.map((relation, index) => {
if (!relation.targetId) fail("RELATION catalog entry is required");
const target = catalogEntry(
catalog,
relation.targetId,
"RELATION",
true,
);
if (!target?.kind) fail(`RELATION kind is required: ${relation.targetId}`);
/*
고른 대상이 카탈로그에 없다고 미리보기 전체를 버리지 않는다.
관계 후보 목록은 개수 상한이 있다. 기록이 그 상한을 넘어서자, 상한 밖의 기록을 가리킨
문서는 편집기 오른쪽이 통째로 「초안을 미리 볼 수 없습니다」가 됐다 — 본문을 쓰는 동안
본문을 볼 수 없었고, 화면은 그 이유로 UUID 하나만 보여 줬다.
관계가 실제로 끊겼는지는 검증이 판정한다(`RELATION_TARGET_NOT_FOUND`). 서버가 자기
저장소를 직접 보므로 목록 상한과 무관하다. 미리보기가 할 일은 지금 쓰고 있는 글을
보여 주는 것이고, 이름을 모르는 관계 한 줄은 그렇다고 적으면 된다.
*/
const target = catalogEntry(catalog, relation.targetId, "RELATION", false, false);
if (!target?.kind) {
return {
id: relation.id ?? `relation-${index + 1}`,
targetId: relation.targetId,
targetKind: "CASE" as const,
title: "목록에 없는 기록",
publicPath: null,
reason: relation.reason,
order: relation.order,
};
}
return {
id: relation.id ?? `relation-${index + 1}`,
targetId: target.id,
@@ -99,6 +99,11 @@ export function DocumentEditorScreen({ documentId }: { documentId: string }) {
setAssets([]);
void Promise.all([
studio.gateway.getDocument(documentId, { signal: request.signal }),
/*
100 은 계약이 정한 상한이다(`Limit.maximum`). 기록이 그 수를 넘으면 목록 뒤쪽은 여기
오지 않으므로, 미리보기가 이 목록에 기대지 않게 따로 고쳤다 — 목록에 없는 관계는
그렇게 적고 나머지를 그린다. 고르는 쪽은 관계 편집기의 검색이 맡는다.
*/
...catalogTypes.map((type) => studio.gateway.getCatalog(
{ type, limit: 100 },
{ signal: request.signal },