From 22705275ae267ed87f4db7ec0221b5123bb8f42a Mon Sep 17 00:00:00 2001 From: Daniel Falbel Date: Tue, 27 Jan 2026 12:00:34 -0300 Subject: [PATCH] Add ark view connection method registration Register S3 methods with Positron's ark to enable viewing connections from the Variables pane: - ark_positron_variable_has_viewer: returns TRUE - ark_positron_variable_kind: returns "connection" - ark_positron_variable_view: opens connection in Connections pane Uses protected pattern with tryCatch and early exit when .ark.register_method is not available. Co-Authored-By: Claude Opus 4.5 --- R/zzz.R | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 R/zzz.R diff --git a/R/zzz.R b/R/zzz.R new file mode 100644 index 0000000..38854c6 --- /dev/null +++ b/R/zzz.R @@ -0,0 +1,33 @@ +.onLoad <- function(libname, pkgname) { + register_ark_methods() +} + +register_ark_methods <- function() { + tryCatch( + { + register <- get(".ark.register_method", envir = globalenv()) + + register( + "ark_positron_variable_has_viewer", + "connConnection", + function(x) TRUE + ) + + register( + "ark_positron_variable_kind", + "connConnection", + function(x) "connection" + ) + + register( + "ark_positron_variable_view", + "connConnection", + function(x) { + connection_view(x) + TRUE + } + ) + }, + error = function(e) {} + ) +}