Skip to content

Add data stream progress events and file rendering#30

Draft
1egoman wants to merge 1 commit into
mainfrom
add-data-stream-progress
Draft

Add data stream progress events and file rendering#30
1egoman wants to merge 1 commit into
mainfrom
add-data-stream-progress

Conversation

@1egoman

@1egoman 1egoman commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Warning

This change relies on the rust data streams v2 implementation. This cannot be merged until that is merged first. This is also why CI is failing.

Add logic to handle rendering data streams with names and/or mime types associated as a special "file" state. I am assuming that these will be relatively large so files are buffered in tempfiles rather than in memory. And then also, add a "save" button which can be used to save files to arbitrary locations for inspection.

Untitled.mov

I will say, design wise, I think this side panel is starting to break down a little bit now that there is a card rendered within a card. I can try some more stuff here but also I'm not an egui expert so I would be interested in some ideas before investigating anything.

Add logic to handle rendering data streams with names and/or mime types
associated as a special "file" state. I am assuming that these will be
relatively large so files are buffered in tempfiles rather than in
memory. And then also, add a "save" button which can be used to save
files to arbitrary locations for inspection.
@1egoman
1egoman marked this pull request as ready for review July 16, 2026 20:58
@1egoman
1egoman requested a review from ladvoc as a code owner July 16, 2026 20:58
Comment thread src/room/data_streams.rs
Comment on lines +639 to +661
/// Streams every chunk of a byte reader into an anonymous temp file, returning the open
/// handle. The file is unlinked at creation (`tempfile`), so the OS reclaims it when the
/// handle is dropped or the process exits — including on a panic/abort, where `Drop` would
/// not run (the release profile sets `panic = "abort"`).
async fn stream_to_temp_file(
reader: &mut ByteStreamReader,
entry: &Arc<Mutex<TopicEntry>>,
n: u64,
total: Option<u64>,
) -> Result<std::fs::File, String> {
use tokio::io::AsyncWriteExt;
let std_file = tempfile::tempfile_in(std::env::temp_dir()).map_err(|e| e.to_string())?;
let mut file = tokio::fs::File::from_std(std_file);
let mut processed = 0u64;
while let Some(chunk) = reader.next().await {
let chunk = chunk.map_err(|e| e.to_string())?;
file.write_all(&chunk).await.map_err(|e| e.to_string())?;
processed += chunk.len() as u64;
update_progress(entry, n, processed, total);
}
file.flush().await.map_err(|e| e.to_string())?;
Ok(file.into_std().await)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note to any reviewers - this maybe could make sense as an extension to ByteStreamReader?

@1egoman
1egoman requested review from MaxHeimbrock and xianshijing-lk and removed request for xianshijing-lk July 16, 2026 21:00
@1egoman
1egoman marked this pull request as draft July 16, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant