Skip to content

refactor(knowledge): add toaster notifications, centralized error handling, and file upload hooks#9024

Open
preetriti1 wants to merge 1 commit intomainfrom
priti/know
Open

refactor(knowledge): add toaster notifications, centralized error handling, and file upload hooks#9024
preetriti1 wants to merge 1 commit intomainfrom
priti/know

Conversation

@preetriti1
Copy link
Copy Markdown
Contributor

@preetriti1 preetriti1 commented Apr 7, 2026

…rd and designer

Commit Type

  • feature - New functionality
  • fix - Bug fix
  • refactor - Code restructuring without behavior change
  • perf - Performance improvement
  • docs - Documentation update
  • test - Test-related changes
  • chore - Maintenance/tooling

Risk Level

  • Low - Minor changes, limited scope
  • Medium - Moderate changes, some user impact
  • High - Major changes, significant user/system impact

What & Why

Added error handling and success / failure notification toasters during create calls.
Refactoring to reuse the code between add file from dialog and drawer

Impact of Change

  • Users: New toaster notifications will show success/failure for connection creation/updating and file uploads; message wording changes for empty-state/placeholders.
  • Developers: New hook (useFileHooks), new ToasterNotification component, changes to createOrUpdateConnection signature (callers must pass isCreate for updates), and new optionsSlice actions (setNotification/clearNotification). Ensure dependent modules update usage where applicable.
  • System:Minor — additional logging and toast dispatching; no new backend/API changes. However, the createOrUpdateConnection function now logs errors and accepts an isCreate flag; callers that relied on the previous signature must be updated.

Test Plan

  • Unit tests added/updated
  • E2E tests added/updated
  • Manual testing completed
  • Tested in:

Contributors

@divyaswarnkar

Screenshots/Videos

Copilot AI review requested due to automatic review settings April 7, 2026 17:32
@preetriti1 preetriti1 added the risk:medium Medium risk change with potential impact label Apr 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

🤖 AI PR Validation Report

PR Review Results

Thank you for your submission! Here's detailed feedback on your PR title and body compliance:

PR Title

  • Current: refactor(knowledge): add toaster notifications, centralized error handling, and file upload hooks
  • Issue: None — the title is clear, follows conventional commit-style scope, and summarizes the main changes.
  • Recommendation: Keep as-is. If you want to be even more specific for reviewers, you can add a short parenthetical noting the main surface area (e.g., ... (connection create/update, file upload)), but this is optional.

Commit Type

  • Properly selected (refactor).
  • Commit Type Note: Only one commit type checked in the PR body and it matches the nature of the changes (restructure and shared behavior). Good.

Risk Level

  • Risk Level Assessment: The PR is labeled risk:medium and the PR body selects "Medium" — these match.
  • Note: Based on the code diff, this is appropriate. The change touches many UI components, the connection creation/update flow, and Redux options state (notifications). The changes are significant in surface area but not introducing new backend contracts; medium is correct.

What & Why

  • Current: "Added error handling and success / failure notification toasters during create calls. Refactoring to reuse the code between add file from dialog and drawer"
  • Issue: The section is accurate but a bit short. The code diff shows additional important details (e.g., createOrUpdateConnection signature change to accept an isCreate flag, new optionsSlice notification fields and actions, new ToasterNotification component, new useFileHooks, and many UI changes and tests). These specifics are mentioned elsewhere in the PR body but the What & Why could call them out more explicitly.
  • Recommendation: Expand the What & Why with 2–3 bullets that explicitly call out the major functional changes so reviewers can quickly understand impact, for example:
    • "createOrUpdateConnection now accepts (parameterValues, isCreate = true) and logs errors via LoggerService. Callers updated for update flows to pass isCreate = false."
    • "Added Redux notification state (optionsSlice notification + actions) and ToasterNotification component wired to show toasts for create/update/upload success/failure."
    • "Extracted file upload logic into useFileHooks and replaced per-panel upload UI with shared TemplatesPanelFooter-driven footerContent."
      This helps reviewers and maintainers scan for potential regressions and places to double-check.

