fix: 작업본 프로젝트 필터·카탈로그 100개 상한·게시 기록 필터 줄
세 가지가 각각 다른 곳에서 조용히 깨져 있었다. 작업본 목록의 프로젝트·정렬은 주소에 적히자마자 지워졌다. 라우트 검색 코덱이 STRIP_UNKNOWN 이라 선언하지 않은 키를 버리는데 `project` 와 `sort` 가 없었다 — 화면은 주소를 쓰고 라우터가 그것을 지워서, 프로젝트를 골라도 목록이 그대로였다. 카탈로그는 한 번만 불렀다. 한 번의 상한은 계약이 100으로 정해 두었으므로, 기록이 101개가 된 날 101번째부터는 관계 대상 선택에도 프로젝트 필터에도 나타나지 않았다. 응답의 `nextCursor` 를 따라 끝까지 읽는다. 게시 기록의 필터 줄은 세 칸 격자에 「검색칸 · 버튼 · 이벤트」로 잘려, 검색칸이 871px 로 벌어지고 이벤트 셀렉트는 91px 로 눌렸다 — 「게시 취소」가 그 너비에 들어가지 않았다. 버튼을 검색칸에 붙이고 칸을 둘로 줄인다. 검색 안내는 「제목 또는 요약」·「제목, 요약, slug」라고 적혀 있었지만 서버가 뒤지는 것은 제목뿐이다. 적힌 대로 고친다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PTnWufiY9ATv57egkKKVAV
This commit is contained in:
co-authored by
Claude Opus 5
parent
02fff0cd03
commit
9e5642cd9f
@@ -0,0 +1,39 @@
|
||||
import type { CatalogPage } from "../contracts/studio/contract.ts";
|
||||
import type { CatalogQuery, RequestOptions, StudioGateway } from "./ports/studio-gateway.ts";
|
||||
|
||||
/** 계약이 정한 한 번의 최대치(`Limit.maximum`). 이보다 크게 부르면 서버가 422 로 거절한다. */
|
||||
const PAGE_SIZE = 100;
|
||||
|
||||
/**
|
||||
* 서버가 커서를 계속 주는 경우에 대비한 상한. 100 × 50 이면 5,000건이고, 그 앞에서 화면이
|
||||
* 영원히 기다리게 두지 않는다.
|
||||
*/
|
||||
const MAX_PAGES = 50;
|
||||
|
||||
/**
|
||||
* 카탈로그를 끝까지 읽는다.
|
||||
*
|
||||
* <p>화면들은 `limit: 100` 으로 한 번만 부르고 있었다. 100 은 계약의 상한이라 더 크게 부를 수도
|
||||
* 없었고, 그래서 기록이 101개가 된 날 101번째부터는 관계 대상 선택에도 작업본 목록의 프로젝트
|
||||
* 필터에도 나타나지 않았다 — 고를 수 없는 기록이 아무 표시 없이 생겼다.
|
||||
*
|
||||
* <p>응답에는 `nextCursor` 가 있다. 그것이 빌 때까지 이어 읽는다.
|
||||
*/
|
||||
export async function collectCatalog(
|
||||
gateway: Pick<StudioGateway, "getCatalog">,
|
||||
query: Omit<CatalogQuery, "cursor" | "limit">,
|
||||
options?: RequestOptions,
|
||||
): Promise<CatalogPage["items"]> {
|
||||
const items: CatalogPage["items"][number][] = [];
|
||||
let cursor: string | undefined;
|
||||
for (let page = 0; page < MAX_PAGES; page += 1) {
|
||||
const result: CatalogPage = await gateway.getCatalog(
|
||||
{ ...query, limit: PAGE_SIZE, ...(cursor === undefined ? {} : { cursor }) },
|
||||
options,
|
||||
);
|
||||
items.push(...result.items);
|
||||
if (!result.nextCursor) return items;
|
||||
cursor = result.nextCursor;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
|
||||
import { collectCatalog } from "../../../application/collect-catalog.ts";
|
||||
import { isStudioGatewayError } from "../../../application/ports/studio-gateway-error.ts";
|
||||
import type { components } from "../../../contracts/studio/generated.ts";
|
||||
import type {
|
||||
@@ -100,12 +101,13 @@ export function DocumentEditorScreen({ documentId }: { documentId: string }) {
|
||||
void Promise.all([
|
||||
studio.gateway.getDocument(documentId, { signal: request.signal }),
|
||||
/*
|
||||
100 은 계약이 정한 상한이다(`Limit.maximum`). 기록이 그 수를 넘으면 목록 뒤쪽은 여기
|
||||
오지 않으므로, 미리보기가 이 목록에 기대지 않게 따로 고쳤다 — 목록에 없는 관계는
|
||||
그렇게 적고 나머지를 그린다. 고르는 쪽은 관계 편집기의 검색이 맡는다.
|
||||
한 번에 받는 상한은 계약이 100으로 정해 두었다(`Limit.maximum`). 그 한 번만 부르던 동안
|
||||
기록이 101개가 되자 101번째부터는 관계 대상 목록에 아예 나타나지 않았고, 화면에는 그
|
||||
사실이 보이지 않았다 — 커서를 따라 끝까지 읽는다.
|
||||
*/
|
||||
...catalogTypes.map((type) => studio.gateway.getCatalog(
|
||||
{ type, limit: 100 },
|
||||
...catalogTypes.map((type) => collectCatalog(
|
||||
studio.gateway,
|
||||
{ type },
|
||||
{ signal: request.signal },
|
||||
)),
|
||||
]).then(
|
||||
@@ -113,7 +115,7 @@ export function DocumentEditorScreen({ documentId }: { documentId: string }) {
|
||||
if (request.signal.aborted) return;
|
||||
setResult({
|
||||
key: requestKey,
|
||||
catalog: catalogPages.flatMap((page) => page.items),
|
||||
catalog: catalogPages.flat(),
|
||||
problem: null,
|
||||
});
|
||||
begin(detail.document, inputOf(detail.document));
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect, useState, type FormEvent } from "react";
|
||||
import { useSearchParams } from "react-router-dom";
|
||||
import { DestructiveConfirmDialog } from "./destructive-confirm-dialog.tsx";
|
||||
|
||||
import { collectCatalog } from "../../../application/collect-catalog.ts";
|
||||
import type { ListDocumentsQuery } from "../../../application/ports/studio-gateway.ts";
|
||||
import type { CatalogPage, DocumentPage } from "../../../contracts/studio/contract.ts";
|
||||
import type { components } from "../../../contracts/studio/generated.ts";
|
||||
@@ -203,12 +204,10 @@ export function DocumentList() {
|
||||
*/
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
void gateway
|
||||
.getCatalog({ type: "PROJECT", limit: 100 }, { signal: controller.signal })
|
||||
.then(
|
||||
(page) => setProjects(page.items),
|
||||
() => undefined,
|
||||
);
|
||||
void collectCatalog(gateway, { type: "PROJECT" }, { signal: controller.signal }).then(
|
||||
(items) => setProjects(items),
|
||||
() => undefined,
|
||||
);
|
||||
return () => controller.abort();
|
||||
}, [gateway]);
|
||||
|
||||
@@ -281,7 +280,8 @@ export function DocumentList() {
|
||||
id="studio-search"
|
||||
type="search"
|
||||
value={searchDraft}
|
||||
placeholder="제목, 요약, slug"
|
||||
/* 서버가 뒤지는 것은 제목뿐이다(`lower(title) LIKE`). 없는 것을 적어 두지 않는다. */
|
||||
placeholder="제목"
|
||||
onChange={(event) => setSearchDraft(event.target.value)}
|
||||
/>
|
||||
<button type="submit">검색</button>
|
||||
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
ProjectEditResponse,
|
||||
TopicEdit,
|
||||
} from "../../../contracts/management/contract.ts";
|
||||
import { collectCatalog } from "../../../application/collect-catalog.ts";
|
||||
import { managementFailureMessage } from "../../../application/ports/management-gateway-error.ts";
|
||||
import { useRouteInput } from "../../../../../presentation/routes/route-input.tsx";
|
||||
import { GuardedStudioLink } from "./guarded-studio-link.tsx";
|
||||
@@ -125,14 +126,14 @@ export function ProjectEditor() {
|
||||
managementGateway.getProject(projectId),
|
||||
managementGateway.listProjectActivities(projectId),
|
||||
managementGateway.listTopics(),
|
||||
gateway.getCatalog({ type: "RELATION", limit: 100 }),
|
||||
collectCatalog(gateway, { type: "RELATION" }),
|
||||
]);
|
||||
if (cancelled) return;
|
||||
setProject(loaded);
|
||||
setDraft(toDraft(loaded));
|
||||
setActivities(activityList);
|
||||
setTopics(topicList.filter((topic) => topic.status !== "ARCHIVED"));
|
||||
setRecords(catalog.items ?? []);
|
||||
setRecords(catalog);
|
||||
setError("");
|
||||
} catch {
|
||||
if (!cancelled) setError("프로젝트를 불러오지 못했습니다.");
|
||||
|
||||
@@ -20,6 +20,7 @@ const publicationFlowClassContract = {
|
||||
success: "studio-publication-success",
|
||||
actions: "studio-publication-actions",
|
||||
filters: "studio-publication-filters",
|
||||
searchField: "studio-publication-search-field",
|
||||
errorState: "studio-publication-error-state",
|
||||
emptyState: "studio-publication-empty-state",
|
||||
historyList: "studio-publication-history-list",
|
||||
|
||||
@@ -180,16 +180,26 @@ export function PublicationList({
|
||||
</header>
|
||||
|
||||
<form className={styles.filters} onSubmit={applyFilter}>
|
||||
<label>
|
||||
<span>검색</span>
|
||||
<input
|
||||
value={queryDraft}
|
||||
maxLength={100}
|
||||
onChange={(event) => setQueryDraft(event.currentTarget.value)}
|
||||
placeholder="제목 또는 요약"
|
||||
/>
|
||||
</label>
|
||||
<button type="submit">검색</button>
|
||||
{/*
|
||||
검색 버튼은 검색 칸에 붙인다. 셋을 나란한 칸으로 두었더니 격자가 「검색칸 · 버튼 ·
|
||||
이벤트」로 잘려, 검색칸이 871px 로 벌어지고 이벤트 셀렉트는 91px 로 눌려 「게시 취소」가
|
||||
잘려 보였다. 버튼은 자기가 무엇을 실행하는지 옆에 있을 때 읽힌다.
|
||||
*/}
|
||||
<div className={styles.searchField}>
|
||||
<label htmlFor="studio-publication-search">검색</label>
|
||||
<div>
|
||||
<input
|
||||
id="studio-publication-search"
|
||||
type="search"
|
||||
value={queryDraft}
|
||||
maxLength={100}
|
||||
onChange={(event) => setQueryDraft(event.currentTarget.value)}
|
||||
/* 서버가 실제로 뒤지는 것은 제목뿐이다. 요약을 적어 두면 넣어도 안 나오는 이유를 알 수 없다. */
|
||||
placeholder="제목"
|
||||
/>
|
||||
<button type="submit">검색</button>
|
||||
</div>
|
||||
</div>
|
||||
<label>
|
||||
<span>이벤트</span>
|
||||
<select
|
||||
|
||||
@@ -292,16 +292,22 @@
|
||||
color: #215943;
|
||||
}
|
||||
|
||||
/*
|
||||
칸은 둘이다 — 검색(칸+버튼)과 이벤트. 셋으로 두었을 때 버튼이 가운데 칸을 190px 차지하면서
|
||||
검색칸이 871px 로 벌어지고 이벤트 셀렉트가 91px 로 눌렸다. 셀렉트 안의 「게시 취소」가 그
|
||||
너비에 들어가지 않아, 무엇으로 거르는 중인지 읽을 수 없었다.
|
||||
*/
|
||||
.filters {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(260px, 1fr) 190px auto;
|
||||
grid-template-columns: minmax(260px, 1fr) 200px;
|
||||
gap: 14px;
|
||||
align-items: end;
|
||||
padding-block: 28px;
|
||||
border-bottom: 1px solid var(--line-strong);
|
||||
}
|
||||
|
||||
.filters label {
|
||||
.filters label,
|
||||
.searchField {
|
||||
display: grid;
|
||||
min-width: 0;
|
||||
gap: 7px;
|
||||
@@ -310,6 +316,21 @@
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.searchField > div {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.searchField input {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.searchField button {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.filters input,
|
||||
.filters select {
|
||||
width: 100%;
|
||||
|
||||
@@ -69,6 +69,12 @@ export const TECH_LOG_ROUTE_CODECS = Object.freeze({
|
||||
q: optionalSelection,
|
||||
kind: optionalString,
|
||||
status: optionalString,
|
||||
/*
|
||||
프로젝트와 정렬도 여기 적어야 한다. 코덱은 STRIP_UNKNOWN 이라 적지 않은 키를 조용히
|
||||
버린다 — 화면은 주소를 쓰는데 라우터가 지워서, 프로젝트 필터가 아무 일도 하지 않았다.
|
||||
*/
|
||||
project: optionalString,
|
||||
sort: optionalString,
|
||||
page: optionalString,
|
||||
})
|
||||
.strip(),
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { collectCatalog } from "../../../src/features/tech-log/application/collect-catalog.ts";
|
||||
import type {
|
||||
CatalogQuery,
|
||||
StudioGateway,
|
||||
} from "../../../src/features/tech-log/application/ports/studio-gateway.ts";
|
||||
import type { CatalogPage } from "../../../src/features/tech-log/contracts/studio/contract.ts";
|
||||
|
||||
type Entry = CatalogPage["items"][number];
|
||||
|
||||
function entry(index: number): Entry {
|
||||
return {
|
||||
id: `00000000-0000-4000-8000-${String(index).padStart(12, "0")}`,
|
||||
type: "RELATION",
|
||||
label: `기록 ${index}`,
|
||||
dependencyRevision: `relation:${index}`,
|
||||
};
|
||||
}
|
||||
|
||||
/** 서버를 흉내 낸다 — 한 번에 100개까지만 주고, 더 있으면 커서를 함께 준다. */
|
||||
function gatewayHolding(total: number) {
|
||||
const all = Array.from({ length: total }, (_, index) => entry(index));
|
||||
const calls: Array<string | undefined> = [];
|
||||
const gateway: Pick<StudioGateway, "getCatalog"> = {
|
||||
getCatalog(query: CatalogQuery) {
|
||||
calls.push(query.cursor);
|
||||
const limit = query.limit ?? 20;
|
||||
const from = query.cursor === undefined ? 0 : Number(query.cursor);
|
||||
const items = all.slice(from, from + limit);
|
||||
const next = from + limit;
|
||||
return Promise.resolve({
|
||||
items,
|
||||
nextCursor: next < all.length ? String(next) : null,
|
||||
});
|
||||
},
|
||||
};
|
||||
return { gateway, calls };
|
||||
}
|
||||
|
||||
describe("catalog 는 커서를 끝까지 따라간다", () => {
|
||||
/*
|
||||
화면들은 `limit: 100` 으로 한 번만 부르고 있었다. 100 은 계약의 상한이라 더 크게 부를 수도
|
||||
없어서, 기록이 101개가 된 날 101번째부터는 관계 대상 선택에 아예 나타나지 않았다 — 화면에는
|
||||
아무 표시도 없이 "고를 수 없는 기록" 이 생겼다.
|
||||
*/
|
||||
it("상한을 넘는 기록도 빠짐없이 모은다", async () => {
|
||||
const { gateway, calls } = gatewayHolding(105);
|
||||
|
||||
const items = await collectCatalog(gateway, { type: "RELATION" });
|
||||
|
||||
expect(items).toHaveLength(105);
|
||||
expect(new Set(items.map((item) => item.id)).size).toBe(105);
|
||||
expect(items.at(-1)?.label).toBe("기록 104");
|
||||
expect(calls).toEqual([undefined, "100"]);
|
||||
});
|
||||
|
||||
it("한 쪽으로 끝나면 한 번만 부른다", async () => {
|
||||
const { gateway, calls } = gatewayHolding(4);
|
||||
|
||||
const items = await collectCatalog(gateway, { type: "PROJECT" });
|
||||
|
||||
expect(items).toHaveLength(4);
|
||||
expect(calls).toEqual([undefined]);
|
||||
});
|
||||
|
||||
/** 서버가 커서를 계속 주더라도 화면이 영원히 기다리지 않는다. */
|
||||
it("커서가 끝나지 않아도 멈춘다", async () => {
|
||||
let calls = 0;
|
||||
const endless: Pick<StudioGateway, "getCatalog"> = {
|
||||
getCatalog() {
|
||||
calls += 1;
|
||||
return Promise.resolve({ items: [entry(calls)], nextCursor: `cursor-${calls}` });
|
||||
},
|
||||
};
|
||||
|
||||
const items = await collectCatalog(endless, { type: "TOPIC" });
|
||||
|
||||
expect(calls).toBe(50);
|
||||
expect(items).toHaveLength(50);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user