Handle comm_open data and fire positron.session_init hooks#1088
Open
Handle comm_open data and fire positron.session_init hooks#1088
Conversation
100cc17 to
3c0d522
Compare
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This reverts commit cadcf8b.
This reverts commit 3c0d522.
Add `comm_open_data` field to `CommSocket` so handlers can access initial state from the frontend. On UI comm open, register the `console_width` and fire session init hooks with `start_type` as the input.
cadcf8b to
532f304
Compare
lionel-
reviewed
Mar 19, 2026
Contributor
lionel-
left a comment
There was a problem hiding this comment.
Looking good! Just a few style comments
| self.ui_comm_tx = Some(UiCommSender::new(ui_comm_tx)); | ||
|
|
||
| // Set initial console width from the comm_open data, if provided. | ||
| if let Some(width) = comm_open_data.get("console_width").and_then(|v| v.as_i64()) { |
Contributor
There was a problem hiding this comment.
I think here we'd try to deserialise from a struct defined in ark/ui/ui_comm.rs with serde_json::from_value().
Comment on lines
+29
to
+34
| if let Err(err) = harp::exec::RFunction::from(".ps.rpc.setConsoleWidth") | ||
| .param("width", RObject::from(width as i32)) | ||
| .call() | ||
| { | ||
| log::warn!("Failed to set initial console width: {err:?}"); | ||
| } |
Contributor
There was a problem hiding this comment.
Here and below: you can use the .log_err() method to collapse this to a single call chain.
| let start_type = comm_open_data | ||
| .get("start_type") | ||
| .and_then(|v| v.as_str()) | ||
| .unwrap_or("new"); |
Contributor
There was a problem hiding this comment.
With the struct approach you can define default values in the struct directly.
| ) | ||
| } | ||
|
|
||
| #' @export |
Contributor
There was a problem hiding this comment.
Does this need to be exported on the search path? Exporting should generally be a last resort.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses posit-dev/positron#9763
Addresses #697
Companion PR in positron: posit-dev/positron#12312
See Positron PR for all discussion at this point.