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
fix: review round 2 of #121, offer everywhere only where the page shows every match
Guido Boyke10b4baec4ec5
diff --git a/app/controllers/organisations/meeting_term_corrections_controller.rb b/app/controllers/organisations/meeting_term_corrections_controller.rbindex 2382497..4489b09 100644--- a/app/controllers/organisations/meeting_term_corrections_controller.rb+++ b/app/controllers/organisations/meeting_term_corrections_controller.rb@@ -55,6 +55,8 @@ module Organisations@dialog = build_dialog(heard: heard_param)return refused(notice: :recounted) if @dialog.recounted?return refused(errors: [mark_error_text(@dialog)]) unless @dialog.correctable?+ # Everywhere only where the page shows every occurrence (the dialog offers no button otherwise).+ return refused(errors: [t('views.organisations.meetings.term_correction.count.everywhere_hidden')]) if everywhere_hidden?actor = Actors::CorrectMeetingTerm.new(**correction_arguments)result = actor.call@@ -156,11 +158,17 @@ module Organisationsenddef mark_error_text(dialog)- return t("views.organisations.meetings.term_correction.mark_errors.#{dialog.mark_error}") if dialog.mark_error+ key = 'views.organisations.meetings.term_correction'+ return t("#{key}.mark_errors.#{dialog.mark_error}", max: GlossaryTerm::MAX_LENGTH) if dialog.mark_error+ return t("#{key}.count.ambiguous") if dialog.heard_error == :ambiguoust('services.actors.correct_meeting_term.place_gone')end+ def everywhere_hidden?+ scalar_param(:scope) == 'everywhere' && [email protected]?+ end+def render_forbiddenskip_authorizationif turbo_frame_request?diff --git a/app/services/CLAUDE.md b/app/services/CLAUDE.mdindex a282601..63af4aa 100644--- a/app/services/CLAUDE.md+++ b/app/services/CLAUDE.md@@ -203,7 +203,10 @@ Verzeichnis-Übersicht (Auswahl):Seite aus derselben Darstellung (`MeetingsHelper#meeting_transcript_html`), n-ter Treffer dort =n-ter Treffer im Speicher. ⚠️ Gleiche Zahl ist kein Beweis (Link-Ziel versteckt, Entität erzeugt):der Treffer wird mit einer Marke an seiner Stelle neu dargestellt und nur genommen, wenn die Marke- genau an der Markierung steht (Review-Runde 1 von #121), sonst Ablehnung. `term_correction_dialog.rb`+ genau an der Markierung steht (Review-Runde 1 von #121), sonst Ablehnung. Eine im Dialog geänderte+ Form bekommt denselben Beweis (`#place_of`), und „überall“ gibt es nur, wenn die Seite mit je+ einer eigenen Marke für JEDEN Treffer unverändert bleibt (`#everywhere?`, Runde 2): ein Treffer+ im Link-Ziel lässt nur „nur hier“. `term_correction_dialog.rb`ist, was der Dialog zeigt (Stelle, Zahl, Sprecher, Digest), geteilt von `new`, `count`, `create`.* `people/` — `directory.rb`, das Lese-Objekt der Personenliste (seit 26.10.2026): Mitgliederüber `MembershipPolicy::Scope` (dieselbe Reichweite wie die Mitgliederseite), dazu diediff --git a/app/services/actors/correct_meeting_term.rb b/app/services/actors/correct_meeting_term.rbindex 7aab25e..c29bb1b 100644--- a/app/services/actors/correct_meeting_term.rb+++ b/app/services/actors/correct_meeting_term.rb@@ -15,7 +15,10 @@# * The place comes from the client (through Meetings::TranscriptMark) and is# only taken where the heard form stands as an occurrence# (Meetings::TermReplacement#at): never in a speaker label, never part of a-# longer word.+# longer word. That the page shows it there is the caller's proof+# (Meetings::TranscriptMark#place_of), as is, for "everywhere", that the+# page shows every occurrence this writes (#everywhere?, review round 2 of+# #121: a match in a link target changed unseen).# * The transcript is written through Actors::SaveMeeting (derived text,# search, fragments as for an edit). On "everywhere" the AI summary gets the# same replacement; it stays in either case (keep_summary: true, the one@@ -88,7 +91,7 @@ module Actorsattr_reader :current_userdef refuse(code)- raise ActorError.new(I18n.t("services.actors.correct_meeting_term.#{code}"), code: code)+ raise ActorError.new(I18n.t("services.actors.correct_meeting_term.#{code}", max: GlossaryTerm::MAX_LENGTH), code: code)enddef check_formsdiff --git a/app/services/meetings/term_correction_dialog.rb b/app/services/meetings/term_correction_dialog.rbindex 129237d..3cd290f 100644--- a/app/services/meetings/term_correction_dialog.rb+++ b/app/services/meetings/term_correction_dialog.rb@@ -42,19 +42,32 @@ module Meetings@client_digest.present? && @client_digest != digestend- # mark_error: nil, or why the mark has no place (Meetings::TranscriptMark's- # codes). place: the marked span in the stored transcript, or nil.- delegate :error, :place, to: :mark_result, prefix: false- alias mark_error error+ # nil, or why the mark itself has no place (Meetings::TranscriptMark's+ # codes): then the dialog offers no form at all.+ def mark_error+ mark_result.error+ end++ # nil, or why the heard form as typed has no place at the mark+ # (not_at_mark, ambiguous): then the dialog offers no button.+ def heard_error+ heard_result&.error+ end++ # The place of the heard form at the mark in the stored transcript, proved+ # on the page (Meetings::TranscriptMark#place_of), or nil.+ def place+ heard_result&.place+ enddef heard_blank?@heard.strip.empty?end- # The occurrence of the heard form at the mark, or nil: then nothing can- # be replaced (the form was changed into one that does not stand there).+ # The occurrence of the heard form at that place, or nil: then nothing can+ # be replaced.def occurrence- return if place.nil? || heard_blank?+ return if place.nil?@occurrence ||= replacement.at(**place.to_h)end@@ -63,6 +76,13 @@ module Meetings!occurrence.nil?end+ # Whether "everywhere" may run: the page shows every occurrence of the+ # heard form (Meetings::TranscriptMark#everywhere?). A match the page hides,+ # a link target say, leaves only "only here".+ def everywhere?+ correctable? && transcript_mark.everywhere?(@heard)+ end+delegate :count, to: :replacement# Who spoke the marked line, a participant or nil.@@ -77,9 +97,19 @@ module Meetingsprivate+ def transcript_mark+ @transcript_mark ||= TranscriptMark.new(transcript: @transcript, render: @render, participants: @participants,+ **@mark.slice(:text, :before, :after, :offset))+ end+def mark_result- @mark_result ||= TranscriptMark.resolve(transcript: @transcript, render: @render,- participants: @participants, **@mark.slice(:text, :before, :after, :offset))+ transcript_mark.resolve+ end++ def heard_result+ return if mark_error || heard_blank?++ @heard_result ||= transcript_mark.place_of(@heard)enddef replacementdiff --git a/app/services/meetings/term_replacement.rb b/app/services/meetings/term_replacement.rbindex 47aee29..8000c58 100644--- a/app/services/meetings/term_replacement.rb+++ b/app/services/meetings/term_replacement.rb@@ -30,9 +30,11 @@ module Meetings# What shows nothing (a zero-width space, a soft hyphen, a bidi mark: the# set GlossaryText drops) joins what stands around it, as the reader sees# it: "Lalabeis<zero-width space>Konto" reads as one word. The boundary- # looks past it, before the form up to two such characters (a look-behind- # has a fixed width), after it any number.+ # looks past a run of up to MAX_INVISIBLE_RUN such characters, the same on+ # both sides (a look-behind has a fixed width, so the run has a limit;+ # a longer run counts as a boundary on both sides alike).INVISIBLE = GlossaryText::INVISIBLE.source+ MAX_INVISIBLE_RUN = 3# Between the words of a form: horizontal whitespace only.WORD_GAP = '[[:blank:]]+'@@ -75,12 +77,18 @@ module Meetings# given (one of #occurrences), and how many it replaced.def replace(with:, only: nil)targets = only.nil? ? occurrences : [own!(only)]- by_line = targets.group_by(&:line_index)- result = lines.each_with_index.map do |line, index|- hits = by_line[index]- hits ? replaced_line(line, hits, with) : line- end- Replaced.new(text: result.join("\n"), count: targets.size)+ rewrite(targets.map { |hit| [hit, with] })+ end++ # The text with every occurrence replaced by what the block gives for it+ # (Meetings::TranscriptMark puts a marker of its own in each one).+ def replace_each+ rewrite(occurrences.map { |hit| [hit, yield(hit)] })+ end++ # The stored text of one match, as it stands in its line.+ def text_at(match)+ lines[match.line_index].byteslice(match.byte_offset, match.byte_length)end# The occurrence that overlaps a marked span of one line, or nil.@@ -137,9 +145,19 @@ module Meetings# One line with `with` in place of its hits, put together from the pieces# between them (in bytes, one pass).- def replaced_line(line, hits, with)+ # pairs: [match, the text in its place], at most one per match.+ def rewrite(pairs)+ by_line = pairs.group_by { |hit, _with| hit.line_index }+ result = lines.each_with_index.map do |line, index|+ here = by_line[index]+ here ? replaced_line(line, here) : line+ end+ Replaced.new(text: result.join("\n"), count: pairs.size)+ end++ def replaced_line(line, pairs)cursor = 0- result = hits.sort_by(&:byte_offset).each_with_object(+'') do |hit, changed|+ result = pairs.sort_by { |hit, _with| hit.byte_offset }.each_with_object(+'') do |(hit, with), changed|changed << line.byteslice(cursor, hit.byte_offset - cursor) << withcursor = hit.byte_offset + hit.byte_lengthend@@ -148,8 +166,8 @@ module Meetingsdef patternbody = @words.map { |word| Regexp.escape(word) }.join(WORD_GAP)- before = "(?<!#{WORD_CHARACTER})(?<!#{WORD_CHARACTER}#{INVISIBLE})(?<!#{WORD_CHARACTER}#{INVISIBLE}#{INVISIBLE})"- Regexp.new("#{before}#{body}(?!#{INVISIBLE}*#{WORD_CHARACTER})")+ before = (0..MAX_INVISIBLE_RUN).map { |run| "(?<!#{WORD_CHARACTER}#{INVISIBLE * run})" }.join+ Regexp.new("#{before}#{body}(?!#{INVISIBLE}{0,#{MAX_INVISIBLE_RUN}}#{WORD_CHARACTER})")end# The frontmatter's lines are no content: nobody sees or marks them. Adiff --git a/app/services/meetings/transcript_mark.rb b/app/services/meetings/transcript_mark.rbindex 4452804..7e6d563 100644--- a/app/services/meetings/transcript_mark.rb+++ b/app/services/meetings/transcript_mark.rb@@ -16,7 +16,7 @@# takes the match with the same number in the stored transcript# (Meetings::TermReplacement#scan, the rule of counting and replacing).#-# The same number is no proof. Markdown can hide one match (a link target, a+# The same number is no proof, and the same count is not either. Markdown can hide one match (a link target, a# reference definition, a tag the sanitizer drops) and show another (an# entity, a link text right at the word): the counts agree, the order does# not (review round 1 of #121). So the match found is put back through the@@ -24,13 +24,22 @@# the page then shows the marker exactly where the reader marked, with all# the rest of its text unchanged.#+# The dialog can change the heard form (#place_of): its occurrence at the mark+# gets the same proof. And "everywhere" replaces every stored match of the+# form (#everywhere?): it is offered only when the page shows each of them, a+# marker of its own in each place, and the page otherwise as before; a match+# in a link target, say, leaves only "only here" (review round 2 of #121).+## It refuses rather than guesses:# * not_found: no place shows the mark with its context, or several do;# * not_a_word: the mark is part of a longer word;-# * ambiguous: the page and the stored text hold the form a different number-# of times, or the match with the same number does not show at the mark;+# * ambiguous: the match with the same number does not show at the mark (a+# match Markdown hid stands before it, or the page shows one the stored text+# does not hold); the proof decides, not the counts, so a hidden match after+# the mark does not stand in the way;# * speaker_label: the mark stands in the speaker label of its line;-# * line_break, too_long: no heard form at all.+# * line_break, too_long: no heard form at all;+# * not_at_mark (#place_of): the changed form does not stand at the mark.## Characters, not bytes and not UTF-16 units: the browser counts code points.#@@ -40,6 +49,8 @@ module Meetings# What the browser sends on each side, and the most this class reads.CONTEXT_LENGTH = 40MAX_CONTEXT_LENGTH = 200+ # Letters and digits only, so Markdown reads a marker as the word it stands for.+ MARKER = /Q[0-9A-Za-z]{16}Q/Place = Data.define(:line_index, :char_offset, :length)@@ -71,14 +82,38 @@ module Meetingsenddef resolve- return refuse(:not_found) if @mark.empty?- return refuse(:line_break) if @mark.match?(/[\r\n]/)- return refuse(:too_long) if @mark.length > GlossaryTerm::MAX_LENGTH+ @resolve ||= begin+ start = locate if checked_mark.nil?+ checked_mark || (start ? map(start) : refuse(:not_found))+ end+ end++ # The place of a heard form at the mark: the mark's own place for the form+ # as marked, else the occurrence of the changed form that overlaps the mark,+ # proved at its place on the page the same way.+ def place_of(heard)+ result = resolve+ return result unless result.success?+ return result if same_form?(heard)- start = locate- return refuse(:not_found) unless start+ replacement = replacement_for(heard)+ occurrence = replacement.at(**result.place.to_h)+ return refuse(:not_at_mark) unless occurrence- map(start)+ start = @mark_start + (occurrence.byte_offset - @mark_match.byte_offset)+ return refuse(:ambiguous) unless start >= 0 && shows_at?(replacement, occurrence, start, replacement.text_at(occurrence).bytesize)++ Result.new(place: place_for(occurrence), error: nil)+ end++ # Whether "everywhere" may replace the heard form: the form stands at the+ # mark, and the page shows every stored occurrence of it, each at a place of+ # its own and in order, with the page otherwise as before.+ def everywhere?(heard)+ @everywhere ||= {}+ return @everywhere[heard] if @everywhere.key?(heard)++ @everywhere[heard] = place_of(heard).success? && all_shown?(replacement_for(heard))endprivate@@ -89,25 +124,64 @@ module Meetingsordinal = shown.index { |match| match.line_index == line_index && match.byte_offset == column }return refuse(:not_a_word) unless ordinal- stored = TermReplacement.new(text: @transcript, heard: @mark, participants: @participants)- return refuse(:ambiguous) unless stored.scan.size == shown.size-+ stored = replacement_for(@mark)match = stored.scan[ordinal]+ return refuse(:ambiguous) unless matchreturn refuse(:speaker_label) if match.in_label- return refuse(:ambiguous) unless shows_at_mark?(stored, match, start)+ return refuse(:ambiguous) unless shows_at?(stored, match, start, @mark.bytesize)++ @mark_match = match+ @mark_start = start+ Result.new(place: place_for(match), error: nil)+ end++ def checked_mark+ if @mark.empty? then refuse(:not_found)+ elsif @mark.match?(/[\r\n]/) then refuse(:line_break)+ elsif @mark.length > GlossaryTerm::MAX_LENGTH then refuse(:too_long)+ end+ end++ def place_for(match)+ Place.new(line_index: match.line_index, char_offset: match.char_offset, length: match.length)+ end++ # The proof of a place: the stored match, replaced by a marker and shown+ # through the page's own rendering, shows the marker exactly where `length`+ # bytes of the page start at `start`, and every other character as before.+ def shows_at?(replacement, match, start, length)+ marker = new_marker+ shown = text_of(@render.call(replacement.replace(with: marker, only: match).text))+ shown == visible.byteslice(0, start) + marker + visible.byteslice(start + length, visible.bytesize)+ end++ # Every occurrence replaced by a marker of its own: the page shows the+ # markers once each, in order, and with the stored texts put back it is the+ # page as it was.+ def all_shown?(replacement)+ texts = {}+ probe = replacement.replace_each { |occurrence| new_marker.tap { |marker| texts[marker] = replacement.text_at(occurrence) } }+ shown = text_of(@render.call(probe.text))+ return false unless shown.scan(MARKER) == texts.keys++ shown.gsub(MARKER) { |marker| texts.fetch(marker, marker) } == visible+ end++ def new_marker+ "Q#{SecureRandom.alphanumeric(16)}Q"+ end++ def same_form?(heard)+ words(heard) == words(@mark)+ end- Result.new(place: Place.new(line_index: match.line_index, char_offset: match.char_offset, length: match.length),- error: nil)+ def words(text)+ text.to_s.split(/[[:space:]]+/).reject(&:empty?)end- # The proof of the number: the stored match, replaced by a marker and- # shown through the page's own rendering, shows the marker exactly at the- # mark, and every other character of the page as before. The marker is- # letters and digits only, so Markdown reads it as the word it replaces.- def shows_at_mark?(stored, match, start)- marker = "Q#{SecureRandom.alphanumeric(16)}Q"- shown = text_of(@render.call(stored.replace(with: marker, only: match).text))- shown == visible.byteslice(0, start) + marker + visible.byteslice(start + @mark.bytesize, visible.bytesize)+ def replacement_for(heard)+ @replacements ||= {}+ @replacements[words(heard)] ||= TermReplacement.new(text: @transcript, heard: heard, participants: @participants)end# The text the content element of the page holds, as the browser reads itdiff --git a/app/views/organisations/meeting_term_corrections/_count.html.erb b/app/views/organisations/meeting_term_corrections/_count.html.erbindex f066ecf..ded0b7c 100644--- a/app/views/organisations/meeting_term_corrections/_count.html.erb+++ b/app/views/organisations/meeting_term_corrections/_count.html.erb@@ -4,7 +4,8 @@the correction replaces (Meetings::TermReplacement). Its own frame, reloaded bymeeting_term_corrections#count while the heard form is typed; it carries the digest of thetranscript it counted, so a correction of another transcript is counted again, never made.- No button where the heard form does not stand at the mark. %>+ No button where the heard form does not stand at the mark, and no "everywhere" where the page+ hides one of its occurrences (a link target, say): that one would change unseen. %><% tc = 'views.organisations.meetings.term_correction' %><%= turbo_frame_tag term_correction_count_id(meeting.id, token), class: 'term-correction-count block space-y-3' do %><%= hidden_field_tag :digest, dialog.digest, id: nil %>@@ -14,6 +15,8 @@<p class="text-sm text-cream-800" aria-live="polite"><% if dialog.heard_blank? %><%= t("#{tc}.count.heard_blank") %>+ <% elsif dialog.heard_error == :ambiguous %>+ <%= t("#{tc}.count.ambiguous") %><% elsif !dialog.correctable? %><%= t("#{tc}.count.not_at_mark") %><% elsif dialog.speaker %>@@ -23,6 +26,9 @@<%= t("#{tc}.count.found", count: dialog.count) %><% end %></p>+ <% if dialog.correctable? && !dialog.everywhere? %>+ <p class="term-correction-hint text-xs text-cream-600"><%= t("#{tc}.count.everywhere_hidden") %></p>+ <% end %><div class="flex flex-wrap justify-end gap-2 border-t border-cream-200 pt-3"><button type="button"class="h-9 rounded border border-cream-300 bg-cream-100 px-4 text-sm font-medium text-cream-800 hover:bg-cream-200"@@ -33,8 +39,10 @@<%= render Neo::Buttons::ButtonComponent.new(variant: :secondary, size: :medium, type: 'submit', name: 'scope', value: 'here') do %><%= t("#{tc}.here") %><% end %>- <%= render Neo::Buttons::ButtonComponent.new(variant: :primary, size: :medium, type: 'submit', name: 'scope', value: 'everywhere') do %>- <%= t("#{tc}.everywhere", count: dialog.count) %>+ <% if dialog.everywhere? %>+ <%= render Neo::Buttons::ButtonComponent.new(variant: :primary, size: :medium, type: 'submit', name: 'scope', value: 'everywhere') do %>+ <%= t("#{tc}.everywhere", count: dialog.count) %>+ <% end %><% end %><% end %></div>diff --git a/app/views/organisations/meeting_term_corrections/_modal.html.erb b/app/views/organisations/meeting_term_corrections/_modal.html.erbindex 7710ffd..9b73ec6 100644--- a/app/views/organisations/meeting_term_corrections/_modal.html.erb+++ b/app/views/organisations/meeting_term_corrections/_modal.html.erb@@ -56,7 +56,7 @@<% if dialog.mark_error %><p class="term-correction-error text-sm text-red-800" role="alert">- <%= t("#{tc}.mark_errors.#{dialog.mark_error}") %>+ <%= t("#{tc}.mark_errors.#{dialog.mark_error}", max: GlossaryTerm::MAX_LENGTH) %></p><div class="flex justify-end border-t border-cream-200 pt-3"><button type="button"diff --git a/config/locales/services.de.yml b/config/locales/services.de.ymlindex c4c75fd..b673d2a 100644--- a/config/locales/services.de.yml+++ b/config/locales/services.de.yml@@ -69,9 +69,9 @@ de:stale_transcript: "Das Transkript hat sich inzwischen geändert."place_gone: "An der markierten Stelle steht diese Form nicht. Markiere das Wort im Transkript neu."speaker_not_found: "Diesen Sprecher gibt es in diesem Meeting nicht."- heard_invalid: "Die gehörte Form muss ein Wort oder mehrere Wörter in einer Zeile sein, höchstens 255 Zeichen."+ heard_invalid: "Die gehörte Form muss ein Wort oder mehrere Wörter in einer Zeile sein, höchstens %{max} Zeichen."correct_blank: "Bitte die richtige Form eingeben."- correct_too_long: "Die richtige Form darf höchstens 255 Zeichen lang sein."+ correct_too_long: "Die richtige Form darf höchstens %{max} Zeichen lang sein."same_form: "Die richtige Form ist dieselbe wie die gehörte."invalid_scope: "Bitte wählen: nur hier oder überall ersetzen."move_ticket:diff --git a/config/locales/services.en.yml b/config/locales/services.en.ymlindex f095543..34c2376 100644--- a/config/locales/services.en.yml+++ b/config/locales/services.en.yml@@ -69,9 +69,9 @@ en:stale_transcript: "The transcript has changed in the meantime."place_gone: "This form does not stand at the marked place. Mark the word in the transcript again."speaker_not_found: "This speaker is not part of this meeting."- heard_invalid: "The heard form must be one or more words on one line, at most 255 characters."+ heard_invalid: "The heard form must be one or more words on one line, at most %{max} characters."correct_blank: "Please enter the right form."- correct_too_long: "The right form may be at most 255 characters long."+ correct_too_long: "The right form may be at most %{max} characters long."same_form: "The right form is the same as the heard one."invalid_scope: "Please choose: replace only here or everywhere."move_ticket:diff --git a/config/locales/views/meetings.de.yml b/config/locales/views/meetings.de.ymlindex 0c46ff6..7d0b318 100644--- a/config/locales/views/meetings.de.yml+++ b/config/locales/views/meetings.de.yml@@ -180,6 +180,8 @@ de:one: "Kommt 1-mal vor, bei %{speaker}."other: "Kommt %{count}-mal vor, davon %{speaker_count}-mal bei %{speaker}."not_at_mark: Diese Form steht nicht an der markierten Stelle. Ändere sie oder markiere neu.+ ambiguous: Diese Form lässt sich an der markierten Stelle nicht sicher zuordnen. Markiere sie neu oder ändere sie über „Bearbeiten“.+ everywhere_hidden: Überall ersetzen geht hier nicht. Die Form steht auch an Stellen, die die Seite nicht zeigt (etwa in einem Link).heard_blank: Bitte die gehörte Form eingeben.mark_errors:not_found: Diese Stelle lässt sich im Transkript nicht finden. Lade die Seite neu und markiere noch einmal.@@ -187,7 +189,7 @@ de:ambiguous: Diese Form steht im Transkript anders, als die Seite sie zeigt (etwa in einem Link). Ändere sie über „Bearbeiten“.speaker_label: Der Name des Sprechers gehört zur Teilnehmerliste und lässt sich hier nicht korrigieren.line_break: Bitte nur innerhalb einer Zeile markieren.- too_long: Die Markierung ist zu lang, höchstens 255 Zeichen.+ too_long: "Die Markierung ist zu lang, höchstens %{max} Zeichen."flash:replaced:one: 1 Stelle ersetzt.diff --git a/config/locales/views/meetings.en.yml b/config/locales/views/meetings.en.ymlindex d3d2c6a..6d4a7a8 100644--- a/config/locales/views/meetings.en.yml+++ b/config/locales/views/meetings.en.yml@@ -179,6 +179,8 @@ en:one: "Appears once, by %{speaker}."other: "Appears %{count} times, %{speaker_count} of them by %{speaker}."not_at_mark: This form does not stand at the marked place. Change it or mark again.+ ambiguous: This form cannot be matched to the marked place for sure. Mark it again or change it through "Edit".+ everywhere_hidden: Replacing everywhere does not work here. The form also stands in places the page does not show (in a link, for example).heard_blank: Please enter the heard form.mark_errors:not_found: This place cannot be found in the transcript. Reload the page and mark again.@@ -186,7 +188,7 @@ en:ambiguous: This form stands differently in the transcript than the page shows it (in a link, for example). Change it through "Edit".speaker_label: The speaker's name belongs to the participant list and cannot be corrected here.line_break: Please mark within one line.- too_long: The mark is too long, at most 255 characters.+ too_long: "The mark is too long, at most %{max} characters."flash:replaced:one: 1 place replaced.diff --git a/spec/requests/organisations/glossary_spec.rb b/spec/requests/organisations/glossary_spec.rbindex 2fdeab1..d739b2f 100644--- a/spec/requests/organisations/glossary_spec.rb+++ b/spec/requests/organisations/glossary_spec.rb@@ -910,6 +910,18 @@ RSpec.describe 'Organisations::Glossary', :ci_guard, type: :request doexpect(row.text).to include(I18n.t("#{gs}.index.open_forms", count: 1))end+ # Review round 2 of #121: the badge counts forms, not their proposals.+ it 'counts open forms, not the proposals in them' do+ create(:term_correction, organisation: organisation, glossary_term: term, heard: 'Lala Beis', status: 'proposed')+ create(:term_correction, organisation: organisation, glossary_term: term, heard: 'lala bese', status: 'proposed')+ sign_in viewer+ get organisation_glossary_terms_path(organisation)++ row = Nokogiri::HTML(response.body).css('[data-glossary-row]').find { |node| node.text.include?('Lalabase') }+ expect(row.text).to include(I18n.t("#{gs}.index.open_forms", count: 2))+ expect(row.text).not_to include(I18n.t("#{gs}.index.open_forms", count: 3))+ end+it 'shows the open form as a proposal in the lane, without buttons for a reader' dosign_in viewergroup = open_group(lane_markup)diff --git a/spec/requests/organisations/meeting_term_corrections_spec.rb b/spec/requests/organisations/meeting_term_corrections_spec.rbindex 93a551b..9a5630e 100644--- a/spec/requests/organisations/meeting_term_corrections_spec.rb+++ b/spec/requests/organisations/meeting_term_corrections_spec.rb@@ -70,8 +70,8 @@ RSpec.describe 'Organisations::MeetingTermCorrections', :ci_guard, type: :requesenddef correction_params(scope: 'everywhere', correct: 'Lalabase', heard: 'Lalabeis', speaker_id: ben.id, to_glossary: '1',- with_digest: digest)- { modal_token: modal_token, mark: browser_mark, digest: with_digest, scope: scope,+ with_digest: digest, mark: nil)+ { modal_token: modal_token, mark: mark || browser_mark, digest: with_digest, scope: scope,term_correction: { heard: heard, correct: correct, speaker_id: speaker_id, to_glossary: to_glossary } }end@@ -217,6 +217,52 @@ RSpec.describe 'Organisations::MeetingTermCorrections', :ci_guard, type: :requesendend+ # Review round 2 of #121: "everywhere" replaces every stored match, so the+ # page has to show each of them. A match the page hides (a link target)+ # leaves only "only here", in the dialog and in the write.+ describe 'a match the page does not show' do+ let(:transcript) { "Anna: Wir testen Lalabeis heute.\nBen: siehe [Wiki](https://example.com/Lalabeis) ok" }++ it 'offers only "only here", and says why' do+ sign_in writer('manage_glossary')+ get new_path(mark: browser_mark('Lalabeis', nth: 0)), headers: frame++ expect(page_markup).to have_button(I18n.t("#{tc}.here"))+ expect(page_markup).not_to have_button(I18n.t("#{tc}.everywhere", count: 2))+ expect(page_markup).to have_text(I18n.t("#{tc}.count.everywhere_hidden"))+ end++ it 'refuses everywhere and writes nothing, and corrects only here' do+ sign_in writer('manage_glossary')+ post organisation_project_meeting_term_correction_path(organisation, project, meeting),+ params: correction_params(mark: browser_mark('Lalabeis', nth: 0)), headers: stream++ expect(response).to have_http_status(:unprocessable_content)+ expect(stream_markup('replace', "meeting-term-correction-modal-#{meeting.id}-#{modal_token}"))+ .to have_text(I18n.t("#{tc}.count.everywhere_hidden"))+ expect(meeting.reload.transcript).to eq(transcript)++ post organisation_project_meeting_term_correction_path(organisation, project, meeting),+ params: correction_params(scope: 'here', mark: browser_mark('Lalabeis', nth: 0)), headers: stream++ expect(response).to have_http_status(:ok)+ expect(meeting.reload.transcript).to eq("Anna: Wir testen Lalabase heute.\nBen: siehe [Wiki](https://example.com/Lalabeis) ok")+ end+ end++ # Review round 2 of #121: the server reads the page through the meeting's+ # participants. Bolding a speaker drops the space before the colon+ # ("Anna : " shows as "Anna: "), so without them the text would differ and+ # the mark would not be found.+ it 'finds a mark behind a speaker label the page writes differently than the transcript' do+ meeting.update_columns(transcript: "Anna : Wir nutzen Lalabeis heute.\n")+ sign_in writer+ get new_path(mark: browser_mark('Lalabeis', nth: 0)), headers: frame++ expect(page_markup).to have_field('term_correction[heard]', with: 'Lalabeis')+ expect(page_markup).to have_button(I18n.t("#{tc}.here"))+ end+describe 'the count' doit 'counts the heard form as typed, in its own frame' dosign_in writerdiff --git a/spec/services/meetings/term_replacement_spec.rb b/spec/services/meetings/term_replacement_spec.rbindex fe519e7..38ee269 100644--- a/spec/services/meetings/term_replacement_spec.rb+++ b/spec/services/meetings/term_replacement_spec.rb@@ -73,6 +73,14 @@ RSpec.describe Meetings::TermReplacement doexpect(count("Lalabeis\u200E und \u200BLalabeis", 'Lalabeis')).to eq(2)end+ # Review round 2 of #121: the same rule before the form as after it, and+ # up to MAX_INVISIBLE_RUN characters that show nothing on either side.+ it 'reads characters that show nothing before the form as part of the word too, up to the same run on both sides' do+ expect(count("Konto\u200BLalabeis", 'Lalabeis')).to eq(0)+ expect(count("Konto\u200B\u200B\u200BLalabeis und Lalabeis\u200B\u200B\u200BKonto", 'Lalabeis')).to eq(0)+ expect(count("Wir \u200BLalabeis\u200B ok", 'Lalabeis')).to eq(1)+ end+it 'counts digits of every script as part of a word' doexpect(count('Raum 12 und Raum 123', 'Raum 12')).to eq(1)expect(count("Lalabeis\u0663 und Lalabeis", 'Lalabeis')).to eq(1)diff --git a/spec/services/meetings/transcript_mark_spec.rb b/spec/services/meetings/transcript_mark_spec.rbindex dd1c7dc..b437f69 100644--- a/spec/services/meetings/transcript_mark_spec.rb+++ b/spec/services/meetings/transcript_mark_spec.rb@@ -144,6 +144,87 @@ RSpec.describe Meetings::TranscriptMark doexpect(result.place.to_h.values_at(:line_index, :char_offset)).to eq([0, 8])end+ # Review round 2 of #121: the heard form can be changed in the dialog, and+ # "everywhere" replaces every stored match. Both need the same proof as the+ # mark: the changed form at the mark shows there, and every match that+ # "everywhere" would replace shows on the page at a place of its own.+ describe 'a changed heard form and "everywhere"' do+ def mark_object(text, nth: 0, mark: 'Lalabeis')+ described_class.new(transcript: text, render: render, participants: participants,+ **browser_mark(text, mark, nth: nth))+ end++ it 'finds the changed form at the mark, and says that everywhere would reach a place the page hides' do+ text = "Anna: Lala beis heute.\nBen: siehe [Wiki](https://example.com/Lala) ok"+ mark = mark_object(text, mark: 'Lala beis')++ expect(mark.resolve).to be_success+ expect(mark.place_of('Lala').place.to_h).to eq(line_index: 0, char_offset: 6, length: 4)+ expect(mark.everywhere?('Lala')).to be(false)+ expect(mark.everywhere?('Lala beis')).to be(true)+ end++ it 'says that everywhere would reach a place the page hides, also for the form as marked' do+ text = "Ben: Lalabeis ist gut.\nAnna: siehe [Wiki](https://example.com/Lalabeis) ok"+ mark = mark_object(text)++ expect(mark.resolve).to be_success+ expect(mark.everywhere?('Lalabeis')).to be(false)+ end++ it 'allows everywhere where the page shows every match, in a link text, bold and in a list as well' do+ text = "Ben: [Lalabeis](https://example.com/wiki) und **Lalabeis**\n- Lalabeis\nAnna: Lalabeis."+ mark = mark_object(text, nth: 1)++ expect(mark.resolve).to be_success+ expect(mark.everywhere?('Lalabeis')).to be(true)+ end++ # The page shows "Lala beis", the stored text holds "Lala *beis*": the+ # changed form stands at the mark, but not as the page shows it.+ it 'refuses a changed form whose place the page shows otherwise' do+ text = "Anna: Lala *beis* heute.\n"+ mark = mark_object(text, mark: 'Lala')+ mark.resolve++ expect(mark.place_of('Lala *beis*').error).to eq(:ambiguous)+ end++ it 'refuses a changed form that does not stand at the mark' do+ text = "Anna: Lala beis heute.\nBen: Konto ok"+ mark = mark_object(text, mark: 'Lala beis')+ mark.resolve++ expect(mark.place_of('Konto').error).to eq(:not_at_mark)+ expect(mark.everywhere?('Konto')).to be(false)+ end+ end++ # Review round 2 of #121: the proof compares the whole text, not only what+ # stands before the marker.+ it 'refuses when the page shows anything after the marker other than before' do+ text = "Ben: Lalabeis ist gut.\n"+ changed_after = lambda do |source|+ html = ApplicationController.helpers.meeting_transcript_html(source, participants)+ source.match?(/Q[0-9A-Za-z]{16}Q/) ? html.sub('gut.', 'gut, anders.') : html+ end++ result = described_class.resolve(transcript: text, render: changed_after, participants: participants,+ **browser_mark(text, 'Lalabeis'))++ expect(result.error).to eq(:ambiguous)+ end++ # Review round 2 of #121: where the 40 characters around the mark repeat,+ # only the offset tells the places apart.+ it 'tells places with the same context apart by the offset alone' do+ text = Array.new(6) { 'Ben: Lalabeis ja' }.join("\n")++ result = resolve(text, **browser_mark(text, 'Lalabeis', nth: 2))++ expect(result.place.to_h.values_at(:line_index, :char_offset)).to eq([2, 5])+ end+it 'refuses a mark over a line break and a mark too long for the glossary' dotwo_lines = "Anna: eins Lala\nBeis zwei\n"long = "Anna: #{'x' * 300}\n"diff --git a/spec/system/meeting_term_correction_spec.rb b/spec/system/meeting_term_correction_spec.rbindex f9628b4..9a3d8d7 100644--- a/spec/system/meeting_term_correction_spec.rb+++ b/spec/system/meeting_term_correction_spec.rb@@ -164,6 +164,30 @@ RSpec.describe 'Correcting a term in a meeting', type: :system doexpect(meeting.reload.transcript).to start_with("Anna: Wir testen Lalabase heute.\nBen: Lalabeis kann viel")end+ # Review round 2 of #121: where the 40 characters around the mark repeat,+ # only the offset the browser counts tells the places apart.+ it 'corrects the marked one of several lines that read the same' do+ user = admin(:de)+ meeting = meeting_for(user)+ repeated = Array.new(6) { 'Ben: Lalabeis ja' }.join("\n")+ meeting.update!(transcript: repeated)+ sign_in user+ visit organisation_project_meetings_path(organisation, project, meeting_id: meeting.id)+ expect(page).to have_text('Ben: Lalabeis ja')++ mark_in_transcript(meeting, 'Lalabeis', nth: 2)+ find("#meeting-term-correction-trigger-#{meeting.id}").click+ within('[role="dialog"]') do+ fill_in I18n.t("#{tc}.correct_label", locale: :de), with: 'Lalabase'+ click_button I18n.t("#{tc}.here", locale: :de)+ end++ expect(page).to have_text(I18n.t("#{tc}.flash.replaced", count: 1, locale: :de))+ expect(meeting.reload.transcript.split("\n")).to eq(+ ['Ben: Lalabeis ja', 'Ben: Lalabeis ja', 'Ben: Lalabase ja', 'Ben: Lalabeis ja', 'Ben: Lalabeis ja', 'Ben: Lalabeis ja']+ )+ end+it 'offers no correction in the panel beside a ticket' douser = admin(:de)meeting = meeting_for(user)