Impact of Change

  • Impact Issue: The PR body lists Users/Developers/System impact; overall good. A few additional, precise reminders would be useful for reviewers:
  • Recommendation:
    • Users: UI will now surface toasts for connection create/update and file upload successes/failures. Some placeholder/empty-state texts changed (verify copy in localization). Ensure localization owners are aware of new/changed strings.
    • Developers: Note the API change to createOrUpdateConnection signature (added isCreate arg, defaulting to true). Confirm all internal callers that expect the previous behavior are compatible (defaults help here), and update any external/internal usage/docs if applicable. Also note new optionsSlice notification state — ensure the root reducer includes this slice and that any consumers of options.notification are updated (you already read usage in KnowledgeHubWizard).
    • System: Minor additional logging and toast dispatching. Ensure logging configuration (LoggerService) is available in all environments and does not leak secrets. Verify that the LoggerService mock in tests aligns with production wiring.

Test Plan

  • Test Plan Assessment: Unit tests were added/updated (diff shows many new/updated unit tests across connection, notification, create/edit panels, file hooks, etc.). Manual testing is indicated and appears reasonable.
  • Recommendation: Consider adding at least one integration/E2E test that exercises the full create-or-update connection workflow and the file upload notification flow (end-to-end) — since those are user-facing flows that involve multiple components, an e2e will help avoid regressions. If E2E is not feasible for this PR, add a short justification in the PR body explaining why (e.g., environment constraints or separate E2E ticket planned).

Contributors

  • Contributors Assessment: @divyaswarnkar listed. Good — remember to credit any other reviewers/designers if they participated.

⚠️ Screenshots/Videos

  • Screenshots Assessment: Optional for this PR. Because these are user-facing UI changes (toasters, messaging), screenshots or a short gif can be helpful for reviewers. Not required, but recommended if you want quicker UX sign-off.

Summary Table

Section Status Recommendation
Title No change needed.
Commit Type Correctly set to refactor.
Risk Level risk:medium is appropriate.
What & Why Expand to name key breaking/behavior changes (createOrUpdateConnection signature, new optionsSlice, useFileHooks) briefly.
Impact of Change Call out update to root reducer/consumers, LoggerService usage, and localization string changes.
Test Plan Unit tests present. Consider adding or explaining lack of E2E tests.
Contributors Contributor listed. Consider adding any additional reviewers/designers.
Screenshots/Videos ⚠️ Optional but recommended for UI toasters and upload flows.

Final Message
Overall this PR is well-structured and follows the repo PR template. It passes the PR title/body checks.
Please consider the small improvements suggested above (expand What & Why, call out the signature and state changes clearly, and either add an E2E test or a short justification for not including one). Also run the full CI and ensure LoggerService wiring and optionsSlice consumption behave correctly in staging. Thank you for the thorough tests and the clear commit.


Last updated: Tue, 07 Apr 2026 17:37:49 GMT

@preetriti1 preetriti1 changed the title fix(knowledge): Error handling and content changes for knowledge wiza… refactor(knowledge): add toaster notifications, centralized error handling, and file upload hooks Apr 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the Knowledge Hub UX in the designer by adding explicit success/failure notifications (toasts and inline error bars) for connection create/update and file upload flows, and refactors duplicated “add file” logic into a shared hook used by both the drawer panel and modal.

Changes:

  • Added notification plumbing via Redux (optionsSlice.notification) and a reusable ToasterNotification component.
  • Added error handling + user-visible error UI for connection create/update, plus success notifications for create/update/upload/group creation.
  • Refactored add-file flows to reuse shared logic (useFileHooks) and updated/added unit tests accordingly.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Localize/lang/strings.json Adds/removes localized strings for new success/failure messages and updated empty-state copy.
