server.negotiation_oob

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

OOB helpers for negotiation — shell actions, layout regions, streamed append.

OOB helpers for negotiation — shell actions, layout regions, streamed append.

server.negotiation_oob

Name Type Default Description
type
qualified_name
element_type
description
source_file
line_number
is_autodoc
autodoc_element
_autodoc_template
_autodoc_url_path
_autodoc_page_type
title
doc_content_hash

Symbols on this page

async function _render_off_loop

Run a discrete, CPU-bound kida render off the event loop (issue #193).

The OOB streams chained onto aLayoutSuspenseresponse (append_layout_oob_stream / append_shell_actions_oob_stream…

Jump to symbol
function _triggers_shell_update

Whether this request should trigger shell OOB updates.

Jump to symbol
function resolve_oob_scope

Return the scope name for the current swap target, or None.

Boosted requests default to the broadest scope (Nonemeans "all scopes"). Non-boosted…

Jump to symbol
function compute_shell_region_updates

Compute shell OOB region updates for boosted/fragment requests.

Jump to symbol
function render_shell_actions_oob

Render shell action OOB markup for boosted layout navigations.

Jump to symbol
async function append_shell_actions_oob_stream

Append shell action OOB markup to the first streamed chunk.

Jump to symbol
function should_append_streamed_shell_actions_oob

Whether a streamed layout response should refresh shell actions via OOB.

Jump to symbol
function render_layout_oob_blocks

Render layout OOB blocks (sidebar, breadcrumbs, title) for boosted navigation.

Mirrors the OOB region logic inexecute_render_planbut works standalone for streaming responses (Suspense,…

Jump to symbol
class _KidaBlockAdapter

KidaAdapter with error handling for layout contract discovery.

Jump to symbol
function should_append_layout_oob

Whether a streamed layout response should append layout OOB blocks.

Jump to symbol
async function append_layout_oob_stream

Append layout OOB markup (sidebar, breadcrumbs, title) to the first chunk.

Jump to symbol
_render_off_loop
function async
async def _render_off_loop(fn: Callable[[], T]) -> T

Run a discrete, CPU-bound kida render off the event loop (issue #193).

The OOB streams chained onto aLayoutSuspenseresponse (append_layout_oob_stream / append_shell_actions_oob_stream) each render a complete batch of layout blocks via synchronous template.render_blockcalls. Running them inline on the loop would re-block the LayoutSuspense path even though the shell body and layout wrapping already render off-loop (see _render_off_loop(), which this mirrors).

The loop's contextvars are copied onto the worker soget_request()and the live CSP nonce (#181) stay visible inside template globals/filters during the render.

Parameters

Name Type Default Description
fn Callable[[], T]
_triggers_shell_update
function
def _triggers_shell_update(request: Request | None, fragment_target_registry: FragmentTargetRegistry | None) -> bool

Whether this request should trigger shell OOB updates.

Parameters

Name Type Default Description
request Request | None
fragment_target_registry FragmentTargetRegistry | None
resolve_oob_scope
function
def resolve_oob_scope(request: Request | None, fragment_target_registry: FragmentTargetRegistry | None) -> str | None

Return the scope name for the current swap target, or None.

Boosted requests default to the broadest scope (Nonemeans "all scopes"). Non-boosted fragment requests return the registered scope_nameso layout OOB blocks can be filtered to the matched scope and its ancestors.

Parameters

Name Type Default Description
request Request | None
fragment_target_registry FragmentTargetRegistry | None
compute_shell_region_updates
function
def compute_shell_region_updates(composition: PageComposition, request: Request | None, fragment_target_registry: FragmentTargetRegistry | None, shell_actions_renderer: ShellActionsRenderer | None = None) -> tuple[RegionUpdate, ...]

Compute shell OOB region updates for boosted/fragment requests.

Parameters

Name Type Default Description
composition PageComposition
request Request | None
fragment_target_registry FragmentTargetRegistry | None
shell_actions_renderer ShellActionsRenderer | None None
render_shell_actions_oob
function
def render_shell_actions_oob(context: dict[str, Any], kida_env: Environment, shell_actions_renderer: ShellActionsRenderer | None = None) -> str

Render shell action OOB markup for boosted layout navigations.

Parameters

Name Type Default Description
context dict[str, Any]
kida_env Environment
shell_actions_renderer ShellActionsRenderer | None None
append_shell_actions_oob_stream
function async
async def append_shell_actions_oob_stream(chunks: AsyncIterator[str], context: dict[str, Any], kida_env: Environment, shell_actions_renderer: ShellActionsRenderer | None = None) -> AsyncIterator[str]

Append shell action OOB markup to the first streamed chunk.

Parameters

Name Type Default Description
chunks AsyncIterator[str]
context dict[str, Any]
kida_env Environment
shell_actions_renderer ShellActionsRenderer | None None
should_append_streamed_shell_actions_oob
function
def should_append_streamed_shell_actions_oob(context: dict[str, Any], request: Request | None) -> bool

Whether a streamed layout response should refresh shell actions via OOB.

Parameters

Name Type Default Description
context dict[str, Any]
request Request | None
render_layout_oob_blocks
function
def render_layout_oob_blocks(kida_env: Environment, layout_chain: LayoutChain, context: dict[str, Any], oob_registry: OOBRegistry | None) -> str

Render layout OOB blocks (sidebar, breadcrumbs, title) for boosted navigation.

Mirrors the OOB region logic inexecute_render_planbut works standalone for streaming responses (Suspense, TemplateStream) that bypass the render plan pipeline.

Parameters

Name Type Default Description
kida_env Environment
layout_chain LayoutChain
context dict[str, Any]
oob_registry OOBRegistry | None
_KidaBlockAdapter
class

KidaAdapter with error handling for layout contract discovery.

should_append_layout_oob
function
def should_append_layout_oob(request: Request | None, layout_chain: LayoutChain | None) -> bool

Whether a streamed layout response should append layout OOB blocks.

Parameters

Name Type Default Description
request Request | None
layout_chain LayoutChain | None
append_layout_oob_stream
function async
async def append_layout_oob_stream(chunks: AsyncIterator[str], kida_env: Environment, layout_chain: LayoutChain, context: dict[str, Any], oob_registry: OOBRegistry | None) -> AsyncIterator[str]

Append layout OOB markup (sidebar, breadcrumbs, title) to the first chunk.

Parameters

Name Type Default Description
chunks AsyncIterator[str]
kida_env Environment
layout_chain LayoutChain
context dict[str, Any]
oob_registry OOBRegistry | None

View source · /home/runner/work/chirp/chirp/site/../src/chirp/server/negotiation_oob.py:1