cadrumo.entrypoints.tui.secret.credentials module

The shared credential-attempt host and password-assessment presentation.

CredentialScreen is the base every secret-entry surface builds on: it owns the bounded, thread-backed attempt lifecycle (start once, settle back on the UI task, refuse or leave) so LoginScreen and RegistrationScreen differ only in their form and their injected door, never in how an attempt is run or reported.

It is a screen rather than an application so a root shell can navigate to it: Textual does not nest applications, so an entry surface expressed as an application can only ever be the whole process. The outcome it used to return by exiting is now returned by dismissing, which is the same contract against a host that can be either the root shell or the standalone runner below.

The assessment helpers below project a canonical ProfilePasswordAssessment into presentation copy and CSS class – the strength banding policy itself stays with assess_profile_password(), which callers inject rather than import.

CREDENTIAL_PANEL_CSS: Final[str]

Layout shared by the login and registration credential panels.

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

Bases: Protocol, Generic

The secret-free result shape returned by an injected credential door.

property outcome: OutcomeT | None

Successful outcome, or None when the door refused.

property refusal: str | None

Safe rendered refusal, or None when no detail was supplied.

class CredentialScreen[source]

Bases: TypedAppAccess, Screen[OutcomeT | None], Generic

Host one bounded, thread-backed credential attempt at a time.

BINDINGS: ClassVar

A list of key bindings.

STATUS_ID: ClassVar[str]
ATTEMPT_NAME: ClassVar[str]
describe_appearance_key()[source]

Name the appearance key in the footer, in this screen’s language.

Bound here so a credential screen offers it before any workbench exists, and described at render time for the reason the workbench keys are: a class body resolves its text once, at import. Called again by a screen that changes its own language.

Return type:

None

credential_panel(*, panel_id)[source]

Compose the shared scrollable column that contains one credential form.

The caller owns its banner, status bar, fields, actions, and footer. This context manager owns only the stable nesting that makes each credential journey scroll and carry the common panel styling.

Return type:

Iterator[None]

Parameters:

panel_id (str)

property attempt_in_flight: bool

Whether a storage call is running and cannot be duplicated.

start_attempt(work)[source]

Run work off the event loop as this screen’s sole attempt.

Return type:

None

Parameters:

work (Callable[[], CredentialAttempt[OutcomeT]])

on_worker_state_changed(event)[source]

Settle the sole attempt back on Textual’s UI task.

Return type:

None

Parameters:

event (StateChanged)

output_locale()[source]

Return this screen’s explicit presentation locale, if it owns one.

Return type:

str | None

resolve_attempt_refusal(attempt)[source]

Render one door refusal at this screen’s presentation boundary.

Return type:

str | None

Parameters:

attempt (CredentialAttempt[OutcomeT])

default_refusal()[source]

Text shown when a refusal carries no message.

Return type:

str

refuse(message)[source]

Show one refusal without leaving, allowing an in-place retry.

Return type:

None

Parameters:

message (str)

set_busy(*, busy)[source]

Show progress and clear the previous refusal.

Return type:

None

Parameters:

busy (bool)

progress_message()[source]

Operator-facing description of the subclass’s in-flight attempt.

Return type:

str

leave(outcome)[source]

Close the screen and return its optional outcome to its host.

Return type:

None

Parameters:

outcome (OutcomeT | None)

action_abandon()[source]

Leave without a result unless storage work is still in flight.

Return type:

None

action_toggle_appearance()[source]

Switch the rendered terminal appearance.

Return type:

None

can_focus: bool

Widget may receive focus.

can_focus_children: bool

Widget’s children may receive focus.

run_credential_screen(screen)[source]

Run one credential screen standalone and return its optional outcome.

Return type:

Optional[TypeVar(OutcomeT)]

Parameters:

screen (CredentialScreen)

assessment_refusal(assessment)[source]

Project a canonical assessment through the application facade.

Return type:

ProspectiveProfilePasswordRefusal | None

Parameters:

assessment (ProfilePasswordAssessment)

assessment_copy(assessment, *, locale=None)[source]

Resolve localized validation or advisory copy for one assessment.

Return type:

str

Parameters:
assessment_css_class(assessment)[source]

Return the presentation class for a secret-free assessment.

Return type:

str

Parameters:

assessment (ProfilePasswordAssessment)