libs/designer/src/lib/ui/knowledge/wizard/knowledgelist.tsx Memoizes intl text/columns and dispatches notifications on delete completion.
libs/designer/src/lib/ui/knowledge/wizard/knowledgehub.tsx Shows toaster notifications, wires notification state, and adds toast on group creation/deletion.
libs/designer/src/lib/ui/knowledge/wizard/test/knowledgelist.spec.tsx Updates tests to include Redux provider for new dispatch usage.
libs/designer/src/lib/ui/knowledge/panel/files/useFileHooks.tsx New shared hook for upload footer state, validation, upload handling, and notifications.
libs/designer/src/lib/ui/knowledge/panel/files/uploadfile.tsx Adds success notification on group creation; memoizes intl text.
libs/designer/src/lib/ui/knowledge/panel/files/filelist.tsx Memoizes intl text and column definitions to reduce rerenders.
libs/designer/src/lib/ui/knowledge/panel/files/addfile.tsx Refactors drawer panel to use useFileHooks and dispatch toast notifications.
libs/designer/src/lib/ui/knowledge/panel/connection/usepaneltabs.tsx Adds onCreate/onError callbacks and reports create failures to UI.
libs/designer/src/lib/ui/knowledge/panel/connection/tabs/model.tsx Memoizes intl text.
libs/designer/src/lib/ui/knowledge/panel/connection/tabs/basics.tsx Memoizes intl text.
libs/designer/src/lib/ui/knowledge/panel/connection/edit.tsx Adds inline error MessageBar + success toast; logs via updated core util signature.
libs/designer/src/lib/ui/knowledge/panel/connection/create.tsx Adds inline error MessageBar + success toast via callbacks.
libs/designer/src/lib/ui/knowledge/panel/connection/test/usepaneltabs.spec.tsx Updates hook tests to assert onError behavior instead of console.error.
libs/designer/src/lib/ui/knowledge/panel/connection/test/edit.spec.tsx Updates tests to validate inline error MessageBar rendering.
libs/designer/src/lib/ui/knowledge/panel/connection/test/create.spec.tsx Adds tests for error MessageBar rendering via captured onError.
libs/designer/src/lib/ui/knowledge/notification.tsx New reusable Fluent UI toaster wrapper component with auto-clear behavior.
libs/designer/src/lib/ui/knowledge/modals/delete.tsx Memoizes derived values and intl text; keeps existing delete behavior + notification payload.
libs/designer/src/lib/ui/knowledge/modals/creategroup.tsx Memoizes intl text.
libs/designer/src/lib/ui/knowledge/editor/index.tsx Updates empty-state copy to new localized strings; memoizes intl text.
libs/designer/src/lib/ui/knowledge/editor/files.tsx Refactors modal upload flow to reuse useFileHooks and designer-ui footer.
libs/designer/src/lib/ui/knowledge/editor/connection.tsx Adds inline error MessageBar and wires onError into create-connection tabs.
libs/designer/src/lib/ui/knowledge/editor/test/index.spec.tsx Updates assertions for changed empty-state strings.
libs/designer/src/lib/ui/knowledge/editor/test/files.spec.tsx Updates cancel-button behavior expectation during upload.
libs/designer/src/lib/ui/knowledge/editor/test/connection.spec.tsx Adds tests for error MessageBar rendering via captured onError.
libs/designer/src/lib/ui/knowledge/test/notification.spec.tsx New unit tests for ToasterNotification dispatch behavior and onClear.
libs/designer/src/lib/core/state/knowledge/optionsSlice.ts Adds notification field and actions to set/clear notifications.
libs/designer/src/lib/core/knowledge/utils/connection.ts Adds logging + isCreate flag to distinguish create vs update failures.
libs/designer/src/lib/core/knowledge/utils/test/connection.spec.ts Updates mocks for newly used LoggerService/LogEntryLevel and typing in intl mock.

Comment on lines 1 to 9
import { createSlice } from '@reduxjs/toolkit';
import { initializeData } from '../../actions/bjsworkflow/knowledge';
import type { ServerNotificationData } from '../../../ui/mcp/servers/servers';

