Skip to content

fix: repair regressions from sidebar PR (#585)#586

Merged
ussaama merged 2 commits into
mainfrom
fix/post-sidebar-regressions
May 25, 2026
Merged

fix: repair regressions from sidebar PR (#585)#586
ussaama merged 2 commits into
mainfrom
fix/post-sidebar-regressions

Conversation

@ussaama
Copy link
Copy Markdown
Contributor

@ussaama ussaama commented May 25, 2026

fix: repair regressions from sidebar PR (#585)

The sidebar PR overlapped with #577, #581, #582, and #583 and introduced
a few cross-cutting issues this commit addresses:

  • Restore the "hide Project defaults for external-only users" gate in the
    new sidebar's UserSettingsView. PR feat: promote external collaborators to first-class role #582/Fixes and improvements #583 added this filter to the
    old UserSettingsRoute; when the sidebar moved navigation into a new
    view component, the NavItem rendered unconditionally and external-only
    users could click through to an empty pane.
  • Drop schema-step tests that imported the deleted scripts/create_schema.py
    one-shot seeding script. The committed snapshot under
    directus/sync/snapshot/ is the source of truth now, so those structural
    guards were checking a script that no longer exists.
  • Update AGENTS.md to remove the create_schema.py reference and point at
    the snapshot directory.
  • Populate ref_workspace_id on PROJECT_SHARE_ROLE_CHANGED (project_sharing.py),
    REPORT_READY, and REPORT_FAILED (tasks.py). The new useNotifications
    href builder requires both ref_workspace_id and ref_project_id to
    produce /w/{ws}/projects/... links; without it those notifications
    rendered as dead clicks.
  • Strip the per-request org_membership lookup in get_workspace_context.
    PR feat: promote external collaborators to first-class role #582 enforces role='external' ⟺ no org_membership at every write
    path, and on_organisation_member_removed cascades workspace_membership
    soft-deletes correctly, so the read-side normalisation was redundant
    per-request DB overhead.

Summary by CodeRabbit

  • New Features

    • User settings view now fetches and displays workspace access information, conditionally showing relevant configuration options based on access level.
    • Notifications for project sharing and report status now include workspace context information for better organization.
  • Documentation

    • Updated deployment guide with clarified schema snapshot and migration script procedures.
  • Tests

    • Removed legacy schema step validation tests from test suite.

Review Change Stack

  The sidebar PR overlapped with #577, #581, #582, and #583 and introduced
  a few cross-cutting issues this commit addresses:

  - Drop schema-step tests that imported the deleted scripts/create_schema.py
    one-shot seeding script. The committed snapshot under
    directus/sync/snapshot/ is the source of truth now, so those structural
    guards were checking a script that no longer exists.
  - Update AGENTS.md to remove the create_schema.py reference and point at
    the snapshot directory.
  - Populate ref_workspace_id on PROJECT_SHARE_ROLE_CHANGED (project_sharing.py),
    REPORT_READY, and REPORT_FAILED (tasks.py). The new useNotifications
    href builder requires both ref_workspace_id and ref_project_id to
    produce /w/{ws}/projects/... links; without it those notifications
    rendered as dead clicks.
  - Strip the per-request org_membership lookup in get_workspace_context.
    PR #582 enforces role='external' ⟺ no org_membership at every write
    path, and on_organisation_member_removed cascades workspace_membership
    soft-deletes correctly, so the read-side normalisation was redundant
    per-request DB overhead.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Warning

Review limit reached

@ussaama, we couldn't start this review because you've used your available PR reviews for now.

Your plan includes 1 review of capacity. Refill in 45 minutes and 43 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f643ab95-4773-4288-9f3e-6a83423488e2

📥 Commits

Reviewing files that changed from the base of the PR and between a7c0cb0 and 270fdaa.

📒 Files selected for processing (1)
  • echo/frontend/src/features/sidebar/views/user/UserSettingsView.tsx

Walkthrough

Frontend now detects workspace external-only status via API query; middleware refactors role normalization to use a shared helper; notifications enriched with workspace IDs; outdated schema step structural test assertions removed; Directus documentation clarified.

Changes

Workspace Access and Context Flow

Layer / File(s) Summary
Frontend workspace access detection
echo/frontend/src/features/sidebar/views/user/UserSettingsView.tsx
Phosphor icon imports updated to component exports; useQuery fetches /v2/workspaces endpoint; isExternalOnly derived from organizations array length; "Project defaults" navigation conditionally rendered only when user is not external-only.
Role normalization refactor
echo/server/dembrane/api/v2/middleware.py
get_workspace_context now uses _normalize_legacy_role helper to compute normalized role; removed prior org-membership lookup that could downgrade role to "external" for direct workspace sources.
Notification payload workspace context
echo/server/dembrane/api/v2/project_sharing.py, echo/server/dembrane/tasks.py
Project share role change and report lifecycle notifications (REPORT_READY, REPORT_FAILED) now include ref_workspace_id from project row; failure path fetches project data to access workspace identifier.
Schema step structural test cleanup
echo/server/tests/test_discount_fields.py, echo/server/tests/test_tier_expiry.py, echo/server/tests/test_tier_expiry_prewarning.py, echo/server/tests/test_workspace_requests.py
Removed TestSchemaStep21, TestSchemaStep19, TestSchemaStep20, TestSchemaStep18 classes that verified step registration and function callability; removed unused sys import.
Documentation clarification
echo/AGENTS.md
Directus Rules checklist now explicitly describes idempotent Python script approach; snapshot JSON commit location specified as directus/sync/snapshot/ with clarification that one-shot migrations need not be committed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

bug

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 accurately captures the main objective: fixing regressions introduced by the prior sidebar PR, which aligns with the file changes addressing cross-cutting issues across schema tests, API endpoints, and frontend code.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/post-sidebar-regressions

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 and usage tips.

@coderabbitai coderabbitai Bot added the bug Something isn't working label May 25, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@echo/frontend/src/features/sidebar/views/user/UserSettingsView.tsx`:
- Around line 24-37: The current isExternalOnly calculation treats missing
accessData as external-only; change it so unknown or failed loads do NOT count
as external-only by checking accessData is present before inspecting
organisations. Specifically, update the isExternalOnly expression (referencing
accessData and isExternalOnly in UserSettingsView.tsx where useQuery is used) to
only evaluate true when accessData is non-null/defined and
accessData.organisations.length === 0, so undefined/null accessData returns
false.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1ddb6a59-2ccd-4fba-966c-df6ed4188fc9

📥 Commits

Reviewing files that changed from the base of the PR and between ebb40c3 and a7c0cb0.

📒 Files selected for processing (9)
  • echo/AGENTS.md
  • echo/frontend/src/features/sidebar/views/user/UserSettingsView.tsx
  • echo/server/dembrane/api/v2/middleware.py
  • echo/server/dembrane/api/v2/project_sharing.py
  • echo/server/dembrane/tasks.py
  • echo/server/tests/test_discount_fields.py
  • echo/server/tests/test_tier_expiry.py
  • echo/server/tests/test_tier_expiry_prewarning.py
  • echo/server/tests/test_workspace_requests.py
💤 Files with no reviewable changes (5)
  • echo/server/tests/test_discount_fields.py
  • echo/server/dembrane/api/v2/middleware.py
  • echo/server/tests/test_tier_expiry_prewarning.py
  • echo/server/tests/test_workspace_requests.py
  • echo/server/tests/test_tier_expiry.py

Comment thread echo/frontend/src/features/sidebar/views/user/UserSettingsView.tsx Outdated
  Guard with `accessData != null` so "Project defaults" only hides once
  we've actually loaded an empty organisations list.
@ussaama ussaama added this pull request to the merge queue May 25, 2026
Merged via the queue into main with commit 2eccbd7 May 25, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants