Skip to content

Fix seven UX problems in the palette, the scan, and the series list - #18

Merged
Thelost77 merged 14 commits into
mainfrom
fix/ux-gotchas
Nov 17, 2026
Merged

Thelost77 merged 14 commits into
mainfrom
fix/ux-gotchas

Conversation

@Thelost77

@Thelost77 Thelost77 commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

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.

  1. Go Library opens 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)
  2. After a scan, the open series list, series screen, and detail screen of the scanned library load again. Before, only home and the library screen loaded again. (3acd8b3)
  3. A small box with a spinner shows "Scanning …" at the right edge while a scan runs. The entry is Scan Library: <name>, and it does nothing while a scan runs. (404310c)
  4. The new palette entry Refresh clears the local cache, then loads the screens and the library list again. It needs no admin permission and starts no scan. (c5d73c2)
  5. The series list is in name order, and each row shows its number of books. The cache key version goes from v1- to v2-, because the cached series type changes. (7fe2a49)
  6. The palette search shows the results of the current library first, then the results of each other library below a header with its name. The row Building index… shows while an index is not ready. pine builds the index of each library in the background. (12c7abe)
  7. pine hides a book library only when it has items and none has audio. It reads the item with the longest duration, not a sample of 10 items. An empty library stays in the list. (d5de770)

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.md describes the new behavior. (d689d87)

Fixes for the review findings

Each finding of the review on this pull request has one commit.

  • High, a scan or Refresh can 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)
  • Medium, Refresh can 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)
  • Medium, a scan cancels a bookmark title edit: the reload does not load the bookmarks during an edit. A second load of the episodes also keeps the selected episode. (e4888cc)
  • Low, the scan box is drawn over the chapter modal: the chapter overlay and the confirmation dialog now cover the box. (ff96903)
  • Low, each ready library resets the palette highlight: a refresh of the palette keeps the selected item while it is in the list. (84633e1)
  • Low, the sessions screen uses the home library: the sessions of an item use the library of that item. (692e43b)

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=1 passes: 1036 tests in 31 packages. main has 1006.
  • Each change has a test that failed before the fix.

Not verified:

  • A manual run of the TUI. The tests assert the View output of the scan box and of the palette.
  • The answers of a real server to sort=name on the series endpoint and to sort=media.duration with desc=1 on the items endpoint. The parameters come from the Audiobookshelf source (seriesFilters.js, libraryItemsBookFilters.js, LibraryController.js).

Known limits

  • After the update, pine fetches each cached value one more time, because of the new cache key version.
  • If an index build fails, for example with no network, the row Building index… stays. Each key press starts a new build.
  • If a bookmark title edit starts while a reload of the bookmarks is in flight, the answer closes the editor. The reload does not start during an edit.
  • The sessions of all items have no library, so the palette uses the library of the home screen there.

Wiktor Ziębka added 8 commits November 17, 2026 10:44
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 Thelost77 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/app/model.go Outdated
}
var cmds []tea.Cmd
if m.screenOpen(ScreenSeriesList) && inLibrary(m.seriesList.SelectedLibraryID()) {
cmds = append(cmds, m.seriesList.Init())

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/screens/home/model.go Outdated
// 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

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/app/model.go
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) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/app/render.go Outdated
}

// The palette covers the scan box.
content = m.overlayScanBox(content)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/app/model.go
@@ -786,11 +826,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, cmd

case search.CacheReadyMsg:

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Wiktor Ziębka added 6 commits November 17, 2026 11:46
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.
@Thelost77
Thelost77 merged commit a47cb3c into main Nov 17, 2026
6 checks passed
Thelost77 pushed a commit that referenced this pull request Nov 17, 2026
Ship pull request #18 (seven UX fixes for the palette, the scan,
and the series list) and 12ed355 (browse series only in book
libraries) as a minor release. The palette has the new entry
Refresh, the search shows the results of each library, and a box
shows while a scan runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant