Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.

Init fix#1

Open
mvoof wants to merge 48 commits into
mainfrom
init-fix
Open

Init fix#1
mvoof wants to merge 48 commits into
mainfrom
init-fix

Conversation

@mvoof

@mvoof mvoof commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

No description provided.

mvoof added 15 commits March 15, 2026 03:58
…re infinite loop

Antd's Typography.Paragraph/Text components use internal EllipsisMeasure with useLayoutEffect that enters infinite setState loops during client-side navigation when layout shifts (Dashboard unmount + Workspace mount in same React commit). Replaced all Typography in Workspace.tsx and TranslationEditor.tsx with plain HTML elements (div, span, code).
The POST /api/invitations endpoint returned 500 because datetime.now(timezone.utc) produced a tz-aware datetime incompatible with the TIMESTAMP WITHOUT TIME ZONE column. Switched to datetime.utcnow() to match the DB schema
Vite picks the next free port (5173→5174→5175...), so hardcoded origins break. Use allow_origin_regex for localhost/127.0.0.1 on any port by default. In prod, set CORS_ORIGINS env var to disable regex and use explicit origins only
  - Add CORS_ORIGIN_REGEX to allow any localhost port (Vite auto-increments)
  - Disable redirect_slashes to prevent 307→cross-origin redirect losing Auth header
  - Fix duplicate /api prefix in 15+ frontend API calls (/api/v1/api/... → /api/v1/...)
Fix trailing slash mismatch causing 404 on /users/ endpoint (backend
has redirect_slashes=false). Add status filter and regenerate endpoint
to invitations API. Replace flat invitation list with Pending/Expired
segmented view and regenerate support for expired invitations.
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request delivers substantial improvements to both the backend and frontend of the application. It focuses on bolstering security and administrative control through enhanced CORS configuration and detailed audit logging. Furthermore, it introduces greater flexibility in project setup with custom configurations and significantly expands the frontend's capabilities by adding dedicated sections for glossary management and annotation review, alongside numerous UI refinements.

