cadrumo.entrypoints.tui.ledger.workspace_presentation module

Reusable Ledger workspace layout, focus, and confirmation mechanics.

ALLOWED_FLOW_TRANSITIONS: dict[LedgerFlowState, frozenset[LedgerFlowState]]

The legal moves of a confirmed Ledger flow, as a state a caller can read.

A state absent from this mapping is terminal and absorbing: SUCCEEDED, FAILED and CANCELLED admit no move at all, so a screen cannot be driven back into an editable state after its command has settled.

Two absences are the safety of the machine rather than gaps in it. EDITING cannot reach SUBMITTING, so nothing is written without passing the confirmation step; and SUBMITTING cannot reach CANCELLED, so a write already in flight cannot be abandoned — which is what LedgerConfirmationFlowScreen.action_back() refuses out loud.

Held here rather than rebuilt inside the transition method so the machine can be read and tested as the specification it is.

door_refusal_text(error)[source]

Render an application door’s typed refusal in the operator’s language.

Return type:

str

Parameters:

error (CadrumoError | ValidationError)

ledger_workspace_page()[source]

Compose the one scroll owner and canonical workspace navigation table.

Return type:

Generator[ContentDataTable[str]]

restore_transaction_focus(*, navigation, table, transaction_id)[source]

Focus a transaction by semantic identity or return focus to navigation.

Return type:

None

Parameters:
  • navigation (DataTable[str])

  • table (DataTable[str])

  • transaction_id (TransactionId | None)

class LedgerConfirmationFlowScreen(controller, *, id)[source]

Bases: LedgerWorkspaceScreen

Shared presentation state machine for confirmed, one-shot Ledger flows.

Parameters:
FLOW_NAME: ClassVar[str]
property flow_state: LedgerFlowState

Expose the guarded interaction state without a public setter.

refresh_after_write(then)[source]

Continue with then over a re-read workspace once this flow has written.

Only a settled write changes anything, so any other state continues at once over the snapshot already shown.

Return type:

None

Parameters:

then (Callable[[], object])

action_back()[source]

Refuse abandonment after submission; otherwise unwind confirmation.

Return type:

None

can_focus: bool

Widget may receive focus.

can_focus_children: bool

Widget’s children may receive focus.