cadrumo.entrypoints.tui.components.workspace_host module

The contract a root shell satisfies so a workspace can replace its own body.

A workspace destination is one screen pushed by the root, but the workspace itself is several screens: an overview plus the internal areas its navigation table lists. Moving between those areas is the workspace’s own concern, not the root’s – the root admits destinations and owns the return journey, and navigation states that it must not import a concrete destination screen.

That leaves the workspace holding the knowledge (its controller and its pure route resolver) and the root holding the capability (the screen stack). This module is the seam between them: the workspace resolves its own next body and hands the finished screen to whatever host it is running under, and the host swaps it without ever naming a workspace type.

The seam matters because there is more than one host. Production runs under the root shell; the development harness and the single-surface entry points run under a one-screen host that has no stack to swap. replace_workspace_body reports whether the swap happened so a screen under the simpler host degrades to its existing standalone behaviour instead of failing.

class WorkspaceBodyHostV1(*args, **kwargs)[source]

Bases: Protocol

A host that can replace the active workspace body with another screen.

replace_workspace_body(screen, /)[source]

Mount screen in place of the workspace body currently shown.

Return type:

None

Parameters:

screen (Screen[None])

replace_workspace_body(app, screen, /)[source]

Ask the running host to show screen as the workspace body.

Returns True when a host accepted the swap and False when the running host does not offer one. The boolean is the honest answer rather than a raised error: a screen opened standalone under the single-screen host has no body to replace, and that is a supported way to run a surface, not a defect.

Parameters:
  • app (App[object]) – The application the requesting screen is mounted under.

  • screen (Screen[None]) – The already-resolved replacement body.

Return type:

bool

Returns:

Whether the host performed the replacement.