Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ body:
attributes:
label: Flowbit version
description: Shown at the bottom of Preferences.
placeholder: "1.3.0"
placeholder: "0.1.0"
validations:
required: true
- type: dropdown
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
workflow_dispatch:
inputs:
tag:
description: Release tag, like v1.4.0
description: Release tag, like v0.1.0
required: true

permissions:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

All notable changes to Flowbit. Versions follow [Semantic Versioning](https://semver.org).

## 0.1.0 - Unreleased

Version numbers start over at 0.1.0 with this release. Releases 1.3.0 to 1.4.0 below came before it.

### Added

- **Select all**: tick torrents in the list, or all of them, and remove them together, with or
without their files.

### Fixed

- Reopening Flowbit no longer repeats the "Download finished" notification for torrents that
finished earlier.

## [1.4.0] - 2026-11-07

### Added
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flowbit",
"version": "1.4.0",
"version": "0.1.0",
"private": true,
"description": "Streaming torrent client for Windows: Rust (librqbit, Tauri) and mpv",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flowbit"
version = "1.4.0"
version = "0.1.0"
description = "Streaming torrent client"
authors = ["Flowbit contributors"]
license = "MIT"
Expand Down
72 changes: 71 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,32 @@ fn open_args(app: &AppHandle, args: Vec<String>) {
});
}

/// Tells downloads finishing now from finished torrents being reloaded at startup.
/// While a restored torrent is being checked it reports "not finished", so it only
/// counts once it has been seen missing data after the check.
#[derive(Default)]
struct FinishNotices {
restored: HashSet<String>,
incomplete: HashSet<String>,
}

impl FinishNotices {
fn observe(&mut self, info_hash: &str, state: &str, finished: bool) {
if !finished && matches!(state, "live" | "paused") {
self.incomplete.insert(info_hash.to_owned());
}
}

fn downloaded_now(&self, info_hash: &str) -> bool {
!self.restored.contains(info_hash) || self.incomplete.contains(info_hash)
}
}

/// Notifies when downloads finish, pauses them if they shouldn't seed, and keeps
/// the tray tooltip's speeds current
async fn watch_torrents(app: AppHandle) {
let mut finished: HashSet<String> = HashSet::new();
let mut notices = FinishNotices::default();
let mut first = true;
let mut last_count = 0;
loop {
Expand All @@ -826,7 +848,11 @@ async fn watch_torrents(app: AppHandle) {
};
let torrents = engine.list();
let prefs = state.prefs();
if first {
notices.restored = torrents.iter().map(|t| t.info_hash.clone()).collect();
}
for t in &torrents {
notices.observe(&t.info_hash, t.state, t.finished);
if t.state == "live" && stops_when_done(&state, &prefs, t) {
engine.pause(t.id).await.ok();
}
Expand All @@ -847,7 +873,7 @@ async fn watch_torrents(app: AppHandle) {
paths.iter().for_each(|p| posters::mark_of_the_web(p))
});
}
if first {
if !notices.downloaded_now(&t.info_hash) {
continue;
}
let name = t.name.clone().unwrap_or_else(|| "Torrent".into());
Expand Down Expand Up @@ -1074,3 +1100,47 @@ fn sanitize_file_name(name: &str) -> String {
})
.collect()
}

