-
Notifications
You must be signed in to change notification settings - Fork 155
refactor: clean up code across multiple files #647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
…ce from BaseSettings and DatasourcePayloadConstructor
There was a problem hiding this 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 refactoring pull request focuses on code cleanup, bug fixes, and maintainability improvements across backend Python, frontend TypeScript/React, and data processing scripts. The changes include fixing resource management patterns, improving inheritance initialization, removing dead code, and cleaning up test files.
Key changes:
- Added proper
super().__init__()calls in Python test page classes to ensure correct inheritance chain initialization - Improved file handling by switching to context managers in data processing scripts
- Removed unused imports, variables, and dead code across frontend components and tests
- Fixed indentation bug in
cosmosdbservice.pyto ensure proper return value handling - Cleaned up unreachable code after error handling in
Chat.tsx
Reviewed changes
Copilot reviewed 35 out of 36 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e-test/pages/homePage.py | Added super().__init__(page) call to properly initialize parent BasePage class |
| tests/e2e-test/pages/generatePage.py | Added super().__init__(page) call to properly initialize parent BasePage class |
| tests/e2e-test/pages/draftPage.py | Added super().__init__(page) call to properly initialize parent BasePage class |
| tests/e2e-test/pages/browsePage.py | Added super().__init__(page) call to properly initialize parent BasePage class |
| src/frontend/src/test/test.utils.tsx | Removed unused Conversation import from test utilities |
| src/frontend/src/state/AppReducer.tsx | Fixed missing braces and improved code formatting; removed redundant variable assignment |
| src/frontend/src/state/AppProvider.tsx | Removed unused historyList import |
| src/frontend/src/pages/landing/Landing.tsx | Removed unused React hook imports (useRef, useState, useEffect, useLayoutEffect) |
| src/frontend/src/pages/draft/Draft.tsx | Removed unused useLocation import and variable |
| src/frontend/src/pages/draft/Draft.test.tsx | Removed unused imports (BrowserRouter, Section, Packer, Paragraph, TextRun, defaultMockState) |
| src/frontend/src/pages/document/Document.tsx | Removed unused error state variable |
| src/frontend/src/pages/chat/Components/ChatMessageContainer.tsx | Removed unused React hook imports |
| src/frontend/src/pages/chat/Components/ChatMessageContainer.test.tsx | Removed unused Citation import; fixed semicolon and escaped dollar sign in test assertion |
| src/frontend/src/pages/chat/Components/AuthNotConfigure.test.tsx | Removed unused styles import |
| src/frontend/src/pages/chat/Chat.tsx | Removed unused imports, variables, and modal-related code; cleaned up unreachable null checks for resultConversation; prefixed unused state variables with underscore |
| src/frontend/src/pages/chat/Chat.test.tsx | Removed unused imports and mock variables |
| src/frontend/src/helpers/helpers.ts | Removed unused imports (Conversation, ToolMessageContent, Citation) |
| src/frontend/src/constants/chatHistory.test.tsx | Removed unused Conversation import |
| src/frontend/src/components/Sidebar/Sidebar.tsx | Removed unused icon imports and dead useEffect code that had no side effects |
| src/frontend/src/components/Sidebar/Sidebar.test.tsx | Removed unused imports (act, useNavigate) and unused mock variable |
| src/frontend/src/components/QuestionInput/QuestionInput.test.tsx | Removed unused SendRegular import |
| src/frontend/src/components/FeatureCard/FeatureCard.test.tsx | Removed unused destructured variables from test render results |
| src/frontend/src/components/DraftCards/TitleCard.test.tsx | Removed unused contextValue constant |
| src/frontend/src/components/ChatHistory/chatHistoryListItem.test.tsx | Removed unused imports and mock conversation variable |
| src/frontend/src/components/ChatHistory/ChatHistoryPanel.test.tsx | Removed unused imports (historyDeleteAll, historyList) |
| src/frontend/src/components/ChatHistory/ChatHistoryListItem.tsx | Removed unused tooltipStyles variable |
| src/frontend/src/components/Answer/Answer.tsx | Removed unused filePathTruncationLimit variable; added more specific type annotations for feedback state variables |
| src/frontend/src/components/Answer/Answer.test.tsx | Removed unused imports and mock variables |
| src/frontend/src/api/models.ts | Removed unused Plotly import |
| src/frontend/mocks/react-markdown.tsx | Cleaned up mock by removing unused mock variables and inlining values in commented code |
| src/backend/settings.py | Added cooperative multiple inheritance support to DatasourcePayloadConstructor; added __init__ to _AzureSearchSettings; added missing return statement in set_datasource_settings |
| src/backend/history/cosmosdbservice.py | Fixed indentation bug - moved return statement outside if block to ensure function always returns a value |
| src/app.py | Removed unreachable assignments after exception raises in client initialization functions |
| src/.env.sample | Deleted environment variable sample file |
| scripts/data_utils.py | Improved file handling with context managers; improved regex readability by splitting into multiple lines |
| infra/scripts/index_scripts/02_process_data.py | Removed unused result variable assignment |
Comments suppressed due to low confidence (1)
src/backend/settings.py:262
- This class does not call DatasourcePayloadConstructor.init during initialization. (_AzureSearchSettings.init may be missing a call to a base class init)
class _AzureSearchSettings(BaseSettings, DatasourcePayloadConstructor):
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ance from BaseSettings and DatasourcePayloadConstructor; update regex pattern in PdfTextSplitter for improved URL matching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 35 out of 36 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
src/backend/settings.py:262
- This class does not call DatasourcePayloadConstructor.init during initialization. (_AzureSearchSettings.init may be missing a call to a base class init)
class _AzureSearchSettings(BaseSettings, DatasourcePayloadConstructor):
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…tePage, and HomePage constructors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 35 out of 36 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
src/.env.sample:1
- The documentation in
docs/README_LOCAL.mdline 4 references copying.env.sampleto.env, but this file has been deleted in this PR. Either the.env.samplefile should be restored, or the documentation needs to be updated to reflect the new setup process.
src/backend/settings.py:262 - This class does not call DatasourcePayloadConstructor.init during initialization. (_AzureSearchSettings.init may be missing a call to a base class init)
class _AzureSearchSettings(BaseSettings, DatasourcePayloadConstructor):
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…; update feedback state handling in Answer component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 35 out of 36 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/backend/settings.py:262
- This class does not call DatasourcePayloadConstructor.init during initialization. (_AzureSearchSettings.init may be missing a call to a base class init)
class _AzureSearchSettings(BaseSettings, DatasourcePayloadConstructor):
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 35 out of 36 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/backend/settings.py:262
- This class does not call DatasourcePayloadConstructor.init during initialization. (_AzureSearchSettings.init may be missing a call to a base class init)
class _AzureSearchSettings(BaseSettings, DatasourcePayloadConstructor):
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 35 out of 36 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/backend/settings.py:262
- This class does not call DatasourcePayloadConstructor.init during initialization. (_AzureSearchSettings.init may be missing a call to a base class init)
class _AzureSearchSettings(BaseSettings, DatasourcePayloadConstructor):
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ity and consistency
Purpose
Does this introduce a breaking change?
This pull request contains a mix of code improvements, bug fixes, and cleanup across the backend, frontend, and data processing scripts. The main focus is on improving code robustness, simplifying initialization logic, and cleaning up test and mock code. Below are the most important changes grouped by theme:
Backend and Data Processing Improvements:
with open(...) as f) for reading files in several places, reducing the risk of resource leaks. [1] [2]settings.pyto better support multiple inheritance and ensure proper initialization order, especially for settings and payload constructors. [1] [2]set_datasource_settingsreturnsselfeven when no datasource config is found, improving method chaining reliability.Frontend and Testing Cleanup:
react-markdownmock file by removing unused mock variables.Configuration and Environment:
src/.env.samplefile, which previously contained a large set of environment variable examples and documentation.Minor Code Quality Improvements:
mask_urls_and_imgsby splitting a long regex string into multiple concatenated lines.filePathTruncationLimit) from theAnswercomponent.Answercomponent for better type safety. [1] [2]These changes collectively improve code maintainability, reliability, and clarity across the project.
Golden Path Validation
Deployment Validation