-
Notifications
You must be signed in to change notification settings - Fork 88
fix(revisions): queue refresh when log-batching stream is in flight #616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,7 @@ type Model struct { | |
| matchedStyle lipgloss.Style | ||
| ensureCursorView bool | ||
| requestInFlight bool | ||
| pendingRefresh bool | ||
| } | ||
|
|
||
| type revisionsMsg struct { | ||
|
|
@@ -347,15 +348,27 @@ func (m *Model) internalUpdate(msg tea.Msg) tea.Cmd { | |
| m.hasMore = msg.hasMore | ||
| m.isLoading = m.hasMore && len(m.offScreenRows) > 0 | ||
|
|
||
| streamDone := false | ||
| if m.hasMore { | ||
| // keep requesting rows until we reach the initial load count or the current cursor position | ||
| lastRowIndex := m.displayContextRenderer.GetLastRowIndex() | ||
| if len(m.offScreenRows) < m.cursor+1 || len(m.offScreenRows) < lastRowIndex+1 { | ||
| return m.requestMoreRows(msg.tag) | ||
| } | ||
| } else if m.streamer != nil { | ||
| m.streamer.Close() | ||
| // Have enough rows — close the stream so the jj process doesn't linger | ||
| if m.streamer != nil { | ||
| m.streamer.Close() | ||
| m.streamer = nil | ||
| } | ||
| streamDone = true | ||
| } else { | ||
| if m.streamer != nil { | ||
| m.streamer.Close() | ||
| m.streamer = nil | ||
| } | ||
| streamDone = true | ||
| } | ||
| m.isLoading = false | ||
|
|
||
| currentSelectedRevision := m.SelectedRevision() | ||
| m.rows = m.offScreenRows | ||
|
|
@@ -378,6 +391,10 @@ func (m *Model) internalUpdate(msg tea.Msg) tea.Cmd { | |
| return common.UpdateRevisionsSuccessMsg{} | ||
| }) | ||
| } | ||
| if streamDone && m.pendingRefresh { | ||
| m.pendingRefresh = false | ||
| cmds = append(cmds, common.RefreshAndKeepSelections) | ||
| } | ||
|
Comment on lines
+394
to
+397
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not debouncing but queueing the next refresh. I don't see how this is helping with your situation. If a refresh is going on (say it takes 5 seconds each) and if you focus back 3 seconds later, instead of cancelling the ongoing one and saving 2 seconds, now you wait total of 10 seconds. Current implementation would settle in 8 seconds.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The debouncing is in the change to the |
||
| return tea.Batch(cmds...) | ||
| } | ||
|
|
||
|
|
@@ -498,6 +515,10 @@ func (m *Model) startBookmarkSet() tea.Cmd { | |
| } | ||
|
|
||
| func (m *Model) refresh(intent intents.Refresh) tea.Cmd { | ||
| if config.Current.Revisions.LogBatching && m.isLoading { | ||
| m.pendingRefresh = true | ||
| return nil | ||
| } | ||
| if !intent.KeepSelections { | ||
| m.context.ClearCheckedItems(reflect.TypeFor[appContext.SelectedRevision]()) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,7 +122,7 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd { | |
| } | ||
| return nil | ||
| case tea.FocusMsg: | ||
| return common.RefreshAndKeepSelections | ||
| return func() tea.Msg { return common.AutoRefreshMsg{} } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change doesn't make sense to me. Why using auto refresh message here?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The goal of this change was to take advantage of the AutoRefreshMsg behavior in revisions.go that only triggers a RefreshAndKeepSelections if the oplog has changed since the last update. Perhaps it would be better to put that check directly into the RefreshMsg handler instead? |
||
| case tea.MouseReleaseMsg: | ||
| if m.splitActive { | ||
| m.splitActive = false | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both of the branches are doing the same thing, so else branch is redundant here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 This PR in general was an off-cycle investigation w/ claude, and I clearly didn't look at the changes closely enough before submitting the PR.