MingaEditor.Window.Content (Minga v0.1.0)

Copy Markdown View Source

Polymorphic content reference for window panes.

A window can host any content type: a file buffer, an agent chat session, a terminal, etc. This module defines the tagged union that replaces the old buffer: pid() field on Window.t().

Why a tagged tuple instead of a protocol?

Window content references are stored in the window tree, serialized for tab save/restore, and pattern-matched in the render pipeline. A simple tagged tuple ({:buffer, pid}, {:agent, session_ref}) is easier to serialize, pattern-match, and debug than a protocol struct. The NavigableContent protocol handles the behavioral polymorphism; this module handles the identity/reference polymorphism.

Content types

TagReferenceNavigableContent?Editable?
:bufferpid() (Buffer.Server)Yes (via BufferSnapshot)Yes
:agent_chatpid() (Agent.Session)YesNo
:agent_promptpid() (Buffer.Server)Yes (via BufferSnapshot)Yes
:terminalpid() (future, #122)Yes (future)No
:browserreference() (future, #305)Yes (future)No

Only :buffer is implemented today. Other tags are documented here to show the design direction and will be added as their features land.

Summary

Types

t()

A content reference identifying what a window pane displays.

Functions

Creates an agent chat content reference. The pid is the agent's *Agent* Buffer.Server.

Returns true if this content reference is an agent chat.

Creates a buffer content reference.

Returns true if this content reference is a file buffer.

Returns the buffer pid if this is a buffer content reference, nil otherwise.

Returns true if the content is editable (supports insert mode).

Returns the underlying pid for any content type.

Types

t()

@type t() :: {:buffer, pid()} | {:agent_chat, pid()}

A content reference identifying what a window pane displays.

Currently only :buffer is used. Other variants will be added as their features are implemented.

Functions

agent_chat(pid)

@spec agent_chat(pid()) :: t()

Creates an agent chat content reference. The pid is the agent's *Agent* Buffer.Server.

agent_chat?(arg)

@spec agent_chat?(t()) :: boolean()

Returns true if this content reference is an agent chat.

buffer(pid)

@spec buffer(pid()) :: t()

Creates a buffer content reference.

buffer?(arg)

@spec buffer?(t()) :: boolean()

Returns true if this content reference is a file buffer.

buffer_pid(arg)

@spec buffer_pid(t()) :: pid() | nil

Returns the buffer pid if this is a buffer content reference, nil otherwise.

editable?(arg)

@spec editable?(t()) :: boolean()

Returns true if the content is editable (supports insert mode).

pid(arg)

@spec pid(t()) :: pid()

Returns the underlying pid for any content type.

For :buffer, this is the Buffer.Server pid. For :agent_chat, this is the agent's *Agent* Buffer.Server pid (used for cursor/scroll).