Highlights

  • CORS Configuration Enhancements: The backend now supports more flexible CORS origin parsing, allowing for comma-separated lists, JSON arrays, and regex patterns for localhost development environments.
  • Comprehensive Audit Logging: Audit logging has been implemented for various critical user and invitation actions, including setup, registration, login, invitation management (create, delete, regenerate), password changes, and toggling user active status.
  • Project Configuration Flexibility: Projects can now store custom configurations, enabling dynamic settings such as source/target languages for translation projects and specific labels for Named Entity Recognition (NER) projects.
  • New Frontend Pages: Dedicated frontend pages have been introduced for managing project glossaries and reviewing project annotations, enhancing organization and user experience.
  • Improved User Management: The admin user management interface has been significantly improved, now displaying detailed project assignments for each user and allowing administrators to easily toggle user active statuses.
  • Playwright E2E Test Removal: Existing Playwright end-to-end tests and their associated configurations have been removed from the frontend.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .gitignore
    • Added '.playwright-mcp' to the ignore list.
  • CONTRIBUTING.md
    • Added a new contributing guide with instructions for forking, creating feature branches, installing dependencies, commit message guidelines (Conventional Commits), and development commands.
  • LICENSE
    • Added a Creative Commons Attribution-NonCommercial 4.0 International License.
  • backend/.env.example
    • Updated with an example for CORS_ORIGINS.
  • backend/app/config.py
    • Imported the json module.
    • Modified the Settings class to include CORS_ORIGIN_REGEX and a parse_cors_origins validator for flexible CORS configuration.
  • backend/app/main.py
    • Added redirect_slashes=False to FastAPI app initialization.
    • Modified CORSMiddleware to use allow_origins or allow_origin_regex based on the CORS_ORIGINS setting.
  • backend/app/routers/auth.py
    • Imported BackgroundTasks and log_audit.
    • Added audit logging for setup, register, and login endpoints.
  • backend/app/routers/invitations.py
    • Imported Optional, Query, BackgroundTasks, and func.
    • Changed datetime.now(timezone.utc) to datetime.utcnow().
    • Added audit logging for create, regenerate, and delete invitation endpoints.
    • Added a new endpoint /invitations/{invitation_id}/regenerate.
    • Modified /invitations to support status filtering.
  • backend/app/routers/projects.py
    • Imported BackgroundTasks and log_audit.
    • Updated project endpoints (/, /{project_id}, /members, /import, /export) to include audit logging for create, delete, add/remove member, import, and export actions.
    • Changed the default language in export to 'en'.
  • backend/app/routers/users.py
    • Imported BackgroundTasks and selectinload.
    • Added audit logging for password_change and toggle_active user actions.
    • Modified list_users to include project assignments.
    • Added a new endpoint /users/{user_id}/toggle-active.
  • backend/app/schemas.py
    • Added config: Optional[dict] = None to ProjectCreate and ProjectResponse.
    • Introduced UserProjectAssignment and UserListItemWithProjects schemas to include project assignment details for users.
  • frontend/.env.development
    • Changed VITE_API_URL to be empty.
  • frontend/e2e/full-flow.spec.ts
    • Removed the file.
  • frontend/eslint.config.js
    • Added global ignores for node_modules, dist, build.
    • Added files property to several configurations.
    • Disabled no-undef rule for TypeScript.
  • frontend/package-lock.json
    • Updated @playwright/test to be a dependency instead of devDependency.
    • Updated @rc-component/mini-decimal version.
    • Removed dev: true from several dependencies.
  • frontend/package.json
    • Updated @playwright/test to be a dependency.
  • frontend/playwright.config.ts
    • Removed the file.
  • frontend/src/App.tsx
    • Refactored theme-related style assignments for better readability and consistency.
  • frontend/src/api/client.ts
    • Changed default API_URL to /api/v1.
    • Updated refresh token endpoint path.
  • frontend/src/components/AuthForm.tsx
    • Performed minor formatting and simplification of input components.
  • frontend/src/components/CommandPalette.tsx
    • Imported React and observer.
    • Added InputRef type.
    • Added role, aria-selected, tabIndex, and onKeyDown for improved accessibility.
    • Added /* eslint-disable jsx-a11y/no-autofocus */ comment.
  • frontend/src/components/ErrorBoundary.tsx
    • Added // eslint-disable-next-line mobx/missing-observer comment.
    • Improved button styling.
  • frontend/src/components/editors/NEREditor.tsx
    • Imported React and observer.
    • Defined DEFAULT_LABELS.
    • Used useMemo for labels.
    • Added accessibility attributes (role, tabIndex, jsx-a11y eslint comments).
    • Refactored whitespace trimming logic.
  • frontend/src/components/editors/TranslationEditor.tsx
    • Imported React, observer, theme, authStore, and TaskAnnotation.
    • Fetched existing annotations and displayed other users' suggestions.
    • Improved glossary term rendering with role and tabIndex.
    • Changed API path for glossary.
  • frontend/src/components/layout/AppLayout.tsx
    • Imported new icons (BookOutlined, FileSearchOutlined).
    • Implemented deferred project ID detection for menu to prevent layout thrashing.
    • Updated API paths for notifications.
    • Added new menu items for Glossary and Review.
    • Improved breadcrumb accessibility.
    • Refactored theme-related style assignments.
  • frontend/src/components/workspace/ContextPanel.tsx
    • Imported React and observer.
    • Updated API paths for glossary and translation memory.
    • Improved rendering of source text with glossary terms.
  • frontend/src/components/workspace/VotingPanel.tsx
    • Imported React and observer.
    • Updated API paths for annotations and votes.
    • Refactored LABEL_COLORS for better readability.
  • frontend/src/constants/languages.ts
    • Added a new file defining LANGUAGE_OPTIONS.
  • frontend/src/hooks/usePresence.ts
    • Improved JSON stringification for WebSocket messages.
  • frontend/src/pages/Dashboard.tsx
    • Updated API paths for overview stats and project stats.
    • Modified createProject mutation to include config for source/target languages.
    • Refactored UI elements for better readability and accessibility.
  • frontend/src/pages/Profile.tsx
    • Imported Alert component.
    • Added state for passwordChanged and passwordForm.
    • Implemented a success message and form reset after a password change.
  • frontend/src/pages/ProjectGlossary.tsx
    • Added a new page for managing project glossaries.
  • frontend/src/pages/ProjectReview.tsx
    • Added a new page for reviewing project annotations.
  • frontend/src/pages/ProjectSettings.tsx
    • Removed review and glossary related states and functions, as they are now handled on separate pages.
    • Updated project config update logic to include source/target languages.
    • Refactored UI elements for better readability and accessibility.
  • frontend/src/pages/ProjectStats.tsx
    • Imported observer.
    • Updated API paths for project stats, annotator stats, timeline, and label stats.
    • Refactored UI elements for better readability.
  • frontend/src/pages/TaskBrowser.tsx
    • Imported React and observer.
    • Updated API path for tasks.
  • frontend/src/pages/Workspace.tsx
    • Imported STATUS_STYLES.
    • Refactored usePresence destructuring.
    • Used useMemo for tasks.
    • Improved task filtering logic.
    • Updated API paths for annotations.
    • Added accessibility attributes and comments.
    • Refactored task status rendering.
  • frontend/src/pages/admin/AuditLog.tsx
    • Imported React, observer, Select, and Space.
    • Defined ACTION_OPTIONS and RESOURCE_TYPE_OPTIONS.
    • Added filters for action and resource type.
    • Updated API path for audit log.
  • frontend/src/pages/admin/InvitationsManagement.tsx
    • Imported observer and Segmented.
    • Added ReloadOutlined icon.
    • Implemented status filtering for invitations.
    • Added regenerateInvitation mutation.
    • Updated API paths for invitations.
  • frontend/src/pages/admin/MembersManagement.tsx
    • Imported React, observer, Button, Modal, Form, Select, message, Space, Input, Switch, Tooltip, Popconfirm, PlusOutlined, SearchOutlined, DeleteOutlined.
    • Updated UserListItem to UserListItemWithProjects.
    • Added mutations for addToProject, removeFromProject, and toggleActive.
    • Implemented search functionality and expanded row rendering for project assignments.
    • Updated API paths.
  • frontend/src/routes/index.tsx
    • Imported ProjectGlossary and ProjectReview.
    • Added new routes for project glossary and review pages.
  • frontend/src/types/api.ts
    • Added UserProjectAssignment and UserListItemWithProjects interfaces.
  • frontend/vite.config.ts
    • Added server.proxy configuration for /api, /ws, and /health.
