Skip to content

fix(kb): show man-page fact titles with a section name (#21037) - #21072

Closed
mrveiss wants to merge 4 commits into
mainfrom
issue-21037-manpage-titles
Closed

mrveiss wants to merge 4 commits into
mainfrom
issue-21037-manpage-titles

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Thinking Path

KB man-page facts were shown by their raw stored title, which carries no section name. One formatter now builds the display title from the fact's metadata, so every surface renders the same text. The stored title, key, search and sort are left alone, so nothing that indexes or orders facts changes.

What Changed

  • formatManPageTitle in utils/formatHelpers.ts renders "name, section N:
    ", keyed on metadata.type === 'man_page'.
  • Used by KnowledgeEntries.vue, KBSearchResultPanel.vue, TreeNodeComponent.vue and KnowledgeContentViewer.vue.
  • en.json gains the knowledge.manSection.* keys (English only for now).
  • Stored title, key, search and sort are unchanged.

Verification

  • 8 tests in utils/__tests__/knowledgeTitle.spec.ts; 3 of them fail on the old behaviour.
  • 162 vitest tests pass.

Model Used

Claude Sonnet 5.5

Single-issue rationale: the formatter and its four call sites are one display change with no sibling issue in the same scope.

Refs #21037 (AC4 needs host evidence on the owner's install before the issue closes)

@mrveiss mrveiss added this to the M3 - Refined GUI complete milestone Nov 7, 2026
@mrveiss mrveiss added the phase:M3.3 Shared kit primitives label Nov 7, 2026
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@mrveiss

mrveiss commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Code review (code-reviewer pass) at 60d0468

Verdict: CHANGES. 7 files changed, 78 behind main (needs a sync before CI). First review of this PR.

# Severity Where Finding Fix
1 Medium PR body It says Closes #21037, but the issue's fourth criterion (host evidence on the live knowledge-base view) is not delivered, and the criteria are unticked. A merge would auto-close the issue. Change to Refs #21037; close after host evidence.
2 Medium The four call sites (KnowledgeEntries, KBSearchResultPanel, TreeNodeComponent, KnowledgeContentViewer) Tests cover only the pure formatter. Nothing checks that each surface passes the right field: the store types document.type as document, webpage, api, upload, and the tree and viewer read metadata.metadata.type. A wrong field renders the raw title silently, which is the very defect being fixed. Whether the search-result payload and the tree nodes carry type: man_page is not shown in the diff. Add one mount test per surface with a man_page fact and a control locale, asserting the section text; show where each payload carries the type.
3 Low KnowledgeDocumentsBranch.vue, KnowledgeSystemDocs.vue These also render doc.title as a list or detail view. The criterion says lists and detail views; say whether they can hold man-page facts, otherwise route them through the formatter. Confirm or wire in.
4 Low knowledgeTitle.spec.ts The "stored record untouched" test freezes an object and calls a pure function, so it cannot fail. Assert on the rendered component that the raw title stays as the title attribute or key.
5 Info formatHelpers.ts MAN_PAGE_TYPES includes manual_page, whose titles are man <cmd> with no section, so they pass through unchanged. Harmless. None.

Checked and fine: section names come from one knowledge.manSection.* map, no hard-coded strings; two sections of one command are told apart (tested); formatter is under 30 lines; no duplicate helper found; stored title, key, search and sort are untouched; no sleeps.

Threads: none unresolved.

@mrveiss

mrveiss commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Code review (code-reviewer pass) follow-up at 2cc7378

Where the backend puts the man-page type. ManPageContent.get_metadata_for_storage (services/man_page_parser.py) writes metadata.type = "man_page" and title = "man <cmd>(<N>)". _get_man_page_metadata (api/knowledge_population.py) writes "manual_page", with no section in the title. Each view gets that metadata as follows:

View, data source Where type arrives Before Now
KnowledgeEntries: GET /entries → _format_knowledge_entry → KnowledgeController.loadAllDocuments entry.metadata.type. The controller collapsed it into doc.type through determineDocumentType (document/webpage/api/upload), so doc.type was never man_page. Wrong field: the raw title was always shown The controller keeps the raw value as doc.metadata.factType. All 3 call sites (table, view dialog, bulk-edit list) read metadata?.factType.
KBSearchResultPanel: POST /search → KnowledgeRepository.searchKnowledge hit metadata.type, copied raw into document.type Correct by accident (the TS type says the four-value union) Reads document.metadata?.factType, the same field as every other KnowledgeDocument. The two identical hit mappers (searchKnowledge, getSimilarDocuments) are now one: toSearchResult.
TreeNodeComponent / KnowledgeContentViewer: browse nodes from GET /facts/by_category (_process_fact_data → buildNestedTree) node.metadata.type: the fact metadata, flat Wrong field (metadata.metadata.type): the raw title on every browse node knowledgeNodeFactType() in utils/formatHelpers.ts reads both node shapes
same, folder nodes lazy-loaded from POST /search (loadFolderContents) node.metadata.metadata.type: the whole hit, nested Correct Unchanged, now read through the same helper
Item How it is addressed
MED 1: component tests for the call sites components/knowledge/__tests__/manPageTitle.callSites.test.ts: one test each for TreeNodeComponent, KnowledgeContentViewer, KBSearchResultPanel and KnowledgeEntries. Control locale, so a hard-coded label cannot pass.
MED 2: payload shapes match the backend Every fixture is a backend payload: storage metadata from get_metadata_for_storage, a /search hit, a _format_knowledge_entry row. Both tree-node shapes are covered. The panel's results come from the real KnowledgeRepository.searchKnowledge with only post stubbed. The entries test stubs knowledgeRepository.get, so the real controller maps the row into the store. Mutation check: with the old fields restored, the TreeNodeComponent and KnowledgeEntries tests fail (2 failed / 2 passed).
LOW 3: KnowledgeDocumentsBranch.vue / KnowledgeSystemDocs.vue Neither can show a man page, so the formatter is not wired into them. KnowledgeDocumentsBranch lists AI documents (useAIDocument → GET /documents → api/documents.py::list_documents). Those are AIDocument records under autobot:ai_document:* with user-authored titles (models/document.py::AIDocument), not KB facts, and they have no fact type. KnowledgeSystemDocs lists markdown files (/system-docs/category/* → services/knowledge/system_docs_service.py::list_category_docs, which globs *.md under PATH.DOCS_DIR). Their titles come from _extract_title(path, path.stem).
LOW 4: the "stored record untouched" test could not fail Dropped from utils/__tests__/knowledgeTitle.spec.ts. The formatter takes primitives, so a frozen object proves nothing. AC 3 is now asserted at component level: after KnowledgeEntries renders the formatted label, useKnowledgeStore().documents[].title is still man gettext(1).

Also: scripts/frontend_file_size_known_large.py lowers the KnowledgeRepository.ts ceiling from 897 to 890, because merging the two mappers removed 7 lines. KnowledgeController.ts and useKnowledgeStore.ts stay at their ceilings.

Verified locally from a scratch copy: vitest 16/16 on the new spec, knowledgeTitle.spec.ts, TreeNodeComponent.zeroSize and KnowledgeEntries.xss. ESLint is clean on the touched files, and vue-tsc --noEmit -p tsconfig.app.json reports no errors in them. The branch is synced with main.

@mrveiss

mrveiss commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Code review (code-reviewer pass) at 2cc7378

Verdict: APPROVE. 12 files changed, 0 behind main. Reviewed the author commits 66d128d and 7cc10ca since 60d0468. No unresolved threads.

# Prior finding Result at this head
1 Body said Closes #21037 while AC4 needs host evidence Fixed: the body now ends Refs #21037.
2 Raw type kept as metadata.factType through one mapper Verified. toSearchResult in KnowledgeRepository.ts is called from searchKnowledge and getSimilarDocuments and sets metadata: { factType: meta?.type }. A grep for fact_id || .*node_id finds only the one definition, so no copy remains. KnowledgeController sets factType from metadata.type and KnowledgeDocument.metadata.factType is typed.
3 Call-site tests manPageTitle.callSites.test.ts mounts all 4 components (TreeNodeComponent, KnowledgeContentViewer, KBSearchResultPanel, KnowledgeEntries) with backend-shaped payloads and a control locale, so a hard-coded label cannot pass. The author's mutation check with the old fields restored fails 2 of the 4 (TreeNode, Entries). The panel's old field was correct by accident, so that test is a positive pin, not a regression catcher. Acceptable.
4 DocumentsBranch and SystemDocs never show KB facts Verified. KnowledgeDocumentsBranch lists AI documents from useAIDocument.fetchDocuments, and KnowledgeSystemDocs lists markdown files from the system-docs endpoints. Neither reads KB fact records, so neither needs the formatter.
5 Cannot-fail test Dropped from knowledgeTitle.spec.ts. The "stored title stays raw" assertion now runs at component level (useKnowledgeStore().documents[].title is still man gettext(1) after render).
# Severity Where Finding
A nit KnowledgeController.ts:445 The closing brace sits on the factType line; a trailing comma and a separate brace would match the surrounding style.
B nit KnowledgeEntries.vue bulk-edit It formats from doc.metadata?.factType, which only the controller path fills. Any other store writer would show the raw title; none found today.

This was referenced Nov 7, 2026
@mrveiss

mrveiss commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

Landed on main in merge train T98c (#21182), merge commit e28fed6. Closing as landed; the owning session handles the linked-issue closure (with AC evidence) and the branch/worktree disposal.

@mrveiss mrveiss closed this Nov 8, 2026
timothybrush pushed a commit to timothybrush/AutoBot-AI that referenced this pull request Nov 9, 2026
@mrveiss mrveiss reopened this Nov 18, 2026
@mrveiss

mrveiss commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Branch audit (zero-change deletion). This PR shows 0 changed files against main (head 11ea4bcaf6): every change it carried is already in main. Closing and deleting the branch through this PR; it can be restored with the Restore branch button below.

@mrveiss mrveiss closed this Nov 18, 2026
@mrveiss
mrveiss deleted the issue-21037-manpage-titles branch November 18, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase:M3.3 Shared kit primitives

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant