From 343010ce5c245f47dc0a627ce6406513e6119b12 Mon Sep 17 00:00:00 2001 From: hl-valdemar Date: Sun, 11 Oct 2026 21:00:04 +0200 Subject: [PATCH] feat: remove individual watch-later videos --- README.md | 3 ++ src/keys.rs | 9 ++++- src/main.rs | 113 ++++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 110 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7858ab9..dc413b9 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ These are the default bindings. Overrides in `[keys]` replace an action's bindin | `w` | Save the selected video to watch later (also works in previews) | | `W` | Browse watch later for the current category, or the combined collection elsewhere | | `f` | In watch later, cycle All → Unwatched → Watched | +| `X` (Shift-X) | Remove only the selected watch-later video (also works in previews) | | `D` | In watch later, confirm removal of all videos matching the current list/filter | | `v` | Save the selected video to saved videos (also works in previews) | | `V` | Browse saved videos for the current category, or the combined collection elsewhere | @@ -185,6 +186,8 @@ Terebi reports acknowledged playback positions. A video becomes watched when an ### Removal +`X` (Shift-X) immediately removes **only the selected video** from watch later, including from Search, category views, or previews. Other videos, saved-video membership, and watched status remain unchanged. Configure this action with `video.watch_later.remove`; it is separate from the bulk action `view.watch_later.remove`. + `D` snapshots all videos matching the current list and filter, then shows their count, category, and filter. **`y` confirms; `n` or Esc cancels.** Enter does not confirm. Removal deletes those videos from the shared collection, so they disappear from every matching category; watched status is untouched. An empty filtered list has nothing to remove. ### Storage diff --git a/src/keys.rs b/src/keys.rs index c4b9e4f..402ca78 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -109,6 +109,7 @@ actions! { WatchLaterBrowse, "view.watch_later.browse", "Browse this category's watch later, or the combined collection elsewhere", &[Context::Normal], ["W"]; WatchLaterFilter, "view.watch_later.filter", "Cycle watch-later filter: all, unwatched, watched", &[Context::Normal], ["f"]; WatchLaterRemove, "view.watch_later.remove", "Confirm removal of the current filtered watch-later subset", &[Context::Normal], ["D"]; + WatchLaterRemoveSelected, "video.watch_later.remove", "Remove only the selected watch-later video (also in previews)", VIEW, ["X"]; SavedVideoSave, "video.saved.save", "Save the selected video (also in previews)", VIEW, ["v"]; SavedVideoBrowse, "view.saved.browse", "Browse this category's saved videos, or the combined collection elsewhere", &[Context::Normal], ["V"]; SavedVideoRemove, "video.saved.remove", "Remove the selected saved video (also in previews)", VIEW, ["x"]; @@ -474,6 +475,10 @@ impl Bindings { "Browse category watch later; combined elsewhere", ), (&[WatchLaterFilter], "Cycle all / unwatched / watched"), + ( + &[WatchLaterRemoveSelected], + "Remove the selected video (also in previews)", + ), ( &[WatchLaterRemove], "Confirm removal of filtered subset (combined: all matches)", @@ -1023,7 +1028,7 @@ mod tests { Some(Action::InfoDescription), ); let bindings = configured( - "[keys.video.watch_later]\nsave = 'alt+w'\n[keys.view.watch_later]\nbrowse = 'shift+x'\nfilter = 'ctrl+f'\nremove = []\n", + "[keys.video.watch_later]\nsave = 'alt+w'\nremove = []\n[keys.view.watch_later]\nbrowse = 'shift+x'\nfilter = 'ctrl+f'\nremove = []\n", ) .unwrap(); for context in ALL { @@ -1083,7 +1088,7 @@ mod tests { } } let bindings = configured( - "[keys.video.saved]\nsave = 'alt+v'\nremove = []\n[keys.view.saved]\nbrowse = 'shift+x'\n", + "[keys.video.watch_later]\nremove = []\n[keys.video.saved]\nsave = 'alt+v'\nremove = []\n[keys.view.saved]\nbrowse = 'shift+x'\n", ) .unwrap(); for context in ALL { diff --git a/src/main.rs b/src/main.rs index c2670e3..5e5aa3e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -98,6 +98,7 @@ //! Both collections store offline metadata beside config.toml; current channel tags determine category lists. //! Saved titles are green before watch-later magenta; ✓ marks acknowledged eligible playback reaching 95%. //! In watch-later, f cycles All/Unwatched/Watched; D asks before removing the filtered subset (y confirms). +//! X removes only the selected watch-later video, including in previews; x removes from saved videos. mod config; mod keys; @@ -137,7 +138,7 @@ use youtube::{Job, PAGE_SIZE, Page, PlayerLaunch, Video}; #[command( version, about = "Browse YouTube and open selected videos in Terebi", - after_help = "Key names below describe default bindings. [keys] overrides named actions with a string or array; omitted actions keep defaults and [] disables an action. Live hints and help reflect overrides.\n--default-config prints complete default TOML to stdout and exits without loading config or starting a terminal.\nRequires 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 plus --progress-file for an independent private reporting stream 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.\nNORMAL ? opens a scrollable keybinding reference over the current view or dialog. The bottom bar shows only essential actions. Scroll help with j/k, arrows, Ctrl-J/K or PageUp/PageDown; ? or Esc closes it. Question mark remains literal text in input fields.\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.\nWATCH LATER: w saves the selected video once (also in previews); W opens the current category's watch-later list, or the combined collection elsewhere. Lists follow current channel category memberships and use persisted metadata offline. In watch-later views f cycles All/Unwatched/Watched; D prompts to remove the current filtered subset from the shared collection, y confirms, n/Esc cancels, and Enter never confirms. Watch-later titles are magenta; a checkmark marks watched videos in every table. Eligible acknowledged progress reaching 95% of a known duration marks watched; seeking near the end counts, launcher exit does not. Separate watch-later.toml and watch-state.toml sit beside config.toml. Private playback-sessions survive Tubular exit for next-launch recovery.\nSAVED VIDEOS: v saves the selected video once (also in previews); V opens the current category's saved-video list, including from a category watch-later list, or the combined collection elsewhere. W likewise retains a saved list's category. Lists derive from current channel memberships and use offline metadata in saved-videos.toml beside config.toml. x removes only the selected saved video in normal or preview mode, without changing watch later or watched state. Saved titles are green, taking precedence over watch-later magenta. Saved lists have no watched filter or bulk removal. Both collections share the temporary tab and cached back/forward history.\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 goes back through view history; + goes forward. Both restore cached rows, selection, and pagination, including replaced temporary tabs. New view navigation clears the forward branch. Removed views are skipped and empty history does nothing. Esc first closes popups or leaves INSERT without navigating; minus and plus type 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:\n[settings]\npinned_categories = [\"Favorites\"]\n[categories]\nCreators = [\"@jawed\"]\nFavorites = [\"@jawed\"]\n[channels]\n\"@jawed\" = \"https://www.youtube.com/channel/UC4QobU6STFB0P71PMvOGN5A\"\n[settings].pinned_categories is an array of category names; pins referencing removed categories are ignored. Settings, channels, categories and keys tables can appear in any order. Add [settings] above pinned_categories in older configs; root-level pins are no longer accepted.\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.\nTAG FILTER (s/S): i edits a case-insensitive substring filter; arrows or Ctrl-J/K move through matches while typing. Enter or Esc returns to NORMAL without saving or clearing the filter. Hidden staged memberships are retained; no matches makes navigation/toggling a no-op. Reopening clears the filter.\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, clears the filter, selects the new tag, 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 = "Key names below describe default bindings. [keys] overrides named actions with a string or array; omitted actions keep defaults and [] disables an action. Live hints and help reflect overrides.\n--default-config prints complete default TOML to stdout and exits without loading config or starting a terminal.\nRequires 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 plus --progress-file for an independent private reporting stream 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.\nNORMAL ? opens a scrollable keybinding reference over the current view or dialog. The bottom bar shows only essential actions. Scroll help with j/k, arrows, Ctrl-J/K or PageUp/PageDown; ? or Esc closes it. Question mark remains literal text in input fields.\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.\nWATCH LATER: w saves the selected video once (also in previews); W opens the current category's watch-later list, or the combined collection elsewhere. Lists follow current channel category memberships and use persisted metadata offline. X (Shift-X) immediately removes only the selected watch-later video in normal or preview mode, leaving saved membership and watched status unchanged; configure video.watch_later.remove separately from bulk view.watch_later.remove. In watch-later views f cycles All/Unwatched/Watched; D prompts to remove the current filtered subset from the shared collection, y confirms, n/Esc cancels, and Enter never confirms. Watch-later titles are magenta; a checkmark marks watched videos in every table. Eligible acknowledged progress reaching 95% of a known duration marks watched; seeking near the end counts, launcher exit does not. Separate watch-later.toml and watch-state.toml sit beside config.toml. Private playback-sessions survive Tubular exit for next-launch recovery.\nSAVED VIDEOS: v saves the selected video once (also in previews); V opens the current category's saved-video list, including from a category watch-later list, or the combined collection elsewhere. W likewise retains a saved list's category. Lists derive from current channel memberships and use offline metadata in saved-videos.toml beside config.toml. x removes only the selected saved video in normal or preview mode, without changing watch later or watched state. Saved titles are green, taking precedence over watch-later magenta. Saved lists have no watched filter or bulk removal. Both collections share the temporary tab and cached back/forward history.\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 goes back through view history; + goes forward. Both restore cached rows, selection, and pagination, including replaced temporary tabs. New view navigation clears the forward branch. Removed views are skipped and empty history does nothing. Esc first closes popups or leaves INSERT without navigating; minus and plus type 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:\n[settings]\npinned_categories = [\"Favorites\"]\n[categories]\nCreators = [\"@jawed\"]\nFavorites = [\"@jawed\"]\n[channels]\n\"@jawed\" = \"https://www.youtube.com/channel/UC4QobU6STFB0P71PMvOGN5A\"\n[settings].pinned_categories is an array of category names; pins referencing removed categories are ignored. Settings, channels, categories and keys tables can appear in any order. Add [settings] above pinned_categories in older configs; root-level pins are no longer accepted.\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.\nTAG FILTER (s/S): i edits a case-insensitive substring filter; arrows or Ctrl-J/K move through matches while typing. Enter or Esc returns to NORMAL without saving or clearing the filter. Hidden staged memberships are retained; no matches makes navigation/toggling a no-op. Reopening clears the filter.\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, clears the filter, selects the new tag, 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; must support --new-instance, --url, and --progress-file. @@ -482,9 +483,10 @@ impl KeyHints { ( Context::Info, format!( - "INFO · {} description · {} later · {} save · {} unsave · {} close · {} help", + "INFO · {} description · {} later · {} remove later · {} save · {} unsave · {} close · {} help", key(Action::InfoDescription), key(Action::WatchLaterSave), + key(Action::WatchLaterRemoveSelected), key(Action::SavedVideoSave), key(Action::SavedVideoRemove), key(Action::InfoHide), @@ -494,11 +496,12 @@ impl KeyHints { ( Context::Description, format!( - "DESCRIPTION · {}/{} scroll · {} info · {} later · {} save · {} unsave · {} close · {} help", + "DESCRIPTION · {}/{} scroll · {} info · {} later · {} remove later · {} save · {} unsave · {} close · {} help", key(Action::DescriptionNext), key(Action::DescriptionPrevious), key(Action::InfoOverview), key(Action::WatchLaterSave), + key(Action::WatchLaterRemoveSelected), key(Action::SavedVideoSave), key(Action::SavedVideoRemove), key(Action::InfoHide), @@ -581,19 +584,21 @@ impl KeyHints { ], preview: [ format!( - "· {} description · {} later · {} save · {} unsave · {} close ", + "· {} description · {} later · {} remove later · {} save · {} unsave · {} close ", key(Action::InfoDescription), key(Action::WatchLaterSave), + key(Action::WatchLaterRemoveSelected), key(Action::SavedVideoSave), key(Action::SavedVideoRemove), key(Action::InfoHide) ), format!( - "· {}/{} scroll · {} info · {} later · {} save · {} unsave · {} close ", + "· {}/{} scroll · {} info · {} later · {} remove later · {} save · {} unsave · {} close ", key(Action::DescriptionNext), key(Action::DescriptionPrevious), key(Action::InfoOverview), key(Action::WatchLaterSave), + key(Action::WatchLaterRemoveSelected), key(Action::SavedVideoSave), key(Action::SavedVideoRemove), key(Action::InfoHide) @@ -647,8 +652,9 @@ impl KeyHints { key(Action::HelpPrevious) ), watch_later: format!( - "· {} filter · {} remove ", + "· {} filter · {} remove selected · {} remove filtered ", key(Action::WatchLaterFilter), + key(Action::WatchLaterRemoveSelected), key(Action::WatchLaterRemove) ), saved_videos: format!("· {} remove selected ", key(Action::SavedVideoRemove)), @@ -1355,7 +1361,7 @@ impl App { self.status = self.view_status(); } - fn remove_saved_video(&mut self) { + fn remove_collection(&mut self, kind: CollectionKind) { let view = &self.views[self.view_index]; let Some(video) = view .selection @@ -1365,15 +1371,23 @@ impl App { self.status = "Select a video first.".into(); return; }; - if !self.video_state.contains(CollectionKind::Saved, &video.id) { - self.status = "Video is not in saved videos.".into(); + if !self.video_state.contains(kind, &video.id) { + self.status = match kind { + CollectionKind::WatchLater => "Video is not in watch later.", + CollectionKind::Saved => "Video is not in saved videos.", + } + .into(); return; } let id = video.id.clone(); - match self.video_state.remove(CollectionKind::Saved, &[id]) { + match self.video_state.remove(kind, &[id]) { Ok(()) => { self.rebuild_collections(); - self.status = "Video removed from saved videos.".into(); + self.status = match kind { + CollectionKind::WatchLater => "Video removed from watch later.", + CollectionKind::Saved => "Video removed from saved videos.", + } + .into(); } Err(error) => self.status = error.to_string(), } @@ -2042,9 +2056,12 @@ impl App { } Some(Action::WatchLaterFilter) => self.filter_watch_later(), Some(Action::WatchLaterRemove) => self.remove_watch_later(), + Some(Action::WatchLaterRemoveSelected) => { + self.remove_collection(CollectionKind::WatchLater) + } Some(Action::SavedVideoSave) => self.save_collection(CollectionKind::Saved), Some(Action::SavedVideoBrowse) => self.browse_collection(CollectionKind::Saved), - Some(Action::SavedVideoRemove) => self.remove_saved_video(), + Some(Action::SavedVideoRemove) => self.remove_collection(CollectionKind::Saved), Some(Action::VideoPlay) => self.play(), Some(Action::VideoNext) => self.views[self.view_index].selection.select_next(), Some(Action::VideoPrevious) => { @@ -2793,6 +2810,76 @@ mod tests { ) } + #[test] + fn individual_watch_later_removal_keeps_siblings_saved_and_watched() { + let root = std::env::temp_dir().join(format!( + "tubular-single-watch-removal-{}", + std::process::id() + )); + let _ = std::fs::remove_dir_all(&root); + std::fs::create_dir_all(&root).unwrap(); + std::fs::write( + root.join("watch-state.toml"), + "version = 1\nwatched = ['jNQXAC9IVRw']\n", + ) + .unwrap(); + let mut app = App::with_state( + Options::parse_from(["tubular"]), + root.join("config.toml"), + config::Config::default(), + video_state::State::open(&root.join("config.toml")).unwrap(), + ); + app.views[0].videos = youtube::search_results( + r#"{"entries":[{"id":"jNQXAC9IVRw","title":"First","uploader_id":"@creator"},{"id":"rQ_J9WH6CGk","title":"Second","uploader_id":"@creator"}]}"#, + ).unwrap().videos; + app.views[0].loaded = true; + app.views[0].selection.select(Some(0)); + app.save_collection(CollectionKind::WatchLater); + app.save_collection(CollectionKind::Saved); + app.views[0].selection.select(Some(1)); + app.save_collection(CollectionKind::WatchLater); + app.views[0].selection.select(Some(0)); + app.key(KeyEvent::new(KeyCode::Char('X'), KeyModifiers::SHIFT)); + assert!( + !app.video_state + .contains(CollectionKind::WatchLater, "jNQXAC9IVRw") + ); + assert!( + app.video_state + .contains(CollectionKind::WatchLater, "rQ_J9WH6CGk") + ); + assert!( + app.video_state + .contains(CollectionKind::Saved, "jNQXAC9IVRw") + ); + assert!(app.video_state.is_watched("jNQXAC9IVRw")); + assert!(app.watch_removal.is_none()); + app.views[0].selection.select(Some(1)); + app.preview = Some(PreviewMode::Info); + app.key(KeyEvent::new(KeyCode::Char('X'), KeyModifiers::NONE)); + assert!( + app.video_state + .videos(CollectionKind::WatchLater) + .is_empty() + ); + assert_eq!(app.preview, Some(PreviewMode::Info)); + app.save_collection(CollectionKind::WatchLater); + app.preview = Some(PreviewMode::Description); + app.key(KeyEvent::new(KeyCode::Char('X'), KeyModifiers::NONE)); + assert!( + app.video_state + .videos(CollectionKind::WatchLater) + .is_empty() + ); + assert_eq!(app.preview, Some(PreviewMode::Description)); + drop(app); + let restarted = video_state::State::open(&root.join("config.toml")).unwrap(); + assert!(restarted.videos(CollectionKind::WatchLater).is_empty()); + assert!(restarted.contains(CollectionKind::Saved, "jNQXAC9IVRw")); + assert!(restarted.is_watched("jNQXAC9IVRw")); + std::fs::remove_dir_all(root).unwrap(); + } + #[test] fn watch_later_tracks_current_tags_filters_and_confirms_only_snapshot_removal() { let root = std::env::temp_dir().join(format!( @@ -3249,7 +3336,7 @@ mod tests { && cell.fg == Color::Black && cell.bg == Color::Cyan) ); - app.remove_saved_video(); + app.remove_collection(CollectionKind::Saved); app.views[0].selection.select(None); terminal .draw(|frame| app.draw(frame, Duration::ZERO))