#[cfg(test)]
mod tests {
use super::*;

fn restored() -> FinishNotices {
FinishNotices {
restored: HashSet::from(["a".to_owned()]),
..Default::default()
}
}

#[test]
fn a_finished_torrent_checked_at_startup_is_not_announced() {
let mut notices = restored();
notices.observe("a", "initializing", false);
notices.observe("a", "paused", true);
assert!(!notices.downloaded_now("a"));
}

#[test]
fn a_restored_download_that_completes_is_announced() {
let mut notices = restored();
notices.observe("a", "initializing", false);
notices.observe("a", "live", false);
notices.observe("a", "live", true);
assert!(notices.downloaded_now("a"));
}

#[test]
fn a_restored_torrent_that_failed_is_not_counted_as_incomplete() {
let mut notices = restored();
notices.observe("a", "error", false);
notices.observe("a", "paused", true);
assert!(!notices.downloaded_now("a"));
}

#[test]
fn a_torrent_added_while_running_is_announced() {
let mut notices = restored();
notices.observe("b", "live", true);
assert!(notices.downloaded_now("b"));
}
}
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schema.tauri.app/config/2",
"productName": "Flowbit",
"mainBinaryName": "Flowbit",
"version": "1.4.0",
"version": "0.1.0",
"identifier": "app.flowbit.desktop",
"build": {
"frontendDist": "../ui"
Expand Down
3 changes: 2 additions & 1 deletion ui/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ body {
margin-top: 1px;
}

.modal-content .check-row {
.modal-content .check-row,
.bulk-bar .check-row {
display: flex;
align-items: center;
gap: 10px;
Expand Down
82 changes: 81 additions & 1 deletion ui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const state = {
expanded: null, // id of the torrent whose files are shown
files: {}, // torrent id -> file list
menu: null, // id of the torrent whose "more" menu is open
selected: new Set(), // ids of the torrents ticked in the list
modal: null,
visible: true,
engineError: null,
Expand Down Expand Up @@ -316,9 +317,32 @@ function renderHome () {
: state.filter === 'all' ? tt('home.empty') : tt('home.emptyFilter')
html = `<div class="empty"><strong>${message}</strong><span>${tt('home.emptyHint')}</span></div>`
} else {
html = `<ul class="torrent-list">${torrents.map(renderTorrent).join('')}</ul>`
html = `${renderBulkBar(torrents)}<ul class="torrent-list">${torrents.map(renderTorrent).join('')}</ul>`
}
setHTML($('list'), html)

const selectAll = $('select-all')
if (selectAll) {
const count = selectedAmong(torrents).length
selectAll.indeterminate = count > 0 && count < torrents.length
}
}

// Only what's on screen counts, so a filter or search can't hide what gets removed
function selectedAmong (torrents) {
return torrents.filter((t) => state.selected.has(t.id))
}

function renderBulkBar (torrents) {
const count = selectedAmong(torrents).length
const remove = count
? `<span class="count mono">${tt('bulk.selected', { count })}</span>
<button type="button" class="btn small danger" data-action="remove-selected">${icon('trash', 16)}${tt('bulk.remove')}</button>`
: ''
return `<div class="bulk-bar">
<label class="check-row"><input type="checkbox" class="checkbox" id="select-all"${count === torrents.length ? ' checked' : ''}>${tt('bulk.selectAll')}</label>
${remove}
</div>`
}

// Torrents already drawn once, so only new ones fade in
Expand Down Expand Up @@ -379,6 +403,7 @@ function renderTorrent (t) {

return `<li class="torrent${expanded ? ' selected' : ''}${isNew ? ' new' : ''}${state.menu === t.id ? ' menu-open' : ''}" data-id="${t.id}">
<div class="torrent-row" data-action="toggle-files" data-id="${t.id}">
<input type="checkbox" class="checkbox" data-action="select-torrent" data-id="${t.id}" aria-label="${tt('bulk.selectOne', { name })}"${state.selected.has(t.id) ? ' checked' : ''}>
<div class="poster${posterClass(t.infoHash)}" aria-hidden="true">${initial}</div>
<div class="torrent-info">
<div class="torrent-name"><span class="name ellipsis" title="${esc(name)}">${esc(name)}</span><span class="chip ${st.cls}">${tt(st.key)}</span></div>
Expand Down Expand Up @@ -1060,6 +1085,16 @@ function renderModal () {
${tt('remove.deleteFiles')}</label>
<div class="modal-actions"><button type="button" class="btn cancel" data-action="close-modal">${tt('common.cancel')}</button>
<button type="button" class="btn danger" data-action="confirm-remove">${tt('remove.ok')}</button></div>`
} else if (m.id === 'remove-many') {
const names = state.snapshot.torrents
.filter((x) => m.torrents.includes(x.id))
.map((x) => `<li dir="auto">${esc(x.name || '…')}</li>`).join('')
body = `<h1>${tt('remove.titleMany', { count: m.torrents.length })}</h1>
<ul style="margin:0;padding:0;list-style:none;color:var(--text-2);max-height:160px;overflow:auto;overflow-wrap:anywhere">${names}</ul>
<label class="check-row"><input type="checkbox" class="checkbox" id="delete-files">
${tt('remove.deleteFilesMany')}</label>
<div class="modal-actions"><button type="button" class="btn cancel" data-action="close-modal">${tt('common.cancel')}</button>
<button type="button" class="btn danger" data-action="confirm-remove-many">${tt('remove.ok')}</button></div>`
}
root.innerHTML = `<div class="modal"><div class="modal-background" data-action="close-modal"></div>
<section class="modal-content" role="dialog" aria-modal="true">${body}</section></div>`
Expand Down Expand Up @@ -1104,6 +1139,9 @@ async function refresh () {
for (const id of Object.keys(state.files)) {
if (!snapshot.torrents.some((x) => String(x.id) === id)) delete state.files[id]
}
for (const id of state.selected) {
if (!snapshot.torrents.some((x) => x.id === id)) state.selected.delete(id)
}
loadPosters(snapshot.torrents)
} catch (err) {
state.engineError = String(err)
Expand Down Expand Up @@ -1144,6 +1182,34 @@ async function addPathList (paths) {
}
}

function onSelectTorrent (el) {
const id = Number(el.dataset.id)
if (el.checked) state.selected.add(id)
else state.selected.delete(id)
renderHome()
}

function onSelectAll (el) {
for (const t of visibleTorrents()) {
if (el.checked) state.selected.add(t.id)
else state.selected.delete(t.id)
}
renderHome()
}

// Keeps going if one fails, then reports the first error
async function removeMany (ids, deleteFiles) {
let failure = null
for (const id of ids) {
try {
await invoke('remove', { id, deleteFiles })
} catch (err) {
failure = failure ?? err
}
}
if (failure !== null) throw failure
}

async function act (promise, after) {
try {
const result = await promise
Expand Down Expand Up @@ -1284,6 +1350,18 @@ function handleAction (el, event) {
act(invoke('remove', { id: torrent, deleteFiles }))
break
}
case 'remove-selected':
openModal({ id: 'remove-many', torrents: selectedAmong(visibleTorrents()).map((x) => x.id) })
break
case 'confirm-remove-many': {
const deleteFiles = $('delete-files').checked
const ids = state.modal.torrents
closeModal()
sound('delete')
if (ids.includes(state.expanded)) state.expanded = null
act(removeMany(ids, deleteFiles))
break
}
case 'set-pref':
updatePref(el.dataset.pref, el.dataset.value)
break
Expand Down Expand Up @@ -1408,6 +1486,8 @@ async function start () {
document.addEventListener('change', (e) => {
const el = e.target
if (el.dataset.action === 'include-file') onIncludeFile(el)
else if (el.dataset.action === 'select-torrent') onSelectTorrent(el)
else if (el.id === 'select-all') onSelectAll(el)
else if (el.dataset.action === 'set-watched') onSetWatched(el)
else if (el.id === 'tr-save-as') state.tr.saveAs = el.checked
else if (el.dataset.pref) onPrefInput(el)
Expand Down
14 changes: 14 additions & 0 deletions ui/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ const STRINGS = {
'remove.title': 'Remove torrent?',
'remove.deleteFiles': 'Also delete its downloaded files',
'remove.ok': 'Remove',
'remove.titleMany': 'Remove {count} torrents?',
'remove.deleteFilesMany': 'Also delete their downloaded files',

'bulk.selectAll': 'Select all',
'bulk.selectOne': 'Select {name}',
'bulk.selected': '{count} selected',
'bulk.remove': 'Remove selected',

'share.titleOne': 'Share this publicly?',
'share.titleMany': 'Share these {count} publicly?',
Expand Down Expand Up @@ -373,6 +380,13 @@ const STRINGS = {
'remove.title': 'حذف التورنت؟',
'remove.deleteFiles': 'احذف ملفاته المنزّلة أيضًا',
'remove.ok': 'حذف',
'remove.titleMany': 'حذف {count} من التورنتات؟',
'remove.deleteFilesMany': 'احذف ملفاتها المنزّلة أيضًا',

'bulk.selectAll': 'تحديد الكل',
'bulk.selectOne': 'تحديد {name}',
'bulk.selected': 'المحدد: {count}',
'bulk.remove': 'حذف المحدد',

'share.titleOne': 'مشاركة هذا للجميع؟',
'share.titleMany': 'مشاركة هذه الـ {count} للجميع؟',
Expand Down
18 changes: 18 additions & 0 deletions ui/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,24 @@ textarea.input {
* TORRENTS
*/

.bulk-bar {
display: flex;
align-items: center;
gap: 12px;
min-height: 32px;
margin-bottom: 10px;
padding-inline-start: 17px;
}

.bulk-bar .check-row {
margin-inline-end: auto;
}

.bulk-bar .count {
font-size: 13px;
color: var(--text-3);
}

.torrent-list {
list-style: none;
margin: 0;
Expand Down
Loading