add GitHub organization metadata filtering - #182
Conversation
…viewer drawer - Extend `ArtifactType` union with `ORG_METADATA` and add optional `metadata` string to `Artifact` interface. - Add `orgMetadata.ts` containing the TypeScript types (`OrgMetadataArtifactMetadata`, `OrgMetadataTeam`, etc.) mirroring the backend DTO and a tolerant JSON parser `parseOrgMetadata`. - Add "Organization" filter tab (`ORGANIZATIONS`) to `tabs.ts` and wire it into the `useKnowledgeBase` filter switch. - Update `ArtifactList` with a dedicated `Building2` icon and "Organization" chip label for org artifacts. - Update `ArtifactViewerDrawer` to skip the content fetch for `ORG_METADATA` (preventing unwanted 302 redirects to GitHub HTML), render the full org profile (description, location, blog, repo counts, teams, and members), and hide the "Summarise" action. - Add unit tests for `parseOrgMetadata`, hook tab filtering/search combination, and drawer rendering.
|
idk when they will adress the bug, but i gues the PR can be already be reviewed |
- Structural guard in parseOrgMetadata: reject payloads where login is not a string or members is not an array before the unchecked �s cast. Previously a backend payload with members: null would pass the plain-object check and crash the viewer when calling members.length or members.map(). - Add missing test case in orgMetadata.test.ts covering structurally invalid payloads (members: null, missing login) that previously slipped past the parser undetected. - Fix KnowledgeTab import in useKnowledgeBase.ts: import from the canonical ../tabs module instead of indirectly through ../components/ArtifactFilters. - Harden normalizeUrl: trim the input and reject strings shorter than 4 chars before prepending https://, preventing nonsense links like https://N/A from being rendered when the backend stores an invalid blog value. - Fix incorrect doc comment on OrgProfileRow (said 'health-check info row' - copy-paste error). - Clarify OrgMetadataView doc comment: teams are always fully expanded, not collapsible as the previous wording implied. Tests: 1873 passed (256 files), 0 failures. TypeScript: 0 errors.
|
Read the whole diff including One thing worth fixing
{team.members.length > 0 && (
<ul …>{team.members.map((member) => …)}</ul>
)}A team object without ( Nits
Not approving yet per the merge sequence in the description — just flagging that I have nothing blocking here. Reviewed with Claude Code. |
…docs
- parseOrgMetadata now rejects a payload whose `teams` is present but not an
array, or whose team entries lack a `members` array. The existing guard only
covered the top-level `members`; the viewer maps over `team.members` for every
team it renders, so a team without one raised the identical TypeError the
top-level check was added to prevent.
- Rename the Knowledge Base filter tab to "Organizations" so it matches its
siblings (Uploads / Issues / Files / Commits). The per-artifact chip stays
singular — it labels one artifact.
- Fix the `Artifact.metadata` doc, which claimed the field is "always present"
while typing it optional. Says why it is optional instead.
- Replace the `{@link ArtifactType.ORG_METADATA}` reference: ArtifactType is a
union, not an enum, so the member link never resolved.
- Rewrite the garbled getTypeLabel comment.
Tests: 1875 passed (256 files). tsc -b, eslint, vite build clean.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Reviewed and pushed a small follow-up commit to this branch (as invited in the PR description). No behaviour change beyond the guard below. One real bug
{team.members.length > 0 && ( … team.members.map(…) )}So a team object without a Small stuff, same commit
Left alone deliberately
Verified on the branch: Otherwise this looks good — the tolerant parser with the structural guard, the |
DavidLeuter
left a comment
There was a problem hiding this comment.
Approving. Re-read the branch as it stands (709f873) and, more to the point, tested what it actually looks like on top of today's dev — the branch forked at d815ae2 and dev has moved 17 commits since, so "green on the branch" and "green on merge" had stopped being the same claim.
Backmerge verified locally
Merged origin/dev into the branch in a scratch worktree. Clean, no conflicts, and nothing to reconcile by hand: those 17 commits are the chat/buddy rail, the widget picker and the dashboard edit mode, and they touch no file this PR touches. The knowledge-base feature is genuinely independent of them.
On the merge result: tsc -b, eslint . and vite build clean, 1904 of 1905 tests pass. The one failure is useChat.test.tsx > exposes stopStreaming function that can abort a stream, which
- this PR does not touch (nothing here goes near the chatbot),
- passes in isolation on the merge result and on plain
dev, and - failed on a run whose suite took 547s on a loaded machine.
So: a timing-sensitive abort test flaking under parallel load, pre-existing on dev. Not this branch's problem, but worth someone pinning that test's clock at some point.
On the code
Nothing new to add over the last round. The structural guard in parseOrgMetadata now covers both levels — a top-level members that isn't an array, and any teams[] entry without one — so the viewer can't be handed a shape it dereferences blindly. Rejecting the whole payload rather than the single bad team is the right call: it keeps the one contract callers rely on (unusable metadata means the quiet empty state) instead of introducing a third, half-populated one.
skipContentLoad around the content endpoint's 302 is the neat part. The artifact has no stored bytes, so not asking for them is the honest fix rather than swallowing the error afterwards.
Merge order
Per the description this can go in whenever, independently of #183, and must land before #185. Nothing I found changes that. Given how far dev has moved, backmerge before you merge.
Reviewed with Claude Code.
Backmerge before review: the branch forked at d815ae2 and dev has moved 17 commits since. Merged clean, no conflicts. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Note
Merge & Review Sequence (Step 2 of 4)
dev(Independent foundation for Knowledge Base org metadata)devbefore Feature/269 confluence connector #185 (feature/269-confluence-connector).📌 Summary
This PR introduces full frontend support for GitHub organization-level metadata artifacts (
ORG_METADATA) in the Knowledge Base feature. It adds the dedicated Organization filter tab, organization-specific badge chip and iconography, resilient JSON metadata parsing, and an enhanced viewer drawer displaying comprehensive organization profile details without triggering unwanted redirects.🔗 Related Issue
Closes #293
🛠️ Key Changes & Architectural Improvements
1. Types & Tolerant Parsing (
src/features/knowledge-base/)ArtifactType: Added"ORG_METADATA"to the union type intypes.ts.metadataproperty: Added optionalmetadata?: stringto theArtifactinterface for backend-serialized JSON payloads.orgMetadata.ts: Defined explicit TypeScript interfaces (OrgMetadataArtifactMetadata,OrgMetadataTeam,OrgMetadataMember) and implementedparseOrgMetadata(), a resilient parser that safely handles nulls, empty strings, and malformed JSON with graceful fallbacks and structurally invalid payloads (missing login or non-array members.2. Knowledge Base Filtering & Navigation
ORGANIZATIONSFilter Tab: Added{ id: "ORGANIZATIONS", label: "Organization" }toTABSintabs.ts.useKnowledgeBaseHook: Wired tab filter switch to matchartifact.artifactType === "ORG_METADATA"and handle search combination and pagination reset.3. Visuals & Artifact Viewer Drawer
Building2icon fromlucide-reactand an"Organization"badge chip inArtifactList.tsx.skipContentLoad: trueforORG_METADATAartifacts, preventing unwanted 302 redirects to GitHub HTML.OrgMetadataView): Renders bio, location, blog/website, email, repository counts, fully expanded teams with member badges, and direct GitHub profile links.🗂️ Modified Files Summary
src/features/knowledge-base/types.tsORG_METADATAartifact type andmetadata?: stringsrc/features/knowledge-base/orgMetadata.tsparseOrgMetadatahelpersrc/features/knowledge-base/tabs.tsORGANIZATIONSfilter tabsrc/features/knowledge-base/hooks/useKnowledgeBase.tssrc/features/knowledge-base/components/ArtifactList.tsxBuilding2icon and Organization badgesrc/features/knowledge-base/components/ArtifactViewerDrawer.tsxOrgMetadataView) & skip content loadtests/unit/features/knowledge-base/orgMetadata.test.tstests/unit/features/knowledge-base/hooks/useKnowledgeBase.test.tstests/unit/features/knowledge-base/components/ArtifactViewerDrawer.test.tsx🧪 Verification & Quality Assurance
Automated Checks
prettier --check .tsc -b && vite buildeslint .vitest runManual Verification
ORG_METADATAartifacts withBuilding2icon.📋 Definition of Done (DoD)
anyleaks.💡 Reviewer Guidance: Please review with Claude Code and commit/push any fixes directly to this branch.