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
Keep the meeting in front while the panel beside the ticket opens
Guido Boyke1da49231249c
diff --git a/app/javascript/controllers/ticket_meeting_panel_controller.js b/app/javascript/controllers/ticket_meeting_panel_controller.jsindex 6e825d7..e9e3489 100644--- a/app/javascript/controllers/ticket_meeting_panel_controller.js+++ b/app/javascript/controllers/ticket_meeting_panel_controller.js@@ -37,6 +37,17 @@ export default class extends Controller {panelMax: number("--panel-max"),gap: number("--lane-gap")}+ // The link just clicked to open the panel sits in the ticket and keeps the focus+ // (Safari focuses no clicked link: then nothing needs excusing). Until the focus+ // leaves that link, nobody is working in the ticket (workingInTicket); whoever+ // comes back to it later is moving through the ticket. Only a link that loads+ // this frame: any other focus in the ticket is somebody's work, however the+ // panel came.+ const active = document.activeElement+ const frameId = this.element.closest("turbo-frame")?.id+ const link = frameId && active?.matches?.(`a[data-turbo-frame="${CSS.escape(frameId)}"]`) ? active : null+ this.openingLink = link+ link?.addEventListener("blur", () => { if (this.openingLink === link) this.openingLink = null }, { once: true })// Before the lane opens, so its first frame already has the right stage.this.select("meeting")this.updateStage(this.grid.getBoundingClientRect().width)@@ -60,6 +71,7 @@ export default class extends Controller {document.removeEventListener("keydown", this.boundCloseOnEscape)this.laneObserver?.disconnect()this.resizeObserver?.disconnect()+ this.openingLink = null// A tab of the panel replaces this content and connects a new instance in the// same task, which writes both again before anything is painted.delete this.grid?.dataset.meetingPanelStage@@ -78,13 +90,16 @@ export default class extends Controller {// Unless the panel was already open and somebody is working in the ticket (the// focus is in it): the grid narrows under their hands (a window or the assistant// dragged), and hiding the field they type into would send the next keys- // nowhere. Not on opening: the link just clicked sits in the ticket, too.- if (stage === "narrow") this.select(previous && this.ticketHasFocus() ? "ticket" : "meeting")+ // nowhere. Not on opening: the link just clicked sits in the ticket, too. And the+ // opening is not one moment: the assistant pushes the page aside in a transition+ // of <main>, so a panel opened during it sees the grid narrow a few frames later.+ if (stage === "narrow") this.select(previous && this.workingInTicket() ? "ticket" : "meeting")}- ticketHasFocus() {+ workingInTicket() {const active = document.activeElement- return Boolean(active && active !== document.body && this.grid.querySelector(":scope > .column.content")?.contains(active))+ if (!active || active === document.body || active === this.openingLink) return false+ return Boolean(this.grid.querySelector(":scope > .column.content")?.contains(active))}showTicket() {diff --git a/spec/system/ticket_meeting_panel_stages_spec.rb b/spec/system/ticket_meeting_panel_stages_spec.rbindex 02b3f10..33df8f6 100644--- a/spec/system/ticket_meeting_panel_stages_spec.rb+++ b/spec/system/ticket_meeting_panel_stages_spec.rb@@ -58,9 +58,14 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sysProsopite.resumeend- def open_at(window_width)+ def visit_ticket_at(window_width)page.driver.browser.manage.window.resize_to(window_width, 900)visit organisation_project_tickets_path(organisation, project, ticket_id: ticket.id)+ expect(page).to have_css("#ticket-content-#{ticket.id}")+ end++ def open_at(window_width)+ visit_ticket_at(window_width)open_panelend@@ -69,6 +74,21 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sysexpect(page).to have_css('aside.column.panel h2', text: 'Planning call')end+ # The panel's frame loads it, without a click on a link: the focus stays where it is.+ def load_panel(meeting_id)+ url = organisation_project_ticket_meeting_panel_path(organisation, project, ticket, meeting_id: meeting_id)+ page.execute_script("document.getElementById('ticket_meeting_panel').src = #{url.to_json}")+ end++ # A control of the ticket the reader has moved on to, the first VISIBLE one: the first+ # in the markup is the phone's back button, hidden here. Until 2026-10-29 the focus test+ # focused that one, which did nothing, and the focus stayed on the link that opened the+ # panel: the test ran on the opening, not on work in the ticket.+ def focus_ticket_control+ find('#ticket-header').first('a[href], button').execute_script('this.focus()')+ expect(page).to have_css('#ticket-header :focus')+ end+def stage = find('.layout')['data-meeting-panel-stage']def rect(selector, side)@@ -200,11 +220,8 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sysendit 'offers the way back to the ticket when the meeting is not available on a narrow grid' do- page.driver.browser.manage.window.resize_to(1024, 900)- visit organisation_project_tickets_path(organisation, project, ticket_id: ticket.id)- expect(page).to have_css("#ticket-content-#{ticket.id}")- url = organisation_project_ticket_meeting_panel_path(organisation, project, ticket, meeting_id: SecureRandom.uuid)- page.execute_script("document.getElementById('ticket_meeting_panel').src = #{url.to_json}")+ visit_ticket_at(1024)+ load_panel(SecureRandom.uuid)expect(page).to have_css('.layout[data-meeting-panel-stage="narrow"]:not(.hide-panel)')expect(page).to have_text(I18n.t('views.organisations.tickets.meeting_panel.unavailable'))@@ -215,7 +232,7 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sysit 'keeps the ticket in front when the grid narrows while the ticket has the focus' doopen_at(1200)expect(page).to have_css('.layout[data-meeting-panel-stage="medium"]')- page.execute_script("document.querySelector('#ticket-header a[href], #ticket-header button').focus()")+ focus_ticket_controlfocused = page.evaluate_script('document.activeElement.outerHTML')page.driver.browser.manage.window.resize_to(1024, 900)@@ -225,6 +242,39 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sysexpect(page).to have_css("#ticket-content-#{ticket.id}", visible: :visible)expect(page.evaluate_script('document.activeElement.outerHTML')).to eq(focused)end++ # The opening is excused for the link that loads the panel, and for nothing else: a+ # panel that arrives while the focus is on another control of the ticket (loaded+ # here without a click) leaves the ticket in front when the grid narrows.+ it 'keeps the ticket in front when the focus was in the ticket before the panel came' do+ visit_ticket_at(1200)+ focus_ticket_control+ load_panel(meeting.id)+ expect(page).to have_css('.layout[data-meeting-panel-stage="medium"]:not(.hide-panel)')+ expect(page).to have_css('#ticket-header :focus')++ page.driver.browser.manage.window.resize_to(1024, 900)++ expect(page).to have_css('.layout[data-meeting-panel-stage="narrow"]')+ expect(stage_tab("Ticket ##{ticket.number}")['aria-pressed']).to eq('true')+ end++ # And the excuse ends when the focus leaves that link: whoever comes back to it+ # later, by keyboard, is moving through the ticket.+ it 'keeps the ticket in front when the focus has left the opening link and come back' do+ open_at(1200)+ expect(page).to have_css('.layout[data-meeting-panel-stage="medium"]')+ link = "#meeting-references-#{ticket.id} a.meeting-reference--panel"+ expect(page).to have_css("#{link}:focus")+ focus_ticket_control+ find(link).execute_script('this.focus()')+ expect(page).to have_css("#{link}:focus")++ page.driver.browser.manage.window.resize_to(1024, 900)++ expect(page).to have_css('.layout[data-meeting-panel-stage="narrow"]')+ expect(stage_tab("Ticket ##{ticket.number}")['aria-pressed']).to eq('true')+ endend# The split follows the GRID's width as well: the assistant changes it without the@@ -269,8 +319,7 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sysendit 'shows the tabs on a grid the assistant has made narrow' do- page.driver.browser.manage.window.resize_to(1280, 900)- visit organisation_project_tickets_path(organisation, project, ticket_id: ticket.id)+ visit_ticket_at(1280)find('#assistant-panel-trigger').clickexpect(page).to have_css('body.assistant-panel-open')open_panel@@ -280,6 +329,31 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sysexpect(stage_tab('Meeting')['aria-pressed']).to eq('true')expect(assistant_open?).to be(true)end++ # The assistant pushes the page aside in a transition of <main> (half a second), so+ # a meeting opened right after it opens on a grid that is still medium and turns+ # narrow under it. The focus is then still on the link just clicked, in the ticket:+ # that is opening the meeting, not working in the ticket, and the meeting stays in+ # front (F6). Until 2026-10-29 the ticket came to the front in about one CI run in+ # four. Here the transition is held at its start while the panel opens and then+ # finished at once, so no clock decides the race.+ it 'keeps the meeting in front when the grid narrows while the panel is still opening' do+ visit_ticket_at(1280)+ main = "document.querySelector('.mobile-app-screen > main')"+ page.execute_script("#{main}.style.transitionDuration = '600s'")+ find('#assistant-panel-trigger').click+ # The composer takes the focus once its frame has loaded, and nothing moves it after that.+ expect(page).to have_css('#assistant_panel [data-neo-chat-composer-target="field"]:focus')+ within("#meeting-references-#{ticket.id}") { click_link 'Planning call' }+ expect(page).to have_css('.layout[data-meeting-panel-stage="medium"]:not(.hide-panel)')+ expect(page).to have_css("#meeting-references-#{ticket.id} a.meeting-reference--panel:focus")++ page.execute_script("#{main}.getAnimations().forEach((animation) => animation.finish())")++ expect(page).to have_css('.layout[data-meeting-panel-stage="narrow"]')+ expect(stage_tab('Meeting')['aria-pressed']).to eq('true')+ expect(page).to have_css('aside.column.panel h2', text: 'Planning call', visible: :visible)+ endendcontext 'on the board' do