posit-dev / positron

Positron, a next-generation data science IDE
Other
1.59k stars 43 forks source link

[ark] Implement history_reply #3861

Open rgbkrk opened 5 days ago

rgbkrk commented 5 days ago

When using jupyter console --kernel ark, this error will show up:

In [1]: c(1,2,3)  2024-07-03T23:23:15.522176Z  INFO  Setting 'DYLD_FALLBACK_LIBRARY_PATH' env var to '/opt/homebrew/Cellar/r/4.4.1/lib/R/lib'.
    at crates/harp/src/sys/unix/library.rs:107

  2024-07-03T23:23:15.526100Z  INFO  Successfully opened R shared library at '/opt/homebrew/Cellar/r/4.4.1/lib/R/lib/libR.dylib'.
    at crates/harp/src/library.rs:30

  2024-07-03T23:23:15.631883Z  WARN  Could not read message from shell socket: Unknown message type 'history_request'
    at crates/amalthea/src/socket/shell.rs:125

In [1]: c(1,2,3)
Out[1]: [1] 1 2 3

You can put in a spec compliant reply by returning a history_reply with an empty history vec. Here's how we do it in the Deno (TypeScript) kernel: https://github.com/denoland/deno/blob/dd6d19e12051fac2ea5639f621501f4710a1b8e1/cli/tools/jupyter/server.rs#L375-L386

      JupyterMessageContent::HistoryRequest(_req) => {
        connection
          .send(
            messaging::HistoryReply {
              history: vec![],
              error: None,
              status: ReplyStatus::Ok,
            }
            .as_child_of(parent),
          )
          .await?;
      }

Nice to see more Rust backed kernels! I'll be testing ark out in Zed soon.

juliasilge commented 5 days ago

@lionel- should we add to #2264?

lionel- commented 5 days ago

I just added this to the list of todo items, we'll take a look.