detached 0fa0a1a

fix(web): send the issues changed notice of a merge request page once

commit
0fa0a1afd9720e32f6a27e945ae54f23cfabeaea
author
brice · · 2026-10-22 18:38 UTC
committer
brice · · 2026-10-22 18:41 UTC
parent
2a12bb1
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +27 -3
M internal/adapters/web/fragments.go +16 -3
@@ -39,6 +39,9 @@ type liveStream struct {
3939 headRuns map[int64]bool
4040 // mergeChecksHTML is the last merge-form part sent, not sent again unchanged.
4141 mergeChecksHTML string
42+ // issuesNoticeSent says the "issues changed" notice of a merge request
43+ // page was sent: a merge resolving several issues sends it once.
44+ issuesNoticeSent bool
4245 }
4346
4447 // maxHeadRuns bounds headRuns: past it the map starts again.
@@ -243,17 +246,17 @@ func (l *liveStream) repoPage(ctx context.Context, we ports.WatchEvent) ([]fragm
243246 return l.issueNotice(ctx, ev.Issue.Number, "an issue was opened — reload")
244247 case domain.IssueResolved:
245248 if l.view == "mr" {
246- return l.notice(ctx, "issues changed — reload", mrBase(l.repo)+"/"+l.n)
249+ return l.issuesChanged(ctx)
247250 }
248251 return l.issueNotice(ctx, ev.Issue.Number, "this issue was resolved — reload")
249252 case domain.IssueClosed:
250253 if l.view == "mr" {
251- return l.notice(ctx, "issues changed — reload", mrBase(l.repo)+"/"+l.n)
254+ return l.issuesChanged(ctx)
252255 }
253256 return l.issueNotice(ctx, ev.Issue.Number, "this issue was closed — reload")
254257 case domain.IssueReopened:
255258 if l.view == "mr" {
256- return l.notice(ctx, "issues changed — reload", mrBase(l.repo)+"/"+l.n)
259+ return l.issuesChanged(ctx)
257260 }
258261 return l.issueNotice(ctx, ev.Issue.Number, "this issue was reopened — reload")
259262 case domain.IssueCommented:
@@ -577,6 +580,16 @@ func (l *liveStream) mrMergeability(ctx context.Context) ([]fragment, error) {
577580 return []fragment{f}, err
578581 }
579582
583+// issuesChanged tells a merge request page that its issues changed, once per
584+// stream: the notice already asks for a reload.
585+func (l *liveStream) issuesChanged(ctx context.Context) ([]fragment, error) {
586+ if l.issuesNoticeSent {
587+ return nil, nil
588+ }
589+ l.issuesNoticeSent = true
590+ return l.notice(ctx, "issues changed — reload", mrBase(l.repo)+"/"+l.n)
591+}
592+
580593 func (l *liveStream) notice(ctx context.Context, text, href string) ([]fragment, error) {
581594 f, err := renderFragment(ctx, "mr-notice", MRNotice(text, href))
582595 return []fragment{f}, err
@@ -39,6 +39,9 @@ type liveStream struct {
39 headRuns map[int64]bool39 headRuns map[int64]bool
40 // mergeChecksHTML is the last merge-form part sent, not sent again unchanged.40 // mergeChecksHTML is the last merge-form part sent, not sent again unchanged.
41 mergeChecksHTML string41 mergeChecksHTML string
42+ // issuesNoticeSent says the "issues changed" notice of a merge request
43+ // page was sent: a merge resolving several issues sends it once.
44+ issuesNoticeSent bool
42 }45 }
43 46
44 // maxHeadRuns bounds headRuns: past it the map starts again.47 // maxHeadRuns bounds headRuns: past it the map starts again.
@@ -243,17 +246,17 @@ func (l *liveStream) repoPage(ctx context.Context, we ports.WatchEvent) ([]fragm
243 return l.issueNotice(ctx, ev.Issue.Number, "an issue was opened — reload")246 return l.issueNotice(ctx, ev.Issue.Number, "an issue was opened — reload")
244 case domain.IssueResolved:247 case domain.IssueResolved:
245 if l.view == "mr" {248 if l.view == "mr" {
246- return l.notice(ctx, "issues changed — reload", mrBase(l.repo)+"/"+l.n)249+ return l.issuesChanged(ctx)
247 }250 }
248 return l.issueNotice(ctx, ev.Issue.Number, "this issue was resolved — reload")251 return l.issueNotice(ctx, ev.Issue.Number, "this issue was resolved — reload")
249 case domain.IssueClosed:252 case domain.IssueClosed:
250 if l.view == "mr" {253 if l.view == "mr" {
251- return l.notice(ctx, "issues changed — reload", mrBase(l.repo)+"/"+l.n)254+ return l.issuesChanged(ctx)
252 }255 }
253 return l.issueNotice(ctx, ev.Issue.Number, "this issue was closed — reload")256 return l.issueNotice(ctx, ev.Issue.Number, "this issue was closed — reload")
254 case domain.IssueReopened:257 case domain.IssueReopened:
255 if l.view == "mr" {258 if l.view == "mr" {
256- return l.notice(ctx, "issues changed — reload", mrBase(l.repo)+"/"+l.n)259+ return l.issuesChanged(ctx)
257 }260 }
258 return l.issueNotice(ctx, ev.Issue.Number, "this issue was reopened — reload")261 return l.issueNotice(ctx, ev.Issue.Number, "this issue was reopened — reload")
259 case domain.IssueCommented:262 case domain.IssueCommented:
@@ -577,6 +580,16 @@ func (l *liveStream) mrMergeability(ctx context.Context) ([]fragment, error) {
577 return []fragment{f}, err580 return []fragment{f}, err
578 }581 }
579 582
583+// issuesChanged tells a merge request page that its issues changed, once per
584+// stream: the notice already asks for a reload.
585+func (l *liveStream) issuesChanged(ctx context.Context) ([]fragment, error) {
586+ if l.issuesNoticeSent {
587+ return nil, nil
588+ }
589+ l.issuesNoticeSent = true
590+ return l.notice(ctx, "issues changed — reload", mrBase(l.repo)+"/"+l.n)
591+}
592+
580 func (l *liveStream) notice(ctx context.Context, text, href string) ([]fragment, error) {593 func (l *liveStream) notice(ctx context.Context, text, href string) ([]fragment, error) {
581 f, err := renderFragment(ctx, "mr-notice", MRNotice(text, href))594 f, err := renderFragment(ctx, "mr-notice", MRNotice(text, href))
582 return []fragment{f}, err595 return []fragment{f}, err
M internal/adapters/web/fragments_test.go +11 -0
@@ -133,3 +133,14 @@ func TestIssueTransitionsRefreshMRRail(t *testing.T) {
133133 })
134134 }
135135 }
136+
137+func TestIssueTransitionsNoticeMROnce(t *testing.T) {
138+ l := liveStream{repo: "demo", view: "mr", n: "7"}
139+ var notices int
140+ for _, ev := range []domain.Event{domain.IssueResolved{}, domain.IssueResolved{}, domain.IssueReopened{}} {
141+ fs, err := l.repoPage(t.Context(), ports.WatchEvent{Event: ev})
142+ require.NoError(t, err)
143+ notices += len(fs)
144+ }
145+ assert.Equal(t, 1, notices)
146+}
@@ -133,3 +133,14 @@ func TestIssueTransitionsRefreshMRRail(t *testing.T) {
133 })133 })
134 }134 }
135 }135 }
136+
137+func TestIssueTransitionsNoticeMROnce(t *testing.T) {
138+ l := liveStream{repo: "demo", view: "mr", n: "7"}
139+ var notices int
140+ for _, ev := range []domain.Event{domain.IssueResolved{}, domain.IssueResolved{}, domain.IssueReopened{}} {
141+ fs, err := l.repoPage(t.Context(), ports.WatchEvent{Event: ev})
142+ require.NoError(t, err)
143+ notices += len(fs)
144+ }
145+ assert.Equal(t, 1, notices)
146+}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 4

Tags 45

↑↓ moveenter openesc close