Repository navigation
feat(minimald): refactor progress, display session setup on first attach #591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| //! Scoped progress rendering onto an SSH channel. | ||
| //! | ||
| //! [`ChannelProgress`] is the `russh`-concrete wrapper around | ||
| //! [`ot::render_operations_while`]: it consumes an SSH [`Channel`], an | ||
| //! [`OpTracker`], and a future, paints the tracker's live operation tree onto | ||
| //! the channel as indicatif progress bars while the future runs, and hands the | ||
| //! channel back (with the future's output) once it resolves. | ||
| //! | ||
| //! The renderer takes **exclusive** use of the channel for the future's | ||
| //! duration — the wrapped operation must not also write to it. This is the | ||
| //! "compute under a progress bar, then print the result" model; live output | ||
| //! interleaved with progress is out of scope (see | ||
| //! `docs/specs/04-spec-ot-render-decoupling`). | ||
|
|
||
| use std::future::Future; | ||
|
|
||
| use ot::OpTracker; | ||
| use russh::Channel; | ||
| use russh::server::Msg; | ||
|
|
||
| /// Renders an [`OpTracker`] onto an SSH channel for the lifetime of a future. | ||
| /// | ||
| /// Construct with [`ChannelProgress::new`], then drive a future with | ||
| /// [`run`](ChannelProgress::run); the channel is returned alongside the | ||
| /// future's output so the caller can resume writing to it. | ||
| pub struct ChannelProgress { | ||
| channel: Channel<Msg>, | ||
| tracker: OpTracker, | ||
| /// Terminal dimensions `(cols, rows)` indicatif lays bars out against — | ||
| /// from the session's PTY size. | ||
| size: (u16, u16), | ||
| } | ||
|
|
||
| impl ChannelProgress { | ||
| /// Creates a renderer that will paint `tracker` onto `channel`, sized for a | ||
| /// `(cols, rows)` terminal. | ||
| #[must_use] | ||
| pub fn new(channel: Channel<Msg>, tracker: OpTracker, size: (u16, u16)) -> Self { | ||
| Self { | ||
| channel, | ||
| tracker, | ||
| size, | ||
| } | ||
| } | ||
|
|
||
| /// Renders progress onto the channel while `fut` runs, returning the channel | ||
| /// and the future's output once it resolves. | ||
| /// | ||
| /// The channel is borrowed (via an independent writer) during rendering and | ||
| /// returned intact — the writer only ever writes data frames, never an EOF, | ||
| /// so the caller can keep using the channel afterwards. | ||
| pub async fn run<F: Future>(self, fut: F) -> (Channel<Msg>, F::Output) { | ||
| let writer = self.channel.make_writer(); | ||
| let out = ot::render_operations_while(&self.tracker, writer, self.size, fut).await; | ||
| (self.channel, out) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| use std::collections::BTreeMap; | ||
|
|
||
| pub mod channel_progress; | ||
| pub mod connection; | ||
| pub mod env; | ||
| mod exec; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.