Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
Address review round 3 of linking a meeting participant
Guido Boyke36e486080c2d
diff --git a/app/helpers/meeting_participant_links_helper.rb b/app/helpers/meeting_participant_links_helper.rbindex cc6e561..0ad2289 100644--- a/app/helpers/meeting_participant_links_helper.rb+++ b/app/helpers/meeting_participant_links_helper.rb@@ -8,15 +8,21 @@ module MeetingParticipantLinksHelper# What the row may show the viewer: whether they may link, and for each# participant the address of its person, or nil. Read once per row, from the# viewer's own directory, so a person they may not see stays plain text.- ParticipantPeople = Struct.new(:can_link, :paths, keyword_init: true) do+ # member_ids: the accounts among the participants with a membership here,+ # active or not; their names are linked through the account, not the dialog.+ ParticipantPeople = Struct.new(:can_link, :paths, :member_ids, keyword_init: true) dodef path_for(participant)paths[participant.id]end++ def linkable?(participant)+ can_link && (participant.user_id.nil? || !member_ids.include?(participant.user_id))+ endend- # The row of one meeting's participants (meeting page and the panel beside a- # ticket); a link or an unlink redraws it.- def meeting_participants_row_id(meeting)+ # The chips of one meeting's participants (meeting page and the panel beside a+ # ticket); a link or an unlink redraws them, never the dialog frame beside them.+ def meeting_participant_chips_id(meeting)dom_id(meeting, :participants)end@@ -42,14 +48,16 @@ module MeetingParticipantLinksHelperenddef meeting_participant_people(meeting, participants)- return ParticipantPeople.new(can_link: false, paths: {}) unless PersonPolicy.view_allowed?(current_user, current_organisation)+ return ParticipantPeople.new(can_link: false, paths: {}, member_ids: Set.new) unless PersonPolicy.view_allowed?(current_user, current_organisation)directory = People::Directory.new(viewer: current_user, organisation: current_organisation)paths = participants.each_with_object({}) do |participant, found|entry = participant_directory_entry(directory, participant)found[participant.id] = person_entry_path(entry) if entryend- ParticipantPeople.new(can_link: policy(meeting).update?, paths: paths)+ member_ids = Membership.where(organisation: current_organisation, user_id: participants.filter_map(&:user_id))+ .pluck(:user_id).to_set+ ParticipantPeople.new(can_link: policy(meeting).update?, paths: paths, member_ids: member_ids)end# The person page of a directory entry: its row, or a member without one.diff --git a/app/models/CLAUDE.md b/app/models/CLAUDE.mdindex d45b8db..eff0cc6 100644--- a/app/models/CLAUDE.md+++ b/app/models/CLAUDE.md@@ -63,10 +63,11 @@ Verzeichnis-Layout nicht ablesbar — diese Karte gruppiert sie:Person) auf eine Zeile; `belongs_to :person` steht VOR `acts_as_tenant`, eine Validierunghält die Person in derselben Org. Ein Mitglied läuft weiter über `user_id`. Meetings und„Letzter Kontakt“ einer Person liest nur `People::Contacts` (`app/services/CLAUDE.md`).- Seit S2b (27.10.2026) schreibt `person_id` nur `Actors::LinkMeetingParticipant` (Dialog an+ Seit S2b (27.10.2026) setzt `person_id` nur `Actors::LinkMeetingParticipant` (Dialog anden Teilnehmer-Chips, `MeetingParticipantLinksController`): EIN Schlüssel je Teilnehmer,- ein Mitglied über `user_id`, ein Kontakt (auch die Zeile eines früheren Mitglieds) über- `person_id`. Der Actor sperrt das Meeting (`lock_in_project!`) und löst Person und Mitglied+ ein Mitglied über `user_id`, ein Kontakt (auch die Zeile eines deaktivierten Mitglieds)+ über `person_id`. Der Teilnehmer eines Mitglieds, dessen Mitgliedschaft entfernt ist, ist+ wieder ein Name: der Dialog verknüpft ihn als Kontakt und leert die `user_id`. Der Actor sperrt das Meeting (`lock_in_project!`) und löst Person und Mitgliednur über `People::Directory` des Schreibenden auf. Das Meeting-Formular kennt `person_id`nicht; `SaveMeeting` behält die Zeile und damit den Link. Macht das Formular eineKontakt-Zeile zu der eines Mitglieds, fällt `person_id` weg (ein Schlüssel), und dasdiff --git a/app/services/actors/claim_meeting_participants.rb b/app/services/actors/claim_meeting_participants.rbindex 9d741a2..4142b34 100644--- a/app/services/actors/claim_meeting_participants.rb+++ b/app/services/actors/claim_meeting_participants.rb@@ -49,7 +49,9 @@ module Actors# and this UPDATE — the RecordNotUnique rescue below turns that race into a# clean, retryable failure.# intentional bulk link; see comment above- @linked_count = MeetingParticipant.where(id: ids)+ # Read again in the write: the link dialog may have given one of these rows+ # a contact (person_id) in between, and a row keeps one key.+ @linked_count = MeetingParticipant.where(id: ids, user_id: nil, person_id: nil).update_all(user_id: @user.id, updated_at: Time.current)rescue ActiveRecord::RecordNotUnique# Another write linked this member to a target meeting between the skip-checkdiff --git a/app/services/actors/link_meeting_participant.rb b/app/services/actors/link_meeting_participant.rbindex 0cb1e38..90e7a78 100644--- a/app/services/actors/link_meeting_participant.rb+++ b/app/services/actors/link_meeting_participant.rb@@ -8,8 +8,9 @@## One key per participant: a member is linked by user_id (the path the meeting# form already uses), a contact by person_id. The row of a FORMER member is a-# contact, as the directory shows it. A participant that is a member already-# is linked through its account and is left alone.+# contact, as the directory shows it. A participant of someone with a+# membership here is linked through its account and is left alone; one whose+# membership was removed may be linked as a contact.## The caller authorizes the meeting write (MeetingPolicy#update?). This actor# resolves every id itself, so a raw id never reaches a column:@@ -43,10 +44,12 @@ module Actorsdef performrefuse!(:not_found) unless @meeting.lock_in_project!(@project.id)- @participant = @meeting.meeting_participants.find_by(id: @participant_id)+ # The row lock too: the claim (Actors::ClaimMeetingParticipants) writes+ # participants without the meeting lock.+ @participant = @meeting.meeting_participants.lock.find_by(id: @participant_id)refuse!(:not_found) if @participant.nil?# A member participant is linked by its account; the meeting form owns that.- refuse!(:member_participant) if @participant.user_id+ refuse!(:member_participant) if member_participant?return @participant.update!(person_id: nil) if @unlink@@ -75,7 +78,7 @@ module Actorsrefuse!(:member_name_taken) if name_taken_by_another?(entry.user.display_name)@participant.update!(user_id: entry.user.id, person_id: nil)else- @participant.update!(person_id: entry.person.id)+ @participant.update!(person_id: entry.person.id, user_id: nil)endrescue ActiveRecord::RecordNotUnique# The meeting lock runs two links one after the other, so the check above@@ -83,6 +86,14 @@ module Actorsrefuse!(:member_already_participant)end+ # A participant of someone with a membership here, active or not. One whose+ # membership was removed is a name again (their row lost its account through+ # PersonLinkRelease): it may be linked as a contact, and its account goes.+ def member_participant?+ @participant.user_id.present? &&+ Membership.where(organisation: organisation, user_id: @participant.user_id).exists?+ end+def taken_by_another?(user_id)@meeting.meeting_participants.where(user_id: user_id).where.not(id: @participant.id).exists?enddiff --git a/app/services/actors/save_meeting.rb b/app/services/actors/save_meeting.rbindex c6978f4..33058a3 100644--- a/app/services/actors/save_meeting.rb+++ b/app/services/actors/save_meeting.rb@@ -182,8 +182,8 @@ module Actors# row of its normalized name first, else the row of its member that no name# claimed. Name first, so the row of a name keeps its name and its link:# a member whose new name is already an external row of this meeting takes- # that row and its link, and the member's old row goes (as before the- # member match existed). Only unclaimed rows count for a member, so a name+ # that row (a contact link on it goes, see reconcile_participants), and the+ # member's old row goes (as before the member match existed). Only unclaimed rows count for a member, so a name# and a member never get the same row. Each user_id occurs once in desired# (guard_against_duplicates!), so a row is never matched twice.def match_participant_rows(existing, desired)diff --git a/app/views/organisations/meeting_participant_links/_row_stream.turbo_stream.erb b/app/views/organisations/meeting_participant_links/_row_stream.turbo_stream.erbindex 3ceb8c4..55e5682 100644--- a/app/views/organisations/meeting_participant_links/_row_stream.turbo_stream.erb+++ b/app/views/organisations/meeting_participant_links/_row_stream.turbo_stream.erb@@ -1,6 +1,9 @@<%# locals: (meeting:) %>-<%# The participant row of this meeting as it is now, wherever the page shows it (the- meeting's page or the panel beside a ticket). %>-<%= turbo_stream.replace meeting_participants_row_id(meeting),- partial: 'organisations/meetings/participants_row',- locals: { meeting: meeting, participants: meeting.meeting_participants.order(:created_at).to_a } %>+<%# The chips of this meeting as they are now, wherever the page shows them (the meeting's+ page or the panel beside a ticket). Only the chips: the dialog frame beside them stays, so+ this answer cannot close a dialog opened after it was sent. %>+<% participants = meeting.meeting_participants.order(:created_at).to_a %>+<%= turbo_stream.replace meeting_participant_chips_id(meeting),+ partial: 'organisations/meetings/participant_chips',+ locals: { meeting: meeting, participants: participants,+ people: meeting_participant_people(meeting, participants) } %>diff --git a/app/views/organisations/meetings/_participant_chips.html.erb b/app/views/organisations/meetings/_participant_chips.html.erbnew file mode 100644index 0000000..ac97a9f--- /dev/null+++ b/app/views/organisations/meetings/_participant_chips.html.erb@@ -0,0 +1,39 @@+<%# locals: (meeting:, participants:, people:) %>+<%# The chips of a meeting's participants (see _participants_row). A link or an unlink of the+ dialog replaces exactly this element (meeting_participant_chips_id): the dialog's frame+ stands beside it, so an answer that comes late closes no dialog opened meanwhile. %>+<% permitted_user_ids = meeting.project.permitted_user_ids.to_set %>+<% pl = 'views.organisations.meetings.participant_links' %>+<div id="<%= meeting_participant_chips_id(meeting) %>" class="flex min-w-0 flex-1 flex-wrap gap-2">+ <% participants.each do |participant| %>+ <% chip_style = meeting_participant_chip_style(meeting_participant_type(participant, permitted_user_ids)) %>+ <% path = people.path_for(participant) %>+ <span class="meeting-participant inline-flex min-w-0 max-w-full items-center gap-0.5">+ <% chip = render NeoTagComponent.new(+ text: participant.display_name,+ variant: chip_style[:variant],+ icon: chip_style[:icon],+ title: chip_style[:title],+ size: :small,+ class: 'max-w-full [&_.tag-text]:break-words [&_.tag-text]:[overflow-wrap:anywhere]'+ ) %>+ <% if path %>+ <%= link_to chip, path, class: 'meeting-participant__person min-w-0 max-w-full rounded-full',+ data: { turbo_frame: '_top' },+ aria: { label: t("#{pl}.open_person", name: participant.display_name) } %>+ <% else %>+ <%= chip %>+ <% end %>+ <% if people.linkable?(participant) %>+ <% action_label = participant.person_id ? t("#{pl}.change", name: participant.display_name) : t("#{pl}.link", name: participant.display_name) %>+ <%= link_to new_organisation_project_meeting_participant_link_path(current_organisation, meeting.project, meeting, participant),+ id: participant_link_trigger_id(participant),+ class: 'meeting-participant__link inline-flex h-6 w-6 items-center justify-center rounded-full text-cream-600 hover:bg-cream-200 hover:text-ink',+ title: action_label, aria: { label: action_label },+ data: { turbo_frame: participant_link_modal_id(meeting) } do %>+ <i class="bi <%= participant.person_id ? 'bi-pencil' : 'bi-link-45deg' %>" aria-hidden="true"></i>+ <% end %>+ <% end %>+ </span>+ <% end %>+</div>diff --git a/app/views/organisations/meetings/_participants_row.html.erb b/app/views/organisations/meetings/_participants_row.html.erbindex f7ee0b2..7a39ee5 100644--- a/app/views/organisations/meetings/_participants_row.html.erb+++ b/app/views/organisations/meetings/_participants_row.html.erb@@ -5,50 +5,16 @@S2b (people directory): a participant whose person the viewer may see is a link to thatperson; a free name stays text. With the meeting write and view_people, a name that is- no member gets the action "Mit Person verknüpfen" (a linked one: "Verknüpfung ändern"),- which loads the dialog into the frame at the end of the row. A link or an unlink- redraws the row (meeting_participants_row_id). %>+ no member's gets the action "Mit Person verknüpfen" (a linked one: "Verknüpfung ändern"),+ which loads the dialog into the frame at the end of the row. A link or an unlink redraws+ the chips (_participant_chips), never the frame. %><% if participants.any? %>- <% permitted_user_ids = meeting.project.permitted_user_ids.to_set %><% people = meeting_participant_people(meeting, participants) %>- <% pl = 'views.organisations.meetings.participant_links' %>- <div id="<%= meeting_participants_row_id(meeting) %>" class="mt-3 flex min-w-0 flex-wrap items-start gap-2">+ <div class="mt-3 flex min-w-0 flex-wrap items-start gap-2"><span class="pt-0.5 text-xs font-mono uppercase tracking-wider text-cream-600"><%= t('views.organisations.meetings.show.participants_heading') %></span>- <div class="flex min-w-0 flex-1 flex-wrap gap-2">- <% participants.each do |participant| %>- <% chip_style = meeting_participant_chip_style(meeting_participant_type(participant, permitted_user_ids)) %>- <% path = people.path_for(participant) %>- <span class="meeting-participant inline-flex min-w-0 max-w-full items-center gap-0.5">- <% chip = render NeoTagComponent.new(- text: participant.display_name,- variant: chip_style[:variant],- icon: chip_style[:icon],- title: chip_style[:title],- size: :small,- class: 'max-w-full [&_.tag-text]:break-words [&_.tag-text]:[overflow-wrap:anywhere]'- ) %>- <% if path %>- <%= link_to chip, path, class: 'meeting-participant__person min-w-0 max-w-full rounded-full',- data: { turbo_frame: '_top' },- aria: { label: t("#{pl}.open_person", name: participant.display_name) } %>- <% else %>- <%= chip %>- <% end %>- <% if people.can_link && participant.user_id.nil? %>- <% action_label = participant.person_id ? t("#{pl}.change", name: participant.display_name) : t("#{pl}.link", name: participant.display_name) %>- <%= link_to new_organisation_project_meeting_participant_link_path(current_organisation, meeting.project, meeting, participant),- id: participant_link_trigger_id(participant),- class: 'meeting-participant__link inline-flex h-6 w-6 items-center justify-center rounded-full text-cream-600 hover:bg-cream-200 hover:text-ink',- title: action_label, aria: { label: action_label },- data: { turbo_frame: participant_link_modal_id(meeting) } do %>- <i class="bi <%= participant.person_id ? 'bi-pencil' : 'bi-link-45deg' %>" aria-hidden="true"></i>- <% end %>- <% end %>- </span>- <% end %>- </div>+ <%= render 'organisations/meetings/participant_chips', meeting: meeting, participants: participants, people: people %><% if people.can_link %><%= turbo_frame_tag participant_link_modal_id(meeting) %><% end %>diff --git a/spec/requests/organisations/meeting_participant_links_spec.rb b/spec/requests/organisations/meeting_participant_links_spec.rbindex 82bb13b..b82b269 100644--- a/spec/requests/organisations/meeting_participant_links_spec.rb+++ b/spec/requests/organisations/meeting_participant_links_spec.rb@@ -120,6 +120,28 @@ RSpec.describe 'Organisations::MeetingParticipantLinks', :ci_guard, type: :requeexpect(response.body).to include(CGI.escapeHTML(organisation_people_path(organisation, person_id: row.id)))end+ # A member who left the organisation: their row lost its account+ # (PersonLinkRelease), the participant still carries it. The name is a+ # contact again and can be linked to that row, which then lists the meeting.+ it 'lets the participant of a removed member be linked as a contact' do+ gone = member_with(create(:role, organisation: organisation), first_name: 'Gerd')+ row = create(:person, organisation: organisation, name: 'Gerd Beispiel', user: gone)+ gone_participant = create(:meeting_participant, meeting: meeting, display_name: 'Gerd Beispiel', user: gone)+ RemoveMembershipService.new(membership: gone.memberships.find_by!(organisation: organisation), admin: admin).call+ expect(row.reload.user_id).to be_nil+ sign_in admin++ show_meeting+ expect(response.body).to include(CGI.escapeHTML(new_link_path(gone_participant)))++ post_link("person:#{row.id}", target: gone_participant)+ expect(response).to have_http_status(:ok)+ expect(gone_participant.reload.slice(:person_id, :user_id)).to eq('person_id' => row.id, 'user_id' => nil)++ get organisation_people_path(organisation, person_id: row.id), headers: { 'Turbo-Frame' => Organisations::PeopleController::DETAIL_FRAME_ID }+ expect(response.body).to include('Hosting-Abstimmung')+ end+it 'keeps a chip as text when its person is a row the viewer may not see' dohidden_member = member_with(create(:role, organisation: organisation), first_name: 'Hanna')create(:project_permission, user: hidden_member, project: create(:project, organisation: organisation),@@ -190,6 +212,20 @@ RSpec.describe 'Organisations::MeetingParticipantLinks', :ci_guard, type: :requeexpect(response.body).not_to include(I18n.t("#{pl}.suggestion"))end+ it 'does not name a linked person the viewer may not see' do+ hidden_member = member_with(create(:role, organisation: organisation), first_name: 'Hanna')+ create(:project_permission, user: hidden_member, project: create(:project, organisation: organisation),+ tickets_access: :read_only)+ hidden_row = create(:person, organisation: organisation, name: 'Hanna Weber', user: hidden_member)+ participant.update_column(:person_id, hidden_row.id)+ sign_in writer('view_people')++ get new_link_path++ expect(response.body).to include(I18n.t("#{pl}.linked"), 'Jonas Weber')+ expect(response.body).not_to include('Hanna Weber')+ end+it 'offers no new person without manage_people' dosign_in writer('view_people')@@ -231,6 +267,17 @@ RSpec.describe 'Organisations::MeetingParticipantLinks', :ci_guard, type: :requeexpect(response.body).to include('Hosting-Abstimmung')end+ it 'redraws the chips without the dialog frame, so a late answer closes no other dialog' do+ sign_in admin++ post_link("person:#{contact.id}")++ chips_id = ActionView::RecordIdentifier.dom_id(meeting, :participants)+ replaced = response.body[%r{<turbo-stream action="replace" target="#{chips_id}">[\s\S]*?</turbo-stream>}]+ expect(replaced).to include('J. Weber (Hoster)')+ expect(replaced).not_to include("<turbo-frame id=\"meeting-participant-link-modal-#{meeting.id}\"")+ end+it 'links a member by account and leaves person_id empty' docolleague = member_with(create(:role, organisation: organisation), first_name: 'Carl')sign_in admin@@ -346,6 +393,9 @@ RSpec.describe 'Organisations::MeetingParticipantLinks', :ci_guard, type: :requepost_link("person:#{foreign.id}")expect(response).to have_http_status(:not_found)+ # The dialog is drawn again for the pick, and still names nobody it may not see.+ expect(response.body).to include(I18n.t('services.actors.link_meeting_participant.not_found'))+ expect(response.body).not_to include('Fremde Weber')expect_unchangedend@@ -358,8 +408,11 @@ RSpec.describe 'Organisations::MeetingParticipantLinks', :ci_guard, type: :requepost_link("person:#{hidden_row.id}")expect(response).to have_http_status(:not_found)+ expect(response.body).to include('Jonas Weber')+ expect(response.body).not_to include('Hanna Weber')post_link("member:#{hidden_member.id}")expect(response).to have_http_status(:not_found)+ expect(response.body).not_to include('Hanna Weber')expect_unchangedenddiff --git a/spec/services/actors/claim_meeting_participants_spec.rb b/spec/services/actors/claim_meeting_participants_spec.rbindex 6ff36b0..458f529 100644--- a/spec/services/actors/claim_meeting_participants_spec.rb+++ b/spec/services/actors/claim_meeting_participants_spec.rb@@ -80,6 +80,22 @@ RSpec.describe Actors::ClaimMeetingParticipants doexpect(MeetingParticipant.where(id: row.id).pluck(:user_id, :person_id)).to eq([[nil, person.id]])end+ # A link set between the claim's read and its write (the link dialog takes+ # the meeting lock, the claim does not) must not give the row a second key.+ it 'skips a row linked to a contact between its read and its write' do+ target = member+ person = create(:person, organisation: organisation, name: 'Karl Krause')+ row = external_row(writable_project, 'Karl Krause')+ claim = described_class.new(user: target, normalized_name: 'Karl Krause', current_user: actor)+ allow(claim).to receive(:linkable_participant_ids).and_wrap_original do |original|+ original.call.tap { row.update_column(:person_id, person.id) }+ end++ claim.call++ expect(MeetingParticipant.where(id: row.id).pluck(:user_id, :person_id)).to eq([[nil, person.id]])+ end+it 'matches across umlaut spellings (member "Jörg Groß" ~ external "Joerg Gross")' dotarget = member(first: 'Jörg', last: 'Groß')row = external_row(writable_project, 'Joerg Gross')diff --git a/spec/system/meeting_participant_link_spec.rb b/spec/system/meeting_participant_link_spec.rbindex a7baf83..2464bb5 100644--- a/spec/system/meeting_participant_link_spec.rb+++ b/spec/system/meeting_participant_link_spec.rb@@ -61,6 +61,27 @@ RSpec.describe 'Linking a meeting participant to a person', type: :system doexpect(page).to have_css("##{trigger_id}:focus")end+ # A refusal swaps the dialog for a new instance: the focus must still go back to the+ # button that opened it, and a search in the refused dialog must still work.+ it 'gives the focus back after a refusal, a search and Escape' do+ visit organisation_project_meetings_path(organisation, project, meeting_id: meeting.id)+ open_dialog++ within('[role="dialog"]') { click_button I18n.t("#{pl}.submit") }+ expect(page).to have_css('[role="dialog"]', text: I18n.t('services.actors.link_meeting_participant.nothing_picked'))+ within('[role="dialog"]') do+ fill_in I18n.t("#{pl}.search_label"), with: 'anders'+ expect(page).to have_no_css('li', text: 'Jonas Weber')+ end+ find('[role="dialog"] input[type="search"]').send_keys(:escape)++ expect(page).to have_no_css('[role="dialog"]')+ expect(page).to have_css("##{trigger_id}:focus")++ open_dialog+ expect(page).to have_no_text(I18n.t('services.actors.link_meeting_participant.nothing_picked'))+ end+it 'closes on Escape without linking' dovisit organisation_project_meetings_path(organisation, project, meeting_id: meeting.id)open_dialog