From a9d5949cdecb2a1dd512014f511653381f2e618e Mon Sep 17 00:00:00 2001 From: hl-valdemar Date: Sun, 11 Oct 2026 16:47:43 +0200 Subject: [PATCH] fix: share one temporary tab for category and channel browsing --- README.md | 4 +-- src/main.rs | 79 +++++++++++++++++++++++++++-------------------------- 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index a7085d9..db83ceb 100644 --- a/README.md +++ b/README.md @@ -101,10 +101,10 @@ If the terminal intercepts modified Backspace rather than transmitting it, use C - **Normal:** `j` / `k` or arrow keys navigate; `i` enters filter mode; Enter opens the selected channel's videos; Esc closes. - **Insert:** type a case-insensitive substring to filter; arrow keys or Ctrl-J / Ctrl-K navigate matches; Enter browses; Esc returns to normal mode without clearing the filter. - The list includes registered channels, including untagged ones, and channels saved only in categories. Aliases of the same channel appear once, using a mapped handle when available; otherwise the saved channel identity is shown. -- Choosing a channel opens one temporary channel tab. Choosing another replaces it without replacing the temporary category tab. Revisiting a channel restores its cached videos, selection, and pagination. +- Channels and unpinned categories share **one temporary browsing tab**. Choosing either replaces the previous temporary view; pinned category tabs stay visible. Revisiting or navigating back restores cached videos, selection, and pagination. - Channel selection is single-choice and does not pin channels or change subscriptions. `s` still edits the selected video's channel tags; bulk `S` remains category-only. -Press **`U` (Shift-U)** on a video to browse its creator directly, including channels you have not saved. This uses the same temporary channel tab and caches without adding a subscription. Channel IDs are preferred; a valid handle is used when an ID is unavailable. Missing channel metadata leaves the current view unchanged. Unsaved channel views survive configuration changes for the session; explicitly removing a saved subscription still removes its channel view. +Press **`U` (Shift-U)** on a video to browse its creator directly, including channels you have not saved. This replaces the current temporary browsing tab without adding a subscription. Channel IDs are preferred; a valid handle is used when an ID is unavailable. Missing channel metadata leaves the current view unchanged. Unsaved channel views survive configuration changes for the session; explicitly removing a saved subscription still removes its channel view. ### Channel tags (`s`, or `S` for bulk editing) diff --git a/src/main.rs b/src/main.rs index 4d41470..ba97dc4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,7 +58,7 @@ //! Normal-mode u opens a searchable saved-channel selector with the category browser's modal controls. //! Normal-mode U opens the selected video's creator directly, without saving a subscription. //! Choices include untagged registrations and category-only channels, deduplicated with readable handle labels. -//! One temporary channel tab is independent of the temporary category tab; hidden channel views retain cached pages. +//! Channels and unpinned categories share one temporary tab; hidden views retain caches and back history. //! Channel views use the same pagination but extract only their stored channel identity; S stays category-only. //! Config changes preserve unsaved browsing, relabel saved identities, and drop explicitly removed subscriptions. //! r reloads config and refreshes the current view. @@ -111,7 +111,7 @@ use youtube::{Job, PAGE_SIZE, Page, PlayerLaunch, Video}; #[command( version, about = "Browse YouTube and open selected videos in Terebi", - after_help = "Requires yt-dlp for browsing; thumbnails also use curl. Playback requires Terebi and its own streaming dependencies.\nDefaults to terebi on PATH; --player overrides the CLI path.\nTerebi receives --new-instance --url followed by the canonical YouTube video URL and handles extraction, decoding, and playback itself; each selection opens an independent player instance without replacing existing playback.\nAlways start in NORMAL. A CLI query is searched automatically; otherwise press i to enter a query.\nINSERT: type to edit; Enter submits if changed and returns to NORMAL; Esc returns without submitting.\nTEXT EDITING (search, category/channel filters, and new tag): Option/Alt+Backspace or Ctrl-W deletes the previous whitespace-delimited word, including trailing whitespace; Cmd/Super+Backspace or Ctrl-U clears the entire line. Plain Backspace removes one character.\nThe terminal must transmit modified Backspace. If it intercepts Option/Cmd, map those shortcuts to Ctrl-W/Ctrl-U respectively.\nNORMAL: j/k or arrows select; Enter opens the video in Terebi; i edits the query; d opens video info (again for full description); c browses saved categories; u browses saved channels; U opens the selected video's channel; s edits channel tags; S edits all channels in the current category; q quits.\nSearch and Feed are permanent tabs. Pinned categories also stay visible; one temporary category tab is replaced by each new unpinned selection.\nTab/Shift-Tab cycle only visible tabs; Esc or - in NORMAL returns through view history, restoring cached rows, selection, and pagination, including replaced temporary tabs. Removed views are skipped and empty history does nothing. Esc first closes popups or leaves INSERT without navigating; minus types normally in input fields. r reloads config and refreshes the current view from its first page.\nCATEGORY BROWSER (c): starts NORMAL; j/k or arrows move; i enters INSERT to filter; Enter browses; p immediately saves pin/unpin; Esc closes. Choosing a pinned category focuses its existing tab and clears the temporary tab.\nCATEGORY FILTER INSERT: type a case-insensitive substring to filter live; arrows or Ctrl-J/K move; Enter browses the selected match; Esc returns to NORMAL with the filter retained. In NORMAL, j/k and pinning operate on the filtered list. No matches makes Enter/p a no-op. Reopening the selector clears the filter.\nCHANNEL BROWSER (u): starts NORMAL; j/k or arrows move; i enters INSERT to filter; Enter opens only the selected channel's videos; Esc closes. INSERT uses case-insensitive filtering, arrows or Ctrl-J/K to move, Enter to browse, and Esc to return to NORMAL. Empty matches do nothing.\nSaved choices include registered channels (even untagged) and category-only subscriptions, deduplicated by resolved identity; mapped handles label aliases. Channel selection never changes subscriptions or pins.\nOne temporary channel tab replaces the previous channel choice independently of the temporary category tab. Revisiting restores cached rows, selection, and page position. Channel views use the same infinite scrolling but extract only their chosen channel; S remains category-only.\nVIDEO CHANNEL (U / Shift-U): opens the selected video's creator in the same temporary channel tab, reusing cached rows and pagination without subscribing. A canonical channel ID or valid @handle is required; unavailable metadata leaves the current view unchanged. Saved mappings resolve handle-only rows. Unsaved channels do not appear in the saved selector unless you save them.\nReloading config relabels stable saved identities and removes explicitly unsubscribed channels; removing the active saved channel falls back to Search. Unsaved channels opened with U remain browseable for the session.\nHidden category and channel views retain loaded rows, selection, and pagination for this session. Temporary tabs do not survive restarting; pins do.\nPUBLISHED: Every video view shows YYYY-MM-DD. Exact upload dates take precedence; ~ marks an estimated UTC date from flat metadata, and Unknown means unavailable. Dates are cached without fetching full metadata for every video.\nLOADING: Result/feed and preview titles show an animated spinner while content loads, including further pages and thumbnail decoding/resizing; it disappears when ready or on error.\nFeed sits immediately right of Search and combines every saved [channels] registration, including untagged channels, plus channels entered directly in tags.\nChannel URLs and videos are deduplicated; Feed keeps its cached selection and page position when only tag assignments change.\nSubscriptions: $XDG_CONFIG_HOME/tubular/config.toml, or ~/.config/tubular/config.toml when XDG_CONFIG_HOME is unset/empty/relative.\nExample TOML:\npinned_categories = [\"Favorites\"]\n[categories]\nCreators = [\"@jawed\"]\nFavorites = [\"@jawed\"]\n[channels]\n\"@jawed\" = \"https://www.youtube.com/channel/UC4QobU6STFB0P71PMvOGN5A\"\npinned_categories is a top-level array of category names; pins referencing removed categories are ignored.\n[categories] defines flat, overlapping tags, each with its own feed; there is no hierarchy or inheritance.\nEntries accept @handles, HTTPS YouTube channel URLs, or canonical UC channel IDs.\n[channels] registers saved handles with canonical channel URLs/IDs; feeds use these stable identities.\nChecked tags save the handle plus its mapping; existing URLs/aliases are replaced with the handle, preserving comments.\nUnchecked tags remove only that channel's tag assignment; other creators, omitted tags, empty tag arrays, saved registrations, and pins are retained.\nUntagging does not unsubscribe from Feed. To unsubscribe, remove all of that channel's [channels] mappings and tag entries, then press r.\nUnmapped handles work directly. Existing URL entries still load.\nSaving a single channel requires a handle and canonical ID; unavailable metadata or conflicting mappings are reported without changing the file.\nPAGINATION: Search loads 20 results per page; Feed and tags request 20 uploads per channel's /videos tab per page.\nMoving near the loaded end in NORMAL fetches more asynchronously, preserving existing rows, selection, and previews. Insert mode and open popups pause automatic prefetch.\nFeed views merge newest-first using approximate upload dates. Older uploads wait while newer channel pages catch up; undated uploads appear when the feed is exhausted.\nStatus shows the page and whether more is available or the end is reached. Switching views cancels pending extraction; returning resumes the same range with cached rows intact.\nPage errors retain loaded rows and stop automatic retries; r reloads config and restarts the current view from page one.\nDeep pages may take longer because yt-dlp offsets re-traverse earlier continuation pages.\nTAGS (s): existing assignments are checked; j/k or arrows move; Space toggles; Enter saves all staged memberships; n prompts for a new tag; Esc cancels without writing.\nBULK TAGS (S, category views only): edits all saved channels in the current category, not just channels with loaded videos. Tags shared by every target start checked; mixed memberships start unchecked. Enter atomically applies the exact checked tag set to every target, removing targets from all unchecked categories while leaving other channels untouched. Empty categories, registrations, pins, and comments remain. n stages a new category for all targets; Esc cancels without saving. If source channels changed while editing, close and reopen. Clearing all tags is refused if any target lacks a [channels] registration, so category-only subscriptions are not accidentally lost.\nNEW TAG: type a name; Enter stages it checked and returns to the list; Esc abandons the name; Ctrl-U clears.\nNew tags and membership changes reach disk only on Enter in the main tag list.\nVIDEO INFO: d opens thumbnail and details; d again expands the full description inside the same popup; another d returns to info. Esc closes.\nThe popup uses up to 70% width and 60% height, capped at 96 by 20 cells.\nFull descriptions have one-column left/right padding and an empty line above the bold title and dimmed author/publication row. Title, metadata, and description scroll together as one document; paragraphs are preserved. Up/Down or Ctrl-J/K scroll lines and PgUp/PgDn scroll pages. Plain j/k selects videos in either mode.\nThumbnails have one column of left padding and two columns before the text. Image space is reserved before loading so metadata does not shift when decoding finishes.\nThe title is bold, only author/publication metadata is dimmed, and readable excerpts end with an ellipsis when clipped.\nImages fit proportionally on resize. Terminal graphics are detected at startup, falling back to colored half-blocks.\nDownloading, JPEG decoding, and image resizing/encoding do not block navigation.\nSwitching info/description retains in-flight work and cached content. Full descriptions have a session LRU of 64; thumbnails retain eight inactive images plus the selected image.\ni, c, s, S, view changes, and refresh dismiss the preview; successful refresh clears its caches. Typing d or t in INSERT edits text.\nCtrl-C quits in any mode or popup.\nThe player CLI exits once macOS accepts the handoff; Tubular reports launcher errors, while later extraction/playback errors appear in Terebi.\nSelecting another video opens a new Terebi player, leaving existing playback untouched. Quitting Tubular cancels only pending metadata/CLI work; Terebi continues playing independently.\nExample: tubular \"rust programming\"" + after_help = "Requires yt-dlp for browsing; thumbnails also use curl. Playback requires Terebi and its own streaming dependencies.\nDefaults to terebi on PATH; --player overrides the CLI path.\nTerebi receives --new-instance --url followed by the canonical YouTube video URL and handles extraction, decoding, and playback itself; each selection opens an independent player instance without replacing existing playback.\nAlways start in NORMAL. A CLI query is searched automatically; otherwise press i to enter a query.\nINSERT: type to edit; Enter submits if changed and returns to NORMAL; Esc returns without submitting.\nTEXT EDITING (search, category/channel filters, and new tag): Option/Alt+Backspace or Ctrl-W deletes the previous whitespace-delimited word, including trailing whitespace; Cmd/Super+Backspace or Ctrl-U clears the entire line. Plain Backspace removes one character.\nThe terminal must transmit modified Backspace. If it intercepts Option/Cmd, map those shortcuts to Ctrl-W/Ctrl-U respectively.\nNORMAL: j/k or arrows select; Enter opens the video in Terebi; i edits the query; d opens video info (again for full description); c browses saved categories; u browses saved channels; U opens the selected video's channel; s edits channel tags; S edits all channels in the current category; q quits.\nSearch and Feed are permanent tabs. Pinned categories also stay visible; one temporary category tab is replaced by each new unpinned selection.\nTab/Shift-Tab cycle only visible tabs; Esc or - in NORMAL returns through view history, restoring cached rows, selection, and pagination, including replaced temporary tabs. Removed views are skipped and empty history does nothing. Esc first closes popups or leaves INSERT without navigating; minus types normally in input fields. r reloads config and refreshes the current view from its first page.\nCATEGORY BROWSER (c): starts NORMAL; j/k or arrows move; i enters INSERT to filter; Enter browses; p immediately saves pin/unpin; Esc closes. Choosing a pinned category focuses its existing tab and clears the temporary tab.\nCATEGORY FILTER INSERT: type a case-insensitive substring to filter live; arrows or Ctrl-J/K move; Enter browses the selected match; Esc returns to NORMAL with the filter retained. In NORMAL, j/k and pinning operate on the filtered list. No matches makes Enter/p a no-op. Reopening the selector clears the filter.\nCHANNEL BROWSER (u): starts NORMAL; j/k or arrows move; i enters INSERT to filter; Enter opens only the selected channel's videos; Esc closes. INSERT uses case-insensitive filtering, arrows or Ctrl-J/K to move, Enter to browse, and Esc to return to NORMAL. Empty matches do nothing.\nSaved choices include registered channels (even untagged) and category-only subscriptions, deduplicated by resolved identity; mapped handles label aliases. Channel selection never changes subscriptions or pins.\nChannels and unpinned categories share one temporary browsing tab. Choosing either replaces the previous temporary view while pinned category tabs remain visible. Revisiting or navigating back restores cached rows, selection, and page position. Channel views use the same infinite scrolling but extract only their chosen channel; S remains category-only.\nVIDEO CHANNEL (U / Shift-U): opens the selected video's creator in the same temporary channel tab, reusing cached rows and pagination without subscribing. A canonical channel ID or valid @handle is required; unavailable metadata leaves the current view unchanged. Saved mappings resolve handle-only rows. Unsaved channels do not appear in the saved selector unless you save them.\nReloading config relabels stable saved identities and removes explicitly unsubscribed channels; removing the active saved channel falls back to Search. Unsaved channels opened with U remain browseable for the session.\nHidden category and channel views retain loaded rows, selection, and pagination for this session. Temporary tabs do not survive restarting; pins do.\nPUBLISHED: Every video view shows YYYY-MM-DD. Exact upload dates take precedence; ~ marks an estimated UTC date from flat metadata, and Unknown means unavailable. Dates are cached without fetching full metadata for every video.\nLOADING: Result/feed and preview titles show an animated spinner while content loads, including further pages and thumbnail decoding/resizing; it disappears when ready or on error.\nFeed sits immediately right of Search and combines every saved [channels] registration, including untagged channels, plus channels entered directly in tags.\nChannel URLs and videos are deduplicated; Feed keeps its cached selection and page position when only tag assignments change.\nSubscriptions: $XDG_CONFIG_HOME/tubular/config.toml, or ~/.config/tubular/config.toml when XDG_CONFIG_HOME is unset/empty/relative.\nExample TOML:\npinned_categories = [\"Favorites\"]\n[categories]\nCreators = [\"@jawed\"]\nFavorites = [\"@jawed\"]\n[channels]\n\"@jawed\" = \"https://www.youtube.com/channel/UC4QobU6STFB0P71PMvOGN5A\"\npinned_categories is a top-level array of category names; pins referencing removed categories are ignored.\n[categories] defines flat, overlapping tags, each with its own feed; there is no hierarchy or inheritance.\nEntries accept @handles, HTTPS YouTube channel URLs, or canonical UC channel IDs.\n[channels] registers saved handles with canonical channel URLs/IDs; feeds use these stable identities.\nChecked tags save the handle plus its mapping; existing URLs/aliases are replaced with the handle, preserving comments.\nUnchecked tags remove only that channel's tag assignment; other creators, omitted tags, empty tag arrays, saved registrations, and pins are retained.\nUntagging does not unsubscribe from Feed. To unsubscribe, remove all of that channel's [channels] mappings and tag entries, then press r.\nUnmapped handles work directly. Existing URL entries still load.\nSaving a single channel requires a handle and canonical ID; unavailable metadata or conflicting mappings are reported without changing the file.\nPAGINATION: Search loads 20 results per page; Feed and tags request 20 uploads per channel's /videos tab per page.\nMoving near the loaded end in NORMAL fetches more asynchronously, preserving existing rows, selection, and previews. Insert mode and open popups pause automatic prefetch.\nFeed views merge newest-first using approximate upload dates. Older uploads wait while newer channel pages catch up; undated uploads appear when the feed is exhausted.\nStatus shows the page and whether more is available or the end is reached. Switching views cancels pending extraction; returning resumes the same range with cached rows intact.\nPage errors retain loaded rows and stop automatic retries; r reloads config and restarts the current view from page one.\nDeep pages may take longer because yt-dlp offsets re-traverse earlier continuation pages.\nTAGS (s): existing assignments are checked; j/k or arrows move; Space toggles; Enter saves all staged memberships; n prompts for a new tag; Esc cancels without writing.\nBULK TAGS (S, category views only): edits all saved channels in the current category, not just channels with loaded videos. Tags shared by every target start checked; mixed memberships start unchecked. Enter atomically applies the exact checked tag set to every target, removing targets from all unchecked categories while leaving other channels untouched. Empty categories, registrations, pins, and comments remain. n stages a new category for all targets; Esc cancels without saving. If source channels changed while editing, close and reopen. Clearing all tags is refused if any target lacks a [channels] registration, so category-only subscriptions are not accidentally lost.\nNEW TAG: type a name; Enter stages it checked and returns to the list; Esc abandons the name; Ctrl-U clears.\nNew tags and membership changes reach disk only on Enter in the main tag list.\nVIDEO INFO: d opens thumbnail and details; d again expands the full description inside the same popup; another d returns to info. Esc closes.\nThe popup uses up to 70% width and 60% height, capped at 96 by 20 cells.\nFull descriptions have one-column left/right padding and an empty line above the bold title and dimmed author/publication row. Title, metadata, and description scroll together as one document; paragraphs are preserved. Up/Down or Ctrl-J/K scroll lines and PgUp/PgDn scroll pages. Plain j/k selects videos in either mode.\nThumbnails have one column of left padding and two columns before the text. Image space is reserved before loading so metadata does not shift when decoding finishes.\nThe title is bold, only author/publication metadata is dimmed, and readable excerpts end with an ellipsis when clipped.\nImages fit proportionally on resize. Terminal graphics are detected at startup, falling back to colored half-blocks.\nDownloading, JPEG decoding, and image resizing/encoding do not block navigation.\nSwitching info/description retains in-flight work and cached content. Full descriptions have a session LRU of 64; thumbnails retain eight inactive images plus the selected image.\ni, c, s, S, view changes, and refresh dismiss the preview; successful refresh clears its caches. Typing d or t in INSERT edits text.\nCtrl-C quits in any mode or popup.\nThe player CLI exits once macOS accepts the handoff; Tubular reports launcher errors, while later extraction/playback errors appear in Terebi.\nSelecting another video opens a new Terebi player, leaving existing playback untouched. Quitting Tubular cancels only pending metadata/CLI work; Terebi continues playing independently.\nExample: tubular \"rust programming\"" )] struct Options { /// Terebi CLI executable; accepts --new-instance --url followed by a YouTube video URL. @@ -333,8 +333,7 @@ struct App { view_history: Vec, category_dialog: Option, browser: Option, - temporary_category: Option, - temporary_channel: Option, + temporary_view: Option, preview: Option, thumbnail: thumbnail::Thumbnail, description_job: Option<(usize, Job)>, @@ -376,8 +375,7 @@ impl App { view_history: Vec::new(), category_dialog: None, browser: None, - temporary_category: None, - temporary_channel: None, + temporary_view: None, preview: None, thumbnail: thumbnail::Thumbnail::new(), description_job: None, @@ -401,15 +399,10 @@ impl App { ViewSource::Category(name) => self.config.pinned_categories.contains(name), ViewSource::Channel(_) => false, }) - .chain(self.temporary_category.as_ref().and_then(|name| { + .chain(self.temporary_view.as_ref().and_then(|source| { self.views.iter().enumerate().find(|(_, view)| { - matches!(&view.source, ViewSource::Category(category) if category == name) - && !self.config.pinned_categories.contains(name) - }) - })) - .chain(self.temporary_channel.as_ref().and_then(|channel| { - self.views.iter().enumerate().find(|(_, view)| { - matches!(&view.source, ViewSource::Channel(identity) if identity == channel) + &view.source == source + && !matches!(source, ViewSource::Category(name) if self.config.pinned_categories.contains(name)) }) })) } @@ -580,7 +573,7 @@ impl App { fn browse_view(&mut self, name: String, source: ViewSource) { if matches!(source, ViewSource::Category(_)) { - self.temporary_category = None; + self.temporary_view = None; } let index = self .views @@ -689,12 +682,11 @@ impl App { } fn activate_view(&mut self, index: usize) { - match &self.views[index].source { - ViewSource::Category(name) if !self.config.pinned_categories.contains(name) => { - self.temporary_category = Some(name.clone()); - } - ViewSource::Channel(identity) => self.temporary_channel = Some(identity.clone()), - _ => {} + let source = &self.views[index].source; + if matches!(source, ViewSource::Channel(_)) + || matches!(source, ViewSource::Category(name) if !self.config.pinned_categories.contains(name)) + { + self.temporary_view = Some(source.clone()); } if index != self.view_index { self.job = None; @@ -877,23 +869,16 @@ impl App { .unwrap_or(0); self.feed_channels = feed_channels; self.config = config; - if self.temporary_category.as_ref().is_some_and(|name| { - !self.config.categories.contains_key(name) - || self.config.pinned_categories.contains(name) + if self.temporary_view.as_ref().is_some_and(|source| { + !self.views.iter().any(|view| &view.source == source) + || matches!(source, ViewSource::Category(name) if self.config.pinned_categories.contains(name)) }) { - self.temporary_category = None; - } - if self.temporary_channel.as_ref().is_some_and(|identity| { - !self.views.iter().any( - |view| matches!(&view.source, ViewSource::Channel(channel) if channel == identity), - ) - }) { - self.temporary_channel = None; + self.temporary_view = None; } if let ViewSource::Category(name) = &self.views[self.view_index].source && !self.config.pinned_categories.contains(name) { - self.temporary_category = Some(name.clone()); + self.temporary_view = Some(ViewSource::Category(name.clone())); } self.job = None; self.close_preview(); @@ -2030,7 +2015,10 @@ mod tests { ); assert_eq!(app.views[app.view_index].selection.selected(), Some(1)); assert_eq!(app.views[app.view_index].next_start, 41); - assert_eq!(app.temporary_channel.as_deref(), Some("alpha")); + assert_eq!( + app.temporary_view, + Some(ViewSource::Channel("alpha".into())) + ); app.key(KeyEvent::new(KeyCode::Char('-'), KeyModifiers::NONE)); assert_eq!( app.views[app.view_index].source, @@ -2157,7 +2145,10 @@ mod tests { ViewSource::Channel(identity.into()) ); assert!(app.views[app.view_index].loaded); - assert_eq!(app.temporary_channel.as_deref(), Some(identity)); + assert_eq!( + app.temporary_view, + Some(ViewSource::Channel(identity.into())) + ); app.apply_config(config::Config { channels: [("@Registered".into(), identity.into())].into(), ..Default::default() @@ -2243,7 +2234,7 @@ mod tests { } #[test] - fn channel_tabs_replace_only_channels_and_revisit_cached_rows_and_pages() { + fn channel_and_category_share_temporary_tab_and_cached_history() { let mut app = app(&["tubular"]); app.apply_config(config::Config { channels: [ @@ -2284,7 +2275,6 @@ mod tests { ViewSource::Search, ViewSource::Feed, ViewSource::Category("@Alpha".into()), - ViewSource::Category("Temporary".into()), ViewSource::Channel("beta".into()) ] ); @@ -2295,6 +2285,19 @@ mod tests { assert_eq!(view.selection.selected(), Some(1)); assert_eq!(view.next_start, 41); assert_eq!(view.videos.len(), 2); + app.key(KeyEvent::new(KeyCode::Char('-'), KeyModifiers::NONE)); + app.key(KeyEvent::new(KeyCode::Char('-'), KeyModifiers::NONE)); + app.key(KeyEvent::new(KeyCode::Char('-'), KeyModifiers::NONE)); + assert_eq!( + app.views[app.view_index].source, + ViewSource::Category("Temporary".into()) + ); + assert_eq!(app.visible_views().count(), 4); + assert!( + !app.visible_views() + .any(|(_, view)| matches!(view.source, ViewSource::Channel(_))) + ); + browse_channel(&mut app, "Alpha"); app.key(KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE)); assert_eq!(app.views[app.view_index].source, ViewSource::Search); app.key(KeyEvent::new(KeyCode::BackTab, KeyModifiers::SHIFT)); @@ -2357,7 +2360,7 @@ mod tests { pinned_categories: vec!["@Alpha".into()], }); assert_eq!(app.views[app.view_index].source, ViewSource::Search); - assert!(app.temporary_channel.is_none()); + assert!(app.temporary_view.is_none()); assert!( !app.views .iter()