Activity
  • The author mvoof initiated this pull request with the title "Init fix", suggesting foundational updates or initial bug resolutions.
  • The pull request includes extensive changes across both backend and frontend, indicating a significant development effort.
  • Frontend E2E tests using Playwright were removed, which might imply a change in testing strategy or a temporary measure.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant number of features and refactorings across both the backend and frontend. Key additions include comprehensive audit logging, enhanced user and invitation management with status filtering and regeneration, and new dedicated pages for project glossary and annotation review. The frontend has been refactored to use a Vite proxy for development, and many components have been improved for better performance and accessibility.

My review found a few areas for improvement:

  • The use of the deprecated datetime.utcnow() should be replaced with the timezone-aware datetime.now(timezone.utc).
  • The @playwright/test dependency should be moved to devDependencies.
  • A leftover debug comment was found in the workspace component.

Overall, this is a substantial and well-executed update that greatly enhances the application's functionality and maintainability.

Comment thread backend/app/routers/invitations.py Outdated
Comment thread backend/app/routers/invitations.py Outdated
Comment thread frontend/package.json Outdated
Comment thread frontend/src/pages/Workspace.tsx Outdated
}

// --- Desktop layout: 3 columns ---
// DEBUG: only task list panel

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This debug comment should be removed before merging the pull request.

mvoof added 10 commits March 15, 2026 22:50
…ions

- Remove trailing slashes from test URLs (redirect_slashes=False means /api/v1/projects/ doesn't match /api/v1/projects)
- Make audit log_audit() session factory overridable so tests use SQLite  instead of trying to connect to PostgreSQL
  Replace confusing 3-tier RBAC (ADMIN/MANAGER/USER global + MANAGER/MEMBER project)
  with clean 2-tier system: ADMIN/USER global + MANAGER/EDITOR project roles.
  All project endpoints now require membership verification, fixing 15+ unprotected
  routes. Add anti-self-modification, ADMIN-only MANAGER assignment, pending imports
  for non-admin managers, and frontend route guards via ProjectContext.
  Add my_role to project list API response so the frontend can
  conditionally show/hide Settings based on the caller's project role
- Backend: add role checks in update_project_member and remove_project_member to block non-admin users from demoting or removing MANAGER-role members
- Frontend: hide Manager role option in selects for non-admins, disable ole change and remove buttons for MANAGER rows when user is not admin

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive Role-Based Access Control (RBAC) system, replacing the previous boolean is_admin flag with GlobalRole and RoleProject enums, and defining granular ProjectPermission levels. This required extensive updates across backend routers to integrate new permission classes (RequireAdmin, RequireProjectMember, etc.) and audit logging for key actions like user setup, registration, login, project creation/deletion, and member management. A new PendingImport model and associated endpoints were added to enable a review process for project data imports by non-admin managers. The frontend was updated to reflect these RBAC changes, including dynamic menu items, project settings permissions, and a new project glossary page. Additionally, the frontend's theme management was simplified to remove 'auto' mode, and Playwright test dependencies were correctly moved to devDependencies.

Comment thread frontend/package.json Outdated
"@types/react-dom": "^19.1.9",
"@typescript-eslint/parser": "^8.46.0",
"@vitejs/plugin-react": "^5.0.4",
"@playwright/test": "^1.58.2",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The @playwright/test package is for end-to-end testing and should be a devDependency, not a production dependency. Including it in dependencies can unnecessarily increase the size of the final production build. Please move this to the devDependencies section.

mvoof added 21 commits March 18, 2026 22:44
…ld error in CommandPalette.tsx by renaming styles.content to styles.container
…HTML with antd

- Rename types/domain.ts → types/index.ts and update all imports
- Add try/finally to authStore login/register/setup so isLoading resets on error
- Wrap post-await MobX mutations in runInAction()
- Extract backend detail field in toUserError() for specific error messages
- Replace raw div/main elements with antd Flex components in auth pages
…colors

- Add theme="light" to Sider for theme-aware sidebar background
- Override headerBg/bodyBg via ConfigProvider Layout component tokens
- Replace hardcoded white text in Dashboard stats with Typography.Text
- Extract static styles into SCSS modules for AppLayout and AppHeader
Add theme="light" to Sider, override headerBg/bodyBg in ConfigProvider, replace hardcoded white Dashboard stats text with Typography.Text.
Add global SCSS reset/variables structure and SCSS modules for layout components.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant