Repository navigation
Fix seven UX problems in the palette, the scan, and the series list - #18
Conversation
Go Library opened the library that the library screen showed last, or the first library of the server. The library screen shows no Go Library, because the entry opened the same screen again.
A scan reloaded only home and the library screen, so an open series list, series, or detail screen kept the data from before the scan. A load of the series list or of a series now reaches its screen also behind the active screen.
A scan can take minutes, and pine showed nothing until its end. A second Scan Library while a scan runs does nothing.
The cache keeps the library list for 24 hours and the lists for 15 minutes, so a change on the server that pine does not make showed late. Refresh clears the local cache and loads the screens again.
With no sort, ABS gives the series in no defined order. Each row shows the number of books of the series in place of the word "Series". The cached series lists have no books, so the cache key version is v2.
The palette searched only the library of the current screen, so a book of a different library was not found. The matches of the current library come first, and the matches of each other library are below a header with its name.
The check read the first 10 items, so a library with ebooks first and audiobooks later was hidden, and an empty book library was hidden too. The longest item has audio if any item has.
- The box covered the right end of a long error. It goes one row down while the banner shows, and it is 3 rows high, not 5. - AGENTS.md describes the reload after a scan, the refresh, the scan box, and the series list as they are.
Thelost77
left a comment
There was a problem hiding this comment.
Verdict: request changes. go build ./..., go vet ./... and go test ./... all pass. The issues are races in the Bubble Tea update loop. AGENTS.md matches the new control flow but doesn't cover these cases.
Findings: 1 high, 2 medium, 3 low. Five are inline below. One sits on lines outside the diff, so it's here:
Low: on the sessions screen, Go Library, Scan Library and the first search group follow the home library. currentLibraryForSearch (internal/app/model.go, around line 1287) falls back to the home selection for every screen except library, series, series list, detail and home. If you open sessions for the playing item, or for a book you reached after pressing Tab on the library screen, home can be on a different library, and the palette then labels and scans that one. sessions.Target has no library id. Suggested fix: store the item's library on the sessions target (use playbackLibraryID for the playing item) and read it in currentLibraryForSearch.
| } | ||
| var cmds []tea.Cmd | ||
| if m.screenOpen(ScreenSeriesList) && inLibrary(m.seriesList.SelectedLibraryID()) { | ||
| cmds = append(cmds, m.seriesList.Init()) |
There was a problem hiding this comment.
High: a scan or Refresh can splice the series list.
serieslist.Model.Init() (internal/screens/serieslist/model.go:107) has a value receiver, and its fetchSeriesCmd (:195) sets loading = true on that copy. reloadOpenScreensCmd throws the copy away, so the live model keeps loading == false and its old pages.
LoadedMsg carries no library id or generation, and the root applies every one (model.go:601), including to a list behind the active screen. Page 0 replaces the slice and any later page appends (serieslist/model.go:124). A prefetch already in flight, or one the next keypress starts because loading is still false, can land after the reload. You end up with page 0 plus an old later page, so rows go missing or repeat.
The series screen has the same hole: series.LoadedMsg (internal/screens/series/model.go:109) doesn't check the series id, so a reload of series A can fill series B.
The new e2e test only checks that one new series name shows up, and TestSeriesLoadedMsgReachesScreenBehindActiveScreen only checks that Loading() becomes false.
Suggested fix: give each load a generation plus a library or series id, drop messages that don't match, and accept an append only when page == m.page+1. Use a pointer method on the model Update returns so loading = true sticks, and clear the rows when the reload starts.
| // RefreshCmd reads the library list from the client again, and loads the | ||
| // shelves of the current library. | ||
| func (m *Model) RefreshCmd() tea.Cmd { | ||
| m.libraries = nil |
There was a problem hiding this comment.
Medium: Refresh can show another library's shelves.
Setting libraries to nil here makes SelectedLibraryID() empty until the new fetch lands. The stale-message check (:207) only drops a PersonalizedMsg when the current id is non-empty, so an older fetch from before the refresh, or from before a library switch, gets applied. Once the libraries are restored, the shelves come from that old message but are labeled with SelectedLibraryID() (:226), which follows selectedLibrary. So a slow response for library A can paint A's books under B's name, and a slow response from before the refresh can overwrite the fresh one.
Suggested fix: put loadingGen on PersonalizedMsg and drop any message whose generation isn't current. Keep the library id on the model until that response arrives, and set contentLibrary from msg.LibraryID.
| if m.screenOpen(ScreenSeries) && inLibrary(m.series.LibraryID()) { | ||
| cmds = append(cmds, m.series.Init()) | ||
| } | ||
| if item := m.detail.Item(); m.screenOpen(ScreenDetail) && inLibrary(item.LibraryID) { |
There was a problem hiding this comment.
Medium: a scan that finishes during a bookmark title edit cancels the edit.
This always refetches bookmarks for an open detail screen. BookmarksUpdatedMsg (internal/screens/detail/model.go:510) sets editingBookmark = false whenever the fetch succeeds, so the title being typed is thrown away. A scan often outlives the palette, and the user can start an edit after the scan has begun.
Suggested fix: skip the bookmark reload while EditingBookmark() is true, or keep the edit when that bookmark is still in the new list.
| } | ||
|
|
||
| // The palette covers the scan box. | ||
| content = m.overlayScanBox(content) |
There was a problem hiding this comment.
Low: the scan box is drawn over the chapter modal.
View draws the chapter overlay and the detail confirmation first, then the scan box (:48, :56). The box sits at headerHeight (:403). On a short terminal the chapter modal starts on that same row, so the spinner covers its top-right corner. The error-banner test doesn't open either modal.
Suggested fix: draw the scan box before those overlays, and skip it while either one is open.
| @@ -786,11 +826,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | |||
| return m, cmd | |||
|
|
|||
| case search.CacheReadyMsg: | |||
There was a problem hiding this comment.
Low: every library that becomes ready resets the palette highlight.
CacheReadyMsg calls Palette.Refresh, and applyFilter (internal/ui/components/palette.go:470) always selects the first action. A single open search now does this once per library, so the highlight jumps back to the top while you're moving through the list.
Suggested fix: keep the selected item id when it's still in the new list.
The box covered the top right part of a high chapter overlay.
Each library whose index became ready moved the highlight back to the first result.
- A reload during a bookmark title edit loaded the bookmarks, and that load closes the editor. The reload skips them during an edit. - A second load of the episodes moved the selection back to the recent episode. It keeps the selected episode.
A reload after a scan or a refresh did not mark the series list as loading, and a load message had no ID. A load of a next page from before the reload then put an old page after the new first page, and a late answer filled the screen of a different series. - serieslist.LoadedMsg has the library ID and a generation, and series.LoadedMsg has the series ID. A screen drops a mismatch. - The series list reloads with ReloadCmd, which raises the generation and blocks the load of a next page.
Refresh set the library list to nil, which turned off the check for an old answer. An old answer for one library then showed below the name of a different library, and it replaced the new shelves. - A PersonalizedMsg has the generation of its load, and the screen drops an earlier one. - The library list stays during a refresh. The answer selects the same library by its ID, not by its position.
On the sessions screen of an item, Go Library, Scan Library, Browse Series, and the search used the library of the home screen, which can be a different library.
Seven fixes for UX problems in pine that a review of the command palette, the scan flow, the cache, and the series list found.
Changes
Each number is one commit.
Go Libraryopens the library of the current screen. Before, it opened the first library of the server, or the library that the library screen showed last. The entry does not show on the library screen. (5111f79)Scan Library: <name>, and it does nothing while a scan runs. (404310c)Refreshclears the local cache, then loads the screens and the library list again. It needs no admin permission and starts no scan. (c5d73c2)v1-tov2-, because the cached series type changes. (7fe2a49)Building index…shows while an index is not ready. pine builds the index of each library in the background. (12c7abe)One more commit has the fixes from the first review of the seven commits: the scan box is 3 rows high and does not cover the error banner, and
AGENTS.mddescribes the new behavior. (d689d87)Fixes for the review findings
Each finding of the review on this pull request has one commit.
Refreshcan splice the series list: a load message of the series list has the library ID and a generation, and a load message of the series screen has the series ID. A screen drops a message that does not match. The reload marks the list as loading, so no load of a next page starts. (da7004d)Refreshcan show the shelves of a different library: the home load message has the generation of its load, and home drops an earlier one. The library list stays during a refresh, and the answer selects the same library by its ID. (f0f118c)Verification
gofmt -l .shows no file.go vet ./...reports nothing.golangci-lint run(v2.14.0) reports 0 issues.PINE_REQUIRE_LIBMPV=1 PINE_REQUIRE_DBUS=1 go test ./... -count=1passes: 1036 tests in 31 packages.mainhas 1006.Not verified:
Viewoutput of the scan box and of the palette.sort=nameon the series endpoint and tosort=media.durationwithdesc=1on the items endpoint. The parameters come from the Audiobookshelf source (seriesFilters.js,libraryItemsBookFilters.js,LibraryController.js).Known limits
Building index…stays. Each key press starts a new build.