Skip to content

View

Conversation views: one conversation’s active transcript and built-in state (pi.agent, pi.live, pi.inbox, pi.usage) as one JSON value, and a watch that delivers it per commit as JSON Patch operations.

import { type Ids, View } from "@effective-harness/core"
import * as Effect from "effect/Effect"
import * as Stream from "effect/Stream"
declare const conversationId: Ids.ConversationId
declare const render: (view: View.ConversationView) => void
const program = Effect.gen(function* () {
const watch = yield* View.watch(conversationId)
render(watch.value)
yield* Stream.runForEach(watch.changes, (frame) => Effect.sync(() => render(frame.value)))
})

A client joining late starts from the current value, so a reconnect needs nothing else. pi-durable sends Chord operations; these are RFC 6902 operations (add, remove, replace), so a string that grows is replaced whole.

Since v0.0.0


Signature

declare const ConversationView: ConversationView

Source

Since v0.0.0

The view after one commit that changed it.

Signature

export interface Frame {
readonly seq: Seq
readonly value: ConversationView
/** Operations from the previously delivered value; one root `replace` after an overflow. */
readonly ops: JsonPatch.JsonPatch
}

Source

Since v0.0.0

A watch of one conversation’s view.

Signature

export interface Watch {
/** The view at acquisition. */
readonly value: ConversationView
/**
* Every later commit that changed the view, in order. When more than `Session.MaxPendingWatchFrames` frames are
* waiting, they collapse into one root replacement. Ends when the Session closes.
*/
readonly changes: Stream.Stream<Frame>
}

Source

Since v0.0.0

The current view, read on the commit line.

Signature

declare const get: (
conversationId: ConversationId
) => Effect.Effect<ConversationView, ConversationNotFound | ReadError, Session>

Source

Since v0.0.0

Watch a conversation’s view. The value and the registration for later commits are captured atomically. The watch lives until its scope closes.

Signature

declare const watch: (
conversationId: ConversationId
) => Effect.Effect<Watch, ConversationNotFound | ReadError, Session | Scope.Scope>

Source

Since v0.0.0