Skip to content

Fix/wework sites project api - #2067

Open
FicoHu wants to merge 13 commits into
wecode-ai:mainfrom
FicoHu:fix/wework-sites-project-api
Open

Fix/wework sites project api#2067
FicoHu wants to merge 13 commits into
wecode-ai:mainfrom
FicoHu:fix/wework-sites-project-api

Conversation

@FicoHu

@FicoHu FicoHu commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added project renaming from the Sites workspace.
    • Updated Sites browsing with cursor-based pagination and search.
    • Added authenticated project publishing and deletion workflows.
    • Updated project details to show network, title, URL, and preview image.
  • Bug Fixes
    • Improved handling of unavailable or unauthorized Sites services.
    • Added safer error reporting that prevents sensitive tokens from being exposed.
    • Improved stale-result handling during search, pagination, and project actions.
  • Accessibility
    • Improved dialog focus management, keyboard navigation, validation, and retry behavior.
  • Localization
    • Added and updated English and Chinese text for rename and deletion workflows.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR migrates Sites from legacy site records to authenticated project APIs with cursor pagination, project rename/delete operations, updated response schemas, Wework API contracts, workspace reconciliation, and improved dialog focus and submission behavior.

Changes

Sites project migration

Layer / File(s) Summary
Backend contracts and gateway
.env.example, backend/.env.example, backend/app/core/config.py, backend/app/schemas/site.py, backend/app/api/endpoints/sites.py, docker-compose.yml
Sites configuration now includes a secret token; schemas use project fields and cursor pagination; authenticated list, publish, delete, and rename routes are exposed.
Authenticated upstream adapter
backend/app/services/sites.py, backend/tests/api/test_sites_api.py
The service calls authenticated project endpoints, sanitizes upstream errors, validates deletion confirmation, supports rename, and maps authentication, transport, configuration, and response failures.
Wework API contract and integration fixtures
wework/src/api/sites.ts, wework/src/api/sites.test.ts, wework/src/App.plugins.test.tsx
The client uses SiteProject, cursor queries, encoded project IDs, rename operations, unavailable fallbacks, and updated integration response fixtures.
Rename, delete, and dialog interaction flow
wework/src/components/common/TextInputDialog.tsx, wework/src/components/sites/DeleteSiteDialog.tsx, wework/src/components/sites/SiteActionsMenu.tsx, wework/src/i18n/locales/*/sites.json, related tests
Dialogs support submission guards, validation, focus trapping and restoration; the actions menu adds rename; deletion and rename copy and interaction tests are updated.
Cursor workspace and stale-response reconciliation
wework/src/components/sites/SitesWorkspace.tsx, wework/src/components/sites/SitesWorkspace.test.tsx
The workspace renders projects, uses cursor pagination, tracks mutation state, reconciles stale responses, and handles publish, rename, delete, search, refresh, thumbnail, and pagination races.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SitesWorkspace
  participant SitesApi
  participant SitesGateway
  participant SitesProjectAPI
  User->>SitesWorkspace: search, publish, rename, or delete project
  SitesWorkspace->>SitesApi: call project operation
  SitesApi->>SitesGateway: send authenticated request
  SitesGateway->>SitesProjectAPI: forward username, project ID, cursor, or title
  SitesProjectAPI-->>SitesGateway: return project page or mutation result
  SitesGateway-->>SitesApi: return validated response
  SitesApi-->>SitesWorkspace: update project list and operation state
  SitesWorkspace-->>User: render projects, errors, or dialog state
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is clearly related to the main change: the WeWork Sites project API refactor.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
wework/src/components/common/TextInputDialog.tsx (1)

71-94: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated dialog focus trap into a shared hook. Both dialogs contain a byte-identical handleKeyDown Tab trap (focusable-element query, empty-list fallback to dialog focus, first/last wrap-around). Duplicating accessibility-critical focus logic risks the two copies silently diverging. Introduce e.g. useFocusTrap(dialogRef) returning the onKeyDown handler and reuse it in both components.

  • wework/src/components/common/TextInputDialog.tsx#L71-L94: replace the inline handleKeyDown with the shared hook.
  • wework/src/components/sites/DeleteSiteDialog.tsx#L57-L80: replace the inline handleKeyDown with the same shared hook.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wework/src/components/common/TextInputDialog.tsx` around lines 71 - 94,
Extract the duplicated Tab focus-trap logic into a shared useFocusTrap hook that
accepts dialogRef and returns the keydown handler, preserving the
focusable-element query, empty-list fallback, and first/last wrap-around
behavior. Replace the inline handleKeyDown implementations in
wework/src/components/common/TextInputDialog.tsx lines 71-94 and
wework/src/components/sites/DeleteSiteDialog.tsx lines 57-80 with the shared
hook; both sites require direct changes.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@wework/src/components/common/TextInputDialog.tsx`:
- Around line 71-94: Extract the duplicated Tab focus-trap logic into a shared
useFocusTrap hook that accepts dialogRef and returns the keydown handler,
preserving the focusable-element query, empty-list fallback, and first/last
wrap-around behavior. Replace the inline handleKeyDown implementations in
wework/src/components/common/TextInputDialog.tsx lines 71-94 and
wework/src/components/sites/DeleteSiteDialog.tsx lines 57-80 with the shared
hook; both sites require direct changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9329a758-001f-4ed5-bf01-30714e1c0d52

📥 Commits

Reviewing files that changed from the base of the PR and between 7493ad6 and 46c30de.

📒 Files selected for processing (19)
  • .env.example
  • backend/.env.example
  • backend/app/api/endpoints/sites.py
  • backend/app/core/config.py
  • backend/app/schemas/site.py
  • backend/app/services/sites.py
  • backend/tests/api/test_sites_api.py
  • docker-compose.yml
  • wework/src/App.plugins.test.tsx
  • wework/src/api/sites.test.ts
  • wework/src/api/sites.ts
  • wework/src/components/common/TextInputDialog.test.tsx
  • wework/src/components/common/TextInputDialog.tsx
  • wework/src/components/sites/DeleteSiteDialog.tsx
  • wework/src/components/sites/SiteActionsMenu.tsx
  • wework/src/components/sites/SitesWorkspace.test.tsx
  • wework/src/components/sites/SitesWorkspace.tsx
  • wework/src/i18n/locales/en/sites.json
  • wework/src/i18n/locales/zh-CN/sites.json

@coderabbitai coderabbitai Bot mentioned this pull request Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant