diff --git a/src/features/tech-log/domain/content-format/asset-evidence-catalog.ts b/src/features/tech-log/domain/content-format/asset-evidence-catalog.ts index e9fd615..d159d66 100644 --- a/src/features/tech-log/domain/content-format/asset-evidence-catalog.ts +++ b/src/features/tech-log/domain/content-format/asset-evidence-catalog.ts @@ -63,39 +63,6 @@ function outranks(candidate: ResolvableAsset, incumbent: ResolvableAsset): boole return candidate.id > incumbent.id; } -/** - * Grows the set of Assets an evidence key can resolve against, never shrinks - * it. - * - * Alignment follow-up, item 2. The editor screen's Asset array feeds two - * consumers whose needs are opposite: the Picker's *displayed* list, which a - * search must narrow, and Instant Preview's *resolution catalog*, which a - * search must never narrow -- `instantPreviewEvidenceKeyGate` rejects any key - * no loaded Asset backs, so an Asset dropped from the array turns a directive - * that rendered a moment ago into an error panel. Handing the Picker's search - * results straight to `setAssets` would do exactly that: type a query that - * excludes an already-inserted figure and the live preview blanks, purely - * because the author touched a search box. - * - * Making the screen's callback *additive* is what keeps the two apart, and it - * has to be additive by construction rather than by convention -- the - * replacing version was one `setAssets` reference away and read as correct. - * `incoming` is placed first and `current` deduped behind it, so a re-fetched - * Asset's fresher fields win while every previously observed Asset survives; - * that is also exactly the expression a single freshly uploaded Asset needs, - * so both callers share one rule. - * - * Order is not load-bearing for resolution -- `findResolvableAsset` is - * explicitly order-independent -- so this only has to be total and stable. - */ -export function mergeAssetCatalog( - current: readonly Asset[], - incoming: readonly Asset[], -): readonly Asset[] { - if (incoming.length === 0) return current; - const arriving = new Set(incoming.map((asset) => asset.id)); - return [...incoming, ...current.filter((asset) => !arriving.has(asset.id))]; -} /** * The evidence-key gate every caller uses. A key is referenceable when a real diff --git a/src/features/tech-log/presentation/shared/public-render/asset-resolvers.ts b/src/features/tech-log/presentation/shared/public-render/asset-resolvers.ts index ab67ad9..120c8e0 100644 --- a/src/features/tech-log/presentation/shared/public-render/asset-resolvers.ts +++ b/src/features/tech-log/presentation/shared/public-render/asset-resolvers.ts @@ -1,5 +1,3 @@ -import type { Asset } from "../../../contracts/studio/contract.ts"; -import { findResolvableAsset } from "../../../domain/content-format/asset-evidence-catalog.ts"; import type { EvidenceAsset, ResolveEvidenceAsset, @@ -9,11 +7,11 @@ import type { * `presentation/` may not import `adapters/` (the * `feature-presentation-does-not-know-outbound-adapters` architecture rule), so this * cannot read `adapters/static/evidence-assets.ts` directly. It carries its own copy of - * that one legacy entry instead -- the same pattern `instant-preview.tsx`, - * `public-preview-screen.tsx`, `publication-event-preview-screen.tsx`, and - * `case-document-page.tsx` already each carry independently. This is not a second - * source of truth for new assets; it exists solely so the one pre-existing hardcoded - * key keeps resolving to byte-identical output once screens move onto this resolver. + * that one legacy entry instead -- the same pattern `public-preview-screen.tsx`, + * `publication-event-preview-screen.tsx`, and `case-document-page.tsx` already each + * carry independently. This is not a second source of truth for new assets; it exists + * solely so the one pre-existing hardcoded key keeps resolving to byte-identical + * output once screens move onto this resolver. */ const LEGACY_STATIC_EVIDENCE_ASSETS: Readonly> = { "fetch-strategy-boundary": Object.freeze({ @@ -65,16 +63,15 @@ function fromDescriptor(descriptor: ResolvedAssetLike): EvidenceAsset { } /** - * Shared resolution order for both factories below. The legacy registry only - * needs to protect the *labels* it hand-authored for the one pre-existing key + * Resolution order. The legacy registry only needs to protect the *labels* it + * hand-authored for the one pre-existing key * (`ResolvedAsset` carries no label fields at all, so nothing else can supply * them) -- the image itself always comes from whichever descriptor actually - * resolved the key, catalog or server block, when one exists. This way a future + * resolved the key, when one exists. This way a future * backend `Asset` whose `assetKey` collides with the legacy slug degrades to, * at worst, a wrong caption on the right image -- never a wrong image shown * under a right caption. Only when no descriptor resolves the key at all does - * the legacy registry supply the image too (today's actual Instant Preview - * fallback path, with no catalog to consult). + * the legacy registry supply the image too. */ function resolveWith( key: string, @@ -97,34 +94,6 @@ function resolveWith( return legacy ?? MISSING_EVIDENCE_ASSET; } -/** - * Instant Preview: resolves against the Asset list the editor has loaded. - * `findResolvableAsset` is the single decision -- the same one the preview's - * key gate and its block-descriptor resolver make -- so the image shown here - * is always the Asset the gate accepted. Building a local `Map` here instead - * was last-wins where the descriptor resolver was first-wins, which meant two - * READY Assets sharing one `assetKey` could put one Asset's caption over - * another Asset's image. - */ -export function createAssetCatalogResolver( - assets: readonly Asset[], -): ResolveEvidenceAsset { - return (key: string) => - resolveWith(key, (lookupKey) => { - const asset = findResolvableAsset(assets, lookupKey); - if (!asset) return undefined; - return { - assetId: asset.id, - assetKey: asset.assetKey, - mediaType: asset.mediaType, - publicPath: asset.publicPath, - width: asset.width, - height: asset.height, - decorative: asset.decorative, - }; - }); -} - /** * 렌더 모델이 본문 블록을 갖고 있으면 그 블록들을 준다. * diff --git a/src/features/tech-log/presentation/shared/public-render/mechanism-map.tsx b/src/features/tech-log/presentation/shared/public-render/mechanism-map.tsx deleted file mode 100644 index f4bc2d9..0000000 --- a/src/features/tech-log/presentation/shared/public-render/mechanism-map.tsx +++ /dev/null @@ -1,32 +0,0 @@ -type Step = Readonly<{ id: string; label: string }>; - -/** - * 동작 원리가 지나가는 자리들을 한눈에. - * - *

개념 기록의 목적은 "작동 원리를 나중에 빠르게 되살리는 것"이다. 그런데 화면은 여느 긴 글과 - * 똑같이 제목 다음에 바로 첫 문단이 왔다 — 어느 계층을 지나는 이야기인지 알려면 끝까지 읽거나 - * 오른쪽 목차를 따로 읽어야 했다. - * - *

본문의 소제목이 곧 그 계층들이므로, 그것을 가로로 이어 첫 화면에 세운다. 작성자가 따로 - * 적을 것이 없다는 점이 중요하다 — 손으로 적게 하면 본문을 고칠 때 이 줄만 낡는다. - * - *

누르면 그 자리로 간다. 목차와 같은 일을 하지만 모양이 다르다: 목차는 "무엇이 있나"의 - * 목록이고, 이것은 "어디를 지나는가"의 흐름이다. - */ -export function MechanismMap({ steps }: { steps: ReadonlyArray }) { - /* 한 자리짜리 흐름은 흐름이 아니다. 둘 이상일 때만 그린다. */ - if (steps.length < 2) return null; - - return ( -

- ); -} diff --git a/src/features/tech-log/presentation/studio/components/asset-picker-dialog.tsx b/src/features/tech-log/presentation/studio/components/asset-picker-dialog.tsx index 9436a3c..2e46fce 100644 --- a/src/features/tech-log/presentation/studio/components/asset-picker-dialog.tsx +++ b/src/features/tech-log/presentation/studio/components/asset-picker-dialog.tsx @@ -28,13 +28,11 @@ export function AssetPickerDialog({ gateway, usedCount, onInsert, - onAssetsObserved, }: { gateway: StudioAssetGateway; /** 본문이 지금 가리키는 자료 수. */ usedCount: number; onInsert(directive: string): void; - onAssetsObserved?(assets: readonly Asset[]): void; }) { const [open, setOpen] = useState(false); const dialogRef = useRef(null); @@ -94,7 +92,6 @@ export function AssetPickerDialog({ { onInsert(directive); close(); diff --git a/src/features/tech-log/presentation/studio/components/asset-picker.tsx b/src/features/tech-log/presentation/studio/components/asset-picker.tsx index ed695b6..55efc33 100644 --- a/src/features/tech-log/presentation/studio/components/asset-picker.tsx +++ b/src/features/tech-log/presentation/studio/components/asset-picker.tsx @@ -40,20 +40,9 @@ function byteLabel(bytes: number): string { export function AssetPicker({ gateway, onInsert, - onAssetsObserved, }: Readonly<{ gateway: StudioAssetGateway; onInsert: (directive: string) => void; - /** - * Every Asset this Picker has *seen* -- the first page, and each search's - * results -- reported as it arrives. Deliberately not "the Assets to show": - * the editor screen merges these into a resolution catalog that only grows - * (`mergeAssetCatalog`), because Instant Preview resolves `:::evidence` - * directives against that catalog and a narrowing search must never make an - * already-inserted figure stop rendering. Optional so Task 10 Step 1's - * original test (which renders `AssetPicker` on its own) keeps passing. - */ - onAssetsObserved?: (assets: readonly Asset[]) => void; }>) { const [assets, setAssets] = useState([]); const [status, setStatus] = useState<"LOADING" | "ERROR" | "READY">("LOADING"); @@ -90,7 +79,6 @@ export function AssetPicker({ if (!active) return; setAssets(page.items); setStatus("READY"); - onAssetsObserved?.(page.items); }) .catch((error: unknown) => { if (!active || isAbortError(error)) return; @@ -100,7 +88,7 @@ export function AssetPicker({ active = false; controller.abort(); }; - }, [gateway, kind, onAssetsObserved, q]); + }, [gateway, kind, q]); // READY만 삽입 후보다. 서버 필터를 신뢰하되 방어적으로 한 번 더 거른다. // A query does not relax this: an asset under review is never insertable, diff --git a/src/features/tech-log/presentation/studio/components/case-fields.tsx b/src/features/tech-log/presentation/studio/components/case-fields.tsx index 9087b9f..7dea590 100644 --- a/src/features/tech-log/presentation/studio/components/case-fields.tsx +++ b/src/features/tech-log/presentation/studio/components/case-fields.tsx @@ -30,14 +30,10 @@ export function CaseFields({ draft, issues, onChange, - onAssetsObserved, - onAssetUploaded, }: { draft: CaseInput; issues: readonly FieldIssue[]; onChange(draft: CaseInput): void; - onAssetsObserved?: (assets: readonly Asset[]) => void; - onAssetUploaded?: (asset: Asset) => void; }) { const assetGateway = useStudioAssetGateway(); const bodyEditorRef = useRef(null); @@ -118,7 +114,7 @@ export function CaseFields({

작성 화면이 곧 문서입니다. 빈 블록에서 / 를 입력해 제목·목록·코드 블록을 추가할 수 있습니다.

- +
@@ -61,7 +59,6 @@ export function ConceptFields({ draft, issues, onChange, onAssetsObserved, onAss {uploadOpen ? { - onAssetUploaded?.(asset); insertDirective(buildEvidenceDirective({ assetKey: asset.assetKey, alt: asset.decorative ? "" : (asset.altText ?? ""), caption: "", zoom: asset.kind === "DIAGRAM" })); setUploadOpen(false); }} onClose={() => setUploadOpen(false)} /> : null} diff --git a/src/features/tech-log/presentation/studio/components/document-editor-screen.tsx b/src/features/tech-log/presentation/studio/components/document-editor-screen.tsx index ec9d3e6..64316b9 100644 --- a/src/features/tech-log/presentation/studio/components/document-editor-screen.tsx +++ b/src/features/tech-log/presentation/studio/components/document-editor-screen.tsx @@ -4,13 +4,11 @@ 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 { - Asset, WorkingCopy, WorkingCopyInput, WorkingCopyDetail, } from "../../../contracts/studio/contract.ts"; import type { TopicVariantEdit } from "../../../contracts/management/contract.ts"; -import { mergeAssetCatalog } from "../../../domain/content-format/asset-evidence-catalog.ts"; import { createLocalId } from "../../../domain/studio/local-id.ts"; import type { DocumentEditorController } from "./document-editor-controller.ts"; import { DocumentEditor } from "./document-editor.tsx"; @@ -65,18 +63,6 @@ export function DocumentEditorScreen({ documentId }: { documentId: string }) { catalog: CatalogEntry[]; problem: Error | null; } | null>(null); - // Owned here (not by CaseFields/AssetPicker) so the Picker, the upload - // dialog, and Instant Preview all read the same array -- a freshly - // uploaded asset appears in the preview without a refetch. - // - // Alignment follow-up, item 2: this array is Instant Preview's *resolution - // catalog*, not the Picker's displayed list. The Picker now searches, so its - // displayed list narrows; adopting that narrowed list here would make an - // already-inserted `:::evidence` figure stop resolving the moment the author - // typed a query. Both writers therefore go through `mergeAssetCatalog`, - // which can only grow the catalog -- the one legitimate reset is the effect - // below, when the screen switches to a different document. - const [assets, setAssets] = useState([]); const [saveError, setSaveError] = useState(""); /** * 마지막 검증 결과. 편집기가 이것을 들고 있는 이유는, 무엇이 모자라 게시가 막히는지 작성자가 @@ -87,17 +73,9 @@ export function DocumentEditorScreen({ documentId }: { documentId: string }) { const [publishing, setPublishing] = useState(false); const [publishError, setPublishError] = useState(""); const [publishIssues, setPublishIssues] = useState([]); - const observeAssets = useCallback((observed: readonly Asset[]) => { - setAssets((current) => mergeAssetCatalog(current, observed)); - }, []); - const observeUploadedAsset = useCallback((asset: Asset) => { - setAssets((current) => mergeAssetCatalog(current, [asset])); - }, []); - useEffect(() => { const request = new AbortController(); clear(); - setAssets([]); void Promise.all([ studio.gateway.getDocument(documentId, { signal: request.signal }), /* @@ -386,9 +364,6 @@ export function DocumentEditorScreen({ documentId }: { documentId: string }) { controller={controller!} catalog={currentResult.catalog} variants={variants} - assets={assets} - onAssetsObserved={observeAssets} - onAssetUploaded={observeUploadedAsset} /> ); } diff --git a/src/features/tech-log/presentation/studio/components/document-editor.tsx b/src/features/tech-log/presentation/studio/components/document-editor.tsx index 45bf8fe..c6213df 100644 --- a/src/features/tech-log/presentation/studio/components/document-editor.tsx +++ b/src/features/tech-log/presentation/studio/components/document-editor.tsx @@ -1,5 +1,4 @@ import type { components } from "../../../contracts/studio/generated.ts"; -import type { Asset } from "../../../contracts/studio/contract.ts"; import type { TopicVariantEdit } from "../../../contracts/management/contract.ts"; import type { DocumentEditorController } from "./document-editor-controller.ts"; import { CASE_FIELD_PATHS, CaseFields } from "./case-fields.tsx"; @@ -30,16 +29,10 @@ export function DocumentEditor({ controller, catalog, variants, - assets: _assets, - onAssetsObserved, - onAssetUploaded, }: { controller: DocumentEditorController; catalog: CatalogEntry[]; variants: readonly TopicVariantEdit[]; - assets: readonly Asset[]; - onAssetsObserved: (assets: readonly Asset[]) => void; - onAssetUploaded: (asset: Asset) => void; }) { const topics = catalog.filter(({ type }) => type === "TOPIC"); const projects = catalog.filter(({ type }) => type === "PROJECT"); @@ -80,11 +73,11 @@ export function DocumentEditor({ /> {controller.draft.kind === "CASE" - ? + ? : controller.draft.kind === "CONCEPT" - ? + ? : controller.draft.kind === "SETUP" - ? + ? : controller.draft.kind === "REFERENCE" ? : controller.draft.kind === "QUESTION" diff --git a/src/features/tech-log/presentation/studio/components/instant-preview.tsx b/src/features/tech-log/presentation/studio/components/instant-preview.tsx deleted file mode 100644 index 23cab62..0000000 --- a/src/features/tech-log/presentation/studio/components/instant-preview.tsx +++ /dev/null @@ -1,131 +0,0 @@ -import type { components } from "../../../contracts/studio/generated.ts"; -import type { Asset, WorkingCopyInput } from "../../../contracts/studio/contract.ts"; -import { - evidenceCatalogEntriesFromAssets, - findResolvableAsset, - supportsResolvableEvidenceKey, -} from "../../../domain/content-format/asset-evidence-catalog.ts"; -import { ContentFormatError } from "../../../domain/content-format/parse-case-content.ts"; -import { - projectWorkingCopy, - resolveCaseEvidenceAssets, -} from "../../../domain/content-format/project-public-render-model.ts"; -import { createAssetCatalogResolver } from "../../shared/public-render/asset-resolvers.ts"; -import { PublicRecordRenderer } from "../../shared/public-render/public-record-renderer.tsx"; -import { useStudio } from "../use-studio.ts"; - -type CatalogEntry = components["schemas"]["CatalogEntry"]; -type ResolvedAsset = components["schemas"]["ResolvedAsset"]; -type PublicRenderModel = components["schemas"]["PublicRenderModel"]; - -/** - * The one legacy key predates the Asset gateway entirely: the document - * catalog carries a fixture `EVIDENCE` row for it, but no `Asset` record - * backs it, so `assets` never resolves it. - */ -export function isLegacyStaticEvidenceKey(key: string): boolean { - return key === "fetch-strategy-boundary"; -} - -/** - * Instant Preview's evidence-key gate. Exported so - * `tests/features/tech-log/evidence-key-agreement.test.ts` cross-products - * *this* expression against the mock adapter's byte-parallel pair rather than - * rebuilding it -- three earlier fix rounds regressed exactly this pair, each - * time by writing a second expression that agreed only on the examples that - * round happened to use. - */ -export function instantPreviewEvidenceKeyGate(assets: readonly Asset[]) { - return supportsResolvableEvidenceKey(assets, isLegacyStaticEvidenceKey); -} - -/** - * Total -- never throws. Resolves through `findResolvableAsset`, the same - * function this file's key gate and `createAssetCatalogResolver` (which - * supplies the pixels) use, so the descriptor attached to a block and the - * image rendered for it always come from one Asset. - */ -export function resolveInstantPreviewAssetDescriptor(assets: readonly Asset[]) { - return (key: string): ResolvedAsset => { - const asset = findResolvableAsset(assets, key); - if (asset) { - return { - assetId: asset.id, - assetKey: asset.assetKey, - mediaType: asset.mediaType, - publicPath: asset.publicPath, - width: asset.width, - height: asset.height, - decorative: asset.decorative, - }; - } - if (isLegacyStaticEvidenceKey(key)) { - // Fixed literal, not derived: this file only ever resolves this one legacy - // key today, so the id only needs to be stable, not computed. - return { - assetId: "00000000-0000-4000-8000-000000000001", - assetKey: key, - mediaType: "image/svg+xml", - publicPath: "/media/fetch-strategy-boundary.svg", - width: 1080, - height: 420, - decorative: false, - }; - } - return { - assetId: "00000000-0000-4000-8000-000000000000", - assetKey: key, - mediaType: "application/octet-stream", - publicPath: "", - width: null, - height: null, - decorative: true, - }; - }; -} - -export function InstantPreview({ - draft, - catalog, - assets = [], -}: { - draft: WorkingCopyInput; - catalog: CatalogEntry[]; - assets?: readonly Asset[]; -}) { - const studio = useStudio(); - const effectiveCatalog = [...catalog, ...evidenceCatalogEntriesFromAssets(assets)]; - let model: PublicRenderModel | null = null; - let issues: string[] | null = null; - try { - model = resolveCaseEvidenceAssets( - projectWorkingCopy( - draft, - effectiveCatalog, - { mode: "PREVIEW", publishedAt: null }, - // The same expression `validate-working-copy.ts` and the mock's - // preview projection use: a resolvable Asset, or the legacy static - // key. A key this rejects fails the projection, and the error panel - // below names it -- the same key `validateDocument` reports - // `EVIDENCE_UNSUPPORTED` for. - instantPreviewEvidenceKeyGate(assets), - ), - resolveInstantPreviewAssetDescriptor(assets), - ); - } catch (error) { - issues = error instanceof ContentFormatError - ? error.issues.map((issue) => `${issue.line}:${issue.column} ${issue.detail}`) - : ["현재 입력으로 공개 문서를 구성할 수 없습니다."]; - } - if (issues) return

초안을 미리 볼 수 없습니다

    {issues.map((issue) =>
  • {issue}
  • )}
; - return ( -
- -
- ); -} diff --git a/src/features/tech-log/presentation/studio/components/setup-fields.tsx b/src/features/tech-log/presentation/studio/components/setup-fields.tsx index bcb6836..c1a4d58 100644 --- a/src/features/tech-log/presentation/studio/components/setup-fields.tsx +++ b/src/features/tech-log/presentation/studio/components/setup-fields.tsx @@ -19,12 +19,10 @@ const ASSET_KIND_OPTIONS: ReadonlyArray<{ value: AssetKind; label: string }> = [ { value: "ATTACHMENT", label: "첨부파일" }, ]; -export function SetupFields({ draft, issues, onChange, onAssetsObserved, onAssetUploaded }: { +export function SetupFields({ draft, issues, onChange }: { draft: SetupInput; issues: readonly FieldIssue[]; onChange(draft: SetupInput): void; - onAssetsObserved?: (assets: readonly Asset[]) => void; - onAssetUploaded?: (asset: Asset) => void; }) { const assetGateway = useStudioAssetGateway(); const bodyEditorRef = useRef(null); @@ -62,7 +60,7 @@ export function SetupFields({ draft, issues, onChange, onAssetsObserved, onAsset
절차

명령은 코드 블록으로, 단계는 제목과 목록으로 나누면 공개 화면에도 그대로 반영됩니다.

- +
@@ -72,7 +70,6 @@ export function SetupFields({ draft, issues, onChange, onAssetsObserved, onAsset
{uploadOpen ? { - onAssetUploaded?.(asset); insertDirective(buildEvidenceDirective({ assetKey: asset.assetKey, alt: asset.decorative ? "" : (asset.altText ?? ""), caption: "", zoom: asset.kind === "DIAGRAM" })); setUploadOpen(false); }} onClose={() => setUploadOpen(false)} /> : null} diff --git a/src/features/tech-log/presentation/styles/globals.css b/src/features/tech-log/presentation/styles/globals.css index 314e460..d1d2fff 100644 --- a/src/features/tech-log/presentation/styles/globals.css +++ b/src/features/tech-log/presentation/styles/globals.css @@ -4034,48 +4034,6 @@ summary { padding-block: 3px; } -/* 동작 원리가 지나가는 자리들 */ - -.mechanism-map { - padding-bottom: 10px; -} - -.mechanism-map > ol { - display: flex; - flex-wrap: wrap; - gap: 7px 0; - margin: 13px 0 0; - padding: 0; - list-style: none; -} - -.mechanism-map > ol > li { - display: flex; - align-items: center; -} - -/* 사이의 화살표. 마지막 뒤에는 붙이지 않는다 — 더 갈 곳이 있다는 거짓말이 된다. */ -.mechanism-map > ol > li:not(:last-child)::after { - content: "→"; - padding-inline: 11px; - color: var(--line-strong); - font-size: 13px; -} - -.mechanism-map a { - padding: 5px 11px; - border: 1px solid var(--line); - border-radius: 999px; - color: var(--ink-soft); - font-size: 13px; - line-height: 1.4; -} - -.mechanism-map a:hover { - border-color: var(--signal); - color: var(--signal); -} - /* 프로젝트 목록의 조사 상태 */ .project-index-state { @@ -4604,11 +4562,6 @@ summary { border-top: 0; } -/* The previous heading-to-pill mechanism approximation was visually misleading. */ -.mechanism-map { - display: none; -} - /* Projects: more information, less empty row height. */ .project-index-list { margin-top: 56px; diff --git a/src/features/tech-log/presentation/styles/studio-editor.css b/src/features/tech-log/presentation/styles/studio-editor.css index 68ca008..19052db 100644 --- a/src/features/tech-log/presentation/styles/studio-editor.css +++ b/src/features/tech-log/presentation/styles/studio-editor.css @@ -1,51 +1,14 @@ .studio-app .studio-editor-page, -.studio-app .studio-editor-split, -.studio-app .studio-editor-workspace, -.studio-app .studio-editor-preview { min-width: 0; } +.studio-app .studio-editor-workspace { min-width: 0; } .studio-app .studio-editor-loading { min-height: 240px; padding-block: 56px; color: var(--muted); } -/* - 편집과 미리보기를 한 화면에 나란히 둔다. 탭이었을 때는 한 번에 하나만 보였고, 고친 결과를 - 보려면 편집하던 자리를 화면에서 치워야 했다. -*/ -/* - 이 화면만 공용 컨테이너보다 넓다. `.studio-main` 은 모든 Studio 화면이 1180px 를 함께 - 쓰는데, 여기서는 그 폭에 본문 두 벌이 들어가야 해서 한 칸이 566px 로 좁아졌다. 헤더와 - 다른 화면은 그대로 두고 편집기가 놓인 경우에만 넓힌다. -*/ -.studio-app:has(.studio-editor-split) .studio-header-inner, -.studio-app:has(.studio-editor-split) .studio-main { width: min(1600px, calc(100% - 80px)); } - -/* - 편집과 미리보기를 한 화면에 나란히 둔다. 탭이었을 때는 한 번에 하나만 보였고, 고친 결과를 - 보려면 편집하던 자리를 화면에서 치워야 했다. - - 두 칸 모두 페이지 스크롤을 그대로 탄다. 미리보기를 붙박이로 두고 자체 스크롤을 주었더니 - 편집기를 내려도 미리보기는 제자리였고, 보려면 그 안을 따로 굴려야 했다 — 나란히 둔 이유가 - 둘을 같이 보는 것인데 움직임이 갈라지면 그 이점이 없다. -*/ -.studio-app .studio-editor-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; padding-top: 40px; } -/* 반쪽 폭에는 62px 짜리 제목이 앉을 자리가 없다. */ -.studio-app .studio-editor-split .studio-editor-heading h1 { font-size: clamp(28px, 3vw, 40px); } - -/* - 미리보기는 제자리에 붙어 따라온다. 예전에는 폼과 같은 흐름에 나란히 놓여 있어서, 편집기가 - 8,872px 이면 미리보기도 그만큼 아래로 흘렀다 — 아래쪽 칸을 고치는 동안 미리보기는 화면 밖이었다. - `align-self: start` 가 없으면 격자가 칸을 늘려 버려 붙박이가 걸리지 않는다. -*/ -.studio-app .studio-editor-preview { position: sticky; top: 24px; align-self: start; max-height: calc(100vh - 48px); overflow-y: auto; display: flex; flex-direction: column; padding-left: 40px; border-left: 1px solid var(--line); } -.studio-app .studio-editor-preview__heading { padding-bottom: 20px; border-bottom: 1px solid var(--line); } -.studio-app .studio-editor-preview__heading .studio-eyebrow { margin-bottom: 8px; } -.studio-app .studio-editor-preview__body { padding-top: 20px; } .studio-app .studio-editor-heading { padding-bottom: 36px; border-bottom: 1px solid var(--line-strong); } .studio-app .studio-editor-heading h1 { margin: 0; font-size: clamp(38px, 5vw, 62px); line-height: 1.05; letter-spacing: -0.045em; } .studio-app .studio-editor-heading > p:last-child { max-width: 780px; margin: 18px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; overflow-wrap: anywhere; } .studio-app .studio-editor-section { padding: 48px 0; border-bottom: 1px solid var(--line); } .studio-app .studio-editor-section-heading { margin-bottom: 24px; } .studio-app .studio-editor-section-heading .studio-eyebrow { margin-bottom: 8px; } -.studio-app .studio-editor-section-heading h2, -.studio-app .studio-editor-preview__heading h2, -.studio-app .studio-preview-error h2 { margin: 0; font-size: 25px; letter-spacing: -0.03em; } +.studio-app .studio-editor-section-heading h2 { margin: 0; font-size: 25px; letter-spacing: -0.03em; } .studio-app .studio-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; } .studio-app .studio-field, @@ -95,10 +58,8 @@ .studio-app .studio-checkbox-set .studio-field--checkbox input { width: 20px; min-width: 20px; min-height: 20px; padding: 0; } .studio-app .studio-checkbox-set .studio-field--checkbox span { font-size: 15px; font-weight: 500; } -.studio-app .studio-ordered-list, -.studio-app .studio-resolution-fields { min-width: 0; margin: 34px 0 0; padding: 0; border: 0; } -.studio-app .studio-ordered-list legend, -.studio-app .studio-resolution-fields legend { margin-bottom: 14px; font-size: 17px; font-weight: 700; } +.studio-app .studio-ordered-list { min-width: 0; margin: 34px 0 0; padding: 0; border: 0; } +.studio-app .studio-ordered-list legend { margin-bottom: 14px; font-size: 17px; font-weight: 700; } .studio-app .studio-ordered-list > p { margin: 0 0 16px; color: var(--muted); font-size: 13px; } .studio-app .studio-ordered-item, .studio-app .studio-relation-item { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 22px 0; border-top: 1px solid var(--line); } @@ -109,8 +70,6 @@ .studio-app .studio-item-actions button:disabled, .studio-app .studio-add-item:disabled { opacity: 0.45; } .studio-app .studio-add-item { margin-top: 12px; } -.studio-app .studio-resolution-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; } -.studio-app .studio-resolution-fields legend { grid-column: 1 / -1; } /* 작업 상태와 저장·게시를 화면 아래에 붙여 둔다. 문서가 길어져도 스크롤 위치와 무관하게 손이 @@ -120,16 +79,12 @@ .studio-app .studio-document-status-bar { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; min-width: 0; margin-top: 48px; padding: 16px 0; border-top: 1px solid var(--line-strong); background: var(--paper); } .studio-app .studio-editor-status { margin: 0; font-weight: 700; } .studio-app .studio-editor-status--dirty, -.studio-app .studio-editor-status--conflict, -.studio-app .studio-editor-conflict { color: #8f2f27; } +.studio-app .studio-editor-status--conflict { color: #8f2f27; } .studio-app .studio-editor-status--clean { color: #166748; } .studio-app .studio-document-status-bar dl { display: flex; gap: 20px; margin: 0; } .studio-app .studio-document-status-bar dl div { display: flex; align-items: baseline; gap: 8px; } .studio-app .studio-document-status-bar dt { color: var(--muted); font-size: 12px; } .studio-app .studio-document-status-bar dd { margin: 0; font-size: 13px; } -.studio-app .studio-document-status-bar__note { flex: 1 1 240px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; } -/* 색은 위 묶음이 정한다 — 여기서 다시 칠하면 실패가 안내문처럼 보인다. */ -.studio-app .studio-document-status-bar .studio-editor-conflict { flex: 1 1 240px; margin: 0; font-size: 12px; line-height: 1.6; } .studio-app .studio-document-status-bar__actions { display: flex; align-items: center; gap: 12px; margin-left: auto; } /* `.studio-primary-button` 은 세로로 쌓이는 자리에 맞춘 바깥 여백을 갖고 있다. 한 줄에 나란히 두면 그 여백이 줄 높이를 늘리고, 옆 버튼만 늘어나 짝이 어긋난다. */ @@ -137,16 +92,8 @@ /* 저장·게시는 이 화면의 주 동작이다 — 굵기와 색으로만 격을 올린다. */ .studio-app .studio-document-status-bar button { min-width: 92px; color: var(--ink); font-weight: 700; } .studio-app .studio-document-status-bar button:disabled { color: var(--faint); } -.studio-app .studio-document-status-bar .studio-editor-unplaced-issues { flex: 1 1 100%; } - -.studio-app .studio-asset-panel { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--line); } -.studio-app .studio-asset-panel .studio-eyebrow { margin-bottom: 8px; } -.studio-app .studio-asset-panel h3 { margin: 0 0 10px; font-size: 19px; letter-spacing: -0.02em; } -.studio-app .studio-asset-panel > p { max-width: 640px; margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.6; } -.studio-app .studio-asset-panel-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 18px; } .studio-app .studio-asset-kind-field { display: grid; min-width: 0; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 650; } .studio-app .studio-asset-kind-field select { min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--paper); color: var(--ink); font: inherit; font-size: 15px; } -.studio-app .studio-asset-panel-actions button { min-height: 44px; padding-inline: 13px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--paper); color: var(--ink); font-weight: 650; } .studio-app .asset-picker ul { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; } .studio-app .asset-picker button { min-height: 36px; padding-inline: 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--paper); color: var(--ink); font-size: 13px; } /* Declared after `.asset-picker button` on purpose: the pill rule above also @@ -168,51 +115,16 @@ .studio-app .asset-picker ul:not(:empty) { margin-top: 12px; } .studio-app .studio-error, .studio-app .studio-asset-picker-empty { margin: 0; color: var(--muted); font-size: 13px; } -.studio-app .studio-instant-preview { min-width: 0; overflow: clip; border: 1px solid var(--line); } -.studio-app .studio-instant-preview .public-record-embedded { width: 100%; max-width: none; margin: 0; padding: clamp(24px, 5vw, 56px); } -.studio-app .studio-preview-error { padding: 48px 0; border-bottom: 1px solid var(--line); } -.studio-app .studio-preview-error ul { margin: 20px 0 0; padding-left: 20px; color: #8f2f27; line-height: 1.7; overflow-wrap: anywhere; } - -@media (max-width: 1024px) { - .studio-app .studio-editor-split { grid-template-columns: minmax(0, 1fr); gap: 40px; } - .studio-app .studio-editor-split .studio-editor-heading h1 { font-size: clamp(38px, 5vw, 62px); } - .studio-app .studio-editor-preview { position: static; max-height: none; overflow-y: visible; padding-top: 8px; padding-left: 0; border-top: 1px solid var(--line-strong); border-left: 0; } -} @media (max-width: 767px) { .studio-app .studio-editor-heading { padding-bottom: 28px; } - .studio-app .studio-editor-split { padding-top: 28px; } - /* 안내문은 세 줄로 접혀 뷰포트의 20%를 고정으로 가져간다. 실패 문구는 남기고 안내만 접는다 — - Ctrl+S 는 여기서 누를 수 있는 것도 아니다. */ - .studio-app .studio-document-status-bar__note { display: none; } .studio-app .studio-document-status-bar__actions { flex: 1 1 100%; margin-left: 0; } .studio-app .studio-document-status-bar__actions button { flex: 1; min-width: 0; } - .studio-app .studio-field-grid, - .studio-app .studio-resolution-fields { grid-template-columns: minmax(0, 1fr); } - .studio-app .studio-field--wide, - .studio-app .studio-resolution-fields legend { grid-column: auto; } + .studio-app .studio-field-grid { grid-template-columns: minmax(0, 1fr); } + .studio-app .studio-field--wide { grid-column: auto; } .studio-app .studio-item-actions { display: grid; grid-template-columns: minmax(0, 1fr); } - .studio-app .studio-instant-preview .public-record-embedded { padding: 22px 16px; } } -/* 게시까지의 단계. 순서가 있는 길이라 번호를 붙인다 — 장식이 아니라 밟아야 하는 차례다. */ -.studio-app .studio-editor-flow ol { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; } -.studio-app .studio-editor-flow li { display: flex; align-items: center; gap: 6px; font-size: 13px; } -.studio-app .studio-editor-flow li + li::before { content: "→"; margin-right: 4px; color: var(--faint); } -.studio-app .studio-editor-flow span { display: inline-flex; min-width: 18px; height: 18px; align-items: center; justify-content: center; border-radius: 999px; background: var(--line); color: var(--muted); font-size: 11px; font-weight: 650; } - -/* 게시를 막는 항목. 고치는 자리에서 보이지 않으면 작성자는 별도 화면과 편집기를 오가며 - 어느 칸이었는지 기억해야 한다. */ -.studio-app .studio-editor-validation { margin: 0 0 20px; padding: 14px 16px; border: 1px solid var(--danger, #b4232a); border-radius: 6px; background: var(--paper); } -.studio-app .studio-editor-validation--stale { border-color: var(--line-strong); opacity: 0.72; } -.studio-app .studio-editor-validation-title { margin: 0 0 10px; color: var(--danger, #b4232a); font-size: 13px; font-weight: 700; } -.studio-app .studio-editor-validation--stale .studio-editor-validation-title { color: var(--muted); } -.studio-app .studio-editor-validation ul { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; } -.studio-app .studio-editor-validation li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 13px; color: var(--ink); } -.studio-app .studio-editor-validation li span { min-width: 30px; color: var(--danger, #b4232a); font-size: 11px; font-weight: 700; } -.studio-app .studio-editor-validation li[data-severity="WARNING"] span { color: var(--muted); } -.studio-app .studio-editor-validation code { color: var(--faint); font-size: 11px; } - /* 칸 아래에 붙는 지적. 검증 결과를 화면 맨 위 한 덩어리로 모아 두는 대신 그 칸 옆에 두면, 작성자는 `/topicId` 같은 경로를 읽고 어느 칸인지 스스로 찾을 필요가 없다. @@ -224,11 +136,6 @@ .studio-app .studio-char-count { justify-self: end; margin-top: -2px; color: var(--faint); font-family: "IBM Plex Mono", monospace; font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; } .studio-app .studio-char-count[data-full] { color: var(--danger, #b4232a); font-weight: 650; } .studio-app .studio-field-notice--error { color: var(--danger, #b4232a); } -.studio-app .studio-field-notice--warning { color: var(--muted); } -.studio-app .studio-editor-unplaced-issues { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; } -.studio-app .studio-editor-unplaced-issues li { font-size: 12px; color: var(--danger, #b4232a); } -.studio-app .studio-editor-unplaced-issues li[data-severity="WARNING"] { color: var(--muted); } -.studio-app .studio-editor-unplaced-issues code { color: var(--faint); font-size: 11px; } /* 저장과 게시는 되돌릴 수 있는 정도가 다르다 — 하나는 초안을 남기고, 하나는 공개한다. 둘이 @@ -262,9 +169,6 @@ /* 지금 보고 있는 구역. 배경 대신 글자만 진하게 — Studio 의 다른 곳과 같은 언어다. */ .studio-app .studio-editor-toc a[aria-current="true"] { color: var(--ink); font-weight: 700; } -/* 미리보기 본문이 스스로 스크롤한다. 편집 중인 절로 옮기려면 이 요소가 스크롤 컨테이너여야 한다. */ -.studio-app .studio-editor-preview__body { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; } - /* 반복 그룹. @@ -282,18 +186,6 @@ /* 순서 바꾸기는 이 행의 목적이 아니다 — 글자 크기로 그렇게 말한다. */ .studio-app .studio-ordered-item .studio-item-actions button { font-size: 12px; font-weight: 500; } -/* 미리보기 보기 방식 — 좁은 칸에 갇힌 미리보기는 공개 화면이 아니다 */ -.studio-app .studio-preview-modes { display: inline-flex; gap: 2px; margin-left: 14px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; } -.studio-app .studio-preview-modes button { min-height: 28px; padding-inline: 10px; border: 0; border-radius: 4px; background: none; color: var(--muted); font-size: 12px; } -.studio-app .studio-preview-modes button[aria-pressed="true"] { background: var(--canvas); color: var(--ink); font-weight: 640; } -.studio-app .studio-editor-split[data-preview="full"] { grid-template-columns: minmax(0, 1fr); } -.studio-app .studio-editor-split[data-preview="hidden"] { grid-template-columns: minmax(0, 1fr); } -/* - 모바일 폭은 실제 좁은 화면의 폭(390px)으로 잘라 본다. 줄여 그리지 않고 그 폭 그대로 두어야 - 줄바꿈과 접힘이 배포본과 같아진다. -*/ -.studio-app .studio-editor-preview__body[data-width="mobile"] > * { max-width: 390px; margin-inline: auto; } - /* 관계 대상 거르기 — 105개를 평면 셀렉트에서 이름으로 찾을 수는 없다 */ .studio-app .studio-relation-filter { display: grid; gap: 5px; margin-bottom: 18px; } .studio-app .studio-relation-filter > span { color: var(--muted); font-size: 12px; font-weight: 640; } @@ -320,7 +212,6 @@ .studio-app .studio-editor-context dd { margin: 0; color: var(--ink); font-size: 14px; font-weight: 600; } .studio-app .studio-context-empty { color: var(--faint); font-weight: 500; } .studio-app .studio-context-missing { color: #a13b31; } -.studio-app .studio-context-relations-title { margin: 15px 0 0; color: var(--faint); font-size: 12px; font-weight: 620; } .studio-app .studio-editor-context ul { margin: 8px 0 0; padding: 0; list-style: none; } .studio-app .studio-editor-context ul li { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; padding-block: 4px; } .studio-app .studio-editor-context ul span { color: var(--faint); font-size: 12px; line-height: 1.7; } @@ -540,24 +431,6 @@ line-height: 1.55; } -.studio-app .studio-editor-commandbar__views { - display: flex; - align-items: center; - gap: 10px; - align-self: center; -} - -.studio-app .studio-editor-commandbar__views > span { - color: var(--faint); - font-size: 11px; - font-weight: 650; -} - -.studio-app .studio-editor-commandbar .studio-preview-modes, -.studio-app .studio-editor-preview__heading .studio-preview-modes { - margin-left: 0; -} - .studio-app .studio-editor-context { grid-column: 1 / -1; display: flex; @@ -680,30 +553,6 @@ line-height: 1.5; } -.studio-app .studio-editor-split { - display: grid; - gap: 28px; - padding-top: 0; -} - -.studio-app .studio-editor-split[data-preview="hidden"] { - grid-template-columns: minmax(0, 1fr); -} - -.studio-app .studio-editor-split[data-preview="hidden"] .studio-editor-workspace { - width: min(100%, 920px); - margin-inline: auto; -} - -.studio-app .studio-editor-split[data-preview="split"] { - grid-template-columns: minmax(560px, 0.86fr) minmax(620px, 1.14fr); - gap: 34px; -} - -.studio-app .studio-editor-split[data-preview="full"] { - grid-template-columns: minmax(0, 1fr); -} - .studio-app .studio-editor-workspace { padding-bottom: 42px; } @@ -725,105 +574,10 @@ padding-top: 34px; } -.studio-app .studio-editor-preview { - position: sticky; - top: 16px; - align-self: start; - display: flex; - min-width: 0; - max-height: calc(100dvh - 32px); - overflow: hidden; - flex-direction: column; - padding: 0; - border: 1px solid var(--line-strong); - border-radius: 8px; - background: #f6f6f3; -} - -.studio-app .studio-editor-preview__heading { - display: flex; - min-height: 68px; - flex: 0 0 auto; - align-items: center; - justify-content: space-between; - gap: 18px; - padding: 12px 16px; - border-bottom: 1px solid var(--line); - background: var(--paper); -} - -.studio-app .studio-editor-preview__heading .studio-eyebrow { - margin: 0 0 2px; - font-size: 9px; -} - -.studio-app .studio-editor-preview__heading h2 { - font-size: 17px; - letter-spacing: -0.02em; -} - -.studio-app .studio-editor-preview__body { - flex: 1 1 auto; - min-height: 0; - overflow: auto; - padding: 22px; - scroll-behavior: smooth; - scrollbar-width: thin; - scrollbar-color: #c3c6c7 transparent; -} - -.studio-app .studio-editor-preview__body::-webkit-scrollbar { - width: 8px; - height: 8px; -} - -.studio-app .studio-editor-preview__body::-webkit-scrollbar-track { - background: transparent; -} - -.studio-app .studio-editor-preview__body::-webkit-scrollbar-thumb { - border: 2px solid transparent; - border-radius: 999px; - background: #c3c6c7; - background-clip: padding-box; -} - -.studio-app .studio-instant-preview { - overflow: clip; - border: 1px solid var(--line); - border-radius: 4px; - background: var(--paper); - box-shadow: 0 10px 28px rgb(0 0 0 / 4%); -} - -.studio-app .studio-editor-split[data-preview="full"] .studio-editor-preview { - position: static; - width: min(100%, 1240px); - max-height: none; - margin-inline: auto; -} - -.studio-app .studio-editor-split[data-preview="full"] .studio-editor-preview__body { - max-height: none; - overflow: visible; - padding: 28px; -} - .studio-app .studio-document-status-bar { margin-top: 0; } -@media (max-width: 1180px) { - .studio-app .studio-editor-split[data-preview="split"] { - grid-template-columns: minmax(0, 1fr); - } - - .studio-app .studio-editor-split[data-preview="split"] .studio-editor-preview { - position: static; - max-height: 72dvh; - } -} - @media (max-width: 767px) { .studio-app:has(.studio-editor-page) .studio-main, .studio-app:has(.studio-editor-page) .studio-header-inner { @@ -839,10 +593,6 @@ gap: 16px; } - .studio-app .studio-editor-commandbar__views { - justify-content: space-between; - } - .studio-app .studio-editor-context { align-items: flex-start; flex-direction: column; @@ -861,10 +611,6 @@ .studio-app .studio-editor-context__separator { display: none; } - - .studio-app .studio-editor-preview__body { - padding: 10px; - } } /* -------------------------------------------------------------------------- @@ -914,19 +660,6 @@ color: var(--line-strong); } -.studio-app .studio-editor-commandbar .studio-preview-modes { - border-color: transparent; - background: var(--canvas); -} - -.studio-app .studio-editor-commandbar .studio-preview-modes button { - min-height: 30px; -} - -.studio-app .studio-editor-split[data-preview="hidden"] .studio-editor-workspace { - width: min(100%, 820px); -} - .studio-app .studio-editor-workspace { padding-top: 34px; } @@ -1415,8 +1148,7 @@ } /* Repeated items resemble reorderable document blocks, not nested forms. */ -.studio-app .studio-ordered-list, -.studio-app .studio-resolution-fields { +.studio-app .studio-ordered-list { margin-top: 30px; } @@ -1457,19 +1189,6 @@ text-underline-offset: 3px; } -/* Evidence is part of authoring, but secondary to the prose. */ -.studio-app .studio-asset-panel { - margin-top: 34px; - padding: 20px 22px; - border: 1px solid var(--line); - border-radius: 8px; - background: color-mix(in srgb, var(--canvas) 48%, transparent); -} - -.studio-app .studio-asset-panel-actions { - margin-bottom: 12px; -} - /* Keep status actions available without making the writing surface feel boxed. */ .studio-app .studio-document-status-bar { margin-top: 44px; diff --git a/tests/features/tech-log/asset-picker.test.tsx b/tests/features/tech-log/asset-picker.test.tsx index 634fefb..76ede94 100644 --- a/tests/features/tech-log/asset-picker.test.tsx +++ b/tests/features/tech-log/asset-picker.test.tsx @@ -10,14 +10,12 @@ import { AssetPicker, buildEvidenceDirective, } from "../../../src/features/tech-log/presentation/studio/components/asset-picker.tsx"; -import { mergeAssetCatalog } from "../../../src/features/tech-log/domain/content-format/asset-evidence-catalog.ts"; import { AssetUploadDialog, stateForError, stateForUploaded, } from "../../../src/features/tech-log/presentation/studio/components/asset-upload-dialog.tsx"; import { DocumentEditorScreen } from "../../../src/features/tech-log/presentation/studio/components/document-editor-screen.tsx"; -import { InstantPreview } from "../../../src/features/tech-log/presentation/studio/components/instant-preview.tsx"; import { StudioProvider } from "../../../src/features/tech-log/presentation/studio/studio-provider.tsx"; import { createTechLogFeatureInstalledInput } from "../../../src/features/tech-log/adapters/create-tech-log-feature-input.ts"; import { createMockStudioGateway } from "../../../src/features/tech-log/adapters/mock/mock-studio-gateway.ts"; @@ -153,21 +151,6 @@ test("does not offer a QUARANTINED asset for insertion", async () => { expect(screen.queryByRole("button", { name: /unsafe/ })).not.toBeInTheDocument(); }); -test("reports the loaded Asset list once listAssets resolves", async () => { - const loaded: readonly Asset[][] = []; - render( - {}} - onAssetsObserved={(assets) => (loaded as Asset[][]).push([...assets])} - />, - ); - - await screen.findByRole("button", { name: /fetch-strategy-boundary/ }); - assert.equal(loaded.length, 1); - assert.equal(loaded[0]!.length, 2); -}); - // --- upload outcome/error classification: pure functions, tested apart from the dialog --- test("stateForUploaded maps a READY asset to the READY outcome", () => { @@ -463,7 +446,6 @@ test("inserts evidence after the active document block without leaving the writi assert.ok(authored.indexOf("## 책임 경계") < authored.indexOf(expectedDirective), authored); assert.ok(authored.indexOf(expectedDirective) < authored.indexOf("정책과 명령을 분리합니다."), authored); expect(screen.getByLabelText("2번째 자료")).toHaveValue(expectedDirective); - expect(screen.queryByRole("region", { name: "즉시 미리보기" })).not.toBeInTheDocument(); }); // --- Fix round 1 --- @@ -1077,7 +1059,7 @@ test("EVIDENCE_NOT_FOUND is reachable through validateWorkingCopy directly: the // collapses "can this key be rendered" and "which Asset does it render" into // one exported decision, `findResolvableAsset`, and puts every caller // (validation's gate, validation's decorative lookup, the mock projection's -// gate and resolver, InstantPreview's gate, resolver, and pixel resolver) on +// gate and resolver) on // it. The tests below are the shapes that broke the round-3 pair. // `MockStudioDependencies.assets` is keyed by whatever the caller chooses -- @@ -1253,30 +1235,8 @@ function caseDraft(bodyMarkdown: string) { } as never; } -function renderInstantPreview(bodyMarkdown: string, assets: readonly Asset[]) { - render( - - createMockStudioGateway()}> - - - , - ); -} - -// Round 3 loosened InstantPreview's gate back to the merged catalog, arguing -// the un-loaded-asset case would otherwise blank the preview. It blanks -// either way -- an un-loaded Asset contributes no catalog row either. All the -// looseness bought was keys the fetched EVIDENCE catalog carries: those -// rendered a caption with an empty gap and no message while validation said -// EVIDENCE_UNSUPPORTED. Every caller is now on the same expression, so the -// preview refuses exactly what validation refuses -- and says so. -test("Instant Preview refuses a key only the document catalog carries, exactly as mock validation does", () => { - const body = ':::evidence key="resolution-evidence" alt="근거" caption="근거" zoom="false"\n:::'; - renderInstantPreview(body, []); - - const alert = screen.getByRole("alert"); - assert.match(alert.textContent ?? "", /resolution-evidence/); +test("검증은 문서 목록에만 있는 자료 열쇠를 받지 않는다", () => { + const body = ':::evidence key="resolution-evidence" alt="근거" caption="근거" zoom="false"'; const report = validateWorkingCopy( { ...(caseDraft(body) as object), id: "88888888-8888-4888-8888-888888888882", version: 1, updatedAt: "2026-08-14T00:00:00.000Z" } as never, @@ -1295,36 +1255,6 @@ test("Instant Preview refuses a key only the document catalog carries, exactly a ); }); -// The pixels come from `createAssetCatalogResolver` (a last-wins `Map`) while -// the block descriptor came from `resolveAssetDescriptor` (a first-wins -// `find`) -- a fourth expression in the same path, disagreeing with the third -// whenever two READY Assets share a key. -test("Instant Preview renders the same asset the gate and the descriptor picked when two assets share a key", () => { - const older = assetFixture({ - id: "dddddddd-dddd-4ddd-8ddd-ddddddddddd1", - assetKey: "dup-pixels", - publicPath: "/media/dup-pixels-older.svg", - updatedAt: "2026-08-14T00:00:00.000Z", - }); - const newer = assetFixture({ - id: "dddddddd-dddd-4ddd-8ddd-ddddddddddd2", - assetKey: "dup-pixels", - publicPath: "/media/dup-pixels-newer.svg", - updatedAt: "2026-08-14T00:00:01.000Z", - }); - - renderInstantPreview( - ':::evidence key="dup-pixels" alt="중복 키 그림" caption="근거" zoom="false"\n:::', - [newer, older], - ); - - expect(screen.queryByRole("alert")).not.toBeInTheDocument(); - assert.equal( - screen.getByAltText("중복 키 그림").getAttribute("src"), - "/media/dup-pixels-newer.svg", - ); -}); - // The idempotency ledger must not freeze an *uncharacterized* internal // failure: the port reports it as retryable, so a same-key retry has to // actually re-run the work instead of replaying the cached 500. @@ -1704,29 +1634,6 @@ test("a QUARANTINED asset the server wrongly returns for a query is still not of expect(screen.queryByRole("button", { name: /unsafe-diagram/ })).not.toBeInTheDocument(); }); -test("the Picker reports search results too, so the catalog grows with every query", async () => { - const user = userEvent.setup(); - const observed: Asset[][] = []; - const { gateway } = searchableGateway([PICKER_A, PICKER_B]); - render( - {}} - onAssetsObserved={(assets) => observed.push([...assets])} - />, - ); - - await screen.findByRole("button", { name: /inserted-diagram/ }); - await user.type(screen.getByLabelText("Asset 검색"), "other"); - await user.click(screen.getByRole("button", { name: "검색" })); - - await waitFor(() => assert.equal(observed.length, 2)); - assert.deepEqual( - observed[1]!.map((asset) => asset.assetKey), - ["other-diagram"], - ); -}); - test("a slow earlier Picker search never overwrites the newer query's results", async () => { const user = userEvent.setup(); const pending: Array<{ settle: (page: unknown) => void }> = []; @@ -1822,36 +1729,6 @@ test("a Picker search never drops an already-inserted asset from the authored do assert.ok(markdownSource().value.includes('key="inserted-diagram"')); assert.ok((screen.getByLabelText(/번째 자료/) as HTMLTextAreaElement).value.includes('key="inserted-diagram"')); - expect(screen.queryByRole("region", { name: "즉시 미리보기" })).not.toBeInTheDocument(); -}); - -test("mergeAssetCatalog keeps every previously known asset and lets a fresher copy win", () => { - const known = assetFixture({ id: "50505050-5050-4050-8050-505050505051", assetKey: "known" }); - const staleCopy = assetFixture({ - id: "50505050-5050-4050-8050-505050505052", - assetKey: "replaced", - publicPath: "/media/replaced-old.svg", - updatedAt: "2026-08-14T00:00:00.000Z", - }); - const freshCopy = { ...staleCopy, publicPath: "/media/replaced-new.svg", version: 2 }; - const arrival = assetFixture({ id: "50505050-5050-4050-8050-505050505053", assetKey: "arrival" }); - - const merged = mergeAssetCatalog([known, staleCopy], [freshCopy, arrival]); - - assert.deepEqual( - [...merged].map((asset) => asset.assetKey).sort(), - ["arrival", "known", "replaced"], - ); - assert.equal( - merged.find((asset) => asset.id === staleCopy.id)?.publicPath, - "/media/replaced-new.svg", - ); -}); - -test("mergeAssetCatalog can only grow: an empty arrival keeps everything", () => { - const known = assetFixture({ id: "60606060-6060-4060-8060-606060606061", assetKey: "kept" }); - - assert.deepEqual(mergeAssetCatalog([known], []).map((asset) => asset.id), [known.id]); }); // --- Alignment follow-up, item 3: alt text must not outlive its file --- diff --git a/tests/features/tech-log/evidence-asset-resolver.test.tsx b/tests/features/tech-log/evidence-asset-resolver.test.tsx index 0a38919..176fcc7 100644 --- a/tests/features/tech-log/evidence-asset-resolver.test.tsx +++ b/tests/features/tech-log/evidence-asset-resolver.test.tsx @@ -1,12 +1,17 @@ import assert from "node:assert/strict"; import { test } from "vitest"; +import { findResolvableAsset } from "../../../src/features/tech-log/domain/content-format/asset-evidence-catalog.ts"; import { - createAssetCatalogResolver, createResolvedAssetResolver, MISSING_EVIDENCE_ASSET, } from "../../../src/features/tech-log/presentation/shared/public-render/asset-resolvers.ts"; +/** 서버가 블록에 붙여 보내는 서술자. 화면이 그림을 그릴 때 읽는 것은 이것뿐이다. */ +function figure(asset: Record) { + return [{ type: "EVIDENCE_FIGURE", key: String(asset["assetKey"]), asset }] as never; +} + const READY = { id: "11111111-1111-4111-8111-111111111111", assetKey: "boundary", @@ -26,32 +31,31 @@ const READY = { updatedAt: "2026-08-14T01:00:00.000Z", } as never; -test("resolves a backend asset key to its public path", () => { - const resolve = createAssetCatalogResolver([READY]); - const asset = resolve("boundary"); +test("고를 수 있는 자료를 열쇠로 찾는다", () => { + const found = findResolvableAsset([READY], "boundary"); - assert.equal(asset.src, "/media/boundary.svg"); - assert.equal(asset.width, 1080); - assert.equal(asset.height, 420); + assert.equal(found?.publicPath, "/media/boundary.svg"); + assert.equal(found?.width, 1080); + assert.equal(found?.height, 420); }); test("falls back to the static registry for the legacy hardcoded key", () => { - const resolve = createAssetCatalogResolver([]); + const resolve = createResolvedAssetResolver([]); const asset = resolve("fetch-strategy-boundary"); assert.equal(asset.src, "/media/fetch-strategy-boundary.svg"); }); test("returns the placeholder instead of throwing on an unknown key", () => { - const resolve = createAssetCatalogResolver([]); + const resolve = createResolvedAssetResolver([]); assert.deepEqual(resolve("does-not-exist"), MISSING_EVIDENCE_ASSET); }); -test("never resolves a QUARANTINED asset", () => { - const resolve = createAssetCatalogResolver([ - { ...(READY as object), managementStatus: "QUARANTINED" } as never, - ]); - assert.deepEqual(resolve("boundary"), MISSING_EVIDENCE_ASSET); +test("격리된 자료는 고르지 않는다", () => { + assert.equal( + findResolvableAsset([{ ...(READY as object), managementStatus: "QUARANTINED" } as never], "boundary"), + undefined, + ); }); test("resolves from the server render model blocks", () => { @@ -75,12 +79,12 @@ test("resolves from the server render model blocks", () => { assert.equal(resolve("boundary").width, 800); }); -test("a READY asset wins over a QUARANTINED asset sharing the same key", () => { - const resolve = createAssetCatalogResolver([ - { ...(READY as object), managementStatus: "QUARANTINED" } as never, - READY, - ]); - assert.equal(resolve("boundary").src, "/media/boundary.svg"); +test("같은 열쇠를 가진 격리 자료보다 쓸 수 있는 자료가 이긴다", () => { + const found = findResolvableAsset( + [{ ...(READY as object), managementStatus: "QUARANTINED" } as never, READY], + "boundary", + ); + assert.equal(found?.publicPath, "/media/boundary.svg"); }); test("keeps the legacy key's hand-authored labels when a server block resolves it via descriptor (today's real Preview/Snapshot path)", () => { @@ -109,15 +113,17 @@ test("keeps the legacy key's hand-authored labels when a server block resolves i }); test("a colliding backend descriptor's publicPath wins over the legacy src, but the legacy labels still win", () => { - const resolve = createAssetCatalogResolver([ - { - ...(READY as object), + const resolve = createResolvedAssetResolver( + figure({ + assetId: "11111111-1111-4111-8111-111111111111", assetKey: "fetch-strategy-boundary", + mediaType: "image/svg+xml", publicPath: "/media/should-win.svg", width: 999, height: 111, - } as never, - ]); + decorative: false, + }), + ); const asset = resolve("fetch-strategy-boundary"); assert.equal(asset.src, "/media/should-win.svg"); diff --git a/tests/features/tech-log/evidence-key-agreement.test.ts b/tests/features/tech-log/evidence-key-agreement.test.ts index 5815fb2..aa0053d 100644 --- a/tests/features/tech-log/evidence-key-agreement.test.ts +++ b/tests/features/tech-log/evidence-key-agreement.test.ts @@ -11,14 +11,12 @@ // Against fix round 3's code this reported 53 of 144 combinations disagreeing. // // The callers covered are the mock adapter's projection gate and descriptor -// resolver, `validateWorkingCopy`, the shared pixel resolver, and -- added in -// the final fix wave -- `instant-preview.tsx`'s own gate and descriptor -// resolver. The last pair is byte-parallel to the adapter's (they live in -// different layers: `presentation/` may not import `adapters/`), and is the -// pair three earlier fix rounds regressed. Its one sanctioned divergence is -// the legacy static key's `assetId`, which the assertions below pin rather -// than ignore. Mutating either half of that pair reports 96 and 64 of 144 -// combinations disagreeing respectively. +// resolver, `validateWorkingCopy`, and the pixel resolver every public screen +// renders through (`createResolvedAssetResolver`, reading the descriptor the +// projection attached to the block). The editor's own instant preview used to +// be a fourth caller carrying a byte-parallel copy of the same decision; the +// v4 editor dropped that surface, so the copy is gone and the pair it could +// disagree with no longer exists. import assert from "node:assert/strict"; import { test } from "vitest"; @@ -27,11 +25,10 @@ import type { Asset } from "../../../src/features/tech-log/contracts/studio/cont import { projectWorkingCopy } from "../../../src/features/tech-log/adapters/mock/project-public-render-model.ts"; import { validateWorkingCopy } from "../../../src/features/tech-log/adapters/mock/validate-working-copy.ts"; import { isSupportedEvidenceKey } from "../../../src/features/tech-log/adapters/static/evidence-assets.ts"; -import { createAssetCatalogResolver } from "../../../src/features/tech-log/presentation/shared/public-render/asset-resolvers.ts"; import { - instantPreviewEvidenceKeyGate, - resolveInstantPreviewAssetDescriptor, -} from "../../../src/features/tech-log/presentation/studio/components/instant-preview.tsx"; + bodyBlocksOf, + createResolvedAssetResolver, +} from "../../../src/features/tech-log/presentation/shared/public-render/asset-resolvers.ts"; import { ContentFormatError } from "../../../src/features/tech-log/domain/content-format/parse-case-content.ts"; const LEGACY = "fetch-strategy-boundary"; @@ -162,7 +159,9 @@ function project(key: string, alt: string, assets: readonly Asset[]) { bodyBlocks: Array<{ type: string; asset?: Descriptor }>; }; const figure = model.bodyBlocks.find((block) => block.type === "EVIDENCE_FIGURE"); - return { accepted: true as const, descriptor: figure!.asset! }; + // 화면이 실제로 그림을 그릴 때 읽는 것은 블록에 붙은 서술자다. 같은 모델에서 뽑아야 + // "서술자와 픽셀이 한 자료인가" 를 묻는 의미가 있다. + return { accepted: true as const, descriptor: figure!.asset!, blocks: bodyBlocksOf(model) }; } catch (error) { return { accepted: false as const, error }; } @@ -194,22 +193,13 @@ test("gate, projection resolver, pixel resolver and validation never disagree", const projected = project(key, "a", assets); const report = validate(key, "a", assets); const unsupported = report.issues.some((issue) => issue.code === "EVIDENCE_UNSUPPORTED"); - const pixels = createAssetCatalogResolver(assets)(key); + const pixels = projected.accepted + ? createResolvedAssetResolver(projected.blocks)(key) + : null; // 1. Validation and the preview projection accept exactly the same keys. check(!unsupported === projected.accepted, `${where}: validation and projection disagree`); - // 1b. Instant Preview's gate is a fourth caller of the same decision, - // living in `presentation/` (which may not import `adapters/`) and - // therefore carrying its own copy of the legacy-key predicate. It - // must accept exactly the same keys, in either array order. - const previewAccepts = instantPreviewEvidenceKeyGate(assets)(key); - check(previewAccepts === projected.accepted, `${where}: Instant Preview gate and the projection disagree`); - check( - instantPreviewEvidenceKeyGate([...assets].reverse())(key) === previewAccepts, - `${where}: order-dependent Instant Preview gate`, - ); - if (!projected.accepted) { check(projected.error instanceof ContentFormatError, `${where}: expected a gate rejection, got ${String(projected.error)}`); check( @@ -224,7 +214,7 @@ test("gate, projection resolver, pixel resolver and validation never disagree", check(projected.descriptor.publicPath !== "", `${where}: accepted a key that renders as an empty publicPath`); // 3. The block descriptor and the pixels are the same asset. - check(pixels.src === projected.descriptor.publicPath, `${where}: descriptor (${projected.descriptor.publicPath}) and pixels (${pixels.src}) disagree`); + check(pixels!.src === projected.descriptor.publicPath, `${where}: descriptor (${projected.descriptor.publicPath}) and pixels (${pixels!.src}) disagree`); // 4. The descriptor names an asset that really is in the list and really // is renderable (or the legacy static asset, which is in no list). @@ -246,52 +236,18 @@ test("gate, projection resolver, pixel resolver and validation never disagree", `${where}: order-dependent descriptor (${projected.descriptor.publicPath} vs ${reProjected.descriptor.publicPath})`, ); } - check(createAssetCatalogResolver(reversed)(key).src === pixels.src, `${where}: order-dependent pixels`); + if (reProjected.accepted) { + check( + createResolvedAssetResolver(reProjected.blocks)(key).src === pixels!.src, + `${where}: order-dependent pixels`, + ); + } // 6. The alt rule is judged against the asset that actually renders. const emptyAlt = validate(key, "", assets); const altRequired = emptyAlt.issues.some((issue) => issue.code === "EVIDENCE_ALT_REQUIRED"); check(altRequired === !projected.descriptor.decorative, `${where}: alt rule judged a different asset than the one rendered`); - // 7. Instant Preview's own pair agrees with the mock adapter's. The two - // are byte-parallel expressions in different layers (`presentation/` - // may not import `adapters/`), and the pair regressed in three - // separate fix rounds, so the agreement is asserted rather than - // assumed. The single sanctioned divergence is the legacy static - // key's `assetId`: with no Asset backing it, Instant Preview returns - // a fixed literal where the adapter derives one from the static - // registry. Everything else -- acceptance, path, dimensions, - // mediaType, decorative -- must match exactly, and the divergence is - // pinned so a future change cannot widen it unnoticed. - const previewDescriptor = resolveInstantPreviewAssetDescriptor(assets)(key); - const { assetId: previewAssetId, ...previewRest } = previewDescriptor; - const { assetId: mockAssetId, ...mockRest } = projected.descriptor as unknown as - Record & { assetId: string }; - check( - JSON.stringify(previewRest) === JSON.stringify(mockRest), - `${where}: Instant Preview descriptor differs from the adapter's beyond assetId (${JSON.stringify(previewRest)} vs ${JSON.stringify(mockRest)})`, - ); - check( - /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(previewAssetId), - `${where}: Instant Preview assetId is not a stable UUID (${previewAssetId})`, - ); - check( - (previewAssetId === mockAssetId) === Boolean(assets.some((candidate) => candidate.assetKey === key && candidate.id === mockAssetId)), - `${where}: assetId agreement is not confined to the legacy fallback`, - ); - - // 8. Instant Preview's descriptor and the pixels it renders are one asset. - check( - pixels.src === previewDescriptor.publicPath, - `${where}: Instant Preview descriptor (${previewDescriptor.publicPath}) and pixels (${pixels.src}) disagree`, - ); - - // 9. Order independence holds for Instant Preview's resolver too. - check( - JSON.stringify(resolveInstantPreviewAssetDescriptor([...assets].reverse())(key)) === - JSON.stringify(previewDescriptor), - `${where}: order-dependent Instant Preview descriptor`, - ); } } assert.ok(checked >= 100, `only ${checked} combinations checked`); diff --git a/tests/features/tech-log/section-selector-scope.test.ts b/tests/features/tech-log/section-selector-scope.test.ts index 9ec6d65..53eb283 100644 --- a/tests/features/tech-log/section-selector-scope.test.ts +++ b/tests/features/tech-log/section-selector-scope.test.ts @@ -42,7 +42,6 @@ const SETTLED = new Set([ ".home-path-records li", ".investigation-records li", // 흐름의 마디는 한 모양뿐이다 — 각 li 안에 링크 하나. - ".mechanism-map a", ".studio-warning-check span", ]);