ENG-2851: [DEMO] Add LLM classification report and Classify with AI button#7528
ENG-2851: [DEMO] Add LLM classification report and Classify with AI button#7528thabofletcher wants to merge 4 commits intomainfrom
Conversation
- Add alphaWebMonitorClassifyWithAI feature flag (separate from config flag) - Add ClassificationReportModal component for viewing LLM classification stats - Add Classify with AI button to DiscoveredAssetsTable - Add classifyWebsiteAssets mutation and getClassificationReport query - Report shows coverage, category distribution, confidence scores, vendor matching Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Greptile SummaryThis PR adds temporary demo UI for LLM classification of website monitor discovered assets. The implementation includes a "Classify with AI" button to trigger classification and a comprehensive classification report modal that displays coverage statistics, category/confidence distributions, vendor matching stats, and sample classifications. Key Changes
Code QualityThe implementation follows existing patterns in the codebase:
Since this is explicitly marked as temporary demo code, the implementation is appropriately focused on functionality over long-term maintainability. Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 6bb5357 |
speaker-ender
left a comment
There was a problem hiding this comment.
Minor color alignments with theme
...min-ui/src/features/data-discovery-and-detection/action-center/ClassificationReportModal.tsx
Outdated
Show resolved
Hide resolved
...min-ui/src/features/data-discovery-and-detection/action-center/ClassificationReportModal.tsx
Outdated
Show resolved
Hide resolved
...min-ui/src/features/data-discovery-and-detection/action-center/ClassificationReportModal.tsx
Outdated
Show resolved
Hide resolved
c45fb22 to
bea8e75
Compare
📝 WalkthroughWalkthroughThis PR introduces AI-based classification functionality for website assets in the data discovery module. It adds a new modal component for viewing classification reports, creates API endpoints for triggering classification and retrieving reports, integrates the feature into the assets table with a new action button, and gates the functionality behind a feature flag. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant UI as DiscoveredAssetsTable
participant Hook as useDiscoveredAssetsTable
participant Mutation as classifyWebsiteAssets<br/>(API)
participant API as Backend
participant Modal as ClassificationReportModal
participant Query as getClassificationReport<br/>(API)
User->>UI: Clicks "Classify with AI"
UI->>Hook: handleClassifyWithAI(monitorId, selectedUrns)
Hook->>Mutation: Invoke mutation with params
Mutation->>API: POST /classify-assets
API-->>Mutation: MonitorActionResponse
Mutation-->>Hook: Success/Error
Hook-->>UI: Toast notification
UI->>User: Display success/error message
User->>UI: Clicks "Report" button
UI->>Modal: Opens ClassificationReportModal (open=true)
Modal->>Query: useGetClassificationReportQuery(monitorId)
Query->>API: GET /classification-report
API-->>Query: WebsiteClassificationReport
Query-->>Modal: Report data
Modal->>Modal: Render report sections (coverage, distribution, resources, etc.)
Modal-->>User: Display detailed classification report
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
clients/admin-ui/src/features/data-discovery-and-detection/action-center/ClassificationReportModal.tsx (1)
317-320: Use a nullish check for numeric confidence rendering.Line 318 uses a truthy check; a valid
0confidence would render as"-". Prefer explicit null/undefined checks.♻️ Proposed fix
- render: (score: number) => - score ? ( + render: (score?: number) => + score !== null && score !== undefined ? ( <Tag color={getConfidenceColor(score)}>{score}</Tag> ) : ( "-" ),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@clients/admin-ui/src/features/data-discovery-and-detection/action-center/ClassificationReportModal.tsx` around lines 317 - 320, The confidence cell renderer in ClassificationReportModal.tsx uses a truthy check (render: (score: number) => score ? ...) which treats 0 as falsy and shows "-" incorrectly; change the condition to an explicit nullish check (e.g., score != null or score !== null && score !== undefined) so that 0 is rendered inside <Tag color={getConfidenceColor(score)}>{score}</Tag> while null/undefined still render the fallback.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@clients/admin-ui/src/features/data-discovery-and-detection/action-center/ClassificationReportModal.tsx`:
- Around line 49-59: getCategoryColor currently calls category.toLowerCase()
without guarding for undefined/null which can crash when items have optional
category; update getCategoryColor to first coerce or guard the incoming category
(e.g., treat undefined/null as "unknown" or an empty string) before calling
toLowerCase, then look up the colors map (advertising, analytics, social_media,
functional, essential, unknown) and return the default tag when no match; ensure
the function signature and callers (getCategoryColor) handle optional string
input safely.
In
`@clients/admin-ui/src/features/data-discovery-and-detection/action-center/hooks/useDiscoveredAssetsTable.tsx`:
- Around line 627-631: The toast message in useDiscoveredAssetsTable.tsx
currently states "Classification complete..." but the mutation is
task-based/async; update the message passed to successToastParams (where toast
is called with selectedUrns and successToastParams) to reflect that the
operation was started/queued (e.g., "Classification started for {count}
uncategorized assets." or "Classification queued for {count} uncategorized
assets.") so it doesn't imply immediate completion.
---
Nitpick comments:
In
`@clients/admin-ui/src/features/data-discovery-and-detection/action-center/ClassificationReportModal.tsx`:
- Around line 317-320: The confidence cell renderer in
ClassificationReportModal.tsx uses a truthy check (render: (score: number) =>
score ? ...) which treats 0 as falsy and shows "-" incorrectly; change the
condition to an explicit nullish check (e.g., score != null or score !== null &&
score !== undefined) so that 0 is rendered inside <Tag
color={getConfidenceColor(score)}>{score}</Tag> while null/undefined still
render the fallback.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 60b04f3a-ea48-47c1-885d-8bd3bd1cef55
📒 Files selected for processing (5)
clients/admin-ui/src/features/data-discovery-and-detection/action-center/ClassificationReportModal.tsxclients/admin-ui/src/features/data-discovery-and-detection/action-center/action-center.slice.tsclients/admin-ui/src/features/data-discovery-and-detection/action-center/hooks/useDiscoveredAssetsTable.tsxclients/admin-ui/src/features/data-discovery-and-detection/action-center/tables/DiscoveredAssetsTable.tsxclients/admin-ui/src/flags.json
| const getCategoryColor = (category: string): TagColor => { | ||
| const colors: Record<string, TagColor> = { | ||
| advertising: "error", | ||
| analytics: "minos", | ||
| social_media: "nectar", | ||
| functional: "success", | ||
| essential: "info", | ||
| unknown: "default", | ||
| }; | ||
| return colors[category.toLowerCase()] || "default"; | ||
| }; |
There was a problem hiding this comment.
Guard category normalization to prevent runtime crashes.
getCategoryColor assumes category is always defined, but flagged/sample items can have optional category. Calling .toLowerCase() on undefined will throw at runtime (e.g., Line 245 usage path).
🐛 Proposed fix
-const getCategoryColor = (category: string): TagColor => {
+const getCategoryColor = (category?: string): TagColor => {
const colors: Record<string, TagColor> = {
advertising: "error",
analytics: "minos",
social_media: "nectar",
functional: "success",
essential: "info",
unknown: "default",
};
- return colors[category.toLowerCase()] || "default";
+ if (!category) {
+ return "default";
+ }
+ return colors[category.toLowerCase()] || "default";
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const getCategoryColor = (category: string): TagColor => { | |
| const colors: Record<string, TagColor> = { | |
| advertising: "error", | |
| analytics: "minos", | |
| social_media: "nectar", | |
| functional: "success", | |
| essential: "info", | |
| unknown: "default", | |
| }; | |
| return colors[category.toLowerCase()] || "default"; | |
| }; | |
| const getCategoryColor = (category?: string): TagColor => { | |
| const colors: Record<string, TagColor> = { | |
| advertising: "error", | |
| analytics: "minos", | |
| social_media: "nectar", | |
| functional: "success", | |
| essential: "info", | |
| unknown: "default", | |
| }; | |
| if (!category) { | |
| return "default"; | |
| } | |
| return colors[category.toLowerCase()] || "default"; | |
| }; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@clients/admin-ui/src/features/data-discovery-and-detection/action-center/ClassificationReportModal.tsx`
around lines 49 - 59, getCategoryColor currently calls category.toLowerCase()
without guarding for undefined/null which can crash when items have optional
category; update getCategoryColor to first coerce or guard the incoming category
(e.g., treat undefined/null as "unknown" or an empty string) before calling
toLowerCase, then look up the colors map (advertising, analytics, social_media,
functional, essential, unknown) and return the default tag when no match; ensure
the function signature and callers (getCategoryColor) handle optional string
input safely.
| const count = selectedUrns.length > 0 ? selectedUrns.length : "all"; | ||
| toast( | ||
| successToastParams( | ||
| `Classification complete for ${count} uncategorized assets.`, | ||
| `Confirmed`, |
There was a problem hiding this comment.
Avoid “complete” wording if classification is async/queued.
The mutation response model is task-based, so Line 630 can overstate completion. Use “started/queued” messaging to avoid false confirmation.
✏️ Proposed fix
- const count = selectedUrns.length > 0 ? selectedUrns.length : "all";
+ const count = selectedUrns.length > 0 ? selectedUrns.length : "all";
toast(
successToastParams(
- `Classification complete for ${count} uncategorized assets.`,
+ `Classification started for ${count} uncategorized assets.`,
`Confirmed`,
),
);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const count = selectedUrns.length > 0 ? selectedUrns.length : "all"; | |
| toast( | |
| successToastParams( | |
| `Classification complete for ${count} uncategorized assets.`, | |
| `Confirmed`, | |
| const count = selectedUrns.length > 0 ? selectedUrns.length : "all"; | |
| toast( | |
| successToastParams( | |
| `Classification started for ${count} uncategorized assets.`, | |
| `Confirmed`, |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@clients/admin-ui/src/features/data-discovery-and-detection/action-center/hooks/useDiscoveredAssetsTable.tsx`
around lines 627 - 631, The toast message in useDiscoveredAssetsTable.tsx
currently states "Classification complete..." but the mutation is
task-based/async; update the message passed to successToastParams (where toast
is called with selectedUrns and successToastParams) to reflect that the
operation was started/queued (e.g., "Classification started for {count}
uncategorized assets." or "Classification queued for {count} uncategorized
assets.") so it doesn't imply immediate completion.
Ticket ENG-2851
This PR contains temporary code for sales demonstrations. It should not be considered production-ready and may be removed or significantly refactored before general release.
Description Of Changes
Adds demo UI for LLM classification of website monitor discovered assets. This includes a "Classify with AI" button and a classification report modal to showcase LLM classification capabilities.
Code Changes
alphaWebMonitorClassifierDemoUIfeature flag for demo UI componentsClassificationReportModalshowing:Related PRs
Steps to Confirm
alphaWebMonitorClassifierDemoUIfeature flagPre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and worksSummary by CodeRabbit