export interface OptionsState {
servicesInitialized: boolean;
isDarkMode?: boolean;
notification?: ServerNotificationData;
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OptionsState now depends on ServerNotificationData imported from a UI component module (ui/mcp/servers/servers.tsx). This introduces an undesirable core->UI dependency (and can drag React/UI code into core state builds). Consider moving ServerNotificationData to a shared types module (e.g., core/state/knowledge/types) or defining a local { title: string; content: string } type in the slice and importing it from there in the UI.

Copilot uses AI. Check for mistakes.
intl.formatMessage(
{
id: '+nKZHB',
defaultMessage: `Can't upload file. Please try again. Error: {errorMessage}`,
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultMessage is using a template literal even though it has no JS interpolation. This tends to violate the repo's Biome rule (prefer normal string literals when no interpolation) and can create noisy diffs in localization extraction. Use a normal quoted string for this message.

Suggested change
defaultMessage: `Can't upload file. Please try again. Error: {errorMessage}`,
defaultMessage: "Can't upload file. Please try again. Error: {errorMessage}",

Copilot uses AI. Check for mistakes.
}),
addFilesSectionDescription: intl.formatMessage({
id: 'ifDZq4',
defaultMessage: `Files are added to the specified group. Each file can't exceed 16 MB. Total upload can't exceed 100 MB.`,
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultMessage is a template literal without interpolation. To align with repo linting/formatting conventions (Biome) and avoid unnecessary template strings in localization messages, change this to a normal quoted string.

Suggested change
defaultMessage: `Files are added to the specified group. Each file can't exceed 16 MB. Total upload can't exceed 100 MB.`,
defaultMessage: "Files are added to the specified group. Each file can't exceed 16 MB. Total upload can't exceed 100 MB.",

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +74
defaultMessage: `Confirm that you want to delete these hub artifacts? Deleting a hub deletes all its artifacts. You can't undo this action.`,
id: 'uYxnwQ',
description: 'Content for the delete hub artifacts modal',
}),
hubContent: intl.formatMessage({
defaultMessage: `Confirm that you want to delete this hub? This action also deletes all the hub's artifacts. You can't undo this action.`,
id: 'Xjhrkz',
description: 'Content for the delete hub',
}),
artifactContent: intl.formatMessage({
defaultMessage: `Confirm that you want to delete this artifact? You can't undo this action.`,
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These defaultMessage values are template literals without interpolation. This is inconsistent with the repo's Biome convention (use normal string literals when there are no substitutions) and can trigger lint/format churn. Convert them to normal quoted strings.

Suggested change
defaultMessage: `Confirm that you want to delete these hub artifacts? Deleting a hub deletes all its artifacts. You can't undo this action.`,
id: 'uYxnwQ',
description: 'Content for the delete hub artifacts modal',
}),
hubContent: intl.formatMessage({
defaultMessage: `Confirm that you want to delete this hub? This action also deletes all the hub's artifacts. You can't undo this action.`,
id: 'Xjhrkz',
description: 'Content for the delete hub',
}),
artifactContent: intl.formatMessage({
defaultMessage: `Confirm that you want to delete this artifact? You can't undo this action.`,
defaultMessage: "Confirm that you want to delete these hub artifacts? Deleting a hub deletes all its artifacts. You can't undo this action.",
id: 'uYxnwQ',
description: 'Content for the delete hub artifacts modal',
}),
hubContent: intl.formatMessage({
defaultMessage: "Confirm that you want to delete this hub? This action also deletes all the hub's artifacts. You can't undo this action.",
id: 'Xjhrkz',
description: 'Content for the delete hub',
}),
artifactContent: intl.formatMessage({
defaultMessage: "Confirm that you want to delete this artifact? You can't undo this action.",

Copilot uses AI. Check for mistakes.
description: 'Text for learn more link',
}),
emptyArtifacts: intl.formatMessage({
defaultMessage: `Can't find knowledge base artifacts. Create a knowledge base and upload files to get started.`,
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultMessage is a template literal without interpolation. To match repo linting/formatting conventions and keep localization strings consistent, switch this to a normal quoted string.

Suggested change
defaultMessage: `Can't find knowledge base artifacts. Create a knowledge base and upload files to get started.`,
defaultMessage: "Can't find knowledge base artifacts. Create a knowledge base and upload files to get started.",

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

📊 Coverage Check

The following changed files need attention:

⚠️ libs/designer/src/lib/core/state/knowledge/optionsSlice.ts - 50% covered (needs improvement)
⚠️ libs/designer/src/lib/ui/knowledge/panel/files/addfile.tsx - 75% covered (needs improvement)

Please add tests for the uncovered files before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-validated risk:medium Medium risk change with potential impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants