Repository navigation
✨ Feature(aidp): refactor knowledge base list and creation pages - #4029
Open
cj2026-bit wants to merge 38 commits into
Open
cj2026-bit wants to merge 38 commits into
cj2026-bit wants to merge 38 commits into
Conversation
Split the AIDP knowledge base overview and its file management into two views: a card or table overview with a collapsible three-step guide, an independent name search, a column visibility setting and a full-page file view that restores the previous search, page, view mode and column state. Move creation to a dedicated two-step page under knowledges/create. The first step owns the basic fields, permission and user groups, the safety guard, the knowledge graph, the chunking mode, the models and the retrieval settings; the next step validates locally only and the knowledge base is created once at the final submission, before any file upload. Restore the document download and delete entries that were dropped from the AIDP file list during the v2.6.1 merge, keeping the documented read and edit permission gates. Backend: accept the new create and update fields, validate and serialize the structured graph configuration, forward an explicit disabled safety guard, and expose the optional display metadata (personal/enterprise flag, personal capacity, creator name, document count reliability) on the list response. Formal assets: requirement, feature and D1-D5 case documents for the change, validated in the design phase. Co-authored-by: ZCode <noreply@zcode.ai> Generated-by: deepseek-flash
Problem:
The new knowledge base cards rendered "文件 {count}" and "容量 {value}"
literally, and the same single-brace placeholders broke two validation
messages and the partial deletion summary. i18next only interpolates
{{name}} placeholders, so those strings were shown verbatim.
Fix:
Rewrote the five affected keys in both locales with {{...}} placeholders
and reformatted the locale files.
Verification:
- Browser check on /zh/knowledges: cards now render "文件 0" / "文件 2"
and "容量 —" instead of the raw placeholders.
- Locale files pass prettier formatting.
Co-authored-by: ZCode <noreply@zcode.ai>
Generated-by: deepseek-flash
cj2026-bit
requested review from
Dallas98,
WMC001,
YehongPan,
hhhhsc701 and
jeffwu-1999
as code owners
September 28, 2026 12:06
Sonar reported 4.8% duplicated lines on the new code (threshold 3%). Two blocks were responsible: the knowledge base and document lists carried a line-for-line identical pagination block, and the creation page repeated the same label-with-tooltip JSX six times. - Extracted AidpPagination, now used by both lists, which also removes the duplicated "unreliable total" fallback rule. - Replaced the repeated label blocks with a local fieldLabel() helper. - Removed AidpCreateKbModal, which the dedicated creation page replaced. Verification: tsc --noEmit reports no error in the changed files, and the browser check on /zh/knowledges still renders the guide, card view, document counts and the unknown-value placeholders. Co-authored-by: ZCode <noreply@zcode.ai> Generated-by: deepseek-flash
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…aults codecov/patch requires 90% coverage of the new lines. The new backend helpers carried no unit tests, so patch coverage failed the gate while every build, analysis and type check passed. Added unit tests for the three units this change introduced: - `_serialize_graph_config`: documented keys and defaults, unknown key filtering, domain and prompt-language rejection, the UTF-8 prompt byte limit and the candidate Top K / sub-graph hop ranges. - `_validate_chunking`: the half-of-chunk-size bound, negative overlap, and the non-positive or non-integer inputs it deliberately skips. - `_apply_create_defaults`: chunk mode and graph defaults, graph fields dropped when the graph is disabled and serialized when it is enabled, and an explicit 0 safety guard that must survive the merge. Verification: `pytest test/ext_components/aidp/` — 628 passed (31 new). Co-authored-by: ZCode <noreply@zcode.ai> Generated-by: deepseek-flash
React 19 already declares onResize as a DOM event handler on ThHTMLAttributes, so the custom onResize?: (width: number) => void member of ResizableTitleProps no longer composed with the base interface and broke compilation with TS2430. Omit the inherited member before adding the column-resize callback. Verification: tsc --noEmit reports no error in the AIDP sources; the refactored overview and creation pages were driven end to end in the browser against the AIDP mock (table/menu interactions, create flow submitting chunk_mode, is_exist_graph and an explicit 0 safety guard, then redirecting into the new base's file view). Co-authored-by: ZCode <noreply@zcode.ai> Generated-by: deepseek-flash
The card's more-actions wrapper div carried onClick={stopPropagation} as
a third bubble guard on top of the trigger button's own handler and the
menu item handler. A visible non-interactive element with a click
handler and no keyboard listener fails Sonar rule S1082, which pushed
the new reliability rating to B.
The inner guards already stop propagation, so the wrapper's handler is
removed; the card keeps its own keyboard activation.
Verification: browser regression - the dropdown still opens with
edit/delete/import and clicking a card still opens its file view;
tsc --noEmit is clean for the AIDP sources.
Co-authored-by: ZCode <noreply@zcode.ai>
Generated-by: deepseek-flash
…dcrumb key The file view opened with a "back to knowledge base list" button. The user asked for the breadcrumb form already used by the creation page, so the header now reads 知识库 / 上传文件: the base segment navigates back to the overview and clears the kb query parameter, and the knowledge base name and lifecycle tags stay below it. The creation breadcrumb referenced aidpKnowledge.createBreadcrumbKnowledge, a key that exists in neither locale, so the page rendered the raw key; both pages now share the new breadcrumbKnowledgeBase entry. Verification: browser - the file view shows 知识库 / 上传文件 with the base name below, clicking 知识库 returns to the overview, the creation page no longer leaks the raw key, and tsc --noEmit is clean for the AIDP sources. Co-authored-by: ZCode <noreply@zcode.ai> Generated-by: deepseek-flash
Sidebar menu items push bare paths such as /knowledges. The [locale] route then receives 'knowledges' as the locale and the page crashes inside the i18n initializer (I18nProviderWrapper reads resourcesCustom[locale] with the garbage segment), leaving a blank screen on every sidebar entry. Added a Next.js middleware that redirects any page path without a zh/en prefix to its localized counterpart based on the NEXT_LOCALE cookie; API routes, Next.js internals and public assets bypass it. Verification: browser - /knowledges now redirects to /zh/knowledges and renders the overview; /zh/knowledges renders directly; the /locales JSON files and the frontend API proxy bypass the redirect; curl confirms 307 for bare paths and direct 200 for prefixed and asset paths. Co-authored-by: ZCode <noreply@zcode.ai> Generated-by: deepseek-flash
The locale redirect already ships in origin/develop's frontend/proxy.ts (Next.js 16's middleware-to-proxy migration). Keeping my middleware.ts makes the build fail with 'Both middleware file and proxy file are detected' as soon as the branch merges with develop. Verification: local NODE_ENV=production npm run build compiles with proxy.ts present and middleware.ts removed. Co-authored-by: ZCode <noreply@zcode.ai> Generated-by: deepseek-flash
Sidebar menu entries push bare paths (/knowledges and friends). The production proxy redirects those, but the dev server does not run it, so every sidebar entry crashed the i18n initializer and rendered a blank page (resourcesCustom["knowledges"] is undefined). Prefix each pushed path with the active i18n language; paths that already carry a locale pass through unchanged. Verification: browser - clicking 知识库配置 in the sidebar stays on /zh/knowledges and renders the overview; tsc --noEmit is clean. Co-authored-by: ZCode <noreply@zcode.ai> Generated-by: deepseek-flash
Deliver the AIDP knowledge base overview, creation and detail experiences, and remove the AIDP knowledge-base safety guard contract.
…wledge-base-pages-refactor
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fix
Overview (AIDP only)
is_privatefield, capacity only from a validcurrent_cap, the creator only from a real display name, and the backend now marks whether a document count is a confirmed statistic. Unknown values render as an em dash.Creation page
/knowledges/createrenders a dedicated two-step page. The first step groups basic information, permission and user groups, the safety guard, the knowledge graph, chunking, vector generation and retrieval; the second step optionally uploads files.chunk_mode(0 smart splitting / 1 legal clauses), a 256-4096 chunk token range, an overlap ratio converted tofloor(tokens * percent / 100)integer tokens, similarity, knowledge base Top K, the embedding model, the graph model from thellmcategory, the multimodal model from thevlmcategory, the full graph configuration and the safety guard. Disabling a capability omits its hidden configuration instead of resubmitting it.graph_configstring, and rejects an overlap above half the chunk size.Safety guard
sensitive_intercept_enalbeis submitted as integer 1/0 on create, forwarded explicitly when disabled on update (the metadata whitelist would otherwise drop the 0), and read back in the edit dialog. A response that omits the field is shown as unknown, never as a confirmed disabled state.Restored file operations
Scope
Verification
pytest test/ext_components/aidp/— 597 passed.tsc --noEmitreports zero errors in the changed AIDP sources, types and locales (run against the same dependency versions as the main checkout).python test/tools/validate_test_assets.py --phase design --generate-excelpasses.chunk_mode, a serializedgraph_configstring whoseno_think_modeis inverse to the thinking switch,llm_model_name, integersensitive_intercept_enalbe, and keeps every legacy field and default.graph_configandllm_model_namewhile still submitting the explicit0safety guard.metadata_status: updatedfor the safety guard change.llm,vlm,embedding).文件 {count}); they now use{{count}}.Not covered: the upstream safety guard contract is still under development on the AIDP side, so a real create/update/readback of that field can only be verified after it ships — the mock accepts the field but does not store it. Browser automation could not exercise the column settings popover, the search input and the upload step (the available in-app browser exposes no reliable locator or mouse API for Ant Design portaled widgets); those paths were reviewed in code and the surrounding flows were verified end to end.