--- name: zlib-tui description: Change zlib's Bubble Tea terminal screens, book cards, list spacing, or shell navigation while preserving shared layout and selection behavior. --- # zlib TUI changes Keep interactive CLI and shell entry points on shared models. `profile` uses `profilePageModel`; Kindle uses `runStandaloneShellCommand` for file selection, configuration, confirmation, password setup, and send results. Standalone pages exit to the terminal on return. Preserve JSON and non-interactive send behavior. Check `TestStandaloneKindleSharesShellPages`, `TestStandaloneKindlePasswordAndResult`, and `TestStandaloneProfileMatchesShellPage` when changing these flows. Home has no search input or Enter-to-search hint. Open commands with `/`; ignore ordinary typing, paste, and Ctrl+K on idle home. Esc closes the command list and restores home without an input. Keep the signed-out login shortcut. Check `TestShellHomeRequiresSlashForCommands` when changing home input handling. Use `renderActionButton` from `tui_layout.go` for every operation on a form, dialog, or result page. Its idle state uses the theme surface and title color; focus uses a filled accent, or error color for a destructive action. Keep two cells of horizontal padding, no border, and no `>` prefix. Wrap action groups with `actionButtonRows` at the available width. Color gaps between dialog buttons with the panel background; plain spaces can expose the terminal color after an ANSI reset. List and folder rows keep `selectionRow`. Check `TestActionButtonsShareConfirmationStyle` after changing button rendering. For the theme picker, keep the list and filter in the current palette while the preview follows the highlighted name. Paint component backgrounds, including cursor and separator cells. Check `TestThemePickerColorsFollowSelection` for all palettes at compact and wide sizes; preview and cancellation must not write preferences. Custom themes live in the user config `themes` directory. Ctrl+N copies the selected palette into a named file; Ctrl+E edits custom colors or starts a copy of a built-in. Validate names and `#RRGGBB` values before saving. Ctrl+S writes the file; Esc discards draft edits. Keep the selected-book preview row on the candidate theme's surface, with every preview cell painted. Check `TestCustomThemeCreateEditAndReload`, `TestCustomThemeValidationAndCancel`, and `TestThemeEditorFitsAndKeepsPaintedBackground`. Compare against a local clone of [charmbracelet/crush](https://github.com/charmbracelet/crush) (``). Check its current HEAD before relying on an old revision cited in docs. Browse `internal/ui/` for layout and component patterns. Its `internal` packages cannot be imported by zlib; use the Charm packages already in `go.mod`. Read [the TUI layout rules](../../../docs/tui.md#book-list-spacing) before changing book lists or cards. `book_feed_view.go` renders the shared Search, Favorites, Recommended, Most popular, and History list; keep its row calculation and rendered height aligned at compact and expanded terminal sizes. Search results appear together when a request finishes; do not bring back row-reveal animation. Loading, empty, and failed Search states keep controls at the bottom. Empty results show the page and filter action. Check `TestSearchResultsAppearTogetherAndSelectionStaysStable` and `TestSearchLoadingAndEmptyKeepControlsAtBottom`. The Search form in `search_filter_form.go` shows query, year range, language, format, exact match, and sort order together. Long choices open a centered picker; arrows navigate and Space toggles multiple choices. Ctrl+S submits; invalid years keep the form open with the error directly below the field. Filter rows use a fixed label column under a `sectionHeader("Filters", …)` rule; do not pass aligned label text through `selectionRow`, which collapses spaces. The query box needs 20 rows; the form caps at 100 columns. The result page reopens the same form with current filters and must resize it through `tea.WindowSizeMsg` so the input width matches the terminal. Loading, result status, and empty states show `searchFilterChips`; the status line drops them when fewer than 12 cells remain. Check `TestSearchFilterFormAlignsLabelsAndShowsErrorsAtField`, `TestSearchFilterFormQueryBoxFollowsTerminalSize`, `TestSearchStatesShowActiveFilters`, and `TestSearchRefineSizesQueryToTerminal`. Keep `SearchOptions`, `searchEAPI`, direct `search` flags, and the form mapped to the same EAPI fields. Check `TestSearchFilterFormSelectsEveryEAPIConstraint` and `TestSearchEAPISendsAllFilters`. Book details come from EAPI for the selected `id:hash`. Fetch after selection settles, cache by reference, and keep late results tied to their original book. Show fields the response provides; the Android model does not guarantee categories or separate ISBN fields. See [EAPI notes](../../../docs/eapi.md#current-scope) for the evidence boundary. Check the shared layout and selection tests in `internal/cli/book_feed_view_test.go` and the EAPI mapping tests in `internal/zlib/eapi_book_test.go`. When changing shared layout code, run `go test ./...` and `go vet ./...` after the focused test passes. Update `docs/tui.md` when interaction or spacing rules change. Keep recoverable failures on the page that owns the request. Download failure shows the book, a URL-safe reason, and `r` to retry with the same directory; retry must start a new shell generation so late messages are ignored. Kindle send failure shows the file and reason but has no automatic retry because SMTP delivery may have completed. Keep login and setting validation on their forms. Check `TestShellDownloadFailureKeepsContextAndRetries` and `TestShellKindleFailureRequiresExplicitResend` when changing these paths. In the shell, a completed download stays on its page with the absolute saved path and Back. Show Send to Kindle only when the saved file extension is in kindleAllowedTypes; keep hidden actions unreachable by keyboard. The Kindle action confirms before SMTP; cancel, missing settings, success, and failure return to the saved-file page without restarting the download. Wrap and scroll long paths; keep the standalone CLI download exit behavior. Check `TestShellDownloadReturnsToSelectedBook`, `TestShellDownloadKindleActionReturnsToCompletion`, and `TestDownloadCompletePathWrapsAndWaitsForReturn`. The Kindle and WeRead file pickers use `bookFileList`, which lists folders and only files whose extension (any case) the target accepts; do not return to the Bubbles file picker, which can only grey unsupported files out. Directory reads run in a command and reads for a folder already left are ignored. Check `TestWeReadFilePickerListsOnlySupportedBooks` and `TestWeReadFilePickerNavigatesFolders`. The WeRead login QR code (`weread_qr.go`) keeps square modules: one column and half a row each, drawn with half blocks, on a panel with as many modules across as down (`qrSide`). `qrFit` picks the largest quiet zone from 4 down to 2 that fits the terminal; never draw a clipped code, name the size needed instead. Encode at level L. The page uses `tightScreenView`, which spends four rows on title, subtitle, status and key hints, so a standard 80×24 terminal shows the whole code. Check `TestQRPanelIsSquareWithQuietZone`, `TestQRFitPicksLargestQuietZoneThatFits`, `TestWeReadLoginShowsWholeCodeOnStandardTerminal` and `TestWeReadLoginNeverClipsTheCode`. WeRead import checks format and per-format size with `weread.CheckImportFile` before any confirmation; the confirmation note names the size and target account. The import page lists the three `weread.ImportStage` steps with done, current and pending marks, and shows the bar only during upload. Esc cancels and stays on the page until WeRead answers the cancellation; Ctrl+C then stops waiting and reports the import as unconfirmed. Delivery outcomes on the saved-file page use `noticeSuccess` or `noticeError` through `returnToDownloadCompletion`. The settings account page keeps status, actions and key hints before the optional intro and import rules. Check `TestWeReadImportPageShowsEachStage`, `TestWeReadImportCancelWaitsForWeRead`, `TestShellWeReadImportResultNamesOutcome` and `TestSettingsWeReadAccountShowsImportRulesWhenTheyFit`. When Kindle SMTP password is missing after confirmation, open a masked form. Save `ZLIB_SMTP_PWD` to the global `.env`, set it in the current process, then continue the same send. Cancel returns to the saved file; a write error stays on the form. Check `TestShellKindlePasswordSaveFailureKeepsMaskedForm` and `TestSettingsSaveSMTPPasswordWithoutChangingOtherKeys`. The Doctor shell page uses Bubbles list, spinner, and the shared help renderer, following the local Crush command-list pattern. Keep its results limited to domains accepted by `availableDomains`. Show one domain per row, use the accent border for the focused row, and mark the current configured domain separately. Retry and page exit must cancel the prior probe context. Check `TestDoctorPageListsOnlyAvailableDomains` and `TestDoctorPageRetryRejectsOldResultsAndCancelsOnExit` after changing it. Profile shows the EAPI daily used count and limit once, above a width-aware horizontal progress bar. Keep unknown quota distinct from zero used, use two account columns on wide terminals, and show scroll controls only when content overflows. Check `TestProfileQuotaBarUsesWidthAndDoesNotRepeatRemaining` and `TestProfilePageUsesFullScreenAndScrolls`. For shell home changes, keep the original five-row letterforms in `shell_home.go`, painted by `homeWordmark` with one column-wise Accent-to-Link gradient (`wordmarkRampEnd` substitutes Info or Success when Link is too close to Accent). Show nothing else with it: no brand text, build version, side strokes or trademark sign. Signed-in command hints use muted descriptions; the signed-out home shows a heading, a focused `renderActionButton("Log in")`, and the sign-in method only. Check `TestHomeWordmarkGradientVisibleInEveryTheme`. Keep the logo free of side strokes. The hints name commands registered in `shellCommands`; typing `/` opens the selectable palette. Without a saved session, shell startup opens the login form directly; Esc reaches the signed-out home, which shows the login action and method. Keep Enter available there on compact terminals. After logout, open the login form again. Do not put session status or the working directory below the logo. Check `TestShellHomeLogoAndShortcutsResponsive`, `TestShellSignedOutHomeOpensLogin`, and `TestShellStartsOnLoginWithoutSession`. The `/` and Ctrl+K command list is a centered overlay in `shell_palette.go`. Keep its filter and selected row inside the dialog; the underlying page must retain its viewport and selection. At 80×24, show five commands with descriptions below their names; narrow terminals use one-line rows. Arrow keys wrap, Tab completes into the inline input, Enter runs, and Esc restores a saved search draft. Fit the dialog at 80×24 through 20×5. Check `TestShellCommandDialogOverlaysPageAndKeepsFocus` and `TestShellCommandDialogFitsCompactTerminals`. Shell command feedback has three tones: `setError` (✗, error color, stays until the next key press), `setSuccess` (✓, success color) and `setNotice` (neutral hint); the last two expire after five seconds. Render it on the title row (row 0), never on row 1, which holds the list status line. Keep it above the input and key hints, including while the command dialog is open. Keep actionable form and request errors on their owning page. Check `TestShellErrorNoticeStaysUntilKeyPressWithoutReplacingInputOrHelp`, `TestShellInfoAndSuccessNoticesExpire`, `TestShellNoticeKeepsListStatusVisible` and `TestShellThemeSavedNoticeLeavesFooterAvailable`. The download-directory choice and folder browser use a centered dialog over the selected book list. The displayed directory is the default action; the browser reopens at the current selection. Keep both direct-command and shell entry points on the same model. Check TestDownloadDirectoryDialogKeepsBookListBehindIt and TestDownloadDirectoryDialogAcceptsTypedFolder. The metadata page (`meta_tui.go`, glue in `shell_meta.go`) is one `metaPageModel` shared by `/meta` and interactive `zlib meta --fetch`; keep it a single model, not a fork per entry point. It opens on the prepare step (`meta_prepare.go`, stage `metaPrepare`) and searches only on Enter, through a `metaRun` that copies of the page share, so repeated `Init` calls start nothing new, and each search creates a fresh run. The prepare page shows the file name's reading first, then what the file embeds, the merged terms with where each came from (`metasource.Extract` builds them, shared with `zlib meta --fetch`; `t` swaps in the other title through `Extraction.UseOtherTitle`), and the sources as `[x]`/`[ ]` rows on a draft copy that Enter commits. A title read from a name or a download record is `TitleGuessed` and cannot confirm a hint ISBN. Terms and sources come before the file's own lines so short terminals keep them. Ctrl+D (not `r`, which is retry on the no-match page) saves the sources that are on through `saveSources` (`withMetaSourceSaver(saveMetaSources)`, which writes `ZLIB_METADATA_SOURCES` through `settingsStore.save`, applies it to the process only when nothing overrides it, and returns the overriding setting's name for the message) and nothing is saved otherwise; `--source` sets `metaSourcesFlag` for one run (`applyMetaSourceFlag`, resolved by `configuredMetaSources`, flag > env > default; the saved value reaches the env through the `.env` load) and is never saved; `s` from the results returns to the prepare page, and Esc during a search returns to the page it started from (`remember`/`abandonSearch`; a prepare page opened from the results keeps them in `metaSnapshot.outer`, so Esc steps back one page at a time). Esc on the results or the no-match page goes back a step through `backToPrepare` (the prepare page with the terms and sources as searched, `m.prev` cleared so Esc there leaves and Enter searches again); it must not keep the results, or Esc would loop between the two pages, and a page built with no sources still leaves. `q` and Ctrl+C leave from the results. Check `TestMetaResultsEscGoesBackToThePreparePage`, `TestMetaResultsEscKeepsAnEditedSearchAndTheChosenSources`, `TestMetaNoMatchEscGoesBackAndQLeaves`, `TestMetaSourcesKeyStillReturnsToTheSameResults` and `TestMetaResultsEscLeavesWhenThereAreNoSourcesToChoose`. The fields page is a workbench (`meta_bench.go`): `benchRows` lists `metasource.EditableFields` the format can store (plus other identifiers the match proposes), each with the file's value, the match's and its `m.plan` index; `pending` resolves what is written, in this order: `m.extra` (typed with `Change{Field, Old}.Edit`, cleared with `metasource.Clear`, a chosen image with `ChangeFromCover`), then the plan row if `m.selected` (taking the match), else the file's value, which writes nothing. `apply` writes only rows whose origin is not the file, reusing a match cover from `coverCache`. `m` on the prepare page opens it with `manual` set (no match column, no lookup). Wide terminals get two `benchBox` panels side by side whose rows line up; each reserves its cover place through `coverBlock` (`leftCoverState`/`matchCoverState`: blank where the image is drawn, else a bordered `loading…`, `no cover` or `cover unavailable` label), and `coverNeededCmd` asks for the match's cover on every resize that makes the panels visible; narrow ones `benchTable`. The description edits in a `textarea` (`newMetaTextEditor`; Enter is a new line, Ctrl+S keeps). Esc with changes sets `confirmDiscard`. Descriptions are shown through `shownValue`/`metasource.PlainText` but compared and written raw. Covers: `coverSlots` (the `coverSlotter` interface in `cover_graphics.go`) gives the graphics layer one or two placements (several images per frame, each with its own Kitty id), none while an editor, the help or the question is open; prepare, results and details pages show a side cover and narrow their text with `sideNarrow`; standalone `zlib meta` runs under `runCoverProgram`. Check `TestBenchWritesOnlyWhatEachFieldDecides`, `TestBenchEditsWithoutALookup`, `TestBenchAsksBeforeDiscarding`, `TestBenchWritesTheMatchCoverItShowed`, `TestBenchLayoutsKeepSaveAndEsc` and `TestCoverOutputDrawsAndErasesEveryImage` when changing it. The review UI lives in `meta_review.go`: `metaSubtitle` puts the step (`metaStepInfo`) in the subtitle, shortening it to `n/3` when narrow; `candidatesBody` aligns columns with `padCell` (width-aware) and `candidateEffect` lists what a match would add (`DefaultSelected`), could add unselected, differs on, and cannot store (`canOffer` false), all from `metasource.Plan`, so it promises exactly what the next page selects; `?` (`openHelp`, `metaHelpRows`, a scrolling `helpView`) lists every key of the stage it was opened on, less those that do nothing there, and swallows other keys until closed, but is text while an editor is open; the file details are a `viewport` (`openInfo`, `resizeInfo`). Colour only repeats what the text says (`(replaces)` and friends stay). Check `TestMetaPageHelpListsEveryKeyOfThePageAndCloses`, `TestMetaResultsSayWhatAMatchWouldChange` and `TestMetaFileDetailsScroll`, `TestMetaPageHelpScrollsOnShortTerminals`, `TestMetaResultsNameFieldsTheFormatCannotStore` and `TestMetaResultsPageKeysMoveAPage` when changing it. The prepare page is a stack (`prepareBody`): the book detail card (`prepareCard`/`prepareCardLines`: title and authors, then labelled rows aligned to one value column, packed into dotted lines when the rows are too few, no padding lines inside the text; the shortcuts live in the `Search for` `sectionHeader`; the shape of `selectedBookCardWithCover`: rounded accent border, cover slot `coverWidth`×`coverRows` on the left when `prepareLayout` says there is room and `coverFits`, else text only), then `prepareTerms`, then `prepareSources`; `prepareLayout` hands rows out so the sources are never cut (full card with cover, short terms, a few text lines, a title line, no card), and `coverSlots` puts the cover at row 4, column 2, inside the border. The file's own metadata is in the card (`fileRows`, built from `metadataRows`, which `printMetadata` shares, so the page and `zlib meta` agree) and `i` opens the `metaInfo` stage with all of it and the wrapped description; the card is the first thing a short terminal gives up, never the sources. `--fetch` prints the same block before the lookup (`printCurrentMetadata`) and `--json` carries it as `current`. Check `TestMetaPagePrepareShowsTheFilesOwnMetadataBeforeAnySearch`, `TestMetaPageFileDetailsShowTheWholeDescription` and `TestMetaFetchShowsTheFilesOwnMetadataBeforeTheMatches` when changing it. Renaming is its own stage (`meta_rename.go`, `metaRename`, key `n` from the prepare, results, no-match and fields pages), not a `metasource.Change` and not part of `apply()`, because the page quits after a write: it renames at once through `renameBook` (same directory, never over another file, `os.SameFile` for a case-only change), sets `m.path` so later writes go to the new name, and records `renamedFrom`. `metaDone` copies the page's path into `deliveryReturn.savedPath` (Kindle and WeRead read it) and reports a rename even when the page was left with Esc. Names come from `metasource.FileNameFor` (`Authors - Title.ext`, subtitle as two spaces) and typed ones through `SanitizeFileName`; `GuessFromFileName` reads `Author - Title` as `DashAuthors`/`DashTitle` and `Extract` decides whether to use it in `dashReading` (the file's or download's authors agree, or the file has no title or authors of its own; a Z-Library name ending in a group needs the authors to agree; when only the title agrees the file's authors stand). Check `TestMetaPageRenamesFromTheFilesTitleBeforeAnySearch`, `TestMetaPageOffersTheSelectedMatchAndWritesToTheNewPath`, `TestMetaPageRenameRefusesAClashAndKeepsTheFile`, `TestShellMetaDoneGivesTheDownloadPageTheNewPath`, `TestMetaPageRenameFitsCompactTerminals`, `TestMetaPagesShowRenameAndEscAtEveryWidth`, `TestAZLibraryNameWithADashStillKeepsItsAuthorGroup`, `TestABuiltNameSurvivesAFileWithNoMetadata`, `TestMetaCommandRenameRefusesBeforeWritingAnyField`, `TestRenameBookMovesOnlyWithinTheDirectoryAndNeverReplaces`, `TestABuiltNameIsReadBackAsItsTitleAndAuthors` and `TestMetaCommandRenameNamesTheFileFromItsTitleAndAuthors` when changing it. The saved list also has a settings row (`metaSourcesEnv` under METADATA, `zlib config metadata sources`). Resolve sources and the proxy when the page is built (`newDefaultMetaLookup`); the lookup goroutine must not read package state. Late answers carry a generation and are dropped. Only empty fields start selected, and only as far as the match is sure: `metasource.Plan` decides (`Change.DefaultSelected`, `Change.Note`), so the CLI and the page agree. A title-only match leaves publisher, date, language and identifiers unselected under `(check edition)`; an `ISBN?` match selects nothing and tags every row `(may be another book)`; a replacement needs an explicit choice and says `(replaces)`. Do not move this rule into the page, and do not preselect a guessed ISBN: once written it reads as an exact match. Offer only fields `ebookmeta.CanStore` accepts for the file's format. Keep write errors on the fields page. `e` edits the focused row's new value through `metasource.Change.Edit`, which validates per field (ISBN check digit, date, language, authors split on `&`) and returns a new `Change`, never mutating the catalogue row; catalogue IDs other than the ISBN are not editable; the description is edited in a text area and the cover by image path in the workbench. The editor (`meta_edit.go`, `metaEditor`) owns the keyboard while `editing` is set: `metaPageModel.key` routes to it before the stage switch, so `q`, `j`, `k`, `e` and space are text, Esc and Ctrl+C close only the editor, and a paste reaches it through `Update`'s default case. On the candidates and failed pages `e` edits the search through the same editor with three inputs (title, authors, ISBNs); `metasource.ParseQueryEdit` reads it, `metaPageModel.search` starts the fresh lookup and drops the old generation's answer, and `Query.Unconfirmed` keeps a hint or scanned ISBN unconfirmed for as long as that same ISBN is in the field (retyping the same value does not confirm it; only a different ISBN the user types does), and `titleSimilarity` against the searched title at the hint bar still decides whether a hit confirms it. While `editing` is set the value editor is drawn first, followed by `editingContext`, so a tall plan can never push it off the screen; `remember` and `abandonSearch` keep and restore the results a repeat search replaces, so Esc during it returns to them and only the first search closes the page; and every page's key hints go through `keysFor`, which picks the longest wording that fits the width because `help` drops trailing hints. Check `TestMetaPageEscDuringARepeatSearchKeepsThePreviousResults`, `TestMetaPageFootersKeepEscOnNarrowTerminals`, `TestDefaultMetaSourceChoicesMatchTheFirstSearch` and `TestChangeEditDateIsStrict` too. The sources live on the prepare page (`meta_sources.go` keeps the `metaSourceChoice`s): the page needs `withMetaSources`, rebuilds the lookup through the injected `metaSourceLookup` factory (`newMetaLookupFor` by default, so tests stay offline), shows a key only as set or not set, and refuses a source that cannot run. `titleNote` says WeRead needs a title; the ISBN row of `prepareTerms` exists only when there is an ISBN. The results' summary above the wide panels is `candidateEffectLine`, built from `effectOf` like `candidateEffect`: it names the added fields, counts the rest and shortens itself rather than cut a word. Check `TestResultsSummaryLineFitsWithoutCuttingWords`, and `TestResultsSummaryLineSaysWhenNothingChanges`. A file with nothing to search with opens the prepare page with the search editor open (`newMetaPageModel` does not refuse it; `Init` returns the editor's cursor command and `search` never sends an empty query). The candidates and no-match footers are chosen by `keysFor` from wordings that shrink with the width, because `help` drops trailing hints and appends an ellipsis; keep `s` and `esc` on screen at 60 columns. Check `TestMetaPageFooterKeepsItsKeysOnNarrowTerminals`, `TestMetaPageOpensTheSearchEditorForAFileWithNoMetadata`, `TestShellMetaEditorTakesSlashQCtrlKAndPaste`, `TestStandaloneMetaPickerOpensThePageAndReportsTheResult` and `TestEditedTitleJudgesAHintISBNLikeAnyOtherTitle`. The lookup does not merge sources (`Lookup` ranks each source's answer on its own with `rankAndMerge`, which only joins a source's own duplicates, then `orderSourceRows`; `Options.MaxResults` is per source), so every candidate has one source. Candidate rows end with `[source]` and the details carry an `ISBN` row (the ISBN, or `no ISBN listed` for an edition-level match without one; a work-level result gets none): check `TestMetaPageRowsNameTheirSources`, `TestMetaPageDetailsSayWhetherAnISBNIsKnown` and `TestMetaPageReviewFitsCompactTerminals`. `candidateColumns` reserves the source column first, from the widest `metaSourceLabel` of every match (not only the visible ones, so it does not move while scrolling); never cut a source name with `padCell`'s ellipsis. The panels size their label column with `benchLabelWidth`, from the longest label shown, so `ID openlibrary` never runs into its value. Check `TestMetaResultsNameEachRowsSourceWholeAtEveryWidth`, `TestMetaResultsKeepTitlesReadableBesideTheSource`, `TestMetaResultsDetailsNameTheSource`, `TestMetaPanelsKeepLongIdentifierLabelsApartFromTheirValues`, `TestLookupKeepsEachSourcesAnswerInItsOwnRow`, `TestLookupGivesEachSourceSeveralRowsUpToTheLimit` and `TestLookupJoinsTheSameBookOnlyWithinOneSource`. Check `TestMetaPageSourcePanelListsEverySourceAndWhyOneIsOff`, `TestMetaPageSourcePanelTogglesAndSearchesAgainWithTheChosenSources`, `TestDefaultMetaSourceChoicesReadTheEnvironmentWithoutShowingTheKey`, `TestMetaPageSaysWeReadNeedsATitle`, `TestMetaPageEditsTheSearchAndLooksAgain`, `TestMetaPageSearchEditWorksAfterNothingMatched`, `TestMetaPageSearchEditKeepsHintISBNsUnconfirmed`, `TestMetaPageSearchEditorFitsCompactTerminals`, `TestParseQueryEdit`, `TestMetaPageEditorOwnsTheKeyboard`, `TestMetaPageEditorFitsCompactTerminals`, `TestChangeEditValidatesAndRewritesEachField` and `TestChangeEditRejectsInvalidText` when changing it, and also `TestMetaPageListsCandidatesWithMatchKind`, `TestMetaPageWriteFailureStaysOnTheFieldsPage`, `TestMetaPageHidesFieldsTheFormatCannotStore`, `TestMetaPageNoMatchAndRetry`, `TestMetaPageEscCancelsALookupInFlight`, `TestMetaPageSearchesOnlyOnEnterHoweverOftenInitRuns`, `TestMetaPageOpensOnThePrepareStepAndSearchesNothingYet`, `TestMetaPagePrepareShowsTheFileNameBeforeTheEmbeddedMetadata`, `TestMetaPageRemembersTheSourcesOnlyWhenAsked`, `TestMetaPageEscDuringARepeatSearchReturnsToTheReopenedPreparePage`, `TestSettingsPageEditsAndClearsTheLookupSources`, `TestAHintISBNWithNoTitleIsNotConfirmed`, `TestSaveMetaSourcesReportsWhatOverridesIt`, `TestMetaFetchSourceFlagBeatsTheEnvironmentForOneRun`, `TestMetaPagePrepareFitsCompactTerminals`, `TestExtractOnTheRealBooks`, `TestMetaPageFitsCompactTerminals` and `TestShellMetaCommandOpensThePage` when changing it. The saved-file page offers Fix metadata (`actionFixMetadata`, last in `completeActions`) for the formats in `ebookmeta.Extensions`. `downloadModel.book` keeps the Z-Library record from the fetch; `openMetaForDownload` passes its ISBNs, title and authors as a `metaHint` that only fills gaps, and `metaDone` returns through `returnToDownloadCompletion`. A selected cover is downloaded before anything is written; a failed download writes nothing and stays on the fields page (`metaCoverError`). MOBI can only replace a cover. Check `TestMetaPageCoverFailureWritesNothing`, `TestMetaPageHintFillsGapsAndAddsISBNs`, `TestDownloadCompletionOffersFixMetadataForReadableFormats` and `TestShellDownloadFixMetadataActionSeedsFromTheRecordAndReturns`. The rename page (`n` or `F2`, `meta_rename.go`) is built from `renameOption` rows (a title and authors, or the typed row) and `renameChoiceFor`, which names the file in `m.nameLayout` and says whether it is current, taken or ready, so a format switch (`←/→`, `1 2 3`) only changes the layout and never the rows. Ctrl+D saves the format (`saveNameLayout`, `ZLIB_FILENAME_FORMAT`). The prepare and fields pages show `fileNameLine` (needs a height of 16). A dashed file name is read by `dashReading` either way round, and `Hint.NameLayout` decides when the file does not. Check `TestMetaPageRenameSwitchesTheFormat`, `TestMetaPageRenameSavesTheFormat`, `TestMetaPagesShowTheFileNameAndTheNameItWouldGet`, `TestMetaPageRenameFitsCompactTerminals` and `TestDashedNamesAreReadEitherWay`. The settings pages for the default search formats and the lookup sources are checklists drawn by one `checklistView` (`settings_formats.go`, `settings_sources.go`): move, Space, Ctrl+A, Enter, Esc, with nothing ticked meaning the default (any format, or sources by book language). Check `TestSettingsPageEditsAndClearsTheLookupSources`. A setting with a short list of values (retries, lookup results, file name format, SMTP port and security) opens a choice page (`settings_choice.go`: `choiceSpecFor`, radio rows drawn by `checklistView`) instead of the text box; its custom row opens the box over the page (`fromChoice`: Esc returns to the choices, a save to the list) with the spec's help and a live preview, and a value outside the rows is marked on the custom row. Tests that need the box use `editText`. Check `TestFileNameFormatIsAChoiceListWithACustomRow` and `TestOtherSettingsWithShortListsAreChoicePages`. The WeRead API key (`ZLIB_WEREAD_API_KEY`, METADATA section, `zlib config metadata weread-key`) follows the same secret rules as the Google Books key through `isSecretSetting` (masked, empty hidden editor, Ctrl+R to remove); check `TestWeReadKeySettingIsValidatedMaskedAndRemovable`. The Google Books key (`ZLIB_GOOGLE_BOOKS_KEY`, METADATA section, `zlib config metadata`) is a credential. `GOOGLE_BOOKS_API_KEY` is an alias read only when the `ZLIB_` name holds nothing (`googleBooksKey()`, `settingValue.alias`): config shows its source, but saving and removing touch only the `ZLIB_` name (`TestConfigShowsAndOutranksTheGoogleKeyAlias`). Show it only through `displaySetting` (`Configured (hidden)`), including `--json` and the saved value. Its editor uses `textinput.EchoPassword` and opens empty, never prefilled; Enter on an empty box keeps the saved key, and only Ctrl+R then Enter removes it (`resetSecret`, cleared by typing or pasting). Validation errors must not repeat the value. The Enter handler lists its pages by name, so a new settings page must be added there as well as to `settingsSections`. Check `TestGoogleKeyIsMaskedInJSONAndOnScreen`, `TestGoogleKeyEditorIsMaskedEmptyAndSafeToEnter`, `TestGoogleKeyEditorSavesReplacesAndRemoves`, `TestGoogleKeyValidationNeverEchoesTheValue` and `TestGoogleKeyRowIsReachableOnAStandardTerminal`.