From 52ec6667b6ba3161e126ecb53b4da1021741fd71 Mon Sep 17 00:00:00 2001 From: Sergey Kozyrenko Date: Tue, 30 Jun 2026 13:21:54 +0700 Subject: [PATCH] chore(editor): trim comments that restate code or defend implementation Review follow-ups: - knowledge-form.tsx: drop the DirtyFlags comment (restates the type) and the "backend also wipes subtypes" parenthetical (defends a redundant path). - markdown-editor-extensions.test.ts: drop the roundTrip narration. Co-Authored-By: Claude Opus 4.8 --- .../components/shared/markdown-editor-extensions.test.ts | 2 -- frontend/src/features/knowledges/knowledge-form.tsx | 9 ++------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/shared/markdown-editor-extensions.test.ts b/frontend/src/components/shared/markdown-editor-extensions.test.ts index e9937bc5..515e7102 100644 --- a/frontend/src/components/shared/markdown-editor-extensions.test.ts +++ b/frontend/src/components/shared/markdown-editor-extensions.test.ts @@ -12,8 +12,6 @@ beforeAll(() => { ({ item: () => null, length: 0, [Symbol.iterator]: [][Symbol.iterator] }) as unknown as DOMRectList; }); -// Runs the EXACT production extension set (createMarkdownExtensions) through the official -// @tiptap/markdown round-trip: markdown string -> marked parse -> ProseMirror doc -> getMarkdown(). const roundTrip = (content: string): string => { const editor = new Editor({ content, contentType: 'markdown', extensions: createMarkdownExtensions() }); const out = editor.getMarkdown(); diff --git a/frontend/src/features/knowledges/knowledge-form.tsx b/frontend/src/features/knowledges/knowledge-form.tsx index dc0002a4..3f28f718 100644 --- a/frontend/src/features/knowledges/knowledge-form.tsx +++ b/frontend/src/features/knowledges/knowledge-form.tsx @@ -119,9 +119,6 @@ export const documentToFormValues = (k: KnowledgeDocumentFragmentFragment): Form question: k.question, }); -// react-hook-form's `dirtyFields` is a partial map of the same shape as -// `FormValues`, with `true` for fields the user actually changed compared to -// `defaultValues`. We project it onto the (flat) FormValues keys here. export type DirtyFlags = Partial>; // CREATE: send all required fields and only non-empty optional fields. There @@ -142,10 +139,8 @@ export const formValuesToCreateInput = (values: FormValues): CreateKnowledgeDocu // every other field is gated by `dirty`. This way: // - untouched fields stay `undefined` and the backend keeps the existing value; // - cleared fields go out as `""` so the backend wipes them; -// - subtype-related fields cleared by `setValue` on docType change are -// marked dirty by the form, so they reach the backend with the right -// "clear me" value (the backend additionally wipes mismatching subtypes -// itself, but we mirror the user-visible state explicitly). +// - subtype-related fields cleared by `setValue` on docType change are marked +// dirty by the form, so they reach the backend with the right "clear me" value. export const formValuesToUpdateInput = (values: FormValues, dirty: DirtyFlags): UpdateKnowledgeDocumentInput => { const input: UpdateKnowledgeDocumentInput = { content: values.content };