Skip to content

Expose nrepl log to Calva API #2955

@maxrothman

Description

@maxrothman

Calva currently has an API for getting access to REPL output messages, but for some use cases it makes more sense to get direct access to the nrepl messages themselves. For example, this would allow for writing a Joyride script to send a notification when a repl command that has run for more than 5 seconds completes.

Here's a strawman proposal for the new API to get a conversation started:

function onNreplMessage(
  callback: (msg: NreplMessage) => void
) => vscode.Disposable

interface BaseNreplMessage {
  "id": string
  "session": string
}

interface SentNreplMessage extends BaseNreplMessage {
  "calva.type": "sent"
  "op": string
  ...
}

interface ReceivedNreplMessage extends BaseNreplMessage {
  "calva.type": "received"
  ...
}

type NreplMessage: SentNreplMessage | ReceivedNreplMessage

Considerations:

  • Should this be one API or two? (one for sent messages and one for received messages)
  • It's going to be impossible to fully ts-type the messages without enumerating all the ops, but that should be fine from an API consumer perspective since it's easy to introspect the messages. Will it cause any internal issues for Calva?
  • The callback probably shouldn't be allowed to block or disrupt Calva's processing of an nrepl message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions