Skip to content

[SE-641] Add mentions in documents to the notification center - #26048

Draft
judithroth wants to merge 5 commits into
feature/se-641-mention-users-in-documents-backend-part-1from
feature/se-641-mention-users-in-documents-backend-part-2
Draft

judithroth wants to merge 5 commits into
feature/se-641-mention-users-in-documents-backend-part-1from
feature/se-641-mention-users-in-documents-backend-part-2

Conversation

@judithroth

Copy link
Copy Markdown
Contributor

Ticket

https://community.openproject.org/wp/SE-641

What are you trying to accomplish?

Enhance OpenProjects notification center to show notifications when a user was mentioned in a document

Screenshots

What approach did you choose and why?

AI involvement

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@judithroth judithroth changed the title [SE-641] Add mentions for documents to the notificatio center [SE-641] Add mentions in documents to the notification center Oct 15, 2026
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./spec/features/projects/lists/filters_spec.rb[1:19:1:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #26048, linked for reference only):

- `rspec ./spec/features/projects/lists/filters_spec.rb[1:19:1:1]`

Treat this as a standalone task, unrelated to PR #26048. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #26048 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @judithroth to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @judithroth, and request a review from @judithroth.
On every commit, set @judithroth as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@judithroth
judithroth force-pushed the feature/se-641-mention-users-in-documents-backend-part-2 branch from 44e10ec to 348b1d2 Compare October 16, 2026 10:51
https://community.openproject.org/wp/SE-641

- notification-resource-id.ts (new): a helper that returns a notification's work package ID or document ID.
- center/state/ian-center.service.ts:
  - When stepping to the next notification, document rows are skipped. If only documents are left, the split screen
    closes.
  - Only work package rows can be selected.
  - The service now uses the new helper wherever it read a work package ID from the link.
- center/in-app-notification-center.component.ts: a document is never highlighted as the open work package.
- center/in-app-notification-center.component.html: data-qa-ian-selected is now only set on the selected row.
- ian-center.service.spec.ts (new).
- path-helper.service.ts: new documentPath(). documents.component.ts in the documents widget now uses it, and the
  URL it builds is the same as before.
@judithroth
judithroth force-pushed the feature/se-641-mention-users-in-documents-backend-part-2 branch from 348b1d2 to 116b263 Compare October 16, 2026 10:55
https://community.openproject.org/wp/SE-641

- Entry component (entry/in-app-notification-entry.component.{ts,html,sass}): the template is now a short @if / @else if / @else
  that picks the child component (work package or document) or the loading placeholder. It keeps:
  - the row element and its click and keyboard handling
  - markAsRead and showDetails
  - the shared #topLineDetails template (project, reasons, counter, buttons), which goes into each child through <ng-content>
- New entry/work-package-content/ (TS, HTML, Sass, spec): renders status and #ID, type and subject, and the reminder alert, date alert or actors line.
- New entry/document-content/ (TS, HTML, Sass): renders the "Document" label, the title link and the actors line.
- New entry/has-notification-reason.ts: the reason check, now in one place for both components.
- in-app-notifications.module.ts: declares the two new components.
@ihordubas99
ihordubas99 added this pull request to stack #26090 October 16, 2026 11:03
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/resource_management/spec/features/edit_resource_allocation_assignee_spec.rb[1:2:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #26048, linked for reference only):

- `rspec ./modules/resource_management/spec/features/edit_resource_allocation_assignee_spec.rb[1:2:1]`

Treat this as a standalone task, unrelated to PR #26048. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #26048 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @judithroth to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @judithroth, and request a review from @judithroth.
On every commit, set @judithroth as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

https://community.openproject.org/wp/SE-641

- document_strategy.rb: supports_ian? returns reason.to_s == "mentioned". Document mentions now also appear in the notification center, and "document added" stays mail-only.
- Specs for that change: document_strategy_spec.rb, create_from_api_service_spec.rb and notifications_api_create_resource_spec.rb now expect read_ian: false for mentions.
- spec/support/pages/notifications/center.rb: new expect_document_item and click_document_label helpers.
- New modules/documents/spec/features/notifications/document_mention_notification_spec.rb (7 examples):
  - how the row looks and links
  - clicking the row does nothing
  - mark as read and mark all as read
  - a document and work package with the same ID don't get mixed up
  - the split screen closes when only the document is left
  - project filter
  - end to end through POST /api/v3/notifications
@judithroth
judithroth force-pushed the feature/se-641-mention-users-in-documents-backend-part-2 branch from 116b263 to 81b4e29 Compare October 16, 2026 11:15
@judithroth
judithroth requested a balanced review from Copilot October 16, 2026 11:16

Copilot AI 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.

🔵 Needs a closer look

Cross-layer notification changes have unresolved issues and need human review with runtime validation.

3 open findings
What changed in this PR

Adds document mentions to OpenProject’s notification center alongside work-package notifications.

Changes:

  • Extends notification visibility, filtering, grouping, and API representations to documents.
  • Adds document rows and resource-aware navigation.
  • Adds regression coverage and updates API documentation.
File Description
spec/​support/​pages/​notifications/​center.rb Adds document notification helpers.
spec/​services/​notifications/​create_from_api_service_spec.rb Expects unread document mentions.
spec/​requests/​api/​v3/​notifications/​show_resource_spec.rb Tests document links without embedding.
spec/​requests/​api/​v3/​notifications/​notifications_api_create_resource_spec.rb Updates mention creation expectations.
spec/​requests/​api/​v3/​notifications/​index_resource_spec.rb Covers document listing and filtering.
spec/​requests/​api/​v3/​notifications/​bulk_unread_ian_resource_spec.rb Protects email-only notifications.
spec/​models/​queries/​notifications/​notification_query_spec.rb Tests mixed-resource queries.
spec/​models/​queries/​base_query_group_bys_spec.rb Updates project grouping expectations.
spec/​models/​notifications/​scopes/​visible_spec.rb Tests document visibility rules.
spec/​lib/​api/​v3/​notifications/​notification_representer_rendering_spec.rb Covers document representation.
modules/​documents/​spec/​services/​notifications/​create_from_model_service/​document_strategy_spec.rb Tests in-app mention support.
modules/​documents/​spec/​features/​notifications/​document_mention_notification_spec.rb Adds notification-center feature coverage.
modules/​documents/​app/​services/​notifications/​create_from_model_service/​document_strategy.rb Enables in-app document mentions.
lib/​api/​v3/​notifications/​notifications_api.rb Excludes email-only bulk updates.
lib/​api/​v3/​notifications/​notification_representer.rb Links documents without embedding.
lib/​api/​decorators/​polymorphic_resource.rb Supports dynamic link-title attributes.
frontend/​src/​app/​shared/​components/​grids/​widgets/​documents/​documents.component.ts Reuses document path helper.
frontend/​src/​app/​features/​in-app-notifications/​notification-resource-id.ts Adds resource-specific ID extraction.
frontend/​src/​app/​features/​in-app-notifications/​in-app-notifications.module.ts Registers resource content components.
frontend/​src/​app/​features/​in-app-notifications/​entry/​work-package-content/​in-app-notification-work-package-content.component.ts Extracts work-package content logic.
frontend/​src/​app/​features/​in-app-notifications/​entry/​work-package-content/​in-app-notification-work-package-content.component.spec.ts Tests work-package content rendering.
frontend/​src/​app/​features/​in-app-notifications/​entry/​work-package-content/​in-app-notification-work-package-content.component.sass Extracts work-package layout styles.
frontend/​src/​app/​features/​in-app-notifications/​entry/​work-package-content/​in-app-notification-work-package-content.component.html Extracts work-package content template.
frontend/​src/​app/​features/​in-app-notifications/​entry/​in-app-notification-entry.component.ts Handles resource-specific row behavior.
frontend/​src/​app/​features/​in-app-notifications/​entry/​in-app-notification-entry.component.spec.ts Tests document and work-package rows.
frontend/​src/​app/​features/​in-app-notifications/​entry/​in-app-notification-entry.component.sass Adds static-row styling.
frontend/​src/​app/​features/​in-app-notifications/​entry/​in-app-notification-entry.component.html Selects resource-specific content.
frontend/​src/​app/​features/​in-app-notifications/​entry/​has-notification-reason.ts Shares notification-reason lookup.
frontend/​src/​app/​features/​in-app-notifications/​entry/​document-content/​in-app-notification-document-content.component.ts Adds document content logic.
frontend/​src/​app/​features/​in-app-notifications/​entry/​document-content/​in-app-notification-document-content.component.sass Styles document notification content.
frontend/​src/​app/​features/​in-app-notifications/​entry/​document-content/​in-app-notification-document-content.component.html Renders document links and actors.
frontend/​src/​app/​features/​in-app-notifications/​center/​state/​ian-center.service.ts Skips documents during split-screen navigation.
frontend/​src/​app/​features/​in-app-notifications/​center/​state/​ian-center.service.spec.ts Tests mixed-resource navigation.
frontend/​src/​app/​features/​in-app-notifications/​center/​in-app-notification-center.component.ts Restricts selection to work packages.
frontend/​src/​app/​features/​in-app-notifications/​center/​in-app-notification-center.component.html Omits selection attribute for unselected rows.
frontend/​src/​app/​core/​path-helper/​path-helper.service.ts Adds document URL helper.
docs/​api/​apiv3/​tags/​notifications.yml Documents document notifications.
docs/​api/​apiv3/​paths/​notifications.yml Documents resource-type filter values.
docs/​api/​apiv3/​components/​schemas/​notification_model.yml Updates embedding and activity requirements.
config/​locales/​js-en.yml Adds document label.
app/​models/​queries/​notifications/​resource_project.rb Shares resource-to-project SQL.
app/​models/​queries/​notifications/​orders/​project_order.rb Orders both resource types by project.
app/​models/​queries/​notifications/​group_bys/​group_by_project.rb Groups both resource types by project.
app/​models/​queries/​notifications/​filters/​resource_type_filter.rb Allows document resource types.
app/​models/​queries/​notifications/​filters/​resource_id_filter.rb Includes visible document IDs.
app/​models/​queries/​notifications/​filters/​project_filter.rb Filters projects across resource types.
app/​models/​notifications/​scopes/​visible.rb Adds document-aware visibility.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


context "with document notifications from two projects" do
shared_let(:other_project) { create(:project, enabled_module_names: %w[documents]) }
shared_let(:other_document) { create(:document, project: other_project, title: "Pre-landing checklist") }
def visible_resource_scopes(user)
{
"WorkPackage" => WorkPackage.visible(user),
"Document" => Document.visible(user)
}

closeSplitScreen():void {
window.location.href = this.pathHelper.notificationsPath();

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants